--- deliantra/server/common/button.C 2006/10/15 02:16:34 1.12 +++ deliantra/server/common/button.C 2006/12/20 09:14:21 1.17 @@ -207,7 +207,6 @@ * to make sure that all gates and other buttons connected to the * button reacts to the (eventual) change of state. */ - void update_button (object *op) { @@ -356,10 +355,12 @@ (!strcmp (ARCH_SACRIFICE (altar), query_base_name (sacrifice, 0)))) && NROF_SACRIFICE (altar) <= (sacrifice->nrof ? sacrifice->nrof : 1)) return 1; + if (strcmp (ARCH_SACRIFICE (altar), "money") == 0 && sacrifice->type == MONEY && sacrifice->nrof * sacrifice->value >= NROF_SACRIFICE (altar)) return 1; } + return 0; } @@ -773,10 +774,8 @@ * dereference a null value */ if (tmp->type == GOLEM && tmp->owner && tmp->owner->type == PLAYER && tmp->owner->contr->ranges[range_golem] == tmp) - { - tmp->owner->contr->ranges[range_golem] = NULL; - tmp->owner->contr->golem_count = 0; - } + tmp->owner->contr->ranges[range_golem] = 0; + tmp->owner = 0; } break; @@ -796,17 +795,20 @@ if (op == source) break; /* only if 'connected' */ - for (tmp2 = get_map_ob (source->map, source->x, source->y); /* finding an owner */ + for (tmp2 = GET_MAP_OB (source->map, source->x, source->y); /* finding an owner */ tmp2->type != PLAYER; tmp2 = tmp2->above) if (tmp2->above == NULL) break; if (tmp2->type != PLAYER) break; - set_owner (tmp, tmp2); + + tmp->set_owner (tmp2); SET_FLAG (tmp, FLAG_MONSTER); + tmp->stats.exp = 0; SET_FLAG (tmp, FLAG_FRIENDLY); + add_friendly_object (tmp); tmp->attack_movement = PETMOVE; break; @@ -822,7 +824,6 @@ * race = match object archetype name flag * hp = match object type (excpt type '0'== PLAYER) */ - object * check_inv_recursive (object *op, const object *trig) { @@ -830,7 +831,8 @@ /* First check the object itself. */ if ((trig->stats.hp && (op->type == trig->stats.hp)) - || (trig->slaying && (op->slaying == trig->slaying)) || (trig->race && (op->arch->name == trig->race))) + || (trig->slaying && (op->slaying == trig->slaying)) + || (trig->race && (op->arch->name == trig->race))) return op; for (tmp = op->inv; tmp; tmp = tmp->below) @@ -842,7 +844,8 @@ return ret; } else if ((trig->stats.hp && (tmp->type == trig->stats.hp)) - || (trig->slaying && (tmp->slaying == trig->slaying)) || (trig->race && (tmp->arch->name == trig->race))) + || (trig->slaying && (tmp->slaying == trig->slaying)) + || (trig->race && (tmp->arch->name == trig->race))) return tmp; } return NULL; @@ -855,23 +858,43 @@ * Values are: last_sp = 1/0 obj/no obj triggers * last_heal = 1/0 remove/dont remove obj if triggered * -b.t. (thomas@nomad.astro.psu.edu + * + * Tue Dec 19 15:34:00 CET 2006 elmex: changed the function to ignore op + * because the check-inventory semantic essentially only applies when + * something is above the inventory checker. + * The semantic prior this change was: trigger if something has moved on or off + * and has a matching item. Imagine what happens if someone steps on the inventory + * checker with a matching item, has it, activates the connection, throws the item + * away, and then leaves the inventory checker. That would've caused an always-enabled + * state in the inventory checker. This won't happen anymore now. + * */ void check_inv (object *op, object *trig) { - object *match; + object *match = 0; - if (op->type != PLAYER) - return; - match = check_inv_recursive (op, trig); - if (match && trig->last_sp) - { - if (trig->last_heal) - decrease_ob (match); - use_trigger (trig); - } - else if (!match && !trig->last_sp) - use_trigger (trig); + trig->value = 0; // deactivate if none of the following conditions apply + + for (object *tmp = trig->above; tmp; tmp = tmp->above) + if (tmp->type == PLAYER) + { + object *match = check_inv_recursive (tmp, trig); + + if (match && trig->last_sp) // match == having + { + if (trig->last_heal) + decrease_ob (match); + + trig->value = 1; + } + else if (!match && !trig->last_sp) // match == not having + trig->value = 1; + + break; + } + + push_button (trig); }