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