--- deliantra/server/common/button.C 2009/01/08 03:03:23 1.51 +++ deliantra/server/common/button.C 2009/01/08 04:35:03 1.52 @@ -31,10 +31,11 @@ * elmex: * This function takes a objectlink list with all the objects are going to be activated. * state is a true/false flag that will actiavte objects that have FLAG_ACTIVATE_ON_PUSH/RELEASE set. - * The source argument can be 0 or the source object for this activation. + * The activator argument can be 0 or the source object for this activation. + * the originator is the player or monster who did something. */ -void -activate_connection_link (objectlink *ol, bool state, object *source = 0) +static void +activate_connection_link (objectlink *ol, bool state, object *activator, object *originator) { for (; ol; ol = ol->next) { @@ -107,7 +108,7 @@ break; case MOOD_FLOOR: - do_mood_floor (tmp, source); + do_mood_floor (tmp, activator); break; case TIMED_GATE: @@ -161,7 +162,7 @@ break; case MAPSCRIPT: - cfperl_mapscript_activate (tmp, source, state); + cfperl_mapscript_activate (tmp, state, activator, originator); break; } } @@ -180,14 +181,14 @@ * */ void -push_button (object *op) +push_button (object *op, object *originator) { if (oblinkpt *obp = op->find_link ()) { - if (INVOKE_MAP (TRIGGER, op->map, ARG_STRING (&obp->id), ARG_INT (op->value))) + if (INVOKE_MAP (TRIGGER, op->map, ARG_STRING (&obp->id), ARG_INT (op->value), ARG_OBJECT (op), ARG_OBJECT (originator))) return; - activate_connection_link (obp->link, op->value, op); + activate_connection_link (obp->link, op->value, op, originator); } } @@ -200,13 +201,13 @@ * */ void -maptile::trigger (shstr_tmp id, bool state, object *originator) +maptile::trigger (shstr_tmp id, bool state, object *activator, object *originator) { if (INVOKE_MAP (TRIGGER, this, ARG_STRING (&id), ARG_INT (state), ARG_OBJECT (originator))) return; if (oblinkpt *obp = find_link (id)) - activate_connection_link (obp->link, state, originator); + activate_connection_link (obp->link, state, activator, originator); } /* @@ -216,7 +217,7 @@ * button reacts to the (eventual) change of state. */ void -update_button (object *op) +update_button (object *op, object *originator) { int any_down = 0, old_value = op->value; @@ -279,16 +280,17 @@ { SET_ANIMATION (op, op->value); update_object (op, UP_OBJ_FACE); - push_button (op); /* Make all other buttons the same */ + push_button (op, originator); /* Make all other buttons the same */ } } void -use_trigger (object *op) +use_trigger (object *op, object *originator) { /* Toggle value */ op->value = !op->value; - push_button (op); + + push_button (op, originator); } /* @@ -390,18 +392,19 @@ } void -trigger_move (object *op, int state) /* 1 down and 0 up */ +trigger_move (object *op, int state, object *originator) /* 1 down and 0 up */ { op->stats.wc = state; + if (state) { - use_trigger (op); + use_trigger (op, originator); op->set_speed (op->stats.exp > 0 ? 1. / op->stats.exp : 1.); op->speed_left = -1; } else { - use_trigger (op); + use_trigger (op, originator); op->set_speed (0); } } @@ -460,7 +463,8 @@ if (in_movement || !push) return 0; } - trigger_move (op, push); + + trigger_move (op, push, cause); } return 0; @@ -498,7 +502,7 @@ return 0; } - trigger_move (op, push); + trigger_move (op, push, cause); return 0; case TRIGGER_ALTAR: @@ -517,7 +521,8 @@ if (op->last_sp >= 0) { - trigger_move (op, 1); + trigger_move (op, 1, cause); + if (op->last_sp > 0) op->last_sp = -op->last_sp; } @@ -527,7 +532,7 @@ * status (-> +/- value) is "simulated": */ op->value = !op->value; - trigger_move (op, 1); + trigger_move (op, 1, cause); op->last_sp = -op->last_sp; op->value = !op->value; } @@ -551,7 +556,7 @@ * pushed twice: First by sacrifice, second by reset! -AV */ if (!op->last_sp) - trigger_move (op, 0); + trigger_move (op, 0, cause); else { op->stats.wc = 0; @@ -576,7 +581,7 @@ update_object (op, UP_OBJ_FACE); } - trigger_move (op, push); + trigger_move (op, push, cause); return 1; default: @@ -667,7 +672,7 @@ if (ol->ob->type == BUTTON || ol->ob->type == PEDESTAL) { - update_button (ol->ob); + update_button (ol->ob, 0); break; } } @@ -882,12 +887,12 @@ match->decrease (); trig->value = (pl == op ? 1 : 0); // 1 if matching player entered, and 0 if he left - push_button (trig); + push_button (trig, op); } else if (!match && !trig->last_sp) // match == not having { trig->value = (pl == op ? 1 : 0); // 1 if matching player entered, and 0 if he left - push_button (trig); + push_button (trig, op); } }