… | |
… | |
205 | * Updates everything connected with the button op. |
205 | * Updates everything connected with the button op. |
206 | * After changing the state of a button, this function must be called |
206 | * After changing the state of a button, this function must be called |
207 | * to make sure that all gates and other buttons connected to the |
207 | * to make sure that all gates and other buttons connected to the |
208 | * button reacts to the (eventual) change of state. |
208 | * button reacts to the (eventual) change of state. |
209 | */ |
209 | */ |
210 | |
|
|
211 | void |
210 | void |
212 | update_button (object *op) |
211 | update_button (object *op) |
213 | { |
212 | { |
214 | object *ab, *tmp, *head; |
213 | object *ab, *tmp, *head; |
215 | int tot, any_down = 0, old_value = op->value; |
214 | int tot, any_down = 0, old_value = op->value; |
… | |
… | |
354 | ARCH_SACRIFICE (altar) == sacrifice->name || |
353 | ARCH_SACRIFICE (altar) == sacrifice->name || |
355 | ARCH_SACRIFICE (altar) == sacrifice->slaying || |
354 | ARCH_SACRIFICE (altar) == sacrifice->slaying || |
356 | (!strcmp (ARCH_SACRIFICE (altar), query_base_name (sacrifice, 0)))) |
355 | (!strcmp (ARCH_SACRIFICE (altar), query_base_name (sacrifice, 0)))) |
357 | && NROF_SACRIFICE (altar) <= (sacrifice->nrof ? sacrifice->nrof : 1)) |
356 | && NROF_SACRIFICE (altar) <= (sacrifice->nrof ? sacrifice->nrof : 1)) |
358 | return 1; |
357 | return 1; |
|
|
358 | |
359 | if (strcmp (ARCH_SACRIFICE (altar), "money") == 0 |
359 | if (strcmp (ARCH_SACRIFICE (altar), "money") == 0 |
360 | && sacrifice->type == MONEY && sacrifice->nrof * sacrifice->value >= NROF_SACRIFICE (altar)) |
360 | && sacrifice->type == MONEY && sacrifice->nrof * sacrifice->value >= NROF_SACRIFICE (altar)) |
361 | return 1; |
361 | return 1; |
362 | } |
362 | } |
|
|
363 | |
363 | return 0; |
364 | return 0; |
364 | } |
365 | } |
365 | |
366 | |
366 | /* |
367 | /* |
367 | * operate_altar checks if sacrifice was accepted and removes sacrificed |
368 | * operate_altar checks if sacrifice was accepted and removes sacrificed |
… | |
… | |
792 | break; |
793 | break; |
793 | case 4: /* charm all monsters */ |
794 | case 4: /* charm all monsters */ |
794 | if (op == source) |
795 | if (op == source) |
795 | break; /* only if 'connected' */ |
796 | break; /* only if 'connected' */ |
796 | |
797 | |
797 | for (tmp2 = get_map_ob (source->map, source->x, source->y); /* finding an owner */ |
798 | for (tmp2 = GET_MAP_OB (source->map, source->x, source->y); /* finding an owner */ |
798 | tmp2->type != PLAYER; tmp2 = tmp2->above) |
799 | tmp2->type != PLAYER; tmp2 = tmp2->above) |
799 | if (tmp2->above == NULL) |
800 | if (tmp2->above == NULL) |
800 | break; |
801 | break; |
801 | |
802 | |
802 | if (tmp2->type != PLAYER) |
803 | if (tmp2->type != PLAYER) |
803 | break; |
804 | break; |
|
|
805 | |
804 | tmp->set_owner (tmp2); |
806 | tmp->set_owner (tmp2); |
805 | SET_FLAG (tmp, FLAG_MONSTER); |
807 | SET_FLAG (tmp, FLAG_MONSTER); |
|
|
808 | |
806 | tmp->stats.exp = 0; |
809 | tmp->stats.exp = 0; |
807 | SET_FLAG (tmp, FLAG_FRIENDLY); |
810 | SET_FLAG (tmp, FLAG_FRIENDLY); |
|
|
811 | |
808 | add_friendly_object (tmp); |
812 | add_friendly_object (tmp); |
809 | tmp->attack_movement = PETMOVE; |
813 | tmp->attack_movement = PETMOVE; |
810 | break; |
814 | break; |
811 | |
815 | |
812 | default: |
816 | default: |
… | |
… | |
818 | * It will descend through containers to find the object. |
822 | * It will descend through containers to find the object. |
819 | * slaying = match object slaying flag |
823 | * slaying = match object slaying flag |
820 | * race = match object archetype name flag |
824 | * race = match object archetype name flag |
821 | * hp = match object type (excpt type '0'== PLAYER) |
825 | * hp = match object type (excpt type '0'== PLAYER) |
822 | */ |
826 | */ |
823 | |
|
|
824 | object * |
827 | object * |
825 | check_inv_recursive (object *op, const object *trig) |
828 | check_inv_recursive (object *op, const object *trig) |
826 | { |
829 | { |
827 | object *tmp, *ret = NULL; |
830 | object *tmp, *ret = NULL; |
828 | |
831 | |
… | |
… | |
864 | * checker with a matching item, has it, activates the connection, throws the item |
867 | * checker with a matching item, has it, activates the connection, throws the item |
865 | * away, and then leaves the inventory checker. That would've caused an always-enabled |
868 | * away, and then leaves the inventory checker. That would've caused an always-enabled |
866 | * state in the inventory checker. This won't happen anymore now. |
869 | * state in the inventory checker. This won't happen anymore now. |
867 | * |
870 | * |
868 | */ |
871 | */ |
869 | |
|
|
870 | void |
872 | void |
871 | check_inv (object *op, object *trig) |
873 | check_inv (object *op, object *trig) |
872 | { |
874 | { |
873 | object *match = 0; |
|
|
874 | |
|
|
875 | trig->value = 0; // deactivate if none of the following conditions apply |
875 | trig->value = 0; // deactivate if none of the following conditions apply |
876 | |
876 | |
877 | for (object *tmp = trig->above; tmp; tmp = tmp->above) |
877 | if (object *pl = trig->ms ().player ()) |
878 | if (tmp->type == PLAYER) |
|
|
879 | { |
878 | { |
880 | object *match = check_inv_recursive (tmp, trig); |
879 | object *match = check_inv_recursive (pl, trig); |
881 | |
880 | |
882 | if (match && trig->last_sp) // match == having |
881 | if (match && trig->last_sp) // match == having |
883 | { |
882 | { |
884 | if (trig->last_heal) |
883 | if (trig->last_heal) |
885 | decrease_ob (match); |
884 | decrease_ob (match); |
886 | |
885 | |
887 | trig->value = 1; |
|
|
888 | } |
|
|
889 | else if (!match && !trig->last_sp) // match == not having |
|
|
890 | trig->value = 1; |
886 | trig->value = 1; |
891 | |
|
|
892 | break; |
|
|
893 | } |
887 | } |
|
|
888 | else if (!match && !trig->last_sp) // match == not having |
|
|
889 | trig->value = 1; |
|
|
890 | } |
894 | |
891 | |
895 | push_button (trig); |
892 | push_button (trig); |
896 | } |
893 | } |
897 | |
894 | |