Crossfire Server, Trunk
|
Go to the source code of this file.
Macros | |
#define | ARCH_SACRIFICE(xyz) ((xyz)->slaying) |
#define | NROF_SACRIFICE(xyz) ((uint32_t)(xyz)->stats.food) |
Functions | |
void | add_button_link (object *button, mapstruct *map, int connected) |
void | animate_turning (object *op) |
int | check_altar_sacrifice (const object *altar, const object *sacrifice, int remove_others, int *toremove) |
void | check_inv (object *op, object *trig) |
object * | check_inv_recursive (object *op, const object *trig) |
int | check_trigger (object *op, object *cause) |
static objectlink * | get_button_links (const object *button) |
int | get_button_value (const object *button) |
static int | matches_sacrifice (const object *altar, const object *sacrifice) |
int | operate_altar (object *altar, object **sacrifice) |
void | push_button (object *op) |
void | remove_button_link (object *op) |
void | trigger_connected (objectlink *ol, object *cause, const int state) |
static void | trigger_move (object *op, int state) |
void | update_button (object *op) |
void | update_buttons (mapstruct *m) |
void | use_trigger (object *op) |
This handles triggers, buttons, altars and associated objects.
Definition in file button.cpp.
#define ARCH_SACRIFICE | ( | xyz | ) | ((xyz)->slaying) |
Definition at line 283 of file button.cpp.
#define NROF_SACRIFICE | ( | xyz | ) | ((uint32_t)(xyz)->stats.food) |
Definition at line 284 of file button.cpp.
Links specified object in the map.
button | object to link. Must not be NULL. |
map | map we are on. Should not be NULL. |
connected | connection value for the item. |
Definition at line 656 of file button.cpp.
References push::connected, object::count, FLAG_IS_LINKED, free_objectlink(), get_objectlink(), get_objectlinkpt(), objectlink::id, oblinkpt::link, llevError, LOG(), disinfect::map, objectlink::next, oblinkpt::next, objectlink::ob, SET_FLAG, and oblinkpt::value.
Referenced by apply_builder_item(), include_map_in_map(), and while().
void animate_turning | ( | object * | op | ) |
Animates one step of object.
op | object to animate. |
Definition at line 270 of file button.cpp.
References FIREWALL, NUM_ANIMATIONS, object_update(), give::op, SET_ANIMATION, and UP_OBJ_FACE.
Referenced by director_process(), legacy_ob_process(), and trigger_connected().
int check_altar_sacrifice | ( | const object * | altar, |
const object * | sacrifice, | ||
int | remove_others, | ||
int * | toremove | ||
) |
Checks whether the altar has enough to sacrifice.
Function put in (0.92.1) so that identify altars won't grab money unnecessarily - we can see if there is sufficient money, see if something needs to be identified, and then remove money if needed.
0.93.4: Linked objects (ie, objects that are connected) can not be sacrificed. This fixes a bug of trying to put multiple altars/related objects on the same space that take the same sacrifice.
The function will now check for all items sitting on the altar, so that the player can put various matching but non merging items on the altar.
This function can potentially remove other items, if remove_others is set.
altar | item to which there is a sacrifice | |
sacrifice | object that may be sacrifed | |
remove_others | if 1, will remove enough items apart sacrifice to compensate for not having enough in sacrifice itself. | |
[out] | toremove | will contain the nrof of sacrifice to really remove to finish operating. Will be set if not NULL only if the function returns 1. |
Definition at line 347 of file button.cpp.
References altar_valkyrie::altar, ARCH_SACRIFICE, FLAG_UNPAID, FOR_ABOVE_FINISH, FOR_ABOVE_PREPARE, llevError, LOG(), matches_sacrifice(), object::nrof, NROF(), NROF_SACRIFICE, object_decrease_nrof(), object_remove(), QUERY_FLAG, ring_occidental_mages::rest, Ice::tmp, and object::value.
Referenced by identify_altar_type_move_on(), and operate_altar().
Function to search the inventory, of a player and then based on a set of conditions, the square will activate connected items.
Monsters can't trigger this square (for now) Values are: last_sp = 1/0 obj/no obj triggers last_heal = 1/0 remove/dont remove obj if triggered -b.t. (thoma s@no mad.a stro .psu. edu
op | object to check. Must be a player. |
trig | trigger object that may be activated. |
Definition at line 825 of file button.cpp.
References check_inv_recursive(), object::last_heal, object::last_sp, push::match, object_decrease_nrof_by_one, give::op, PLAYER, and use_trigger().
Referenced by check_inv_type_move_on().
Checks object and its inventory for specific item.
It will descend through containers to find the object. slaying = match object slaying flag race = match object archetype name flag hp = match object type (excpt type '0'== PLAYER) title = match object title unpaid = 1 -> match only unpaid, 0 -> match only not unpaid Searching by title only is not recommended, as it can be a rather slow operation; use it in combination with archetype or type.
op | object of which to search inventory |
trig | what to search |
Definition at line 782 of file button.cpp.
References check_inv_recursive(), FLAG_UNPAID, FOR_INV_FINISH, FOR_INV_PREPARE, living::hp, give::op, QUERY_FLAG, object::race, object::slaying, object::stats, object::title, and Ice::tmp.
Referenced by blocked_link(), check_inv(), check_inv_recursive(), town_portal_destroy_existing(), and town_portal_find_force().
cause == NULL: nothing has moved, we have been called from animate_trigger().
TRIGGER_ALTAR: Returns 1 if 'cause' was destroyed, 0 if not.
TRIGGER: Returns 1 if handle could be moved, 0 if not.
TRIGGER_BUTTON, TRIGGER_PEDESTAL: Returns 0.
Definition at line 518 of file button.cpp.
References FOR_ABOVE_FINISH, FOR_ABOVE_PREPARE, llevDebug, LOG(), object::move_type, NROF(), NUM_ANIMATIONS, object_update(), object_update_speed(), give::op, operate_altar(), PLAYER, push(), object::race, SET_ANIMATION, Ice::tmp, TRIGGER, TRIGGER_ALTAR, TRIGGER_BUTTON, trigger_move(), TRIGGER_PEDESTAL, object::type, and UP_OBJ_FACE.
Referenced by animate_trigger(), apply_auto_fix(), cfapi_object_check_trigger(), do_auto_apply(), trigger_altar_type_move_on(), trigger_button_type_move_on(), trigger_pedestal_type_move_on(), trigger_type_apply(), and trigger_type_process().
|
static |
Return the first objectlink in the objects linked to this one
button | object to check. Must not be NULL. |
Definition at line 727 of file button.cpp.
References mapstruct::buttons, object::count, objectlink::id, oblinkpt::link, object::map, objectlink::next, oblinkpt::next, and objectlink::ob.
Referenced by push_button(), and update_button().
int get_button_value | ( | const object * | button | ) |
Returns the first value linked to this button. Made as a separate function to increase efficiency
button | object to check. Must not be NULL. |
Definition at line 749 of file button.cpp.
References mapstruct::buttons, object::count, objectlink::id, oblinkpt::link, object::map, objectlink::next, oblinkpt::next, objectlink::ob, and oblinkpt::value.
Referenced by examine(), and get_ob_diff().
Helper function to check if the item matches altar's requested sacrifice. The number of objects is not taken into account.
altar | altar we're checking for. Can't be NULL. |
sacrifice | what object to check for. Can't be NULL. |
Definition at line 297 of file button.cpp.
References altar_valkyrie::altar, object::arch, ARCH_SACRIFICE, FLAG_ALIVE, FLAG_IS_LINKED, MAX_BUF, MONEY, give::name, object::name, archetype::name, object_value_set(), PLAYER, query_base_name(), QUERY_FLAG, object::slaying, and object::type.
Referenced by check_altar_sacrifice().
Checks if sacrifice was accepted and removes sacrificed objects. Might be better to call check_altar_sacrifice (above) than depend on the return value, since operate_altar will remove the sacrifice also.
If this function returns 1, '*sacrifice' is modified to point to the remaining sacrifice, or is set to NULL if the sacrifice was used up.
altar | item to which there is a sacrifice |
sacrifice | object that may be sacrifed |
Definition at line 463 of file button.cpp.
References altar_valkyrie::altar, check_altar_sacrifice(), ext_info_map(), llevError, LOG(), MSG_TYPE_DIALOG, MSG_TYPE_DIALOG_ALTAR, NDI_BLACK, and object_decrease_nrof().
Referenced by altar_type_move_on(), check_trigger(), and identify_altar_type_move_on().
void push_button | ( | object * | op | ) |
Push the specified object. This can affect other buttons/gates/handles altars/pedestals/holes in the whole map. Changed the routine to loop through all linked objects. Better hurry with that linked list...
op | object to push. |
Definition at line 149 of file button.cpp.
References get_button_links(), give::op, and trigger_connected().
Referenced by altar_type_move_on(), cf_handle_type_apply(), move_detector(), update_button(), and use_trigger().
void remove_button_link | ( | object * | op | ) |
Remove the object from the linked lists of buttons in the map. This is only needed by editors.
op | object to remove. Must be on a map, and linked. |
Definition at line 693 of file button.cpp.
References CLEAR_FLAG, FLAG_IS_LINKED, oblinkpt::link, llevError, LOG(), objectlink::next, oblinkpt::next, objectlink::ob, give::op, and QUERY_FLAG.
Referenced by apply_builder_remove(), clean_object(), and delete_unique_items().
void trigger_connected | ( | objectlink * | ol, |
object * | cause, | ||
const int | state | ||
) |
Trigger every object in an objectlink. This was originally part of push_button but has been extracted to make it possible to trigger the connected object on a map from a plugin without requiring a source object. This method will take care of calling EVENT_TRIGGER of all elligible object in list (see state parameter)
ol | the objectlink to trigger. This can be acquire from map |
cause | the object that cause this path to trigger, may be NULL |
state | which object to apply. 0=all object with FLAG_ACTIVATE_ON_PUSH other=all object with FLAG_ACTIVATE_ON_RELEASE |
Definition at line 41 of file button.cpp.
References ALTAR, animate_turning(), BUTTON, CF_HANDLE, object::count, DIRECTOR, EVENT_TRIGGER, events_execute_object_event(), ext_info_map(), FIREWALL, FLAG_ACTIVATE_ON_PUSH, FLAG_ACTIVATE_ON_RELEASE, FLAG_ANIMATE, FLAG_FREED, GATE, HOLE, living::hp, objectlink::id, llevError, LOG(), move_firewall(), MSG_SUBTYPE_NONE, MSG_TYPE_SIGN, object::name, NDI_NAVY, NDI_UNIQUE, objectlink::next, objectlink::ob, ob_trigger(), object_update(), object_update_speed(), PEDESTAL, QUERY_FLAG, SCRIPT_FIX_ALL, SET_ANIMATION, SIGN, living::sp, object::speed, dragon::state, object::stats, TIMED_GATE, Ice::tmp, UP_OBJ_FACE, and object::value.
Referenced by cfapi_map_trigger_connected(), and push_button().
|
static |
Definition at line 488 of file button.cpp.
References object_update_speed(), give::op, dragon::state, and use_trigger().
Referenced by check_trigger().
void update_button | ( | object * | op | ) |
Updates everything connected with the button op. After changing the state of a button, this function must be called to make sure that all gates and other buttons connected to the button reacts to the (eventual) change of state.
op | object to update. |
Definition at line 162 of file button.cpp.
References BUTTON, object::count, FOR_ABOVE_FINISH, FOR_ABOVE_PREPARE, get_button_links(), object::head, objectlink::id, llevDebug, LOG(), object::move_type, objectlink::next, NROF(), objectlink::ob, object_update(), give::op, PEDESTAL, PLAYER, push_button(), object::race, SET_ANIMATION, object::slaying, SPECIAL_KEY, Ice::tmp, object::type, and UP_OBJ_FACE.
Referenced by button_type_move_on(), pedestal_type_move_on(), and update_buttons().
void update_buttons | ( | mapstruct * | m | ) |
Updates every button on the map (by calling update_button() for them).
Definition at line 227 of file button.cpp.
References BUTTON, object::count, objectlink::id, oblinkpt::link, llevError, LOG(), m, object::name, objectlink::next, oblinkpt::next, objectlink::ob, PEDESTAL, object::type, update_button(), oblinkpt::value, object::x, and object::y.
Referenced by mapfile_load().
void use_trigger | ( | object * | op | ) |
Toggles the state of specified button.
op | object to toggle. |
Definition at line 254 of file button.cpp.
References give::op, and push_button().
Referenced by check_inv(), monster_do_talk_npc(), spring_trap(), and trigger_move().