… | |
… | |
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.", 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" << marked->msg; |
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.", 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" << id->msg; |
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"); |
… | |
… | |
150 | } |
148 | } |
151 | |
149 | |
152 | if (buf.empty ()) |
150 | if (buf.empty ()) |
153 | buf << ("You have nothing that needs identifying"); |
151 | buf << ("You have nothing that needs identifying"); |
154 | |
152 | |
155 | pl->contr->infobox (buf); |
153 | pl->contr->infobox ("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."); |
631 | return 0; |
629 | return 0; |
632 | } |
630 | } |
633 | |
631 | |
634 | sacrifice_count = check_sacrifice (op, improver); |
632 | sacrifice_count = check_sacrifice (op, improver); |
635 | if (sacrifice_count <= 0) |
633 | if (sacrifice_count <= 0) |
… | |
… | |
637 | |
635 | |
638 | weapon->level = isqrt (sacrifice_count); |
636 | weapon->level = isqrt (sacrifice_count); |
639 | eat_item (op, improver->slaying, sacrifice_count); |
637 | eat_item (op, improver->slaying, sacrifice_count); |
640 | |
638 | |
641 | op->statusmsg (format ( |
639 | op->statusmsg (format ( |
642 | "Your sacrifice was accepted." |
640 | "Your sacrifice was accepted." |
643 | "Your *%s may be improved %d times.", |
641 | "Your *%s may be improved %d times.", |
644 | &weapon->name, weapon->level |
642 | &weapon->name, weapon->level |
645 | )); |
643 | )); |
646 | |
644 | |
647 | sprintf (buf, "%s's %s", &op->name, &weapon->name); |
645 | sprintf (buf, "%s's %s", &op->name, &weapon->name); |
648 | weapon->name = weapon->name_pl = buf; |
646 | weapon->name = weapon->name_pl = buf; |
649 | weapon->nrof = 0; /* prevents preparing n weapons in the same |
647 | weapon->nrof = 0; /* prevents preparing n weapons in the same |
… | |
… | |
673 | if (improver->stats.sp == IMPROVE_PREPARE) |
671 | if (improver->stats.sp == IMPROVE_PREPARE) |
674 | return prepare_weapon (op, improver, weapon); |
672 | return prepare_weapon (op, improver, weapon); |
675 | |
673 | |
676 | if (weapon->level == 0) |
674 | if (weapon->level == 0) |
677 | { |
675 | { |
678 | op->errormsg ("This weapon has not been prepared. H<You first ahve to prepare a weapon with a prepare weapon scroll.>"); |
676 | op->failmsg ("This weapon has not been prepared. H<You first ahve to prepare a weapon with a prepare weapon scroll.>"); |
679 | return 0; |
677 | return 0; |
680 | } |
678 | } |
681 | |
679 | |
682 | if (weapon->level == weapon->last_eat && weapon->item_power >= 100) |
680 | if (weapon->level == weapon->last_eat && weapon->item_power >= 100) |
683 | { |
681 | { |
684 | op->errormsg ("This weapon cannot be improved any more."); |
682 | op->failmsg ("This weapon cannot be improved any more."); |
685 | return 0; |
683 | return 0; |
686 | } |
684 | } |
687 | |
685 | |
688 | if (QUERY_FLAG (weapon, FLAG_APPLIED) && !check_weapon_power (op, weapon->last_eat + 1)) |
686 | if (QUERY_FLAG (weapon, FLAG_APPLIED) && !check_weapon_power (op, weapon->last_eat + 1)) |
689 | { |
687 | { |
690 | op->errormsg ("Improving the weapon will make it too " |
688 | op->failmsg ("Improving the weapon will make it too " |
691 | "powerful for you to use. Unready it if you " |
689 | "powerful for you to use. Unready it if you " |
692 | "really want to improve it."); |
690 | "really want to improve it."); |
693 | return 0; |
691 | return 0; |
694 | } |
692 | } |
695 | |
693 | |
… | |
… | |
741 | sacrifice_needed *= 2; |
739 | sacrifice_needed *= 2; |
742 | |
740 | |
743 | sacrifice_count = check_sacrifice (op, improver); |
741 | sacrifice_count = check_sacrifice (op, improver); |
744 | if (sacrifice_count < sacrifice_needed) |
742 | if (sacrifice_count < sacrifice_needed) |
745 | { |
743 | { |
746 | op->errormsg (format ("You need at least %d %s.", sacrifice_needed, &improver->slaying)); |
744 | op->failmsg (format ("You need at least %d %s.", sacrifice_needed, &improver->slaying)); |
747 | return 0; |
745 | return 0; |
748 | } |
746 | } |
749 | |
747 | |
750 | eat_item (op, improver->slaying, sacrifice_needed); |
748 | eat_item (op, improver->slaying, sacrifice_needed); |
751 | weapon->item_power++; |
749 | weapon->item_power++; |
… | |
… | |
758 | case IMPROVE_WIS: return improve_weapon_stat (op, improver, weapon, weapon->stats.Wis, 1, "wisdom"); |
756 | 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"); |
757 | 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"); |
758 | 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"); |
759 | case IMPROVE_POW: return improve_weapon_stat (op, improver, weapon, weapon->stats.Pow, 1, "power"); |
762 | default: |
760 | default: |
763 | op->errormsg ("Unknown improvement type."); |
761 | op->failmsg ("Unknown improvement type."); |
764 | } |
762 | } |
765 | |
763 | |
766 | LOG (llevError, "improve_weapon: Got to end of function\n"); |
764 | LOG (llevError, "improve_weapon: Got to end of function\n"); |
767 | return 0; |
765 | return 0; |
768 | } |
766 | } |
… | |
… | |
780 | if (op->type != PLAYER) |
778 | if (op->type != PLAYER) |
781 | return 0; |
779 | return 0; |
782 | |
780 | |
783 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
781 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
784 | { |
782 | { |
785 | op->errormsg ("Something blocks the magic of the scroll!"); |
783 | op->failmsg ("Something blocks the magic of the scroll!"); |
786 | return 0; |
784 | return 0; |
787 | } |
785 | } |
788 | |
786 | |
789 | otmp = find_marked_object (op); |
787 | otmp = find_marked_object (op); |
790 | if (!otmp) |
788 | if (!otmp) |
791 | { |
789 | { |
792 | op->errormsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); |
790 | 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; |
791 | return 0; |
794 | } |
792 | } |
795 | |
793 | |
796 | if (otmp->type != WEAPON && otmp->type != BOW) |
794 | if (otmp->type != WEAPON && otmp->type != BOW) |
797 | { |
795 | { |
798 | op->errormsg ("Marked item is not a weapon or bow!"); |
796 | op->failmsg ("Marked item is not a weapon or bow!"); |
799 | return 0; |
797 | return 0; |
800 | } |
798 | } |
801 | |
799 | |
802 | op->statusmsg ("Applied weapon builder."); |
800 | op->statusmsg ("Applied weapon builder."); |
803 | |
801 | |
… | |
… | |
833 | { |
831 | { |
834 | object *tmp; |
832 | object *tmp; |
835 | |
833 | |
836 | if (armour->magic >= settings.armor_max_enchant) |
834 | if (armour->magic >= settings.armor_max_enchant) |
837 | { |
835 | { |
838 | op->errormsg ("This armour can not be enchanted any further!"); |
836 | op->failmsg ("This armour can not be enchanted any further!"); |
839 | return 0; |
837 | return 0; |
840 | } |
838 | } |
841 | /* Dealing with random artifact armor is a lot trickier (in terms of value, weight, |
839 | /* 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. |
840 | * 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 |
841 | * Note - maybe add scrolls which make the random artifact versions (eg, armour |
844 | * of gnarg and what not?) |
842 | * of gnarg and what not?) |
845 | */ |
843 | */ |
846 | if (armour->title) |
844 | if (armour->title) |
847 | { |
845 | { |
848 | op->errormsg ("This armour will not accept further enchantment."); |
846 | op->failmsg ("This armour will not accept further enchantment."); |
849 | return 0; |
847 | return 0; |
850 | } |
848 | } |
851 | |
849 | |
852 | /* Split objects if needed. Can't insert tmp until the |
850 | /* Split objects if needed. Can't insert tmp until the |
853 | * end of this function - otherwise it will just re-merge. |
851 | * end of this function - otherwise it will just re-merge. |
… | |
… | |
1054 | |
1052 | |
1055 | op->contr->last_used = 0; |
1053 | op->contr->last_used = 0; |
1056 | |
1054 | |
1057 | if (sack->env && sack->env != op) |
1055 | if (sack->env && sack->env != op) |
1058 | { |
1056 | { |
1059 | new_draw_info (NDI_UNIQUE, 0, op, "You must put it onto the floor or into your inventory first."); |
1057 | op->failmsg ("You must put it onto the floor or into your inventory first."); |
1060 | return 1; |
1058 | return 1; |
1061 | } |
1059 | } |
1062 | |
1060 | |
1063 | // already applied == open on ground, or open in inv, or active in inv |
1061 | // already applied == open on ground, or open in inv, or active in inv |
1064 | if (sack->flag [FLAG_APPLIED]) |
1062 | if (sack->flag [FLAG_APPLIED]) |
… | |
… | |
1070 | return 1; |
1068 | return 1; |
1071 | } |
1069 | } |
1072 | else if (!sack->env) |
1070 | else if (!sack->env) |
1073 | { |
1071 | { |
1074 | // active, but not ours: some other player has opened it |
1072 | // active, but not ours: some other player has opened it |
1075 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is already occupied.", query_name (sack)); |
1073 | op->failmsg (format ("Somebody else is using the %s already.", query_name (sack))); |
1076 | return 1; |
1074 | return 1; |
1077 | } |
1075 | } |
1078 | |
1076 | |
1079 | // fall through to opening it (active in inv) |
1077 | // fall through to opening it (active in inv) |
1080 | } |
1078 | } |
… | |
… | |
1082 | { |
1080 | { |
1083 | // it is in our env, so activate it, do not open yet |
1081 | // it is in our env, so activate it, do not open yet |
1084 | op->close_container (); |
1082 | op->close_container (); |
1085 | sack->flag [FLAG_APPLIED] = 1; |
1083 | sack->flag [FLAG_APPLIED] = 1; |
1086 | esrv_update_item (UPD_FLAGS, op, sack); |
1084 | esrv_update_item (UPD_FLAGS, op, sack); |
1087 | new_draw_info_format (NDI_UNIQUE, 0, op, "You ready %s.", query_name (sack)); |
1085 | op->statusmsg (format ("You ready %s.", query_name (sack))); |
1088 | return 1; |
1086 | return 1; |
1089 | } |
1087 | } |
1090 | |
1088 | |
1091 | // it's locked? |
1089 | // it's locked? |
1092 | if (sack->slaying) |
1090 | if (sack->slaying) |
1093 | { |
1091 | { |
1094 | if (object *tmp = find_key (op, op, sack)) |
1092 | if (object *tmp = find_key (op, op, sack)) |
1095 | new_draw_info_format (NDI_UNIQUE, 0, op, "You unlock %s with %s.", query_name (sack), query_name (tmp)); |
1093 | op->statusmsg (format ("You unlock %s with %s.", query_name (sack), query_name (tmp))); |
1096 | else |
1094 | else |
1097 | { |
1095 | { |
1098 | new_draw_info_format (NDI_UNIQUE, 0, op, "You don't have the key to unlock %s.", query_name (sack)); |
1096 | op->statusmsg (format ("You don't have the key to unlock %s.", query_name (sack))); |
1099 | return 1; |
1097 | return 1; |
1100 | } |
1098 | } |
1101 | } |
1099 | } |
1102 | |
1100 | |
1103 | op->open_container (sack); |
1101 | op->open_container (sack); |
… | |
… | |
1122 | * with an altar. We call it a Potion - altars are stationary - it |
1120 | * with an altar. We call it a Potion - altars are stationary - it |
1123 | * is up to map designers to use them properly. |
1121 | * is up to map designers to use them properly. |
1124 | */ |
1122 | */ |
1125 | if (altar->inv && altar->inv->type == SPELL) |
1123 | if (altar->inv && altar->inv->type == SPELL) |
1126 | { |
1124 | { |
1127 | new_draw_info_format (NDI_BLACK, 0, originator, "The altar casts %s.", &altar->inv->name); |
1125 | originator->statusmsg (format ("The altar casts %s.", &altar->inv->name)); |
1128 | cast_spell (originator, altar, 0, altar->inv, NULL); |
1126 | cast_spell (originator, altar, 0, altar->inv, NULL); |
1129 | /* If it is connected, push the button. Fixes some problems with |
1127 | /* If it is connected, push the button. Fixes some problems with |
1130 | * old maps. |
1128 | * old maps. |
1131 | */ |
1129 | */ |
1132 | |
1130 | |
1133 | /* push_button (altar);*/ |
1131 | /* push_button (altar);*/ |
1134 | } |
1132 | } |
… | |
… | |
1230 | op->contr->play_sound (sound_find ("shop_enter")); |
1228 | op->contr->play_sound (sound_find ("shop_enter")); |
1231 | else |
1229 | else |
1232 | op->contr->play_sound (sound_find ("shop_leave")); |
1230 | op->contr->play_sound (sound_find ("shop_leave")); |
1233 | |
1231 | |
1234 | if (shop_mat->msg) |
1232 | if (shop_mat->msg) |
1235 | new_draw_info (NDI_UNIQUE, 0, op, shop_mat->msg); |
1233 | op->statusmsg (shop_mat->msg); |
1236 | /* This check below is a bit simplistic - generally it should be correct, |
1234 | /* This check below is a bit simplistic - generally it should be correct, |
1237 | * but there is never a guarantee that the bottom space on the map is |
1235 | * but there is never a guarantee that the bottom space on the map is |
1238 | * actually the shop floor. |
1236 | * actually the shop floor. |
1239 | */ |
1237 | */ |
1240 | else if (!rv && !is_in_shop (op)) |
1238 | else if (!rv && !is_in_shop (op)) |
1241 | { |
1239 | { |
1242 | opinion = shopkeeper_approval (op->map, op); |
1240 | opinion = shopkeeper_approval (op->map, op); |
1243 | |
1241 | |
1244 | if (opinion > 0.9) |
1242 | op->statusmsg ( |
1245 | new_draw_info (NDI_UNIQUE, 0, op, "The shopkeeper gives you a friendly wave."); |
1243 | opinion >= 0.90 ? "The shopkeeper gives you a friendly wave." |
1246 | else if (opinion > 0.75) |
1244 | : opinion >= 0.75 ? "The shopkeeper waves to you." |
1247 | new_draw_info (NDI_UNIQUE, 0, op, "The shopkeeper waves to you."); |
1245 | : opinion >= 0.50 ? "The shopkeeper ignores you." |
1248 | else if (opinion > 0.5) |
1246 | : "The shopkeeper glares at you with contempt." |
1249 | new_draw_info (NDI_UNIQUE, 0, op, "The shopkeeper ignores you."); |
|
|
1250 | else |
1247 | ); |
1251 | new_draw_info (NDI_UNIQUE, 0, op, "The shopkeeper glares at you with contempt."); |
|
|
1252 | } |
1248 | } |
1253 | } |
1249 | } |
1254 | else |
1250 | else |
1255 | { |
1251 | { |
1256 | /* if we get here, a player tried to leave a shop but was not able |
1252 | /* if we get here, a player tried to leave a shop but was not able |
… | |
… | |
1280 | static void |
1276 | static void |
1281 | apply_sign (object *op, object *sign, int autoapply) |
1277 | apply_sign (object *op, object *sign, int autoapply) |
1282 | { |
1278 | { |
1283 | readable_message_type *msgType; |
1279 | readable_message_type *msgType; |
1284 | |
1280 | |
1285 | if (sign->msg == NULL) |
1281 | if (!sign->msg) |
1286 | { |
1282 | { |
1287 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing is written on it."); |
1283 | op->statusmsg ("Nothing is written on it."); |
1288 | return; |
1284 | return; |
1289 | } |
1285 | } |
1290 | |
1286 | |
1291 | if (sign->stats.food) |
1287 | if (sign->stats.food) |
1292 | { |
1288 | { |
1293 | if (sign->last_eat >= sign->stats.food) |
1289 | if (sign->last_eat >= sign->stats.food) |
1294 | { |
1290 | { |
1295 | if (!sign->move_on) |
1291 | if (!sign->move_on) |
1296 | new_draw_info (NDI_UNIQUE, 0, op, "You cannot read it anymore."); |
1292 | op->statusmsg ("You cannot read it anymore."); |
1297 | |
1293 | |
1298 | return; |
1294 | return; |
1299 | } |
1295 | } |
1300 | |
1296 | |
1301 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
1297 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
… | |
… | |
1307 | * move_on is zero, it needs to be manually applied (doesn't talk |
1303 | * move_on is zero, it needs to be manually applied (doesn't talk |
1308 | * to us). |
1304 | * to us). |
1309 | */ |
1305 | */ |
1310 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ) && !sign->move_on) |
1306 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ) && !sign->move_on) |
1311 | { |
1307 | { |
1312 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); |
1308 | op->failmsg ("You are unable to read while blind!"); |
1313 | return; |
1309 | return; |
1314 | } |
1310 | } |
1315 | |
1311 | |
1316 | if (op->contr) |
1312 | if (op->contr) |
1317 | if (client *ns = op->contr->ns) |
1313 | if (client *ns = op->contr->ns) |
… | |
… | |
1469 | |
1465 | |
1470 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1466 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1471 | { |
1467 | { |
1472 | if (!sound_was_played) |
1468 | if (!sound_was_played) |
1473 | { |
1469 | { |
1474 | trap->play_sound (sound_find ("fall_hole")); |
1470 | trap->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole")); |
1475 | sound_was_played = 1; |
1471 | sound_was_played = 1; |
1476 | } |
1472 | } |
1477 | |
1473 | |
1478 | new_draw_info (NDI_UNIQUE, 0, ab, "You fall into a trapdoor!"); |
1474 | ab->statusmsg ("You fall into a trapdoor!", NDI_RED); |
1479 | transfer_ob (ab, (int) EXIT_X (trap), (int) EXIT_Y (trap), 0, ab); |
1475 | transfer_ob (ab, EXIT_X (trap), EXIT_Y (trap), 0, ab); |
1480 | } |
1476 | } |
1481 | } |
1477 | } |
1482 | goto leave; |
1478 | goto leave; |
1483 | } |
1479 | } |
1484 | |
1480 | |
1485 | case CONVERTER: |
1481 | case CONVERTER: |
1486 | if (convert_item (victim, trap) < 0) |
1482 | if (convert_item (victim, trap) < 0) |
1487 | { |
1483 | { |
1488 | new_draw_info_format (NDI_UNIQUE, 0, originator, "The %s seems to be broken!", query_name (trap)); |
1484 | originator->failmsg (format ("The %s seems to be broken!", query_name (trap))); |
1489 | get_archetype ("burnout")->insert_at (trap, trap); |
1485 | get_archetype ("burnout")->insert_at (trap, trap); |
1490 | } |
1486 | } |
1491 | |
1487 | |
1492 | goto leave; |
1488 | goto leave; |
1493 | |
1489 | |
… | |
… | |
1514 | * Processing will happen if the head runs into the pit |
1510 | * Processing will happen if the head runs into the pit |
1515 | */ |
1511 | */ |
1516 | if (victim->head) |
1512 | if (victim->head) |
1517 | goto leave; |
1513 | goto leave; |
1518 | |
1514 | |
1519 | victim->play_sound (sound_find ("fall_hole")); |
1515 | victim->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole")); |
1520 | new_draw_info (NDI_UNIQUE, 0, victim, "You fall through the hole!\n"); |
1516 | victim->statusmsg ("You fall through the hole!", NDI_RED); |
1521 | transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim); |
1517 | transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim); |
1522 | goto leave; |
1518 | goto leave; |
1523 | |
1519 | |
1524 | case EXIT: |
1520 | case EXIT: |
1525 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1521 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1526 | { |
1522 | { |
1527 | /* Basically, don't show exits leading to random maps the |
1523 | /* Basically, don't show exits leading to random maps the |
1528 | * players output. |
1524 | * players output. |
1529 | */ |
1525 | */ |
1530 | if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2)) |
1526 | if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2)) |
1531 | new_draw_info (NDI_NAVY, 0, victim, trap->msg); |
1527 | victim->statusmsg (trap->msg, NDI_NAVY); |
1532 | |
1528 | |
1533 | victim->enter_exit (trap); |
1529 | victim->enter_exit (trap); |
1534 | } |
1530 | } |
1535 | goto leave; |
1531 | goto leave; |
1536 | |
1532 | |
… | |
… | |
1559 | goto leave; |
1555 | goto leave; |
1560 | |
1556 | |
1561 | case RUNE: |
1557 | case RUNE: |
1562 | case TRAP: |
1558 | case TRAP: |
1563 | if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) |
1559 | if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) |
1564 | { |
|
|
1565 | spring_trap (trap, victim); |
1560 | spring_trap (trap, victim); |
1566 | } |
|
|
1567 | goto leave; |
1561 | goto leave; |
1568 | |
1562 | |
1569 | default: |
1563 | default: |
1570 | LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " |
1564 | LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " |
1571 | "handled in move_apply()\n", &trap->name, &trap->arch->archname, trap->type); |
1565 | "handled in move_apply()\n", &trap->name, &trap->arch->archname, trap->type); |
… | |
… | |
1585 | int lev_diff; |
1579 | int lev_diff; |
1586 | object *skill_ob; |
1580 | object *skill_ob; |
1587 | |
1581 | |
1588 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1582 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1589 | { |
1583 | { |
1590 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); |
1584 | op->failmsg ("You are unable to read while blind!"); |
1591 | return; |
1585 | return; |
1592 | } |
1586 | } |
1593 | |
1587 | |
1594 | if (!tmp->msg) |
1588 | if (!tmp->msg) |
1595 | { |
1589 | { |
1596 | new_draw_info_format (NDI_UNIQUE, 0, op, "You open the %s and find it empty.", &tmp->name); |
1590 | op->failmsg (format ("You open the %s and find it empty.", &tmp->name)); |
1597 | return; |
1591 | return; |
1598 | } |
1592 | } |
1599 | |
1593 | |
1600 | /* need a literacy skill to read stuff! */ |
1594 | /* need a literacy skill to read stuff! */ |
1601 | skill_ob = find_skill_by_name (op, tmp->skill); |
1595 | skill_ob = find_skill_by_name (op, tmp->skill); |
1602 | if (!skill_ob) |
1596 | if (!skill_ob) |
1603 | { |
1597 | { |
1604 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<You lack the skill to read this>"); |
1598 | op->failmsg (format ("You are unable to decipher the strange symbols. H<You lack the %s skill to read this.>", &tmp->skill)); |
1605 | return; |
1599 | return; |
1606 | } |
1600 | } |
1607 | |
1601 | |
1608 | lev_diff = tmp->level - (skill_ob->level + 5); |
1602 | lev_diff = tmp->level - (skill_ob->level + 5); |
1609 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
1603 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
1610 | { |
1604 | { |
1611 | if (lev_diff < 2) |
1605 | op->failmsg (lev_diff < 2 ? "This book is just barely beyond your comprehension." |
1612 | new_draw_info (NDI_UNIQUE, 0, op, "This book is just barely beyond your comprehension."); |
1606 | : lev_diff < 3 ? "This book is slightly beyond your comprehension." |
1613 | else if (lev_diff < 3) |
1607 | : lev_diff < 5 ? "This book is beyond your comprehension." |
1614 | new_draw_info (NDI_UNIQUE, 0, op, "This book is slightly beyond your comprehension."); |
1608 | : lev_diff < 8 ? "This book is quite a bit beyond your comprehension." |
1615 | else if (lev_diff < 5) |
1609 | : lev_diff < 15 ? "This book is way beyond your comprehension." |
1616 | new_draw_info (NDI_UNIQUE, 0, op, "This book is beyond your comprehension."); |
1610 | : "This book is totally beyond your comprehension."); |
1617 | else if (lev_diff < 8) |
|
|
1618 | new_draw_info (NDI_UNIQUE, 0, op, "This book is quite a bit beyond your comprehension."); |
|
|
1619 | else if (lev_diff < 15) |
|
|
1620 | new_draw_info (NDI_UNIQUE, 0, op, "This book is way beyond your comprehension."); |
|
|
1621 | else |
|
|
1622 | new_draw_info (NDI_UNIQUE, 0, op, "This book is totally beyond your comprehension."); |
|
|
1623 | return; |
1611 | return; |
1624 | } |
1612 | } |
1625 | |
1613 | |
1626 | readable_message_type *msgType = get_readable_message_type (tmp); |
1614 | readable_message_type *msgType = get_readable_message_type (tmp); |
1627 | |
1615 | |
… | |
… | |
1669 | * op is the person learning the skill, tmp is the skill scroll object |
1657 | * op is the person learning the skill, tmp is the skill scroll object |
1670 | */ |
1658 | */ |
1671 | static void |
1659 | static void |
1672 | apply_skillscroll (object *op, object *tmp) |
1660 | apply_skillscroll (object *op, object *tmp) |
1673 | { |
1661 | { |
1674 | switch ((int) learn_skill (op, tmp)) |
1662 | switch (learn_skill (op, tmp)) |
1675 | { |
1663 | { |
1676 | case 0: |
1664 | case 0: |
1677 | new_draw_info (NDI_UNIQUE, 0, op, "You already possess the knowledge "); |
1665 | op->play_sound (sound_find ("generic_fail")); |
1678 | new_draw_info_format (NDI_UNIQUE, 0, op, "held within the %s.\n", query_name (tmp)); |
1666 | op->failmsg (format ("You already possess the knowledge held within the %s.", query_name (tmp))); |
1679 | return; |
1667 | break; |
1680 | |
1668 | |
1681 | case 1: |
1669 | case 1: |
1682 | new_draw_info_format (NDI_UNIQUE, 0, op, "You succeed in learning %s", &tmp->skill); |
|
|
1683 | decrease_ob (tmp); |
1670 | decrease_ob (tmp); |
|
|
1671 | op->play_sound (sound_find ("skill_learn")); |
|
|
1672 | op->statusmsg (format ("You succeed in learning %s", &tmp->skill)); |
1684 | return; |
1673 | break; |
1685 | |
1674 | |
1686 | default: |
1675 | default: |
1687 | new_draw_info_format (NDI_UNIQUE, 0, op, "You fail to learn the knowledge of the %s.\n", query_name (tmp)); |
|
|
1688 | decrease_ob (tmp); |
1676 | decrease_ob (tmp); |
|
|
1677 | op->play_sound (sound_find ("generic_fail")); |
|
|
1678 | op->failmsg (format ("You fail to learn the knowledge of the %s.\n", query_name (tmp))); |
1689 | return; |
1679 | break; |
1690 | } |
1680 | } |
1691 | } |
1681 | } |
1692 | |
1682 | |
1693 | /** |
1683 | /** |
1694 | * Actually makes op learn spell. |
1684 | * Actually makes op learn spell. |
… | |
… | |
1744 | { |
1734 | { |
1745 | LOG (llevError, "BUG: do_forget_spell(): spell not known\n"); |
1735 | LOG (llevError, "BUG: do_forget_spell(): spell not known\n"); |
1746 | return; |
1736 | return; |
1747 | } |
1737 | } |
1748 | |
1738 | |
1749 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", spell); |
1739 | op->failmsg (format ("You lose knowledge of %s.", spell)); |
1750 | player_unready_range_ob (op->contr, spob); |
1740 | player_unready_range_ob (op->contr, spob); |
1751 | esrv_remove_spell (op->contr, spob); |
1741 | esrv_remove_spell (op->contr, spob); |
1752 | spob->destroy (); |
1742 | spob->destroy (); |
1753 | } |
1743 | } |
1754 | |
1744 | |
… | |
… | |
1762 | { |
1752 | { |
1763 | object *skop, *spell, *spell_skill; |
1753 | object *skop, *spell, *spell_skill; |
1764 | |
1754 | |
1765 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1755 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1766 | { |
1756 | { |
1767 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); |
1757 | op->failmsg ("You are unable to read while blind."); |
1768 | return; |
1758 | return; |
1769 | } |
1759 | } |
1770 | |
1760 | |
1771 | /* artifact_spellbooks have 'slaying' field point to a spell name, |
1761 | /* artifact_spellbooks have 'slaying' field point to a spell name, |
1772 | * instead of having their spell stored in stats.sp. These are |
1762 | * instead of having their spell stored in stats.sp. These are |
… | |
… | |
1775 | if (tmp->slaying) |
1765 | if (tmp->slaying) |
1776 | { |
1766 | { |
1777 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1767 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1778 | if (!spell) |
1768 | if (!spell) |
1779 | { |
1769 | { |
1780 | new_draw_info_format (NDI_UNIQUE, 0, op, "The book's formula for %s is incomplete", &tmp->slaying); |
1770 | op->failmsg (format ("The book's formula for %s is incomplete.", &tmp->slaying)); |
1781 | return; |
1771 | return; |
1782 | } |
1772 | } |
1783 | else |
1773 | else |
1784 | insert_ob_in_ob (spell, tmp); |
1774 | insert_ob_in_ob (spell, tmp); |
1785 | |
1775 | |
… | |
… | |
1790 | |
1780 | |
1791 | /* need a literacy skill to learn spells. Also, having a literacy level |
1781 | /* need a literacy skill to learn spells. Also, having a literacy level |
1792 | * lower than the spell will make learning the spell more difficult */ |
1782 | * lower than the spell will make learning the spell more difficult */ |
1793 | if (!skop) |
1783 | if (!skop) |
1794 | { |
1784 | { |
1795 | new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails. H<You lack the literacy skill.>"); |
1785 | op->failmsg (format ("You can't read! Your attempt fails. H<You lack the %s skill.>", &tmp->skill)); |
1796 | return; |
1786 | return; |
1797 | } |
1787 | } |
1798 | |
1788 | |
1799 | spell = tmp->inv; |
1789 | spell = tmp->inv; |
1800 | |
1790 | |
1801 | if (!spell) |
1791 | if (!spell) |
1802 | { |
1792 | { |
1803 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1793 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1804 | new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense. This is a bug, please report!"); |
1794 | op->failmsg ("The spellbook symbols make no sense. This is a bug, please report!"); |
1805 | return; |
1795 | return; |
1806 | } |
1796 | } |
1807 | |
1797 | |
1808 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1798 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1809 | { |
1799 | { |
1810 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<Your literacy level is too low.>"); |
1800 | op->failmsg (format ("You are unable to decipher the strange symbols. H<Your %s level is too low.>", &tmp->skill)); |
1811 | return; |
1801 | return; |
1812 | } |
1802 | } |
1813 | |
1803 | |
1814 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1804 | op->statusmsg (format ("The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name)); |
1815 | |
1805 | |
1816 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1806 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1817 | { |
1807 | { |
1818 | identify (tmp); |
1808 | identify (tmp); |
1819 | |
1809 | |
… | |
… | |
1828 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1818 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1829 | * they would have a special prayer mark. |
1819 | * they would have a special prayer mark. |
1830 | */ |
1820 | */ |
1831 | if (check_spell_known (op, spell->name)) |
1821 | if (check_spell_known (op, spell->name)) |
1832 | { |
1822 | { |
1833 | new_draw_info (NDI_UNIQUE, 0, op, "You already know that spell. H<It makes no sense to learn spells twice, and would only waste the spellbook.>\n"); |
1823 | op->statusmsg ("You already know that spell. H<It makes no sense to learn spells twice, and would only waste the spellbook.>\n"); |
1834 | return; |
1824 | return; |
1835 | } |
1825 | } |
1836 | |
1826 | |
1837 | if (spell->skill) |
1827 | if (spell->skill) |
1838 | { |
1828 | { |
1839 | spell_skill = find_skill_by_name (op, spell->skill); |
1829 | spell_skill = find_skill_by_name (op, spell->skill); |
1840 | |
1830 | |
1841 | if (!spell_skill) |
1831 | if (!spell_skill) |
1842 | { |
1832 | { |
1843 | new_draw_info_format (NDI_UNIQUE, 0, op, "You lack the skill %s to use this spell.", &spell->skill); |
1833 | op->failmsg (format ("You lack the skill %s to use this spell.", &spell->skill)); |
1844 | return; |
1834 | return; |
1845 | } |
1835 | } |
1846 | |
1836 | |
1847 | if (spell_skill->level < spell->level) |
1837 | if (spell_skill->level < spell->level) |
1848 | { |
1838 | { |
1849 | new_draw_info_format (NDI_UNIQUE, 0, op, "You need to be level %d in %s to learn this spell.", spell->level, &spell->skill); |
1839 | op->failmsg (format ("You need to be level %d in %s to learn this spell.", spell->level, &spell->skill)); |
1850 | return; |
1840 | return; |
1851 | } |
1841 | } |
1852 | } |
1842 | } |
1853 | |
1843 | |
1854 | /* Logic as follows |
1844 | /* Logic as follows |
… | |
… | |
1863 | * Overall, chances are the same but a player will find having a high |
1853 | * Overall, chances are the same but a player will find having a high |
1864 | * literacy rate very useful! -b.t. |
1854 | * literacy rate very useful! -b.t. |
1865 | */ |
1855 | */ |
1866 | if (QUERY_FLAG (op, FLAG_CONFUSED)) |
1856 | if (QUERY_FLAG (op, FLAG_CONFUSED)) |
1867 | { |
1857 | { |
1868 | new_draw_info (NDI_UNIQUE, 0, op, "In your confused state you flub the wording of the text!"); |
1858 | op->failmsg ("In your confused state you flub the wording of the text!"); |
1869 | scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), MAX (spell->stats.sp, spell->stats.grace)); |
1859 | scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), MAX (spell->stats.sp, spell->stats.grace)); |
1870 | } |
1860 | } |
1871 | else if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || |
1861 | else if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || |
1872 | (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int]) |
1862 | (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int]) |
1873 | { |
1863 | { |
1874 | |
1864 | op->statusmsg ("You succeed in learning the spell!", NDI_GREEN); |
1875 | new_draw_info (NDI_UNIQUE, 0, op, "You succeed in learning the spell!"); |
|
|
1876 | do_learn_spell (op, spell, 0); |
1865 | do_learn_spell (op, spell, 0); |
1877 | |
1866 | |
1878 | /* xp gain to literacy for spell learning */ |
1867 | /* xp gain to literacy for spell learning */ |
1879 | if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
1868 | if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
1880 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
1869 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
1881 | } |
1870 | } |
1882 | else |
1871 | else |
1883 | { |
1872 | { |
1884 | op->contr->play_sound (sound_find ("fumble_spell")); |
1873 | op->contr->play_sound (sound_find ("fumble_spell")); |
1885 | new_draw_info (NDI_UNIQUE, 0, op, "You fail to learn the spell. H<Wis (priests) or Int (wizards) governs the chance of learning a prayer or spell.>\n"); |
1874 | op->failmsg ("You fail to learn the spell. H<Wis (priests) or Int (wizards) governs the chance of learning a prayer or spell.>\n"); |
1886 | } |
1875 | } |
1887 | |
1876 | |
1888 | decrease_ob (tmp); |
1877 | decrease_ob (tmp); |
1889 | } |
1878 | } |
1890 | |
1879 | |
… | |
… | |
1896 | { |
1885 | { |
1897 | object *skop; |
1886 | object *skop; |
1898 | |
1887 | |
1899 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1888 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
1900 | { |
1889 | { |
1901 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); |
1890 | op->failmsg ("You are unable to read while blind."); |
1902 | return; |
1891 | return; |
1903 | } |
1892 | } |
1904 | |
1893 | |
1905 | if (!tmp->inv || tmp->inv->type != SPELL) |
1894 | if (!tmp->inv || tmp->inv->type != SPELL) |
1906 | { |
1895 | { |
1907 | new_draw_info (NDI_UNIQUE, 0, op, "The scroll just doesn't make sense! H<...and never will make sense.>"); |
1896 | op->failmsg ("The scroll just doesn't make sense! H<...and never will make sense.>"); |
1908 | return; |
1897 | return; |
1909 | } |
1898 | } |
1910 | |
1899 | |
1911 | if (op->type == PLAYER) |
1900 | if (op->type == PLAYER) |
1912 | { |
1901 | { |
… | |
… | |
1918 | */ |
1907 | */ |
1919 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
1908 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
1920 | |
1909 | |
1921 | if (!skop) |
1910 | if (!skop) |
1922 | { |
1911 | { |
1923 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<You lack the literacy skill.>"); |
1912 | op->failmsg (format ("You are unable to decipher the strange symbols. H<You lack the %s skill.>", &skill_names[SK_LITERACY])); |
1924 | return; |
1913 | return; |
1925 | } |
1914 | } |
1926 | |
1915 | |
1927 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
1916 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
1928 | change_exp (op, exp_gain, skop->skill, 0); |
1917 | change_exp (op, exp_gain, skop->skill, 0); |
1929 | } |
1918 | } |
1930 | |
1919 | |
1931 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1920 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1932 | identify (tmp); |
1921 | identify (tmp); |
1933 | |
1922 | |
1934 | new_draw_info_format (NDI_BLACK, 0, op, "The scroll of %s turns to dust.", &tmp->inv->name); |
1923 | op->statusmsg (format ("The scroll of %s turns to dust.", &tmp->inv->name)); |
1935 | |
1924 | |
1936 | cast_spell (op, tmp, dir, tmp->inv, NULL); |
1925 | cast_spell (op, tmp, dir, tmp->inv, NULL); |
1937 | decrease_ob (tmp); |
1926 | decrease_ob (tmp); |
1938 | } |
1927 | } |
1939 | |
1928 | |
… | |
… | |
1943 | * chest. |
1932 | * chest. |
1944 | */ |
1933 | */ |
1945 | static void |
1934 | static void |
1946 | apply_treasure (object *op, object *tmp) |
1935 | apply_treasure (object *op, object *tmp) |
1947 | { |
1936 | { |
1948 | /* Nice side effect of new treasure creation method is that the treasure |
1937 | /* Nice side effect of this treasure creation method is that the treasure |
1949 | * for the chest is done when the chest is created, and put into the chest |
1938 | * for the chest is done when the chest is created, and put into the chest |
1950 | * inventory. So that when the chest burns up, the items still exist. Also |
1939 | * inventory. So that when the chest burns up, the items still exist. Also |
1951 | * prevents people fromt moving chests to more difficult maps to get better |
1940 | * prevents people from moving chests to more difficult maps to get better |
1952 | * treasure |
1941 | * treasure |
1953 | */ |
1942 | */ |
1954 | object *treas = tmp->inv; |
1943 | object *treas = tmp->inv; |
1955 | |
1944 | |
1956 | if (!treas) |
1945 | if (!treas) |
1957 | { |
1946 | { |
1958 | new_draw_info (NDI_UNIQUE, 0, op, "The chest was empty."); |
1947 | op->statusmsg ("The chest was empty."); |
1959 | decrease_ob (tmp); |
1948 | decrease_ob (tmp); |
1960 | return; |
1949 | return; |
1961 | } |
1950 | } |
1962 | |
1951 | |
1963 | while (tmp->inv) |
1952 | while (tmp->inv) |
1964 | { |
1953 | { |
1965 | treas = tmp->inv; |
1954 | treas = tmp->inv; |
1966 | |
|
|
1967 | treas->remove (); |
1955 | treas->remove (); |
1968 | new_draw_info_format (NDI_UNIQUE, 0, op, "You find %s in the chest.", query_name (treas)); |
|
|
1969 | |
1956 | |
1970 | treas->x = op->x; |
1957 | treas->x = op->x; |
1971 | treas->y = op->y; |
1958 | treas->y = op->y; |
1972 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
1959 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
1973 | |
1960 | |
1974 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) |
1961 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) |
1975 | spring_trap (treas, op); |
1962 | spring_trap (treas, op); |
1976 | |
1963 | |
1977 | /* If either player or container was destroyed, no need to do |
1964 | /* If either player or container was destroyed, no need to do |
1978 | * further processing. I think this should be enclused with |
1965 | * further processing. I think this should be enclused with |
1979 | * spring trap above, as I don't think there is otherwise |
1966 | * spring trap above, as I don't think there is otherwise |
1980 | * any way for the treasure chest or player to get killed |
1967 | * any way for the treasure chest or player to get killed. |
1981 | */ |
1968 | */ |
1982 | if (op->destroyed () || tmp->destroyed ()) |
1969 | if (op->destroyed () || tmp->destroyed ()) |
1983 | break; |
1970 | break; |
1984 | } |
1971 | } |
1985 | |
1972 | |
1986 | if (!tmp->destroyed () && tmp->inv == NULL) |
1973 | if (!tmp->destroyed () && !tmp->inv) |
1987 | decrease_ob (tmp); |
1974 | decrease_ob (tmp); |
1988 | |
|
|
1989 | } |
1975 | } |
1990 | |
1976 | |
1991 | /** |
1977 | /** |
1992 | * op eats food. |
1978 | * op eats food. |
1993 | * If player, takes care of messages and dragon special food. |
1979 | * If player, takes care of messages and dragon special food. |
… | |
… | |
2008 | { |
1994 | { |
2009 | /* usual case - no dragon meal: */ |
1995 | /* usual case - no dragon meal: */ |
2010 | if (op->stats.food + tmp->stats.food > 999) |
1996 | if (op->stats.food + tmp->stats.food > 999) |
2011 | { |
1997 | { |
2012 | if (tmp->type == FOOD || tmp->type == FLESH) |
1998 | if (tmp->type == FOOD || tmp->type == FLESH) |
2013 | new_draw_info (NDI_UNIQUE, 0, op, "You feel full, but what a waste of food!"); |
1999 | op->failmsg ("You feel full, but what a waste of food!"); |
2014 | else |
2000 | else |
2015 | new_draw_info (NDI_UNIQUE, 0, op, "Most of the drink goes down your face not your throat!"); |
2001 | op->statusmsg ("Most of the drink goes down your face not your throat!"); |
2016 | } |
2002 | } |
2017 | |
2003 | |
2018 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2004 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2019 | { |
2005 | { |
2020 | char buf[MAX_BUF]; |
2006 | const char *buf; |
2021 | |
2007 | |
2022 | if (!is_dragon_pl (op)) |
2008 | if (!is_dragon_pl (op)) |
2023 | { |
2009 | { |
2024 | /* eating message for normal players */ |
2010 | /* eating message for normal players */ |
2025 | if (tmp->type == DRINK) |
2011 | if (tmp->type == DRINK) |
2026 | sprintf (buf, "Ahhh...that %s tasted good.", &tmp->name); |
2012 | buf = format ("Ahhh...that %s tasted good.", &tmp->name); |
2027 | else |
2013 | else |
2028 | sprintf (buf, "The %s tasted %s", &tmp->name, tmp->type == FLESH ? "terrible!" : "good."); |
2014 | buf = format ("The %s tasted %s", &tmp->name, tmp->type == FLESH ? "terrible!" : "good."); |
2029 | } |
2015 | } |
2030 | else |
2016 | else |
2031 | { |
|
|
2032 | /* eating message for dragon players */ |
2017 | /* eating message for dragon players */ |
2033 | sprintf (buf, "The %s tasted terrible!", &tmp->name); |
2018 | buf = format ("The %s tasted terrible!", &tmp->name); |
2034 | } |
|
|
2035 | |
2019 | |
2036 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
2020 | op->statusmsg (buf); |
|
|
2021 | |
2037 | capacity_remaining = 999 - op->stats.food; |
2022 | capacity_remaining = 999 - op->stats.food; |
2038 | op->stats.food += tmp->stats.food; |
2023 | op->stats.food += tmp->stats.food; |
2039 | if (capacity_remaining < tmp->stats.food) |
2024 | if (capacity_remaining < tmp->stats.food) |
2040 | op->stats.hp += capacity_remaining / 50; |
2025 | op->stats.hp += capacity_remaining / 50; |
2041 | else |
2026 | else |
2042 | op->stats.hp += tmp->stats.food / 50; |
2027 | op->stats.hp += tmp->stats.food / 50; |
|
|
2028 | |
2043 | if (op->stats.hp > op->stats.maxhp) |
2029 | if (op->stats.hp > op->stats.maxhp) |
2044 | op->stats.hp = op->stats.maxhp; |
2030 | op->stats.hp = op->stats.maxhp; |
2045 | if (op->stats.food > 999) |
2031 | if (op->stats.food > 999) |
2046 | op->stats.food = 999; |
2032 | op->stats.food = 999; |
2047 | } |
2033 | } |
… | |
… | |
2071 | { |
2057 | { |
2072 | object *skin = NULL; /* pointer to dragon skin force */ |
2058 | object *skin = NULL; /* pointer to dragon skin force */ |
2073 | object *abil = NULL; /* pointer to dragon ability force */ |
2059 | object *abil = NULL; /* pointer to dragon ability force */ |
2074 | object *tmp = NULL; /* tmp. object */ |
2060 | object *tmp = NULL; /* tmp. object */ |
2075 | |
2061 | |
2076 | char buf[MAX_BUF]; /* tmp. string buffer */ |
|
|
2077 | double chance; /* improvement-chance of one resistance type */ |
2062 | double chance; /* improvement-chance of one resistance type */ |
2078 | double totalchance = 1; /* total chance of gaining one resistance */ |
2063 | double totalchance = 1; /* total chance of gaining one resistance */ |
2079 | double bonus = 0; /* level bonus (improvement is easier at lowlevel) */ |
2064 | double bonus = 0; /* level bonus (improvement is easier at lowlevel) */ |
2080 | double mbonus = 0; /* monster bonus */ |
2065 | double mbonus = 0; /* monster bonus */ |
2081 | int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */ |
2066 | int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */ |
… | |
… | |
2103 | /* now start by filling stomache and health, according to food-value */ |
2088 | /* now start by filling stomache and health, according to food-value */ |
2104 | if ((999 - op->stats.food) < meal->stats.food) |
2089 | if ((999 - op->stats.food) < meal->stats.food) |
2105 | op->stats.hp += (999 - op->stats.food) / 50; |
2090 | op->stats.hp += (999 - op->stats.food) / 50; |
2106 | else |
2091 | else |
2107 | op->stats.hp += meal->stats.food / 50; |
2092 | op->stats.hp += meal->stats.food / 50; |
|
|
2093 | |
2108 | if (op->stats.hp > op->stats.maxhp) |
2094 | if (op->stats.hp > op->stats.maxhp) |
2109 | op->stats.hp = op->stats.maxhp; |
2095 | op->stats.hp = op->stats.maxhp; |
2110 | |
2096 | |
2111 | op->stats.food = MIN (999, op->stats.food + meal->stats.food); |
2097 | op->stats.food = MIN (999, op->stats.food + meal->stats.food); |
2112 | |
2098 | |
… | |
… | |
2157 | } |
2143 | } |
2158 | } |
2144 | } |
2159 | |
2145 | |
2160 | /* inverse totalchance as until now we have the failure-chance */ |
2146 | /* inverse totalchance as until now we have the failure-chance */ |
2161 | totalchance = 100 - totalchance * 100; |
2147 | totalchance = 100 - totalchance * 100; |
|
|
2148 | |
2162 | /* print message according to totalchance */ |
2149 | /* print message according to totalchance */ |
|
|
2150 | const char *buf; |
2163 | if (totalchance > 50.) |
2151 | if (totalchance > 50.) |
2164 | sprintf (buf, "Hmm! The %s tasted delicious!", &meal->name); |
2152 | buf = format ("Hmm! The %s tasted delicious!", &meal->name); |
2165 | else if (totalchance > 10.) |
2153 | else if (totalchance > 10.) |
2166 | sprintf (buf, "The %s tasted very good.", &meal->name); |
2154 | buf = format ("The %s tasted very good.", &meal->name); |
2167 | else if (totalchance > 1.) |
2155 | else if (totalchance > 1.) |
2168 | sprintf (buf, "The %s tasted good.", &meal->name); |
2156 | buf = format ("The %s tasted good.", &meal->name); |
2169 | else if (totalchance > 0.1) |
2157 | else if (totalchance > 0.1) |
2170 | sprintf (buf, "The %s tasted bland.", &meal->name); |
2158 | buf = format ("The %s tasted bland.", &meal->name); |
2171 | else if (totalchance >= 0.01) |
2159 | else if (totalchance >= 0.01) |
2172 | sprintf (buf, "The %s had a boring taste.", &meal->name); |
2160 | buf = format ("The %s had a boring taste.", &meal->name); |
2173 | else if (meal->last_eat > 0 && atnr_is_dragon_enabled (meal->last_eat)) |
2161 | else if (meal->last_eat > 0 && atnr_is_dragon_enabled (meal->last_eat)) |
2174 | sprintf (buf, "The %s tasted strange.", &meal->name); |
2162 | buf = format ("The %s tasted strange.", &meal->name); |
2175 | else |
2163 | else |
2176 | sprintf (buf, "The %s had no taste.", &meal->name); |
2164 | buf = format ("The %s had no taste.", &meal->name); |
2177 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
2165 | |
|
|
2166 | op->statusmsg (buf); |
2178 | |
2167 | |
2179 | /* now choose a winner if we have any */ |
2168 | /* now choose a winner if we have any */ |
2180 | i = -1; |
2169 | i = -1; |
2181 | if (winners > 0) |
2170 | if (winners > 0) |
2182 | i = atnr_winner[RANDOM () % winners]; |
2171 | i = atnr_winner[RANDOM () % winners]; |
… | |
… | |
2185 | { |
2174 | { |
2186 | /* resistance increased! */ |
2175 | /* resistance increased! */ |
2187 | skin->resist[i]++; |
2176 | skin->resist[i]++; |
2188 | op->update_stats (); |
2177 | op->update_stats (); |
2189 | |
2178 | |
2190 | sprintf (buf, "Your skin is now more resistant to %s!", change_resist_msg[i]); |
2179 | op->statusmsg (format ("Your skin is now more resistant to %s!", change_resist_msg[i])); |
2191 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, buf); |
|
|
2192 | } |
2180 | } |
2193 | |
2181 | |
2194 | /* if this flesh contains a new ability focus, we mark it |
2182 | /* if this flesh contains a new ability focus, we mark it |
2195 | into the ability_force and it will take effect on next level */ |
2183 | into the ability_force and it will take effect on next level */ |
2196 | if (meal->last_eat > 0 && atnr_is_dragon_enabled (meal->last_eat) && meal->last_eat != abil->last_eat) |
2184 | if (meal->last_eat > 0 && atnr_is_dragon_enabled (meal->last_eat) && meal->last_eat != abil->last_eat) |
2197 | { |
2185 | { |
2198 | abil->last_eat = meal->last_eat; /* write: last_eat <new attnr focus> */ |
2186 | abil->last_eat = meal->last_eat; /* write: last_eat <new attnr focus> */ |
2199 | |
2187 | |
2200 | if (meal->last_eat != abil->stats.exp) |
2188 | if (meal->last_eat != abil->stats.exp) |
|
|
2189 | op->statusmsg (format ( |
|
|
2190 | "Your metabolism prepares to focus on %s!\n" |
|
|
2191 | "The change will happen at level %d.", |
|
|
2192 | change_resist_msg[meal->last_eat], |
|
|
2193 | abil->level + 1 |
2201 | { |
2194 | )); |
2202 | sprintf (buf, "Your metabolism prepares to focus on %s!", change_resist_msg[meal->last_eat]); |
|
|
2203 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
2204 | sprintf (buf, "The change will happen at level %d", abil->level + 1); |
|
|
2205 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
2206 | } |
|
|
2207 | else |
2195 | else |
2208 | { |
2196 | { |
2209 | sprintf (buf, "Your metabolism will continue to focus on %s.", change_resist_msg[meal->last_eat]); |
2197 | op->statusmsg (format ("Your metabolism will continue to focus on %s.", change_resist_msg[meal->last_eat])); |
2210 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
2211 | abil->last_eat = 0; |
2198 | abil->last_eat = 0; |
2212 | } |
2199 | } |
2213 | } |
2200 | } |
|
|
2201 | |
2214 | return 1; |
2202 | return 1; |
2215 | } |
2203 | } |
2216 | |
2204 | |
2217 | /** |
2205 | /** |
2218 | * Handles applying an improve armor scroll. |
2206 | * Handles applying an improve armor scroll. |
… | |
… | |
2223 | { |
2211 | { |
2224 | object *armor; |
2212 | object *armor; |
2225 | |
2213 | |
2226 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2214 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2227 | { |
2215 | { |
2228 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll. H<The area prevents magic effects.>"); |
2216 | op->failmsg ("Something blocks the magic of the scroll. H<This area prevents magic effects.>"); |
2229 | return; |
2217 | return; |
2230 | } |
2218 | } |
2231 | |
2219 | |
2232 | armor = find_marked_object (op); |
2220 | armor = find_marked_object (op); |
2233 | |
2221 | |
2234 | if (!armor) |
2222 | if (!armor) |
2235 | { |
2223 | { |
2236 | new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object. Use the right mouse button popup or the mark command to do this."); |
2224 | op->failmsg ("You need to mark an armor object. Use the right mouse button popup or the mark command to do this."); |
2237 | return; |
2225 | return; |
2238 | } |
2226 | } |
2239 | |
2227 | |
2240 | if (armor->type != ARMOUR |
2228 | if (armor->type != ARMOUR |
2241 | && armor->type != CLOAK |
2229 | && armor->type != CLOAK |
2242 | && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) |
2230 | && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) |
2243 | { |
2231 | { |
2244 | new_draw_info (NDI_UNIQUE, 0, op, "Your marked item is not armour!\n"); |
2232 | op->failmsg ("Your marked item is not armour!\n"); |
2245 | return; |
2233 | return; |
2246 | } |
2234 | } |
2247 | |
2235 | |
2248 | new_draw_info (NDI_UNIQUE, 0, op, "Applying armour enchantment."); |
2236 | op->statusmsg ("Applying armour enchantment."); |
2249 | improve_armour (op, tmp, armor); |
2237 | improve_armour (op, tmp, armor); |
2250 | } |
2238 | } |
2251 | |
2239 | |
2252 | extern void |
2240 | extern void |
2253 | apply_poison (object *op, object *tmp) |
2241 | apply_poison (object *op, object *tmp) |
2254 | { |
2242 | { |
2255 | if (op->type == PLAYER) |
2243 | if (op->type == PLAYER) |
2256 | { |
2244 | { |
2257 | op->contr->play_sound (sound_find ("drink_poison")); |
2245 | op->contr->play_sound (sound_find ("drink_poison")); |
2258 | new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!"); |
2246 | op->failmsg ("Yech! That tasted poisonous!"); |
2259 | strcpy (op->contr->killer, "poisonous booze"); |
2247 | strcpy (op->contr->killer, "poisonous booze"); |
2260 | } |
2248 | } |
2261 | |
2249 | |
2262 | if (tmp->stats.hp > 0) |
2250 | if (tmp->stats.hp > 0) |
2263 | { |
2251 | { |
… | |
… | |
2382 | |
2370 | |
2383 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2371 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2384 | { |
2372 | { |
2385 | if (op->type == PLAYER) |
2373 | if (op->type == PLAYER) |
2386 | { |
2374 | { |
2387 | new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first. H<You cannot use items marked as unpaid.>"); |
2375 | op->failmsg ("You should pay for it first! H<You cannot use items marked as unpaid.>"); |
2388 | return 1; |
2376 | return 1; |
2389 | } |
2377 | } |
2390 | else |
2378 | else |
2391 | return 0; /* monsters just skip unpaid items */ |
2379 | return 0; /* monsters just skip unpaid items */ |
2392 | } |
2380 | } |
… | |
… | |
2395 | return RESULT_INT (0); |
2383 | return RESULT_INT (0); |
2396 | |
2384 | |
2397 | switch (tmp->type) |
2385 | switch (tmp->type) |
2398 | { |
2386 | { |
2399 | case CF_HANDLE: |
2387 | case CF_HANDLE: |
2400 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
|
|
2401 | op->play_sound (sound_find ("turn_handle")); |
2388 | op->play_sound (sound_find ("turn_handle")); |
|
|
2389 | op->statusmsg ("You turn the handle."); |
2402 | tmp->value = tmp->value ? 0 : 1; |
2390 | tmp->value = tmp->value ? 0 : 1; |
2403 | SET_ANIMATION (tmp, tmp->value); |
2391 | SET_ANIMATION (tmp, tmp->value); |
2404 | update_object (tmp, UP_OBJ_FACE); |
2392 | update_object (tmp, UP_OBJ_FACE); |
2405 | push_button (tmp); |
2393 | push_button (tmp); |
2406 | return 1; |
2394 | return 1; |
2407 | |
2395 | |
2408 | case TRIGGER: |
2396 | case TRIGGER: |
2409 | if (check_trigger (tmp, op)) |
2397 | if (check_trigger (tmp, op)) |
2410 | { |
2398 | { |
2411 | new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); |
2399 | op->statusmsg ("You turn the handle."); |
2412 | op->play_sound (sound_find ("turn_handle")); |
2400 | op->play_sound (sound_find ("turn_handle")); |
2413 | } |
2401 | } |
2414 | else |
2402 | else |
2415 | new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); |
2403 | op->failmsg ("The handle doesn't move."); |
2416 | |
2404 | |
2417 | return 1; |
2405 | return 1; |
2418 | |
2406 | |
2419 | case EXIT: |
2407 | case EXIT: |
2420 | if (op->type != PLAYER) |
2408 | if (op->type != PLAYER) |
2421 | return 0; |
2409 | return 0; |
2422 | |
2410 | |
2423 | if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp)) |
2411 | if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp)) |
2424 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s is closed.", query_name (tmp)); |
2412 | op->failmsg (format ("The %s is closed.", query_name (tmp))); |
2425 | else |
2413 | else |
2426 | { |
2414 | { |
2427 | /* Don't display messages for random maps. */ |
2415 | /* Don't display messages for random maps. */ |
2428 | if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2)) |
2416 | if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2)) |
2429 | new_draw_info (NDI_NAVY, 0, op, tmp->msg); |
2417 | op->statusmsg (tmp->msg, NDI_NAVY); |
2430 | |
2418 | |
2431 | op->enter_exit (tmp); |
2419 | op->enter_exit (tmp); |
2432 | } |
2420 | } |
2433 | |
2421 | |
2434 | return 1; |
2422 | return 1; |
2435 | |
2423 | |
2436 | case INSCRIBABLE: |
2424 | case INSCRIBABLE: |
2437 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
2425 | op->statusmsg (tmp->msg); |
2438 | // maybe show a spell menu to chose from or something like that |
2426 | // maybe show a spell menu to chose from or something like that |
2439 | return 1; |
2427 | return 1; |
2440 | |
2428 | |
2441 | case SIGN: |
2429 | case SIGN: |
2442 | apply_sign (op, tmp, 0); |
2430 | apply_sign (op, tmp, 0); |
… | |
… | |
2552 | { |
2540 | { |
2553 | char buf[MAX_BUF]; |
2541 | char buf[MAX_BUF]; |
2554 | timeofday_t tod; |
2542 | timeofday_t tod; |
2555 | |
2543 | |
2556 | get_tod (&tod); |
2544 | get_tod (&tod); |
2557 | sprintf (buf, "It is %d minute%s past %d o'clock %s", |
|
|
2558 | tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), |
|
|
2559 | ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am")); |
|
|
2560 | op->play_sound (sound_find ("sound_clock")); |
2545 | op->play_sound (sound_find ("sound_clock")); |
2561 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
2546 | op->statusmsg (format ( |
|
|
2547 | "It is %d minute%s past %d o'clock %s", |
|
|
2548 | tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), |
|
|
2549 | ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am") |
|
|
2550 | )); |
2562 | return 1; |
2551 | return 1; |
2563 | } |
2552 | } |
2564 | else |
2553 | else |
2565 | return 0; |
2554 | return 0; |
2566 | |
2555 | |
… | |
… | |
2610 | if (op->env && (pl->move_type & MOVE_FLYING)) |
2599 | if (op->env && (pl->move_type & MOVE_FLYING)) |
2611 | { |
2600 | { |
2612 | /* player is flying and applying object not in inventory */ |
2601 | /* player is flying and applying object not in inventory */ |
2613 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2602 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2614 | { |
2603 | { |
2615 | new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high above the ground! H<You have to stop levitating first, if you can.>"); |
2604 | op->failmsg ("But you are floating high above the ground! H<You have to stop levitating first, if you can.>"); |
2616 | return 0; |
2605 | return 0; |
2617 | } |
2606 | } |
2618 | } |
2607 | } |
2619 | |
2608 | |
2620 | pl->contr->last_used = op; |
2609 | pl->contr->last_used = op; |
2621 | |
2610 | |
2622 | tmp = manual_apply (pl, op, aflag); |
2611 | tmp = manual_apply (pl, op, aflag); |
2623 | if (!quiet) |
2612 | if (!quiet) |
2624 | { |
2613 | { |
2625 | if (tmp == 0) |
2614 | if (tmp == 0) |
2626 | new_draw_info_format (NDI_UNIQUE, 0, pl, "I don't know how to apply the %s.", query_name (op)); |
2615 | op->statusmsg (format ("I don't know how to apply the %s.", query_name (op))); |
2627 | else if (tmp == 2) |
2616 | else if (tmp == 2) |
2628 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n"); |
2617 | op->failmsg ("You must get it first!\n"); |
2629 | } |
2618 | } |
2630 | |
2619 | |
2631 | return tmp; |
2620 | return tmp; |
2632 | } |
2621 | } |
2633 | |
2622 | |
… | |
… | |
2710 | { |
2699 | { |
2711 | pl->combat_ob = 0; |
2700 | pl->combat_ob = 0; |
2712 | who->change_weapon (pl->ranged_ob); |
2701 | who->change_weapon (pl->ranged_ob); |
2713 | } |
2702 | } |
2714 | |
2703 | |
2715 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unwield %s.", query_name (op)); |
2704 | who->statusmsg (format ("You unwield %s.", query_name (op))); |
2716 | |
2705 | |
2717 | change_abil (who, op); |
2706 | change_abil (who, op); |
2718 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2707 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2719 | break; |
2708 | break; |
2720 | |
2709 | |
2721 | case SKILL: |
2710 | case SKILL: |
2722 | if (who->contr) |
2711 | if (who->contr) |
2723 | { |
2712 | { |
2724 | if (!op->invisible) |
2713 | if (!op->invisible) |
2725 | new_draw_info_format (NDI_UNIQUE, 0, who, "You stop using the %s.", query_name (op)); |
2714 | who->statusmsg (format ("You stop using the %s.", query_name (op))); |
2726 | else |
2715 | else |
2727 | new_draw_info_format (NDI_UNIQUE, 0, who, "You can no longer use the skill: %s.", &op->skill); |
2716 | who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill)); |
2728 | } |
2717 | } |
2729 | |
2718 | |
2730 | change_abil (who, op); |
2719 | change_abil (who, op); |
2731 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
2720 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
2732 | break; |
2721 | break; |
… | |
… | |
2739 | case GLOVES: |
2728 | case GLOVES: |
2740 | case AMULET: |
2729 | case AMULET: |
2741 | case GIRDLE: |
2730 | case GIRDLE: |
2742 | case BRACERS: |
2731 | case BRACERS: |
2743 | case CLOAK: |
2732 | case CLOAK: |
2744 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unwear %s.", query_name (op)); |
2733 | who->statusmsg (format ("You unwear %s.", query_name (op))); |
2745 | change_abil (who, op); |
2734 | change_abil (who, op); |
2746 | break; |
2735 | break; |
2747 | |
2736 | |
2748 | case LAMP: |
2737 | case LAMP: |
2749 | { |
2738 | { |
2750 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn off your %s.", &op->name); |
2739 | who->statusmsg (format ("You turn off your %s.", &op->name)); |
2751 | |
2740 | |
2752 | object *tmp2 = arch_to_object (op->other_arch); |
2741 | object *tmp2 = arch_to_object (op->other_arch); |
2753 | tmp2->x = op->x; |
2742 | tmp2->x = op->x; |
2754 | tmp2->y = op->y; |
2743 | tmp2->y = op->y; |
2755 | tmp2->map = op->map; |
2744 | tmp2->map = op->map; |
… | |
… | |
2770 | |
2759 | |
2771 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2760 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2772 | { |
2761 | { |
2773 | if (who->contr) |
2762 | if (who->contr) |
2774 | { |
2763 | { |
2775 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
2764 | who->failmsg ("Oops, it feels deadly cold!"); |
2776 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2765 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2777 | } |
2766 | } |
2778 | } |
2767 | } |
2779 | |
2768 | |
2780 | if (who->contr) |
2769 | if (who->contr) |
… | |
… | |
2793 | { |
2782 | { |
2794 | pl->ranged_ob = 0; |
2783 | pl->ranged_ob = 0; |
2795 | who->change_weapon (pl->combat_ob); |
2784 | who->change_weapon (pl->combat_ob); |
2796 | } |
2785 | } |
2797 | |
2786 | |
2798 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); |
2787 | who->statusmsg (format ("You unready %s.", query_name (op))); |
2799 | } |
2788 | } |
2800 | else |
2789 | else |
2801 | { |
2790 | { |
2802 | who->change_skill (0); |
2791 | who->change_skill (0); |
2803 | |
2792 | |
… | |
… | |
2809 | |
2798 | |
2810 | break; |
2799 | break; |
2811 | |
2800 | |
2812 | case BUILDER: |
2801 | case BUILDER: |
2813 | if (who->contr) |
2802 | if (who->contr) |
2814 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); |
2803 | who->statusmsg (format ("You unready %s.", query_name (op))); |
2815 | break; |
2804 | break; |
2816 | |
2805 | |
2817 | default: |
2806 | default: |
2818 | new_draw_info_format (NDI_UNIQUE, 0, who, "You unapply %s.", query_name (op)); |
2807 | who->statusmsg (format ("You unapply %s.", query_name (op))); |
2819 | break; |
2808 | break; |
2820 | } |
2809 | } |
2821 | |
2810 | |
2822 | who->update_stats (); |
2811 | who->update_stats (); |
2823 | |
2812 | |
… | |
… | |
2890 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2879 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2891 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->is_range ()) |
2880 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->is_range ()) |
2892 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED))) |
2881 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED))) |
2893 | { |
2882 | { |
2894 | if (aflags & AP_PRINT) |
2883 | if (aflags & AP_PRINT) |
2895 | new_draw_info (NDI_UNIQUE, 0, who, query_name (tmp)); |
2884 | who->failmsg (query_name (tmp)); |
2896 | else |
2885 | else |
2897 | unapply_special (who, tmp, aflags); |
2886 | unapply_special (who, tmp, aflags); |
2898 | } |
2887 | } |
2899 | else |
2888 | else |
2900 | { |
2889 | { |
2901 | /* In this case, we want to try and remove a cursed item. |
2890 | /* In this case, we want to try and remove a cursed item. |
2902 | * While we know it won't work, we want unapply_special to |
2891 | * While we know it won't work, we want unapply_special to |
2903 | * at least generate the message. |
2892 | * at least generate the message. |
2904 | */ |
2893 | */ |
2905 | new_draw_info_format (NDI_UNIQUE, 0, who, |
2894 | who->failmsg (format ("No matter how hard you try, you just can't remove the %s." CANNOT_REMOVE_CURSED, query_name (tmp))); |
2906 | "No matter how hard you try, you just can't remove the %s." CANNOT_REMOVE_CURSED, |
|
|
2907 | query_name (tmp)); |
|
|
2908 | return 1; |
2895 | return 1; |
2909 | } |
2896 | } |
2910 | |
2897 | |
2911 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2898 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2912 | { |
2899 | { |
… | |
… | |
2935 | |
2922 | |
2936 | /* If we are just printing, we don't care about cursed status */ |
2923 | /* If we are just printing, we don't care about cursed status */ |
2937 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!(QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)))) |
2924 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!(QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)))) |
2938 | { |
2925 | { |
2939 | if (aflags & AP_PRINT) |
2926 | if (aflags & AP_PRINT) |
2940 | new_draw_info (NDI_UNIQUE, 0, who, query_name (tmp)); |
2927 | who->failmsg (query_name (tmp)); |
2941 | else |
2928 | else |
2942 | unapply_special (who, tmp, aflags); |
2929 | unapply_special (who, tmp, aflags); |
2943 | } |
2930 | } |
2944 | else |
2931 | else |
2945 | { |
2932 | { |
2946 | /* Cursed item that we can't unequip - tell the player. |
2933 | /* Cursed item that we can't unequip - tell the player. |
2947 | * Note this could be annoying if this is just one of a few, |
2934 | * Note this could be annoying if this is just one of a few, |
2948 | * so it may not be critical (eg, putting on a ring and you have |
2935 | * so it may not be critical (eg, putting on a ring and you have |
2949 | * one cursed ring.) |
2936 | * one cursed ring.) |
2950 | */ |
2937 | */ |
2951 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp)); |
2938 | who->failmsg (format ("The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp))); |
2952 | } |
2939 | } |
2953 | |
2940 | |
2954 | last = tmp->below; |
2941 | last = tmp->below; |
2955 | } |
2942 | } |
2956 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
2943 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
… | |
… | |
3137 | if (basic_flag == AP_APPLY) |
3124 | if (basic_flag == AP_APPLY) |
3138 | return 0; |
3125 | return 0; |
3139 | |
3126 | |
3140 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3127 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3141 | { |
3128 | { |
3142 | new_draw_info_format (NDI_UNIQUE, 0, who, |
3129 | who->failmsg (format ("No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, query_name (op))); |
3143 | "No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, |
|
|
3144 | query_name (op)); |
|
|
3145 | return 1; |
3130 | return 1; |
3146 | } |
3131 | } |
3147 | |
3132 | |
3148 | return unapply_special (who, op, aflags); |
3133 | return unapply_special (who, op, aflags); |
3149 | } |
3134 | } |
… | |
… | |
3165 | /* Can't just apply this object. Lets see what not and what to do */ |
3150 | /* Can't just apply this object. Lets see what not and what to do */ |
3166 | if (int i = can_apply_object (who, op)) |
3151 | if (int i = can_apply_object (who, op)) |
3167 | { |
3152 | { |
3168 | if (i & CAN_APPLY_NEVER) |
3153 | if (i & CAN_APPLY_NEVER) |
3169 | { |
3154 | { |
3170 | new_draw_info_format (NDI_UNIQUE, 0, who, |
3155 | who->failmsg (format ("You don't have the body to use a %s. H<You can never apply this item.>", query_name (op))); |
3171 | "You don't have the body to use a %s. H<You can never apply this item.>", |
|
|
3172 | query_name (op)); |
|
|
3173 | return 1; |
3156 | return 1; |
3174 | } |
3157 | } |
3175 | else if (i & CAN_APPLY_RESTRICTION) |
3158 | else if (i & CAN_APPLY_RESTRICTION) |
3176 | { |
3159 | { |
3177 | new_draw_info_format (NDI_UNIQUE, 0, who, |
3160 | who->failmsg (format ( |
3178 | "You have a prohibition against using a %s. " |
3161 | "You have a prohibition against using a %s. " |
3179 | "H<Your belief, profession or class prevents you from applying this item.>", |
3162 | "H<Your belief, profession or class prevents you from applying this item.>", |
3180 | query_name (op)); |
3163 | query_name (op) |
|
|
3164 | )); |
3181 | return 1; |
3165 | return 1; |
3182 | } |
3166 | } |
3183 | |
3167 | |
3184 | if (who->type != PLAYER) |
3168 | if (who->type != PLAYER) |
3185 | { |
3169 | { |
… | |
… | |
3189 | } |
3173 | } |
3190 | else |
3174 | else |
3191 | { |
3175 | { |
3192 | if (who->contr->unapply == unapply_never || (i & CAN_APPLY_UNAPPLY_CHOICE && who->contr->unapply == unapply_nochoice)) |
3176 | if (who->contr->unapply == unapply_never || (i & CAN_APPLY_UNAPPLY_CHOICE && who->contr->unapply == unapply_nochoice)) |
3193 | { |
3177 | { |
3194 | new_draw_info (NDI_UNIQUE, 0, who, "You need to unapply some of the following item(s) or change your applymode:"); |
3178 | who->failmsg ("You need to unapply some of the following item(s) or change your applymode:"); |
3195 | unapply_for_ob (who, op, AP_PRINT); |
3179 | unapply_for_ob (who, op, AP_PRINT); |
3196 | return 1; |
3180 | return 1; |
3197 | } |
3181 | } |
3198 | else if (who->contr->unapply == unapply_always || !(i & CAN_APPLY_UNAPPLY_CHOICE)) |
3182 | else if (who->contr->unapply == unapply_always || !(i & CAN_APPLY_UNAPPLY_CHOICE)) |
3199 | if (unapply_for_ob (who, op, aflags)) |
3183 | if (unapply_for_ob (who, op, aflags)) |
… | |
… | |
3205 | { |
3189 | { |
3206 | skop = find_skill_by_name (who, op->skill); |
3190 | skop = find_skill_by_name (who, op->skill); |
3207 | |
3191 | |
3208 | if (!skop) |
3192 | if (!skop) |
3209 | { |
3193 | { |
3210 | new_draw_info_format (NDI_UNIQUE, 0, who, "You need the %s skill to use this item!", &op->skill); |
3194 | who->failmsg (format ("You need the %s skill to use this item!", &op->skill)); |
3211 | return 1; |
3195 | return 1; |
3212 | } |
3196 | } |
3213 | else |
3197 | else |
3214 | /* While experience will be credited properly, we want to change the |
3198 | /* While experience will be credited properly, we want to change the |
3215 | * skill so that the dam and wc get updated |
3199 | * skill so that the dam and wc get updated |
… | |
… | |
3219 | |
3203 | |
3220 | if (who->type == PLAYER |
3204 | if (who->type == PLAYER |
3221 | && op->item_power |
3205 | && op->item_power |
3222 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3206 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3223 | { |
3207 | { |
3224 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3225 | "Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); |
3208 | who->failmsg ("Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); |
3226 | return 1; |
3209 | return 1; |
3227 | } |
3210 | } |
3228 | |
3211 | |
3229 | /* Ok. We are now at the state where we can apply the new object. |
3212 | /* Ok. We are now at the state where we can apply the new object. |
3230 | * Note that we don't have the checks for can_use_... |
3213 | * Note that we don't have the checks for can_use_... |
… | |
… | |
3241 | switch (op->type) |
3224 | switch (op->type) |
3242 | { |
3225 | { |
3243 | case WEAPON: |
3226 | case WEAPON: |
3244 | if (!check_weapon_power (who, op->last_eat)) |
3227 | if (!check_weapon_power (who, op->last_eat)) |
3245 | { |
3228 | { |
3246 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " |
3229 | op->failmsg ("This weapon is too powerful for you to use. It would consume your soul!." LACK_ITEM_POWER); |
3247 | "It would consume your soul!." LACK_ITEM_POWER); |
|
|
3248 | |
3230 | |
3249 | if (tmp) |
3231 | if (tmp) |
3250 | insert_ob_in_ob (tmp, who); |
3232 | insert_ob_in_ob (tmp, who); |
3251 | |
3233 | |
3252 | return 1; |
3234 | return 1; |
… | |
… | |
3256 | // i.e. "R" can use Ragnarok's sword. |
3238 | // i.e. "R" can use Ragnarok's sword. |
3257 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3239 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3258 | { |
3240 | { |
3259 | /* if the weapon does not have the name as the character, can't use it. */ |
3241 | /* if the weapon does not have the name as the character, can't use it. */ |
3260 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3242 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3261 | new_draw_info (NDI_UNIQUE, 0, who, |
3243 | who->failmsg ("The weapon does not recognize you as its owner. H<Its name indicates that it belongs to somebody else.>"); |
3262 | "The weapon does not recognize you as its owner. " |
|
|
3263 | "H<Its name indicates that it belongs to somebody else.>"); |
|
|
3264 | |
3244 | |
3265 | if (tmp) |
3245 | if (tmp) |
3266 | insert_ob_in_ob (tmp, who); |
3246 | insert_ob_in_ob (tmp, who); |
3267 | |
3247 | |
3268 | return 1; |
3248 | return 1; |
3269 | } |
3249 | } |
3270 | |
3250 | |
3271 | if (!skop) |
3251 | if (!skop) |
3272 | { |
3252 | { |
3273 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO |
3253 | who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO |
3274 | return 1; |
3254 | return 1; |
3275 | } |
3255 | } |
3276 | |
3256 | |
3277 | SET_FLAG (op, FLAG_APPLIED); |
3257 | SET_FLAG (op, FLAG_APPLIED); |
3278 | who->change_skill (skop); |
3258 | who->change_skill (skop); |
3279 | |
3259 | |
3280 | if (who->contr) |
3260 | if (who->contr) |
3281 | who->change_weapon (who->contr->combat_ob = op); |
3261 | who->change_weapon (who->contr->combat_ob = op); |
3282 | |
3262 | |
3283 | new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); |
3263 | who->statusmsg (format ("You wield %s.", query_name (op))); |
3284 | |
3264 | |
3285 | SET_FLAG (who, FLAG_READY_WEAPON); |
3265 | SET_FLAG (who, FLAG_READY_WEAPON); |
3286 | change_abil (who, op); |
3266 | change_abil (who, op); |
3287 | break; |
3267 | break; |
3288 | |
3268 | |
… | |
… | |
3295 | case BRACERS: |
3275 | case BRACERS: |
3296 | case CLOAK: |
3276 | case CLOAK: |
3297 | case RING: |
3277 | case RING: |
3298 | case AMULET: |
3278 | case AMULET: |
3299 | SET_FLAG (op, FLAG_APPLIED); |
3279 | SET_FLAG (op, FLAG_APPLIED); |
3300 | new_draw_info_format (NDI_UNIQUE, 0, who, "You wear %s.", query_name (op)); |
3280 | who->statusmsg (format ("You wear %s.", query_name (op))); |
3301 | change_abil (who, op); |
3281 | change_abil (who, op); |
3302 | break; |
3282 | break; |
3303 | |
3283 | |
3304 | case LAMP: |
3284 | case LAMP: |
3305 | if (op->stats.food < 1) |
3285 | if (op->stats.food < 1) |
3306 | { |
3286 | { |
3307 | new_draw_info_format (NDI_UNIQUE, 0, who, |
3287 | who->failmsg (format ( |
3308 | "Your %s is out of fuel! " |
3288 | "Your %s is out of fuel! " |
3309 | "H<Lamps and similar items need fuel. They cannot be refilled.>", &op->name); |
3289 | "H<Lamps and similar items need fuel. They cannot be refilled.>", |
|
|
3290 | &op->name |
|
|
3291 | )); |
3310 | return 1; |
3292 | return 1; |
3311 | } |
3293 | } |
3312 | |
3294 | |
3313 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); |
3295 | who->statusmsg (format ("You turn on your %s.", &op->name)); |
|
|
3296 | |
3314 | tmp2 = arch_to_object (op->other_arch); |
3297 | tmp2 = arch_to_object (op->other_arch); |
3315 | tmp2->stats.food = op->stats.food; |
3298 | tmp2->stats.food = op->stats.food; |
3316 | SET_FLAG (tmp2, FLAG_APPLIED); |
3299 | SET_FLAG (tmp2, FLAG_APPLIED); |
3317 | |
3300 | |
3318 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
3301 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
… | |
… | |
3337 | who->update_stats (); |
3320 | who->update_stats (); |
3338 | |
3321 | |
3339 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3322 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3340 | if (who->type == PLAYER) |
3323 | if (who->type == PLAYER) |
3341 | { |
3324 | { |
3342 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3343 | "Oops, it feels deadly cold! " |
|
|
3344 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3325 | who->failmsg ("Oops, it feels deadly cold! H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3345 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3326 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3346 | } |
3327 | } |
3347 | |
3328 | |
3348 | if (who->type == PLAYER) |
3329 | if (who->type == PLAYER) |
3349 | esrv_send_item (who, tmp2); |
3330 | esrv_send_item (who, tmp2); |
… | |
… | |
3377 | who->change_weapon (pl->combat_ob = item); |
3358 | who->change_weapon (pl->combat_ob = item); |
3378 | goto found_weapon; |
3359 | goto found_weapon; |
3379 | } |
3360 | } |
3380 | } |
3361 | } |
3381 | |
3362 | |
3382 | new_draw_info_format (NDI_UNIQUE, 0, who, |
3363 | who->failmsg (format ( |
3383 | "You need to apply a '%s' melee weapon before readying this skill. " |
3364 | "You need to apply a '%s' melee weapon before readying this skill. " |
3384 | "H<Some skills need an item, in this case a melee weapon, to function.>", |
3365 | "H<Some skills need an item, in this case a melee weapon, to function.>", |
3385 | &op->skill); |
3366 | &op->skill |
|
|
3367 | )); |
3386 | return 1; |
3368 | return 1; |
3387 | |
3369 | |
3388 | found_weapon:; |
3370 | found_weapon:; |
3389 | } |
3371 | } |
3390 | else |
3372 | else |
… | |
… | |
3400 | //TODO: bows should/must all have skill missile weapon right now |
3382 | //TODO: bows should/must all have skill missile weapon right now |
3401 | who->change_weapon (pl->ranged_ob = item); |
3383 | who->change_weapon (pl->ranged_ob = item); |
3402 | goto found_bow; |
3384 | goto found_bow; |
3403 | } |
3385 | } |
3404 | |
3386 | |
3405 | new_draw_info (NDI_UNIQUE, 0, who, |
3387 | who->failmsg ( |
3406 | "You need to apply a missile weapon before readying this skill. " |
3388 | "You need to apply a missile weapon before readying this skill. " |
3407 | "H<Some skills need an item, in this case a missile weapon, to function.>"); |
3389 | "H<Some skills need an item, in this case a missile weapon, to function.>" |
|
|
3390 | ); |
3408 | return 1; |
3391 | return 1; |
3409 | |
3392 | |
3410 | found_bow:; |
3393 | found_bow:; |
3411 | } |
3394 | } |
3412 | else |
3395 | else |
3413 | who->change_weapon (pl->ranged_ob = op); |
3396 | who->change_weapon (pl->ranged_ob = op); |
3414 | } |
3397 | } |
3415 | |
3398 | |
3416 | if (!op->invisible) |
3399 | if (!op->invisible) |
3417 | { |
3400 | { |
3418 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); |
3401 | who->statusmsg (format ( |
3419 | new_draw_info_format (NDI_UNIQUE, 0, who, "You can now use the skill: %s.", &op->skill); |
3402 | "You ready %s." |
|
|
3403 | "You can now use the skill: %s.", |
|
|
3404 | query_name (op), |
|
|
3405 | &op->skill |
|
|
3406 | )); |
3420 | } |
3407 | } |
3421 | else |
3408 | else |
3422 | new_draw_info_format (NDI_UNIQUE, 0, who, "Readied skill: %s.", op->skill ? &op->skill : &op->name); |
3409 | who->statusmsg (format ("Readied skill: %s.", op->skill ? &op->skill : &op->name)); |
3423 | } |
3410 | } |
3424 | else |
3411 | else |
3425 | { |
3412 | { |
3426 | SET_FLAG (op, FLAG_APPLIED); |
3413 | SET_FLAG (op, FLAG_APPLIED); |
3427 | change_abil (who, op); |
3414 | change_abil (who, op); |
… | |
… | |
3432 | break; |
3419 | break; |
3433 | |
3420 | |
3434 | case BOW: |
3421 | case BOW: |
3435 | if (!check_weapon_power (who, op->last_eat)) |
3422 | if (!check_weapon_power (who, op->last_eat)) |
3436 | { |
3423 | { |
3437 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3438 | "That weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER); |
3424 | who->failmsg ("That weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER); |
3439 | |
3425 | |
3440 | if (tmp) |
3426 | if (tmp) |
3441 | insert_ob_in_ob (tmp, who); |
3427 | insert_ob_in_ob (tmp, who); |
3442 | |
3428 | |
3443 | return 1; |
3429 | return 1; |
3444 | } |
3430 | } |
3445 | |
3431 | |
3446 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3432 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3447 | { |
3433 | { |
3448 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3449 | "The weapon does not recognize you as its owner. " |
3434 | who->failmsg ("The weapon does not recognize you as its owner. " |
3450 | "H<Its name indicates that it belongs to somebody else.>"); |
3435 | "H<Its name indicates that it belongs to somebody else.>"); |
3451 | if (tmp) |
3436 | if (tmp) |
3452 | insert_ob_in_ob (tmp, who); |
3437 | insert_ob_in_ob (tmp, who); |
3453 | |
3438 | |
3454 | return 1; |
3439 | return 1; |
… | |
… | |
3460 | case HORN: |
3445 | case HORN: |
3461 | /* check for skill, alter player status */ |
3446 | /* check for skill, alter player status */ |
3462 | |
3447 | |
3463 | if (!skop) |
3448 | if (!skop) |
3464 | { |
3449 | { |
3465 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO |
3450 | who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO |
3466 | return 1; |
3451 | return 1; |
3467 | } |
3452 | } |
3468 | |
3453 | |
3469 | SET_FLAG (op, FLAG_APPLIED); |
3454 | SET_FLAG (op, FLAG_APPLIED); |
3470 | who->change_skill (skop); |
3455 | who->change_skill (skop); |
3471 | |
3456 | |
3472 | if (who->contr) |
3457 | if (who->contr) |
3473 | { |
3458 | { |
3474 | who->contr->ranged_ob = op; |
3459 | who->contr->ranged_ob = op; |
3475 | |
3460 | |
3476 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); |
3461 | who->statusmsg (format ("You ready %s.", query_name (op))); |
3477 | |
3462 | |
3478 | if (op->type == BOW) |
3463 | if (op->type == BOW) |
3479 | { |
3464 | { |
3480 | who->current_weapon = op; |
3465 | who->current_weapon = op; |
3481 | change_abil (who, op); |
3466 | change_abil (who, op); |
3482 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3483 | "You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op)); |
3467 | who->statusmsg (format ("You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op))); |
3484 | } |
3468 | } |
3485 | } |
3469 | } |
3486 | else |
3470 | else |
3487 | { |
3471 | { |
3488 | if (op->type == BOW) |
3472 | if (op->type == BOW) |
… | |
… | |
3498 | { |
3482 | { |
3499 | //TODO: wtf does this do? shouldn't this be managed automatically (slots?) |
3483 | //TODO: wtf does this do? shouldn't this be managed automatically (slots?) |
3500 | if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) |
3484 | if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) |
3501 | unapply_special (who, who->contr->ranged_ob, 0); |
3485 | unapply_special (who, who->contr->ranged_ob, 0); |
3502 | |
3486 | |
3503 | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready your %s.", query_name (op)); |
3487 | who->statusmsg (format ("You ready your %s.", query_name (op))); |
3504 | |
3488 | |
3505 | who->contr->ranged_ob = op; |
3489 | who->contr->ranged_ob = op; |
3506 | } |
3490 | } |
3507 | break; |
3491 | break; |
3508 | |
3492 | |
3509 | default: |
3493 | default: |
3510 | new_draw_info_format (NDI_UNIQUE, 0, who, "You apply %s.", query_name (op)); |
3494 | who->statusmsg (format ("You apply %s.", query_name (op))); |
3511 | } /* end of switch op->type */ |
3495 | } |
3512 | |
3496 | |
3513 | SET_FLAG (op, FLAG_APPLIED); |
3497 | SET_FLAG (op, FLAG_APPLIED); |
3514 | |
3498 | |
3515 | if (tmp) |
3499 | if (tmp) |
3516 | tmp = insert_ob_in_ob (tmp, who); |
3500 | tmp = insert_ob_in_ob (tmp, who); |
… | |
… | |
3525 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
3509 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
3526 | |
3510 | |
3527 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3511 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3528 | if (who->type == PLAYER) |
3512 | if (who->type == PLAYER) |
3529 | { |
3513 | { |
3530 | new_draw_info (NDI_UNIQUE, 0, who, |
3514 | who->failmsg ( |
3531 | "Oops, it feels deadly cold! " |
3515 | "Oops, it feels deadly cold! " |
3532 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3516 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>" |
|
|
3517 | ); |
3533 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3518 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3534 | } |
3519 | } |
3535 | |
3520 | |
3536 | if (who->type == PLAYER) |
3521 | if (who->type == PLAYER) |
3537 | { |
3522 | { |
… | |
… | |
3775 | { |
3760 | { |
3776 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3761 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3777 | { |
3762 | { |
3778 | assign (who->contr->killer, food->name); |
3763 | assign (who->contr->killer, food->name); |
3779 | hit_player (who, food->stats.hp, food, AT_POISON, 1); |
3764 | hit_player (who, food->stats.hp, food, AT_POISON, 1); |
3780 | new_draw_info (NDI_UNIQUE, 0, who, "Eck!...that was poisonous!"); |
3765 | who->failmsg ("Eck!...that was poisonous!"); |
3781 | } |
3766 | } |
3782 | else |
3767 | else |
3783 | { |
3768 | { |
3784 | if (food->stats.hp > 0) |
3769 | if (food->stats.hp > 0) |
3785 | new_draw_info (NDI_UNIQUE, 0, who, "You begin to feel better."); |
3770 | who->statusmsg ("You begin to feel better."); |
3786 | else |
3771 | else |
3787 | new_draw_info (NDI_UNIQUE, 0, who, "Eck!...that was poisonous!"); |
3772 | who->failmsg ("Eck!...that was poisonous!"); |
|
|
3773 | |
3788 | who->stats.hp += food->stats.hp; |
3774 | who->stats.hp += food->stats.hp; |
3789 | } |
3775 | } |
3790 | } |
3776 | } |
3791 | if (food->stats.sp != 0) |
3777 | if (food->stats.sp != 0) |
3792 | { |
3778 | { |
3793 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3779 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3794 | { |
3780 | { |
3795 | new_draw_info (NDI_UNIQUE, 0, who, "You are drained of mana!"); |
3781 | who->failmsg ("You are drained of mana!"); |
3796 | who->stats.sp -= food->stats.sp; |
3782 | who->stats.sp -= food->stats.sp; |
3797 | if (who->stats.sp < 0) |
3783 | if (who->stats.sp < 0) |
3798 | who->stats.sp = 0; |
3784 | who->stats.sp = 0; |
3799 | } |
3785 | } |
3800 | else |
3786 | else |
3801 | { |
3787 | { |
3802 | new_draw_info (NDI_UNIQUE, 0, who, "You feel a rush of magical energy!"); |
3788 | who->statusmsg ("You feel a rush of magical energy!"); |
3803 | who->stats.sp += food->stats.sp; |
3789 | who->stats.sp += food->stats.sp; |
3804 | /* place limit on max sp from food? */ |
3790 | /* place limit on max sp from food? */ |
3805 | } |
3791 | } |
3806 | } |
3792 | } |
|
|
3793 | |
3807 | who->update_stats (); |
3794 | who->update_stats (); |
3808 | } |
3795 | } |
3809 | |
3796 | |
3810 | /** |
3797 | /** |
3811 | * Designed primarily to light torches/lanterns/etc. |
3798 | * Designed primarily to light torches/lanterns/etc. |
… | |
… | |
3838 | } |
3825 | } |
3839 | else |
3826 | else |
3840 | lighter->stats.food--; |
3827 | lighter->stats.food--; |
3841 | } |
3828 | } |
3842 | else if (lighter->last_eat) |
3829 | else if (lighter->last_eat) |
|
|
3830 | { |
3843 | { /* no charges left in lighter */ |
3831 | /* no charges left in lighter */ |
3844 | new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with a used up %s.", &item->name, &lighter->name); |
3832 | who->failmsg (format ("You attempt to light the %s with a used up %s.", &item->name, &lighter->name)); |
3845 | return; |
3833 | return; |
3846 | } |
3834 | } |
3847 | |
3835 | |
3848 | /* Perhaps we should split what we are trying to light on fire? |
3836 | /* Perhaps we should split what we are trying to light on fire? |
3849 | * I can't see many times when you would want to light multiple |
3837 | * I can't see many times when you would want to light multiple |
… | |
… | |
3855 | |
3843 | |
3856 | save_throw_object (item, AT_FIRE, who); |
3844 | save_throw_object (item, AT_FIRE, who); |
3857 | |
3845 | |
3858 | if (item->destroyed ()) |
3846 | if (item->destroyed ()) |
3859 | { |
3847 | { |
3860 | new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item->name, &lighter->name); |
3848 | who->statusmsg (format ("You light the %s with the %s.", &item->name, &lighter->name)); |
3861 | /* Need to update the player so that the players glow radius |
3849 | /* Need to update the player so that the players glow radius |
3862 | * gets changed. |
3850 | * gets changed. |
3863 | */ |
3851 | */ |
3864 | if (is_player_env) |
3852 | if (is_player_env) |
3865 | who->update_stats (); |
3853 | who->update_stats (); |
3866 | } |
3854 | } |
3867 | else |
3855 | else |
3868 | new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with the %s and fail.", &item->name, &lighter->name); |
3856 | who->failmsg (format ("You attempt to light the %s with the %s and fail.", &item->name, &lighter->name)); |
3869 | } |
3857 | } |
3870 | else /* nothing to light */ |
3858 | else |
3871 | new_draw_info (NDI_UNIQUE, 0, who, "You need to mark a lightable object."); |
3859 | who->failmsg ("You need to mark a lightable object."); |
3872 | |
|
|
3873 | } |
3860 | } |
3874 | |
3861 | |
3875 | /** |
3862 | /** |
3876 | * op made some mistake with a scroll, this takes care of punishment. |
3863 | * op made some mistake with a scroll, this takes care of punishment. |
3877 | * scroll_failure()- hacked directly from spell_failure |
3864 | * scroll_failure()- hacked directly from spell_failure |
… | |
… | |
3884 | |
3871 | |
3885 | if (failure <= -1 && failure > -15) |
3872 | if (failure <= -1 && failure > -15) |
3886 | { /* wonder */ |
3873 | { /* wonder */ |
3887 | object *tmp; |
3874 | object *tmp; |
3888 | |
3875 | |
3889 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!"); |
3876 | op->failmsg ("Your spell warps!"); |
3890 | tmp = get_archetype (SPELL_WONDER); |
3877 | tmp = get_archetype (SPELL_WONDER); |
3891 | cast_wonder (op, op, 0, tmp); |
3878 | cast_wonder (op, op, 0, tmp); |
3892 | tmp->destroy (); |
3879 | tmp->destroy (); |
3893 | } |
3880 | } |
3894 | else if (failure <= -15 && failure > -35) |
3881 | else if (failure <= -15 && failure > -35) |
3895 | { /* drain mana */ |
3882 | { /* drain mana */ |
3896 | new_draw_info (NDI_UNIQUE, 0, op, "Your mana is drained!."); |
3883 | op->failmsg ("Your mana is drained!"); |
3897 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
3884 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
3898 | if (op->stats.sp < 0) |
3885 | if (op->stats.sp < 0) |
3899 | op->stats.sp = 0; |
3886 | op->stats.sp = 0; |
3900 | } |
3887 | } |
3901 | else if (settings.spell_failure_effects == TRUE) |
3888 | else if (settings.spell_failure_effects == TRUE) |
3902 | { |
3889 | { |
3903 | if (failure <= -35 && failure > -60) |
3890 | if (failure <= -35 && failure > -60) |
3904 | { /* confusion */ |
3891 | { /* confusion */ |
3905 | new_draw_info (NDI_UNIQUE, 0, op, "The magic recoils on you!"); |
3892 | op->failmsg ("The magic recoils on you!"); |
3906 | confuse_player (op, op, power); |
3893 | confuse_player (op, op, power); |
3907 | } |
3894 | } |
3908 | else if (failure <= -60 && failure > -70) |
3895 | else if (failure <= -60 && failure > -70) |
3909 | { /* paralysis */ |
3896 | { /* paralysis */ |
3910 | new_draw_info (NDI_UNIQUE, 0, op, "The magic recoils and paralyzes " "you!"); |
3897 | op->failmsg ("The magic recoils and paralyzes you!"); |
3911 | paralyze_player (op, op, power); |
3898 | paralyze_player (op, op, power); |
3912 | } |
3899 | } |
3913 | else if (failure <= -70 && failure > -80) |
3900 | else if (failure <= -70 && failure > -80) |
3914 | { /* blind */ |
3901 | { /* blind */ |
3915 | new_draw_info (NDI_UNIQUE, 0, op, "The magic recoils on you!"); |
3902 | op->failmsg ("The magic recoils on you!"); |
3916 | blind_player (op, op, power); |
3903 | blind_player (op, op, power); |
3917 | } |
3904 | } |
3918 | else if (failure <= -80) |
3905 | else if (failure <= -80) |
3919 | { /* blast the immediate area */ |
3906 | { /* blast the immediate area */ |
3920 | object *tmp = get_archetype (LOOSE_MANA); |
3907 | object *tmp = get_archetype (LOOSE_MANA); |
3921 | cast_magic_storm (op, tmp, power); |
3908 | cast_magic_storm (op, tmp, power); |
3922 | new_draw_info (NDI_UNIQUE, 0, op, "You unleash uncontrolled mana!"); |
3909 | op->failmsg ("You unleash uncontrolled mana!"); |
3923 | tmp->destroy (); |
3910 | tmp->destroy (); |
3924 | } |
3911 | } |
3925 | } |
3912 | } |
3926 | } |
3913 | } |
3927 | |
3914 | |
… | |
… | |
4039 | |
4026 | |
4040 | marked = find_marked_object (pl); |
4027 | marked = find_marked_object (pl); |
4041 | |
4028 | |
4042 | if (!marked) |
4029 | if (!marked) |
4043 | { |
4030 | { |
4044 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); |
4031 | pl->failmsg (format ("Use the %s with what item?", query_name (transformer))); |
4045 | return; |
4032 | return; |
4046 | } |
4033 | } |
4047 | |
4034 | |
4048 | if (!marked->slaying) |
4035 | if (!marked->slaying) |
4049 | { |
4036 | { |
4050 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
4037 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
4051 | return; |
4038 | return; |
4052 | } |
4039 | } |
4053 | |
4040 | |
4054 | /* check whether they are compatible or not */ |
4041 | /* check whether they are compatible or not */ |
4055 | find = strstr (marked->slaying, transformer->arch->archname); |
4042 | find = strstr (marked->slaying, transformer->arch->archname); |
4056 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
4043 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
4057 | { |
4044 | { |
4058 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
4045 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
4059 | return; |
4046 | return; |
4060 | } |
4047 | } |
4061 | |
4048 | |
4062 | find += strlen (transformer->arch->archname) + 1; |
4049 | find += strlen (transformer->arch->archname) + 1; |
4063 | /* Item can be used, now find how many and what it yields */ |
4050 | /* Item can be used, now find how many and what it yields */ |
… | |
… | |
4073 | else |
4060 | else |
4074 | yield = 1; |
4061 | yield = 1; |
4075 | |
4062 | |
4076 | while (isdigit (*find)) |
4063 | while (isdigit (*find)) |
4077 | find++; |
4064 | find++; |
|
|
4065 | |
4078 | while (*find == ' ') |
4066 | while (*find == ' ') |
4079 | find++; |
4067 | find++; |
4080 | |
4068 | |
4081 | memset (got, 0, MAX_BUF); |
4069 | memset (got, 0, MAX_BUF); |
4082 | |
4070 | |
… | |
… | |
4093 | |
4081 | |
4094 | /* Now create new item, remove used ones when required. */ |
4082 | /* Now create new item, remove used ones when required. */ |
4095 | new_item = get_archetype (got); |
4083 | new_item = get_archetype (got); |
4096 | if (!new_item) |
4084 | if (!new_item) |
4097 | { |
4085 | { |
4098 | pl->errormsg (format ("This %s is strange, better to not use it.", query_base_name (marked, 0))); |
4086 | pl->failmsg (format ("This %s is strange, better to not use it.", query_base_name (marked, 0))); |
4099 | return; |
4087 | return; |
4100 | } |
4088 | } |
4101 | |
4089 | |
4102 | new_item->nrof = yield; |
4090 | new_item->nrof = yield; |
4103 | |
4091 | |