… | |
… | |
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 | set_owner (tmp, 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 | |
829 | /* First check the object itself. */ |
832 | /* First check the object itself. */ |
830 | if ((trig->stats.hp && (op->type == trig->stats.hp)) |
833 | if ((trig->stats.hp && (op->type == trig->stats.hp)) |
831 | || (trig->slaying && (op->slaying == trig->slaying)) || (trig->race && (op->arch->name == trig->race))) |
834 | || (trig->slaying && (op->slaying == trig->slaying)) |
|
|
835 | || (trig->race && (op->arch->name == trig->race))) |
832 | return op; |
836 | return op; |
833 | |
837 | |
834 | for (tmp = op->inv; tmp; tmp = tmp->below) |
838 | for (tmp = op->inv; tmp; tmp = tmp->below) |
835 | { |
839 | { |
836 | if (tmp->inv) |
840 | if (tmp->inv) |
… | |
… | |
838 | ret = check_inv_recursive (tmp, trig); |
842 | ret = check_inv_recursive (tmp, trig); |
839 | if (ret) |
843 | if (ret) |
840 | return ret; |
844 | return ret; |
841 | } |
845 | } |
842 | else if ((trig->stats.hp && (tmp->type == trig->stats.hp)) |
846 | else if ((trig->stats.hp && (tmp->type == trig->stats.hp)) |
843 | || (trig->slaying && (tmp->slaying == trig->slaying)) || (trig->race && (tmp->arch->name == trig->race))) |
847 | || (trig->slaying && (tmp->slaying == trig->slaying)) |
|
|
848 | || (trig->race && (tmp->arch->name == trig->race))) |
844 | return tmp; |
849 | return tmp; |
845 | } |
850 | } |
846 | return NULL; |
851 | return NULL; |
847 | } |
852 | } |
848 | |
853 | |
… | |
… | |
851 | * the square will activate connected items. |
856 | * the square will activate connected items. |
852 | * Monsters can't trigger this square (for now) |
857 | * Monsters can't trigger this square (for now) |
853 | * Values are: last_sp = 1/0 obj/no obj triggers |
858 | * Values are: last_sp = 1/0 obj/no obj triggers |
854 | * last_heal = 1/0 remove/dont remove obj if triggered |
859 | * last_heal = 1/0 remove/dont remove obj if triggered |
855 | * -b.t. (thomas@nomad.astro.psu.edu |
860 | * -b.t. (thomas@nomad.astro.psu.edu |
856 | */ |
861 | * |
857 | |
862 | * Tue Dec 19 15:34:00 CET 2006 elmex: changed the function to ignore op |
|
|
863 | * because the check-inventory semantic essentially only applies when |
|
|
864 | * something is above the inventory checker. |
|
|
865 | * The semantic prior this change was: trigger if something has moved on or off |
|
|
866 | * and has a matching item. Imagine what happens if someone steps on the inventory |
|
|
867 | * checker with a matching item, has it, activates the connection, throws the item |
|
|
868 | * away, and then leaves the inventory checker. That would've caused an always-enabled |
|
|
869 | * state in the inventory checker. This won't happen anymore now. |
|
|
870 | * |
|
|
871 | */ |
858 | void |
872 | void |
859 | check_inv (object *op, object *trig) |
873 | check_inv (object *op, object *trig) |
860 | { |
874 | { |
861 | object *match; |
875 | trig->value = 0; // deactivate if none of the following conditions apply |
862 | |
876 | |
863 | if (op->type != PLAYER) |
877 | if (object *pl = trig->ms ().player ()) |
864 | return; |
878 | { |
865 | match = check_inv_recursive (op, trig); |
879 | object *match = check_inv_recursive (pl, trig); |
866 | if (match && trig->last_sp) |
880 | |
867 | { |
881 | if (match && trig->last_sp) // match == having |
|
|
882 | { |
868 | if (trig->last_heal) |
883 | if (trig->last_heal) |
869 | decrease_ob (match); |
884 | decrease_ob (match); |
870 | use_trigger (trig); |
|
|
871 | } |
|
|
872 | else if (!match && !trig->last_sp) |
|
|
873 | use_trigger (trig); |
|
|
874 | } |
|
|
875 | |
885 | |
|
|
886 | trig->value = 1; |
|
|
887 | } |
|
|
888 | else if (!match && !trig->last_sp) // match == not having |
|
|
889 | trig->value = 1; |
|
|
890 | } |
|
|
891 | |
|
|
892 | push_button (trig); |
|
|
893 | } |
|
|
894 | |