1 | /* |
1 | /* |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
… | |
… | |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * |
20 | * |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <cmath> |
24 | #include <cmath> |
25 | |
25 | |
26 | #include <global.h> |
26 | #include <global.h> |
… | |
… | |
94 | static int |
94 | static int |
95 | apply_id_altar (object *money, object *altar, object *pl) |
95 | apply_id_altar (object *money, object *altar, object *pl) |
96 | { |
96 | { |
97 | dynbuf_text buf; |
97 | dynbuf_text buf; |
98 | |
98 | |
99 | object *id, *marked; |
|
|
100 | |
|
|
101 | if (pl == NULL || pl->type != PLAYER) |
99 | if (!pl || pl->type != PLAYER) |
102 | return 0; |
100 | return 0; |
103 | |
101 | |
104 | /* Check for MONEY type is a special hack - it prevents 'nothing needs |
102 | /* Check for MONEY type is a special hack - it prevents 'nothing needs |
105 | * identifying' from being printed out more than it needs to be. |
103 | * identifying' from being printed out more than it needs to be. |
106 | */ |
104 | */ |
107 | if (!check_altar_sacrifice (altar, money) || money->type != MONEY) |
105 | if (!check_altar_sacrifice (altar, money) || money->type != MONEY) |
108 | return 0; |
106 | return 0; |
109 | |
107 | |
110 | marked = find_marked_object (pl); |
|
|
111 | /* if the player has a marked item, identify that if it needs to be |
108 | /* if the player has a marked item, identify that if it needs to be |
112 | * identified. If it doesn't, then go through the player inventory. |
109 | * identified. If it doesn't, then go through the player inventory. |
113 | */ |
110 | */ |
|
|
111 | if (object *marked = find_marked_object (pl)) |
114 | if (marked && !QUERY_FLAG (marked, FLAG_IDENTIFIED) && need_identify (marked)) |
112 | if (!QUERY_FLAG (marked, FLAG_IDENTIFIED) && need_identify (marked)) |
115 | { |
113 | { |
116 | if (operate_altar (altar, &money)) |
114 | if (operate_altar (altar, &money)) |
117 | { |
115 | { |
118 | identify (marked); |
116 | identify (marked); |
119 | |
117 | |
120 | buf.printf ("You have %s.", long_desc (marked, pl)); |
118 | buf.printf ("You have %s.\n\n", long_desc (marked, pl)); |
121 | if (marked->msg) |
119 | if (marked->msg) |
122 | buf << "The item has a story:\n" << marked->msg; |
120 | buf << "The item has a story:\n\n" << marked->msg << "\n\n"; |
123 | |
121 | |
124 | return money == NULL; |
122 | return !money; |
125 | } |
123 | } |
126 | } |
124 | } |
127 | |
125 | |
128 | for (id = pl->inv; id; id = id->below) |
126 | for (object *id = pl->inv; id; id = id->below) |
129 | { |
127 | { |
130 | if (!QUERY_FLAG (id, FLAG_IDENTIFIED) && !id->invisible && need_identify (id)) |
128 | if (!QUERY_FLAG (id, FLAG_IDENTIFIED) && !id->invisible && need_identify (id)) |
131 | { |
129 | { |
132 | if (operate_altar (altar, &money)) |
130 | if (operate_altar (altar, &money)) |
133 | { |
131 | { |
134 | identify (id); |
132 | identify (id); |
135 | |
133 | |
136 | buf.printf ("You have %s.", long_desc (id, pl)); |
134 | buf.printf ("You have %s.\n\n", long_desc (id, pl)); |
137 | if (marked->msg) |
135 | if (id->msg) |
138 | buf << "The item has a story:\n" << marked->msg; |
136 | buf << "The item has a story:\n\n" << id->msg << "\n\n"; |
139 | |
137 | |
140 | /* If no more money, might as well quit now */ |
138 | /* If no more money, might as well quit now */ |
141 | if (money == NULL || !check_altar_sacrifice (altar, money)) |
139 | if (!money || !check_altar_sacrifice (altar, money)) |
142 | break; |
140 | break; |
143 | } |
141 | } |
144 | else |
142 | else |
145 | { |
143 | { |
146 | LOG (llevError, "check_id_altar: Couldn't do sacrifice when we should have been able to\n"); |
144 | LOG (llevError, "check_id_altar: Couldn't do sacrifice when we should have been able to\n"); |
… | |
… | |
148 | } |
146 | } |
149 | } |
147 | } |
150 | } |
148 | } |
151 | |
149 | |
152 | if (buf.empty ()) |
150 | if (buf.empty ()) |
153 | buf << ("You have nothing that needs identifying"); |
151 | pl->failmsg ("You have nothing that needs identifying"); |
154 | |
152 | else |
155 | pl->contr->infobox (buf); |
153 | pl->contr->infobox (MSG_CHANNEL ("identify"), buf); |
156 | |
154 | |
157 | return !money; |
155 | return !money; |
158 | } |
156 | } |
159 | |
157 | |
160 | /** |
158 | /** |
… | |
… | |
197 | |
195 | |
198 | floor = GET_MAP_OB (op->map, op->x, op->y); |
196 | floor = GET_MAP_OB (op->map, op->x, op->y); |
199 | |
197 | |
200 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
198 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
201 | { |
199 | { |
202 | op->errormsg ("Gods prevent you from using this here, it's sacred ground!"); |
200 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
203 | |
201 | |
204 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
202 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
205 | return 0; |
203 | return 0; |
206 | } |
204 | } |
207 | |
205 | |
… | |
… | |
314 | else |
312 | else |
315 | { /* cursed potion */ |
313 | { /* cursed potion */ |
316 | if (got_one) |
314 | if (got_one) |
317 | { |
315 | { |
318 | op->update_stats (); |
316 | op->update_stats (); |
319 | op->errormsg ("The Gods are angry and punish you."); |
317 | op->failmsg ("The Gods are angry and punish you."); |
320 | } |
318 | } |
321 | else |
319 | else |
322 | op->statusmsg ("You are fortunate that you are so pathetic.", NDI_DK_ORANGE); |
320 | op->statusmsg ("You are fortunate that you are so pathetic.", NDI_DK_ORANGE); |
323 | } |
321 | } |
324 | |
322 | |
… | |
… | |
336 | { |
334 | { |
337 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
335 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
338 | { |
336 | { |
339 | object *fball; |
337 | object *fball; |
340 | |
338 | |
341 | op->errormsg ("Yech! Your lungs are on fire!"); |
339 | op->failmsg ("Yech! Your lungs are on fire!"); |
342 | |
340 | |
343 | /* Explodes a fireball centered at player */ |
341 | /* Explodes a fireball centered at player */ |
344 | fball = get_archetype (EXPLODING_FIREBALL); |
342 | fball = get_archetype (EXPLODING_FIREBALL); |
345 | fball->dam_modifier = random_roll (1, op->level, op, PREFER_LOW) / 5 + 1; |
343 | fball->dam_modifier = random_roll (1, op->level, op, PREFER_LOW) / 5 + 1; |
346 | fball->stats.maxhp = random_roll (1, op->level, op, PREFER_LOW) / 10 + 2; |
344 | fball->stats.maxhp = random_roll (1, op->level, op, PREFER_LOW) / 10 + 2; |
… | |
… | |
552 | if (improver->slaying) |
550 | if (improver->slaying) |
553 | { |
551 | { |
554 | count = check_item (op, improver->slaying); |
552 | count = check_item (op, improver->slaying); |
555 | if (count < 1) |
553 | if (count < 1) |
556 | { |
554 | { |
557 | op->errormsg (format ("The gods want more %ss", &improver->slaying)); |
555 | op->failmsg (format ("The gods want more %ss", &improver->slaying)); |
558 | return 0; |
556 | return 0; |
559 | } |
557 | } |
560 | } |
558 | } |
561 | else |
559 | else |
562 | count = 1; |
560 | count = 1; |
… | |
… | |
576 | |
574 | |
577 | /* So it updates the players stats and the window */ |
575 | /* So it updates the players stats and the window */ |
578 | op->update_stats (); |
576 | op->update_stats (); |
579 | |
577 | |
580 | op->statusmsg (format ( |
578 | op->statusmsg (format ( |
581 | "Your sacrifice was accepted.\n" |
579 | "Your sacrifice was accepted.\n" |
582 | "Weapon's bonus to %s improved by %d.", |
580 | "Weapon's bonus to %s improved by %d.", |
583 | statname, sacrifice_count |
581 | statname, sacrifice_count |
584 | )); |
582 | )); |
585 | |
583 | |
586 | return 1; |
584 | return 1; |
587 | } |
585 | } |
588 | |
586 | |
… | |
… | |
609 | int sacrifice_count, i; |
607 | int sacrifice_count, i; |
610 | char buf[MAX_BUF]; |
608 | char buf[MAX_BUF]; |
611 | |
609 | |
612 | if (weapon->level != 0) |
610 | if (weapon->level != 0) |
613 | { |
611 | { |
614 | op->errormsg ("Weapon is already prepared!"); |
612 | op->failmsg ("Weapon is already prepared!"); |
615 | return 0; |
613 | return 0; |
616 | } |
614 | } |
617 | |
615 | |
618 | for (i = 0; i < NROFATTACKS; i++) |
616 | for (i = 0; i < NROFATTACKS; i++) |
619 | if (weapon->resist[i]) |
617 | if (weapon->resist[i]) |
… | |
… | |
625 | if (i < NROFATTACKS || weapon->stats.hp || /* regeneration */ |
623 | if (i < NROFATTACKS || weapon->stats.hp || /* regeneration */ |
626 | (weapon->stats.sp && weapon->type == WEAPON) || /* sp regeneration */ |
624 | (weapon->stats.sp && weapon->type == WEAPON) || /* sp regeneration */ |
627 | weapon->stats.exp || /* speed */ |
625 | weapon->stats.exp || /* speed */ |
628 | weapon->stats.ac) /* AC - only taifu's I think */ |
626 | weapon->stats.ac) /* AC - only taifu's I think */ |
629 | { |
627 | { |
630 | op->errormsg ("You cannot prepare magic weapons."); |
628 | op->failmsg ("You cannot prepare magic weapons. " |
|
|
629 | "H<A weapon is considered magical if it changes regeneration, " |
|
|
630 | "speed or ac.>"); |
631 | return 0; |
631 | return 0; |
632 | } |
632 | } |
633 | |
633 | |
634 | sacrifice_count = check_sacrifice (op, improver); |
634 | sacrifice_count = check_sacrifice (op, improver); |
635 | if (sacrifice_count <= 0) |
635 | if (sacrifice_count <= 0) |
… | |
… | |
637 | |
637 | |
638 | weapon->level = isqrt (sacrifice_count); |
638 | weapon->level = isqrt (sacrifice_count); |
639 | eat_item (op, improver->slaying, sacrifice_count); |
639 | eat_item (op, improver->slaying, sacrifice_count); |
640 | |
640 | |
641 | op->statusmsg (format ( |
641 | op->statusmsg (format ( |
642 | "Your sacrifice was accepted." |
642 | "Your sacrifice was accepted." |
643 | "Your *%s may be improved %d times.", |
643 | "Your *%s may be improved %d times.", |
644 | &weapon->name, weapon->level |
644 | &weapon->name, weapon->level |
645 | )); |
645 | )); |
646 | |
646 | |
647 | sprintf (buf, "%s's %s", &op->name, &weapon->name); |
647 | sprintf (buf, "%s's %s", &op->name, &weapon->name); |
648 | weapon->name = weapon->name_pl = buf; |
648 | weapon->name = weapon->name_pl = buf; |
649 | weapon->nrof = 0; /* prevents preparing n weapons in the same |
649 | weapon->nrof = 0; /* prevents preparing n weapons in the same |
… | |
… | |
673 | if (improver->stats.sp == IMPROVE_PREPARE) |
673 | if (improver->stats.sp == IMPROVE_PREPARE) |
674 | return prepare_weapon (op, improver, weapon); |
674 | return prepare_weapon (op, improver, weapon); |
675 | |
675 | |
676 | if (weapon->level == 0) |
676 | if (weapon->level == 0) |
677 | { |
677 | { |
678 | op->errormsg ("This weapon has not been prepared. H<You first ahve to prepare a weapon with a prepare weapon scroll.>"); |
678 | op->failmsg ("This weapon has not been prepared. H<You first ahve to prepare a weapon with a prepare weapon scroll.>"); |
679 | return 0; |
679 | return 0; |
680 | } |
680 | } |
681 | |
681 | |
682 | if (weapon->level == weapon->last_eat && weapon->item_power >= 100) |
682 | if (weapon->level == weapon->last_eat && weapon->item_power >= 100) |
683 | { |
683 | { |
684 | op->errormsg ("This weapon cannot be improved any more."); |
684 | op->failmsg ("This weapon cannot be improved any more."); |
685 | return 0; |
685 | return 0; |
686 | } |
686 | } |
687 | |
687 | |
688 | if (QUERY_FLAG (weapon, FLAG_APPLIED) && !check_weapon_power (op, weapon->last_eat + 1)) |
688 | if (QUERY_FLAG (weapon, FLAG_APPLIED) && !check_weapon_power (op, weapon->last_eat + 1)) |
689 | { |
689 | { |
690 | op->errormsg ("Improving the weapon will make it too " |
690 | op->failmsg ("Improving the weapon will make it too " |
691 | "powerful for you to use. Unready it if you " |
691 | "powerful for you to use. Unready it if you " |
692 | "really want to improve it."); |
692 | "really want to improve it."); |
693 | return 0; |
693 | return 0; |
694 | } |
694 | } |
695 | |
695 | |
… | |
… | |
741 | sacrifice_needed *= 2; |
741 | sacrifice_needed *= 2; |
742 | |
742 | |
743 | sacrifice_count = check_sacrifice (op, improver); |
743 | sacrifice_count = check_sacrifice (op, improver); |
744 | if (sacrifice_count < sacrifice_needed) |
744 | if (sacrifice_count < sacrifice_needed) |
745 | { |
745 | { |
746 | op->errormsg (format ("You need at least %d %s.", sacrifice_needed, &improver->slaying)); |
746 | op->failmsg (format ("You need at least %d %s.", sacrifice_needed, &improver->slaying)); |
747 | return 0; |
747 | return 0; |
748 | } |
748 | } |
749 | |
749 | |
750 | eat_item (op, improver->slaying, sacrifice_needed); |
750 | eat_item (op, improver->slaying, sacrifice_needed); |
751 | weapon->item_power++; |
751 | weapon->item_power++; |
… | |
… | |
758 | case IMPROVE_WIS: return improve_weapon_stat (op, improver, weapon, weapon->stats.Wis, 1, "wisdom"); |
758 | case IMPROVE_WIS: return improve_weapon_stat (op, improver, weapon, weapon->stats.Wis, 1, "wisdom"); |
759 | case IMPROVE_CHA: return improve_weapon_stat (op, improver, weapon, weapon->stats.Cha, 1, "charisma"); |
759 | case IMPROVE_CHA: return improve_weapon_stat (op, improver, weapon, weapon->stats.Cha, 1, "charisma"); |
760 | case IMPROVE_INT: return improve_weapon_stat (op, improver, weapon, weapon->stats.Int, 1, "intelligence"); |
760 | case IMPROVE_INT: return improve_weapon_stat (op, improver, weapon, weapon->stats.Int, 1, "intelligence"); |
761 | case IMPROVE_POW: return improve_weapon_stat (op, improver, weapon, weapon->stats.Pow, 1, "power"); |
761 | case IMPROVE_POW: return improve_weapon_stat (op, improver, weapon, weapon->stats.Pow, 1, "power"); |
762 | default: |
762 | default: |
763 | op->errormsg ("Unknown improvement type."); |
763 | op->failmsg ("Unknown improvement type."); |
764 | } |
764 | } |
765 | |
765 | |
766 | LOG (llevError, "improve_weapon: Got to end of function\n"); |
766 | LOG (llevError, "improve_weapon: Got to end of function\n"); |
767 | return 0; |
767 | return 0; |
768 | } |
768 | } |
… | |
… | |
780 | if (op->type != PLAYER) |
780 | if (op->type != PLAYER) |
781 | return 0; |
781 | return 0; |
782 | |
782 | |
783 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
783 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
784 | { |
784 | { |
785 | op->errormsg ("Something blocks the magic of the scroll!"); |
785 | op->failmsg ("Something blocks the magic of the scroll!"); |
786 | return 0; |
786 | return 0; |
787 | } |
787 | } |
788 | |
788 | |
789 | otmp = find_marked_object (op); |
789 | otmp = find_marked_object (op); |
790 | if (!otmp) |
790 | if (!otmp) |
791 | { |
791 | { |
792 | op->errormsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); |
792 | op->failmsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); |
793 | return 0; |
793 | return 0; |
794 | } |
794 | } |
795 | |
795 | |
796 | if (otmp->type != WEAPON && otmp->type != BOW) |
796 | if (otmp->type != WEAPON && otmp->type != BOW) |
797 | { |
797 | { |
798 | op->errormsg ("Marked item is not a weapon or bow!"); |
798 | op->failmsg ("Marked item is not a weapon or bow!"); |
799 | return 0; |
799 | return 0; |
800 | } |
800 | } |
801 | |
801 | |
802 | op->statusmsg ("Applied weapon builder."); |
802 | op->statusmsg ("Applied weapon builder."); |
803 | |
803 | |
… | |
… | |
833 | { |
833 | { |
834 | object *tmp; |
834 | object *tmp; |
835 | |
835 | |
836 | if (armour->magic >= settings.armor_max_enchant) |
836 | if (armour->magic >= settings.armor_max_enchant) |
837 | { |
837 | { |
838 | op->errormsg ("This armour can not be enchanted any further!"); |
838 | op->failmsg ("This armour can not be enchanted any further!"); |
839 | return 0; |
839 | return 0; |
840 | } |
840 | } |
|
|
841 | |
841 | /* Dealing with random artifact armor is a lot trickier (in terms of value, weight, |
842 | /* Dealing with random artifact armor is a lot trickier (in terms of value, weight, |
842 | * etc), so take the easy way out and don't worry about it. |
843 | * etc), so take the easy way out and don't worry about it. |
843 | * Note - maybe add scrolls which make the random artifact versions (eg, armour |
844 | * Note - maybe add scrolls which make the random artifact versions (eg, armour |
844 | * of gnarg and what not?) |
845 | * of gnarg and what not?) |
845 | */ |
846 | */ |
846 | if (armour->title) |
847 | if (armour->title) |
847 | { |
848 | { |
848 | op->errormsg ("This armour will not accept further enchantment."); |
849 | op->failmsg ("This armour will not accept further enchantment."); |
849 | return 0; |
850 | return 0; |
850 | } |
851 | } |
851 | |
852 | |
852 | /* Split objects if needed. Can't insert tmp until the |
853 | /* Split objects if needed. Can't insert tmp until the |
853 | * end of this function - otherwise it will just re-merge. |
854 | * end of this function - otherwise it will just re-merge. |
854 | */ |
855 | */ |
855 | if (armour->nrof > 1) |
856 | if (armour->nrof > 1) |
856 | tmp = get_split_ob (armour, armour->nrof - 1); |
857 | tmp = get_split_ob (armour, armour->nrof - 1); |
857 | else |
858 | else |
… | |
… | |
918 | } |
919 | } |
919 | |
920 | |
920 | /* |
921 | /* |
921 | * convert_item() returns 1 if anything was converted, 0 if the item was not |
922 | * convert_item() returns 1 if anything was converted, 0 if the item was not |
922 | * what the converter wants, -1 if the converter is broken. |
923 | * what the converter wants, -1 if the converter is broken. |
923 | */ |
924 | * |
924 | #define CONV_FROM(xyz) xyz->slaying |
|
|
925 | #define CONV_TO(xyz) xyz->other_arch |
|
|
926 | #define CONV_NR(xyz) xyz->stats.sp |
|
|
927 | #define CONV_NEED(xyz) xyz->stats.food |
|
|
928 | |
|
|
929 | /* Takes one items and makes another. |
925 | * Takes one type of items and makes another. |
930 | * converter is the object that is doing the conversion. |
926 | * converter is the object that is doing the conversion. |
931 | * item is the object that triggered the converter - if it is not |
927 | * item is the object that triggered the converter - if it is not |
932 | * what the converter wants, this will not do anything. |
928 | * what the converter wants, this will not do anything. |
933 | */ |
929 | */ |
934 | int |
930 | static int |
935 | convert_item (object *item, object *converter) |
931 | convert_item (object *item, object *converter) |
936 | { |
932 | { |
937 | int nr = 0; |
|
|
938 | uint32 price_in; |
933 | sint64 nr, price_in; |
|
|
934 | |
|
|
935 | if (item->flag [FLAG_UNPAID]) |
|
|
936 | return 0; |
|
|
937 | |
|
|
938 | shstr conv_from = converter->slaying; |
|
|
939 | archetype *conv_to = converter->other_arch; |
|
|
940 | sint64 need = converter->stats.food; |
|
|
941 | sint64 give = converter->stats.sp; |
939 | |
942 | |
940 | /* We make some assumptions - we assume if it takes money as it type, |
943 | /* We make some assumptions - we assume if it takes money as it type, |
941 | * it wants some amount. We don't make change (ie, if something costs |
944 | * it wants some amount. We don't make change (ie, if something costs |
942 | * 3 gp and player drops a platinum, tough luck) |
945 | * 3 gp and player drops a platinum, tough luck) |
943 | */ |
946 | */ |
944 | if (CONV_FROM (converter) == shstr_money) |
947 | if (conv_from == shstr_money) |
945 | { |
948 | { |
946 | if (item->type != MONEY) |
949 | if (item->type != MONEY) |
947 | return 0; |
950 | return 0; |
948 | |
951 | |
949 | nr = (item->nrof * item->value) / CONV_NEED (converter); |
952 | nr = sint64 (item->nrof) * item->value / need; |
950 | if (!nr) |
953 | if (!nr) |
951 | return 0; |
954 | return 0; |
952 | |
955 | |
953 | converter->play_sound (sound_find ("shop_buy")); |
956 | converter->play_sound (sound_find ("shop_buy")); |
954 | |
957 | |
955 | int cost = nr * CONV_NEED (converter) / item->value; |
958 | sint64 cost = (nr * need + item->value - 1) / item->value; |
956 | /* take into account rounding errors */ |
|
|
957 | if (nr * CONV_NEED (converter) % item->value) |
|
|
958 | cost++; |
|
|
959 | |
959 | |
960 | decrease_ob_nr (item, cost); |
960 | decrease_ob_nr (item, cost); |
961 | |
961 | |
962 | price_in = cost * item->value; |
962 | price_in = cost * item->value; |
963 | } |
963 | } |
964 | else |
964 | else |
965 | { |
965 | { |
966 | if (item->type == PLAYER || CONV_FROM (converter) != item->arch->archname || |
966 | if (item->type == PLAYER |
967 | (CONV_NEED (converter) && CONV_NEED (converter) > (uint16) item->nrof)) |
967 | || conv_from != item->arch->archname |
|
|
968 | || (need && need > (uint16) item->nrof)) |
968 | return 0; |
969 | return 0; |
969 | |
970 | |
970 | converter->play_sound (sound_find ("convert_item")); |
971 | converter->play_sound (sound_find ("convert_item")); |
971 | |
972 | |
972 | if (CONV_NEED (converter)) |
973 | if (need) |
973 | { |
974 | { |
974 | nr = item->nrof / CONV_NEED (converter); |
975 | nr = sint64 (item->nrof) / need; |
975 | decrease_ob_nr (item, nr * CONV_NEED (converter)); |
976 | decrease_ob_nr (item, nr * need); |
976 | price_in = nr * CONV_NEED (converter) * item->value; |
977 | price_in = nr * need * item->value; |
977 | } |
978 | } |
978 | else |
979 | else |
979 | { |
980 | { |
980 | price_in = item->value; |
981 | price_in = item->value; |
981 | item->destroy (); |
982 | item->destroy (); |
… | |
… | |
998 | CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); |
999 | CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); |
999 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
1000 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
1000 | } |
1001 | } |
1001 | else |
1002 | else |
1002 | { |
1003 | { |
1003 | if (converter->other_arch == NULL) |
1004 | if (!conv_to) |
1004 | { |
1005 | { |
1005 | LOG (llevError, "move_creator: Converter doesn't have other arch set: %s (%s, %d, %d)\n", |
1006 | LOG (llevError, "move_creator: Converter doesn't have other arch set: %s (%s, %d, %d)\n", |
1006 | &converter->name, &converter->map->path, converter->x, converter->y); |
1007 | &converter->name, &converter->map->path, converter->x, converter->y); |
1007 | return -1; |
1008 | return -1; |
1008 | } |
1009 | } |
1009 | |
1010 | |
1010 | item = object_create_arch (converter->other_arch); |
1011 | item = object_create_arch (conv_to); |
1011 | fix_generated_item (item, converter, 0, 0, GT_MINIMAL); |
1012 | fix_generated_item (item, converter, 0, 0, GT_MINIMAL); |
1012 | } |
1013 | } |
1013 | |
1014 | |
1014 | if (CONV_NR (converter)) |
1015 | if (give) |
1015 | item->nrof = CONV_NR (converter); |
1016 | item->nrof = give; |
1016 | |
1017 | |
1017 | if (nr) |
1018 | if (nr) |
1018 | item->nrof *= nr; |
1019 | item->nrof *= nr; |
1019 | |
1020 | |
1020 | if (is_in_shop (converter)) |
1021 | if (is_in_shop (converter)) |
1021 | SET_FLAG (item, FLAG_UNPAID); |
1022 | SET_FLAG (item, FLAG_UNPAID); |
1022 | else if (price_in < item->nrof * item->value) |
1023 | else if (price_in < sint64 (item->nrof) * item->value) |
1023 | { |
1024 | { |
1024 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
1025 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
1025 | &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
1026 | &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
1026 | /** |
1027 | /** |
1027 | * elmex: we are going to let the game continue, as the mapcreator |
1028 | * elmex: we are going to let the game continue, as the mapcreator |
… | |
… | |
1054 | |
1055 | |
1055 | op->contr->last_used = 0; |
1056 | op->contr->last_used = 0; |
1056 | |
1057 | |
1057 | if (sack->env && sack->env != op) |
1058 | if (sack->env && sack->env != op) |
1058 | { |
1059 | { |
1059 | op->errormsg ("You must put it onto the floor or into your inventory first."); |
1060 | op->failmsg ("You must put it onto the floor or into your inventory first."); |
1060 | return 1; |
1061 | return 1; |
1061 | } |
1062 | } |
1062 | |
1063 | |
1063 | // already applied == open on ground, or open in inv, or active in inv |
1064 | // already applied == open on ground, or open in inv, or active in inv |
1064 | if (sack->flag [FLAG_APPLIED]) |
1065 | if (sack->flag [FLAG_APPLIED]) |
… | |
… | |
1070 | return 1; |
1071 | return 1; |
1071 | } |
1072 | } |
1072 | else if (!sack->env) |
1073 | else if (!sack->env) |
1073 | { |
1074 | { |
1074 | // active, but not ours: some other player has opened it |
1075 | // active, but not ours: some other player has opened it |
1075 | op->errormsg (format ("Somebody else is using the %s already.", query_name (sack))); |
1076 | op->failmsg (format ("Somebody else is using the %s already.", query_name (sack))); |
1076 | return 1; |
1077 | return 1; |
1077 | } |
1078 | } |
1078 | |
1079 | |
1079 | // fall through to opening it (active in inv) |
1080 | // fall through to opening it (active in inv) |
1080 | } |
1081 | } |
… | |
… | |
1305 | * move_on is zero, it needs to be manually applied (doesn't talk |
1306 | * move_on is zero, it needs to be manually applied (doesn't talk |
1306 | * to us). |
1307 | * to us). |
1307 | */ |
1308 | */ |
1308 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ) && !sign->move_on) |
1309 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ) && !sign->move_on) |
1309 | { |
1310 | { |
1310 | op->errormsg ("You are unable to read while blind!"); |
1311 | op->failmsg ("You are unable to read while blind!"); |
1311 | return; |
1312 | return; |
1312 | } |
1313 | } |
1313 | |
1314 | |
1314 | if (op->contr) |
1315 | if (op->contr) |
1315 | if (client *ns = op->contr->ns) |
1316 | if (client *ns = op->contr->ns) |
1316 | { |
1317 | { |
|
|
1318 | if (sign->sound) |
1317 | ns->play_sound (sign->sound); |
1319 | ns->play_sound (sign->sound); |
1318 | msgType = get_readable_message_type (sign); |
1320 | else if (autoapply) |
|
|
1321 | ns->play_sound (sound_find ("msg_voice")); |
1319 | |
1322 | |
1320 | if (ns->can_msg) |
1323 | if (ns->can_msg) |
1321 | ns->send_msg (NDI_NAVY, msgType->msgtype, &sign->msg); |
1324 | op->contr->infobox (MSG_CHANNEL ("examine"), format ("T<%s>\n\n\n\n%s", &sign->name, &sign->msg)); |
1322 | else |
1325 | else |
1323 | { |
1326 | { |
1324 | char newbuf[HUGE_BUF]; |
1327 | msgType = get_readable_message_type (sign); |
1325 | snprintf (newbuf, sizeof (newbuf), "%u %s", autoapply ? 1 : 0, &sign->msg); |
1328 | const char *somemsg = format ("%u %s", autoapply ? 1 : 0, &sign->msg); |
1326 | draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, newbuf, &sign->msg); |
1329 | draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, somemsg, &sign->msg); |
1327 | } |
1330 | } |
1328 | } |
1331 | } |
1329 | } |
1332 | } |
1330 | |
1333 | |
1331 | /** |
1334 | /** |
… | |
… | |
1481 | } |
1484 | } |
1482 | |
1485 | |
1483 | case CONVERTER: |
1486 | case CONVERTER: |
1484 | if (convert_item (victim, trap) < 0) |
1487 | if (convert_item (victim, trap) < 0) |
1485 | { |
1488 | { |
1486 | originator->errormsg (format ("The %s seems to be broken!", query_name (trap))); |
1489 | originator->failmsg (format ("The %s seems to be broken!", query_name (trap))); |
1487 | get_archetype ("burnout")->insert_at (trap, trap); |
1490 | get_archetype ("burnout")->insert_at (trap, trap); |
1488 | } |
1491 | } |
1489 | |
1492 | |
1490 | goto leave; |
1493 | goto leave; |
1491 | |
1494 | |
… | |
… | |
1526 | * players output. |
1529 | * players output. |
1527 | */ |
1530 | */ |
1528 | if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2)) |
1531 | if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2)) |
1529 | victim->statusmsg (trap->msg, NDI_NAVY); |
1532 | victim->statusmsg (trap->msg, NDI_NAVY); |
1530 | |
1533 | |
|
|
1534 | trap->play_sound (trap->sound); |
1531 | victim->enter_exit (trap); |
1535 | victim->enter_exit (trap); |
1532 | } |
1536 | } |
1533 | goto leave; |
1537 | goto leave; |
1534 | |
1538 | |
1535 | case ENCOUNTER: |
1539 | case ENCOUNTER: |
… | |
… | |
1557 | goto leave; |
1561 | goto leave; |
1558 | |
1562 | |
1559 | case RUNE: |
1563 | case RUNE: |
1560 | case TRAP: |
1564 | case TRAP: |
1561 | if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) |
1565 | if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) |
1562 | { |
|
|
1563 | spring_trap (trap, victim); |
1566 | spring_trap (trap, victim); |
1564 | } |
|
|
1565 | goto leave; |
1567 | goto leave; |
1566 | |
1568 | |
1567 | default: |
1569 | default: |
1568 | LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " |
1570 | LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " |
1569 | "handled in move_apply()\n", &trap->name, &trap->arch->archname, trap->type); |
1571 | "handled in move_apply()\n", &trap->name, &trap->arch->archname, trap->type); |
… | |
… | |
1583 | int lev_diff; |
1585 | int lev_diff; |
1584 | object *skill_ob; |
1586 | object *skill_ob; |
1585 | |
1587 | |
1586 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1588 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1587 | { |
1589 | { |
1588 | op->errormsg ("You are unable to read while blind!"); |
1590 | op->failmsg ("You are unable to read while blind!"); |
1589 | return; |
1591 | return; |
1590 | } |
1592 | } |
1591 | |
1593 | |
1592 | if (!tmp->msg) |
1594 | if (!tmp->msg) |
1593 | { |
1595 | { |
1594 | op->errormsg (format ("You open the %s and find it empty.", &tmp->name)); |
1596 | op->failmsg (format ("You open the %s and find it empty.", &tmp->name)); |
1595 | return; |
1597 | return; |
1596 | } |
1598 | } |
1597 | |
1599 | |
1598 | /* need a literacy skill to read stuff! */ |
1600 | /* need a literacy skill to read stuff! */ |
1599 | skill_ob = find_skill_by_name (op, tmp->skill); |
1601 | skill_ob = find_skill_by_name (op, tmp->skill); |
1600 | if (!skill_ob) |
1602 | if (!skill_ob) |
1601 | { |
1603 | { |
1602 | op->errormsg (format ("You are unable to decipher the strange symbols. H<You lack the %s skill to read this.>", &tmp->skill)); |
1604 | op->failmsg (format ("You are unable to decipher the strange symbols. H<You lack the %s skill to read this.>", &tmp->skill)); |
1603 | return; |
1605 | return; |
1604 | } |
1606 | } |
1605 | |
1607 | |
1606 | lev_diff = tmp->level - (skill_ob->level + 5); |
1608 | lev_diff = tmp->level - (skill_ob->level + 5); |
1607 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
1609 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
1608 | { |
1610 | { |
1609 | op->errormsg (lev_diff < 2 ? "This book is just barely beyond your comprehension." |
1611 | op->failmsg (lev_diff < 2 ? "This book is just barely beyond your comprehension." |
1610 | : lev_diff < 3 ? "This book is slightly beyond your comprehension." |
1612 | : lev_diff < 3 ? "This book is slightly beyond your comprehension." |
1611 | : lev_diff < 5 ? "This book is beyond your comprehension." |
1613 | : lev_diff < 5 ? "This book is beyond your comprehension." |
1612 | : lev_diff < 8 ? "This book is quite a bit beyond your comprehension." |
1614 | : lev_diff < 8 ? "This book is quite a bit beyond your comprehension." |
1613 | : lev_diff < 15 ? "This book is way beyond your comprehension." |
1615 | : lev_diff < 15 ? "This book is way beyond your comprehension." |
1614 | : "This book is totally beyond your comprehension."); |
1616 | : "This book is totally beyond your comprehension."); |
… | |
… | |
1618 | readable_message_type *msgType = get_readable_message_type (tmp); |
1620 | readable_message_type *msgType = get_readable_message_type (tmp); |
1619 | |
1621 | |
1620 | if (player *pl = op->contr) |
1622 | if (player *pl = op->contr) |
1621 | if (client *ns = pl->ns) |
1623 | if (client *ns = pl->ns) |
1622 | if (ns->can_msg) |
1624 | if (ns->can_msg) |
1623 | { |
1625 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
1624 | dynbuf_text buf; |
|
|
1625 | buf << long_desc (tmp, op) |
|
|
1626 | << "\n\n" |
|
|
1627 | << tmp->msg |
|
|
1628 | << '\0'; |
|
|
1629 | ns->send_msg (NDI_NAVY, msgType->msgtype, buf.linearise ()); |
|
|
1630 | } |
|
|
1631 | else |
1626 | else |
1632 | draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, |
1627 | draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, |
1633 | msgType->message_type, msgType->message_subtype, |
1628 | msgType->message_type, msgType->message_subtype, |
1634 | "You open the %s and start reading.\n%s", (char *)"%s\n%s", |
1629 | "You open the %s and start reading.\n%s", (char *)"%s\n%s", |
1635 | long_desc (tmp, op), &tmp->msg); |
1630 | long_desc (tmp, op), &tmp->msg); |
… | |
… | |
1665 | { |
1660 | { |
1666 | switch (learn_skill (op, tmp)) |
1661 | switch (learn_skill (op, tmp)) |
1667 | { |
1662 | { |
1668 | case 0: |
1663 | case 0: |
1669 | op->play_sound (sound_find ("generic_fail")); |
1664 | op->play_sound (sound_find ("generic_fail")); |
1670 | op->errormsg (format ("You already possess the knowledge held within the %s.", query_name (tmp))); |
1665 | op->failmsg (format ("You already possess the knowledge held within the %s.", query_name (tmp))); |
1671 | break; |
1666 | break; |
1672 | |
1667 | |
1673 | case 1: |
1668 | case 1: |
1674 | decrease_ob (tmp); |
1669 | decrease_ob (tmp); |
1675 | op->play_sound (sound_find ("skill_learn")); |
1670 | op->play_sound (sound_find ("skill_learn")); |
… | |
… | |
1677 | break; |
1672 | break; |
1678 | |
1673 | |
1679 | default: |
1674 | default: |
1680 | decrease_ob (tmp); |
1675 | decrease_ob (tmp); |
1681 | op->play_sound (sound_find ("generic_fail")); |
1676 | op->play_sound (sound_find ("generic_fail")); |
1682 | op->errormsg (format ("You fail to learn the knowledge of the %s.\n", query_name (tmp))); |
1677 | op->failmsg (format ("You fail to learn the knowledge of the %s.\n", query_name (tmp))); |
1683 | break; |
1678 | break; |
1684 | } |
1679 | } |
1685 | } |
1680 | } |
1686 | |
1681 | |
1687 | /** |
1682 | /** |
… | |
… | |
1738 | { |
1733 | { |
1739 | LOG (llevError, "BUG: do_forget_spell(): spell not known\n"); |
1734 | LOG (llevError, "BUG: do_forget_spell(): spell not known\n"); |
1740 | return; |
1735 | return; |
1741 | } |
1736 | } |
1742 | |
1737 | |
1743 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", spell); |
1738 | op->failmsg (format ("You lose knowledge of %s.", spell)); |
1744 | player_unready_range_ob (op->contr, spob); |
1739 | player_unready_range_ob (op->contr, spob); |
1745 | esrv_remove_spell (op->contr, spob); |
1740 | esrv_remove_spell (op->contr, spob); |
1746 | spob->destroy (); |
1741 | spob->destroy (); |
1747 | } |
1742 | } |
1748 | |
1743 | |
… | |
… | |
1756 | { |
1751 | { |
1757 | object *skop, *spell, *spell_skill; |
1752 | object *skop, *spell, *spell_skill; |
1758 | |
1753 | |
1759 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1754 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1760 | { |
1755 | { |
1761 | op->errormsg ("You are unable to read while blind."); |
1756 | op->failmsg ("You are unable to read while blind."); |
1762 | return; |
1757 | return; |
1763 | } |
1758 | } |
1764 | |
1759 | |
1765 | /* artifact_spellbooks have 'slaying' field point to a spell name, |
1760 | /* artifact_spellbooks have 'slaying' field point to a spell name, |
1766 | * instead of having their spell stored in stats.sp. These are |
1761 | * instead of having their spell stored in stats.sp. These are |
… | |
… | |
1769 | if (tmp->slaying) |
1764 | if (tmp->slaying) |
1770 | { |
1765 | { |
1771 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1766 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1772 | if (!spell) |
1767 | if (!spell) |
1773 | { |
1768 | { |
1774 | op->errormsg (format ("The book's formula for %s is incomplete.", &tmp->slaying)); |
1769 | op->failmsg (format ("The book's formula for %s is incomplete.", &tmp->slaying)); |
1775 | return; |
1770 | return; |
1776 | } |
1771 | } |
1777 | else |
1772 | else |
1778 | insert_ob_in_ob (spell, tmp); |
1773 | insert_ob_in_ob (spell, tmp); |
1779 | |
1774 | |
… | |
… | |
1784 | |
1779 | |
1785 | /* need a literacy skill to learn spells. Also, having a literacy level |
1780 | /* need a literacy skill to learn spells. Also, having a literacy level |
1786 | * lower than the spell will make learning the spell more difficult */ |
1781 | * lower than the spell will make learning the spell more difficult */ |
1787 | if (!skop) |
1782 | if (!skop) |
1788 | { |
1783 | { |
1789 | op->errormsg (format ("You can't read! Your attempt fails. H<You lack the %s skill.>", &tmp->skill)); |
1784 | op->failmsg (format ("You can't read! Your attempt fails. H<You lack the %s skill.>", &tmp->skill)); |
1790 | return; |
1785 | return; |
1791 | } |
1786 | } |
1792 | |
1787 | |
1793 | spell = tmp->inv; |
1788 | spell = tmp->inv; |
1794 | |
1789 | |
1795 | if (!spell) |
1790 | if (!spell) |
1796 | { |
1791 | { |
1797 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1792 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1798 | op->errormsg ("The spellbook symbols make no sense. This is a bug, please report!"); |
1793 | op->failmsg ("The spellbook symbols make no sense. This is a bug, please report!"); |
1799 | return; |
1794 | return; |
1800 | } |
1795 | } |
1801 | |
1796 | |
1802 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1797 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1803 | { |
1798 | { |
1804 | op->errormsg (format ("You are unable to decipher the strange symbols. H<Your %s level is too low.>", &tmp->skill)); |
1799 | op->failmsg (format ("You are unable to decipher the strange symbols. H<Your %s level is too low.>", &tmp->skill)); |
1805 | return; |
1800 | return; |
1806 | } |
1801 | } |
1807 | |
1802 | |
1808 | op->statusmsg (format ("The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name)); |
1803 | op->statusmsg (format ("The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name)); |
1809 | |
1804 | |
… | |
… | |
1832 | { |
1827 | { |
1833 | spell_skill = find_skill_by_name (op, spell->skill); |
1828 | spell_skill = find_skill_by_name (op, spell->skill); |
1834 | |
1829 | |
1835 | if (!spell_skill) |
1830 | if (!spell_skill) |
1836 | { |
1831 | { |
1837 | op->errormsg (format ("You lack the skill %s to use this spell.", &spell->skill)); |
1832 | op->failmsg (format ("You lack the skill %s to use this spell.", &spell->skill)); |
1838 | return; |
1833 | return; |
1839 | } |
1834 | } |
1840 | |
1835 | |
1841 | if (spell_skill->level < spell->level) |
1836 | if (spell_skill->level < spell->level) |
1842 | { |
1837 | { |
1843 | op->errormsg (format ("You need to be level %d in %s to learn this spell.", spell->level, &spell->skill)); |
1838 | op->failmsg (format ("You need to be level %d in %s to learn this spell.", spell->level, &spell->skill)); |
1844 | return; |
1839 | return; |
1845 | } |
1840 | } |
1846 | } |
1841 | } |
1847 | |
1842 | |
1848 | /* Logic as follows |
1843 | /* Logic as follows |
… | |
… | |
1857 | * Overall, chances are the same but a player will find having a high |
1852 | * Overall, chances are the same but a player will find having a high |
1858 | * literacy rate very useful! -b.t. |
1853 | * literacy rate very useful! -b.t. |
1859 | */ |
1854 | */ |
1860 | if (QUERY_FLAG (op, FLAG_CONFUSED)) |
1855 | if (QUERY_FLAG (op, FLAG_CONFUSED)) |
1861 | { |
1856 | { |
1862 | op->errormsg ("In your confused state you flub the wording of the text!"); |
1857 | op->failmsg ("In your confused state you flub the wording of the text!"); |
1863 | scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), MAX (spell->stats.sp, spell->stats.grace)); |
1858 | scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), MAX (spell->stats.sp, spell->stats.grace)); |
1864 | } |
1859 | } |
1865 | else if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || |
1860 | else if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || |
1866 | (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int]) |
1861 | (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int]) |
1867 | { |
1862 | { |
… | |
… | |
1873 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
1868 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
1874 | } |
1869 | } |
1875 | else |
1870 | else |
1876 | { |
1871 | { |
1877 | op->contr->play_sound (sound_find ("fumble_spell")); |
1872 | op->contr->play_sound (sound_find ("fumble_spell")); |
1878 | op->errormsg ("You fail to learn the spell. H<Wis (priests) or Int (wizards) governs the chance of learning a prayer or spell.>\n"); |
1873 | op->failmsg ("You fail to learn the spell. H<Wis (priests) or Int (wizards) governs the chance of learning a prayer or spell.>\n"); |
1879 | } |
1874 | } |
1880 | |
1875 | |
1881 | decrease_ob (tmp); |
1876 | decrease_ob (tmp); |
1882 | } |
1877 | } |
1883 | |
1878 | |
… | |
… | |
1889 | { |
1884 | { |
1890 | object *skop; |
1885 | object *skop; |
1891 | |
1886 | |
1892 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1887 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1893 | { |
1888 | { |
1894 | op->errormsg ("You are unable to read while blind."); |
1889 | op->failmsg ("You are unable to read while blind."); |
1895 | return; |
1890 | return; |
1896 | } |
1891 | } |
1897 | |
1892 | |
1898 | if (!tmp->inv || tmp->inv->type != SPELL) |
1893 | if (!tmp->inv || tmp->inv->type != SPELL) |
1899 | { |
1894 | { |
1900 | op->errormsg ("The scroll just doesn't make sense! H<...and never will make sense.>"); |
1895 | op->failmsg ("The scroll just doesn't make sense! H<...and never will make sense.>"); |
1901 | return; |
1896 | return; |
1902 | } |
1897 | } |
1903 | |
1898 | |
1904 | if (op->type == PLAYER) |
1899 | if (op->type == PLAYER) |
1905 | { |
1900 | { |
… | |
… | |
1911 | */ |
1906 | */ |
1912 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
1907 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
1913 | |
1908 | |
1914 | if (!skop) |
1909 | if (!skop) |
1915 | { |
1910 | { |
1916 | op->errormsg (format ("You are unable to decipher the strange symbols. H<You lack the %s skill.>", &skill_names[SK_LITERACY])); |
1911 | op->failmsg (format ("You are unable to decipher the strange symbols. H<You lack the %s skill.>", &skill_names[SK_LITERACY])); |
1917 | return; |
1912 | return; |
1918 | } |
1913 | } |
1919 | |
1914 | |
1920 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
1915 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
1921 | change_exp (op, exp_gain, skop->skill, 0); |
1916 | change_exp (op, exp_gain, skop->skill, 0); |
… | |
… | |
1998 | { |
1993 | { |
1999 | /* usual case - no dragon meal: */ |
1994 | /* usual case - no dragon meal: */ |
2000 | if (op->stats.food + tmp->stats.food > 999) |
1995 | if (op->stats.food + tmp->stats.food > 999) |
2001 | { |
1996 | { |
2002 | if (tmp->type == FOOD || tmp->type == FLESH) |
1997 | if (tmp->type == FOOD || tmp->type == FLESH) |
2003 | op->errormsg ("You feel full, but what a waste of food!"); |
1998 | op->failmsg ("You feel full, but what a waste of food!"); |
2004 | else |
1999 | else |
2005 | op->statusmsg ("Most of the drink goes down your face not your throat!"); |
2000 | op->statusmsg ("Most of the drink goes down your face not your throat!"); |
2006 | } |
2001 | } |
|
|
2002 | |
|
|
2003 | tmp->play_sound ( |
|
|
2004 | tmp->sound |
|
|
2005 | ? tmp->sound |
|
|
2006 | : tmp->type == DRINK |
|
|
2007 | ? sound_find ("eat_drink") |
|
|
2008 | : sound_find ("eat_food") |
|
|
2009 | ); |
2007 | |
2010 | |
2008 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2011 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2009 | { |
2012 | { |
2010 | const char *buf; |
2013 | const char *buf; |
2011 | |
2014 | |
… | |
… | |
2189 | { |
2192 | { |
2190 | abil->last_eat = meal->last_eat; /* write: last_eat <new attnr focus> */ |
2193 | abil->last_eat = meal->last_eat; /* write: last_eat <new attnr focus> */ |
2191 | |
2194 | |
2192 | if (meal->last_eat != abil->stats.exp) |
2195 | if (meal->last_eat != abil->stats.exp) |
2193 | op->statusmsg (format ( |
2196 | op->statusmsg (format ( |
2194 | "Your metabolism prepares to focus on %s!\n" |
2197 | "Your metabolism prepares to focus on %s!\n" |
2195 | "The change will happen at level %d.", |
2198 | "The change will happen at level %d.", |
2196 | change_resist_msg[meal->last_eat], |
2199 | change_resist_msg[meal->last_eat], |
2197 | abil->level + 1 |
2200 | abil->level + 1 |
2198 | )); |
2201 | )); |
2199 | else |
2202 | else |
2200 | { |
2203 | { |
2201 | op->statusmsg (format ("Your metabolism will continue to focus on %s.", change_resist_msg[meal->last_eat])); |
2204 | op->statusmsg (format ("Your metabolism will continue to focus on %s.", change_resist_msg[meal->last_eat])); |
2202 | abil->last_eat = 0; |
2205 | abil->last_eat = 0; |
… | |
… | |
2215 | { |
2218 | { |
2216 | object *armor; |
2219 | object *armor; |
2217 | |
2220 | |
2218 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2221 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2219 | { |
2222 | { |
2220 | op->errormsg ("Something blocks the magic of the scroll. H<This area prevents magic effects.>"); |
2223 | op->failmsg ("Something blocks the magic of the scroll. H<This area prevents magic effects.>"); |
2221 | return; |
2224 | return; |
2222 | } |
2225 | } |
2223 | |
2226 | |
2224 | armor = find_marked_object (op); |
2227 | armor = find_marked_object (op); |
2225 | |
2228 | |
2226 | if (!armor) |
2229 | if (!armor) |
2227 | { |
2230 | { |
2228 | op->errormsg ("You need to mark an armor object. Use the right mouse button popup or the mark command to do this."); |
2231 | op->failmsg ("You need to mark an armor object. Use the right mouse button popup or the mark command to do this."); |
2229 | return; |
2232 | return; |
2230 | } |
2233 | } |
2231 | |
2234 | |
2232 | if (armor->type != ARMOUR |
2235 | if (armor->type != ARMOUR |
2233 | && armor->type != CLOAK |
2236 | && armor->type != CLOAK |
2234 | && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) |
2237 | && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) |
2235 | { |
2238 | { |
2236 | op->errormsg ("Your marked item is not armour!\n"); |
2239 | op->failmsg ("Your marked item is not armour!\n"); |
2237 | return; |
2240 | return; |
2238 | } |
2241 | } |
2239 | |
2242 | |
2240 | op->statusmsg ("Applying armour enchantment."); |
2243 | op->statusmsg ("Applying armour enchantment."); |
2241 | improve_armour (op, tmp, armor); |
2244 | improve_armour (op, tmp, armor); |
… | |
… | |
2245 | apply_poison (object *op, object *tmp) |
2248 | apply_poison (object *op, object *tmp) |
2246 | { |
2249 | { |
2247 | if (op->type == PLAYER) |
2250 | if (op->type == PLAYER) |
2248 | { |
2251 | { |
2249 | op->contr->play_sound (sound_find ("drink_poison")); |
2252 | op->contr->play_sound (sound_find ("drink_poison")); |
2250 | op->errormsg ("Yech! That tasted poisonous!"); |
2253 | op->failmsg ("Yech! That tasted poisonous!"); |
2251 | strcpy (op->contr->killer, "poisonous booze"); |
2254 | strcpy (op->contr->killer, "poisonous booze"); |
2252 | } |
2255 | } |
2253 | |
2256 | |
2254 | if (tmp->stats.hp > 0) |
2257 | if (tmp->stats.hp > 0) |
2255 | { |
2258 | { |
… | |
… | |
2282 | |
2285 | |
2283 | #if 0 //TODO |
2286 | #if 0 //TODO |
2284 | if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) |
2287 | if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) |
2285 | return 0; /* This is a reset town portal */ |
2288 | return 0; /* This is a reset town portal */ |
2286 | #endif |
2289 | #endif |
|
|
2290 | |
|
|
2291 | LOG (llevError | logBacktrace, "sync map load due to %s\n", exit->debug_desc ()); |
2287 | |
2292 | |
2288 | maptile *exitmap = maptile::find_sync (EXIT_PATH (exit), exit->map); |
2293 | maptile *exitmap = maptile::find_sync (EXIT_PATH (exit), exit->map); |
2289 | |
2294 | |
2290 | if (exitmap) |
2295 | if (exitmap) |
2291 | { |
2296 | { |
… | |
… | |
2374 | |
2379 | |
2375 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2380 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2376 | { |
2381 | { |
2377 | if (op->type == PLAYER) |
2382 | if (op->type == PLAYER) |
2378 | { |
2383 | { |
2379 | op->errormsg ("You should pay for it first! H<You cannot use items marked as unpaid.>"); |
2384 | op->failmsg ("You should pay for it first! H<You cannot use items marked as unpaid.>"); |
2380 | return 1; |
2385 | return 1; |
2381 | } |
2386 | } |
2382 | else |
2387 | else |
2383 | return 0; /* monsters just skip unpaid items */ |
2388 | return 0; /* monsters just skip unpaid items */ |
2384 | } |
2389 | } |
… | |
… | |
2402 | { |
2407 | { |
2403 | op->statusmsg ("You turn the handle."); |
2408 | op->statusmsg ("You turn the handle."); |
2404 | op->play_sound (sound_find ("turn_handle")); |
2409 | op->play_sound (sound_find ("turn_handle")); |
2405 | } |
2410 | } |
2406 | else |
2411 | else |
2407 | op->errormsg ("The handle doesn't move."); |
2412 | op->failmsg ("The handle doesn't move."); |
2408 | |
2413 | |
2409 | return 1; |
2414 | return 1; |
2410 | |
2415 | |
2411 | case EXIT: |
2416 | case EXIT: |
2412 | if (op->type != PLAYER) |
2417 | if (op->type != PLAYER) |
2413 | return 0; |
2418 | return 0; |
2414 | |
2419 | |
2415 | if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp)) |
2420 | if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp)) |
2416 | op->errormsg (format ("The %s is closed.", query_name (tmp))); |
2421 | op->failmsg (format ("The %s is closed.", query_name (tmp))); |
2417 | else |
2422 | else |
2418 | { |
2423 | { |
2419 | /* Don't display messages for random maps. */ |
2424 | /* Don't display messages for random maps. */ |
2420 | if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2)) |
2425 | if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2)) |
2421 | op->statusmsg (tmp->msg, NDI_NAVY); |
2426 | op->statusmsg (tmp->msg, NDI_NAVY); |
… | |
… | |
2546 | timeofday_t tod; |
2551 | timeofday_t tod; |
2547 | |
2552 | |
2548 | get_tod (&tod); |
2553 | get_tod (&tod); |
2549 | op->play_sound (sound_find ("sound_clock")); |
2554 | op->play_sound (sound_find ("sound_clock")); |
2550 | op->statusmsg (format ( |
2555 | op->statusmsg (format ( |
2551 | "It is %d minute%s past %d o'clock %s", |
2556 | "It is %d minute%s past %d o'clock %s", |
2552 | tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), |
2557 | tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), |
2553 | ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am") |
2558 | ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am") |
2554 | )); |
2559 | )); |
2555 | return 1; |
2560 | return 1; |
2556 | } |
2561 | } |
2557 | else |
2562 | else |
2558 | return 0; |
2563 | return 0; |
… | |
… | |
2603 | if (op->env && (pl->move_type & MOVE_FLYING)) |
2608 | if (op->env && (pl->move_type & MOVE_FLYING)) |
2604 | { |
2609 | { |
2605 | /* player is flying and applying object not in inventory */ |
2610 | /* player is flying and applying object not in inventory */ |
2606 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2611 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2607 | { |
2612 | { |
2608 | op->errormsg ("But you are floating high above the ground! H<You have to stop levitating first, if you can.>"); |
2613 | pl->failmsg ("But you are floating high above the ground! H<You have to stop levitating first, if you can.>"); |
2609 | return 0; |
2614 | return 0; |
2610 | } |
2615 | } |
2611 | } |
2616 | } |
2612 | |
2617 | |
2613 | pl->contr->last_used = op; |
2618 | pl->contr->last_used = op; |
2614 | |
2619 | |
2615 | tmp = manual_apply (pl, op, aflag); |
2620 | tmp = manual_apply (pl, op, aflag); |
2616 | if (!quiet) |
2621 | if (!quiet) |
2617 | { |
2622 | { |
2618 | if (tmp == 0) |
2623 | if (tmp == 0) |
2619 | op->statusmsg (format ("I don't know how to apply the %s.", query_name (op))); |
2624 | pl->statusmsg (format ("I don't know how to apply the %s.", query_name (op))); |
2620 | else if (tmp == 2) |
2625 | else if (tmp == 2) |
2621 | op->errormsg ("You must get it first!\n"); |
2626 | pl->failmsg ("You must get it first!\n"); |
2622 | } |
2627 | } |
2623 | |
2628 | |
2624 | return tmp; |
2629 | return tmp; |
2625 | } |
2630 | } |
2626 | |
2631 | |
… | |
… | |
2763 | |
2768 | |
2764 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2769 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2765 | { |
2770 | { |
2766 | if (who->contr) |
2771 | if (who->contr) |
2767 | { |
2772 | { |
2768 | who->errormsg ("Oops, it feels deadly cold!"); |
2773 | who->failmsg ("Oops, it feels deadly cold!"); |
2769 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2774 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2770 | } |
2775 | } |
2771 | } |
2776 | } |
2772 | |
2777 | |
2773 | if (who->contr) |
2778 | if (who->contr) |
… | |
… | |
2883 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2888 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2884 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->is_range ()) |
2889 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->is_range ()) |
2885 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED))) |
2890 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED))) |
2886 | { |
2891 | { |
2887 | if (aflags & AP_PRINT) |
2892 | if (aflags & AP_PRINT) |
2888 | new_draw_info (NDI_UNIQUE, 0, who, query_name (tmp)); |
2893 | who->failmsg (query_name (tmp)); |
2889 | else |
2894 | else |
2890 | unapply_special (who, tmp, aflags); |
2895 | unapply_special (who, tmp, aflags); |
2891 | } |
2896 | } |
2892 | else |
2897 | else |
2893 | { |
2898 | { |
2894 | /* In this case, we want to try and remove a cursed item. |
2899 | /* In this case, we want to try and remove a cursed item. |
2895 | * While we know it won't work, we want unapply_special to |
2900 | * While we know it won't work, we want unapply_special to |
2896 | * at least generate the message. |
2901 | * at least generate the message. |
2897 | */ |
2902 | */ |
2898 | new_draw_info_format (NDI_UNIQUE, 0, who, |
2903 | who->failmsg (format ("No matter how hard you try, you just can't remove the %s." CANNOT_REMOVE_CURSED, query_name (tmp))); |
2899 | "No matter how hard you try, you just can't remove the %s." CANNOT_REMOVE_CURSED, |
|
|
2900 | query_name (tmp)); |
|
|
2901 | return 1; |
2904 | return 1; |
2902 | } |
2905 | } |
2903 | |
2906 | |
2904 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2907 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2905 | { |
2908 | { |
… | |
… | |
2928 | |
2931 | |
2929 | /* If we are just printing, we don't care about cursed status */ |
2932 | /* If we are just printing, we don't care about cursed status */ |
2930 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!(QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)))) |
2933 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!(QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)))) |
2931 | { |
2934 | { |
2932 | if (aflags & AP_PRINT) |
2935 | if (aflags & AP_PRINT) |
2933 | new_draw_info (NDI_UNIQUE, 0, who, query_name (tmp)); |
2936 | who->failmsg (query_name (tmp)); |
2934 | else |
2937 | else |
2935 | unapply_special (who, tmp, aflags); |
2938 | unapply_special (who, tmp, aflags); |
2936 | } |
2939 | } |
2937 | else |
2940 | else |
2938 | { |
2941 | { |
2939 | /* Cursed item that we can't unequip - tell the player. |
2942 | /* Cursed item that we can't unequip - tell the player. |
2940 | * Note this could be annoying if this is just one of a few, |
2943 | * Note this could be annoying if this is just one of a few, |
2941 | * so it may not be critical (eg, putting on a ring and you have |
2944 | * so it may not be critical (eg, putting on a ring and you have |
2942 | * one cursed ring.) |
2945 | * one cursed ring.) |
2943 | */ |
2946 | */ |
2944 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp)); |
2947 | who->failmsg (format ("The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp))); |
2945 | } |
2948 | } |
2946 | |
2949 | |
2947 | last = tmp->below; |
2950 | last = tmp->below; |
2948 | } |
2951 | } |
2949 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
2952 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
… | |
… | |
3130 | if (basic_flag == AP_APPLY) |
3133 | if (basic_flag == AP_APPLY) |
3131 | return 0; |
3134 | return 0; |
3132 | |
3135 | |
3133 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3136 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3134 | { |
3137 | { |
3135 | new_draw_info_format (NDI_UNIQUE, 0, who, |
3138 | who->failmsg (format ("No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, query_name (op))); |
3136 | "No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, |
|
|
3137 | query_name (op)); |
|
|
3138 | return 1; |
3139 | return 1; |
3139 | } |
3140 | } |
3140 | |
3141 | |
3141 | return unapply_special (who, op, aflags); |
3142 | return unapply_special (who, op, aflags); |
3142 | } |
3143 | } |
… | |
… | |
3158 | /* Can't just apply this object. Lets see what not and what to do */ |
3159 | /* Can't just apply this object. Lets see what not and what to do */ |
3159 | if (int i = can_apply_object (who, op)) |
3160 | if (int i = can_apply_object (who, op)) |
3160 | { |
3161 | { |
3161 | if (i & CAN_APPLY_NEVER) |
3162 | if (i & CAN_APPLY_NEVER) |
3162 | { |
3163 | { |
3163 | new_draw_info_format (NDI_UNIQUE, 0, who, |
3164 | who->failmsg (format ("You don't have the body to use a %s. H<You can never apply this item.>", query_name (op))); |
3164 | "You don't have the body to use a %s. H<You can never apply this item.>", |
|
|
3165 | query_name (op)); |
|
|
3166 | return 1; |
3165 | return 1; |
3167 | } |
3166 | } |
3168 | else if (i & CAN_APPLY_RESTRICTION) |
3167 | else if (i & CAN_APPLY_RESTRICTION) |
3169 | { |
3168 | { |
3170 | new_draw_info_format (NDI_UNIQUE, 0, who, |
3169 | who->failmsg (format ( |
3171 | "You have a prohibition against using a %s. " |
3170 | "You have a prohibition against using a %s. " |
3172 | "H<Your belief, profession or class prevents you from applying this item.>", |
3171 | "H<Your belief, profession or class prevents you from applying this item.>", |
3173 | query_name (op)); |
3172 | query_name (op) |
|
|
3173 | )); |
3174 | return 1; |
3174 | return 1; |
3175 | } |
3175 | } |
3176 | |
3176 | |
3177 | if (who->type != PLAYER) |
3177 | if (who->type != PLAYER) |
3178 | { |
3178 | { |
… | |
… | |
3182 | } |
3182 | } |
3183 | else |
3183 | else |
3184 | { |
3184 | { |
3185 | if (who->contr->unapply == unapply_never || (i & CAN_APPLY_UNAPPLY_CHOICE && who->contr->unapply == unapply_nochoice)) |
3185 | if (who->contr->unapply == unapply_never || (i & CAN_APPLY_UNAPPLY_CHOICE && who->contr->unapply == unapply_nochoice)) |
3186 | { |
3186 | { |
3187 | new_draw_info (NDI_UNIQUE, 0, who, "You need to unapply some of the following item(s) or change your applymode:"); |
3187 | who->failmsg ("You need to unapply some of the following item(s) or change your applymode:"); |
3188 | unapply_for_ob (who, op, AP_PRINT); |
3188 | unapply_for_ob (who, op, AP_PRINT); |
3189 | return 1; |
3189 | return 1; |
3190 | } |
3190 | } |
3191 | else if (who->contr->unapply == unapply_always || !(i & CAN_APPLY_UNAPPLY_CHOICE)) |
3191 | else if (who->contr->unapply == unapply_always || !(i & CAN_APPLY_UNAPPLY_CHOICE)) |
3192 | if (unapply_for_ob (who, op, aflags)) |
3192 | if (unapply_for_ob (who, op, aflags)) |
… | |
… | |
3198 | { |
3198 | { |
3199 | skop = find_skill_by_name (who, op->skill); |
3199 | skop = find_skill_by_name (who, op->skill); |
3200 | |
3200 | |
3201 | if (!skop) |
3201 | if (!skop) |
3202 | { |
3202 | { |
3203 | new_draw_info_format (NDI_UNIQUE, 0, who, "You need the %s skill to use this item!", &op->skill); |
3203 | who->failmsg (format ("You need the %s skill to use this item!", &op->skill)); |
3204 | return 1; |
3204 | return 1; |
3205 | } |
3205 | } |
3206 | else |
3206 | else |
3207 | /* While experience will be credited properly, we want to change the |
3207 | /* While experience will be credited properly, we want to change the |
3208 | * skill so that the dam and wc get updated |
3208 | * skill so that the dam and wc get updated |
… | |
… | |
3212 | |
3212 | |
3213 | if (who->type == PLAYER |
3213 | if (who->type == PLAYER |
3214 | && op->item_power |
3214 | && op->item_power |
3215 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3215 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3216 | { |
3216 | { |
3217 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3218 | "Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); |
3217 | who->failmsg ("Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); |
3219 | return 1; |
3218 | return 1; |
3220 | } |
3219 | } |
3221 | |
3220 | |
3222 | /* Ok. We are now at the state where we can apply the new object. |
3221 | /* Ok. We are now at the state where we can apply the new object. |
3223 | * Note that we don't have the checks for can_use_... |
3222 | * Note that we don't have the checks for can_use_... |
… | |
… | |
3234 | switch (op->type) |
3233 | switch (op->type) |
3235 | { |
3234 | { |
3236 | case WEAPON: |
3235 | case WEAPON: |
3237 | if (!check_weapon_power (who, op->last_eat)) |
3236 | if (!check_weapon_power (who, op->last_eat)) |
3238 | { |
3237 | { |
3239 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " |
3238 | op->failmsg ("This weapon is too powerful for you to use. It would consume your soul!." LACK_ITEM_POWER); |
3240 | "It would consume your soul!." LACK_ITEM_POWER); |
|
|
3241 | |
3239 | |
3242 | if (tmp) |
3240 | if (tmp) |
3243 | insert_ob_in_ob (tmp, who); |
3241 | insert_ob_in_ob (tmp, who); |
3244 | |
3242 | |
3245 | return 1; |
3243 | return 1; |
… | |
… | |
3249 | // i.e. "R" can use Ragnarok's sword. |
3247 | // i.e. "R" can use Ragnarok's sword. |
3250 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3248 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3251 | { |
3249 | { |
3252 | /* if the weapon does not have the name as the character, can't use it. */ |
3250 | /* if the weapon does not have the name as the character, can't use it. */ |
3253 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3251 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3254 | new_draw_info (NDI_UNIQUE, 0, who, |
3252 | who->failmsg ("The weapon does not recognize you as its owner. H<Its name indicates that it belongs to somebody else.>"); |
3255 | "The weapon does not recognize you as its owner. " |
|
|
3256 | "H<Its name indicates that it belongs to somebody else.>"); |
|
|
3257 | |
3253 | |
3258 | if (tmp) |
3254 | if (tmp) |
3259 | insert_ob_in_ob (tmp, who); |
3255 | insert_ob_in_ob (tmp, who); |
3260 | |
3256 | |
3261 | return 1; |
3257 | return 1; |
3262 | } |
3258 | } |
3263 | |
3259 | |
3264 | if (!skop) |
3260 | if (!skop) |
3265 | { |
3261 | { |
3266 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO |
3262 | who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO |
3267 | return 1; |
3263 | return 1; |
3268 | } |
3264 | } |
3269 | |
3265 | |
3270 | SET_FLAG (op, FLAG_APPLIED); |
3266 | SET_FLAG (op, FLAG_APPLIED); |
3271 | who->change_skill (skop); |
3267 | who->change_skill (skop); |
3272 | |
3268 | |
3273 | if (who->contr) |
3269 | if (who->contr) |
3274 | who->change_weapon (who->contr->combat_ob = op); |
3270 | who->change_weapon (who->contr->combat_ob = op); |
3275 | |
3271 | |
3276 | new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); |
3272 | who->statusmsg (format ("You wield %s.", query_name (op))); |
3277 | |
3273 | |
3278 | SET_FLAG (who, FLAG_READY_WEAPON); |
3274 | SET_FLAG (who, FLAG_READY_WEAPON); |
3279 | change_abil (who, op); |
3275 | change_abil (who, op); |
3280 | break; |
3276 | break; |
3281 | |
3277 | |
… | |
… | |
3288 | case BRACERS: |
3284 | case BRACERS: |
3289 | case CLOAK: |
3285 | case CLOAK: |
3290 | case RING: |
3286 | case RING: |
3291 | case AMULET: |
3287 | case AMULET: |
3292 | SET_FLAG (op, FLAG_APPLIED); |
3288 | SET_FLAG (op, FLAG_APPLIED); |
3293 | new_draw_info_format (NDI_UNIQUE, 0, who, "You wear %s.", query_name (op)); |
3289 | who->statusmsg (format ("You wear %s.", query_name (op))); |
3294 | change_abil (who, op); |
3290 | change_abil (who, op); |
3295 | break; |
3291 | break; |
3296 | |
3292 | |
3297 | case LAMP: |
3293 | case LAMP: |
3298 | if (op->stats.food < 1) |
3294 | if (op->stats.food < 1) |
3299 | { |
3295 | { |
3300 | new_draw_info_format (NDI_UNIQUE, 0, who, |
3296 | who->failmsg (format ( |
3301 | "Your %s is out of fuel! " |
3297 | "Your %s is out of fuel! " |
3302 | "H<Lamps and similar items need fuel. They cannot be refilled.>", &op->name); |
3298 | "H<Lamps and similar items need fuel. They cannot be refilled.>", |
|
|
3299 | &op->name |
|
|
3300 | )); |
3303 | return 1; |
3301 | return 1; |
3304 | } |
3302 | } |
3305 | |
3303 | |
3306 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); |
3304 | who->statusmsg (format ("You turn on your %s.", &op->name)); |
|
|
3305 | |
3307 | tmp2 = arch_to_object (op->other_arch); |
3306 | tmp2 = arch_to_object (op->other_arch); |
3308 | tmp2->stats.food = op->stats.food; |
3307 | tmp2->stats.food = op->stats.food; |
3309 | SET_FLAG (tmp2, FLAG_APPLIED); |
3308 | SET_FLAG (tmp2, FLAG_APPLIED); |
3310 | |
3309 | |
3311 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
3310 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
… | |
… | |
3330 | who->update_stats (); |
3329 | who->update_stats (); |
3331 | |
3330 | |
3332 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3331 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3333 | if (who->type == PLAYER) |
3332 | if (who->type == PLAYER) |
3334 | { |
3333 | { |
3335 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3336 | "Oops, it feels deadly cold! " |
|
|
3337 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3334 | who->failmsg ("Oops, it feels deadly cold! H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3338 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3335 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3339 | } |
3336 | } |
3340 | |
3337 | |
3341 | if (who->type == PLAYER) |
3338 | if (who->type == PLAYER) |
3342 | esrv_send_item (who, tmp2); |
3339 | esrv_send_item (who, tmp2); |
… | |
… | |
3370 | who->change_weapon (pl->combat_ob = item); |
3367 | who->change_weapon (pl->combat_ob = item); |
3371 | goto found_weapon; |
3368 | goto found_weapon; |
3372 | } |
3369 | } |
3373 | } |
3370 | } |
3374 | |
3371 | |
3375 | new_draw_info_format (NDI_UNIQUE, 0, who, |
3372 | who->failmsg (format ( |
3376 | "You need to apply a '%s' melee weapon before readying this skill. " |
3373 | "You need to apply a '%s' melee weapon before readying this skill. " |
3377 | "H<Some skills need an item, in this case a melee weapon, to function.>", |
3374 | "H<Some skills need an item, in this case a melee weapon, to function.>", |
3378 | &op->skill); |
3375 | &op->skill |
|
|
3376 | )); |
3379 | return 1; |
3377 | return 1; |
3380 | |
3378 | |
3381 | found_weapon:; |
3379 | found_weapon:; |
3382 | } |
3380 | } |
3383 | else |
3381 | else |
… | |
… | |
3393 | //TODO: bows should/must all have skill missile weapon right now |
3391 | //TODO: bows should/must all have skill missile weapon right now |
3394 | who->change_weapon (pl->ranged_ob = item); |
3392 | who->change_weapon (pl->ranged_ob = item); |
3395 | goto found_bow; |
3393 | goto found_bow; |
3396 | } |
3394 | } |
3397 | |
3395 | |
3398 | new_draw_info (NDI_UNIQUE, 0, who, |
3396 | who->failmsg ( |
3399 | "You need to apply a missile weapon before readying this skill. " |
3397 | "You need to apply a missile weapon before readying this skill. " |
3400 | "H<Some skills need an item, in this case a missile weapon, to function.>"); |
3398 | "H<Some skills need an item, in this case a missile weapon, to function.>" |
|
|
3399 | ); |
3401 | return 1; |
3400 | return 1; |
3402 | |
3401 | |
3403 | found_bow:; |
3402 | found_bow:; |
3404 | } |
3403 | } |
3405 | else |
3404 | else |
3406 | who->change_weapon (pl->ranged_ob = op); |
3405 | who->change_weapon (pl->ranged_ob = op); |
3407 | } |
3406 | } |
3408 | |
3407 | |
3409 | if (!op->invisible) |
3408 | if (!op->invisible) |
3410 | { |
3409 | { |
3411 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); |
3410 | who->statusmsg (format ( |
3412 | new_draw_info_format (NDI_UNIQUE, 0, who, "You can now use the skill: %s.", &op->skill); |
3411 | "You ready %s." |
|
|
3412 | "You can now use the skill: %s.", |
|
|
3413 | query_name (op), |
|
|
3414 | &op->skill |
|
|
3415 | )); |
3413 | } |
3416 | } |
3414 | else |
3417 | else |
3415 | new_draw_info_format (NDI_UNIQUE, 0, who, "Readied skill: %s.", op->skill ? &op->skill : &op->name); |
3418 | who->statusmsg (format ("Readied skill: %s.", op->skill ? &op->skill : &op->name)); |
3416 | } |
3419 | } |
3417 | else |
3420 | else |
3418 | { |
3421 | { |
3419 | SET_FLAG (op, FLAG_APPLIED); |
3422 | SET_FLAG (op, FLAG_APPLIED); |
3420 | change_abil (who, op); |
3423 | change_abil (who, op); |
… | |
… | |
3425 | break; |
3428 | break; |
3426 | |
3429 | |
3427 | case BOW: |
3430 | case BOW: |
3428 | if (!check_weapon_power (who, op->last_eat)) |
3431 | if (!check_weapon_power (who, op->last_eat)) |
3429 | { |
3432 | { |
3430 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3431 | "That weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER); |
3433 | who->failmsg ("That weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER); |
3432 | |
3434 | |
3433 | if (tmp) |
3435 | if (tmp) |
3434 | insert_ob_in_ob (tmp, who); |
3436 | insert_ob_in_ob (tmp, who); |
3435 | |
3437 | |
3436 | return 1; |
3438 | return 1; |
3437 | } |
3439 | } |
3438 | |
3440 | |
3439 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3441 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3440 | { |
3442 | { |
3441 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3442 | "The weapon does not recognize you as its owner. " |
3443 | who->failmsg ("The weapon does not recognize you as its owner. " |
3443 | "H<Its name indicates that it belongs to somebody else.>"); |
3444 | "H<Its name indicates that it belongs to somebody else.>"); |
3444 | if (tmp) |
3445 | if (tmp) |
3445 | insert_ob_in_ob (tmp, who); |
3446 | insert_ob_in_ob (tmp, who); |
3446 | |
3447 | |
3447 | return 1; |
3448 | return 1; |
… | |
… | |
3453 | case HORN: |
3454 | case HORN: |
3454 | /* check for skill, alter player status */ |
3455 | /* check for skill, alter player status */ |
3455 | |
3456 | |
3456 | if (!skop) |
3457 | if (!skop) |
3457 | { |
3458 | { |
3458 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO |
3459 | who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO |
3459 | return 1; |
3460 | return 1; |
3460 | } |
3461 | } |
3461 | |
3462 | |
3462 | SET_FLAG (op, FLAG_APPLIED); |
3463 | SET_FLAG (op, FLAG_APPLIED); |
3463 | who->change_skill (skop); |
3464 | who->change_skill (skop); |
3464 | |
3465 | |
3465 | if (who->contr) |
3466 | if (who->contr) |
3466 | { |
3467 | { |
3467 | who->contr->ranged_ob = op; |
3468 | who->contr->ranged_ob = op; |
3468 | |
3469 | |
3469 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); |
3470 | who->statusmsg (format ("You ready %s.", query_name (op))); |
3470 | |
3471 | |
3471 | if (op->type == BOW) |
3472 | if (op->type == BOW) |
3472 | { |
3473 | { |
3473 | who->current_weapon = op; |
3474 | who->current_weapon = op; |
3474 | change_abil (who, op); |
3475 | change_abil (who, op); |
3475 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3476 | "You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op)); |
3476 | who->statusmsg (format ("You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op))); |
3477 | } |
3477 | } |
3478 | } |
3478 | } |
3479 | else |
3479 | else |
3480 | { |
3480 | { |
3481 | if (op->type == BOW) |
3481 | if (op->type == BOW) |
… | |
… | |
3491 | { |
3491 | { |
3492 | //TODO: wtf does this do? shouldn't this be managed automatically (slots?) |
3492 | //TODO: wtf does this do? shouldn't this be managed automatically (slots?) |
3493 | if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) |
3493 | if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) |
3494 | unapply_special (who, who->contr->ranged_ob, 0); |
3494 | unapply_special (who, who->contr->ranged_ob, 0); |
3495 | |
3495 | |
3496 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready your %s.", query_name (op)); |
3496 | who->statusmsg (format ("You ready your %s.", query_name (op))); |
3497 | |
3497 | |
3498 | who->contr->ranged_ob = op; |
3498 | who->contr->ranged_ob = op; |
3499 | } |
3499 | } |
3500 | break; |
3500 | break; |
3501 | |
3501 | |
3502 | default: |
3502 | default: |
3503 | new_draw_info_format (NDI_UNIQUE, 0, who, "You apply %s.", query_name (op)); |
3503 | who->statusmsg (format ("You apply %s.", query_name (op))); |
3504 | } /* end of switch op->type */ |
3504 | } |
3505 | |
3505 | |
3506 | SET_FLAG (op, FLAG_APPLIED); |
3506 | SET_FLAG (op, FLAG_APPLIED); |
3507 | |
3507 | |
3508 | if (tmp) |
3508 | if (tmp) |
3509 | tmp = insert_ob_in_ob (tmp, who); |
3509 | tmp = insert_ob_in_ob (tmp, who); |
… | |
… | |
3518 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
3518 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
3519 | |
3519 | |
3520 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3520 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3521 | if (who->type == PLAYER) |
3521 | if (who->type == PLAYER) |
3522 | { |
3522 | { |
3523 | new_draw_info (NDI_UNIQUE, 0, who, |
3523 | who->failmsg ( |
3524 | "Oops, it feels deadly cold! " |
3524 | "Oops, it feels deadly cold! " |
3525 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3525 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>" |
|
|
3526 | ); |
3526 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3527 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3527 | } |
3528 | } |
3528 | |
3529 | |
3529 | if (who->type == PLAYER) |
3530 | if (who->type == PLAYER) |
3530 | { |
3531 | { |
… | |
… | |
3768 | { |
3769 | { |
3769 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3770 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3770 | { |
3771 | { |
3771 | assign (who->contr->killer, food->name); |
3772 | assign (who->contr->killer, food->name); |
3772 | hit_player (who, food->stats.hp, food, AT_POISON, 1); |
3773 | hit_player (who, food->stats.hp, food, AT_POISON, 1); |
3773 | new_draw_info (NDI_UNIQUE, 0, who, "Eck!...that was poisonous!"); |
3774 | who->failmsg ("Eck!...that was poisonous!"); |
3774 | } |
3775 | } |
3775 | else |
3776 | else |
3776 | { |
3777 | { |
3777 | if (food->stats.hp > 0) |
3778 | if (food->stats.hp > 0) |
3778 | new_draw_info (NDI_UNIQUE, 0, who, "You begin to feel better."); |
3779 | who->statusmsg ("You begin to feel better."); |
3779 | else |
3780 | else |
3780 | new_draw_info (NDI_UNIQUE, 0, who, "Eck!...that was poisonous!"); |
3781 | who->failmsg ("Eck!...that was poisonous!"); |
|
|
3782 | |
3781 | who->stats.hp += food->stats.hp; |
3783 | who->stats.hp += food->stats.hp; |
3782 | } |
3784 | } |
3783 | } |
3785 | } |
3784 | if (food->stats.sp != 0) |
3786 | if (food->stats.sp != 0) |
3785 | { |
3787 | { |
3786 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3788 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3787 | { |
3789 | { |
3788 | new_draw_info (NDI_UNIQUE, 0, who, "You are drained of mana!"); |
3790 | who->failmsg ("You are drained of mana!"); |
3789 | who->stats.sp -= food->stats.sp; |
3791 | who->stats.sp -= food->stats.sp; |
3790 | if (who->stats.sp < 0) |
3792 | if (who->stats.sp < 0) |
3791 | who->stats.sp = 0; |
3793 | who->stats.sp = 0; |
3792 | } |
3794 | } |
3793 | else |
3795 | else |
3794 | { |
3796 | { |
3795 | new_draw_info (NDI_UNIQUE, 0, who, "You feel a rush of magical energy!"); |
3797 | who->statusmsg ("You feel a rush of magical energy!"); |
3796 | who->stats.sp += food->stats.sp; |
3798 | who->stats.sp += food->stats.sp; |
3797 | /* place limit on max sp from food? */ |
3799 | /* place limit on max sp from food? */ |
3798 | } |
3800 | } |
3799 | } |
3801 | } |
|
|
3802 | |
3800 | who->update_stats (); |
3803 | who->update_stats (); |
3801 | } |
3804 | } |
3802 | |
3805 | |
3803 | /** |
3806 | /** |
3804 | * Designed primarily to light torches/lanterns/etc. |
3807 | * Designed primarily to light torches/lanterns/etc. |
… | |
… | |
3831 | } |
3834 | } |
3832 | else |
3835 | else |
3833 | lighter->stats.food--; |
3836 | lighter->stats.food--; |
3834 | } |
3837 | } |
3835 | else if (lighter->last_eat) |
3838 | else if (lighter->last_eat) |
|
|
3839 | { |
3836 | { /* no charges left in lighter */ |
3840 | /* no charges left in lighter */ |
3837 | new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with a used up %s.", &item->name, &lighter->name); |
3841 | who->failmsg (format ("You attempt to light the %s with a used up %s.", &item->name, &lighter->name)); |
3838 | return; |
3842 | return; |
3839 | } |
3843 | } |
3840 | |
3844 | |
3841 | /* Perhaps we should split what we are trying to light on fire? |
3845 | /* Perhaps we should split what we are trying to light on fire? |
3842 | * I can't see many times when you would want to light multiple |
3846 | * I can't see many times when you would want to light multiple |
… | |
… | |
3848 | |
3852 | |
3849 | save_throw_object (item, AT_FIRE, who); |
3853 | save_throw_object (item, AT_FIRE, who); |
3850 | |
3854 | |
3851 | if (item->destroyed ()) |
3855 | if (item->destroyed ()) |
3852 | { |
3856 | { |
3853 | new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item->name, &lighter->name); |
3857 | who->statusmsg (format ("You light the %s with the %s.", &item->name, &lighter->name)); |
3854 | /* Need to update the player so that the players glow radius |
3858 | /* Need to update the player so that the players glow radius |
3855 | * gets changed. |
3859 | * gets changed. |
3856 | */ |
3860 | */ |
3857 | if (is_player_env) |
3861 | if (is_player_env) |
3858 | who->update_stats (); |
3862 | who->update_stats (); |
3859 | } |
3863 | } |
3860 | else |
3864 | else |
3861 | new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with the %s and fail.", &item->name, &lighter->name); |
3865 | who->failmsg (format ("You attempt to light the %s with the %s and fail.", &item->name, &lighter->name)); |
3862 | } |
3866 | } |
3863 | else /* nothing to light */ |
3867 | else |
3864 | new_draw_info (NDI_UNIQUE, 0, who, "You need to mark a lightable object."); |
3868 | who->failmsg ("You need to mark a lightable object."); |
3865 | |
|
|
3866 | } |
3869 | } |
3867 | |
3870 | |
3868 | /** |
3871 | /** |
3869 | * op made some mistake with a scroll, this takes care of punishment. |
3872 | * op made some mistake with a scroll, this takes care of punishment. |
3870 | * scroll_failure()- hacked directly from spell_failure |
3873 | * scroll_failure()- hacked directly from spell_failure |
… | |
… | |
3877 | |
3880 | |
3878 | if (failure <= -1 && failure > -15) |
3881 | if (failure <= -1 && failure > -15) |
3879 | { /* wonder */ |
3882 | { /* wonder */ |
3880 | object *tmp; |
3883 | object *tmp; |
3881 | |
3884 | |
3882 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!"); |
3885 | op->failmsg ("Your spell warps!"); |
3883 | tmp = get_archetype (SPELL_WONDER); |
3886 | tmp = get_archetype (SPELL_WONDER); |
3884 | cast_wonder (op, op, 0, tmp); |
3887 | cast_wonder (op, op, 0, tmp); |
3885 | tmp->destroy (); |
3888 | tmp->destroy (); |
3886 | } |
3889 | } |
3887 | else if (failure <= -15 && failure > -35) |
3890 | else if (failure <= -15 && failure > -35) |
3888 | { /* drain mana */ |
3891 | { /* drain mana */ |
3889 | new_draw_info (NDI_UNIQUE, 0, op, "Your mana is drained!."); |
3892 | op->failmsg ("Your mana is drained!"); |
3890 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
3893 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
3891 | if (op->stats.sp < 0) |
3894 | if (op->stats.sp < 0) |
3892 | op->stats.sp = 0; |
3895 | op->stats.sp = 0; |
3893 | } |
3896 | } |
3894 | else if (settings.spell_failure_effects == TRUE) |
3897 | else if (settings.spell_failure_effects == TRUE) |
3895 | { |
3898 | { |
3896 | if (failure <= -35 && failure > -60) |
3899 | if (failure <= -35 && failure > -60) |
3897 | { /* confusion */ |
3900 | { /* confusion */ |
3898 | new_draw_info (NDI_UNIQUE, 0, op, "The magic recoils on you!"); |
3901 | op->failmsg ("The magic recoils on you!"); |
3899 | confuse_player (op, op, power); |
3902 | confuse_player (op, op, power); |
3900 | } |
3903 | } |
3901 | else if (failure <= -60 && failure > -70) |
3904 | else if (failure <= -60 && failure > -70) |
3902 | { /* paralysis */ |
3905 | { /* paralysis */ |
3903 | new_draw_info (NDI_UNIQUE, 0, op, "The magic recoils and paralyzes " "you!"); |
3906 | op->failmsg ("The magic recoils and paralyzes you!"); |
3904 | paralyze_player (op, op, power); |
3907 | paralyze_player (op, op, power); |
3905 | } |
3908 | } |
3906 | else if (failure <= -70 && failure > -80) |
3909 | else if (failure <= -70 && failure > -80) |
3907 | { /* blind */ |
3910 | { /* blind */ |
3908 | new_draw_info (NDI_UNIQUE, 0, op, "The magic recoils on you!"); |
3911 | op->failmsg ("The magic recoils on you!"); |
3909 | blind_player (op, op, power); |
3912 | blind_player (op, op, power); |
3910 | } |
3913 | } |
3911 | else if (failure <= -80) |
3914 | else if (failure <= -80) |
3912 | { /* blast the immediate area */ |
3915 | { /* blast the immediate area */ |
3913 | object *tmp = get_archetype (LOOSE_MANA); |
3916 | object *tmp = get_archetype (LOOSE_MANA); |
3914 | cast_magic_storm (op, tmp, power); |
3917 | cast_magic_storm (op, tmp, power); |
3915 | new_draw_info (NDI_UNIQUE, 0, op, "You unleash uncontrolled mana!"); |
3918 | op->failmsg ("You unleash uncontrolled mana!"); |
3916 | tmp->destroy (); |
3919 | tmp->destroy (); |
3917 | } |
3920 | } |
3918 | } |
3921 | } |
3919 | } |
3922 | } |
3920 | |
3923 | |
… | |
… | |
4032 | |
4035 | |
4033 | marked = find_marked_object (pl); |
4036 | marked = find_marked_object (pl); |
4034 | |
4037 | |
4035 | if (!marked) |
4038 | if (!marked) |
4036 | { |
4039 | { |
4037 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); |
4040 | pl->failmsg (format ("Use the %s with what item?", query_name (transformer))); |
4038 | return; |
4041 | return; |
4039 | } |
4042 | } |
4040 | |
4043 | |
4041 | if (!marked->slaying) |
4044 | if (!marked->slaying) |
4042 | { |
4045 | { |
4043 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
4046 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
4044 | return; |
4047 | return; |
4045 | } |
4048 | } |
4046 | |
4049 | |
4047 | /* check whether they are compatible or not */ |
4050 | /* check whether they are compatible or not */ |
4048 | find = strstr (marked->slaying, transformer->arch->archname); |
4051 | find = strstr (marked->slaying, transformer->arch->archname); |
4049 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
4052 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
4050 | { |
4053 | { |
4051 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
4054 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
4052 | return; |
4055 | return; |
4053 | } |
4056 | } |
4054 | |
4057 | |
4055 | find += strlen (transformer->arch->archname) + 1; |
4058 | find += strlen (transformer->arch->archname) + 1; |
4056 | /* Item can be used, now find how many and what it yields */ |
4059 | /* Item can be used, now find how many and what it yields */ |
… | |
… | |
4066 | else |
4069 | else |
4067 | yield = 1; |
4070 | yield = 1; |
4068 | |
4071 | |
4069 | while (isdigit (*find)) |
4072 | while (isdigit (*find)) |
4070 | find++; |
4073 | find++; |
|
|
4074 | |
4071 | while (*find == ' ') |
4075 | while (*find == ' ') |
4072 | find++; |
4076 | find++; |
4073 | |
4077 | |
4074 | memset (got, 0, MAX_BUF); |
4078 | memset (got, 0, MAX_BUF); |
4075 | |
4079 | |
… | |
… | |
4086 | |
4090 | |
4087 | /* Now create new item, remove used ones when required. */ |
4091 | /* Now create new item, remove used ones when required. */ |
4088 | new_item = get_archetype (got); |
4092 | new_item = get_archetype (got); |
4089 | if (!new_item) |
4093 | if (!new_item) |
4090 | { |
4094 | { |
4091 | pl->errormsg (format ("This %s is strange, better to not use it.", query_base_name (marked, 0))); |
4095 | pl->failmsg (format ("This %s is strange, better to not use it.", query_base_name (marked, 0))); |
4092 | return; |
4096 | return; |
4093 | } |
4097 | } |
4094 | |
4098 | |
4095 | new_item->nrof = yield; |
4099 | new_item->nrof = yield; |
4096 | |
4100 | |