… | |
… | |
828 | * and has a matching item. Imagine what happens if someone steps on the inventory |
828 | * and has a matching item. Imagine what happens if someone steps on the inventory |
829 | * checker with a matching item, has it, activates the connection, throws the item |
829 | * checker with a matching item, has it, activates the connection, throws the item |
830 | * away, and then leaves the inventory checker. That would've caused an always-enabled |
830 | * away, and then leaves the inventory checker. That would've caused an always-enabled |
831 | * state in the inventory checker. This won't happen anymore now. |
831 | * state in the inventory checker. This won't happen anymore now. |
832 | * |
832 | * |
|
|
833 | * Wed Jan 10 11:34:26 CET 2007 elmex: fixed this function, we now check |
|
|
834 | * whether op is on this mapspace or not, because the value (1|0) depends |
|
|
835 | * on this information. also make sure to only push_button if op has |
|
|
836 | * a matching item (because when we do a push_button with value=0 timed gates |
|
|
837 | * will still open)! (i hope i got the semantics right this time) |
|
|
838 | * |
833 | */ |
839 | */ |
834 | void |
840 | void |
835 | check_inv (object *op, object *trig) |
841 | check_inv (object *op, object *trig) |
836 | { |
842 | { |
837 | trig->value = 0; // deactivate if none of the following conditions apply |
843 | trig->value = 0; // deactivate if none of the following conditions apply |
838 | |
844 | |
839 | if (object *pl = trig->ms ().player ()) |
845 | object *pl = trig->ms ().player (); |
840 | { |
|
|
841 | object *match = check_inv_recursive (pl, trig); |
846 | object *match = check_inv_recursive (op, trig); |
842 | |
847 | |
|
|
848 | // elmex: a note about (pl == op): |
|
|
849 | // if pl == 0 then the player has left this space |
|
|
850 | // if pl != 0 then a player is on this mapspace, but then |
|
|
851 | // we still have to check whether it's the player that triggered |
|
|
852 | // this inv-checker, because if not, then the op left this inv-checker |
|
|
853 | // and we have to set the value to 0 |
|
|
854 | |
843 | if (match && trig->last_sp) // match == having |
855 | if (match && trig->last_sp) // match == having |
844 | { |
856 | { |
845 | if (trig->last_heal) |
857 | if (trig->last_heal) |
846 | decrease_ob (match); |
858 | decrease_ob (match); |
847 | |
859 | |
848 | trig->value = 1; |
860 | trig->value = (pl == op ? 1 : 0); // 1 if matching player entered, and 0 if he left |
849 | } |
861 | push_button (trig); |
|
|
862 | } |
850 | else if (!match && !trig->last_sp) // match == not having |
863 | else if (!match && !trig->last_sp) // match == not having |
851 | trig->value = 1; |
|
|
852 | } |
864 | { |
853 | |
865 | trig->value = (pl == op ? 1 : 0); // 1 if matching player entered, and 0 if he left |
854 | push_button (trig); |
866 | push_button (trig); |
|
|
867 | } |
855 | } |
868 | } |
856 | |
869 | |