… | |
… | |
65 | |
65 | |
66 | static const struct apply_types_player_only : typeset |
66 | static const struct apply_types_player_only : typeset |
67 | { |
67 | { |
68 | apply_types_player_only () |
68 | apply_types_player_only () |
69 | { |
69 | { |
|
|
70 | set (TRANSPORT); |
70 | set (EXIT); |
71 | set (EXIT); |
71 | set (BOOK); |
72 | set (BOOK); |
72 | set (SIGN); |
73 | set (SIGN); |
73 | set (BOOK); |
74 | set (BOOK); |
74 | set (SKILLSCROLL); |
75 | set (SKILLSCROLL); |
… | |
… | |
250 | */ |
251 | */ |
251 | static int |
252 | static int |
252 | prepare_weapon (object *op, object *improver, object *weapon) |
253 | prepare_weapon (object *op, object *improver, object *weapon) |
253 | { |
254 | { |
254 | int sacrifice_count, i; |
255 | int sacrifice_count, i; |
255 | char buf[MAX_BUF]; |
|
|
256 | |
256 | |
257 | if (weapon->level != 0) |
257 | if (weapon->level != 0) |
258 | { |
258 | { |
259 | op->failmsg ("Weapon is already prepared!"); |
259 | op->failmsg ("Weapon is already prepared!"); |
260 | return 0; |
260 | return 0; |
… | |
… | |
289 | "Your sacrifice was accepted." |
289 | "Your sacrifice was accepted." |
290 | "Your *%s may be improved %d times.", |
290 | "Your *%s may be improved %d times.", |
291 | &weapon->name, weapon->level |
291 | &weapon->name, weapon->level |
292 | )); |
292 | )); |
293 | |
293 | |
294 | sprintf (buf, "%s's %s", &op->name, &weapon->name); |
294 | weapon->name = weapon->name_pl = format ("%s's %s", &op->name, &weapon->name); |
295 | weapon->name = weapon->name_pl = buf; |
|
|
296 | weapon->nrof = 0; /* prevents preparing n weapons in the same |
295 | weapon->nrof = 0; /* prevents preparing n weapons in the same |
297 | slot at once! */ |
296 | slot at once! */ |
298 | improver->decrease (); |
297 | improver->decrease (); |
299 | weapon->last_eat = 0; |
298 | weapon->last_eat = 0; |
300 | return 1; |
299 | return 1; |
… | |
… | |
688 | */ |
687 | */ |
689 | } |
688 | } |
690 | |
689 | |
691 | // elmex: only identify if we need to, for example so that generated money doesn't |
690 | // elmex: only identify if we need to, for example so that generated money doesn't |
692 | // get an 'identified' flag so easily. |
691 | // get an 'identified' flag so easily. |
693 | if (need_identify (item)) |
692 | if (item->need_identify ()) |
694 | identify (item); |
693 | identify (item); |
695 | |
694 | |
696 | insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); |
695 | insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); |
697 | return 1; |
696 | return 1; |
698 | } |
697 | } |
… | |
… | |
732 | op->close_container (); |
731 | op->close_container (); |
733 | return 1; |
732 | return 1; |
734 | } |
733 | } |
735 | else if (!sack->env) |
734 | else if (!sack->env) |
736 | { |
735 | { |
737 | // active, but not ours: some other player has opened it |
736 | // active on floor, but not ours: some other player has opened it |
|
|
737 | // normally this only happens to dms standing on the same space. |
|
|
738 | // but it doesn't hurt to handle it. |
738 | op->failmsgf ("Somebody else is using the %s already.", query_name (sack)); |
739 | op->failmsgf ("Somebody else is using the %s already.", query_name (sack)); |
739 | return 1; |
740 | return 1; |
740 | } |
741 | } |
|
|
742 | } |
741 | |
743 | |
742 | // fall through to opening it (active in inv) |
744 | // it's locked? |
|
|
745 | if (sack->slaying) |
743 | } |
746 | { |
744 | else if (sack->env) |
747 | if (object *tmp = find_key (op, op, sack)) |
|
|
748 | { |
|
|
749 | op->statusmsg (format ("You unlock %s with %s.", query_name (sack), query_name (tmp))); |
|
|
750 | } |
|
|
751 | else |
|
|
752 | { |
|
|
753 | sack->flag [FLAG_APPLIED] = false; // might be applied in inv, let the user close it |
|
|
754 | esrv_update_item (UPD_FLAGS, op, sack); |
|
|
755 | op->statusmsg (format ("You don't have the key to unlock %s.", query_name (sack))); |
|
|
756 | return 1; |
|
|
757 | } |
|
|
758 | } |
|
|
759 | |
|
|
760 | if (sack->env && !sack->flag [FLAG_APPLIED]) |
745 | { |
761 | { |
746 | // it is in our env, so activate it, do not open yet |
762 | // it is in our env, so activate it, do not open yet |
747 | op->close_container (); |
763 | op->close_container (); |
748 | sack->flag [FLAG_APPLIED] = 1; |
764 | sack->flag [FLAG_APPLIED] = true; |
749 | esrv_update_item (UPD_FLAGS, op, sack); |
765 | esrv_update_item (UPD_FLAGS, op, sack); |
750 | op->statusmsg (format ("You ready %s.", query_name (sack))); |
766 | op->statusmsg (format ("You ready %s.", query_name (sack))); |
751 | return 1; |
|
|
752 | } |
|
|
753 | |
|
|
754 | // it's locked? |
|
|
755 | if (sack->slaying) |
|
|
756 | { |
767 | } |
757 | if (object *tmp = find_key (op, op, sack)) |
|
|
758 | op->statusmsg (format ("You unlock %s with %s.", query_name (sack), query_name (tmp))); |
|
|
759 | else |
768 | else |
760 | { |
|
|
761 | op->statusmsg (format ("You don't have the key to unlock %s.", query_name (sack))); |
|
|
762 | return 1; |
|
|
763 | } |
|
|
764 | } |
|
|
765 | |
|
|
766 | op->open_container (sack); |
769 | op->open_container (sack); |
767 | |
770 | |
768 | return 1; |
771 | return 1; |
769 | } |
772 | } |
770 | |
773 | |
771 | /** |
774 | /** |
… | |
… | |
1762 | |
1765 | |
1763 | /* if the player has a marked item, identify that if it needs to be |
1766 | /* if the player has a marked item, identify that if it needs to be |
1764 | * identified. If it doesn't, then go through the player inventory. |
1767 | * identified. If it doesn't, then go through the player inventory. |
1765 | */ |
1768 | */ |
1766 | if (object *marked = pl->mark ()) |
1769 | if (object *marked = pl->mark ()) |
1767 | if (!marked->flag [FLAG_IDENTIFIED] && need_identify (marked)) |
1770 | if (!marked->flag [FLAG_IDENTIFIED] && marked->need_identify ()) |
1768 | { |
1771 | { |
1769 | if (operate_altar (altar, &money, pl)) |
1772 | if (operate_altar (altar, &money, pl)) |
1770 | { |
1773 | { |
1771 | identify (marked); |
1774 | identify (marked); |
1772 | |
1775 | |
… | |
… | |
1778 | } |
1781 | } |
1779 | } |
1782 | } |
1780 | |
1783 | |
1781 | for (object *id = pl->inv; id; id = id->below) |
1784 | for (object *id = pl->inv; id; id = id->below) |
1782 | { |
1785 | { |
1783 | if (!id->flag [FLAG_IDENTIFIED] && !id->invisible && need_identify (id)) |
1786 | if (!id->flag [FLAG_IDENTIFIED] && !id->invisible && id->need_identify ()) |
1784 | { |
1787 | { |
1785 | if (operate_altar (altar, &money, pl)) |
1788 | if (operate_altar (altar, &money, pl)) |
1786 | { |
1789 | { |
1787 | identify (id); |
1790 | identify (id); |
1788 | |
1791 | |
… | |
… | |
2060 | void |
2063 | void |
2061 | move_apply (object *trap, object *victim, object *originator) |
2064 | move_apply (object *trap, object *victim, object *originator) |
2062 | { |
2065 | { |
2063 | static int recursion_depth = 0; |
2066 | static int recursion_depth = 0; |
2064 | |
2067 | |
|
|
2068 | trap = trap->head_ (); |
|
|
2069 | |
2065 | /* Only exits affect DMs. */ |
2070 | /* Only exits affect DMs. */ |
2066 | if (victim->flag [FLAG_WIZPASS] && trap->type != EXIT && trap->type != SIGN) |
2071 | if (victim->flag [FLAG_WIZPASS] && trap->type != EXIT && trap->type != SIGN) |
2067 | return; |
2072 | return; |
2068 | |
2073 | |
2069 | /* move_apply() is the most likely candidate for causing unwanted and |
2074 | /* move_apply() is the most likely candidate for causing unwanted and |
2070 | * possibly unlimited recursion. |
2075 | * possibly unlimited recursion. |
2071 | */ |
2076 | */ |
|
|
2077 | |
2072 | /* The following was changed because it was causing perfectly correct |
2078 | /* The following was changed because it was causing perfectly correct |
2073 | * maps to fail. 1) it's not an error to recurse: |
2079 | * maps to fail. 1) it's not an error to recurse: |
2074 | * rune detonates, summoning monster. monster lands on nearby rune. |
2080 | * rune detonates, summoning monster. monster lands on nearby rune. |
2075 | * nearby rune detonates. This sort of recursion is expected and |
2081 | * nearby rune detonates. This sort of recursion is expected and |
2076 | * proper. This code was causing needless crashes. |
2082 | * proper. This code was causing needless crashes. |
… | |
… | |
2081 | "[trap arch %s, name %s; victim arch %s, name %s]\n", &trap->arch->archname, &trap->name, &victim->arch->archname, &victim->name); |
2087 | "[trap arch %s, name %s; victim arch %s, name %s]\n", &trap->arch->archname, &trap->name, &victim->arch->archname, &victim->name); |
2082 | return; |
2088 | return; |
2083 | } |
2089 | } |
2084 | |
2090 | |
2085 | recursion_depth++; |
2091 | recursion_depth++; |
2086 | if (trap->head) |
|
|
2087 | trap = trap->head; |
|
|
2088 | |
2092 | |
2089 | if (!INVOKE_OBJECT (MOVE_TRIGGER, trap, ARG_OBJECT (victim), ARG_OBJECT (originator))) |
2093 | if (!INVOKE_OBJECT (MOVE_TRIGGER, trap, ARG_OBJECT (victim), ARG_OBJECT (originator))) |
2090 | switch (trap->type) |
2094 | switch (trap->type) |
2091 | { |
2095 | { |
2092 | case PLAYERMOVER: |
2096 | case PLAYERMOVER: |
… | |
… | |
2102 | |
2106 | |
2103 | /* Just put in some sanity check. I think there is a bug in the |
2107 | /* Just put in some sanity check. I think there is a bug in the |
2104 | * above with some objects have zero speed, and thus the player |
2108 | * above with some objects have zero speed, and thus the player |
2105 | * getting permanently paralyzed. |
2109 | * getting permanently paralyzed. |
2106 | */ |
2110 | */ |
2107 | if (victim->speed_left < -50.f) |
2111 | victim->speed_left = max (-50.f, victim->speed_left); |
2108 | victim->speed_left = -50.f; |
|
|
2109 | /* LOG(llevDebug, "apply, playermove, player speed_left=%f\n", victim->speed_left); */ |
2112 | /* LOG(llevDebug, "apply, playermove, player speed_left=%f\n", victim->speed_left); */ |
2110 | } |
2113 | } |
2111 | break; |
2114 | break; |
2112 | |
2115 | |
2113 | case SPINNER: |
2116 | case SPINNER: |
… | |
… | |
3517 | check_improve_weapon (who, op); |
3520 | check_improve_weapon (who, op); |
3518 | break; |
3521 | break; |
3519 | |
3522 | |
3520 | case CLOCK: |
3523 | case CLOCK: |
3521 | { |
3524 | { |
3522 | char buf[MAX_BUF]; |
|
|
3523 | timeofday_t tod; |
3525 | timeofday_t tod; |
3524 | |
3526 | |
3525 | get_tod (&tod); |
3527 | get_tod (&tod); |
3526 | who->play_sound (sound_find ("sound_clock")); |
3528 | who->play_sound (sound_find ("sound_clock")); |
3527 | who->statusmsg (format ( |
3529 | who->statusmsg (format ( |