mirror of
https://github.com/tbamud/tbamud.git
synced 2026-04-02 10:27:19 +02:00
Remove DG scripts in favor of Python scripting
This commit is contained in:
parent
5273201d1b
commit
a1976f92dd
80 changed files with 4332 additions and 2430 deletions
|
|
@ -391,6 +391,8 @@ configure_file(
|
|||
)
|
||||
|
||||
|
||||
# ========== Python ==========
|
||||
find_package(Python3 3.12 REQUIRED COMPONENTS Development)
|
||||
|
||||
# ========== Source-filer ==========
|
||||
file(GLOB SRC_FILES src/*.c)
|
||||
|
|
@ -398,8 +400,9 @@ list(APPEND SRC_FILES third_party/tomlc99/toml.c)
|
|||
|
||||
# ========== Bygg kjørbar ==========
|
||||
add_executable(circle ${SRC_FILES})
|
||||
target_link_libraries(circle ${EXTRA_LIBS})
|
||||
target_link_libraries(circle ${EXTRA_LIBS} Python3::Python)
|
||||
target_include_directories(circle PRIVATE ${CMAKE_SOURCE_DIR}/third_party/tomlc99)
|
||||
target_include_directories(circle PRIVATE ${Python3_INCLUDE_DIRS})
|
||||
|
||||
add_subdirectory(src/util)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,3 +24,12 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
## Python 3.12 (CPython)
|
||||
|
||||
Copyright (c) 2001-2024 Python Software Foundation
|
||||
|
||||
Python Software Foundation License Version 2 (PSF-2.0)
|
||||
|
||||
This project embeds CPython and is subject to the PSF-2.0 license. See the
|
||||
Python source distribution or documentation for the full license text.
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ Changes in v1.3.0-alpha:
|
|||
* Migration away from OLC with new commands "qcreate", "qset", and "qsave" for builders to create quests
|
||||
* Updated mset, oset, and rset commands with missing parameters
|
||||
* Added NPC extra descriptions for future support
|
||||
* Introduced Python scripting as DG Scripts replacement, using "pylist" and storing scripts in lib/scripts
|
||||
|
||||
Features that will be implemented in the next few releases:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,301 +0,0 @@
|
|||
/*
|
||||
************************************************************************
|
||||
* File: events.doc *
|
||||
* *
|
||||
* Usage: An explanation of how to use mud events *
|
||||
* Written by Joseph Arnusch (Vatiken) (Joseph.Arnusch@gmail.com) *
|
||||
*
|
||||
* Usage: An explanation of how to use events *
|
||||
* Written by Eric Green (ejg3@cornell.edu) *
|
||||
************************************************************************
|
||||
*/
|
||||
|
||||
Vatiken's MUD event system
|
||||
--------------------------
|
||||
|
||||
Table of Contents
|
||||
-----------------
|
||||
1. Purpose
|
||||
2. Functions Related to MUD Events
|
||||
3. Steps to Create a New MUD Event
|
||||
4. Differences between the two systems
|
||||
|
||||
1. PURPOSE
|
||||
|
||||
I scribed a "MUD" event system using the "Death Gate Event" system already
|
||||
in place to allow for increased ease, and maintainability for both rookie
|
||||
and experienced programmers.
|
||||
|
||||
2. FUNCTIONS RELATED TO MUD EVENTS
|
||||
|
||||
a) See EVENTFUNC() in the Death Gate Events documentation below
|
||||
b) void init_events(void)
|
||||
"init_events()" creates the global events list and is the allocated location
|
||||
for placing any global events, these may include things like AI, Weather,
|
||||
and Combat.
|
||||
c) struct mud_event_data * char_has_mud_event(struct char_data * ch, event_id iId)
|
||||
"char_has_mud_event()" returns an event in the characters event list that matches
|
||||
the supplied "event_id", or NULL if none exists.
|
||||
d) NEW_EVENT(event_id, struct, var, time)
|
||||
"NEW_EVENT" creates a new event of the "event_id" type, with the supplied structure
|
||||
(ch, desc, object, etc..), any addtional "var"s, and is set to activate in
|
||||
this amount of "time".
|
||||
e) struct mud_event_list[]
|
||||
The mud_event_list[] is an array of all the events you've designed into your MUD.
|
||||
The reason for this excessive step is primarily for organization and troubleshooting,
|
||||
and it takes a mere couple seconds to add to mud_events.c.
|
||||
|
||||
3. STEPS TO CREATE A NEW MUD EVENT
|
||||
|
||||
a) Add the new event_id to enum list in mud_events.h
|
||||
|
||||
typedef enum {
|
||||
eNULL,
|
||||
ePROTOCOLS, /* The Protocol Detection Event */
|
||||
eWHIRLWIND, /* The Whirlwind Attack */
|
||||
|
||||
eNEWEVENT /* A NEW EVENT */
|
||||
} event_id;
|
||||
|
||||
b) Create the event
|
||||
|
||||
EVENTFUNC(new_event)
|
||||
{
|
||||
struct char_data *ch, *tch;
|
||||
struct mud_event_data *pMudEvent;
|
||||
struct list_data *room_list;
|
||||
int count;
|
||||
|
||||
/* This is just a dummy check, but we'll do it anyway */
|
||||
if (event_obj == NULL)
|
||||
return 0;
|
||||
|
||||
...
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
c) Add the event_id data to mud_event_list[]
|
||||
|
||||
struct mud_event_list mud_event_index[] = {
|
||||
{ "Null" , NULL , -1 }, /* eNULL */
|
||||
{ "Protocol" , get_protocols , EVENT_DESC }, /* ePROTOCOLS */
|
||||
{ "Whirlwind" , event_whirlwind, EVENT_CHAR } /* eWHIRLWIND */
|
||||
|
||||
{ "A New Event" , new_event , EVENT_CHAR } /* eNEWEVENT */
|
||||
};
|
||||
|
||||
d) Place a call for the new event
|
||||
|
||||
if (variableX > variableY)
|
||||
NEW_EVENT(eNEWEVENT, ch, NULL, 60 * PASSES_PER_SEC);
|
||||
|
||||
e) Sit back and enjoy your event triggering in 60 seconds.
|
||||
|
||||
4. DIFFERENCES BETWEEN THE TWO SYSTEMS
|
||||
|
||||
The biggest differences between the two systems is that the MUD Event System
|
||||
employs certain functions to make it more "dummy proof" without limiting
|
||||
functionality.
|
||||
|
||||
For example:
|
||||
a) all memory allocated for a MUD event will be freed when the event
|
||||
is no longer in use.
|
||||
b) the mud_event_index[] can/will log when events are called, allowing for an
|
||||
easy way to debug any problems.
|
||||
c) the mud_event structure allows for easy handling of memory that shouldn't
|
||||
be freed with the event like the character him/herself.
|
||||
d) when a character leaves the game, all mud_events will be cleared without
|
||||
manually having to place checks in free_char().
|
||||
|
||||
The "MUD Event" system should be adequate for 99% of all events that a developer
|
||||
may be interested in creating, and still allows access the dg_event event system
|
||||
for anything requiring more complicated procedures.
|
||||
|
||||
========================================================================
|
||||
|
||||
Death Gate Events
|
||||
|
||||
|
||||
Table of Contents
|
||||
-----------------
|
||||
1. Event Functions and Event Objects
|
||||
2. Functions for Manipulating Events
|
||||
3. Steps to Create a New Event Type
|
||||
4. An Example Event Type
|
||||
5. Tips for Create Events
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
1. Event Functions and Event Objects
|
||||
|
||||
|
||||
Each event type needs an:
|
||||
|
||||
Event function:
|
||||
|
||||
An event function is a function with a prototype of:
|
||||
|
||||
long (event_function)(void *event_obj)
|
||||
|
||||
This function is called when the event occurs, and is passed the event
|
||||
object (see below). If the function returns a positive value, the event
|
||||
is reenqueued using the return value as the number of pulses in the
|
||||
future the event will reoccur. If the function returns 0 or a negative
|
||||
number, the event is not reenqueued. If the event is not to be
|
||||
reenqueued, the event function is responsible for freeing the event
|
||||
object. There is a define:
|
||||
|
||||
#define EVENTFUNC(name) long (name)(void *event_obj)
|
||||
|
||||
to be used when declaring an event function.
|
||||
|
||||
Event object:
|
||||
|
||||
The event object is any structure with the fields to store any data
|
||||
needed by the event function. The event object should not be a game
|
||||
object (such as a struct char_data), since this object is freed when
|
||||
events are canceled (see cancel_event() below). All unique data
|
||||
contained by the object should be freed by a call of free(event_obj).
|
||||
In other words, don't have event_obj include pointers to other structures
|
||||
which aren't pointed to elsewhere. It is also not advisable to have
|
||||
pointers in the event object unless the thing they point to has a pointer
|
||||
to this event and cancels the event when it is freed. Passing NULL as an
|
||||
event object is valid (providing the event function doesn't need any
|
||||
data).
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
2. Functions for Manipulating Events
|
||||
|
||||
|
||||
The prototypes for the interface functions for events are provided in
|
||||
events.h. They are:
|
||||
|
||||
void event_init(void);
|
||||
This function initializes the event queue for all events. It is only
|
||||
called once, at the initialization of the game.
|
||||
|
||||
struct event *event_create(EVENTFUNC(*func), void *event_obj, long when);
|
||||
This function creates a new event. At the current time plus 'when',
|
||||
the function call
|
||||
|
||||
func(event_obj);
|
||||
|
||||
will be made. A pointer to the created event is returned. Never free()
|
||||
the event returned. Use event_cancel instead if you want to get rid of it
|
||||
prematurely.
|
||||
|
||||
void event_cancel(struct event *event);
|
||||
This function cancels an event currently in the queue. The event and the
|
||||
event_obj are freed by this call.
|
||||
|
||||
void event_process(void);
|
||||
This function is called once each pulse to process any pending events.
|
||||
It should not be used outside of the main loop.
|
||||
|
||||
long event_time(struct event *event);
|
||||
Given event, this function returns the number of pulses until the event
|
||||
occurs. One example of a place it is used is to get the pulses left before
|
||||
an object timer expires, so its current state can be saved and restored
|
||||
later.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
3. Steps to Create a New Event Type
|
||||
|
||||
To add a new event type, you do not need to know anything about what's in
|
||||
events.c, queue.c, or queue.h, the core of the event code. To create an
|
||||
event type:
|
||||
|
||||
1. Declare an event object structure.
|
||||
|
||||
2. Create your event function.
|
||||
|
||||
3. Construct your event object, and call event_create() where needed.
|
||||
|
||||
4. Any place that the 'owner' of the event can be destroyed, call
|
||||
event_cancel().
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
4. An Example Event Type
|
||||
|
||||
|
||||
Example event type:
|
||||
|
||||
/* the event object for the sniff event */
|
||||
struct sniff_event_obj {
|
||||
struct char_data *ch;
|
||||
byte type;
|
||||
};
|
||||
|
||||
|
||||
EVENTFUNC(sniff_event)
|
||||
{
|
||||
struct sniff_event_obj *seo = (struct sniff_event_obj *) event_obj;
|
||||
struct char_data *ch, *victim;
|
||||
|
||||
ch = seo->ch;
|
||||
|
||||
GET_CHAR_SNIFF(ch) = NULL;
|
||||
|
||||
if (type == SNIFF_COLD)
|
||||
act("$n sniffs loudly.", FALSE, ch, NULL, NULL, TO_ROOM);
|
||||
else
|
||||
act("$n sniffs some cocaine.", FALSE, ch, NULL, NULL, TO_ROOM);
|
||||
|
||||
act("You sniff.", FALSE, ch, NULL, NULL, TO_CHAR);
|
||||
|
||||
if (--seo->severity <= 0) {
|
||||
/* we're done with sniffing */
|
||||
free(event_obj);
|
||||
}
|
||||
else
|
||||
return PULSE_SNIFF;
|
||||
}
|
||||
|
||||
|
||||
ACMD(do_sniff)
|
||||
{
|
||||
struct sniff_event_obj *sniff;
|
||||
|
||||
CREATE(sniff, struct sniff_event_obj, 1);
|
||||
sniff->ch = ch;
|
||||
sniff->severity = 5;
|
||||
if (GET_CLASS(ch) != CLASS_THIEF)
|
||||
sniff->type = SNIFF_COLD;
|
||||
else
|
||||
sniff->type = SNIFF_COCAINE;
|
||||
|
||||
GET_CHAR_SNIFF(ch) = event_create(sniff_event, sniff, PULSE_SNIFF);
|
||||
|
||||
send_to_char(OK, ch);
|
||||
}
|
||||
|
||||
|
||||
void extract_char(struct char_data *ch)
|
||||
{
|
||||
|
||||
...
|
||||
|
||||
if (GET_CHAR_SNIFF(ch)) {
|
||||
event_cancel(GET_CHAR_SNIFF(ch));
|
||||
GET_CHAR_SNIFF(ch) = NULL;
|
||||
}
|
||||
|
||||
...
|
||||
}
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
5. Tips for Create Events
|
||||
|
||||
|
||||
Tips for creating events:
|
||||
|
||||
o event_obj should always be freed (or reused) in the EVENTFUNC()
|
||||
|
||||
o Any game object pointed to by event_obj should have a pointer to the
|
||||
the event so it can cancel the event if it is extracted.
|
||||
|
||||
o Any game object with pointers to an event should have the event pointer
|
||||
set to NULL in EVENTFUNC and immediately following event_cancel().
|
||||
|
||||
o Any place a game object is extracted from the game, any events it points to
|
||||
should be canceled and its pointer to the events set to NULL.
|
||||
162
lib/scripts/README.md
Normal file
162
lib/scripts/README.md
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
Scripts In lib/scripts
|
||||
======================
|
||||
|
||||
This directory contains Python and DSL-style scripts used by the game. Scripts
|
||||
are attached to rooms, npc's, and objects via builder commands (e.g. `rset add script`,
|
||||
`mset add script`, `oset add script`). The script file itself is the data format.
|
||||
|
||||
Two Script Styles
|
||||
-----------------
|
||||
|
||||
1) DSL (no function definitions)
|
||||
- If the file does NOT contain `def on_trigger`, it is treated as the DSL.
|
||||
- The DSL supports Python-style `if/elif/else`, `for`, and `while` blocks.
|
||||
- Actions are written as simple verbs or function-style calls:
|
||||
- `move("n")` or `move("north")`
|
||||
- `move(1200)` (room vnum path step, no closed doors)
|
||||
- `emote("looks around warily")`
|
||||
- `sleep(3)`
|
||||
- `log("text with {npc.vnum}")`
|
||||
- `do("say hello")`
|
||||
- Command-style is also supported:
|
||||
- `move "n"`
|
||||
- `sleep 3`
|
||||
- `log "hello {npc.vnum}"`
|
||||
- NOTE: The DSL does not support custom variable assignments yet. Use the
|
||||
full Python style if you need variables.
|
||||
|
||||
2) Full Python (with `def on_trigger(event):`)
|
||||
- If the file contains `def on_trigger`, it runs as normal Python.
|
||||
- Use `mud.sleep(seconds)` to pause and resume later.
|
||||
- You can use local variables, helpers, and full Python expressions.
|
||||
|
||||
Event Context (Full Python)
|
||||
---------------------------
|
||||
|
||||
`on_trigger(event)` receives a dict with:
|
||||
- `event["self"]`: the entity this trigger is attached to (mob/object/room)
|
||||
- `event["trigger"]`: info about the trigger (vnum, name, type, narg, etc.)
|
||||
- `event["vars"]`: trigger variables (if any)
|
||||
|
||||
Entity Data Model (DSL and Python)
|
||||
----------------------------------
|
||||
|
||||
Every entity has these common properties:
|
||||
- `entity.kind` -> kind id (mob/obj/room)
|
||||
- `entity.uid` -> unique runtime id
|
||||
- `entity.vnum` -> vnum (mob/obj/room)
|
||||
- `entity.name` -> name/short for display
|
||||
|
||||
Mob (NPC or PC) properties:
|
||||
- `npc.health` / `npc.max_health`
|
||||
- `npc.mana` / `npc.max_mana`
|
||||
- `npc.stamina` / `npc.max_stamina`
|
||||
- `npc.move` / `npc.max_move` (alias for stamina)
|
||||
- `npc.class` / `npc.class_id`
|
||||
- `npc.species` / `npc.species_id`
|
||||
- `npc.is_pc` / `npc.is_npc`
|
||||
- `npc.keyword` (NPC keywords; for PCs, name)
|
||||
- `npc.room` -> room entity where the mob is located
|
||||
- `npc.room.vnum` -> room vnum
|
||||
- `npc.room.name` -> room name/short
|
||||
|
||||
Object properties:
|
||||
- `object.keyword` -> object keywords
|
||||
- `object.oval` -> list of object values (oval[0] .. oval[NUM_OBJ_VAL_POSITIONS-1])
|
||||
- `object.room` -> room entity where the object is located
|
||||
- `object.room.vnum` -> room vnum
|
||||
- `object.room.name` -> room name/short
|
||||
|
||||
Room properties:
|
||||
- `room.contents` -> list of objects in the room
|
||||
- `room.people` -> list of characters in the room
|
||||
- `room.vnum` -> room vnum
|
||||
- `room.name` -> room name/short
|
||||
|
||||
Entity comparisons:
|
||||
- `entity == "rat"` checks keyword match for mobs/objects.
|
||||
- `entity == 123456` checks entity uid.
|
||||
- `entity_a == entity_b` matches if kind+uid are equal.
|
||||
|
||||
Available Methods
|
||||
-----------------
|
||||
|
||||
These are available in both DSL and Python (via the `mud` module).
|
||||
|
||||
Core methods:
|
||||
- `mud.do(command, actor=None)`
|
||||
Execute a game command. If `actor` is a mob, it runs as that mob. If `actor`
|
||||
is a room, it runs in that room context.
|
||||
- `mud.emote(message, actor=None)`
|
||||
Emote as a mob (actor is optional if the trigger is on a mob).
|
||||
- `mud.move(direction, actor=None)`
|
||||
Move a mob in a direction (e.g. "n", "south", "ne").
|
||||
You can also pass a room vnum to step toward a destination, but if it is blocked (eg. with a door), this will not work.
|
||||
- `mud.sleep(seconds)`
|
||||
Pause the script and resume later.
|
||||
- `mud.roll("1d6")`
|
||||
Roll dice. Supported: d4/d6/d8/d10/d12/d20/d100.
|
||||
- `mud.log(message)`
|
||||
Write to `log/script.log`.
|
||||
- `mud.echo_room(room, message)`
|
||||
Echo a message to a specific room.
|
||||
- `mud.send_char(character, message)`
|
||||
Send a message to a character.
|
||||
- `mud.call_later(seconds, func, *args, **kwargs)`
|
||||
Call a function later (Python scripts only).
|
||||
|
||||
Convenience names in full Python scripts:
|
||||
- `log("...")` is available as a shortcut for `mud.log(...)`.
|
||||
- Direction strings are available as `mud.n`, `mud.s`, `mud.e`, `mud.w`, etc.
|
||||
|
||||
Formatting / Expressions
|
||||
------------------------
|
||||
|
||||
DSL supports Python-style blocks:
|
||||
```
|
||||
while True:
|
||||
if npc.stamina < 20:
|
||||
rest
|
||||
else:
|
||||
stand
|
||||
```
|
||||
|
||||
DSL logging supports f-string style with braces:
|
||||
```
|
||||
log "rat {npc.vnum} in room {npc.room.vnum}"
|
||||
```
|
||||
|
||||
In full Python scripts, use normal f-strings:
|
||||
```
|
||||
log(f"rat {event['self'].vnum} in room {event['self'].room.vnum}")
|
||||
```
|
||||
|
||||
Variables (Full Python)
|
||||
-----------------------
|
||||
|
||||
Use normal Python variables:
|
||||
```
|
||||
def on_trigger(event):
|
||||
room = event["self"]
|
||||
count = 0
|
||||
while True:
|
||||
count += 1
|
||||
mud.echo_room(room, f"tick {count}")
|
||||
mud.sleep(30)
|
||||
```
|
||||
|
||||
The DSL currently does not support custom variable assignment. If you need
|
||||
variables, use full Python with `def on_trigger(event):`.
|
||||
|
||||
Best Practices
|
||||
--------------
|
||||
- Keep scripts small and focused.
|
||||
- Use `log(...)` during development and remove or reduce noise later.
|
||||
- Avoid infinite tight loops without `sleep`.
|
||||
- Use comments generously (`# ...`).
|
||||
- Prefer readable direction strings: `"north"`, `"west"`, etc.
|
||||
|
||||
Sample: Room Echo Script
|
||||
------------------------
|
||||
|
||||
See `sample_echo.py` in this directory for a ready-to-attach room script.
|
||||
14
lib/scripts/sample_echo.py
Normal file
14
lib/scripts/sample_echo.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Room echo script example (attach to a room trigger)
|
||||
|
||||
def on_trigger(event):
|
||||
# Room entity the script is attached to.
|
||||
room = event["self"]
|
||||
|
||||
while True:
|
||||
# Pick between two messages using a dice roll.
|
||||
if mud.roll("1d2") == 1:
|
||||
mud.echo_room(room, "someone spills a drink at the bar")
|
||||
else:
|
||||
mud.echo_room(room, "a game of cards gets rowdy as a dwarf slams a fist on a table")
|
||||
# Wait before the next echo.
|
||||
mud.sleep(60)
|
||||
26
lib/scripts/sample_fountain.py
Normal file
26
lib/scripts/sample_fountain.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Fountain refill script example (attach to an object trigger)
|
||||
|
||||
def on_trigger(event):
|
||||
# Object entity the script is attached to.
|
||||
fountain = event["self"]
|
||||
# Minimum refill amount per tick.
|
||||
refill_amount = 1
|
||||
|
||||
while True:
|
||||
# Ensure the fountain has object values to read.
|
||||
if fountain and fountain.oval:
|
||||
# oval[0] is capacity, oval[1] is current contents.
|
||||
capacity = fountain.oval[0]
|
||||
contains = fountain.oval[1]
|
||||
if capacity > 0 and contains < capacity:
|
||||
# Calculate the new fill amount without exceeding capacity.
|
||||
new_amount = contains + refill_amount
|
||||
if new_amount > capacity:
|
||||
new_amount = capacity
|
||||
# Update the fountain contents via osetval.
|
||||
mud.do(f"osetval 1 {new_amount}", actor=fountain)
|
||||
# Echo a drip message to the room when refilling.
|
||||
if fountain.room:
|
||||
mud.echo_room(fountain.room, f"water drips from the ceiling into {fountain.name}")
|
||||
# Wait before attempting another refill.
|
||||
mud.sleep(300)
|
||||
39
lib/scripts/sample_patrol.py
Normal file
39
lib/scripts/sample_patrol.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# NPC patrol script example (attach to a mob trigger)
|
||||
|
||||
# Track per-NPC patrol state by uid.
|
||||
patrol_state = {}
|
||||
# Ordered list of target room vnums for the patrol route.
|
||||
patrol_route = [103, 105, 153, 149, 100]
|
||||
|
||||
def on_trigger(event):
|
||||
# The mob this trigger is attached to.
|
||||
npc = event["self"]
|
||||
# Unique runtime id used to track this NPC's state.
|
||||
uid = npc.uid
|
||||
# Lookup or create state for this NPC.
|
||||
state = patrol_state.get(uid)
|
||||
if state is None:
|
||||
# Start at the first patrol target.
|
||||
state = {"target": 0}
|
||||
patrol_state[uid] = state
|
||||
|
||||
# Current target room vnum.
|
||||
target = patrol_route[state["target"]]
|
||||
|
||||
# If already at target, advance to the next.
|
||||
if npc.room.vnum == target:
|
||||
state["target"] = (state["target"] + 1) % len(patrol_route)
|
||||
target = patrol_route[state["target"]]
|
||||
|
||||
# Move one step toward the target room vnum.
|
||||
if not mud.move(target, actor=npc):
|
||||
mud.log(f"sample_patrol: no path to {target}", actor=npc)
|
||||
|
||||
# Optional flavor emotes at specific rooms.
|
||||
if npc.room.vnum == 153:
|
||||
mud.emote("looks around carefully", actor=npc)
|
||||
elif npc.room.vnum == 149:
|
||||
mud.emote("sniffs the air", actor=npc)
|
||||
|
||||
# Sleep to schedule the next patrol tick.
|
||||
mud.sleep(3)
|
||||
|
|
@ -434,6 +434,7 @@ flags = [8, 0, 0, 0]
|
|||
aff_flags = [0, 0, 0, 0]
|
||||
alignment = 0
|
||||
mob_type = "enhanced"
|
||||
triggers = [100]
|
||||
|
||||
[mob.simple]
|
||||
level = 1
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
[[room]]
|
||||
vnum = 100
|
||||
saved_at = 1759514843
|
||||
saved_at = 1769960339
|
||||
|
||||
[[room.mob]]
|
||||
vnum = 104
|
||||
|
||||
[[room.mob]]
|
||||
vnum = 100
|
||||
|
|
@ -285,3 +288,11 @@ contents = []
|
|||
vnum = 101
|
||||
saved_at = 1767296996
|
||||
|
||||
[[room]]
|
||||
vnum = 132
|
||||
saved_at = 1769720941
|
||||
|
||||
[[room]]
|
||||
vnum = 102
|
||||
saved_at = 1769960333
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,4 @@ attach_type = 0
|
|||
flags = 65536
|
||||
narg = 1
|
||||
arglist = ""
|
||||
commands = [
|
||||
"* No Script",
|
||||
]
|
||||
|
||||
script = ""
|
||||
|
|
|
|||
|
|
@ -1 +1,8 @@
|
|||
trigger = []
|
||||
[[trigger]]
|
||||
vnum = 100
|
||||
name = "sample_patrol.py"
|
||||
attach_type = 0
|
||||
flags = 8192
|
||||
narg = 100
|
||||
arglist = ""
|
||||
script = "sample_patrol.py"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
vnum = 100
|
||||
name = "Caravan Gate"
|
||||
description = " Two large doors, each at least ten feet in height, make up the massive gate\nset into the walls that surround the city. Made of agafari wood, mekillot hide,\nrusted old studs and iron hinges, they provide access into the city for\ntravelers and traders alike. A massive stone block sits off to the side of the\nroad, which seems to have been carved to the exact size and shape of the gate\nitself. Caravans and wagons can be seen passing through at all hours of the day\nwhen the gates are open, with some pausing just inside the gate to unload while\nothers continue on their way to the inner city.\n To the north and south, Wall Road continues onward. To the west, the main\nthoroughfare of Caravan Way passes by several buildings.\n"
|
||||
flags = [0, 0, 0, 0]
|
||||
flags = [32768, 0, 0, 0]
|
||||
sector = 1
|
||||
|
||||
[[room.exit]]
|
||||
|
|
@ -12,6 +12,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 146
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -19,6 +20,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 135
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -31,7 +33,7 @@ to_room = 101
|
|||
vnum = 101
|
||||
name = "Caravan Way"
|
||||
description = " This broad avenue is wide enough for several mounted riders to easily\nnavigate, or even a pair of wagons to pass by without incident. Buildings line\nthe road offering services to travelers and visitors of the city. Street\nvendors line the sides, with an occasional shout to draw attention to their\nwares. The route through the city itself is made up of brick, though several\nappear cracked and broken when given a thorough inspection.\n Caravan Way continues to the west and east. A placard with a stylized\neyeball, ear, and lips hangs as a standard above a building to the north,\nwhile the smell of a stable wafts from the south.\n"
|
||||
flags = [0, 0, 0, 0]
|
||||
flags = [32768, 0, 0, 0]
|
||||
sector = 0
|
||||
|
||||
[[room.exit]]
|
||||
|
|
@ -41,6 +43,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 131
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -48,6 +51,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 100
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -55,6 +59,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 136
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -67,7 +72,7 @@ to_room = 102
|
|||
vnum = 102
|
||||
name = "Caravan Way"
|
||||
description = " This broad avenue is wide enough for several mounted riders to easily\nnavigate, or even a pair of wagons to pass by without incident. Buildings line\nthe road offering services to travelers and visitors of the city. Street\nvendors line the sides, with an occasional shout to draw attention to their\nwares. The route through the city itself is made up of brick, though several\nappear cracked and broken when given a thorough inspection.\n Caravan Way continues to the west and east. To the south is a two-story\nbuilding with a sign hanging above the entrance of crossed swords.\n"
|
||||
flags = [0, 0, 0, 0]
|
||||
flags = [32768, 0, 0, 0]
|
||||
sector = 0
|
||||
|
||||
[[room.exit]]
|
||||
|
|
@ -77,6 +82,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 101
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -84,6 +90,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 132
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -96,7 +103,7 @@ to_room = 103
|
|||
vnum = 103
|
||||
name = "Caravan Way"
|
||||
description = " This broad avenue is wide enough for several mounted riders to easily\nnavigate, or even a pair of wagons to pass by without incident. Buildings line\nthe road offering services to travelers and visitors of the city. Street\nvendors line the sides, with an occasional shout to draw attention to their\nwares. The route through the city itself is made up of brick, though several\nappear cracked and broken when given a thorough inspection.\n Caravan Way continues to the north and east. To the south, a side street\npasses between some buildings.\n"
|
||||
flags = [0, 0, 0, 0]
|
||||
flags = [32768, 0, 0, 0]
|
||||
sector = 0
|
||||
|
||||
[[room.exit]]
|
||||
|
|
@ -106,6 +113,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 104
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -113,6 +121,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 102
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -135,6 +144,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 103
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -157,6 +167,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 155
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -164,6 +175,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 104
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -186,6 +198,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 105
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -208,6 +221,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 106
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -215,6 +229,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 108
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -237,6 +252,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 107
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -244,6 +260,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 134
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -266,6 +283,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 133
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -273,6 +291,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 108
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -295,6 +314,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 109
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -317,6 +337,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 122
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -324,6 +345,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 110
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -346,6 +368,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 111
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -353,6 +376,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 128
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -375,6 +399,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 123
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -382,6 +407,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 112
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -389,6 +415,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 160
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -411,6 +438,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 124
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -418,6 +446,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 113
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -440,6 +469,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 116
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -447,6 +477,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 114
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -469,6 +500,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 117
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -476,6 +508,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 115
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -498,6 +531,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 118
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -505,6 +539,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 125
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -512,6 +547,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 116
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -534,6 +570,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 182
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -541,6 +578,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 119
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -563,6 +601,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 120
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -585,6 +624,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 127
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -592,6 +632,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 121
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -599,6 +640,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 126
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -621,6 +663,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 198
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -628,6 +671,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 122
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -650,6 +694,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 121
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -782,7 +827,7 @@ to_room = 117
|
|||
vnum = 131
|
||||
name = "Draqoman Station"
|
||||
description = " This large building has a variety of tables and seats available in it, and\nseems to be a meeting point for those new to the city. The walls are lined with\nsconces to provide light throughout the evening, and barrels of water can be\nseen in the northern side of the room. Conversations can be heard in hushed\ntones, while others may be more boisterous as if between old friends. A crude\nmap of the city can be seen upon one wall, giving the impression this would be a\ngood place to learn more about where certain landmarks are.\n To the south lies Caravan Way, while to the east Wall Road can be seen.\n"
|
||||
flags = [131080, 0, 0, 0]
|
||||
flags = [163848, 0, 0, 0]
|
||||
sector = 0
|
||||
|
||||
[[room.exit]]
|
||||
|
|
@ -792,6 +837,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 146
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -804,7 +850,7 @@ to_room = 101
|
|||
vnum = 132
|
||||
name = "Grik's Weapons"
|
||||
description = " The walls of this building have been made out of uneven blocks of sandstone.\nPiled haphazardly on top of each other, they somehow remain stable despite\nlooking precarious and ready to fall anytime. Upon the walls are hooks that\nhave weapons placed on them, as well as trophies from gladiator tournaments. A\ncounter sits in the southwest corner of the room, and a stairway behind it leads\nupward to a trapdoor in the ceiling.\n Outside to the north lies Caravan Way.\n"
|
||||
flags = [0, 0, 0, 0]
|
||||
flags = [32776, 0, 0, 0]
|
||||
sector = 0
|
||||
|
||||
[[room.exit]]
|
||||
|
|
@ -829,6 +875,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 107
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -851,6 +898,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 108
|
||||
|
||||
[[room.exit]]
|
||||
dir = 4
|
||||
description = ""
|
||||
|
|
@ -863,7 +911,7 @@ to_room = 200
|
|||
vnum = 135
|
||||
name = "Wall Road"
|
||||
description = " Following along the walls of the city is a small road only large enough for a\npair of mounted riders to traverse side by side. The walls are thick and\nprimarily made of adobe brick, rising at least ten feet. The occasional figure\ncan be seen walking the walls, keeping an eye on the horizon. The buildings\nnear the gate are small and unassuming. Most have no windows and a simple\nwooden door.\n Wall Road continues to the south, while Caravan Gate can be seen to the \nnorth. To the west the smell of a stables wafts out onto the road.\n"
|
||||
flags = [0, 0, 0, 0]
|
||||
flags = [32768, 0, 0, 0]
|
||||
sector = 0
|
||||
|
||||
[[room.exit]]
|
||||
|
|
@ -873,6 +921,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 100
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -880,6 +929,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 137
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -892,7 +942,7 @@ to_room = 136
|
|||
vnum = 136
|
||||
name = "Messenger's Mount"
|
||||
description = " This two story building eminates a smell from the multitude of beasts within\nthat is all that is needed to knowing that this is a stable. Various pens have\nbeen set up here, holding kanks, erdlus, crodlus, and occasionally other more\nuncommon livestock. Traders and caravans come and go, leaving and retrieving\nmounts. Animal handlers can be seen moving about with food and water, as well\nas shoveling dung to be taken away.\n A small staircase is upon the southern wall and heads upward to the\nsecond floor. To the north lies Caravan Way, and to the east Wall Road can\nbe seen.\n"
|
||||
flags = [0, 0, 0, 0]
|
||||
flags = [32768, 0, 0, 0]
|
||||
sector = 0
|
||||
|
||||
[[room.exit]]
|
||||
|
|
@ -902,6 +952,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 101
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -914,7 +965,7 @@ to_room = 135
|
|||
vnum = 137
|
||||
name = "Wall Road"
|
||||
description = " Following along the walls of the city is a small road only large enough for a\npair of mounted riders to traverse side by side. The walls are thick and\nprimarily made of adobe brick, rising at least ten feet. The occasional figure\ncan be seen walking the walls, keeping an eye on the horizon. The buildings\nnear the gate are small and unassuming. Most have no windows and a simple\nwooden door.\n Wall Road continues to the north and south. Buildings rise up to the west,\nwhile the city walls are to the east.\n"
|
||||
flags = [0, 0, 0, 0]
|
||||
flags = [32768, 0, 0, 0]
|
||||
sector = 0
|
||||
|
||||
[[room.exit]]
|
||||
|
|
@ -924,6 +975,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 135
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -946,6 +998,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 137
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -968,6 +1021,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 138
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -990,6 +1044,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 139
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1012,6 +1067,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 140
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1034,6 +1090,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 143
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -1056,6 +1113,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 144
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1078,6 +1136,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 145
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1085,6 +1144,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 143
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1107,6 +1167,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 103
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1119,7 +1180,7 @@ to_room = 144
|
|||
vnum = 146
|
||||
name = "Wall Road"
|
||||
description = " Following along the walls of the city is a small road only large enough for a\npair of mounted riders to traverse side by side. The walls are thick and\nprimarily made of adobe brick, rising at least ten feet. The occasional figure\ncan be seen walking the walls, keeping an eye on the horizon. The buildings\nnear the gate are small and unassuming. Most have no windows and a simple\nwooden door.\n Wall Road continues to the north, while the Caravan Gate can be seen to\nthe south. A placard with a stylized eyeball, ears, and lips hangs as a\nstandard above a building to the west.\n"
|
||||
flags = [0, 0, 0, 0]
|
||||
flags = [32768, 0, 0, 0]
|
||||
sector = 0
|
||||
|
||||
[[room.exit]]
|
||||
|
|
@ -1129,6 +1190,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 147
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1136,6 +1198,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 100
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1148,7 +1211,7 @@ to_room = 131
|
|||
vnum = 147
|
||||
name = "Wall Road"
|
||||
description = " Following along the walls of the city is a small road only large enough for a\npair of mounted riders to traverse side by side. The walls are thick and\nprimarily made of adobe brick, rising at least ten feet. The occasional figure\ncan be seen walking the walls, keeping an eye on the horizon. The buildings\nnear the gate are small and unassuming. Most have no windows and a simple\nwooden door.\n Wall Road continues to the north and south. Buildings rise up to the west,\nwhile the city walls are to the east.\n"
|
||||
flags = [0, 0, 0, 0]
|
||||
flags = [32768, 0, 0, 0]
|
||||
sector = 0
|
||||
|
||||
[[room.exit]]
|
||||
|
|
@ -1158,6 +1221,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 148
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1180,6 +1244,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 149
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1202,6 +1267,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 148
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1224,6 +1290,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 149
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1231,6 +1298,7 @@ keyword = "door"
|
|||
exit_info = 1
|
||||
key = 0
|
||||
to_room = 157
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1253,6 +1321,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 150
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1275,6 +1344,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 151
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1282,6 +1352,7 @@ keyword = "door"
|
|||
exit_info = 9
|
||||
key = 0
|
||||
to_room = 156
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1304,6 +1375,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 152
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1326,6 +1398,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 153
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1333,6 +1406,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 155
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1355,6 +1429,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 154
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1452,6 +1527,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 115
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1474,6 +1550,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 163
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -1481,6 +1558,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 161
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1503,6 +1581,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 164
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1525,6 +1604,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 165
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1547,6 +1627,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 178
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1554,6 +1635,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 164
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1576,6 +1658,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 165
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1598,6 +1681,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 166
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1620,6 +1704,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 167
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1642,6 +1727,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 168
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1664,6 +1750,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 169
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1686,6 +1773,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 170
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1708,6 +1796,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 171
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1730,6 +1819,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 172
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -1752,6 +1842,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 175
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1774,6 +1865,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 176
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1796,6 +1888,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 177
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1818,6 +1911,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 162
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1840,6 +1934,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 179
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1862,6 +1957,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 180
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1869,6 +1965,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 178
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1891,6 +1988,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 181
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1913,6 +2011,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 183
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1920,6 +2019,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 182
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -1942,6 +2042,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 181
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1964,6 +2065,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 194
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -1986,6 +2088,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 179
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -2008,6 +2111,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 186
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -2015,6 +2119,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 184
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -2037,6 +2142,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 192
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -2044,6 +2150,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 193
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -2051,6 +2158,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 185
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -2073,6 +2181,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 191
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -2080,6 +2189,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 186
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -2087,6 +2197,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 188
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -2109,6 +2220,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 187
|
||||
|
||||
[[room.exit]]
|
||||
dir = 1
|
||||
description = ""
|
||||
|
|
@ -2116,6 +2228,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 185
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -2198,6 +2311,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 186
|
||||
|
||||
[[room.exit]]
|
||||
dir = 4
|
||||
description = "A trapdoor in the ceiling can be passed through by climbing a set of stairs.\n"
|
||||
|
|
@ -2220,6 +2334,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 195
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -2242,6 +2357,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 196
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -2264,6 +2380,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 199
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -2271,6 +2388,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 197
|
||||
|
||||
[[room.exit]]
|
||||
dir = 3
|
||||
description = ""
|
||||
|
|
@ -2293,6 +2411,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 196
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
@ -2315,6 +2434,7 @@ keyword = ""
|
|||
exit_info = 0
|
||||
key = 0
|
||||
to_room = 197
|
||||
|
||||
[[room.exit]]
|
||||
dir = 2
|
||||
description = ""
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ file(GLOB CIRCLE_SOURCES
|
|||
"*.c"
|
||||
)
|
||||
|
||||
list(FILTER CIRCLE_SOURCES EXCLUDE REGEX ".*/dg_.*\\.c$")
|
||||
|
||||
add_executable(circle ${CIRCLE_SOURCES})
|
||||
target_sources(circle PRIVATE ${CMAKE_SOURCE_DIR}/third_party/tomlc99/toml.c)
|
||||
target_include_directories(circle PRIVATE ${CMAKE_SOURCE_DIR}/third_party/tomlc99)
|
||||
|
|
|
|||
10
src/Makefile
10
src/Makefile
|
|
@ -17,11 +17,15 @@ PROFILE =
|
|||
|
||||
BINDIR = ../bin
|
||||
|
||||
CFLAGS = -g -O2 $(MYFLAGS) $(PROFILE) -I../third_party/tomlc99
|
||||
PYTHON_CONFIG ?= python3.12-config
|
||||
PY_CFLAGS := $(shell $(PYTHON_CONFIG) --includes 2>/dev/null | tr ' ' '\n' | awk '!seen[$$0]++' | tr '\n' ' ')
|
||||
PY_LIBS := $(shell $(PYTHON_CONFIG) --embed --ldflags 2>/dev/null)
|
||||
|
||||
LIBS = -lcrypt
|
||||
CFLAGS = -g -O2 $(MYFLAGS) $(PROFILE) -I../third_party/tomlc99 $(PY_CFLAGS)
|
||||
|
||||
SRCFILES := $(shell ls *.c | sort) ../third_party/tomlc99/toml.c
|
||||
LIBS = -lcrypt $(PY_LIBS)
|
||||
|
||||
SRCFILES := $(shell ls *.c | grep -v '^dg_' | sort) ../third_party/tomlc99/toml.c
|
||||
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
|
||||
|
||||
default: all
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ act.wizard.o: act.wizard.c conf.h sysdep.h structs.h utils.h comm.h \
|
|||
$(CC) -c $(CFLAGS) act.wizard.c
|
||||
set.o: set.c conf.h sysdep.h structs.h utils.h comm.h \
|
||||
interpreter.h handler.h db.h constants.h genolc.h genwld.h genzon.h \
|
||||
oasis.h improved-edit.h modify.h genobj.h dg_scripts.h set.h
|
||||
oasis.h improved-edit.h modify.h genobj.h set.h
|
||||
$(CC) -c $(CFLAGS) set.c
|
||||
ban.o: ban.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h
|
||||
$(CC) -c $(CFLAGS) ban.c
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ act.o.wizard: act.c.wizard h.conf h.sysdep h.structs \
|
|||
o.set: c.set h.conf h.sysdep h.structs \
|
||||
h.utils h.comm h.interpreter h.handler \
|
||||
h.db h.constants h.genobj h.genolc h.genwld h.genzon h.oasis \
|
||||
h.improved-edit h.modify h.dg_scripts h.set
|
||||
h.improved-edit h.modify h.set
|
||||
$(CC) -c $(CFLAGS) c.set -o o.set
|
||||
o.ban: c.ban h.conf h.sysdep h.structs h.utils h.comm h.interpreter h.handler h.db
|
||||
$(CC) -c $(CFLAGS) c.ban
|
||||
|
|
@ -159,7 +159,7 @@ o.weather: c.weather h.conf h.sysdep h.structs h.utils h.comm h.handler \
|
|||
h.interpreter h.db
|
||||
$(CC) -c $(CFLAGS) c.weather
|
||||
o.players: c.players h.conf h.sysdep h.structs h.utils h.db h.handler \
|
||||
h.pfdefaults h.dg_scripts h.comm h.interpreter h.genolc h.config h.spells
|
||||
h.pfdefaults h.comm h.interpreter h.genolc h.config h.spells
|
||||
$(CC) -c $(CFLAGS) c.players
|
||||
o.quest: c.quest h.conf h.sysdep h.structs h.utils h.interpreter h.handler \
|
||||
h.comm h.db h.screen h.quest
|
||||
|
|
|
|||
|
|
@ -16,11 +16,15 @@ PROFILE =
|
|||
|
||||
BINDIR = ../bin
|
||||
|
||||
CFLAGS = @CFLAGS@ $(MYFLAGS) $(PROFILE) -I../third_party/tomlc99
|
||||
PYTHON_CONFIG ?= python3.12-config
|
||||
PY_CFLAGS := $(shell $(PYTHON_CONFIG) --includes 2>/dev/null | tr ' ' '\n' | awk '!seen[$$0]++' | tr '\n' ' ')
|
||||
PY_LIBS := $(shell $(PYTHON_CONFIG) --embed --ldflags 2>/dev/null)
|
||||
|
||||
LIBS = @LIBS@ @CRYPTLIB@ @NETLIB@
|
||||
CFLAGS = @CFLAGS@ $(MYFLAGS) $(PROFILE) -I../third_party/tomlc99 $(PY_CFLAGS)
|
||||
|
||||
SRCFILES := $(shell ls *.c | sort) ../third_party/tomlc99/toml.c
|
||||
LIBS = @LIBS@ @CRYPTLIB@ @NETLIB@ $(PY_LIBS)
|
||||
|
||||
SRCFILES := $(shell ls *.c | grep -v '^dg_' | sort) ../third_party/tomlc99/toml.c
|
||||
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
|
||||
|
||||
default: all
|
||||
|
|
|
|||
|
|
@ -512,7 +512,6 @@ SET_C=\
|
|||
$(DISTDIR)\src\oasis.h\
|
||||
$(DISTDIR)\src\improved-edit.h\
|
||||
$(DISTDIR)\src\modify.h\
|
||||
$(DISTDIR)\src\dg_scripts.h\
|
||||
$(DISTDIR)\src\set.h\
|
||||
|
||||
set.obj: $(SET_C) $(DISTDIR)\src\set.c
|
||||
|
|
|
|||
|
|
@ -39,15 +39,14 @@ OBJFILES = comm.obj act.comm.obj act.informative.obj act.movement.obj act.item.o
|
|||
asciimap.obj act.offensive.obj act.other.obj act.social.obj act.wizard.obj \
|
||||
set.obj \
|
||||
ban.obj boards.obj castle.obj class.obj config.obj constants.obj db.obj \
|
||||
dg_event.obj dg_scripts.obj dg_triggers.obj fight.obj genolc.obj graph.obj \
|
||||
fight.obj genolc.obj graph.obj \
|
||||
handler.obj house.obj ibt.obj interpreter.obj limits.obj lists.obj magic.obj \
|
||||
mail.obj msgedit.obj mobact.obj modify.obj mud_event.obj oasis.obj oasis_copy.obj \
|
||||
oasis_delete.obj oasis_list.obj objsave.obj protocol.obj shop.obj spec_assign.obj \
|
||||
spec_procs.obj spell_parser.obj improved-edit.obj spells.obj utils.obj weather.obj \
|
||||
random.obj players.obj quest.obj qedit.obj genqst.obj aedit.obj cedit.obj hedit.obj \
|
||||
medit.obj oedit.obj qedit.obj redit.obj sedit.obj tedit.obj zedit.obj \
|
||||
dg_comm.obj dg_db_scripts.obj dg_handler.obj dg_misc.obj dg_mobcmd.obj dg_objcmd.obj \
|
||||
dg_olc.obj dg_variables.obj dg_wldcmd.obj genmob.obj genobj.obj genshp.obj genwld.obj \
|
||||
genmob.obj genobj.obj genshp.obj genwld.obj \
|
||||
genzon.obj prefedit.obj
|
||||
|
||||
default: circle.exe
|
||||
|
|
@ -86,7 +85,7 @@ act.wizard.obj: act.wizard.c conf.h sysdep.h structs.h utils.h comm.h \
|
|||
$(CC) -c $(CFLAGS) act.wizard.c
|
||||
set.obj: set.c conf.h sysdep.h structs.h utils.h comm.h \
|
||||
interpreter.h handler.h db.h constants.h genolc.h genwld.h genzon.h \
|
||||
oasis.h improved-edit.h modify.h genobj.h dg_scripts.h set.h
|
||||
oasis.h improved-edit.h modify.h genobj.h set.h
|
||||
$(CC) -c $(CFLAGS) set.c
|
||||
ban.obj: ban.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h
|
||||
$(CC) -c $(CFLAGS) ban.c
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ act.wizard.o: act.wizard.c conf.h sysdep.h structs.h utils.h comm.h \
|
|||
$(CC) -c $(CFLAGS) act.wizard.c
|
||||
set.o: set.c conf.h sysdep.h structs.h utils.h comm.h \
|
||||
interpreter.h handler.h db.h constants.h genolc.h genwld.h genzon.h \
|
||||
oasis.h improved-edit.h modify.h genobj.h dg_scripts.h set.h
|
||||
oasis.h improved-edit.h modify.h genobj.h set.h
|
||||
$(CC) -c $(CFLAGS) set.c
|
||||
ban.o: ban.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h
|
||||
$(CC) -c $(CFLAGS) ban.c
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ act.wizard.o: act.wizard.c conf.h sysdep.h structs.h utils.h comm.h \
|
|||
$(CC) $(CFLAGS) act.wizard.c
|
||||
set.o: set.c conf.h sysdep.h structs.h utils.h comm.h \
|
||||
interpreter.h handler.h db.h constants.h genolc.h genwld.h genzon.h \
|
||||
oasis.h improved-edit.h modify.h genobj.h dg_scripts.h set.h
|
||||
oasis.h improved-edit.h modify.h genobj.h set.h
|
||||
$(CC) $(CFLAGS) set.c
|
||||
ban.o: ban.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h
|
||||
$(CC) $(CFLAGS) ban.c
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#include "constants.h"
|
||||
#include "spells.h"
|
||||
#include "improved-edit.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "act.h"
|
||||
#include "modify.h"
|
||||
#include <ctype.h>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#include "spells.h"
|
||||
#include "screen.h"
|
||||
#include "constants.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "mud_event.h"
|
||||
#include "mail.h" /**< For the has_mail function */
|
||||
#include "act.h"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include "db.h"
|
||||
#include "spells.h"
|
||||
#include "constants.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "oasis.h"
|
||||
#include "act.h"
|
||||
#include "quest.h"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#include "spells.h"
|
||||
#include "house.h"
|
||||
#include "constants.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "act.h"
|
||||
#include "fight.h"
|
||||
#include "oasis.h" /* for buildwalk */
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#include "screen.h"
|
||||
#include "house.h"
|
||||
#include "constants.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "act.h"
|
||||
#include "spec_procs.h"
|
||||
#include "class.h"
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include "screen.h"
|
||||
#include "constants.h"
|
||||
#include "oasis.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "shop.h"
|
||||
#include "act.h"
|
||||
#include "genzon.h" /* for real_zone_by_thing */
|
||||
|
|
@ -355,13 +355,14 @@ static void stat_format_script_triggers(struct script_data *sc, char *buf, size_
|
|||
if (len)
|
||||
stat_appendf(buf, buf_size, &len, "\n");
|
||||
|
||||
stat_appendf(buf, buf_size, &len, "#%d %s (%s %s) narg=%d arg=%s",
|
||||
stat_appendf(buf, buf_size, &len, "#%d %s (%s %s) narg=%d arg=%s script=%s",
|
||||
GET_TRIG_VNUM(t),
|
||||
GET_TRIG_NAME(t),
|
||||
attach,
|
||||
type_buf,
|
||||
GET_TRIG_NARG(t),
|
||||
(GET_TRIG_ARG(t) && *GET_TRIG_ARG(t)) ? GET_TRIG_ARG(t) : "None");
|
||||
(GET_TRIG_ARG(t) && *GET_TRIG_ARG(t)) ? GET_TRIG_ARG(t) : "None",
|
||||
(t->script && *t->script) ? t->script : "None");
|
||||
|
||||
if (GET_TRIG_WAIT(t))
|
||||
stat_appendf(buf, buf_size, &len, " [wait]");
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#include "spells.h"
|
||||
#include "house.h"
|
||||
#include "constants.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "asciimap.h"
|
||||
|
||||
/******************************************************************************
|
||||
|
|
|
|||
|
|
@ -69,8 +69,9 @@
|
|||
#include "house.h"
|
||||
#include "oasis.h"
|
||||
#include "genolc.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "dg_event.h"
|
||||
#include "py_triggers.h"
|
||||
#include "py_event.h"
|
||||
#include "py_scripts.h"
|
||||
#include "screen.h" /* to support the gemote act type command */
|
||||
#include "constants.h" /* For mud versions */
|
||||
#include "boards.h"
|
||||
|
|
@ -513,6 +514,8 @@ static void init_game(ush_int local_port)
|
|||
/* set up hash table for find_char() */
|
||||
init_lookup_table();
|
||||
|
||||
python_scripts_init();
|
||||
|
||||
boot_db();
|
||||
|
||||
#if defined(CIRCLE_UNIX) || defined(CIRCLE_MACINTOSH)
|
||||
|
|
@ -530,6 +533,8 @@ static void init_game(ush_int local_port)
|
|||
|
||||
game_loop(mother_desc);
|
||||
|
||||
python_scripts_shutdown();
|
||||
|
||||
Crash_save_all();
|
||||
|
||||
log("Closing all sockets.");
|
||||
|
|
|
|||
46
src/db.c
46
src/db.c
|
|
@ -22,8 +22,8 @@
|
|||
#include "constants.h"
|
||||
#include "oasis.h"
|
||||
#include "species.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "dg_event.h"
|
||||
#include "py_triggers.h"
|
||||
#include "py_event.h"
|
||||
#include "act.h"
|
||||
#include "ban.h"
|
||||
#include "spec_procs.h"
|
||||
|
|
@ -1957,6 +1957,22 @@ static void parse_mobile_toml(toml_table_t *mob_tab)
|
|||
if (v.ok)
|
||||
add_proto_trigger(&mob_proto[i], MOB_TRIGGER, (int)v.u.i);
|
||||
}
|
||||
} else {
|
||||
toml_table_t *enh_tab = toml_table_in(mob_tab, "enhanced");
|
||||
toml_table_t *save_tab = NULL;
|
||||
if (enh_tab)
|
||||
save_tab = toml_table_in(enh_tab, "saving_throws");
|
||||
if (save_tab) {
|
||||
toml_array_t *tarr = toml_array_in(save_tab, "triggers");
|
||||
if (tarr) {
|
||||
int n = toml_array_nelem(tarr);
|
||||
for (j = 0; j < n; j++) {
|
||||
toml_datum_t v = toml_int_at(tarr, j);
|
||||
if (v.ok)
|
||||
add_proto_trigger(&mob_proto[i], MOB_TRIGGER, (int)v.u.i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mob_proto[i].aff_abils = mob_proto[i].real_abils;
|
||||
|
|
@ -2143,28 +2159,12 @@ static void parse_trigger_toml(toml_table_t *trig_tab)
|
|||
trig->trigger_type = (long)toml_get_int_default(trig_tab, "flags", 0);
|
||||
trig->narg = toml_get_int_default(trig_tab, "narg", 0);
|
||||
trig->arglist = toml_get_string_dup(trig_tab, "arglist");
|
||||
trig->script = toml_get_string_dup(trig_tab, "script");
|
||||
|
||||
arr = toml_array_in(trig_tab, "commands");
|
||||
if (arr) {
|
||||
n = toml_array_nelem(arr);
|
||||
for (i = 0; i < n; i++) {
|
||||
toml_datum_t v = toml_string_at(arr, i);
|
||||
if (!v.ok || !v.u.s)
|
||||
continue;
|
||||
if (!trig->cmdlist) {
|
||||
CREATE(trig->cmdlist, struct cmdlist_element, 1);
|
||||
trig->cmdlist->cmd = strdup(v.u.s);
|
||||
trig->cmdlist->next = NULL;
|
||||
cle = trig->cmdlist;
|
||||
} else {
|
||||
CREATE(cle->next, struct cmdlist_element, 1);
|
||||
cle = cle->next;
|
||||
cle->cmd = strdup(v.u.s);
|
||||
cle->next = NULL;
|
||||
}
|
||||
free(v.u.s);
|
||||
}
|
||||
}
|
||||
(void)arr;
|
||||
(void)i;
|
||||
(void)n;
|
||||
(void)cle;
|
||||
|
||||
trig_index[top_of_trigt++] = t_index;
|
||||
}
|
||||
|
|
|
|||
4
src/db.h
4
src/db.h
|
|
@ -35,6 +35,7 @@
|
|||
#define LIB_PLRVARS ":plrvars:"
|
||||
#define LIB_PLRFILES ":plrfiles:"
|
||||
#define LIB_ACCTFILES ":acctfiles:"
|
||||
#define LIB_SCRIPTS ":scripts:"
|
||||
#define LIB_HOUSE ":house:"
|
||||
#define SLASH ":"
|
||||
#elif defined(CIRCLE_AMIGA) || defined(CIRCLE_UNIX) || defined(CIRCLE_WINDOWS) || defined(CIRCLE_ACORN) || defined(CIRCLE_VMS)
|
||||
|
|
@ -49,6 +50,7 @@
|
|||
#define LIB_HOUSE "house/"
|
||||
#define LIB_PLRFILES "plrfiles/"
|
||||
#define LIB_ACCTFILES "acctfiles/"
|
||||
#define LIB_SCRIPTS "scripts/"
|
||||
#define SLASH "/"
|
||||
#else
|
||||
#error "Unknown path components."
|
||||
|
|
@ -85,6 +87,7 @@
|
|||
#define ZON_PREFIX LIB_WORLD"zon"SLASH /* zon defs & command tables */
|
||||
#define SHP_PREFIX LIB_WORLD"shp"SLASH /* shop definitions */
|
||||
#define TRG_PREFIX LIB_WORLD"trg"SLASH /* trigger files */
|
||||
#define SCRIPTS_PREFIX LIB_SCRIPTS /* python scripts */
|
||||
#define HLP_PREFIX LIB_TEXT"help"SLASH /* Help files */
|
||||
#define QST_PREFIX LIB_WORLD"qst"SLASH /* quest files */
|
||||
|
||||
|
|
@ -128,6 +131,7 @@
|
|||
#define BADPWS_LOGFILE PREFIX_LOGFILE"badpws"
|
||||
#define OLC_LOGFILE PREFIX_LOGFILE"olc"
|
||||
#define TRIGGER_LOGFILE PREFIX_LOGFILE"trigger"
|
||||
#define SCRIPT_LOGFILE "../log/script.log"
|
||||
/**/
|
||||
/* END: Assumed default locations for logfiles, mainly used in do_file. */
|
||||
|
||||
|
|
|
|||
1646
src/dg_variables.c
1646
src/dg_variables.c
File diff suppressed because it is too large
Load diff
|
|
@ -19,7 +19,7 @@
|
|||
#include "spells.h"
|
||||
#include "screen.h"
|
||||
#include "constants.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "act.h"
|
||||
#include "class.h"
|
||||
#include "fight.h"
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include "genolc.h"
|
||||
#include "genmob.h"
|
||||
#include "genzon.h"
|
||||
#include "dg_olc.h"
|
||||
#include "py_olc.h"
|
||||
#include "spells.h"
|
||||
#include "toml_utils.h"
|
||||
|
||||
|
|
@ -479,6 +479,9 @@ int write_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd)
|
|||
fprintf(fd, "alignment = %d\n", GET_ALIGNMENT(mob));
|
||||
toml_write_kv_string(fd, "mob_type", "enhanced");
|
||||
|
||||
/* --- DG Scripts --- */
|
||||
script_save_to_disk(fd, mob, MOB_TRIGGER);
|
||||
|
||||
fprintf(fd, "\n[mob.simple]\n");
|
||||
fprintf(fd, "level = %d\n", GET_LEVEL(mob));
|
||||
fprintf(fd, "hit_dice = %d\n", GET_HIT(mob));
|
||||
|
|
@ -527,9 +530,6 @@ int write_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd)
|
|||
fprintf(fd, "quantity = %d\n", MAX(1, e->quantity));
|
||||
}
|
||||
|
||||
/* --- DG Scripts --- */
|
||||
script_save_to_disk(fd, mob, MOB_TRIGGER);
|
||||
|
||||
/* --- Skinning yields --- */
|
||||
{
|
||||
mob_rnum rmob = real_mobile(mvnum);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include "genolc.h"
|
||||
#include "genobj.h"
|
||||
#include "genzon.h"
|
||||
#include "dg_olc.h"
|
||||
#include "py_olc.h"
|
||||
#include "handler.h"
|
||||
#include "interpreter.h"
|
||||
#include "boards.h" /* for board_info */
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#include "genshp.h"
|
||||
#include "genzon.h"
|
||||
#include "genobj.h"
|
||||
#include "dg_olc.h"
|
||||
#include "py_olc.h"
|
||||
#include "constants.h"
|
||||
#include "interpreter.h"
|
||||
#include "act.h" /* for the space_to_minus function */
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#include "genwld.h"
|
||||
#include "genzon.h"
|
||||
#include "shop.h"
|
||||
#include "dg_olc.h"
|
||||
#include "py_olc.h"
|
||||
#include "mud_event.h"
|
||||
#include "toml_utils.h"
|
||||
|
||||
|
|
@ -310,6 +310,8 @@ int save_rooms(zone_rnum rzone)
|
|||
room->room_flags[2], room->room_flags[3]);
|
||||
fprintf(sf, "sector = %d\n", room->sector_type);
|
||||
|
||||
script_save_to_disk(sf, room, WLD_TRIGGER);
|
||||
|
||||
/* Now you write out the exits for the room. */
|
||||
for (j = 0; j < DIR_COUNT; j++) {
|
||||
if (R_EXIT(room, j)) {
|
||||
|
|
@ -356,7 +358,6 @@ int save_rooms(zone_rnum rzone)
|
|||
fprintf(sf, "dc = %d\n", entry->dc);
|
||||
}
|
||||
}
|
||||
script_save_to_disk(sf, room, WLD_TRIGGER);
|
||||
fputc('\n', sf);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
#include "toml.h"
|
||||
#include "toml_utils.h"
|
||||
#include "genzon.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
|
||||
/* local functions */
|
||||
static void remove_cmd_from_list(struct reset_com **list, int pos);
|
||||
|
|
|
|||
57
src/graph.c
57
src/graph.c
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
/* local functions */
|
||||
static int VALID_EDGE(room_rnum x, int y);
|
||||
static int VALID_EDGE_NO_DOORS(room_rnum x, int y);
|
||||
static void bfs_enqueue(room_rnum room, int dir);
|
||||
static void bfs_dequeue(void);
|
||||
static void bfs_clear_queue(void);
|
||||
|
|
@ -56,6 +57,18 @@ static int VALID_EDGE(room_rnum x, int y)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int VALID_EDGE_NO_DOORS(room_rnum x, int y)
|
||||
{
|
||||
if (world[x].dir_option[y] == NULL || TOROOM(x, y) == NOWHERE)
|
||||
return 0;
|
||||
if (IS_CLOSED(x, y))
|
||||
return 0;
|
||||
if (ROOM_FLAGGED(TOROOM(x, y), ROOM_NOTRACK) || IS_MARKED(TOROOM(x, y)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void bfs_enqueue(room_rnum room, int dir)
|
||||
{
|
||||
struct bfs_queue_struct *curr;
|
||||
|
|
@ -137,6 +150,50 @@ static int find_first_step(room_rnum src, room_rnum target)
|
|||
return (BFS_NO_PATH);
|
||||
}
|
||||
|
||||
int find_first_step_no_doors(room_rnum src, room_rnum target)
|
||||
{
|
||||
int curr_dir;
|
||||
room_rnum curr_room;
|
||||
|
||||
if (src == NOWHERE || target == NOWHERE || src > top_of_world || target > top_of_world) {
|
||||
log("SYSERR: Illegal value %d or %d passed to find_first_step_no_doors. (%s)", src, target, __FILE__);
|
||||
return (BFS_ERROR);
|
||||
}
|
||||
if (src == target)
|
||||
return (BFS_ALREADY_THERE);
|
||||
|
||||
/* clear marks first, some OLC systems will save the mark. */
|
||||
for (curr_room = 0; curr_room <= top_of_world; curr_room++)
|
||||
UNMARK(curr_room);
|
||||
|
||||
MARK(src);
|
||||
|
||||
/* first, enqueue the first steps, saving which direction we're going. */
|
||||
for (curr_dir = 0; curr_dir < DIR_COUNT; curr_dir++)
|
||||
if (VALID_EDGE_NO_DOORS(src, curr_dir)) {
|
||||
MARK(TOROOM(src, curr_dir));
|
||||
bfs_enqueue(TOROOM(src, curr_dir), curr_dir);
|
||||
}
|
||||
|
||||
/* now, do the classic BFS. */
|
||||
while (queue_head) {
|
||||
if (queue_head->room == target) {
|
||||
curr_dir = queue_head->dir;
|
||||
bfs_clear_queue();
|
||||
return (curr_dir);
|
||||
} else {
|
||||
for (curr_dir = 0; curr_dir < DIR_COUNT; curr_dir++)
|
||||
if (VALID_EDGE_NO_DOORS(queue_head->room, curr_dir)) {
|
||||
MARK(TOROOM(queue_head->room, curr_dir));
|
||||
bfs_enqueue(TOROOM(queue_head->room, curr_dir), queue_head->dir);
|
||||
}
|
||||
bfs_dequeue();
|
||||
}
|
||||
}
|
||||
|
||||
return (BFS_NO_PATH);
|
||||
}
|
||||
|
||||
/* Functions and Commands which use the above functions. */
|
||||
ACMD(do_track)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,5 +16,6 @@
|
|||
|
||||
ACMD(do_track);
|
||||
void hunt_victim(struct char_data *ch);
|
||||
int find_first_step_no_doors(room_rnum src, room_rnum target);
|
||||
|
||||
#endif /* _GRAPH_H_*/
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include "screen.h"
|
||||
#include "interpreter.h"
|
||||
#include "spells.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "act.h"
|
||||
#include "class.h"
|
||||
#include "fight.h"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include "comm.h"
|
||||
#include "interpreter.h"
|
||||
#include "improved-edit.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "modify.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include "genolc.h"
|
||||
#include "oasis.h"
|
||||
#include "improved-edit.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "constants.h"
|
||||
#include "act.h" /* ACMDs located within the act*.c files */
|
||||
#include "ban.h"
|
||||
|
|
@ -334,6 +334,7 @@ cpp_extern const struct command_info cmd_info[] = {
|
|||
{ "trigedit" , "trigedit", POS_DEAD , do_oasis_trigedit, LVL_BUILDER, 0 },
|
||||
{ "typo" , "typo" , POS_DEAD , do_ibt , 0, SCMD_TYPO },
|
||||
{ "tlist" , "tlist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_TLIST },
|
||||
{ "pylist" , "pylist" , POS_DEAD , do_pylist , LVL_BUILDER, 0 },
|
||||
{ "tcopy" , "tcopy" , POS_DEAD , do_oasis_copy, LVL_GOD, CON_TRIGEDIT },
|
||||
{ "tstat" , "tstat" , POS_DEAD , do_tstat , LVL_BUILDER, 0 },
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include "db.h"
|
||||
#include "handler.h"
|
||||
#include "interpreter.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "class.h"
|
||||
#include "fight.h"
|
||||
#include "screen.h"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include "structs.h"
|
||||
#include "utils.h"
|
||||
#include "db.h"
|
||||
#include "dg_event.h"
|
||||
#include "py_event.h"
|
||||
|
||||
static struct iterator_data Iterator;
|
||||
static bool loop = FALSE;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include "db.h"
|
||||
#include "interpreter.h"
|
||||
#include "constants.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "class.h"
|
||||
#include "fight.h"
|
||||
#include "mud_event.h"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include "handler.h"
|
||||
#include "constants.h"
|
||||
#include "improved-edit.h"
|
||||
#include "dg_olc.h"
|
||||
#include "py_olc.h"
|
||||
#include "screen.h"
|
||||
#include "fight.h"
|
||||
#include "modify.h" /* for smash_tilde */
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include "improved-edit.h"
|
||||
#include "oasis.h"
|
||||
#include "class.h"
|
||||
#include "dg_scripts.h" /* for trigedit_string_cleanup */
|
||||
#include "py_triggers.h" /* for trigedit_string_cleanup */
|
||||
#include "modify.h"
|
||||
#include "quest.h"
|
||||
#include "ibt.h"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include "structs.h"
|
||||
#include "utils.h"
|
||||
#include "db.h"
|
||||
#include "dg_event.h"
|
||||
#include "py_event.h"
|
||||
#include "constants.h"
|
||||
#include "comm.h" /* For access to the game pulse */
|
||||
#include "mud_event.h"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#ifndef _MUD_EVENT_H_
|
||||
#define _MUD_EVENT_H_
|
||||
|
||||
#include "dg_event.h"
|
||||
#include "py_event.h"
|
||||
|
||||
#define EVENT_WORLD 0
|
||||
#define EVENT_DESC 1
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include "genobj.h"
|
||||
#include "oasis.h"
|
||||
#include "screen.h"
|
||||
#include "dg_olc.h"
|
||||
#include "py_olc.h"
|
||||
#include "act.h"
|
||||
#include "handler.h" /* for is_name */
|
||||
#include "quest.h"
|
||||
|
|
|
|||
|
|
@ -489,5 +489,6 @@ void print_zone(struct char_data *ch, zone_rnum rnum);
|
|||
/** @deprecated is do_oasis_links intentionally dead code? */
|
||||
ACMD(do_oasis_links);
|
||||
ACMD(do_oasis_list);
|
||||
ACMD(do_pylist);
|
||||
|
||||
#endif /* _OASIS_H_ */
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include "oasis.h"
|
||||
#include "improved-edit.h"
|
||||
#include "constants.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
|
||||
/* Local, filescope function prototypes */
|
||||
/* Utility function for buildwalk */
|
||||
|
|
|
|||
123
src/oasis_list.c
123
src/oasis_list.c
|
|
@ -8,6 +8,14 @@
|
|||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
#include "structs.h"
|
||||
#include "utils.h"
|
||||
#include "comm.h"
|
||||
|
|
@ -20,7 +28,7 @@
|
|||
#include "shop.h"
|
||||
#include "screen.h"
|
||||
#include "constants.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "quest.h"
|
||||
#include "modify.h"
|
||||
#include "spells.h"
|
||||
|
|
@ -38,6 +46,7 @@ static void list_mobiles(struct char_data *ch, zone_rnum rnum, mob_vnum vmin , m
|
|||
static void list_objects(struct char_data *ch, zone_rnum rnum, obj_vnum vmin , obj_vnum vmax );
|
||||
static void list_shops(struct char_data *ch , zone_rnum rnum, shop_vnum vmin, shop_vnum vmax);
|
||||
static void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zone_vnum vmax, char *name);
|
||||
static int pylist_name_cmp(const void *a, const void *b);
|
||||
|
||||
static void perform_mob_flag_list(struct char_data * ch, char *arg)
|
||||
{
|
||||
|
|
@ -358,6 +367,20 @@ static void perform_obj_name_list(struct char_data * ch, char *arg)
|
|||
page_string(ch->desc, buf, TRUE);
|
||||
}
|
||||
|
||||
static int pylist_name_cmp(const void *a, const void *b)
|
||||
{
|
||||
const char *left = *(const char *const *)a;
|
||||
const char *right = *(const char *const *)b;
|
||||
|
||||
if (!left && !right)
|
||||
return 0;
|
||||
if (!left)
|
||||
return -1;
|
||||
if (!right)
|
||||
return 1;
|
||||
return strcmp(left, right);
|
||||
}
|
||||
|
||||
/* Ingame Commands */
|
||||
ACMD(do_oasis_list)
|
||||
{
|
||||
|
|
@ -499,6 +522,94 @@ ACMD(do_oasis_list)
|
|||
}
|
||||
}
|
||||
|
||||
ACMD(do_pylist)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
struct stat st;
|
||||
char path[PATH_MAX];
|
||||
char **names = NULL;
|
||||
size_t count = 0;
|
||||
size_t capacity = 0;
|
||||
size_t i;
|
||||
size_t len = 0;
|
||||
size_t buf_size = 8192;
|
||||
char *buf;
|
||||
|
||||
if (!ch->desc)
|
||||
return;
|
||||
|
||||
dir = opendir(SCRIPTS_PREFIX);
|
||||
if (!dir) {
|
||||
send_to_char(ch, "Unable to open scripts directory (%s).\r\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
if (entry->d_name[0] == '.')
|
||||
continue;
|
||||
if (!str_cmp(entry->d_name, ".keep"))
|
||||
continue;
|
||||
if (!strstr(entry->d_name, ".py"))
|
||||
continue;
|
||||
|
||||
snprintf(path, sizeof(path), "%s%s", SCRIPTS_PREFIX, entry->d_name);
|
||||
if (stat(path, &st) < 0)
|
||||
continue;
|
||||
if (!S_ISREG(st.st_mode))
|
||||
continue;
|
||||
|
||||
if (capacity == count) {
|
||||
size_t new_cap = capacity ? (capacity * 2) : 32;
|
||||
RECREATE(names, char *, new_cap);
|
||||
capacity = new_cap;
|
||||
}
|
||||
|
||||
names[count++] = strdup(entry->d_name);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
if (count == 0) {
|
||||
send_to_char(ch, "No scripts found in %s.\r\n", SCRIPTS_PREFIX);
|
||||
return;
|
||||
}
|
||||
|
||||
qsort(names, count, sizeof(*names), pylist_name_cmp);
|
||||
|
||||
CREATE(buf, char, buf_size);
|
||||
len = snprintf(buf, buf_size,
|
||||
"Index Script Name\r\n"
|
||||
"----- ------------------------------\r\n");
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
char line[MAX_STRING_LENGTH];
|
||||
size_t line_len;
|
||||
|
||||
snprintf(line, sizeof(line), "%4zu) %s\r\n", i + 1, names[i]);
|
||||
line_len = strlen(line);
|
||||
|
||||
if (len + line_len + 1 > buf_size) {
|
||||
size_t new_size = buf_size;
|
||||
while (len + line_len + 1 > new_size)
|
||||
new_size *= 2;
|
||||
RECREATE(buf, char, new_size);
|
||||
buf_size = new_size;
|
||||
}
|
||||
|
||||
memcpy(buf + len, line, line_len + 1);
|
||||
len += line_len;
|
||||
}
|
||||
|
||||
page_string(ch->desc, buf, TRUE);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
if (names[i])
|
||||
free(names[i]);
|
||||
free(names);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
ACMD(do_oasis_links)
|
||||
{
|
||||
zone_rnum zrnum;
|
||||
|
|
@ -916,8 +1027,8 @@ static void list_triggers(struct char_data *ch, zone_rnum rnum, trig_vnum vmin,
|
|||
|
||||
/* Store the header for the room listing. */
|
||||
send_to_char (ch,
|
||||
"Index VNum Trigger Name Type\r\n"
|
||||
"----- ------- --------------------------------------------- ---------\r\n");
|
||||
"Index VNum Trigger Name Script Type\r\n"
|
||||
"----- ------- ----------------------------- ---------------------- ---------\r\n");
|
||||
|
||||
/* Loop through the world and find each room. */
|
||||
for (i = 0; i < top_of_trigt; i++) {
|
||||
|
|
@ -925,8 +1036,10 @@ static void list_triggers(struct char_data *ch, zone_rnum rnum, trig_vnum vmin,
|
|||
if ((trig_index[i]->vnum >= bottom) && (trig_index[i]->vnum <= top)) {
|
||||
counter++;
|
||||
|
||||
send_to_char(ch, "%4d) [%s%5d%s] %s%-45.45s%s ",
|
||||
counter, QGRN, trig_index[i]->vnum, QNRM, QCYN, trig_index[i]->proto->name, QNRM);
|
||||
send_to_char(ch, "%4d) [%s%5d%s] %s%-29.29s%s %-22.22s ",
|
||||
counter, QGRN, trig_index[i]->vnum, QNRM, QCYN,
|
||||
trig_index[i]->proto->name, QNRM,
|
||||
trig_index[i]->proto->script ? trig_index[i]->proto->script : "-");
|
||||
|
||||
if (trig_index[i]->proto->attach_type == OBJ_TRIGGER) {
|
||||
sprintbit(GET_TRIG_TYPE(trig_index[i]->proto), otrig_types, trgtypes, sizeof(trgtypes));
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include "genzon.h"
|
||||
#include "oasis.h"
|
||||
#include "improved-edit.h"
|
||||
#include "dg_olc.h"
|
||||
#include "py_olc.h"
|
||||
#include "fight.h"
|
||||
#include "modify.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@
|
|||
#include "db.h"
|
||||
#include "handler.h"
|
||||
#include "pfdefaults.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "comm.h"
|
||||
#include "interpreter.h"
|
||||
#include "genolc.h" /* for strip_cr */
|
||||
#include "config.h" /* for pclean_criteria[] */
|
||||
#include "dg_scripts.h" /* To enable saving of player variables to disk */
|
||||
#include "py_triggers.h" /* To enable saving of player variables to disk */
|
||||
#include "quest.h"
|
||||
#include "toml.h"
|
||||
#include "toml_utils.h"
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
#include "db.h"
|
||||
#include "screen.h"
|
||||
#include "improved-edit.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "act.h"
|
||||
#include "modify.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,13 @@
|
|||
/**************************************************************************
|
||||
* File: dg_comm.c Part of tbaMUD *
|
||||
* Usage: Contains routines to handle mud to player communication. *
|
||||
* *
|
||||
* All rights reserved. See license for complete information. *
|
||||
* *
|
||||
* Death's Gate MUD is based on CircleMUD, Copyright (C) 1993, 94. *
|
||||
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
|
||||
* *
|
||||
* $Author: Mark A. Heilpern/egreen/Welcor $ *
|
||||
* $Date: 2004/10/11 12:07:00$ *
|
||||
* $Revision: 1.0.14 $ *
|
||||
**************************************************************************/
|
||||
/**
|
||||
* @file py_comm.c
|
||||
*
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
#include "structs.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "utils.h"
|
||||
#include "comm.h"
|
||||
#include "handler.h"
|
||||
|
|
@ -1,25 +1,17 @@
|
|||
/**************************************************************************
|
||||
* File: dg_db_scripts.c Part of tbaMUD *
|
||||
* Usage: Contains routines to handle db functions for scripts and trigs. *
|
||||
* *
|
||||
* All rights reserved. See license for complete information. *
|
||||
* *
|
||||
* Death's Gate MUD is based on CircleMUD, Copyright (C) 1993, 94. *
|
||||
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
|
||||
* *
|
||||
* $Author: Mark A. Heilpern/egreen/Welcor $ *
|
||||
* $Date: 2004/10/11 12:07:00$ *
|
||||
* $Revision: 1.0.14 $ *
|
||||
**************************************************************************/
|
||||
/**
|
||||
* @file py_db_scripts.c
|
||||
*
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
#include "structs.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "utils.h"
|
||||
#include "db.h"
|
||||
#include "handler.h"
|
||||
#include "dg_event.h"
|
||||
#include "py_event.h"
|
||||
#include "comm.h"
|
||||
#include "constants.h"
|
||||
#include "interpreter.h" /* For half_chop */
|
||||
|
|
@ -97,6 +89,7 @@ static void trig_data_init(trig_data *this_data)
|
|||
this_data->data_type = 0;
|
||||
this_data->name = NULL;
|
||||
this_data->trigger_type = 0;
|
||||
this_data->script = NULL;
|
||||
this_data->cmdlist = NULL;
|
||||
this_data->curr_state = NULL;
|
||||
this_data->narg = 0;
|
||||
|
|
@ -123,6 +116,8 @@ void trig_data_copy(trig_data *this_data, const trig_data *trg)
|
|||
log("Trigger with no name! (%d)", trg->nr);
|
||||
}
|
||||
this_data->trigger_type = trg->trigger_type;
|
||||
if (trg->script)
|
||||
this_data->script = strdup(trg->script);
|
||||
this_data->cmdlist = trg->cmdlist;
|
||||
this_data->narg = trg->narg;
|
||||
if (trg->arglist) this_data->arglist = strdup(trg->arglist);
|
||||
|
|
@ -1,27 +1,15 @@
|
|||
/**
|
||||
* @file dg_event.c
|
||||
* This file contains a simplified event system to allow trigedit
|
||||
* to use the "wait" command, causing a delay in the middle of a script.
|
||||
* This system could easily be expanded by coders who wish to implement
|
||||
* an event driven mud.
|
||||
* @file py_event.c
|
||||
*
|
||||
* Part of the core tbaMUD source code distribution, which is a derivative
|
||||
* of, and continuation of, CircleMUD.
|
||||
*
|
||||
* This source code, which was not part of the CircleMUD legacy code,
|
||||
* was created by the following people:
|
||||
* $Author: Mark A. Heilpern/egreen/Welcor $
|
||||
* $Date: 2004/10/11 12:07:00$
|
||||
* $Revision: 1.0.14 $
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
#include "structs.h"
|
||||
#include "utils.h"
|
||||
#include "db.h"
|
||||
#include "dg_event.h"
|
||||
#include "py_event.h"
|
||||
#include "constants.h"
|
||||
#include "comm.h" /* For access to the game pulse */
|
||||
#include "mud_event.h"
|
||||
|
|
@ -1,21 +1,11 @@
|
|||
/**
|
||||
* @file dg_event.h
|
||||
* This file contains defines for the simplified event system to allow trigedit
|
||||
* to use the "wait" command, causing a delay in the middle of a script.
|
||||
* This system could easily be expanded by coders who wish to implement
|
||||
* an event driven mud.
|
||||
* @file py_event.h
|
||||
*
|
||||
* Part of the core tbaMUD source code distribution, which is a derivative
|
||||
* of, and continuation of, CircleMUD.
|
||||
*
|
||||
* This source code, which was not part of the CircleMUD legacy code,
|
||||
* is attributed to:
|
||||
* $Author: Mark A. Heilpern/egreen/Welcor $
|
||||
* $Date: 2004/10/11 12:07:00$
|
||||
* $Revision: 1.0.14 $
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
#ifndef _DG_EVENT_H_
|
||||
#define _DG_EVENT_H_
|
||||
|
||||
#ifndef _PY_EVENT_H_
|
||||
#define _PY_EVENT_H_
|
||||
|
||||
/** How often will heartbeat() call the 'wait' event function?
|
||||
* @deprecated Currently not used. */
|
||||
|
|
@ -80,4 +70,4 @@ long queue_elmt_key(struct q_element *qe);
|
|||
void queue_free(struct dg_queue *q);
|
||||
int event_is_queued(struct event *event);
|
||||
|
||||
#endif /* _DG_EVENT_H_ */
|
||||
#endif /* _PY_EVENT_H_ */
|
||||
|
|
@ -1,27 +1,19 @@
|
|||
/**************************************************************************
|
||||
* File: dg_handler.c Part of tbaMUD *
|
||||
* Usage: Contains functions to handle memory for scripts. *
|
||||
* *
|
||||
* All rights reserved. See license for complete information. *
|
||||
* *
|
||||
* Death's Gate MUD is based on CircleMUD, Copyright (C) 1993, 94. *
|
||||
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
|
||||
* *
|
||||
* $Author: Mark A. Heilpern/egreen/Welcor $ *
|
||||
* $Date: 2004/10/11 12:07:00$ *
|
||||
* $Revision: 1.0.14 $ *
|
||||
***************************************************************************/
|
||||
/**
|
||||
* @file py_handler.c
|
||||
*
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
#include "structs.h"
|
||||
#include "utils.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "comm.h"
|
||||
#include "db.h"
|
||||
#include "handler.h"
|
||||
#include "spells.h"
|
||||
#include "dg_event.h"
|
||||
#include "py_event.h"
|
||||
#include "constants.h"
|
||||
|
||||
/* frees memory associated with var */
|
||||
|
|
@ -76,6 +68,11 @@ void free_trigger(struct trig_data *trig)
|
|||
free(trig->name);
|
||||
trig->name = NULL;
|
||||
|
||||
if (trig->script) {
|
||||
free(trig->script);
|
||||
trig->script = NULL;
|
||||
}
|
||||
|
||||
if (trig->arglist) {
|
||||
free(trig->arglist);
|
||||
trig->arglist = NULL;
|
||||
|
|
@ -1,21 +1,18 @@
|
|||
/**************************************************************************
|
||||
* File: dg_misc.c Part of tbaMUD *
|
||||
* Usage: Contains general functions for script usage. *
|
||||
* *
|
||||
* $Author: Mark A. Heilpern/egreen/Welcor $ *
|
||||
* $Date: 2004/10/11 12:07:00$ *
|
||||
* $Revision: 1.0.14 $ *
|
||||
**************************************************************************/
|
||||
/**
|
||||
* @file py_misc.c
|
||||
*
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
#include "structs.h"
|
||||
#include "utils.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "comm.h"
|
||||
#include "interpreter.h"
|
||||
#include "handler.h"
|
||||
#include "dg_event.h"
|
||||
#include "py_event.h"
|
||||
#include "db.h"
|
||||
#include "screen.h"
|
||||
#include "spells.h"
|
||||
|
|
@ -26,6 +23,15 @@
|
|||
/* copied from spell_parser.c: */
|
||||
#define SINFO spell_info[spellnum]
|
||||
|
||||
struct room_data *dg_room_of_obj(struct obj_data *obj)
|
||||
{
|
||||
if (IN_ROOM(obj) != NOWHERE) return &world[IN_ROOM(obj)];
|
||||
if (obj->carried_by) return &world[IN_ROOM(obj->carried_by)];
|
||||
if (obj->worn_by) return &world[IN_ROOM(obj->worn_by)];
|
||||
if (obj->in_obj) return (dg_room_of_obj(obj->in_obj));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Cast a spell; can be called by mobiles, objects and rooms, and no level
|
||||
* check is required. Note that mobs should generally use the normal 'cast'
|
||||
|
|
@ -307,4 +313,3 @@ void script_damage(struct char_data *vict, int dam)
|
|||
die(vict, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,18 +1,15 @@
|
|||
/**************************************************************************
|
||||
* File: dg_mobcmd.c Part of tbaMUD *
|
||||
* Usage: Contains the mobile script commands. *
|
||||
* *
|
||||
* $Author: N'Atas-ha/Mark A. Heilpern/egreen/Welcor $ *
|
||||
* $Date: 2004/10/11 12:07:00$ *
|
||||
* $Revision: 1.0.14 $ *
|
||||
**************************************************************************/
|
||||
/**
|
||||
* @file py_mobcmd.c
|
||||
*
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
#include "structs.h"
|
||||
#include "utils.h"
|
||||
#include "screen.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "db.h"
|
||||
#include "handler.h"
|
||||
#include "interpreter.h"
|
||||
|
|
@ -1,17 +1,14 @@
|
|||
/**************************************************************************
|
||||
* File: dg_objcmd.c Part of tbaMUD *
|
||||
* Usage: Contains the command_interpreter for objects, object commands. *
|
||||
* *
|
||||
* $Author: galion/Mark A. Heilpern/egreen/Welcor $ *
|
||||
* $Date: 2004/10/11 12:07:00$ *
|
||||
* $Revision: 1.0.14 $ *
|
||||
**************************************************************************/
|
||||
/**
|
||||
* @file py_objcmd.c
|
||||
*
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
#include "structs.h"
|
||||
#include "screen.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "utils.h"
|
||||
#include "comm.h"
|
||||
#include "interpreter.h"
|
||||
|
|
@ -1,11 +1,8 @@
|
|||
/**************************************************************************
|
||||
* File: dg_olc.c Part of tbaMUD *
|
||||
* Usage: This source file is used in extending Oasis OLC for trigedit. *
|
||||
* *
|
||||
* $Author: Chris Jacobsen/Mark A. Heilpern/egreen/Welcor $ *
|
||||
* $Date: 2004/10/11 12:07:00$ *
|
||||
* $Revision: 1.0.14 $ *
|
||||
**************************************************************************/
|
||||
/**
|
||||
* @file py_olc.h
|
||||
*
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
|
|
@ -16,8 +13,8 @@
|
|||
#include "genolc.h"
|
||||
#include "interpreter.h"
|
||||
#include "oasis.h"
|
||||
#include "dg_olc.h"
|
||||
#include "dg_event.h"
|
||||
#include "py_olc.h"
|
||||
#include "py_event.h"
|
||||
#include "genzon.h" /* for real_zone_by_thing */
|
||||
#include "constants.h" /* for the *trig_types */
|
||||
#include "modify.h" /* for smash_tilde */
|
||||
|
|
@ -1,20 +1,13 @@
|
|||
/**
|
||||
* @file dg_olc.h
|
||||
* This source file is used in extending Oasis OLC for trigedit.
|
||||
* @file py_olc.c
|
||||
*
|
||||
* Part of the core tbaMUD source code distribution, which is a derivative
|
||||
* of, and continuation of, CircleMUD.
|
||||
*
|
||||
* This source code, which was not part of the CircleMUD legacy code,
|
||||
* was created by the following people:
|
||||
* $Author: Mark A. Heilpern/egreen/Welcor $
|
||||
* $Date: 2004/10/11 12:07:00$
|
||||
* $Revision: 1.0.14 $
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
#ifndef _DG_OLC_H_
|
||||
#define _DG_OLC_H_
|
||||
|
||||
#include "dg_scripts.h"
|
||||
#ifndef _PY_OLC_H_
|
||||
#define _PY_OLC_H_
|
||||
|
||||
#include "py_triggers.h"
|
||||
|
||||
#define NUM_TRIG_TYPE_FLAGS 21
|
||||
|
||||
|
|
@ -46,4 +39,4 @@ void dg_script_menu(struct descriptor_data *d);
|
|||
int dg_script_edit_parse(struct descriptor_data *d, char *arg);
|
||||
|
||||
|
||||
#endif /* _DG_OLC_H_ */
|
||||
#endif /* _PY_OLC_H_ */
|
||||
|
|
@ -1,26 +1,18 @@
|
|||
/**
|
||||
* @file dg_scripts.c
|
||||
* Contains the main script driver interface.
|
||||
* @file py_script_driver.c
|
||||
*
|
||||
* Part of the core tbaMUD source code distribution, which is a derivative
|
||||
* of, and continuation of, CircleMUD.
|
||||
*
|
||||
* This source code, which was not part of the CircleMUD legacy code,
|
||||
* was created by the following people:
|
||||
* $Author: Mark A. Heilpern/egreen/Welcor $
|
||||
* $Date: 2004/10/11 12:07:00$
|
||||
* $Revision: 1.0.14 $
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
#include "structs.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "utils.h"
|
||||
#include "comm.h"
|
||||
#include "interpreter.h"
|
||||
#include "handler.h"
|
||||
#include "dg_event.h"
|
||||
#include "py_event.h"
|
||||
#include "db.h"
|
||||
#include "screen.h"
|
||||
#include "constants.h"
|
||||
|
|
@ -31,6 +23,7 @@
|
|||
#include "modify.h"
|
||||
#include "toml.h"
|
||||
#include "toml_utils.h"
|
||||
#include "py_scripts.h"
|
||||
|
||||
#define PULSES_PER_MUD_HOUR (SECS_PER_MUD_HOUR*PASSES_PER_SEC)
|
||||
|
||||
|
|
@ -40,6 +33,7 @@ static room_data *find_room(long n);
|
|||
static void do_stat_trigger(struct char_data *ch, trig_data *trig);
|
||||
static void script_stat(char_data *ch, struct script_data *sc);
|
||||
static int remove_trigger(struct script_data *sc, char *name);
|
||||
#if 0 /* DG scripting language removed */
|
||||
static int is_num(char *arg);
|
||||
static void eval_op(char *op, char *lhs, char *rhs, char *result, void *go,
|
||||
struct script_data *sc, trig_data *trig);
|
||||
|
|
@ -73,9 +67,12 @@ static void dg_letter_value(struct script_data *sc, trig_data *trig, char *cmd);
|
|||
static struct cmdlist_element * find_case(struct trig_data *trig, struct cmdlist_element *cl,
|
||||
void *go, struct script_data *sc, int type, char *cond);
|
||||
static struct cmdlist_element *find_done(struct cmdlist_element *cl);
|
||||
#endif
|
||||
static struct char_data *find_char_by_uid_in_lookup_table(long uid);
|
||||
static struct obj_data *find_obj_by_uid_in_lookup_table(long uid);
|
||||
#if 0 /* DG scripting language removed */
|
||||
static EVENTFUNC(trig_wait_event);
|
||||
#endif
|
||||
|
||||
|
||||
/* Return pointer to first occurrence of string ct in cs, or NULL if not
|
||||
|
|
@ -708,6 +705,7 @@ void check_time_triggers(void)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0 /* DG scripting language removed */
|
||||
static EVENTFUNC(trig_wait_event)
|
||||
{
|
||||
struct wait_event_data *wait_event_obj = (struct wait_event_data *)event_obj;
|
||||
|
|
@ -756,10 +754,10 @@ static EVENTFUNC(trig_wait_event)
|
|||
/* Do not reenqueue*/
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void do_stat_trigger(struct char_data *ch, trig_data *trig)
|
||||
{
|
||||
struct cmdlist_element *cmd_list;
|
||||
char sb[MAX_STRING_LENGTH], buf[MAX_STRING_LENGTH];
|
||||
int len = 0;
|
||||
|
||||
|
|
@ -790,20 +788,8 @@ static void do_stat_trigger(struct char_data *ch, trig_data *trig)
|
|||
((GET_TRIG_ARG(trig) && *GET_TRIG_ARG(trig))
|
||||
? GET_TRIG_ARG(trig) : "None"));
|
||||
|
||||
len += snprintf(sb + len, sizeof(sb)-len, "Commands:\r\n");
|
||||
|
||||
cmd_list = trig->cmdlist;
|
||||
while (cmd_list) {
|
||||
if (cmd_list->cmd)
|
||||
len += snprintf(sb + len, sizeof(sb)-len, "%s\r\n", cmd_list->cmd);
|
||||
|
||||
if (len>MAX_STRING_LENGTH-80) {
|
||||
snprintf(sb + len, sizeof(sb)-len, "*** Overflow - script too long! ***\r\n");
|
||||
break;
|
||||
}
|
||||
|
||||
cmd_list = cmd_list->next;
|
||||
}
|
||||
len += snprintf(sb + len, sizeof(sb)-len, "Script: %s\r\n",
|
||||
(trig->script && *trig->script) ? trig->script : "None");
|
||||
|
||||
page_string(ch->desc, sb, 1);
|
||||
}
|
||||
|
|
@ -1357,6 +1343,7 @@ void script_log(const char *format, ...)
|
|||
va_end(args);
|
||||
}
|
||||
|
||||
#if 0 /* DG scripting language removed */
|
||||
/* Returns 1 if string is all digits, else 0. Bugfixed - would have returned
|
||||
* true on num="------". */
|
||||
static int is_num(char *arg)
|
||||
|
|
@ -1474,6 +1461,7 @@ static void eval_op(char *op, char *lhs, char *rhs, char *result, void *go,
|
|||
sprintf(result, "%d", !*rhs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* p points to the first quote, returns the matching end quote, or the last
|
||||
* non-null char in p.*/
|
||||
|
|
@ -1490,6 +1478,7 @@ char *matching_quote(char *p)
|
|||
return p;
|
||||
}
|
||||
|
||||
#if 0 /* DG scripting language removed */
|
||||
/* p points to the first paren. returns a pointer to the matching closing
|
||||
* paren, or the last non-null char in p. */
|
||||
static char *matching_paren(char *p)
|
||||
|
|
@ -2262,6 +2251,7 @@ ACMD(do_vdelete)
|
|||
|
||||
send_to_char(ch, "Deleted.\r\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Called from do_set - return 0 for failure, 1 for success. ch and vict are
|
||||
* verified. */
|
||||
|
|
@ -2282,6 +2272,7 @@ int perform_set_dg_var(struct char_data *ch, struct char_data *vict, char *val_a
|
|||
return 1;
|
||||
}
|
||||
|
||||
#if 0 /* DG scripting language removed */
|
||||
/* Delete a variable from the globals of another script.
|
||||
* 'rdelete <variable_name> <uid>' */
|
||||
static void process_rdelete(struct script_data *sc, trig_data *trig, char *cmd)
|
||||
|
|
@ -2465,6 +2456,7 @@ static void dg_letter_value(struct script_data *sc, trig_data *trig, char *cmd)
|
|||
*(junk+1) = '\0';
|
||||
add_var(&GET_TRIG_VARS(trig), varname, junk, sc->context);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This is the core driver for scripts.
|
||||
* Arguments:
|
||||
|
|
@ -2486,14 +2478,8 @@ int script_driver(void *go_adress, trig_data *trig, int type, int mode)
|
|||
{
|
||||
static int depth = 0;
|
||||
int ret_val = 1;
|
||||
struct cmdlist_element *cl;
|
||||
char cmd[MAX_INPUT_LENGTH], *p;
|
||||
struct script_data *sc = 0;
|
||||
struct cmdlist_element *temp;
|
||||
void *go = NULL;
|
||||
|
||||
void obj_command_interpreter(obj_data *obj, char *argument);
|
||||
void wld_command_interpreter(struct room_data *room, char *argument);
|
||||
struct script_data *sc = NULL;
|
||||
|
||||
switch (type) {
|
||||
case MOB_TRIGGER:
|
||||
|
|
@ -2542,178 +2528,23 @@ int script_driver(void *go_adress, trig_data *trig, int type, int mode)
|
|||
if (mode == TRIG_NEW) {
|
||||
GET_TRIG_DEPTH(trig) = 1;
|
||||
GET_TRIG_LOOPS(trig) = 0;
|
||||
sc->context = 0;
|
||||
if (sc)
|
||||
sc->context = 0;
|
||||
}
|
||||
|
||||
dg_owner_purged = 0;
|
||||
|
||||
for (cl = (mode == TRIG_NEW) ? trig->cmdlist : trig->curr_state;
|
||||
cl && GET_TRIG_DEPTH(trig); cl = cl->next) {
|
||||
for (p = cl->cmd; *p && isspace(*p); p++);
|
||||
ret_val = python_trigger_run(go, trig, type, mode);
|
||||
|
||||
if (*p == '*') /* comment */
|
||||
continue;
|
||||
|
||||
else if (!strn_cmp(p, "if ", 3)) {
|
||||
if (process_if(p + 3, go, sc, trig, type))
|
||||
GET_TRIG_DEPTH(trig)++;
|
||||
else
|
||||
cl = find_else_end(trig, cl, go, sc, type);
|
||||
}
|
||||
|
||||
else if (!strn_cmp("elseif ", p, 7) ||
|
||||
!strn_cmp("else", p, 4)) {
|
||||
/* If not in an if-block, ignore the extra 'else[if]' and warn about it. */
|
||||
if (GET_TRIG_DEPTH(trig) == 1) {
|
||||
script_log("Trigger VNum %d has 'else' without 'if'.",
|
||||
GET_TRIG_VNUM(trig));
|
||||
continue;
|
||||
}
|
||||
cl = find_end(trig, cl);
|
||||
GET_TRIG_DEPTH(trig)--;
|
||||
} else if (!strn_cmp("while ", p, 6)) {
|
||||
temp = find_done(cl);
|
||||
if (!temp) {
|
||||
script_log("Trigger VNum %d has 'while' without 'done'.",
|
||||
GET_TRIG_VNUM(trig));
|
||||
return ret_val;
|
||||
}
|
||||
if (process_if(p + 6, go, sc, trig, type)) {
|
||||
temp->original = cl;
|
||||
} else {
|
||||
cl->loops = 0;
|
||||
cl = temp;
|
||||
}
|
||||
} else if (!strn_cmp("switch ", p, 7)) {
|
||||
cl = find_case(trig, cl, go, sc, type, p + 7);
|
||||
} else if (!strn_cmp("end", p, 3)) {
|
||||
/* If not in an if-block, ignore the extra 'end' and warn about it. */
|
||||
if (GET_TRIG_DEPTH(trig) == 1) {
|
||||
script_log("Trigger VNum %d has 'end' without 'if'.",
|
||||
GET_TRIG_VNUM(trig));
|
||||
continue;
|
||||
}
|
||||
GET_TRIG_DEPTH(trig)--;
|
||||
} else if (!strn_cmp("done", p, 4)) {
|
||||
/* if in a while loop, cl->original is non-NULL */
|
||||
if (cl->original) {
|
||||
char *orig_cmd = cl->original->cmd;
|
||||
while (*orig_cmd && isspace(*orig_cmd)) orig_cmd++;
|
||||
if (cl->original && process_if(orig_cmd + 6, go, sc, trig,
|
||||
type)) {
|
||||
cl = cl->original;
|
||||
cl->loops++;
|
||||
GET_TRIG_LOOPS(trig)++;
|
||||
if (cl->loops == 30) {
|
||||
cl->loops = 0;
|
||||
process_wait(go, trig, type, "wait 1", cl);
|
||||
depth--;
|
||||
return ret_val;
|
||||
}
|
||||
if (GET_TRIG_LOOPS(trig) >= 100) {
|
||||
script_log("Trigger VNum %d has looped 100 times!!!",
|
||||
GET_TRIG_VNUM(trig));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* if we're falling through a switch statement, this ends it. */
|
||||
}
|
||||
}
|
||||
} else if (!strn_cmp("break", p, 5)) {
|
||||
cl = find_done(cl);
|
||||
} else if (!strn_cmp("case", p, 4)) {
|
||||
/* Do nothing, this allows multiple cases to a single instance */
|
||||
}
|
||||
|
||||
else {
|
||||
var_subst(go, sc, trig, type, p, cmd);
|
||||
|
||||
if (!strn_cmp(cmd, "eval ", 5))
|
||||
process_eval(go, sc, trig, type, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "nop ", 4)); /* nop: do nothing */
|
||||
|
||||
else if (!strn_cmp(cmd, "extract ", 8))
|
||||
extract_value(sc, trig, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "dg_letter ", 10))
|
||||
dg_letter_value(sc, trig, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "makeuid ", 8))
|
||||
makeuid_var(go, sc, trig, type, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "halt", 4))
|
||||
break;
|
||||
|
||||
else if (!strn_cmp(cmd, "dg_cast ", 8))
|
||||
do_dg_cast(go, sc, trig, type, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "dg_affect ", 10))
|
||||
do_dg_affect(go, sc, trig, type, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "global ", 7))
|
||||
process_global(sc, trig, cmd, sc->context);
|
||||
|
||||
else if (!strn_cmp(cmd, "context ", 8))
|
||||
process_context(sc, trig, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "remote ", 7))
|
||||
process_remote(sc, trig, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "rdelete ", 8))
|
||||
process_rdelete(sc, trig, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "return ", 7))
|
||||
ret_val = process_return(trig, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "set ", 4))
|
||||
process_set(sc, trig, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "unset ", 6))
|
||||
process_unset(sc, trig, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "wait ", 5)) {
|
||||
process_wait(go, trig, type, cmd, cl);
|
||||
depth--;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
else if (!strn_cmp(cmd, "attach ", 7))
|
||||
process_attach(go, sc, trig, type, cmd);
|
||||
|
||||
else if (!strn_cmp(cmd, "detach ", 7))
|
||||
process_detach(go, sc, trig, type, cmd);
|
||||
|
||||
else {
|
||||
switch (type) {
|
||||
case MOB_TRIGGER:
|
||||
if (!script_command_interpreter((char_data *) go, cmd))
|
||||
command_interpreter((char_data *) go, cmd);
|
||||
break;
|
||||
case OBJ_TRIGGER:
|
||||
obj_command_interpreter((obj_data *) go, cmd);
|
||||
break;
|
||||
case WLD_TRIGGER:
|
||||
wld_command_interpreter((struct room_data *) go, cmd);
|
||||
break;
|
||||
}
|
||||
if (dg_owner_purged) {
|
||||
depth--;
|
||||
if (type == OBJ_TRIGGER)
|
||||
*(obj_data **)go_adress = NULL;
|
||||
return ret_val;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dg_owner_purged) {
|
||||
depth--;
|
||||
if (type == OBJ_TRIGGER)
|
||||
*(obj_data **)go_adress = NULL;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
switch (type) { /* the script may have been detached */
|
||||
case MOB_TRIGGER: sc = SCRIPT((char_data *) go); break;
|
||||
case OBJ_TRIGGER: sc = SCRIPT((obj_data *) go); break;
|
||||
case WLD_TRIGGER: sc = SCRIPT((room_data *) go); break;
|
||||
}
|
||||
if (sc)
|
||||
free_varlist(GET_TRIG_VARS(trig));
|
||||
free_varlist(GET_TRIG_VARS(trig));
|
||||
GET_TRIG_VARS(trig) = NULL;
|
||||
GET_TRIG_DEPTH(trig) = 0;
|
||||
|
||||
|
|
@ -2764,6 +2595,95 @@ ACMD(do_tstat)
|
|||
send_to_char(ch, "Usage: tstat <vnum>\r\n");
|
||||
}
|
||||
|
||||
/* Command-line interface to rdelete. Named vdelete so people didn't think it
|
||||
* was to delete rooms. */
|
||||
ACMD(do_vdelete)
|
||||
{
|
||||
struct trig_var_data *vd, *vd_prev=NULL;
|
||||
struct script_data *sc_remote=NULL;
|
||||
char *var, *uid_p;
|
||||
char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH];
|
||||
long uid;
|
||||
room_data *room;
|
||||
char_data *mob;
|
||||
obj_data *obj;
|
||||
|
||||
two_arguments(argument, buf, buf2);
|
||||
var = buf;
|
||||
uid_p = buf2;
|
||||
skip_spaces(&var);
|
||||
skip_spaces(&uid_p);
|
||||
|
||||
|
||||
if (!*buf || !*buf2) {
|
||||
send_to_char(ch, "Usage: vdelete { <variablename> | * | all } <id>\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* find the target script from the uid number */
|
||||
uid = atoi(buf2);
|
||||
if (uid<=0) {
|
||||
send_to_char(ch, "vdelete: illegal id specified.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((room = find_room(uid))) {
|
||||
sc_remote = SCRIPT(room);
|
||||
} else if ((mob = find_char(uid))) {
|
||||
sc_remote = SCRIPT(mob);
|
||||
} else if ((obj = find_obj(uid))) {
|
||||
sc_remote = SCRIPT(obj);
|
||||
} else {
|
||||
send_to_char(ch, "vdelete: cannot resolve specified id.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sc_remote==NULL) {
|
||||
send_to_char(ch, "That id represents no global variables.(1)\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sc_remote->global_vars==NULL) {
|
||||
send_to_char(ch, "That id represents no global variables.(2)\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (*var == '*' || is_abbrev(var, "all")) {
|
||||
struct trig_var_data *vd_next;
|
||||
for (vd = sc_remote->global_vars; vd; vd = vd_next) {
|
||||
vd_next = vd->next;
|
||||
free(vd->value);
|
||||
free(vd->name);
|
||||
free(vd);
|
||||
}
|
||||
sc_remote->global_vars = NULL;
|
||||
send_to_char(ch, "All variables deleted from that id.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* find the global */
|
||||
for (vd = sc_remote->global_vars; vd; vd_prev = vd, vd = vd->next)
|
||||
if (!str_cmp(vd->name, var))
|
||||
break;
|
||||
|
||||
if (!vd) {
|
||||
send_to_char(ch, "That variable cannot be located.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* ok, delete the variable */
|
||||
if (vd_prev) vd_prev->next = vd->next;
|
||||
else sc_remote->global_vars = vd->next;
|
||||
|
||||
/* and free up the space */
|
||||
free(vd->value);
|
||||
free(vd->name);
|
||||
free(vd);
|
||||
|
||||
send_to_char(ch, "Deleted.\r\n");
|
||||
}
|
||||
|
||||
#if 0 /* DG scripting language removed */
|
||||
/* Scans for a case/default instance. Returns the line containg the correct
|
||||
* case instance, or the last line of the trigger if not found. */
|
||||
static struct cmdlist_element *
|
||||
|
|
@ -2822,6 +2742,7 @@ static struct cmdlist_element *find_done(struct cmdlist_element *cl)
|
|||
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* load in a character's saved variables */
|
||||
2594
src/py_scripts.c
Normal file
2594
src/py_scripts.c
Normal file
File diff suppressed because it is too large
Load diff
17
src/py_scripts.h
Normal file
17
src/py_scripts.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* @file py_scripts.h
|
||||
*
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
#ifndef _PY_SCRIPTS_H_
|
||||
#define _PY_SCRIPTS_H_
|
||||
|
||||
struct trig_data;
|
||||
|
||||
void python_scripts_init(void);
|
||||
void python_scripts_shutdown(void);
|
||||
int python_trigger_run(void *go, struct trig_data *trig, int type, int mode);
|
||||
void python_debug_log(const char *message);
|
||||
|
||||
#endif /* _PY_SCRIPTS_H_ */
|
||||
|
|
@ -1,21 +1,13 @@
|
|||
/**************************************************************************
|
||||
* File: dg_triggers.c part of tbaMUD *
|
||||
* Usage: Contains all the trigger functions for scripts. *
|
||||
* *
|
||||
* All rights reserved. See license for complete information. *
|
||||
* *
|
||||
* Death's Gate MUD is based on CircleMUD, Copyright (C) 1993, 94. *
|
||||
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
|
||||
* *
|
||||
* $Author: galion/Mark A. Heilpern/egreen/Welcor $ *
|
||||
* $Date: 2004/10/11 12:07:00$ *
|
||||
* $Revision: 1.0.14 $ *
|
||||
**************************************************************************/
|
||||
/**
|
||||
* @file py_triggers.c
|
||||
*
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
#include "structs.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "utils.h"
|
||||
#include "comm.h"
|
||||
#include "interpreter.h"
|
||||
|
|
@ -23,6 +15,7 @@
|
|||
#include "db.h"
|
||||
#include "oasis.h"
|
||||
#include "constants.h"
|
||||
#include "py_scripts.h"
|
||||
#include "spells.h" /* for skill_name() */
|
||||
#include "act.h" /* for cmd_door[] */
|
||||
|
||||
|
|
@ -510,12 +503,23 @@ void load_mtrigger(char_data *ch)
|
|||
trig_data *t;
|
||||
int result = 0;
|
||||
|
||||
if (!SCRIPT_CHECK(ch, MTRIG_LOAD))
|
||||
if (!SCRIPT_CHECK(ch, MTRIG_LOAD)) {
|
||||
if (ch && IS_NPC(ch)) {
|
||||
char buf[MAX_STRING_LENGTH];
|
||||
snprintf(buf, sizeof(buf), "load_mtrigger: no MTRIG_LOAD for %s [%d]", GET_SHORT(ch), GET_MOB_VNUM(ch));
|
||||
python_debug_log(buf);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
||||
if (TRIGGER_CHECK(t, MTRIG_LOAD) &&
|
||||
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
||||
if (ch && IS_NPC(ch)) {
|
||||
char buf[MAX_STRING_LENGTH];
|
||||
snprintf(buf, sizeof(buf), "load_mtrigger: firing trigger %d for %s [%d]", GET_TRIG_VNUM(t), GET_SHORT(ch), GET_MOB_VNUM(ch));
|
||||
python_debug_log(buf);
|
||||
}
|
||||
result = script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1,19 +1,10 @@
|
|||
/**
|
||||
* @file dg_scripts.h
|
||||
* Header file for script structures, constants, and function prototypes for
|
||||
* dg_scripts.c
|
||||
*
|
||||
* Part of the core tbaMUD source code distribution, which is a derivative
|
||||
* of, and continuation of, CircleMUD.
|
||||
*
|
||||
* This source code, which was not part of the CircleMUD legacy code,
|
||||
* was created by the following people:
|
||||
* $Author: Mark A. Heilpern/egreen/Welcor $
|
||||
* $Date: 2004/10/11 12:07:00$
|
||||
* $Revision: 1.0.14 $
|
||||
* @file py_triggers.h
|
||||
*
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
#ifndef _DG_SCRIPTS_H_
|
||||
#define _DG_SCRIPTS_H_
|
||||
#ifndef _PY_TRIGGERS_H_
|
||||
#define _PY_TRIGGERS_H_
|
||||
|
||||
#include "utils.h" /* To make sure ACMD is defined */
|
||||
|
||||
|
|
@ -154,6 +145,7 @@ struct trig_data {
|
|||
byte data_type; /**< type of game_data for trig */
|
||||
char *name; /**< name of trigger */
|
||||
long trigger_type; /**< type of trigger (for bitvector) */
|
||||
char *script; /**< python script path */
|
||||
struct cmdlist_element *cmdlist; /**< top of command list */
|
||||
struct cmdlist_element *curr_state; /**< ptr to current line of trigger */
|
||||
int narg; /**< numerical argument */
|
||||
|
|
@ -310,8 +302,6 @@ int trig_is_attached(struct script_data *sc, int trig_num);
|
|||
/* Thanks to Chris Gilbert for reminding me that there are other options. */
|
||||
int script_driver(void *go_adress, trig_data *trig, int type, int mode);
|
||||
trig_rnum real_trigger(trig_vnum vnum);
|
||||
void process_eval(void *go, struct script_data *sc, trig_data *trig,
|
||||
int type, char *cmd);
|
||||
void read_saved_vars(struct char_data *ch);
|
||||
void save_char_vars(struct char_data *ch);
|
||||
void init_lookup_table(void);
|
||||
|
|
@ -328,15 +318,6 @@ void assign_triggers(void *i, int type);
|
|||
|
||||
/* From dg_variables.c */
|
||||
void add_var(struct trig_var_data **var_list, const char *name, const char *value, long id);
|
||||
int item_in_list(char *item, obj_data *list);
|
||||
char *skill_percent(struct char_data *ch, char *skill);
|
||||
int char_has_item(char *item, struct char_data *ch);
|
||||
void var_subst(void *go, struct script_data *sc, trig_data *trig,
|
||||
int type, char *line, char *buf);
|
||||
int text_processed(char *field, char *subfield, struct trig_var_data *vd,
|
||||
char *str, size_t slen);
|
||||
void find_replacement(void *go, struct script_data *sc, trig_data *trig,
|
||||
int type, char *var, char *field, char *subfield, char *str, size_t slen);
|
||||
|
||||
/* From dg_handler.c */
|
||||
void free_var_el(struct trig_var_data *var);
|
||||
|
|
@ -456,4 +437,4 @@ extern int has_obj_by_uid_in_lookup_table(long uid);
|
|||
|
||||
#define room_script_id(room) ((long)(room)->number + ROOM_ID_BASE)
|
||||
|
||||
#endif /* _DG_SCRIPTS_H_ */
|
||||
#endif /* _PY_TRIGGERS_H_ */
|
||||
37
src/py_variables.c
Normal file
37
src/py_variables.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* @file py_variables.c
|
||||
*
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
#include "structs.h"
|
||||
#include "utils.h"
|
||||
#include "py_triggers.h"
|
||||
#include "db.h"
|
||||
|
||||
void add_var(struct trig_var_data **var_list, const char *name, const char *value, long id)
|
||||
{
|
||||
struct trig_var_data *vd;
|
||||
|
||||
if (!name || !*name)
|
||||
return;
|
||||
|
||||
for (vd = *var_list; vd; vd = vd->next) {
|
||||
if (!str_cmp(name, vd->name)) {
|
||||
if (vd->value)
|
||||
free(vd->value);
|
||||
vd->value = strdup(value ? value : "");
|
||||
vd->context = id;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CREATE(vd, struct trig_var_data, 1);
|
||||
vd->name = strdup(name);
|
||||
vd->value = strdup(value ? value : "");
|
||||
vd->context = id;
|
||||
vd->next = *var_list;
|
||||
*var_list = vd;
|
||||
}
|
||||
|
|
@ -1,17 +1,14 @@
|
|||
/**************************************************************************
|
||||
* File: dg_wldcmd.c Part of tbaMUD *
|
||||
* Usage: Contains the command_interpreter for rooms, room commands. *
|
||||
* *
|
||||
* $Author: galion/Mark A. Heilpern/egreen/Welcor $ *
|
||||
* $Date: 2004/10/11 12:07:00$ *
|
||||
* $Revision: 1.0.14 $ *
|
||||
**************************************************************************/
|
||||
/**
|
||||
* @file py_wldcmd.c
|
||||
*
|
||||
* This set of code was not originally part of the circlemud distribution.
|
||||
*/
|
||||
|
||||
#include "conf.h"
|
||||
#include "sysdep.h"
|
||||
#include "structs.h"
|
||||
#include "screen.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "utils.h"
|
||||
#include "comm.h"
|
||||
#include "interpreter.h"
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
#include "genzon.h"
|
||||
#include "oasis.h"
|
||||
#include "improved-edit.h"
|
||||
#include "dg_olc.h"
|
||||
#include "py_olc.h"
|
||||
#include "constants.h"
|
||||
#include "modify.h"
|
||||
|
||||
|
|
|
|||
773
src/set.c
773
src/set.c
|
|
@ -35,13 +35,407 @@
|
|||
#include "modify.h"
|
||||
#include "genobj.h"
|
||||
#include "genmob.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "fight.h"
|
||||
#include "toml.h"
|
||||
|
||||
#define PY_SCRIPT_EXT ".py"
|
||||
|
||||
static void script_toml_escape(const char *input, char *output, size_t outsz)
|
||||
{
|
||||
size_t len = 0;
|
||||
const char *p = input ? input : "";
|
||||
|
||||
if (!outsz)
|
||||
return;
|
||||
|
||||
while (*p && len + 2 < outsz) {
|
||||
if (*p == '\\' || *p == '"') {
|
||||
output[len++] = '\\';
|
||||
if (len + 1 >= outsz)
|
||||
break;
|
||||
}
|
||||
output[len++] = *p++;
|
||||
}
|
||||
|
||||
output[len] = '\0';
|
||||
}
|
||||
|
||||
static int script_normalize_name(const char *input, char *output, size_t outsz)
|
||||
{
|
||||
const char *ext;
|
||||
|
||||
if (!input || !*input || !output || outsz < 4)
|
||||
return 0;
|
||||
|
||||
if (strchr(input, '/'))
|
||||
return 0;
|
||||
|
||||
strlcpy(output, input, outsz);
|
||||
ext = strrchr(output, '.');
|
||||
if (!ext)
|
||||
strlcat(output, PY_SCRIPT_EXT, outsz);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int script_exists(const char *script_name)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
struct stat st;
|
||||
|
||||
if (!script_name || !*script_name)
|
||||
return 0;
|
||||
|
||||
snprintf(path, sizeof(path), "%s%s", SCRIPTS_PREFIX, script_name);
|
||||
if (stat(path, &st) < 0)
|
||||
return 0;
|
||||
|
||||
return S_ISREG(st.st_mode);
|
||||
}
|
||||
|
||||
static int script_find_trigger_by_script(const char *script, zone_rnum znum, int attach_type)
|
||||
{
|
||||
int i;
|
||||
int bottom, top;
|
||||
|
||||
if (!script || !*script)
|
||||
return NOTHING;
|
||||
|
||||
if (znum != NOWHERE) {
|
||||
bottom = zone_table[znum].bot;
|
||||
top = zone_table[znum].top;
|
||||
} else {
|
||||
bottom = INT_MIN;
|
||||
top = INT_MAX;
|
||||
}
|
||||
|
||||
for (i = 0; i < top_of_trigt; i++) {
|
||||
if (!trig_index[i] || !trig_index[i]->proto)
|
||||
continue;
|
||||
if (trig_index[i]->vnum < bottom || trig_index[i]->vnum > top)
|
||||
continue;
|
||||
if (trig_index[i]->proto->attach_type != attach_type)
|
||||
continue;
|
||||
if (!trig_index[i]->proto->script)
|
||||
continue;
|
||||
if (!str_cmp(trig_index[i]->proto->script, script))
|
||||
return trig_index[i]->vnum;
|
||||
}
|
||||
|
||||
return NOTHING;
|
||||
}
|
||||
|
||||
static int script_find_next_trigger_vnum(zone_rnum znum)
|
||||
{
|
||||
int vnum;
|
||||
int bottom;
|
||||
int top;
|
||||
|
||||
if (znum == NOWHERE)
|
||||
return NOTHING;
|
||||
|
||||
bottom = zone_table[znum].bot;
|
||||
top = zone_table[znum].top;
|
||||
|
||||
for (vnum = bottom; vnum <= top; vnum++) {
|
||||
if (real_trigger(vnum) == NOTHING)
|
||||
return vnum;
|
||||
}
|
||||
|
||||
return NOTHING;
|
||||
}
|
||||
|
||||
static int script_default_trigger_type(int attach_type)
|
||||
{
|
||||
switch (attach_type) {
|
||||
case MOB_TRIGGER: return MTRIG_LOAD;
|
||||
case OBJ_TRIGGER: return OTRIG_LOAD;
|
||||
case WLD_TRIGGER: return WTRIG_RESET;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int script_default_trigger_narg(int attach_type, long trigger_type)
|
||||
{
|
||||
if (attach_type == MOB_TRIGGER && (trigger_type & MTRIG_LOAD))
|
||||
return 100;
|
||||
if (attach_type == OBJ_TRIGGER && (trigger_type & OTRIG_LOAD))
|
||||
return 100;
|
||||
if (attach_type == WLD_TRIGGER && (trigger_type & WTRIG_RESET))
|
||||
return 100;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *script_default_trigger_name(const char *script)
|
||||
{
|
||||
const char *base;
|
||||
const char *dot;
|
||||
|
||||
if (!script || !*script)
|
||||
return "script";
|
||||
|
||||
base = script;
|
||||
dot = strrchr(base, '.');
|
||||
if (dot && dot > base)
|
||||
return base;
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
static int script_insert_trigger_index(trig_data *trig, int vnum)
|
||||
{
|
||||
struct index_data **new_index;
|
||||
struct trig_data *proto;
|
||||
struct trig_data *live_trig;
|
||||
trig_rnum i, rnum = NOTHING;
|
||||
|
||||
if (!trig || vnum <= 0)
|
||||
return NOTHING;
|
||||
|
||||
CREATE(new_index, struct index_data *, top_of_trigt + 1);
|
||||
|
||||
for (i = 0; i < top_of_trigt; i++) {
|
||||
if (rnum == NOTHING && trig_index[i]->vnum > vnum) {
|
||||
rnum = i;
|
||||
CREATE(new_index[rnum], struct index_data, 1);
|
||||
new_index[rnum]->vnum = vnum;
|
||||
new_index[rnum]->number = 0;
|
||||
new_index[rnum]->func = NULL;
|
||||
proto = trig;
|
||||
new_index[rnum]->proto = proto;
|
||||
proto->nr = rnum;
|
||||
new_index[i + 1] = trig_index[i];
|
||||
trig_index[i]->proto->nr = i + 1;
|
||||
} else {
|
||||
if (rnum == NOTHING) {
|
||||
new_index[i] = trig_index[i];
|
||||
} else {
|
||||
new_index[i + 1] = trig_index[i];
|
||||
trig_index[i]->proto->nr = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rnum == NOTHING) {
|
||||
rnum = top_of_trigt;
|
||||
CREATE(new_index[rnum], struct index_data, 1);
|
||||
new_index[rnum]->vnum = vnum;
|
||||
new_index[rnum]->number = 0;
|
||||
new_index[rnum]->func = NULL;
|
||||
proto = trig;
|
||||
new_index[rnum]->proto = proto;
|
||||
proto->nr = rnum;
|
||||
}
|
||||
|
||||
free(trig_index);
|
||||
trig_index = new_index;
|
||||
top_of_trigt++;
|
||||
|
||||
for (live_trig = trigger_list; live_trig; live_trig = live_trig->next_in_world)
|
||||
GET_TRIG_RNUM(live_trig) += (GET_TRIG_RNUM(live_trig) != NOTHING && GET_TRIG_RNUM(live_trig) >= rnum);
|
||||
|
||||
return rnum;
|
||||
}
|
||||
|
||||
static int script_append_trigger_toml(int znum, trig_data *trig, int vnum)
|
||||
{
|
||||
char fname[PATH_MAX];
|
||||
FILE *fp;
|
||||
char name_buf[MAX_INPUT_LENGTH];
|
||||
char arg_buf[MAX_INPUT_LENGTH];
|
||||
char script_buf[MAX_INPUT_LENGTH];
|
||||
|
||||
if (!trig || vnum <= 0)
|
||||
return 0;
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/%d.toml", TRG_PREFIX, znum);
|
||||
fp = fopen(fname, "a");
|
||||
if (!fp)
|
||||
return 0;
|
||||
|
||||
script_toml_escape(trig->name ? trig->name : "script", name_buf, sizeof(name_buf));
|
||||
script_toml_escape(trig->arglist ? trig->arglist : "", arg_buf, sizeof(arg_buf));
|
||||
script_toml_escape(trig->script ? trig->script : "", script_buf, sizeof(script_buf));
|
||||
|
||||
fprintf(fp, "\n[[trigger]]\n");
|
||||
fprintf(fp, "vnum = %d\n", vnum);
|
||||
fprintf(fp, "name = \"%s\"\n", name_buf);
|
||||
fprintf(fp, "attach_type = %d\n", trig->attach_type);
|
||||
fprintf(fp, "flags = %ld\n", trig->trigger_type);
|
||||
fprintf(fp, "narg = %d\n", trig->narg);
|
||||
fprintf(fp, "arglist = \"%s\"\n", arg_buf);
|
||||
fprintf(fp, "script = \"%s\"\n", script_buf);
|
||||
|
||||
fclose(fp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int script_create_trigger_for_zone(zone_rnum znum, int attach_type, const char *script)
|
||||
{
|
||||
trig_data *trig;
|
||||
int vnum;
|
||||
int rnum;
|
||||
|
||||
if (znum == NOWHERE || !script || !*script)
|
||||
return NOTHING;
|
||||
|
||||
vnum = script_find_next_trigger_vnum(znum);
|
||||
if (vnum == NOTHING)
|
||||
return NOTHING;
|
||||
|
||||
CREATE(trig, trig_data, 1);
|
||||
memset(trig, 0, sizeof(*trig));
|
||||
trig->name = strdup(script_default_trigger_name(script));
|
||||
trig->attach_type = (byte)attach_type;
|
||||
trig->trigger_type = (long)script_default_trigger_type(attach_type);
|
||||
trig->narg = script_default_trigger_narg(attach_type, trig->trigger_type);
|
||||
trig->arglist = strdup("");
|
||||
trig->script = strdup(script);
|
||||
|
||||
rnum = script_insert_trigger_index(trig, vnum);
|
||||
if (rnum == NOTHING) {
|
||||
if (trig->name)
|
||||
free(trig->name);
|
||||
if (trig->arglist)
|
||||
free(trig->arglist);
|
||||
if (trig->script)
|
||||
free(trig->script);
|
||||
free(trig);
|
||||
return NOTHING;
|
||||
}
|
||||
|
||||
if (!script_append_trigger_toml(zone_table[znum].number, trig, vnum))
|
||||
return NOTHING;
|
||||
|
||||
return vnum;
|
||||
}
|
||||
|
||||
static int script_resolve_trigger_vnum(struct char_data *ch, const char *arg,
|
||||
zone_rnum znum, int attach_type)
|
||||
{
|
||||
char script_name[MAX_INPUT_LENGTH];
|
||||
int vnum;
|
||||
|
||||
if (!arg || !*arg)
|
||||
return NOTHING;
|
||||
|
||||
if (is_number(arg))
|
||||
return atoi(arg);
|
||||
|
||||
if (!script_normalize_name(arg, script_name, sizeof(script_name))) {
|
||||
send_to_char(ch, "Script name is invalid.\r\n");
|
||||
return NOTHING;
|
||||
}
|
||||
|
||||
if (!script_exists(script_name)) {
|
||||
send_to_char(ch, "Script file %s not found.\r\n", script_name);
|
||||
return NOTHING;
|
||||
}
|
||||
|
||||
vnum = script_find_trigger_by_script(script_name, znum, attach_type);
|
||||
if (vnum != NOTHING)
|
||||
return vnum;
|
||||
|
||||
vnum = script_create_trigger_for_zone(znum, attach_type, script_name);
|
||||
if (vnum == NOTHING) {
|
||||
send_to_char(ch, "No available trigger vnums in this zone.\r\n");
|
||||
return NOTHING;
|
||||
}
|
||||
|
||||
send_to_char(ch, "Created trigger %d for script %s.\r\n", vnum, script_name);
|
||||
return vnum;
|
||||
}
|
||||
|
||||
static int script_find_attached_trigger_vnum(struct trig_proto_list *list,
|
||||
const char *script, int attach_type)
|
||||
{
|
||||
struct trig_proto_list *tp;
|
||||
int rnum;
|
||||
|
||||
if (!script || !*script)
|
||||
return NOTHING;
|
||||
|
||||
for (tp = list; tp; tp = tp->next) {
|
||||
rnum = real_trigger(tp->vnum);
|
||||
if (rnum == NOTHING || !trig_index[rnum] || !trig_index[rnum]->proto)
|
||||
continue;
|
||||
if (trig_index[rnum]->proto->attach_type != attach_type)
|
||||
continue;
|
||||
if (!trig_index[rnum]->proto->script)
|
||||
continue;
|
||||
if (!str_cmp(trig_index[rnum]->proto->script, script))
|
||||
return tp->vnum;
|
||||
}
|
||||
|
||||
return NOTHING;
|
||||
}
|
||||
#include "quest.h"
|
||||
|
||||
#include "set.h"
|
||||
|
||||
static int proto_trigger_has(struct trig_proto_list *list, int vnum)
|
||||
{
|
||||
for (; list; list = list->next)
|
||||
if (list->vnum == vnum)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int proto_trigger_add(struct trig_proto_list **list, int vnum)
|
||||
{
|
||||
struct trig_proto_list *trig, *tail;
|
||||
|
||||
if (!list)
|
||||
return 0;
|
||||
|
||||
if (proto_trigger_has(*list, vnum))
|
||||
return 0;
|
||||
|
||||
CREATE(trig, struct trig_proto_list, 1);
|
||||
trig->vnum = vnum;
|
||||
trig->next = NULL;
|
||||
|
||||
if (!*list) {
|
||||
*list = trig;
|
||||
return 1;
|
||||
}
|
||||
|
||||
tail = *list;
|
||||
while (tail->next)
|
||||
tail = tail->next;
|
||||
tail->next = trig;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int proto_trigger_remove(struct trig_proto_list **list, int vnum)
|
||||
{
|
||||
struct trig_proto_list *cur, *prev, *next;
|
||||
int removed = 0;
|
||||
|
||||
if (!list)
|
||||
return 0;
|
||||
|
||||
prev = NULL;
|
||||
cur = *list;
|
||||
while (cur) {
|
||||
next = cur->next;
|
||||
if (cur->vnum == vnum) {
|
||||
if (prev)
|
||||
prev->next = next;
|
||||
else
|
||||
*list = next;
|
||||
free(cur);
|
||||
removed = 1;
|
||||
} else {
|
||||
prev = cur;
|
||||
}
|
||||
cur = next;
|
||||
}
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
static void rset_show_usage(struct char_data *ch)
|
||||
{
|
||||
send_to_char(ch,
|
||||
|
|
@ -58,6 +452,7 @@ static void rset_show_usage(struct char_data *ch)
|
|||
" rset add hidden <direction>\r\n"
|
||||
" rset add forage <object vnum> <dc check>\r\n"
|
||||
" rset add edesc <keyword> <description>\r\n"
|
||||
" rset add script <script name>\r\n"
|
||||
" rset add desc\r\n"
|
||||
" rset del <field>\r\n"
|
||||
" rset clear force\r\n"
|
||||
|
|
@ -110,6 +505,7 @@ static void rset_show_add_usage(struct char_data *ch)
|
|||
" rset add hidden <direction>\r\n"
|
||||
" rset add forage <object vnum> <dc check>\r\n"
|
||||
" rset add edesc <keyword> <description>\r\n"
|
||||
" rset add script <script name>\r\n"
|
||||
" rset add desc\r\n");
|
||||
}
|
||||
|
||||
|
|
@ -128,6 +524,7 @@ static void rset_show_del_usage(struct char_data *ch)
|
|||
" rset del hidden <direction>\r\n"
|
||||
" rset del forage <object vnum>\r\n"
|
||||
" rset del edesc <keyword>\r\n"
|
||||
" rset del script <script name>\r\n"
|
||||
"\r\n"
|
||||
"Examples:\r\n"
|
||||
" rset del flags INDOORS QUITSAFE\r\n"
|
||||
|
|
@ -136,7 +533,8 @@ static void rset_show_del_usage(struct char_data *ch)
|
|||
" rset del key n\r\n"
|
||||
" rset del hidden n\r\n"
|
||||
" rset del forage 301\r\n"
|
||||
" rset del edesc mosaic\r\n");
|
||||
" rset del edesc mosaic\r\n"
|
||||
" rset del script rat_patrol.py\r\n");
|
||||
}
|
||||
|
||||
static void rset_show_validate_usage(struct char_data *ch)
|
||||
|
|
@ -748,6 +1146,8 @@ ACMD(do_rset)
|
|||
char arg3[MAX_INPUT_LENGTH];
|
||||
struct room_data *room;
|
||||
room_rnum rnum;
|
||||
trig_data *trig;
|
||||
int tn, rn;
|
||||
|
||||
if (IS_NPC(ch) || ch->desc == NULL) {
|
||||
send_to_char(ch, "rset is only usable by connected players.\r\n");
|
||||
|
|
@ -1169,6 +1569,43 @@ ACMD(do_rset)
|
|||
return;
|
||||
}
|
||||
|
||||
if (is_abbrev(arg2, "script")) {
|
||||
argument = one_argument(argument, arg3);
|
||||
if (!*arg3) {
|
||||
rset_show_add_usage(ch);
|
||||
return;
|
||||
}
|
||||
|
||||
tn = script_resolve_trigger_vnum(ch, arg3, room->zone, WLD_TRIGGER);
|
||||
if (tn == NOTHING)
|
||||
return;
|
||||
rn = real_trigger(tn);
|
||||
if (rn == NOTHING || trig_index[rn] == NULL || trig_index[rn]->proto == NULL) {
|
||||
send_to_char(ch, "That trigger does not exist.\r\n");
|
||||
return;
|
||||
}
|
||||
trig = trig_index[rn]->proto;
|
||||
|
||||
if (!proto_trigger_add(&room->proto_script, tn)) {
|
||||
send_to_char(ch, "That trigger is already attached.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (SCRIPT(room))
|
||||
extract_script(room, WLD_TRIGGER);
|
||||
assign_triggers(room, WLD_TRIGGER);
|
||||
rset_mark_room_modified(rnum);
|
||||
|
||||
if (!save_rooms(room->zone)) {
|
||||
send_to_char(ch, "Failed to write room data to disk.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
send_to_char(ch, "Trigger %d (%s) attached to room %d.\r\n",
|
||||
tn, GET_TRIG_NAME(trig), room->number);
|
||||
return;
|
||||
}
|
||||
|
||||
if (set_alias) {
|
||||
int flag;
|
||||
|
||||
|
|
@ -1498,6 +1935,53 @@ ACMD(do_rset)
|
|||
return;
|
||||
}
|
||||
|
||||
if (is_abbrev(arg2, "script")) {
|
||||
const char *tname = "unknown";
|
||||
char script_name[MAX_INPUT_LENGTH];
|
||||
|
||||
argument = one_argument(argument, arg3);
|
||||
if (!*arg3) {
|
||||
rset_show_del_usage(ch);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_number(arg3)) {
|
||||
tn = atoi(arg3);
|
||||
} else {
|
||||
if (!script_normalize_name(arg3, script_name, sizeof(script_name))) {
|
||||
send_to_char(ch, "Script name is invalid.\r\n");
|
||||
return;
|
||||
}
|
||||
tn = script_find_attached_trigger_vnum(room->proto_script, script_name, WLD_TRIGGER);
|
||||
if (tn == NOTHING) {
|
||||
send_to_char(ch, "That script is not attached.\r\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
rn = real_trigger(tn);
|
||||
if (rn != NOTHING && trig_index[rn] && trig_index[rn]->proto)
|
||||
tname = GET_TRIG_NAME(trig_index[rn]->proto);
|
||||
|
||||
if (!proto_trigger_remove(&room->proto_script, tn)) {
|
||||
send_to_char(ch, "That trigger is not attached.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (SCRIPT(room))
|
||||
extract_script(room, WLD_TRIGGER);
|
||||
assign_triggers(room, WLD_TRIGGER);
|
||||
rset_mark_room_modified(rnum);
|
||||
|
||||
if (!save_rooms(room->zone)) {
|
||||
send_to_char(ch, "Failed to write room data to disk.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
send_to_char(ch, "Trigger %d (%s) removed from room %d.\r\n",
|
||||
tn, tname, room->number);
|
||||
return;
|
||||
}
|
||||
|
||||
rset_show_del_usage(ch);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1557,6 +2041,7 @@ static void oset_show_usage(struct char_data *ch)
|
|||
" oset add cost <obj> <value>\r\n"
|
||||
" oset add oval <obj> <oval number> <value>\r\n"
|
||||
" oset add edesc <obj> <keyword> <description>\r\n"
|
||||
" oset add script <obj> <script name>\r\n"
|
||||
" oset del <obj> <field>\r\n"
|
||||
" oset clear <obj> force\r\n"
|
||||
" oset validate <obj>\r\n");
|
||||
|
|
@ -1578,7 +2063,8 @@ static void oset_show_add_usage(struct char_data *ch)
|
|||
" oset add weight <obj> <value>\r\n"
|
||||
" oset add cost <obj> <value>\r\n"
|
||||
" oset add oval <obj> <oval number> <value>\r\n"
|
||||
" oset add edesc <obj> <keyword> <description>\r\n");
|
||||
" oset add edesc <obj> <keyword> <description>\r\n"
|
||||
" oset add script <obj> <script name>\r\n");
|
||||
}
|
||||
|
||||
static void oset_show_add_keywords_usage(struct char_data *ch)
|
||||
|
|
@ -1714,6 +2200,7 @@ static void oset_show_del_usage(struct char_data *ch)
|
|||
" oset del <obj> wear <wear type> [wear types]\r\n"
|
||||
" oset del <obj> oval <oval number|oval name>\r\n"
|
||||
" oset del <obj> edesc <keyword>\r\n"
|
||||
" oset del <obj> script <script name>\r\n"
|
||||
"\r\n"
|
||||
"Examples:\r\n"
|
||||
" oset del sword keywords sword\r\n"
|
||||
|
|
@ -2132,6 +2619,8 @@ ACMD(do_oset)
|
|||
char arg3[MAX_INPUT_LENGTH];
|
||||
char arg4[MAX_INPUT_LENGTH];
|
||||
struct obj_data *obj;
|
||||
trig_data *trig;
|
||||
int tn, rn;
|
||||
|
||||
if (IS_NPC(ch) || ch->desc == NULL) {
|
||||
send_to_char(ch, "oset is only usable by connected players.\r\n");
|
||||
|
|
@ -2504,6 +2993,88 @@ ACMD(do_oset)
|
|||
return;
|
||||
}
|
||||
|
||||
if (is_abbrev(arg2, "script")) {
|
||||
obj_rnum robj_num;
|
||||
obj_vnum vnum;
|
||||
zone_rnum znum;
|
||||
|
||||
argument = one_argument(argument, arg3);
|
||||
if (!*arg3) {
|
||||
oset_show_add_usage(ch);
|
||||
return;
|
||||
}
|
||||
skip_spaces(&argument);
|
||||
if (!*argument) {
|
||||
oset_show_add_usage(ch);
|
||||
return;
|
||||
}
|
||||
|
||||
obj = oset_get_target_obj_keyword(ch, arg3);
|
||||
if (!obj) {
|
||||
send_to_char(ch, "You don't seem to have %s %s.\r\n", AN(arg3), arg3);
|
||||
return;
|
||||
}
|
||||
|
||||
robj_num = GET_OBJ_RNUM(obj);
|
||||
vnum = GET_OBJ_VNUM(obj);
|
||||
if (robj_num == NOTHING || vnum == NOTHING) {
|
||||
send_to_char(ch, "That object has no valid vnum.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!can_edit_zone(ch, real_zone_by_thing(vnum))) {
|
||||
send_to_char(ch, "You do not have permission to modify that zone.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
znum = real_zone_by_thing(vnum);
|
||||
if (znum == NOWHERE) {
|
||||
send_to_char(ch, "That object has no valid zone.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
tn = script_resolve_trigger_vnum(ch, argument, znum, OBJ_TRIGGER);
|
||||
if (tn == NOTHING)
|
||||
return;
|
||||
rn = real_trigger(tn);
|
||||
if (rn == NOTHING || trig_index[rn] == NULL || trig_index[rn]->proto == NULL) {
|
||||
send_to_char(ch, "That trigger does not exist.\r\n");
|
||||
return;
|
||||
}
|
||||
trig = trig_index[rn]->proto;
|
||||
|
||||
if (!proto_trigger_add(&obj_proto[robj_num].proto_script, tn)) {
|
||||
send_to_char(ch, "That trigger is already attached.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
struct obj_data *obj_it;
|
||||
struct obj_data *target_obj = obj;
|
||||
|
||||
for (obj_it = object_list; obj_it; obj_it = obj_it->next) {
|
||||
if (obj_it->item_number != robj_num)
|
||||
continue;
|
||||
if (SCRIPT(obj_it))
|
||||
extract_script(obj_it, OBJ_TRIGGER);
|
||||
free_proto_script(obj_it, OBJ_TRIGGER);
|
||||
copy_proto_script(&obj_proto[robj_num], obj_it, OBJ_TRIGGER);
|
||||
assign_triggers(obj_it, OBJ_TRIGGER);
|
||||
}
|
||||
|
||||
if (znum == NOWHERE || !save_objects(znum)) {
|
||||
send_to_char(ch, "Failed to write object data to disk.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
send_to_char(ch, "Trigger %d (%s) attached to %s [%d].\r\n",
|
||||
tn, GET_TRIG_NAME(trig),
|
||||
(target_obj->short_description ? target_obj->short_description : target_obj->name),
|
||||
GET_OBJ_VNUM(target_obj));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
oset_show_add_usage(ch);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2673,6 +3244,89 @@ ACMD(do_oset)
|
|||
return;
|
||||
}
|
||||
|
||||
if (is_abbrev(arg3, "script")) {
|
||||
obj_rnum robj_num;
|
||||
obj_vnum vnum;
|
||||
zone_rnum znum;
|
||||
const char *tname = "unknown";
|
||||
char script_name[MAX_INPUT_LENGTH];
|
||||
|
||||
argument = one_argument(argument, arg4);
|
||||
if (!*arg4) {
|
||||
oset_show_del_usage(ch);
|
||||
return;
|
||||
}
|
||||
|
||||
obj = oset_get_target_obj_keyword(ch, arg2);
|
||||
if (!obj) {
|
||||
send_to_char(ch, "You don't seem to have %s %s.\r\n", AN(arg2), arg2);
|
||||
return;
|
||||
}
|
||||
|
||||
robj_num = GET_OBJ_RNUM(obj);
|
||||
vnum = GET_OBJ_VNUM(obj);
|
||||
if (robj_num == NOTHING || vnum == NOTHING) {
|
||||
send_to_char(ch, "That object has no valid vnum.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!can_edit_zone(ch, real_zone_by_thing(vnum))) {
|
||||
send_to_char(ch, "You do not have permission to modify that zone.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_number(arg4)) {
|
||||
tn = atoi(arg4);
|
||||
} else {
|
||||
if (!script_normalize_name(arg4, script_name, sizeof(script_name))) {
|
||||
send_to_char(ch, "Script name is invalid.\r\n");
|
||||
return;
|
||||
}
|
||||
tn = script_find_attached_trigger_vnum(obj_proto[robj_num].proto_script,
|
||||
script_name, OBJ_TRIGGER);
|
||||
if (tn == NOTHING) {
|
||||
send_to_char(ch, "That script is not attached.\r\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rn = real_trigger(tn);
|
||||
if (rn != NOTHING && trig_index[rn] && trig_index[rn]->proto)
|
||||
tname = GET_TRIG_NAME(trig_index[rn]->proto);
|
||||
|
||||
if (!proto_trigger_remove(&obj_proto[robj_num].proto_script, tn)) {
|
||||
send_to_char(ch, "That trigger is not attached.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
struct obj_data *obj_it;
|
||||
struct obj_data *target_obj = obj;
|
||||
|
||||
for (obj_it = object_list; obj_it; obj_it = obj_it->next) {
|
||||
if (obj_it->item_number != robj_num)
|
||||
continue;
|
||||
if (SCRIPT(obj_it))
|
||||
extract_script(obj_it, OBJ_TRIGGER);
|
||||
free_proto_script(obj_it, OBJ_TRIGGER);
|
||||
copy_proto_script(&obj_proto[robj_num], obj_it, OBJ_TRIGGER);
|
||||
assign_triggers(obj_it, OBJ_TRIGGER);
|
||||
}
|
||||
|
||||
znum = real_zone_by_thing(vnum);
|
||||
if (znum == NOWHERE || !save_objects(znum)) {
|
||||
send_to_char(ch, "Failed to write object data to disk.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
send_to_char(ch, "Trigger %d (%s) removed from %s [%d].\r\n",
|
||||
tn, tname,
|
||||
(target_obj->short_description ? target_obj->short_description : target_obj->name),
|
||||
GET_OBJ_VNUM(target_obj));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
oset_show_del_usage(ch);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2754,6 +3408,7 @@ static void mset_show_usage(struct char_data *ch)
|
|||
" mset add flags <npc> <flags> [flags]\r\n"
|
||||
" mset add affect <npc> <affect> [affects]\r\n"
|
||||
" mset add skinning <npc> <vnum> <dc>\r\n"
|
||||
" mset add script <npc> <script name>\r\n"
|
||||
" mset del <npc>\r\n"
|
||||
" mset clear <npc>\r\n"
|
||||
" mset validate <npc>\r\n");
|
||||
|
|
@ -3004,7 +3659,8 @@ static void mset_show_del_usage(struct char_data *ch)
|
|||
" mset del <npc> skill <skill name>\r\n"
|
||||
" mset del <npc> flags <flags> [flags]\r\n"
|
||||
" mset del <npc> affect <affect> [affects]\r\n"
|
||||
" mset del <npc> skinning <vnum>\r\n");
|
||||
" mset del <npc> skinning <vnum>\r\n"
|
||||
" mset del <npc> script <script name>\r\n");
|
||||
}
|
||||
|
||||
static void mset_show_del_edesc_usage(struct char_data *ch)
|
||||
|
|
@ -3407,6 +4063,8 @@ ACMD(do_mset)
|
|||
struct char_data *mob;
|
||||
mob_rnum rnum;
|
||||
mob_vnum vnum;
|
||||
trig_data *trig;
|
||||
int tn, rn;
|
||||
|
||||
if (IS_NPC(ch) || ch->desc == NULL) {
|
||||
send_to_char(ch, "mset is only usable by connected players.\r\n");
|
||||
|
|
@ -3501,6 +4159,56 @@ ACMD(do_mset)
|
|||
return;
|
||||
}
|
||||
|
||||
if (is_abbrev(arg2, "script")) {
|
||||
zone_rnum znum;
|
||||
|
||||
skip_spaces(&argument);
|
||||
if (!*argument) {
|
||||
mset_show_usage(ch);
|
||||
return;
|
||||
}
|
||||
|
||||
znum = real_zone_by_thing(vnum);
|
||||
if (znum == NOWHERE) {
|
||||
send_to_char(ch, "That NPC has no valid zone.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
tn = script_resolve_trigger_vnum(ch, argument, znum, MOB_TRIGGER);
|
||||
if (tn == NOTHING)
|
||||
return;
|
||||
rn = real_trigger(tn);
|
||||
if (rn == NOTHING || trig_index[rn] == NULL || trig_index[rn]->proto == NULL) {
|
||||
send_to_char(ch, "That trigger does not exist.\r\n");
|
||||
return;
|
||||
}
|
||||
trig = trig_index[rn]->proto;
|
||||
|
||||
if (!proto_trigger_add(&mob_proto[rnum].proto_script, tn)) {
|
||||
send_to_char(ch, "That trigger is already attached.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (struct char_data *mob_it = character_list; mob_it; mob_it = mob_it->next) {
|
||||
if (GET_MOB_RNUM(mob_it) != rnum)
|
||||
continue;
|
||||
if (SCRIPT(mob_it))
|
||||
extract_script(mob_it, MOB_TRIGGER);
|
||||
free_proto_script(mob_it, MOB_TRIGGER);
|
||||
copy_proto_script(&mob_proto[rnum], mob_it, MOB_TRIGGER);
|
||||
assign_triggers(mob_it, MOB_TRIGGER);
|
||||
}
|
||||
|
||||
if (znum == NOWHERE || !save_mobiles(znum)) {
|
||||
send_to_char(ch, "Failed to write mobile data to disk.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
send_to_char(ch, "Trigger %d (%s) attached to %s [%d].\r\n",
|
||||
tn, GET_TRIG_NAME(trig), GET_SHORT(mob), GET_MOB_VNUM(mob));
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_abbrev(arg2, "keywords")) {
|
||||
char kwbuf[MAX_STRING_LENGTH];
|
||||
char word[MAX_INPUT_LENGTH];
|
||||
|
|
@ -4043,6 +4751,61 @@ ACMD(do_mset)
|
|||
return;
|
||||
}
|
||||
|
||||
if (is_abbrev(arg3, "script")) {
|
||||
zone_rnum znum;
|
||||
const char *tname = "unknown";
|
||||
char script_name[MAX_INPUT_LENGTH];
|
||||
|
||||
if (!*argument) {
|
||||
mset_show_del_usage(ch);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_number(argument)) {
|
||||
tn = atoi(argument);
|
||||
} else {
|
||||
if (!script_normalize_name(argument, script_name, sizeof(script_name))) {
|
||||
send_to_char(ch, "Script name is invalid.\r\n");
|
||||
return;
|
||||
}
|
||||
tn = script_find_attached_trigger_vnum(mob_proto[rnum].proto_script,
|
||||
script_name, MOB_TRIGGER);
|
||||
if (tn == NOTHING) {
|
||||
send_to_char(ch, "That script is not attached.\r\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rn = real_trigger(tn);
|
||||
if (rn != NOTHING && trig_index[rn] && trig_index[rn]->proto)
|
||||
tname = GET_TRIG_NAME(trig_index[rn]->proto);
|
||||
|
||||
if (!proto_trigger_remove(&mob_proto[rnum].proto_script, tn)) {
|
||||
send_to_char(ch, "That trigger is not attached.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (struct char_data *mob_it = character_list; mob_it; mob_it = mob_it->next) {
|
||||
if (GET_MOB_RNUM(mob_it) != rnum)
|
||||
continue;
|
||||
if (SCRIPT(mob_it))
|
||||
extract_script(mob_it, MOB_TRIGGER);
|
||||
free_proto_script(mob_it, MOB_TRIGGER);
|
||||
copy_proto_script(&mob_proto[rnum], mob_it, MOB_TRIGGER);
|
||||
assign_triggers(mob_it, MOB_TRIGGER);
|
||||
}
|
||||
|
||||
znum = real_zone_by_thing(vnum);
|
||||
if (znum == NOWHERE || !save_mobiles(znum)) {
|
||||
send_to_char(ch, "Failed to write mobile data to disk.\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
send_to_char(ch, "Trigger %d (%s) removed from %s [%d].\r\n",
|
||||
tn, tname, GET_SHORT(mob), GET_MOB_VNUM(mob));
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_abbrev(arg3, "name")) {
|
||||
if (rnum != NOBODY) {
|
||||
if (mob_proto[rnum].player.name)
|
||||
|
|
@ -7287,6 +8050,8 @@ static int roomsave_restore_room_mobs(struct roomsave_room *room, room_rnum rnum
|
|||
if (!saw_inventory)
|
||||
RS_apply_inventory_loadout(mob);
|
||||
|
||||
load_mtrigger(mob);
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
#include "handler.h"
|
||||
#include "comm.h"
|
||||
#include "db.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "fight.h" /* for hit() */
|
||||
|
||||
#define SINFO spell_info[spellnum]
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include "db.h"
|
||||
#include "constants.h"
|
||||
#include "interpreter.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
#include "act.h"
|
||||
#include "fight.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#include "genolc.h"
|
||||
#include "genzon.h"
|
||||
#include "oasis.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "py_triggers.h"
|
||||
|
||||
/* Nasty internal macros to clean up the code. */
|
||||
#define MYCMD (OLC_ZONE(d)->cmd[subcmd])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue