ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/apply.C
(Generate patch)

Comparing deliantra/server/server/apply.C (file contents):
Revision 1.123 by root, Thu Aug 16 06:36:56 2007 UTC vs.
Revision 1.169 by root, Sun Sep 7 21:31:23 2008 UTC

1/* 1/*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Crossfire TRT is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24#include <cmath> 24#include <cmath>
25 25
26#include <global.h> 26#include <global.h>
53 * subtype 5: arch or race 53 * subtype 5: arch or race
54 * subtype 7: all three 54 * subtype 7: all three
55 */ 55 */
56 if (op->subtype) 56 if (op->subtype)
57 { 57 {
58 arch_flag = (op->subtype & 1); 58 arch_flag = op->subtype & 1;
59 name_flag = (op->subtype & 2); 59 name_flag = op->subtype & 2;
60 race_flag = (op->subtype & 4); 60 race_flag = op->subtype & 4;
61 } 61 }
62 else 62 else
63 { 63 {
64 arch_flag = 1; 64 arch_flag = 1;
65 name_flag = 1; 65 name_flag = 1;
94static int 94static int
95apply_id_altar (object *money, object *altar, object *pl) 95apply_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.\r", 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:\r" << marked->msg << "\n\n";
123 121
124 return money == NULL; 122 return !money;
125 } 123 }
126 } 124 }
127 125
128 for (id = pl->inv; id; id = id->below) 126 for (object *id = pl->inv; id; id = id->below)
129 { 127 {
130 if (!QUERY_FLAG (id, FLAG_IDENTIFIED) && !id->invisible && need_identify (id)) 128 if (!QUERY_FLAG (id, FLAG_IDENTIFIED) && !id->invisible && need_identify (id))
131 { 129 {
132 if (operate_altar (altar, &money)) 130 if (operate_altar (altar, &money))
133 { 131 {
134 identify (id); 132 identify (id);
135 133
136 buf.printf ("You have %s.", long_desc (id, pl)); 134 buf.printf ("You have %s.\r", 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:\r" << id->msg << "\n\n";
139 137
140 /* If no more money, might as well quit now */ 138 /* If no more money, might as well quit now */
141 if (money == NULL || !check_altar_sacrifice (altar, money)) 139 if (!money || !check_altar_sacrifice (altar, money))
142 break; 140 break;
143 } 141 }
144 else 142 else
145 { 143 {
146 LOG (llevError, "check_id_altar: Couldn't do sacrifice when we should have been able to\n"); 144 LOG (llevError, "check_id_altar: Couldn't do sacrifice when we should have been able to\n");
148 } 146 }
149 } 147 }
150 } 148 }
151 149
152 if (buf.empty ()) 150 if (buf.empty ())
153 buf << ("You have nothing that needs identifying"); 151 pl->failmsg ("You have nothing that needs identifying");
154 152 else
155 pl->contr->infobox (buf); 153 pl->contr->infobox (MSG_CHANNEL ("identify"), buf);
156 154
157 return !money; 155 return !money;
158} 156}
159 157
160/** 158/**
162 * matching item. 160 * matching item.
163 **/ 161 **/
164void 162void
165handle_apply_yield (object *tmp) 163handle_apply_yield (object *tmp)
166{ 164{
167 const char *yield; 165 if (shstr yield = tmp->kv (shstr_on_use_yield))
168 166 archetype::get (yield)->insert_at (tmp, tmp, INS_BELOW_ORIGINATOR);
169 yield = get_ob_key_value (tmp, "on_use_yield");
170 if (yield != NULL)
171 {
172 object *drop = get_archetype (yield);
173
174 if (tmp->env)
175 {
176 drop = insert_ob_in_ob (drop, tmp->env);
177 if (tmp->env->type == PLAYER)
178 esrv_send_item (tmp->env, drop);
179 }
180 else
181 {
182 drop->x = tmp->x;
183 drop->y = tmp->y;
184 insert_ob_in_map (drop, tmp->map, tmp, INS_BELOW_ORIGINATOR);
185 }
186 }
187} 167}
188 168
189/** 169/**
190 * Handles applying a potion. 170 * Handles applying a potion.
191 */ 171 */
197 177
198 floor = GET_MAP_OB (op->map, op->x, op->y); 178 floor = GET_MAP_OB (op->map, op->x, op->y);
199 179
200 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 180 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
201 { 181 {
202 op->errormsg ("Gods prevent you from using this here, it's sacred ground!"); 182 op->failmsg ("Gods prevent you from using this here, it's sacred ground!");
203 183
204 CLEAR_FLAG (tmp, FLAG_APPLIED); 184 CLEAR_FLAG (tmp, FLAG_APPLIED);
205 return 0; 185 return 0;
206 } 186 }
207 187
219 199
220 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 200 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
221 { 201 {
222 op->drain_stat (); 202 op->drain_stat ();
223 op->update_stats (); 203 op->update_stats ();
224 decrease_ob (tmp); 204 tmp->decrease ();
225 return 1; 205 return 1;
226 } 206 }
227 207
228 if (!(at = archetype::find (ARCH_DEPLETION))) 208 if (!(at = archetype::find (ARCH_DEPLETION)))
229 { 209 {
230 LOG (llevError, "Could not find archetype depletion\n"); 210 LOG (llevError, "Could not find archetype depletion\n");
231 return 0; 211 return 0;
232 } 212 }
213
233 depl = present_arch_in_ob (at, op); 214 depl = present_arch_in_ob (at, op);
234 215
235 if (depl) 216 if (depl)
236 { 217 {
237 for (i = 0; i < NUM_STATS; i++) 218 for (i = 0; i < NUM_STATS; i++)
242 op->update_stats (); 223 op->update_stats ();
243 } 224 }
244 else 225 else
245 op->statusmsg ("Your potion had no effect."); 226 op->statusmsg ("Your potion had no effect.");
246 227
247 decrease_ob (tmp); 228 tmp->decrease ();
248 return 1; 229 return 1;
249 } 230 }
250 231
251 /* improvement potion - only for players */ 232 /* improvement potion - only for players */
252 if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) 233 if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER))
314 else 295 else
315 { /* cursed potion */ 296 { /* cursed potion */
316 if (got_one) 297 if (got_one)
317 { 298 {
318 op->update_stats (); 299 op->update_stats ();
319 op->errormsg ("The Gods are angry and punish you."); 300 op->failmsg ("The Gods are angry and punish you.");
320 } 301 }
321 else 302 else
322 op->statusmsg ("You are fortunate that you are so pathetic.", NDI_DK_ORANGE); 303 op->statusmsg ("You are fortunate that you are so pathetic.", NDI_DK_ORANGE);
323 } 304 }
324 305
325 decrease_ob (tmp); 306 tmp->decrease ();
326 return 1; 307 return 1;
327 } 308 }
328 309
329 310
330 /* A potion that casts a spell. Healing, restore spellpoint (power potion) 311 /* A potion that casts a spell. Healing, restore spellpoint (power potion)
336 { 317 {
337 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 318 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
338 { 319 {
339 object *fball; 320 object *fball;
340 321
341 op->errormsg ("Yech! Your lungs are on fire!"); 322 op->failmsg ("Yech! Your lungs are on fire!");
342 323
343 /* Explodes a fireball centered at player */ 324 /* Explodes a fireball centered at player */
344 fball = get_archetype (EXPLODING_FIREBALL); 325 fball = get_archetype (EXPLODING_FIREBALL);
345 fball->dam_modifier = random_roll (1, op->level, op, PREFER_LOW) / 5 + 1; 326 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; 327 fball->stats.maxhp = random_roll (1, op->level, op, PREFER_LOW) / 10 + 2;
349 insert_ob_in_map (fball, op->map, NULL, 0); 330 insert_ob_in_map (fball, op->map, NULL, 0);
350 } 331 }
351 else 332 else
352 cast_spell (op, tmp, op->facing, tmp->inv, NULL); 333 cast_spell (op, tmp, op->facing, tmp->inv, NULL);
353 334
354 decrease_ob (tmp); 335 tmp->decrease ();
355 336
356 /* if youre dead, no point in doing this... */ 337 /* if youre dead, no point in doing this... */
357 if (!QUERY_FLAG (op, FLAG_REMOVED)) 338 if (!QUERY_FLAG (op, FLAG_REMOVED))
358 op->update_stats (); 339 op->update_stats ();
359 340
390 force->speed_left = -1; 371 force->speed_left = -1;
391 force = insert_ob_in_ob (force, op); 372 force = insert_ob_in_ob (force, op);
392 CLEAR_FLAG (tmp, FLAG_APPLIED); 373 CLEAR_FLAG (tmp, FLAG_APPLIED);
393 SET_FLAG (force, FLAG_APPLIED); 374 SET_FLAG (force, FLAG_APPLIED);
394 change_abil (op, force); 375 change_abil (op, force);
395 decrease_ob (tmp); 376 tmp->decrease ();
396 return 1; 377 return 1;
397 } 378 }
398 379
399 /* Only thing left are the stat potions */ 380 /* Only thing left are the stat potions */
400 if (op->type == PLAYER) 381 if (op->type == PLAYER)
413 * stat will not be raised by them. fix_player just clears 394 * stat will not be raised by them. fix_player just clears
414 * up all the stats. 395 * up all the stats.
415 */ 396 */
416 CLEAR_FLAG (tmp, FLAG_APPLIED); 397 CLEAR_FLAG (tmp, FLAG_APPLIED);
417 op->update_stats (); 398 op->update_stats ();
418 decrease_ob (tmp); 399 tmp->decrease ();
419 return 1; 400 return 1;
420} 401}
421 402
422/**************************************************************************** 403/****************************************************************************
423 * Weapon improvement code follows 404 * Weapon improvement code follows
470 { 451 {
471 if (strcmp (op->arch->archname, item) == 0) 452 if (strcmp (op->arch->archname, item) == 0)
472 { 453 {
473 if (op->nrof >= nrof) 454 if (op->nrof >= nrof)
474 { 455 {
475 decrease_ob_nr (op, nrof); 456 op->decrease (nrof);
476 return; 457 return;
477 } 458 }
478 else 459 else
479 { 460 {
480 decrease_ob_nr (op, op->nrof); 461 op->decrease (nrof);
481 nrof -= op->nrof; 462 nrof -= op->nrof;
482 } 463 }
483 464
484 op = prev; 465 op = prev;
485 } 466 }
552 if (improver->slaying) 533 if (improver->slaying)
553 { 534 {
554 count = check_item (op, improver->slaying); 535 count = check_item (op, improver->slaying);
555 if (count < 1) 536 if (count < 1)
556 { 537 {
557 op->errormsg (format ("The gods want more %ss", &improver->slaying)); 538 op->failmsg (format ("The gods want more %ss", &improver->slaying));
558 return 0; 539 return 0;
559 } 540 }
560 } 541 }
561 else 542 else
562 count = 1; 543 count = 1;
570static int 551static int
571improve_weapon_stat (object *op, object *improver, object *weapon, sint8 &stat, int sacrifice_count, const char *statname) 552improve_weapon_stat (object *op, object *improver, object *weapon, sint8 &stat, int sacrifice_count, const char *statname)
572{ 553{
573 stat += sacrifice_count; 554 stat += sacrifice_count;
574 weapon->last_eat++; 555 weapon->last_eat++;
575 decrease_ob (improver); 556 improver->decrease ();
576 557
577 /* So it updates the players stats and the window */ 558 /* So it updates the players stats and the window */
578 op->update_stats (); 559 op->update_stats ();
579 560
580 op->statusmsg (format ( 561 op->statusmsg (format (
581 "Your sacrifice was accepted.\n" 562 "Your sacrifice was accepted.\n"
582 "Weapon's bonus to %s improved by %d.", 563 "Weapon's bonus to %s improved by %d.",
583 statname, sacrifice_count 564 statname, sacrifice_count
584 )); 565 ));
585 566
586 return 1; 567 return 1;
587} 568}
588 569
609 int sacrifice_count, i; 590 int sacrifice_count, i;
610 char buf[MAX_BUF]; 591 char buf[MAX_BUF];
611 592
612 if (weapon->level != 0) 593 if (weapon->level != 0)
613 { 594 {
614 op->errormsg ("Weapon is already prepared!"); 595 op->failmsg ("Weapon is already prepared!");
615 return 0; 596 return 0;
616 } 597 }
617 598
618 for (i = 0; i < NROFATTACKS; i++) 599 for (i = 0; i < NROFATTACKS; i++)
619 if (weapon->resist[i]) 600 if (weapon->resist[i])
625 if (i < NROFATTACKS || weapon->stats.hp || /* regeneration */ 606 if (i < NROFATTACKS || weapon->stats.hp || /* regeneration */
626 (weapon->stats.sp && weapon->type == WEAPON) || /* sp regeneration */ 607 (weapon->stats.sp && weapon->type == WEAPON) || /* sp regeneration */
627 weapon->stats.exp || /* speed */ 608 weapon->stats.exp || /* speed */
628 weapon->stats.ac) /* AC - only taifu's I think */ 609 weapon->stats.ac) /* AC - only taifu's I think */
629 { 610 {
630 op->errormsg ("You cannot prepare magic weapons."); 611 op->failmsg ("You cannot prepare magic weapons. "
612 "H<A weapon is considered magical if it changes regeneration, "
613 "speed or ac, or has other protections.>");
631 return 0; 614 return 0;
632 } 615 }
633 616
634 sacrifice_count = check_sacrifice (op, improver); 617 sacrifice_count = check_sacrifice (op, improver);
635 if (sacrifice_count <= 0) 618 if (sacrifice_count <= 0)
637 620
638 weapon->level = isqrt (sacrifice_count); 621 weapon->level = isqrt (sacrifice_count);
639 eat_item (op, improver->slaying, sacrifice_count); 622 eat_item (op, improver->slaying, sacrifice_count);
640 623
641 op->statusmsg (format ( 624 op->statusmsg (format (
642 "Your sacrifice was accepted." 625 "Your sacrifice was accepted."
643 "Your *%s may be improved %d times.", 626 "Your *%s may be improved %d times.",
644 &weapon->name, weapon->level 627 &weapon->name, weapon->level
645 )); 628 ));
646 629
647 sprintf (buf, "%s's %s", &op->name, &weapon->name); 630 sprintf (buf, "%s's %s", &op->name, &weapon->name);
648 weapon->name = weapon->name_pl = buf; 631 weapon->name = weapon->name_pl = buf;
649 weapon->nrof = 0; /* prevents preparing n weapons in the same 632 weapon->nrof = 0; /* prevents preparing n weapons in the same
650 slot at once! */ 633 slot at once! */
651 decrease_ob (improver); 634 improver->decrease ();
652 weapon->last_eat = 0; 635 weapon->last_eat = 0;
653 return 1; 636 return 1;
654} 637}
655
656 638
657/** 639/**
658 * Does the dirty job for 'improve weapon' scroll, prepare or add something. 640 * Does the dirty job for 'improve weapon' scroll, prepare or add something.
659 * This is the new improve weapon code. 641 * This is the new improve weapon code.
660 * Returns 0 if it was not able to work for some reason. 642 * Returns 0 if it was not able to work for some reason.
673 if (improver->stats.sp == IMPROVE_PREPARE) 655 if (improver->stats.sp == IMPROVE_PREPARE)
674 return prepare_weapon (op, improver, weapon); 656 return prepare_weapon (op, improver, weapon);
675 657
676 if (weapon->level == 0) 658 if (weapon->level == 0)
677 { 659 {
678 op->errormsg ("This weapon has not been prepared. H<You first ahve to prepare a weapon with a prepare weapon scroll.>"); 660 op->failmsg ("This weapon has not been prepared. H<You first ahve to prepare a weapon with a prepare weapon scroll.>");
679 return 0; 661 return 0;
680 } 662 }
681 663
682 if (weapon->level == weapon->last_eat && weapon->item_power >= 100) 664 if (weapon->level == weapon->last_eat && weapon->item_power >= 100)
683 { 665 {
684 op->errormsg ("This weapon cannot be improved any more."); 666 op->failmsg ("This weapon cannot be improved any more.");
685 return 0; 667 return 0;
686 } 668 }
687 669
688 if (QUERY_FLAG (weapon, FLAG_APPLIED) && !check_weapon_power (op, weapon->last_eat + 1)) 670 if (QUERY_FLAG (weapon, FLAG_APPLIED) && !check_weapon_power (op, weapon->last_eat + 1))
689 { 671 {
690 op->errormsg ("Improving the weapon will make it too " 672 op->failmsg ("Improving the weapon will make it too "
691 "powerful for you to use. Unready it if you " 673 "powerful for you to use. Unready it if you "
692 "really want to improve it."); 674 "really want to improve it.");
693 return 0; 675 return 0;
694 } 676 }
695 677
704 weapon->weight += 5000; /* 5 KG's */ 686 weapon->weight += 5000; /* 5 KG's */
705 op->statusmsg (format ("Damage has been increased by 5 to %d.", weapon->stats.dam)); 687 op->statusmsg (format ("Damage has been increased by 5 to %d.", weapon->stats.dam));
706 weapon->last_eat++; 688 weapon->last_eat++;
707 689
708 weapon->item_power++; 690 weapon->item_power++;
709 decrease_ob (improver); 691 improver->decrease ();
710 return 1; 692 return 1;
711 } 693 }
712 694
713 if (improver->stats.sp == IMPROVE_WEIGHT) 695 if (improver->stats.sp == IMPROVE_WEIGHT)
714 { 696 {
718 weapon->weight = 1; 700 weapon->weight = 1;
719 701
720 op->statusmsg (format ("Weapon weight reduced to %6.1fkg.", (float) weapon->weight / 1000.0)); 702 op->statusmsg (format ("Weapon weight reduced to %6.1fkg.", (float) weapon->weight / 1000.0));
721 weapon->last_eat++; 703 weapon->last_eat++;
722 weapon->item_power++; 704 weapon->item_power++;
723 decrease_ob (improver); 705 improver->decrease ();
724 return 1; 706 return 1;
725 } 707 }
708
726 if (improver->stats.sp == IMPROVE_ENCHANT) 709 if (improver->stats.sp == IMPROVE_ENCHANT)
727 { 710 {
728 weapon->magic++; 711 weapon->magic++;
729 weapon->last_eat++; 712 weapon->last_eat++;
730 op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic)); 713 op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic));
731 decrease_ob (improver); 714 improver->decrease ();
732 weapon->item_power++; 715 weapon->item_power++;
733 return 1; 716 return 1;
734 } 717 }
735 718
736 sacrifice_needed = weapon->stats.Str + weapon->stats.Int + weapon->stats.Dex + 719 sacrifice_needed = weapon->stats.Str + weapon->stats.Int + weapon->stats.Dex +
741 sacrifice_needed *= 2; 724 sacrifice_needed *= 2;
742 725
743 sacrifice_count = check_sacrifice (op, improver); 726 sacrifice_count = check_sacrifice (op, improver);
744 if (sacrifice_count < sacrifice_needed) 727 if (sacrifice_count < sacrifice_needed)
745 { 728 {
746 op->errormsg (format ("You need at least %d %s.", sacrifice_needed, &improver->slaying)); 729 op->failmsg (format ("You need at least %d %s.", sacrifice_needed, &improver->slaying));
747 return 0; 730 return 0;
748 } 731 }
749 732
750 eat_item (op, improver->slaying, sacrifice_needed); 733 eat_item (op, improver->slaying, sacrifice_needed);
751 weapon->item_power++; 734 weapon->item_power++;
758 case IMPROVE_WIS: return improve_weapon_stat (op, improver, weapon, weapon->stats.Wis, 1, "wisdom"); 741 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"); 742 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"); 743 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"); 744 case IMPROVE_POW: return improve_weapon_stat (op, improver, weapon, weapon->stats.Pow, 1, "power");
762 default: 745 default:
763 op->errormsg ("Unknown improvement type."); 746 op->failmsg ("Unknown improvement type.");
764 } 747 }
765 748
766 LOG (llevError, "improve_weapon: Got to end of function\n"); 749 LOG (llevError, "improve_weapon: Got to end of function\n");
767 return 0; 750 return 0;
768} 751}
780 if (op->type != PLAYER) 763 if (op->type != PLAYER)
781 return 0; 764 return 0;
782 765
783 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) 766 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC))
784 { 767 {
785 op->errormsg ("Something blocks the magic of the scroll!"); 768 op->failmsg ("Something blocks the magic of the scroll!");
786 return 0; 769 return 0;
787 } 770 }
788 771
789 otmp = find_marked_object (op); 772 otmp = find_marked_object (op);
773
790 if (!otmp) 774 if (!otmp)
791 { 775 {
792 op->errormsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); 776 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; 777 return 0;
794 } 778 }
795 779
796 if (otmp->type != WEAPON && otmp->type != BOW) 780 if (otmp->type != WEAPON && otmp->type != BOW)
797 { 781 {
798 op->errormsg ("Marked item is not a weapon or bow!"); 782 op->failmsg ("Marked item is not a weapon or bow!");
799 return 0; 783 return 0;
800 } 784 }
801 785
802 op->statusmsg ("Applied weapon builder."); 786 op->statusmsg ("Applied weapon builder.");
803 787
833{ 817{
834 object *tmp; 818 object *tmp;
835 819
836 if (armour->magic >= settings.armor_max_enchant) 820 if (armour->magic >= settings.armor_max_enchant)
837 { 821 {
838 op->errormsg ("This armour can not be enchanted any further!"); 822 op->failmsg ("This armour can not be enchanted any further!");
839 return 0; 823 return 0;
840 } 824 }
825
841 /* Dealing with random artifact armor is a lot trickier (in terms of value, weight, 826 /* 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. 827 * 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 828 * Note - maybe add scrolls which make the random artifact versions (eg, armour
844 * of gnarg and what not?) 829 * of gnarg and what not?)
845 */ 830 */
846 if (armour->title) 831 if (armour->title)
847 { 832 {
848 op->errormsg ("This armour will not accept further enchantment."); 833 op->failmsg ("This armour will not accept further enchantment.");
849 return 0; 834 return 0;
850 } 835 }
851 836
852 /* Split objects if needed. Can't insert tmp until the 837 /* Split objects if needed. Can't insert tmp until the
853 * end of this function - otherwise it will just re-merge. 838 * end of this function - otherwise it will just re-merge.
854 */ 839 */
855 if (armour->nrof > 1) 840 tmp = armour->nrof > 1 ? armour->split (armour->nrof - 1) : 0;
856 tmp = get_split_ob (armour, armour->nrof - 1);
857 else
858 tmp = NULL;
859 841
860 armour->magic++; 842 armour->magic++;
861 843
862 if (!settings.armor_speed_linear) 844 if (!settings.armor_speed_linear)
863 { 845 {
900 armour->item_power = get_power_from_ench (armour->arch->item_power + armour->magic); 882 armour->item_power = get_power_from_ench (armour->arch->item_power + armour->magic);
901 883
902 if (op->type == PLAYER) 884 if (op->type == PLAYER)
903 { 885 {
904 esrv_send_item (op, armour); 886 esrv_send_item (op, armour);
887
905 if (QUERY_FLAG (armour, FLAG_APPLIED)) 888 if (QUERY_FLAG (armour, FLAG_APPLIED))
906 op->update_stats (); 889 op->update_stats ();
907 } 890 }
908 891
909 decrease_ob (improver); 892 improver->decrease ();
910 893
911 if (tmp) 894 if (tmp)
912 { 895 op->insert (tmp);
913 insert_ob_in_ob (tmp, op);
914 esrv_send_item (op, tmp);
915 }
916 896
917 return 1; 897 return 1;
918} 898}
919 899
920/* 900/*
921 * convert_item() returns 1 if anything was converted, 0 if the item was not 901 * convert_item() returns 1 if anything was converted, 0 if the item was not
922 * what the converter wants, -1 if the converter is broken. 902 * what the converter wants, -1 if the converter is broken.
923 */ 903 *
924#define CONV_FROM(xyz) xyz->slaying
925#define CONV_TO(xyz) xyz->other_arch
926#define CONV_NR(xyz) xyz->stats.sp
927#define CONV_NEED(xyz) xyz->stats.food
928
929/* Takes one items and makes another. 904 * Takes one type of items and makes another.
930 * converter is the object that is doing the conversion. 905 * converter is the object that is doing the conversion.
931 * item is the object that triggered the converter - if it is not 906 * item is the object that triggered the converter - if it is not
932 * what the converter wants, this will not do anything. 907 * what the converter wants, this will not do anything.
933 */ 908 */
934int 909static int
935convert_item (object *item, object *converter) 910convert_item (object *item, object *converter)
936{ 911{
937 int nr = 0;
938 uint32 price_in; 912 sint64 nr, price_in;
913
914 if (item->flag [FLAG_UNPAID])
915 return 0;
916
917 shstr conv_from = converter->slaying;
918 archetype *conv_to = converter->other_arch;
919 sint64 need = converter->stats.food;
920 sint64 give = converter->stats.sp;
939 921
940 /* We make some assumptions - we assume if it takes money as it type, 922 /* We make some assumptions - we assume if it takes money as it type,
941 * it wants some amount. We don't make change (ie, if something costs 923 * it wants some amount. We don't make change (ie, if something costs
942 * 3 gp and player drops a platinum, tough luck) 924 * 3 gp and player drops a platinum, tough luck)
943 */ 925 */
944 if (CONV_FROM (converter) == shstr_money) 926 if (conv_from == shstr_money)
945 { 927 {
946 if (item->type != MONEY) 928 if (item->type != MONEY)
947 return 0; 929 return 0;
948 930
949 nr = (item->nrof * item->value) / CONV_NEED (converter); 931 nr = sint64 (item->nrof) * item->value / need;
950 if (!nr) 932 if (!nr)
951 return 0; 933 return 0;
952 934
953 converter->play_sound (sound_find ("shop_buy")); 935 converter->play_sound (sound_find ("shop_buy"));
954 936
955 int cost = nr * CONV_NEED (converter) / item->value; 937 sint64 cost = (nr * need + item->value - 1) / item->value;
956 /* take into account rounding errors */
957 if (nr * CONV_NEED (converter) % item->value)
958 cost++;
959 938
960 decrease_ob_nr (item, cost); 939 item->decrease (cost);
961 940
962 price_in = cost * item->value; 941 price_in = cost * item->value;
963 } 942 }
964 else 943 else
965 { 944 {
966 if (item->type == PLAYER || CONV_FROM (converter) != item->arch->archname || 945 if (item->type == PLAYER
967 (CONV_NEED (converter) && CONV_NEED (converter) > (uint16) item->nrof)) 946 || conv_from != item->arch->archname
947 || (need && need > (uint16) item->nrof))
968 return 0; 948 return 0;
969 949
970 converter->play_sound (sound_find ("convert_item")); 950 converter->play_sound (sound_find ("convert_item"));
971 951
972 if (CONV_NEED (converter)) 952 if (need)
973 { 953 {
974 nr = item->nrof / CONV_NEED (converter); 954 nr = sint64 (item->nrof) / need;
975 decrease_ob_nr (item, nr * CONV_NEED (converter)); 955 item->decrease (nr * need);
976 price_in = nr * CONV_NEED (converter) * item->value; 956 price_in = nr * need * item->value;
977 } 957 }
978 else 958 else
979 { 959 {
980 price_in = item->value; 960 price_in = item->value;
981 item->destroy (); 961 item->destroy ();
992 ob_to_copy = converter->inv; 972 ob_to_copy = converter->inv;
993 for (ob = converter->inv->below, i = 1; ob; ob = ob->below, i++) 973 for (ob = converter->inv->below, i = 1; ob; ob = ob->below, i++)
994 if (rndm (0, i) == 0) 974 if (rndm (0, i) == 0)
995 ob_to_copy = ob; 975 ob_to_copy = ob;
996 976
997 item = object_create_clone (ob_to_copy); 977 item = ob_to_copy->deep_clone ();
998 CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); 978 CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE);
999 unflag_inv (item, FLAG_IS_A_TEMPLATE); 979 unflag_inv (item, FLAG_IS_A_TEMPLATE);
1000 } 980 }
1001 else 981 else
1002 { 982 {
1003 if (converter->other_arch == NULL) 983 if (!conv_to)
1004 { 984 {
1005 LOG (llevError, "move_creator: Converter doesn't have other arch set: %s (%s, %d, %d)\n", 985 LOG (llevError, "move_creator: Converter doesn't have other arch set: %s (%s, %d, %d)\n",
1006 &converter->name, &converter->map->path, converter->x, converter->y); 986 &converter->name, &converter->map->path, converter->x, converter->y);
1007 return -1; 987 return -1;
1008 } 988 }
1009 989
1010 item = object_create_arch (converter->other_arch); 990 item = object_create_arch (conv_to);
1011 fix_generated_item (item, converter, 0, 0, GT_MINIMAL); 991 fix_generated_item (item, converter, 0, 0, GT_MINIMAL);
1012 } 992 }
1013 993
1014 if (CONV_NR (converter)) 994 if (give)
1015 item->nrof = CONV_NR (converter); 995 item->nrof = give;
1016 996
1017 if (nr) 997 if (nr)
1018 item->nrof *= nr; 998 item->nrof *= nr;
1019 999
1020 if (is_in_shop (converter)) 1000 if (is_in_shop (converter))
1021 SET_FLAG (item, FLAG_UNPAID); 1001 SET_FLAG (item, FLAG_UNPAID);
1022 else if (price_in < item->nrof * item->value) 1002 else if (price_in < sint64 (item->nrof) * item->value)
1023 { 1003 {
1024 LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", 1004 LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n",
1025 &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); 1005 &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name);
1026 /** 1006 /**
1027 * elmex: we are going to let the game continue, as the mapcreator 1007 * elmex: we are going to let the game continue, as the mapcreator
1028 * hopefully had something in mind when doing this. 1008 * hopefully had something in mind when doing this.
1029 */ 1009 */
1030 } 1010 }
1031 1011
1032 SET_FLAG (item, FLAG_IDENTIFIED); 1012 // elmex: only identify if we need to, for example so that generated money doesn't
1013 // get an 'identified' flag so easily.
1014 if (need_identify (item))
1015 identify (item);
1016
1033 insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); 1017 insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y);
1034 return 1; 1018 return 1;
1035} 1019}
1036 1020
1037/** 1021/**
1054 1038
1055 op->contr->last_used = 0; 1039 op->contr->last_used = 0;
1056 1040
1057 if (sack->env && sack->env != op) 1041 if (sack->env && sack->env != op)
1058 { 1042 {
1059 new_draw_info (NDI_UNIQUE, 0, op, "You must put it onto the floor or into your inventory first."); 1043 op->failmsg ("You must put it onto the floor or into your inventory first.");
1060 return 1; 1044 return 1;
1061 } 1045 }
1062 1046
1063 // already applied == open on ground, or open in inv, or active in inv 1047 // already applied == open on ground, or open in inv, or active in inv
1064 if (sack->flag [FLAG_APPLIED]) 1048 if (sack->flag [FLAG_APPLIED])
1070 return 1; 1054 return 1;
1071 } 1055 }
1072 else if (!sack->env) 1056 else if (!sack->env)
1073 { 1057 {
1074 // active, but not ours: some other player has opened it 1058 // 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)); 1059 op->failmsg (format ("Somebody else is using the %s already.", query_name (sack)));
1076 return 1; 1060 return 1;
1077 } 1061 }
1078 1062
1079 // fall through to opening it (active in inv) 1063 // fall through to opening it (active in inv)
1080 } 1064 }
1082 { 1066 {
1083 // it is in our env, so activate it, do not open yet 1067 // it is in our env, so activate it, do not open yet
1084 op->close_container (); 1068 op->close_container ();
1085 sack->flag [FLAG_APPLIED] = 1; 1069 sack->flag [FLAG_APPLIED] = 1;
1086 esrv_update_item (UPD_FLAGS, op, sack); 1070 esrv_update_item (UPD_FLAGS, op, sack);
1087 new_draw_info_format (NDI_UNIQUE, 0, op, "You ready %s.", query_name (sack)); 1071 op->statusmsg (format ("You ready %s.", query_name (sack)));
1088 return 1; 1072 return 1;
1089 } 1073 }
1090 1074
1091 // it's locked? 1075 // it's locked?
1092 if (sack->slaying) 1076 if (sack->slaying)
1093 { 1077 {
1094 if (object *tmp = find_key (op, op, sack)) 1078 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)); 1079 op->statusmsg (format ("You unlock %s with %s.", query_name (sack), query_name (tmp)));
1096 else 1080 else
1097 { 1081 {
1098 new_draw_info_format (NDI_UNIQUE, 0, op, "You don't have the key to unlock %s.", query_name (sack)); 1082 op->statusmsg (format ("You don't have the key to unlock %s.", query_name (sack)));
1099 return 1; 1083 return 1;
1100 } 1084 }
1101 } 1085 }
1102 1086
1103 op->open_container (sack); 1087 op->open_container (sack);
1122 * with an altar. We call it a Potion - altars are stationary - it 1106 * with an altar. We call it a Potion - altars are stationary - it
1123 * is up to map designers to use them properly. 1107 * is up to map designers to use them properly.
1124 */ 1108 */
1125 if (altar->inv && altar->inv->type == SPELL) 1109 if (altar->inv && altar->inv->type == SPELL)
1126 { 1110 {
1127 new_draw_info_format (NDI_BLACK, 0, originator, "The altar casts %s.", &altar->inv->name); 1111 originator->statusmsg (format ("The altar casts %s.", &altar->inv->name));
1128 cast_spell (originator, altar, 0, altar->inv, NULL); 1112 cast_spell (originator, altar, 0, altar->inv, NULL);
1129 /* If it is connected, push the button. Fixes some problems with 1113 /* If it is connected, push the button. Fixes some problems with
1130 * old maps. 1114 * old maps.
1131 */ 1115 */
1132 1116
1133/* push_button (altar);*/ 1117/* push_button (altar);*/
1134 } 1118 }
1230 op->contr->play_sound (sound_find ("shop_enter")); 1214 op->contr->play_sound (sound_find ("shop_enter"));
1231 else 1215 else
1232 op->contr->play_sound (sound_find ("shop_leave")); 1216 op->contr->play_sound (sound_find ("shop_leave"));
1233 1217
1234 if (shop_mat->msg) 1218 if (shop_mat->msg)
1235 new_draw_info (NDI_UNIQUE, 0, op, shop_mat->msg); 1219 op->statusmsg (shop_mat->msg);
1236 /* This check below is a bit simplistic - generally it should be correct, 1220 /* 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 1221 * but there is never a guarantee that the bottom space on the map is
1238 * actually the shop floor. 1222 * actually the shop floor.
1239 */ 1223 */
1240 else if (!rv && !is_in_shop (op)) 1224 else if (!rv && !is_in_shop (op))
1241 { 1225 {
1242 opinion = shopkeeper_approval (op->map, op); 1226 opinion = shopkeeper_approval (op->map, op);
1243 1227
1244 if (opinion > 0.9) 1228 op->statusmsg (
1245 new_draw_info (NDI_UNIQUE, 0, op, "The shopkeeper gives you a friendly wave."); 1229 opinion >= 0.90 ? "The shopkeeper gives you a friendly wave."
1246 else if (opinion > 0.75) 1230 : opinion >= 0.75 ? "The shopkeeper waves to you."
1247 new_draw_info (NDI_UNIQUE, 0, op, "The shopkeeper waves to you."); 1231 : opinion >= 0.50 ? "The shopkeeper ignores you."
1248 else if (opinion > 0.5) 1232 : "The shopkeeper glares at you with contempt."
1249 new_draw_info (NDI_UNIQUE, 0, op, "The shopkeeper ignores you.");
1250 else 1233 );
1251 new_draw_info (NDI_UNIQUE, 0, op, "The shopkeeper glares at you with contempt.");
1252 } 1234 }
1253 } 1235 }
1254 else 1236 else
1255 { 1237 {
1256 /* if we get here, a player tried to leave a shop but was not able 1238 /* if we get here, a player tried to leave a shop but was not able
1278 * Handles applying a sign. 1260 * Handles applying a sign.
1279 */ 1261 */
1280static void 1262static void
1281apply_sign (object *op, object *sign, int autoapply) 1263apply_sign (object *op, object *sign, int autoapply)
1282{ 1264{
1283 readable_message_type *msgType; 1265 if (sign->has_dialogue ())
1284
1285 if (sign->msg == NULL)
1286 { 1266 {
1287 new_draw_info (NDI_UNIQUE, 0, op, "Nothing is written on it."); 1267 op->statusmsg (form ("Maybe you should I<talk> to the %s instead?", &sign->name));
1288 return; 1268 return;
1289 } 1269 }
1290 1270
1271 if (!sign->msg)
1272 {
1273 op->statusmsg ("Nothing is written on it.");
1274 return;
1275 }
1276
1291 if (sign->stats.food) 1277 if (sign->stats.food)
1292 { 1278 {
1293 if (sign->last_eat >= sign->stats.food) 1279 if (sign->last_eat >= sign->stats.food)
1294 { 1280 {
1295 if (!sign->move_on) 1281 if (!sign->move_on)
1296 new_draw_info (NDI_UNIQUE, 0, op, "You cannot read it anymore."); 1282 op->statusmsg ("You cannot read it anymore.");
1297 1283
1298 return; 1284 return;
1299 } 1285 }
1300 1286
1301 if (!QUERY_FLAG (op, FLAG_WIZPASS)) 1287 if (!QUERY_FLAG (op, FLAG_WIZPASS))
1307 * move_on is zero, it needs to be manually applied (doesn't talk 1293 * move_on is zero, it needs to be manually applied (doesn't talk
1308 * to us). 1294 * to us).
1309 */ 1295 */
1310 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ) && !sign->move_on) 1296 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ) && !sign->move_on)
1311 { 1297 {
1312 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); 1298 op->failmsg ("You are unable to read while blind!");
1313 return; 1299 return;
1314 } 1300 }
1315 1301
1316 if (op->contr) 1302 if (op->contr)
1317 if (client *ns = op->contr->ns) 1303 if (client *ns = op->contr->ns)
1318 { 1304 {
1305 if (sign->sound)
1319 ns->play_sound (sign->sound); 1306 ns->play_sound (sign->sound);
1320 msgType = get_readable_message_type (sign); 1307 else if (autoapply)
1308 ns->play_sound (sound_find ("msg_voice"));
1321 1309
1322 if (ns->can_msg) 1310 if (ns->can_msg)
1323 ns->send_msg (NDI_NAVY, msgType->msgtype, &sign->msg); 1311 op->contr->infobox (MSG_CHANNEL ("examine"), format ("T<%s>\n\n\n\n%s", &sign->name, &sign->msg));
1324 else 1312 else
1325 { 1313 {
1326 char newbuf[HUGE_BUF]; 1314 readable_message_type *msgType = get_readable_message_type (sign);
1327 snprintf (newbuf, sizeof (newbuf), "%u %s", autoapply ? 1 : 0, &sign->msg); 1315 const char *somemsg = format ("%u %s", autoapply ? 1 : 0, &sign->msg);
1328 draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, newbuf, &sign->msg); 1316 draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, somemsg, &sign->msg);
1329 } 1317 }
1330 } 1318 }
1319}
1320
1321static void
1322move_apply_hole (object *trap, object *victim)
1323{
1324 /* Hole not open? */
1325 if (trap->stats.wc > 0)
1326 return;
1327
1328 /* Is this a multipart monster and not the head? If so, return.
1329 * Processing will happen if the head runs into the pit
1330 */
1331 if (victim->head)
1332 return;
1333
1334 // now find all possible locations and randomly pick one
1335 int dir = find_free_spot (victim, trap->map, EXIT_X (trap), EXIT_Y (trap), 0,
1336 trap->range >= 3 ? SIZEOFFREE3 + 1
1337 : trap->range >= 2 ? SIZEOFFREE2 + 1
1338 : trap->range >= 1 ? SIZEOFFREE1 + 1
1339 : SIZEOFFREE0 + 1);
1340
1341 if (dir < 0)
1342 return;
1343
1344 victim->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole"));
1345 victim->statusmsg ("You fall through the hole!", NDI_RED);
1346
1347 transfer_ob (victim,
1348 EXIT_X (trap) + freearr_x[dir],
1349 EXIT_Y (trap) + freearr_y[dir],
1350 0, victim);
1331} 1351}
1332 1352
1333/** 1353/**
1334 * 'victim' moves onto 'trap' 1354 * 'victim' moves onto 'trap'
1335 * 'victim' leaves 'trap' 1355 * 'victim' leaves 'trap'
1447 1467
1448 if (!trap->value) 1468 if (!trap->value)
1449 { 1469 {
1450 int tot; 1470 int tot;
1451 1471
1452 for (ab = trap->above, tot = 0; ab != NULL; ab = ab->above) 1472 for (ab = trap->above, tot = 0; ab; ab = ab->above)
1453 if ((ab->move_type && trap->move_on) || ab->move_type == 0) 1473 if ((ab->move_type && trap->move_on) || ab->move_type == 0)
1454 tot += (ab->nrof ? ab->nrof : 1) * ab->weight + ab->carrying; 1474 tot += ab->head_ ()->total_weight ();
1455 1475
1456 if (!(trap->value = (tot > trap->weight) ? 1 : 0)) 1476 if (!(trap->value = (tot > trap->weight) ? 1 : 0))
1457 goto leave; 1477 goto leave;
1458 1478
1459 SET_ANIMATION (trap, trap->value); 1479 SET_ANIMATION (trap, trap->value);
1469 1489
1470 if ((ab->move_type && trap->move_on) || ab->move_type == 0) 1490 if ((ab->move_type && trap->move_on) || ab->move_type == 0)
1471 { 1491 {
1472 if (!sound_was_played) 1492 if (!sound_was_played)
1473 { 1493 {
1474 trap->play_sound (sound_find ("fall_hole")); 1494 trap->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole"));
1475 sound_was_played = 1; 1495 sound_was_played = 1;
1476 } 1496 }
1477 1497
1478 new_draw_info (NDI_UNIQUE, 0, ab, "You fall into a trapdoor!"); 1498 ab->statusmsg ("You fall into a trapdoor!", NDI_RED);
1479 transfer_ob (ab, (int) EXIT_X (trap), (int) EXIT_Y (trap), 0, ab); 1499 transfer_ob (ab, EXIT_X (trap), EXIT_Y (trap), 0, ab);
1480 } 1500 }
1481 } 1501 }
1482 goto leave; 1502 goto leave;
1483 } 1503 }
1484 1504
1485 case CONVERTER: 1505 case CONVERTER:
1486 if (convert_item (victim, trap) < 0) 1506 if (convert_item (victim, trap) < 0)
1487 { 1507 {
1488 new_draw_info_format (NDI_UNIQUE, 0, originator, "The %s seems to be broken!", query_name (trap)); 1508 originator->failmsg (format ("The %s seems to be broken!", query_name (trap)));
1489 get_archetype ("burnout")->insert_at (trap, trap); 1509 archetype::get (shstr_burnout)->insert_at (trap, trap);
1490 } 1510 }
1491 1511
1492 goto leave; 1512 goto leave;
1493 1513
1494 case TRIGGER_BUTTON: 1514 case TRIGGER_BUTTON:
1504 case CHECK_INV: 1524 case CHECK_INV:
1505 check_inv (victim, trap); 1525 check_inv (victim, trap);
1506 goto leave; 1526 goto leave;
1507 1527
1508 case HOLE: 1528 case HOLE:
1509 /* Hole not open? */ 1529 move_apply_hole (trap, victim);
1510 if (trap->stats.wc > 0)
1511 goto leave;
1512
1513 /* Is this a multipart monster and not the head? If so, return.
1514 * Processing will happen if the head runs into the pit
1515 */
1516 if (victim->head)
1517 goto leave;
1518
1519 victim->play_sound (sound_find ("fall_hole"));
1520 new_draw_info (NDI_UNIQUE, 0, victim, "You fall through the hole!\n");
1521 transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim);
1522 goto leave; 1530 goto leave;
1523 1531
1524 case EXIT: 1532 case EXIT:
1525 if (victim->type == PLAYER && EXIT_PATH (trap)) 1533 if (victim->type == PLAYER && EXIT_PATH (trap))
1526 { 1534 {
1527 /* Basically, don't show exits leading to random maps the 1535 /* Basically, don't show exits leading to random maps the
1528 * players output. 1536 * players output.
1529 */ 1537 */
1530 if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2)) 1538 if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2))
1531 new_draw_info (NDI_NAVY, 0, victim, trap->msg); 1539 victim->statusmsg (trap->msg, NDI_NAVY);
1532 1540
1541 trap->play_sound (trap->sound);
1533 victim->enter_exit (trap); 1542 victim->enter_exit (trap);
1534 } 1543 }
1535 goto leave; 1544 goto leave;
1536 1545
1537 case ENCOUNTER: 1546 case ENCOUNTER:
1559 goto leave; 1568 goto leave;
1560 1569
1561 case RUNE: 1570 case RUNE:
1562 case TRAP: 1571 case TRAP:
1563 if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) 1572 if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE))
1564 {
1565 spring_trap (trap, victim); 1573 spring_trap (trap, victim);
1566 }
1567 goto leave; 1574 goto leave;
1568 1575
1569 default: 1576 default:
1570 LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " 1577 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); 1578 "handled in move_apply()\n", &trap->name, &trap->arch->archname, trap->type);
1585 int lev_diff; 1592 int lev_diff;
1586 object *skill_ob; 1593 object *skill_ob;
1587 1594
1588 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) 1595 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ))
1589 { 1596 {
1590 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); 1597 op->failmsg ("You are unable to read while blind!");
1591 return; 1598 return;
1592 } 1599 }
1593 1600
1594 if (!tmp->msg) 1601 if (!tmp->msg)
1595 { 1602 {
1596 new_draw_info_format (NDI_UNIQUE, 0, op, "You open the %s and find it empty.", &tmp->name); 1603 op->failmsg (format ("You open the %s and find it empty.", &tmp->name));
1597 return; 1604 return;
1598 } 1605 }
1599 1606
1600 /* need a literacy skill to read stuff! */ 1607 /* need a literacy skill to read stuff! */
1601 skill_ob = find_skill_by_name (op, tmp->skill); 1608 skill_ob = find_skill_by_name (op, tmp->skill);
1602 if (!skill_ob) 1609 if (!skill_ob)
1603 { 1610 {
1604 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<You lack the skill to read this>"); 1611 op->failmsg (format ("You are unable to decipher the strange symbols. H<You lack the %s skill to read this.>", &tmp->skill));
1605 return; 1612 return;
1606 } 1613 }
1607 1614
1608 lev_diff = tmp->level - (skill_ob->level + 5); 1615 lev_diff = tmp->level - (skill_ob->level + 5);
1609 if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) 1616 if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0)
1610 { 1617 {
1611 if (lev_diff < 2) 1618 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."); 1619 : lev_diff < 3 ? "This book is slightly beyond your comprehension."
1613 else if (lev_diff < 3) 1620 : lev_diff < 5 ? "This book is beyond your comprehension."
1614 new_draw_info (NDI_UNIQUE, 0, op, "This book is slightly beyond your comprehension."); 1621 : lev_diff < 8 ? "This book is quite a bit beyond your comprehension."
1615 else if (lev_diff < 5) 1622 : lev_diff < 15 ? "This book is way beyond your comprehension."
1616 new_draw_info (NDI_UNIQUE, 0, op, "This book is beyond your comprehension."); 1623 : "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; 1624 return;
1624 } 1625 }
1625 1626
1626 readable_message_type *msgType = get_readable_message_type (tmp); 1627 readable_message_type *msgType = get_readable_message_type (tmp);
1627 1628
1628 if (player *pl = op->contr) 1629 if (player *pl = op->contr)
1629 if (client *ns = pl->ns) 1630 if (client *ns = pl->ns)
1630 if (ns->can_msg) 1631 if (ns->can_msg)
1631 { 1632 pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n\n\n%s", (char *)long_desc (tmp, op), &tmp->msg));
1632 dynbuf_text buf;
1633 buf << long_desc (tmp, op)
1634 << "\n\n"
1635 << tmp->msg
1636 << '\0';
1637 ns->send_msg (NDI_NAVY, msgType->msgtype, buf.linearise ());
1638 }
1639 else 1633 else
1640 draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, 1634 draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op,
1641 msgType->message_type, msgType->message_subtype, 1635 msgType->message_type, msgType->message_subtype,
1642 "You open the %s and start reading.\n%s", (char *)"%s\n%s", 1636 "You open the %s and start reading.\n%s", (char *)"%s\n%s",
1643 long_desc (tmp, op), &tmp->msg); 1637 long_desc (tmp, op), &tmp->msg);
1650 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 1644 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED))
1651 { 1645 {
1652 /*exp_gain *= 2; because they just identified it too */ 1646 /*exp_gain *= 2; because they just identified it too */
1653 SET_FLAG (tmp, FLAG_IDENTIFIED); 1647 SET_FLAG (tmp, FLAG_IDENTIFIED);
1654 1648
1655 /* If in a container, update how it looks */ 1649 if (object *pl = tmp->visible_to ())
1656 if (tmp->env)
1657 esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); 1650 esrv_update_item (UPD_FLAGS | UPD_NAME, pl, tmp);
1658 else
1659 op->contr->ns->floorbox_update ();
1660 } 1651 }
1661 1652
1662 change_exp (op, exp_gain, skill_ob->skill, 0); 1653 change_exp (op, exp_gain, skill_ob->skill, 0);
1663 SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ 1654 SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */
1664 } 1655 }
1669 * op is the person learning the skill, tmp is the skill scroll object 1660 * op is the person learning the skill, tmp is the skill scroll object
1670 */ 1661 */
1671static void 1662static void
1672apply_skillscroll (object *op, object *tmp) 1663apply_skillscroll (object *op, object *tmp)
1673{ 1664{
1674 switch ((int) learn_skill (op, tmp)) 1665 switch (learn_skill (op, tmp))
1675 { 1666 {
1676 case 0: 1667 case 0:
1677 new_draw_info (NDI_UNIQUE, 0, op, "You already possess the knowledge "); 1668 op->play_sound (sound_find ("generic_fail"));
1678 new_draw_info_format (NDI_UNIQUE, 0, op, "held within the %s.\n", query_name (tmp)); 1669 op->failmsg (format ("You already possess the knowledge held within the %s.", query_name (tmp)));
1679 return; 1670 break;
1680 1671
1681 case 1: 1672 case 1:
1682 new_draw_info_format (NDI_UNIQUE, 0, op, "You succeed in learning %s", &tmp->skill);
1683 decrease_ob (tmp); 1673 tmp->decrease ();
1674 op->play_sound (sound_find ("skill_learn"));
1675 op->statusmsg (format ("You succeed in learning %s", &tmp->skill));
1684 return; 1676 break;
1685 1677
1686 default: 1678 default:
1679 tmp->decrease ();
1680 op->play_sound (sound_find ("generic_fail"));
1687 new_draw_info_format (NDI_UNIQUE, 0, op, "You fail to learn the knowledge of the %s.\n", query_name (tmp)); 1681 op->failmsg (format ("You fail to learn the knowledge of the %s.\n", query_name (tmp)));
1688 decrease_ob (tmp);
1689 return; 1682 break;
1690 } 1683 }
1691} 1684}
1692 1685
1693/** 1686/**
1694 * Actually makes op learn spell. 1687 * Actually makes op learn spell.
1744 { 1737 {
1745 LOG (llevError, "BUG: do_forget_spell(): spell not known\n"); 1738 LOG (llevError, "BUG: do_forget_spell(): spell not known\n");
1746 return; 1739 return;
1747 } 1740 }
1748 1741
1749 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", spell); 1742 op->failmsg (format ("You lose knowledge of %s.", spell));
1750 player_unready_range_ob (op->contr, spob); 1743 player_unready_range_ob (op->contr, spob);
1751 esrv_remove_spell (op->contr, spob); 1744 esrv_remove_spell (op->contr, spob);
1752 spob->destroy (); 1745 spob->destroy ();
1753} 1746}
1754 1747
1762{ 1755{
1763 object *skop, *spell, *spell_skill; 1756 object *skop, *spell, *spell_skill;
1764 1757
1765 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) 1758 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ))
1766 { 1759 {
1767 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); 1760 op->failmsg ("You are unable to read while blind.");
1768 return; 1761 return;
1769 } 1762 }
1770 1763
1771 /* artifact_spellbooks have 'slaying' field point to a spell name, 1764 /* artifact_spellbooks have 'slaying' field point to a spell name,
1772 * instead of having their spell stored in stats.sp. These are 1765 * instead of having their spell stored in stats.sp. These are
1775 if (tmp->slaying) 1768 if (tmp->slaying)
1776 { 1769 {
1777 spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); 1770 spell = arch_to_object (find_archetype_by_object_name (tmp->slaying));
1778 if (!spell) 1771 if (!spell)
1779 { 1772 {
1780 new_draw_info_format (NDI_UNIQUE, 0, op, "The book's formula for %s is incomplete", &tmp->slaying); 1773 op->failmsg (format ("The book's formula for %s is incomplete.", &tmp->slaying));
1781 return; 1774 return;
1782 } 1775 }
1783 else 1776 else
1784 insert_ob_in_ob (spell, tmp); 1777 insert_ob_in_ob (spell, tmp);
1785 1778
1790 1783
1791 /* need a literacy skill to learn spells. Also, having a literacy level 1784 /* need a literacy skill to learn spells. Also, having a literacy level
1792 * lower than the spell will make learning the spell more difficult */ 1785 * lower than the spell will make learning the spell more difficult */
1793 if (!skop) 1786 if (!skop)
1794 { 1787 {
1795 new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails. H<You lack the literacy skill.>"); 1788 op->failmsg (format ("You can't read! Your attempt fails. H<You lack the %s skill.>", &tmp->skill));
1796 return; 1789 return;
1797 } 1790 }
1798 1791
1799 spell = tmp->inv; 1792 spell = tmp->inv;
1800 1793
1801 if (!spell) 1794 if (!spell)
1802 { 1795 {
1803 LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); 1796 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!"); 1797 op->failmsg ("The spellbook symbols make no sense. This is a bug, please report!");
1805 return; 1798 return;
1806 } 1799 }
1807 1800
1808 if (skop->level < int (sqrtf (spell->level) * 1.5f)) 1801 if (skop->level < int (sqrtf (spell->level) * 1.5f))
1809 { 1802 {
1810 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<Your literacy level is too low.>"); 1803 op->failmsg (format ("You are unable to decipher the strange symbols. H<Your %s level is too low.>", &tmp->skill));
1811 return; 1804 return;
1812 } 1805 }
1813 1806
1814 new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); 1807 op->statusmsg (format ("The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name));
1815 1808
1816 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 1809 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED))
1817 {
1818 identify (tmp); 1810 identify (tmp);
1819
1820 if (tmp->env)
1821 esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp);
1822 else
1823 op->contr->ns->floorbox_update ();
1824 }
1825 1811
1826 /* I removed the check for special_prayer_mark here - it didn't make 1812 /* I removed the check for special_prayer_mark here - it didn't make
1827 * a lot of sense - special prayers are not found in spellbooks, and 1813 * a lot of sense - special prayers are not found in spellbooks, and
1828 * if the player doesn't know the spell, doesn't make a lot of sense that 1814 * if the player doesn't know the spell, doesn't make a lot of sense that
1829 * they would have a special prayer mark. 1815 * they would have a special prayer mark.
1830 */ 1816 */
1831 if (check_spell_known (op, spell->name)) 1817 if (check_spell_known (op, spell->name))
1832 { 1818 {
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"); 1819 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; 1820 return;
1835 } 1821 }
1836 1822
1837 if (spell->skill) 1823 if (spell->skill)
1838 { 1824 {
1839 spell_skill = find_skill_by_name (op, spell->skill); 1825 spell_skill = find_skill_by_name (op, spell->skill);
1840 1826
1841 if (!spell_skill) 1827 if (!spell_skill)
1842 { 1828 {
1843 new_draw_info_format (NDI_UNIQUE, 0, op, "You lack the skill %s to use this spell.", &spell->skill); 1829 op->failmsg (format ("You lack the skill %s to use this spell.", &spell->skill));
1844 return; 1830 return;
1845 } 1831 }
1846 1832
1847 if (spell_skill->level < spell->level) 1833 if (spell_skill->level < spell->level)
1848 { 1834 {
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); 1835 op->failmsg (format ("You need to be level %d in %s to learn this spell.", spell->level, &spell->skill));
1850 return; 1836 return;
1851 } 1837 }
1852 } 1838 }
1853 1839
1854 /* Logic as follows 1840 /* Logic as follows
1863 * Overall, chances are the same but a player will find having a high 1849 * Overall, chances are the same but a player will find having a high
1864 * literacy rate very useful! -b.t. 1850 * literacy rate very useful! -b.t.
1865 */ 1851 */
1866 if (QUERY_FLAG (op, FLAG_CONFUSED)) 1852 if (QUERY_FLAG (op, FLAG_CONFUSED))
1867 { 1853 {
1868 new_draw_info (NDI_UNIQUE, 0, op, "In your confused state you flub the wording of the text!"); 1854 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)); 1855 scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), MAX (spell->stats.sp, spell->stats.grace));
1870 } 1856 }
1871 else if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || 1857 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]) 1858 (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int])
1873 { 1859 {
1874 1860 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); 1861 do_learn_spell (op, spell, 0);
1877 1862
1878 /* xp gain to literacy for spell learning */ 1863 /* xp gain to literacy for spell learning */
1879 if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) 1864 if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP))
1880 change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); 1865 change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0);
1881 } 1866 }
1882 else 1867 else
1883 { 1868 {
1884 op->contr->play_sound (sound_find ("fumble_spell")); 1869 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"); 1870 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 } 1871 }
1887 1872
1888 decrease_ob (tmp); 1873 tmp->decrease ();
1889} 1874}
1890 1875
1891/** 1876/**
1892 * Handles applying a spell scroll. 1877 * Handles applying a spell scroll.
1893 */ 1878 */
1896{ 1881{
1897 object *skop; 1882 object *skop;
1898 1883
1899 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) 1884 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ))
1900 { 1885 {
1901 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); 1886 op->failmsg ("You are unable to read while blind.");
1902 return; 1887 return;
1903 } 1888 }
1904 1889
1905 if (!tmp->inv || tmp->inv->type != SPELL) 1890 if (!tmp->inv || tmp->inv->type != SPELL)
1906 { 1891 {
1907 new_draw_info (NDI_UNIQUE, 0, op, "The scroll just doesn't make sense! H<...and never will make sense.>"); 1892 op->failmsg ("The scroll just doesn't make sense! H<...and never will make sense.>");
1908 return; 1893 return;
1909 } 1894 }
1910 1895
1911 if (op->type == PLAYER) 1896 if (op->type == PLAYER)
1912 { 1897 {
1918 */ 1903 */
1919 skop = find_skill_by_name (op, skill_names[SK_LITERACY]); 1904 skop = find_skill_by_name (op, skill_names[SK_LITERACY]);
1920 1905
1921 if (!skop) 1906 if (!skop)
1922 { 1907 {
1923 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<You lack the literacy skill.>"); 1908 op->failmsg (format ("You are unable to decipher the strange symbols. H<You lack the %s skill.>", &skill_names[SK_LITERACY]));
1924 return; 1909 return;
1925 } 1910 }
1926 1911
1927 if ((exp_gain = calc_skill_exp (op, tmp, skop))) 1912 if ((exp_gain = calc_skill_exp (op, tmp, skop)))
1928 change_exp (op, exp_gain, skop->skill, 0); 1913 change_exp (op, exp_gain, skop->skill, 0);
1929 } 1914 }
1930 1915
1931 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 1916 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED))
1932 identify (tmp); 1917 identify (tmp);
1933 1918
1934 new_draw_info_format (NDI_BLACK, 0, op, "The scroll of %s turns to dust.", &tmp->inv->name); 1919 op->statusmsg (format ("The scroll of %s turns to dust.", &tmp->inv->name));
1935 1920
1936 cast_spell (op, tmp, dir, tmp->inv, NULL); 1921 cast_spell (op, tmp, dir, tmp->inv, NULL);
1937 decrease_ob (tmp); 1922 tmp->decrease ();
1938} 1923}
1939 1924
1940/** 1925/**
1941 * Applies a treasure object - by default, chest. op 1926 * Applies a treasure object - by default, chest. op
1942 * is the person doing the applying, tmp is the treasure 1927 * is the person doing the applying, tmp is the treasure
1943 * chest. 1928 * chest.
1944 */ 1929 */
1945static void 1930static void
1946apply_treasure (object *op, object *tmp) 1931apply_treasure (object *op, object *tmp)
1947{ 1932{
1948 /* Nice side effect of new treasure creation method is that the treasure 1933 /* 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 1934 * 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 1935 * 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 1936 * prevents people from moving chests to more difficult maps to get better
1952 * treasure 1937 * treasure
1953 */ 1938 */
1954 object *treas = tmp->inv; 1939 object *treas = tmp->inv;
1955 1940
1956 if (!treas) 1941 if (!treas)
1957 { 1942 {
1958 new_draw_info (NDI_UNIQUE, 0, op, "The chest was empty."); 1943 op->statusmsg ("The chest was empty.");
1959 decrease_ob (tmp); 1944 tmp->decrease ();
1960 return; 1945 return;
1961 } 1946 }
1962 1947
1963 while (tmp->inv) 1948 while (tmp->inv)
1964 { 1949 {
1965 treas = tmp->inv; 1950 treas = tmp->inv;
1966
1967 treas->remove (); 1951 treas->remove ();
1968 new_draw_info_format (NDI_UNIQUE, 0, op, "You find %s in the chest.", query_name (treas));
1969 1952
1970 treas->x = op->x; 1953 treas->x = op->x;
1971 treas->y = op->y; 1954 treas->y = op->y;
1972 treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); 1955 treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR);
1973 1956
1974 if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) 1957 if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE))
1975 spring_trap (treas, op); 1958 spring_trap (treas, op);
1976 1959
1977 /* If either player or container was destroyed, no need to do 1960 /* If either player or container was destroyed, no need to do
1978 * further processing. I think this should be enclused with 1961 * further processing. I think this should be enclused with
1979 * spring trap above, as I don't think there is otherwise 1962 * spring trap above, as I don't think there is otherwise
1980 * any way for the treasure chest or player to get killed 1963 * any way for the treasure chest or player to get killed.
1981 */ 1964 */
1982 if (op->destroyed () || tmp->destroyed ()) 1965 if (op->destroyed () || tmp->destroyed ())
1983 break; 1966 break;
1984 } 1967 }
1985 1968
1986 if (!tmp->destroyed () && tmp->inv == NULL) 1969 if (!tmp->destroyed () && !tmp->inv)
1987 decrease_ob (tmp); 1970 tmp->decrease ();
1988
1989} 1971}
1990 1972
1991/** 1973/**
1992 * op eats food. 1974 * op eats food.
1993 * If player, takes care of messages and dragon special food. 1975 * If player, takes care of messages and dragon special food.
2008 { 1990 {
2009 /* usual case - no dragon meal: */ 1991 /* usual case - no dragon meal: */
2010 if (op->stats.food + tmp->stats.food > 999) 1992 if (op->stats.food + tmp->stats.food > 999)
2011 { 1993 {
2012 if (tmp->type == FOOD || tmp->type == FLESH) 1994 if (tmp->type == FOOD || tmp->type == FLESH)
2013 new_draw_info (NDI_UNIQUE, 0, op, "You feel full, but what a waste of food!"); 1995 op->failmsg ("You feel full, but what a waste of food!");
2014 else 1996 else
2015 new_draw_info (NDI_UNIQUE, 0, op, "Most of the drink goes down your face not your throat!"); 1997 op->statusmsg ("Most of the drink goes down your face not your throat!");
2016 } 1998 }
1999
2000 tmp->play_sound (
2001 tmp->sound
2002 ? tmp->sound
2003 : tmp->type == DRINK
2004 ? sound_find ("eat_drink")
2005 : sound_find ("eat_food")
2006 );
2017 2007
2018 if (!QUERY_FLAG (tmp, FLAG_CURSED)) 2008 if (!QUERY_FLAG (tmp, FLAG_CURSED))
2019 { 2009 {
2020 char buf[MAX_BUF]; 2010 const char *buf;
2021 2011
2022 if (!is_dragon_pl (op)) 2012 if (!is_dragon_pl (op))
2023 { 2013 {
2024 /* eating message for normal players */ 2014 /* eating message for normal players */
2025 if (tmp->type == DRINK) 2015 if (tmp->type == DRINK)
2026 sprintf (buf, "Ahhh...that %s tasted good.", &tmp->name); 2016 buf = format ("Ahhh...that %s tasted good.", &tmp->name);
2027 else 2017 else
2028 sprintf (buf, "The %s tasted %s", &tmp->name, tmp->type == FLESH ? "terrible!" : "good."); 2018 buf = format ("The %s tasted %s", &tmp->name, tmp->type == FLESH ? "terrible!" : "good.");
2029 } 2019 }
2030 else 2020 else
2031 {
2032 /* eating message for dragon players */ 2021 /* eating message for dragon players */
2033 sprintf (buf, "The %s tasted terrible!", &tmp->name); 2022 buf = format ("The %s tasted terrible!", &tmp->name);
2034 }
2035 2023
2036 new_draw_info (NDI_UNIQUE, 0, op, buf); 2024 op->statusmsg (buf);
2025
2037 capacity_remaining = 999 - op->stats.food; 2026 capacity_remaining = 999 - op->stats.food;
2038 op->stats.food += tmp->stats.food; 2027 op->stats.food += tmp->stats.food;
2039 if (capacity_remaining < tmp->stats.food) 2028 if (capacity_remaining < tmp->stats.food)
2040 op->stats.hp += capacity_remaining / 50; 2029 op->stats.hp += capacity_remaining / 50;
2041 else 2030 else
2042 op->stats.hp += tmp->stats.food / 50; 2031 op->stats.hp += tmp->stats.food / 50;
2032
2043 if (op->stats.hp > op->stats.maxhp) 2033 if (op->stats.hp > op->stats.maxhp)
2044 op->stats.hp = op->stats.maxhp; 2034 op->stats.hp = op->stats.maxhp;
2045 if (op->stats.food > 999) 2035 if (op->stats.food > 999)
2046 op->stats.food = 999; 2036 op->stats.food = 999;
2047 } 2037 }
2051 eat_special_food (op, tmp); 2041 eat_special_food (op, tmp);
2052 } 2042 }
2053 } 2043 }
2054 2044
2055 handle_apply_yield (tmp); 2045 handle_apply_yield (tmp);
2056 decrease_ob (tmp); 2046 tmp->decrease ();
2057} 2047}
2058 2048
2059/** 2049/**
2060 * A dragon is eating some flesh. If the flesh contains resistances, 2050 * A dragon is eating some flesh. If the flesh contains resistances,
2061 * there is a chance for the dragon's skin to get improved. 2051 * there is a chance for the dragon's skin to get improved.
2071{ 2061{
2072 object *skin = NULL; /* pointer to dragon skin force */ 2062 object *skin = NULL; /* pointer to dragon skin force */
2073 object *abil = NULL; /* pointer to dragon ability force */ 2063 object *abil = NULL; /* pointer to dragon ability force */
2074 object *tmp = NULL; /* tmp. object */ 2064 object *tmp = NULL; /* tmp. object */
2075 2065
2076 char buf[MAX_BUF]; /* tmp. string buffer */
2077 double chance; /* improvement-chance of one resistance type */ 2066 double chance; /* improvement-chance of one resistance type */
2078 double totalchance = 1; /* total chance of gaining one resistance */ 2067 double totalchance = 1; /* total chance of gaining one resistance */
2079 double bonus = 0; /* level bonus (improvement is easier at lowlevel) */ 2068 double bonus = 0; /* level bonus (improvement is easier at lowlevel) */
2080 double mbonus = 0; /* monster bonus */ 2069 double mbonus = 0; /* monster bonus */
2081 int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */ 2070 int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */
2103 /* now start by filling stomache and health, according to food-value */ 2092 /* now start by filling stomache and health, according to food-value */
2104 if ((999 - op->stats.food) < meal->stats.food) 2093 if ((999 - op->stats.food) < meal->stats.food)
2105 op->stats.hp += (999 - op->stats.food) / 50; 2094 op->stats.hp += (999 - op->stats.food) / 50;
2106 else 2095 else
2107 op->stats.hp += meal->stats.food / 50; 2096 op->stats.hp += meal->stats.food / 50;
2097
2108 if (op->stats.hp > op->stats.maxhp) 2098 if (op->stats.hp > op->stats.maxhp)
2109 op->stats.hp = op->stats.maxhp; 2099 op->stats.hp = op->stats.maxhp;
2110 2100
2111 op->stats.food = MIN (999, op->stats.food + meal->stats.food); 2101 op->stats.food = MIN (999, op->stats.food + meal->stats.food);
2112 2102
2157 } 2147 }
2158 } 2148 }
2159 2149
2160 /* inverse totalchance as until now we have the failure-chance */ 2150 /* inverse totalchance as until now we have the failure-chance */
2161 totalchance = 100 - totalchance * 100; 2151 totalchance = 100 - totalchance * 100;
2152
2162 /* print message according to totalchance */ 2153 /* print message according to totalchance */
2154 const char *buf;
2163 if (totalchance > 50.) 2155 if (totalchance > 50.)
2164 sprintf (buf, "Hmm! The %s tasted delicious!", &meal->name); 2156 buf = format ("Hmm! The %s tasted delicious!", &meal->name);
2165 else if (totalchance > 10.) 2157 else if (totalchance > 10.)
2166 sprintf (buf, "The %s tasted very good.", &meal->name); 2158 buf = format ("The %s tasted very good.", &meal->name);
2167 else if (totalchance > 1.) 2159 else if (totalchance > 1.)
2168 sprintf (buf, "The %s tasted good.", &meal->name); 2160 buf = format ("The %s tasted good.", &meal->name);
2169 else if (totalchance > 0.1) 2161 else if (totalchance > 0.1)
2170 sprintf (buf, "The %s tasted bland.", &meal->name); 2162 buf = format ("The %s tasted bland.", &meal->name);
2171 else if (totalchance >= 0.01) 2163 else if (totalchance >= 0.01)
2172 sprintf (buf, "The %s had a boring taste.", &meal->name); 2164 buf = format ("The %s had a boring taste.", &meal->name);
2173 else if (meal->last_eat > 0 && atnr_is_dragon_enabled (meal->last_eat)) 2165 else if (meal->last_eat > 0 && atnr_is_dragon_enabled (meal->last_eat))
2174 sprintf (buf, "The %s tasted strange.", &meal->name); 2166 buf = format ("The %s tasted strange.", &meal->name);
2175 else 2167 else
2176 sprintf (buf, "The %s had no taste.", &meal->name); 2168 buf = format ("The %s had no taste.", &meal->name);
2177 new_draw_info (NDI_UNIQUE, 0, op, buf); 2169
2170 op->statusmsg (buf);
2178 2171
2179 /* now choose a winner if we have any */ 2172 /* now choose a winner if we have any */
2180 i = -1; 2173 i = -1;
2181 if (winners > 0) 2174 if (winners > 0)
2182 i = atnr_winner[RANDOM () % winners]; 2175 i = atnr_winner[RANDOM () % winners];
2185 { 2178 {
2186 /* resistance increased! */ 2179 /* resistance increased! */
2187 skin->resist[i]++; 2180 skin->resist[i]++;
2188 op->update_stats (); 2181 op->update_stats ();
2189 2182
2190 sprintf (buf, "Your skin is now more resistant to %s!", change_resist_msg[i]); 2183 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 } 2184 }
2193 2185
2194 /* if this flesh contains a new ability focus, we mark it 2186 /* if this flesh contains a new ability focus, we mark it
2195 into the ability_force and it will take effect on next level */ 2187 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) 2188 if (meal->last_eat > 0 && atnr_is_dragon_enabled (meal->last_eat) && meal->last_eat != abil->last_eat)
2197 { 2189 {
2198 abil->last_eat = meal->last_eat; /* write: last_eat <new attnr focus> */ 2190 abil->last_eat = meal->last_eat; /* write: last_eat <new attnr focus> */
2199 2191
2200 if (meal->last_eat != abil->stats.exp) 2192 if (meal->last_eat != abil->stats.exp)
2193 op->statusmsg (format (
2194 "Your metabolism prepares to focus on %s!\n"
2195 "The change will happen at level %d.",
2196 change_resist_msg[meal->last_eat],
2197 abil->level + 1
2201 { 2198 ));
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 2199 else
2208 { 2200 {
2209 sprintf (buf, "Your metabolism will continue to focus on %s.", change_resist_msg[meal->last_eat]); 2201 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; 2202 abil->last_eat = 0;
2212 } 2203 }
2213 } 2204 }
2205
2214 return 1; 2206 return 1;
2215} 2207}
2216 2208
2217/** 2209/**
2218 * Handles applying an improve armor scroll. 2210 * Handles applying an improve armor scroll.
2223{ 2215{
2224 object *armor; 2216 object *armor;
2225 2217
2226 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) 2218 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC))
2227 { 2219 {
2228 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll. H<The area prevents magic effects.>"); 2220 op->failmsg ("Something blocks the magic of the scroll. H<This area prevents magic effects.>");
2229 return; 2221 return;
2230 } 2222 }
2231 2223
2232 armor = find_marked_object (op); 2224 armor = find_marked_object (op);
2233 2225
2234 if (!armor) 2226 if (!armor)
2235 { 2227 {
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."); 2228 op->failmsg ("You need to mark an armor object. Use the right mouse button popup or the mark command to do this.");
2237 return; 2229 return;
2238 } 2230 }
2239 2231
2240 if (armor->type != ARMOUR 2232 if (armor->type != ARMOUR
2241 && armor->type != CLOAK 2233 && armor->type != CLOAK
2242 && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) 2234 && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET)
2243 { 2235 {
2244 new_draw_info (NDI_UNIQUE, 0, op, "Your marked item is not armour!\n"); 2236 op->failmsg ("Your marked item is not armour!\n");
2245 return; 2237 return;
2246 } 2238 }
2247 2239
2248 new_draw_info (NDI_UNIQUE, 0, op, "Applying armour enchantment."); 2240 op->statusmsg ("Applying armour enchantment.");
2249 improve_armour (op, tmp, armor); 2241 improve_armour (op, tmp, armor);
2250} 2242}
2251 2243
2252extern void 2244void
2253apply_poison (object *op, object *tmp) 2245apply_poison (object *op, object *tmp)
2254{ 2246{
2247 // need to do it now when it is still on the map
2248 handle_apply_yield (tmp);
2249
2250 object *poison = tmp->split (1);
2251
2255 if (op->type == PLAYER) 2252 if (op->type == PLAYER)
2256 { 2253 {
2257 op->contr->play_sound (sound_find ("drink_poison")); 2254 op->contr->play_sound (sound_find ("drink_poison"));
2258 new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!"); 2255 op->failmsg ("Yech! That tasted poisonous!");
2259 strcpy (op->contr->killer, "poisonous booze"); 2256 op->contr->killer = poison;
2260 } 2257 }
2261 2258
2262 if (tmp->stats.hp > 0) 2259 if (poison->stats.hp > 0)
2263 { 2260 {
2264 LOG (llevDebug, "Trying to poison player/monster for %d hp\n", tmp->stats.hp); 2261 LOG (llevDebug, "Trying to poison player/monster for %d hp\n", poison->stats.hp);
2265 hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); 2262 hit_player (op, poison->stats.hp, tmp, AT_POISON, 1);
2266 } 2263 }
2267 2264
2268 op->stats.food -= op->stats.food / 4; 2265 op->stats.food -= op->stats.food / 4;
2269 handle_apply_yield (tmp); 2266 poison->destroy ();
2270 decrease_ob (tmp);
2271} 2267}
2272 2268
2273/** 2269/**
2274 * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit. 2270 * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit.
2275 * A valid 2 way exit means: 2271 * A valid 2 way exit means:
2290 2286
2291#if 0 //TODO 2287#if 0 //TODO
2292 if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) 2288 if (!has_been_loaded (EXIT_PATH (exit)) && exit->race)
2293 return 0; /* This is a reset town portal */ 2289 return 0; /* This is a reset town portal */
2294#endif 2290#endif
2291
2292 LOG (llevError | logBacktrace, "sync map load due to %s\n", exit->debug_desc ());
2295 2293
2296 maptile *exitmap = maptile::find_sync (EXIT_PATH (exit), exit->map); 2294 maptile *exitmap = maptile::find_sync (EXIT_PATH (exit), exit->map);
2297 2295
2298 if (exitmap) 2296 if (exitmap)
2299 { 2297 {
2375 * them in this function - they are passed to apply_special 2373 * them in this function - they are passed to apply_special
2376 */ 2374 */
2377int 2375int
2378manual_apply (object *op, object *tmp, int aflag) 2376manual_apply (object *op, object *tmp, int aflag)
2379{ 2377{
2380 if (tmp->head)
2381 tmp = tmp->head; 2378 tmp = tmp->head_ ();
2382 2379
2383 if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) 2380 if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED))
2384 { 2381 {
2385 if (op->type == PLAYER) 2382 if (op->type == PLAYER)
2386 { 2383 {
2387 new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first. H<You cannot use items marked as unpaid.>"); 2384 op->failmsg ("You should pay for it first! H<You cannot use items marked as unpaid.>");
2388 return 1; 2385 return 1;
2389 } 2386 }
2390 else 2387 else
2391 return 0; /* monsters just skip unpaid items */ 2388 return 0; /* monsters just skip unpaid items */
2392 } 2389 }
2395 return RESULT_INT (0); 2392 return RESULT_INT (0);
2396 2393
2397 switch (tmp->type) 2394 switch (tmp->type)
2398 { 2395 {
2399 case CF_HANDLE: 2396 case CF_HANDLE:
2400 new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle.");
2401 op->play_sound (sound_find ("turn_handle")); 2397 op->play_sound (sound_find ("turn_handle"));
2398 op->statusmsg ("You turn the handle.");
2402 tmp->value = tmp->value ? 0 : 1; 2399 tmp->value = tmp->value ? 0 : 1;
2403 SET_ANIMATION (tmp, tmp->value); 2400 SET_ANIMATION (tmp, tmp->value);
2404 update_object (tmp, UP_OBJ_FACE); 2401 update_object (tmp, UP_OBJ_FACE);
2405 push_button (tmp); 2402 push_button (tmp);
2406 return 1; 2403 return 1;
2407 2404
2408 case TRIGGER: 2405 case TRIGGER:
2409 if (check_trigger (tmp, op)) 2406 if (check_trigger (tmp, op))
2410 { 2407 {
2411 new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); 2408 op->statusmsg ("You turn the handle.");
2412 op->play_sound (sound_find ("turn_handle")); 2409 op->play_sound (sound_find ("turn_handle"));
2413 } 2410 }
2414 else 2411 else
2415 new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); 2412 op->failmsg ("The handle doesn't move.");
2416 2413
2417 return 1; 2414 return 1;
2418 2415
2419 case EXIT: 2416 case EXIT:
2420 if (op->type != PLAYER) 2417 if (op->type != PLAYER)
2421 return 0; 2418 return 0;
2422 2419
2423 if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp)) 2420 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)); 2421 op->failmsg (format ("The %s is closed.", query_name (tmp)));
2425 else 2422 else
2426 { 2423 {
2427 /* Don't display messages for random maps. */ 2424 /* Don't display messages for random maps. */
2428 if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2)) 2425 if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2))
2429 new_draw_info (NDI_NAVY, 0, op, tmp->msg); 2426 op->statusmsg (tmp->msg, NDI_NAVY);
2430 2427
2431 op->enter_exit (tmp); 2428 op->enter_exit (tmp);
2432 } 2429 }
2433 2430
2434 return 1; 2431 return 1;
2435 2432
2436 case INSCRIBABLE: 2433 case INSCRIBABLE:
2437 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); 2434 op->statusmsg (tmp->msg);
2438 // maybe show a spell menu to chose from or something like that 2435 // maybe show a spell menu to chose from or something like that
2439 return 1; 2436 return 1;
2440 2437
2441 case SIGN: 2438 case SIGN:
2442 apply_sign (op, tmp, 0); 2439 apply_sign (op, tmp, 0);
2552 { 2549 {
2553 char buf[MAX_BUF]; 2550 char buf[MAX_BUF];
2554 timeofday_t tod; 2551 timeofday_t tod;
2555 2552
2556 get_tod (&tod); 2553 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")); 2554 op->play_sound (sound_find ("sound_clock"));
2561 new_draw_info (NDI_UNIQUE, 0, op, buf); 2555 op->statusmsg (format (
2556 "It is %d minute%s past %d o'clock %s",
2557 tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"),
2558 ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am")
2559 ));
2562 return 1; 2560 return 1;
2563 } 2561 }
2564 else 2562 else
2565 return 0; 2563 return 0;
2566 2564
2593 default: 2591 default:
2594 return 0; 2592 return 0;
2595 } 2593 }
2596} 2594}
2597 2595
2598
2599/* quiet suppresses the "don't know how to apply" and "you must get it first" 2596/* quiet suppresses the "don't know how to apply" and "you must get it first"
2600 * messages as needed by player_apply_below(). But there can still be 2597 * messages as needed by player_apply_below(). But there can still be
2601 * "but you are floating high above the ground" messages. 2598 * "but you are floating high above the ground" messages.
2602 * 2599 *
2603 * Same return value as apply() function. 2600 * Same return value as apply() function.
2604 */ 2601 */
2605int 2602int
2606player_apply (object *pl, object *op, int aflag, int quiet) 2603player_apply (object *pl, object *op, int aflag, int quiet)
2607{ 2604{
2608 int tmp;
2609
2610 if (op->env && (pl->move_type & MOVE_FLYING)) 2605 if (!op->env && (pl->move_type & MOVE_FLYING))
2611 { 2606 {
2612 /* player is flying and applying object not in inventory */ 2607 /* player is flying and applying object not in inventory */
2613 if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) 2608 if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING))
2614 { 2609 {
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.>"); 2610 pl->failmsg ("But you are floating high above the ground! "
2611 "H<You have to stop levitating first, if you can, either by using your levitation skill, "
2612 "or waiting till the levitation effect wears off.>");
2616 return 0; 2613 return 0;
2617 } 2614 }
2618 } 2615 }
2619 2616
2620 pl->contr->last_used = op; 2617 pl->contr->last_used = op;
2621 2618
2622 tmp = manual_apply (pl, op, aflag); 2619 int tmp = manual_apply (pl, op, aflag);
2620
2623 if (!quiet) 2621 if (!quiet)
2624 { 2622 {
2625 if (tmp == 0) 2623 if (tmp == 0)
2626 new_draw_info_format (NDI_UNIQUE, 0, pl, "I don't know how to apply the %s.", query_name (op)); 2624 pl->statusmsg (format ("I don't know how to apply the %s.", query_name (op)));
2627 else if (tmp == 2) 2625 else if (tmp == 2)
2628 new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n"); 2626 pl->failmsg ("You must get it first!\n");
2629 } 2627 }
2630 2628
2631 return tmp; 2629 return tmp;
2632} 2630}
2633 2631
2710 { 2708 {
2711 pl->combat_ob = 0; 2709 pl->combat_ob = 0;
2712 who->change_weapon (pl->ranged_ob); 2710 who->change_weapon (pl->ranged_ob);
2713 } 2711 }
2714 2712
2715 new_draw_info_format (NDI_UNIQUE, 0, who, "You unwield %s.", query_name (op)); 2713 who->statusmsg (format ("You unwield %s.", query_name (op)));
2716 2714
2717 change_abil (who, op); 2715 change_abil (who, op);
2718 CLEAR_FLAG (who, FLAG_READY_WEAPON); 2716 CLEAR_FLAG (who, FLAG_READY_WEAPON);
2719 break; 2717 break;
2720 2718
2721 case SKILL: 2719 case SKILL:
2722 if (who->contr) 2720 if (who->contr)
2723 { 2721 {
2722 if (IS_COMBAT_SKILL (op->subtype))
2723 who->change_weapon (who->contr->combat_ob = 0);
2724 else if (IS_RANGED_SKILL (op->subtype))
2725 who->change_weapon (who->contr->ranged_ob = 0);
2726
2724 if (!op->invisible) 2727 if (op->invisible)
2725 new_draw_info_format (NDI_UNIQUE, 0, who, "You stop using the %s.", query_name (op)); 2728 who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill));
2726 else 2729 else
2727 new_draw_info_format (NDI_UNIQUE, 0, who, "You can no longer use the skill: %s.", &op->skill); 2730 who->statusmsg (format ("You stop using the %s.", query_name (op)));
2728 } 2731 }
2729 2732
2730 change_abil (who, op); 2733 change_abil (who, op);
2731 CLEAR_FLAG (who, FLAG_READY_SKILL); 2734 CLEAR_FLAG (who, FLAG_READY_SKILL);
2732 break; 2735 break;
2739 case GLOVES: 2742 case GLOVES:
2740 case AMULET: 2743 case AMULET:
2741 case GIRDLE: 2744 case GIRDLE:
2742 case BRACERS: 2745 case BRACERS:
2743 case CLOAK: 2746 case CLOAK:
2744 new_draw_info_format (NDI_UNIQUE, 0, who, "You unwear %s.", query_name (op)); 2747 who->statusmsg (format ("You unwear %s.", query_name (op)));
2745 change_abil (who, op); 2748 change_abil (who, op);
2746 break; 2749 break;
2747 2750
2748 case LAMP: 2751 case LAMP:
2749 { 2752 {
2750 new_draw_info_format (NDI_UNIQUE, 0, who, "You turn off your %s.", &op->name); 2753 who->statusmsg (format ("You turn off your %s.", &op->name));
2751 2754
2752 object *tmp2 = arch_to_object (op->other_arch); 2755 object *tmp2 = arch_to_object (op->other_arch);
2753 tmp2->x = op->x; 2756 tmp2->x = op->x;
2754 tmp2->y = op->y; 2757 tmp2->y = op->y;
2755 tmp2->map = op->map; 2758 tmp2->map = op->map;
2759 CLEAR_FLAG (tmp2, FLAG_APPLIED); 2762 CLEAR_FLAG (tmp2, FLAG_APPLIED);
2760 2763
2761 if (QUERY_FLAG (op, FLAG_INV_LOCKED)) 2764 if (QUERY_FLAG (op, FLAG_INV_LOCKED))
2762 SET_FLAG (tmp2, FLAG_INV_LOCKED); 2765 SET_FLAG (tmp2, FLAG_INV_LOCKED);
2763 2766
2767 op->destroy ();
2768 who->insert (tmp2);
2769 who->update_stats ();
2770
2764 if (who->contr) 2771 if (who->contr)
2765 esrv_del_item (who->contr, op->count);
2766
2767 op->destroy ();
2768 insert_ob_in_ob (tmp2, who);
2769 who->update_stats ();
2770
2771 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))
2772 { 2772 {
2773 if (who->contr) 2773 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))
2774 { 2774 {
2775 new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); 2775 who->failmsg ("Oops, it feels deadly cold!");
2776 SET_FLAG (tmp2, FLAG_KNOWN_CURSED); 2776 SET_FLAG (tmp2, FLAG_KNOWN_CURSED);
2777 } 2777 }
2778 } 2778 }
2779
2780 if (who->contr)
2781 esrv_send_item (who, tmp2);
2782 } 2779 }
2783 2780
2784 return 1; /* otherwise, an attempt to drop causes problems */ 2781 return 1; /* otherwise, an attempt to drop causes problems */
2785 2782
2786 case BOW: 2783 case BOW:
2793 { 2790 {
2794 pl->ranged_ob = 0; 2791 pl->ranged_ob = 0;
2795 who->change_weapon (pl->combat_ob); 2792 who->change_weapon (pl->combat_ob);
2796 } 2793 }
2797 2794
2798 new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); 2795 who->statusmsg (format ("You unready %s.", query_name (op)));
2799 } 2796 }
2800 else 2797 else
2801 { 2798 {
2802 who->change_skill (0); 2799 who->change_skill (0);
2803 2800
2809 2806
2810 break; 2807 break;
2811 2808
2812 case BUILDER: 2809 case BUILDER:
2813 if (who->contr) 2810 if (who->contr)
2814 new_draw_info_format (NDI_UNIQUE, 0, who, "You unready %s.", query_name (op)); 2811 who->statusmsg (format ("You unready %s.", query_name (op)));
2815 break; 2812 break;
2816 2813
2817 default: 2814 default:
2818 new_draw_info_format (NDI_UNIQUE, 0, who, "You unapply %s.", query_name (op)); 2815 who->statusmsg (format ("You unapply %s.", query_name (op)));
2819 break; 2816 break;
2820 } 2817 }
2821 2818
2819 if (aflags & AP_NO_MERGE || !merge_ob (op, 0))
2820 if (object *pl = op->visible_to ())
2821 esrv_send_item (pl, op);
2822
2822 who->update_stats (); 2823 who->update_stats ();
2823
2824 if (!(aflags & AP_NO_MERGE))
2825 {
2826 object *tmp = merge_ob (op, 0);
2827
2828 if (who->contr)
2829 {
2830 if (tmp)
2831 { /* it was merged */
2832 esrv_del_item (who->contr, op->count);
2833 op = tmp;
2834 }
2835
2836 esrv_send_item (who, op);
2837 }
2838 }
2839 2824
2840 return 0; 2825 return 0;
2841} 2826}
2842 2827
2843/** 2828/**
2890 for (object *tmp = who->inv; tmp; tmp = tmp->below) 2875 for (object *tmp = who->inv; tmp; tmp = tmp->below)
2891 if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->is_range ()) 2876 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))) 2877 if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)))
2893 { 2878 {
2894 if (aflags & AP_PRINT) 2879 if (aflags & AP_PRINT)
2895 new_draw_info (NDI_UNIQUE, 0, who, query_name (tmp)); 2880 who->failmsg (query_name (tmp));
2896 else 2881 else
2897 unapply_special (who, tmp, aflags); 2882 unapply_special (who, tmp, aflags);
2898 } 2883 }
2899 else 2884 else
2900 { 2885 {
2901 /* In this case, we want to try and remove a cursed item. 2886 /* 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 2887 * While we know it won't work, we want unapply_special to
2903 * at least generate the message. 2888 * at least generate the message.
2904 */ 2889 */
2905 new_draw_info_format (NDI_UNIQUE, 0, who, 2890 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; 2891 return 1;
2909 } 2892 }
2910 2893
2911 for (int i = 0; i < NUM_BODY_LOCATIONS; i++) 2894 for (int i = 0; i < NUM_BODY_LOCATIONS; i++)
2912 { 2895 {
2935 2918
2936 /* If we are just printing, we don't care about cursed status */ 2919 /* 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)))) 2920 if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!(QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))))
2938 { 2921 {
2939 if (aflags & AP_PRINT) 2922 if (aflags & AP_PRINT)
2940 new_draw_info (NDI_UNIQUE, 0, who, query_name (tmp)); 2923 who->failmsg (query_name (tmp));
2941 else 2924 else
2942 unapply_special (who, tmp, aflags); 2925 unapply_special (who, tmp, aflags);
2943 } 2926 }
2944 else 2927 else
2945 { 2928 {
2946 /* Cursed item that we can't unequip - tell the player. 2929 /* Cursed item that we can't unequip - tell the player.
2947 * Note this could be annoying if this is just one of a few, 2930 * 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 2931 * so it may not be critical (eg, putting on a ring and you have
2949 * one cursed ring.) 2932 * one cursed ring.)
2950 */ 2933 */
2951 new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp)); 2934 who->failmsg (format ("The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp)));
2952 } 2935 }
2953 2936
2954 last = tmp->below; 2937 last = tmp->below;
2955 } 2938 }
2956 /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the 2939 /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the
3137 if (basic_flag == AP_APPLY) 3120 if (basic_flag == AP_APPLY)
3138 return 0; 3121 return 0;
3139 3122
3140 if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) 3123 if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)))
3141 { 3124 {
3142 new_draw_info_format (NDI_UNIQUE, 0, who, 3125 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; 3126 return 1;
3146 } 3127 }
3147 3128
3148 return unapply_special (who, op, aflags); 3129 return unapply_special (who, op, aflags);
3149 } 3130 }
3150
3151 if (basic_flag == AP_UNAPPLY) 3131 else if (basic_flag == AP_UNAPPLY)
3152 return 0; 3132 return 0;
3153 3133
3154 // if the item is combat/ranged, wield the relevant slot first 3134 // if the item is combat/ranged, wield the relevant slot first
3155 // to resolve conflicts. 3135 // to resolve conflicts.
3156 if (player *pl = who->contr) 3136 if (player *pl = who->contr)
3165 /* Can't just apply this object. Lets see what not and what to do */ 3145 /* Can't just apply this object. Lets see what not and what to do */
3166 if (int i = can_apply_object (who, op)) 3146 if (int i = can_apply_object (who, op))
3167 { 3147 {
3168 if (i & CAN_APPLY_NEVER) 3148 if (i & CAN_APPLY_NEVER)
3169 { 3149 {
3170 new_draw_info_format (NDI_UNIQUE, 0, who, 3150 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; 3151 return 1;
3174 } 3152 }
3175 else if (i & CAN_APPLY_RESTRICTION) 3153 else if (i & CAN_APPLY_RESTRICTION)
3176 { 3154 {
3177 new_draw_info_format (NDI_UNIQUE, 0, who, 3155 who->failmsg (format (
3178 "You have a prohibition against using a %s. " 3156 "You have a prohibition against using a %s. "
3179 "H<Your belief, profession or class prevents you from applying this item.>", 3157 "H<Your belief, profession or class prevents you from applying this item.>",
3180 query_name (op)); 3158 query_name (op)
3159 ));
3181 return 1; 3160 return 1;
3182 } 3161 }
3183 3162
3184 if (who->type != PLAYER) 3163 if (who->type != PLAYER)
3185 { 3164 {
3189 } 3168 }
3190 else 3169 else
3191 { 3170 {
3192 if (who->contr->unapply == unapply_never || (i & CAN_APPLY_UNAPPLY_CHOICE && who->contr->unapply == unapply_nochoice)) 3171 if (who->contr->unapply == unapply_never || (i & CAN_APPLY_UNAPPLY_CHOICE && who->contr->unapply == unapply_nochoice))
3193 { 3172 {
3194 new_draw_info (NDI_UNIQUE, 0, who, "You need to unapply some of the following item(s) or change your applymode:"); 3173 who->failmsg ("You need to unapply some of the following item(s) or change your applymode:");
3195 unapply_for_ob (who, op, AP_PRINT); 3174 unapply_for_ob (who, op, AP_PRINT);
3196 return 1; 3175 return 1;
3197 } 3176 }
3198 else if (who->contr->unapply == unapply_always || !(i & CAN_APPLY_UNAPPLY_CHOICE)) 3177 else if (who->contr->unapply == unapply_always || !(i & CAN_APPLY_UNAPPLY_CHOICE))
3199 if (unapply_for_ob (who, op, aflags)) 3178 if (unapply_for_ob (who, op, aflags))
3205 { 3184 {
3206 skop = find_skill_by_name (who, op->skill); 3185 skop = find_skill_by_name (who, op->skill);
3207 3186
3208 if (!skop) 3187 if (!skop)
3209 { 3188 {
3210 new_draw_info_format (NDI_UNIQUE, 0, who, "You need the %s skill to use this item!", &op->skill); 3189 who->failmsg (format ("You need the %s skill to use this item!", &op->skill));
3211 return 1; 3190 return 1;
3212 } 3191 }
3213 else 3192 else
3214 /* While experience will be credited properly, we want to change the 3193 /* While experience will be credited properly, we want to change the
3215 * skill so that the dam and wc get updated 3194 * skill so that the dam and wc get updated
3219 3198
3220 if (who->type == PLAYER 3199 if (who->type == PLAYER
3221 && op->item_power 3200 && op->item_power
3222 && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) 3201 && op->item_power + who->contr->item_power > settings.item_power_factor * who->level)
3223 { 3202 {
3224 new_draw_info (NDI_UNIQUE, 0, who,
3225 "Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); 3203 who->failmsg ("Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER);
3226 return 1; 3204 return 1;
3227 } 3205 }
3228 3206
3229 /* Ok. We are now at the state where we can apply the new object. 3207 /* 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_... 3208 * Note that we don't have the checks for can_use_...
3231 * below - that is already taken care of by can_apply_object. 3209 * below - that is already taken care of by can_apply_object.
3232 */ 3210 */
3233 if (op->nrof > 1) 3211 tmp = op->nrof > 1 ? op->split (op->nrof - 1) : 0;
3234 tmp = get_split_ob (op, op->nrof - 1);
3235 else
3236 tmp = 0;
3237 3212
3238 if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) || INVOKE_OBJECT (READY, who, ARG_OBJECT (op))) 3213 if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) || INVOKE_OBJECT (READY, who, ARG_OBJECT (op)))
3239 return RESULT_INT (0); 3214 return RESULT_INT (0);
3240 3215
3241 switch (op->type) 3216 switch (op->type)
3242 { 3217 {
3243 case WEAPON: 3218 case WEAPON:
3244 if (!check_weapon_power (who, op->last_eat)) 3219 if (!check_weapon_power (who, op->last_eat))
3245 { 3220 {
3246 new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " 3221 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 3222
3249 if (tmp) 3223 if (tmp)
3250 insert_ob_in_ob (tmp, who); 3224 insert_ob_in_ob (tmp, who);
3251 3225
3252 return 1; 3226 return 1;
3256 // i.e. "R" can use Ragnarok's sword. 3230 // i.e. "R" can use Ragnarok's sword.
3257 if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) 3231 if (op->level && (strncmp (op->name, who->name, strlen (who->name))))
3258 { 3232 {
3259 /* if the weapon does not have the name as the character, can't use it. */ 3233 /* 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) */ 3234 /* (Ragnarok's sword attempted to be used by Foo: won't work) */
3261 new_draw_info (NDI_UNIQUE, 0, who, 3235 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 3236
3265 if (tmp) 3237 if (tmp)
3266 insert_ob_in_ob (tmp, who); 3238 insert_ob_in_ob (tmp, who);
3267 3239
3268 return 1; 3240 return 1;
3269 } 3241 }
3270 3242
3271 if (!skop) 3243 if (!skop)
3272 { 3244 {
3273 new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO 3245 who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO
3274 return 1; 3246 return 1;
3275 } 3247 }
3276 3248
3277 SET_FLAG (op, FLAG_APPLIED); 3249 SET_FLAG (op, FLAG_APPLIED);
3278 who->change_skill (skop); 3250 who->change_skill (skop);
3279 3251
3280 if (who->contr) 3252 if (who->contr)
3281 who->change_weapon (who->contr->combat_ob = op); 3253 who->change_weapon (who->contr->combat_ob = op);
3282 3254
3283 new_draw_info_format (NDI_UNIQUE, 0, who, "You wield %s.", query_name (op)); 3255 who->statusmsg (format ("You wield %s.", query_name (op)));
3284 3256
3285 SET_FLAG (who, FLAG_READY_WEAPON); 3257 SET_FLAG (who, FLAG_READY_WEAPON);
3286 change_abil (who, op); 3258 change_abil (who, op);
3287 break; 3259 break;
3288 3260
3295 case BRACERS: 3267 case BRACERS:
3296 case CLOAK: 3268 case CLOAK:
3297 case RING: 3269 case RING:
3298 case AMULET: 3270 case AMULET:
3299 SET_FLAG (op, FLAG_APPLIED); 3271 SET_FLAG (op, FLAG_APPLIED);
3300 new_draw_info_format (NDI_UNIQUE, 0, who, "You wear %s.", query_name (op)); 3272 who->statusmsg (format ("You wear %s.", query_name (op)));
3301 change_abil (who, op); 3273 change_abil (who, op);
3302 break; 3274 break;
3303 3275
3304 case LAMP: 3276 case LAMP:
3305 if (op->stats.food < 1) 3277 if (op->stats.food < 1)
3306 { 3278 {
3307 new_draw_info_format (NDI_UNIQUE, 0, who, 3279 who->failmsg (format (
3308 "Your %s is out of fuel! " 3280 "Your %s is out of fuel! "
3309 "H<Lamps and similar items need fuel. They cannot be refilled.>", &op->name); 3281 "H<Lamps and similar items need fuel. They cannot be refilled.>",
3282 &op->name
3283 ));
3310 return 1; 3284 return 1;
3311 } 3285 }
3312 3286
3313 new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); 3287 who->statusmsg (format ("You turn on your %s.", &op->name));
3288
3314 tmp2 = arch_to_object (op->other_arch); 3289 tmp2 = arch_to_object (op->other_arch);
3315 tmp2->stats.food = op->stats.food; 3290 tmp2->stats.food = op->stats.food;
3316 SET_FLAG (tmp2, FLAG_APPLIED); 3291 SET_FLAG (tmp2, FLAG_APPLIED);
3317 3292
3318 if (QUERY_FLAG (op, FLAG_INV_LOCKED)) 3293 if (QUERY_FLAG (op, FLAG_INV_LOCKED))
3319 SET_FLAG (tmp2, FLAG_INV_LOCKED); 3294 SET_FLAG (tmp2, FLAG_INV_LOCKED);
3320 3295
3321 insert_ob_in_ob (tmp2, who); 3296 who->insert (tmp2);
3322 3297
3323 /* Remove the old lantern */ 3298 /* Remove the old lantern */
3324 if (who->type == PLAYER)
3325 esrv_del_item (who->contr, op->count);
3326
3327 op->destroy (); 3299 op->destroy ();
3328 3300
3329 /* insert the portion that was split off */ 3301 /* insert the portion that was split off */
3330 if (tmp) 3302 if (tmp)
3331 { 3303 who->insert (tmp);
3332 insert_ob_in_ob (tmp, who);
3333 if (who->type == PLAYER)
3334 esrv_send_item (who, tmp);
3335 }
3336 3304
3337 who->update_stats (); 3305 who->update_stats ();
3338 3306
3339 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) 3307 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))
3340 if (who->type == PLAYER) 3308 if (who->type == PLAYER)
3341 { 3309 {
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.>"); 3310 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); 3311 SET_FLAG (tmp2, FLAG_KNOWN_CURSED);
3346 } 3312 }
3347
3348 if (who->type == PLAYER)
3349 esrv_send_item (who, tmp2);
3350 3313
3351 return 0; 3314 return 0;
3352 3315
3353 case SKILL_TOOL: 3316 case SKILL_TOOL:
3354 // applying a skill tool also readies the skill 3317 // applying a skill tool also readies the skill
3377 who->change_weapon (pl->combat_ob = item); 3340 who->change_weapon (pl->combat_ob = item);
3378 goto found_weapon; 3341 goto found_weapon;
3379 } 3342 }
3380 } 3343 }
3381 3344
3382 new_draw_info_format (NDI_UNIQUE, 0, who, 3345 who->failmsg (format (
3383 "You need to apply a '%s' melee weapon before readying this skill. " 3346 "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.>", 3347 "H<Some skills need an item, in this case a melee weapon, to function.>",
3385 &op->skill); 3348 &op->skill
3349 ));
3386 return 1; 3350 return 1;
3387 3351
3388 found_weapon:; 3352 found_weapon:;
3389 } 3353 }
3390 else 3354 else
3400 //TODO: bows should/must all have skill missile weapon right now 3364 //TODO: bows should/must all have skill missile weapon right now
3401 who->change_weapon (pl->ranged_ob = item); 3365 who->change_weapon (pl->ranged_ob = item);
3402 goto found_bow; 3366 goto found_bow;
3403 } 3367 }
3404 3368
3405 new_draw_info (NDI_UNIQUE, 0, who, 3369 who->failmsg (
3406 "You need to apply a missile weapon before readying this skill. " 3370 "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.>"); 3371 "H<Some skills need an item, in this case a missile weapon, to function.>"
3372 );
3408 return 1; 3373 return 1;
3409 3374
3410 found_bow:; 3375 found_bow:;
3411 } 3376 }
3412 else 3377 else
3413 who->change_weapon (pl->ranged_ob = op); 3378 who->change_weapon (pl->ranged_ob = op);
3414 } 3379 }
3415 3380
3416 if (!op->invisible) 3381 if (!op->invisible)
3417 { 3382 {
3418 new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); 3383 who->statusmsg (format (
3419 new_draw_info_format (NDI_UNIQUE, 0, who, "You can now use the skill: %s.", &op->skill); 3384 "You ready %s."
3385 "You can now use the skill: %s.",
3386 query_name (op),
3387 &op->skill
3388 ));
3420 } 3389 }
3421 else 3390 else
3422 new_draw_info_format (NDI_UNIQUE, 0, who, "Readied skill: %s.", op->skill ? &op->skill : &op->name); 3391 who->statusmsg (format ("Readied skill: %s.", op->skill ? &op->skill : &op->name));
3423 } 3392 }
3424 else 3393 else
3425 { 3394 {
3426 SET_FLAG (op, FLAG_APPLIED); 3395 SET_FLAG (op, FLAG_APPLIED);
3427 change_abil (who, op); 3396 change_abil (who, op);
3432 break; 3401 break;
3433 3402
3434 case BOW: 3403 case BOW:
3435 if (!check_weapon_power (who, op->last_eat)) 3404 if (!check_weapon_power (who, op->last_eat))
3436 { 3405 {
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); 3406 who->failmsg ("That weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER);
3439 3407
3440 if (tmp) 3408 if (tmp)
3441 insert_ob_in_ob (tmp, who); 3409 insert_ob_in_ob (tmp, who);
3442 3410
3443 return 1; 3411 return 1;
3444 } 3412 }
3445 3413
3446 if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) 3414 if (op->level && (strncmp (op->name, who->name, strlen (who->name))))
3447 { 3415 {
3448 new_draw_info (NDI_UNIQUE, 0, who,
3449 "The weapon does not recognize you as its owner. " 3416 who->failmsg ("The weapon does not recognize you as its owner. "
3450 "H<Its name indicates that it belongs to somebody else.>"); 3417 "H<Its name indicates that it belongs to somebody else.>");
3451 if (tmp) 3418 if (tmp)
3452 insert_ob_in_ob (tmp, who); 3419 insert_ob_in_ob (tmp, who);
3453 3420
3454 return 1; 3421 return 1;
3460 case HORN: 3427 case HORN:
3461 /* check for skill, alter player status */ 3428 /* check for skill, alter player status */
3462 3429
3463 if (!skop) 3430 if (!skop)
3464 { 3431 {
3465 new_draw_info_format (NDI_UNIQUE, 0, who, "The %s is broken, please report this to the dungeon master!", query_name (op));//TODO 3432 who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO
3466 return 1; 3433 return 1;
3467 } 3434 }
3468 3435
3469 SET_FLAG (op, FLAG_APPLIED); 3436 SET_FLAG (op, FLAG_APPLIED);
3470 who->change_skill (skop); 3437 who->change_skill (skop);
3471 3438
3472 if (who->contr) 3439 if (who->contr)
3473 { 3440 {
3474 who->contr->ranged_ob = op; 3441 who->contr->ranged_ob = op;
3475 3442
3476 new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name (op)); 3443 who->statusmsg (format ("You ready %s.", query_name (op)));
3477 3444
3478 if (op->type == BOW) 3445 if (op->type == BOW)
3479 { 3446 {
3480 who->current_weapon = op; 3447 who->current_weapon = op;
3481 change_abil (who, op); 3448 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)); 3449 who->statusmsg (format ("You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op)));
3484 } 3450 }
3485 } 3451 }
3486 else 3452 else
3487 { 3453 {
3488 if (op->type == BOW) 3454 if (op->type == BOW)
3498 { 3464 {
3499 //TODO: wtf does this do? shouldn't this be managed automatically (slots?) 3465 //TODO: wtf does this do? shouldn't this be managed automatically (slots?)
3500 if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) 3466 if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER)
3501 unapply_special (who, who->contr->ranged_ob, 0); 3467 unapply_special (who, who->contr->ranged_ob, 0);
3502 3468
3503 new_draw_info_format (NDI_UNIQUE, 0, who, "You ready your %s.", query_name (op)); 3469 who->statusmsg (format ("You ready your %s.", query_name (op)));
3504 3470
3505 who->contr->ranged_ob = op; 3471 who->contr->ranged_ob = op;
3506 } 3472 }
3507 break; 3473 break;
3508 3474
3509 default: 3475 default:
3510 new_draw_info_format (NDI_UNIQUE, 0, who, "You apply %s.", query_name (op)); 3476 who->statusmsg (format ("You apply %s.", query_name (op)));
3511 } /* end of switch op->type */ 3477 }
3512 3478
3513 SET_FLAG (op, FLAG_APPLIED); 3479 SET_FLAG (op, FLAG_APPLIED);
3514 3480
3515 if (tmp) 3481 if (tmp)
3516 tmp = insert_ob_in_ob (tmp, who); 3482 who->insert (tmp);
3517 3483
3518 who->update_stats (); 3484 who->update_stats ();
3519 3485
3520 /* We exclude spell casting objects. The fire code will set the 3486 /* We exclude spell casting objects. The fire code will set the
3521 * been applied flag when they are used - until that point, 3487 * been applied flag when they are used - until that point,
3525 SET_FLAG (op, FLAG_BEEN_APPLIED); 3491 SET_FLAG (op, FLAG_BEEN_APPLIED);
3526 3492
3527 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) 3493 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))
3528 if (who->type == PLAYER) 3494 if (who->type == PLAYER)
3529 { 3495 {
3530 new_draw_info (NDI_UNIQUE, 0, who, 3496 who->failmsg (
3531 "Oops, it feels deadly cold! " 3497 "Oops, it feels deadly cold! "
3532 "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); 3498 "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"
3499 );
3533 SET_FLAG (op, FLAG_KNOWN_CURSED); 3500 SET_FLAG (op, FLAG_KNOWN_CURSED);
3534 } 3501 }
3535 3502
3536 if (who->type == PLAYER) 3503 if (object *pl = op->visible_to ())
3537 {
3538 /* if multiple objects were applied, update both slots */
3539 if (tmp)
3540 esrv_send_item (who, tmp);
3541
3542 esrv_send_item (who, op); 3504 esrv_send_item (pl, op);
3543 }
3544 3505
3545 return 0; 3506 return 0;
3546} 3507}
3547 3508
3548int 3509int
3562int 3523int
3563auto_apply (object *op) 3524auto_apply (object *op)
3564{ 3525{
3565 object *tmp = NULL, *tmp2; 3526 object *tmp = NULL, *tmp2;
3566 int i; 3527 int i;
3528
3529 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
3567 3530
3568 switch (op->type) 3531 switch (op->type)
3569 { 3532 {
3570 case SHOP_FLOOR: 3533 case SHOP_FLOOR:
3571 if (!op->has_random_items ()) 3534 if (!op->has_random_items ())
3573 3536
3574 do 3537 do
3575 { 3538 {
3576 i = 10; /* let's give it 10 tries */ 3539 i = 10; /* let's give it 10 tries */
3577 while ((tmp = generate_treasure (op->randomitems, 3540 while ((tmp = generate_treasure (op->randomitems,
3578 op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); 3541 op->stats.exp
3542 ? (int) op->stats.exp
3543 : max (op->map->difficulty, 5)))
3544 == NULL && --i);
3545
3579 if (tmp == NULL) 3546 if (tmp == NULL)
3580 return 0; 3547 return 0;
3548
3581 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 3549 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
3582 { 3550 {
3583 tmp->destroy (); 3551 tmp->destroy ();
3584 tmp = NULL; 3552 tmp = NULL;
3585 } 3553 }
3588 3556
3589 tmp->x = op->x; 3557 tmp->x = op->x;
3590 tmp->y = op->y; 3558 tmp->y = op->y;
3591 SET_FLAG (tmp, FLAG_UNPAID); 3559 SET_FLAG (tmp, FLAG_UNPAID);
3592 insert_ob_in_map (tmp, op->map, NULL, 0); 3560 insert_ob_in_map (tmp, op->map, NULL, 0);
3593 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
3594 identify (tmp); 3561 identify (tmp);
3595 break; 3562 break;
3596 3563
3597 case TREASURE: 3564 case TREASURE:
3598 if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) 3565 if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE))
3619 } 3586 }
3620 3587
3621 op->destroy (); 3588 op->destroy ();
3622 break; 3589 break;
3623 } 3590 }
3624 return tmp ? 1 : 0; 3591
3592 return !!tmp;
3625} 3593}
3626 3594
3627/** 3595/**
3628 * fix_auto_apply goes through the entire map every time a map 3596 * fix_auto_apply goes through the entire map every time a map
3629 * is loaded or swapped in and performs special actions for 3597 * is loaded or swapped in and performs special actions for
3643 3611
3644 if (tmp->inv) 3612 if (tmp->inv)
3645 { 3613 {
3646 object *invtmp, *invnext; 3614 object *invtmp, *invnext;
3647 3615
3648 for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext) 3616 for (invtmp = tmp->inv; invtmp; invtmp = invnext)
3649 { 3617 {
3650 invnext = invtmp->below; 3618 invnext = invtmp->below;
3651 3619
3652 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) 3620 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY))
3653 auto_apply (invtmp); 3621 auto_apply (invtmp);
3654 else if (invtmp->type == TREASURE && invtmp->has_random_items ()) 3622 else if (invtmp->type == TREASURE && invtmp->has_random_items ())
3655 { 3623 {
3656 while ((invtmp->stats.hp--) > 0) 3624 while (invtmp->stats.hp-- > 0)
3657 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); 3625 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0);
3658 3626
3659 invtmp->randomitems = NULL; 3627 invtmp->randomitems = NULL;
3660 } 3628 }
3661 else if (invtmp && invtmp->arch 3629 else if (invtmp && invtmp->arch
3773 /* check for hp, sp change */ 3741 /* check for hp, sp change */
3774 if (food->stats.hp != 0) 3742 if (food->stats.hp != 0)
3775 { 3743 {
3776 if (QUERY_FLAG (food, FLAG_CURSED)) 3744 if (QUERY_FLAG (food, FLAG_CURSED))
3777 { 3745 {
3778 assign (who->contr->killer, food->name); 3746 who->contr->killer = food;
3779 hit_player (who, food->stats.hp, food, AT_POISON, 1); 3747 hit_player (who, food->stats.hp, food, AT_POISON, 1);
3780 new_draw_info (NDI_UNIQUE, 0, who, "Eck!...that was poisonous!"); 3748 who->failmsg ("Eck!...that was poisonous!");
3781 } 3749 }
3782 else 3750 else
3783 { 3751 {
3784 if (food->stats.hp > 0) 3752 if (food->stats.hp > 0)
3785 new_draw_info (NDI_UNIQUE, 0, who, "You begin to feel better."); 3753 who->statusmsg ("You begin to feel better.");
3786 else 3754 else
3787 new_draw_info (NDI_UNIQUE, 0, who, "Eck!...that was poisonous!"); 3755 who->failmsg ("Eck!...that was poisonous!");
3756
3788 who->stats.hp += food->stats.hp; 3757 who->stats.hp += food->stats.hp;
3789 } 3758 }
3790 } 3759 }
3760
3791 if (food->stats.sp != 0) 3761 if (food->stats.sp != 0)
3792 { 3762 {
3793 if (QUERY_FLAG (food, FLAG_CURSED)) 3763 if (QUERY_FLAG (food, FLAG_CURSED))
3794 { 3764 {
3795 new_draw_info (NDI_UNIQUE, 0, who, "You are drained of mana!"); 3765 who->failmsg ("You are drained of mana!");
3796 who->stats.sp -= food->stats.sp; 3766 who->stats.sp -= food->stats.sp;
3797 if (who->stats.sp < 0) 3767 if (who->stats.sp < 0)
3798 who->stats.sp = 0; 3768 who->stats.sp = 0;
3799 } 3769 }
3800 else 3770 else
3801 { 3771 {
3802 new_draw_info (NDI_UNIQUE, 0, who, "You feel a rush of magical energy!"); 3772 who->statusmsg ("You feel a rush of magical energy!");
3803 who->stats.sp += food->stats.sp; 3773 who->stats.sp += food->stats.sp;
3804 /* place limit on max sp from food? */ 3774 /* place limit on max sp from food? */
3805 } 3775 }
3806 } 3776 }
3777
3807 who->update_stats (); 3778 who->update_stats ();
3808} 3779}
3809 3780
3810/** 3781/**
3811 * Designed primarily to light torches/lanterns/etc. 3782 * Designed primarily to light torches/lanterns/etc.
3821 item = find_marked_object (who); 3792 item = find_marked_object (who);
3822 if (item) 3793 if (item)
3823 { 3794 {
3824 if (lighter->last_eat && lighter->stats.food) 3795 if (lighter->last_eat && lighter->stats.food)
3825 { /* lighter gets used up */ 3796 { /* lighter gets used up */
3826 /* Split multiple lighters if they're being used up. Otherwise *
3827 * one charge from each would be used up. --DAMN */
3828 if (lighter->nrof > 1)
3829 {
3830 object *oneLighter = lighter->clone (); 3797 object *oneLighter = lighter->split ();
3831
3832 lighter->nrof -= 1;
3833 oneLighter->nrof = 1;
3834 oneLighter->stats.food--; 3798 oneLighter->stats.food--;
3835 esrv_send_item (who, lighter); 3799 who->insert (oneLighter);
3836 oneLighter = insert_ob_in_ob (oneLighter, who);
3837 esrv_send_item (who, oneLighter);
3838 }
3839 else
3840 lighter->stats.food--;
3841 } 3800 }
3842 else if (lighter->last_eat) 3801 else if (lighter->last_eat)
3802 {
3843 { /* no charges left in lighter */ 3803 /* 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); 3804 who->failmsg (format ("You attempt to light the %s with a used up %s.", &item->name, &lighter->name));
3845 return; 3805 return;
3846 } 3806 }
3847 3807
3848 /* Perhaps we should split what we are trying to light on fire? 3808 /* 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 3809 * I can't see many times when you would want to light multiple
3855 3815
3856 save_throw_object (item, AT_FIRE, who); 3816 save_throw_object (item, AT_FIRE, who);
3857 3817
3858 if (item->destroyed ()) 3818 if (item->destroyed ())
3859 { 3819 {
3860 new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item->name, &lighter->name); 3820 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 3821 /* Need to update the player so that the players glow radius
3862 * gets changed. 3822 * gets changed.
3863 */ 3823 */
3864 if (is_player_env) 3824 if (is_player_env)
3865 who->update_stats (); 3825 who->update_stats ();
3866 } 3826 }
3867 else 3827 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); 3828 who->failmsg (format ("You attempt to light the %s with the %s and fail.", &item->name, &lighter->name));
3869 } 3829 }
3870 else /* nothing to light */ 3830 else
3871 new_draw_info (NDI_UNIQUE, 0, who, "You need to mark a lightable object."); 3831 who->failmsg ("You need to mark a lightable object.");
3872
3873} 3832}
3874 3833
3875/** 3834/**
3876 * op made some mistake with a scroll, this takes care of punishment. 3835 * op made some mistake with a scroll, this takes care of punishment.
3877 * scroll_failure()- hacked directly from spell_failure 3836 * scroll_failure()- hacked directly from spell_failure
3884 3843
3885 if (failure <= -1 && failure > -15) 3844 if (failure <= -1 && failure > -15)
3886 { /* wonder */ 3845 { /* wonder */
3887 object *tmp; 3846 object *tmp;
3888 3847
3889 new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!"); 3848 op->failmsg ("Your spell warps!");
3890 tmp = get_archetype (SPELL_WONDER); 3849 tmp = get_archetype (SPELL_WONDER);
3891 cast_wonder (op, op, 0, tmp); 3850 cast_wonder (op, op, 0, tmp);
3892 tmp->destroy (); 3851 tmp->destroy ();
3893 } 3852 }
3894 else if (failure <= -15 && failure > -35) 3853 else if (failure <= -15 && failure > -35)
3895 { /* drain mana */ 3854 { /* drain mana */
3896 new_draw_info (NDI_UNIQUE, 0, op, "Your mana is drained!."); 3855 op->failmsg ("Your mana is drained!");
3897 op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); 3856 op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW);
3898 if (op->stats.sp < 0) 3857 if (op->stats.sp < 0)
3899 op->stats.sp = 0; 3858 op->stats.sp = 0;
3900 } 3859 }
3901 else if (settings.spell_failure_effects == TRUE) 3860 else if (settings.spell_failure_effects == TRUE)
3902 { 3861 {
3903 if (failure <= -35 && failure > -60) 3862 if (failure <= -35 && failure > -60)
3904 { /* confusion */ 3863 { /* confusion */
3905 new_draw_info (NDI_UNIQUE, 0, op, "The magic recoils on you!"); 3864 op->failmsg ("The magic recoils on you!");
3906 confuse_player (op, op, power); 3865 confuse_player (op, op, power);
3907 } 3866 }
3908 else if (failure <= -60 && failure > -70) 3867 else if (failure <= -60 && failure > -70)
3909 { /* paralysis */ 3868 { /* paralysis */
3910 new_draw_info (NDI_UNIQUE, 0, op, "The magic recoils and paralyzes " "you!"); 3869 op->failmsg ("The magic recoils and paralyzes you!");
3911 paralyze_player (op, op, power); 3870 paralyze_player (op, op, power);
3912 } 3871 }
3913 else if (failure <= -70 && failure > -80) 3872 else if (failure <= -70 && failure > -80)
3914 { /* blind */ 3873 { /* blind */
3915 new_draw_info (NDI_UNIQUE, 0, op, "The magic recoils on you!"); 3874 op->failmsg ("The magic recoils on you!");
3916 blind_player (op, op, power); 3875 blind_player (op, op, power);
3917 } 3876 }
3918 else if (failure <= -80) 3877 else if (failure <= -80)
3919 { /* blast the immediate area */ 3878 { /* blast the immediate area */
3920 object *tmp = get_archetype (LOOSE_MANA); 3879 object *tmp = get_archetype (LOOSE_MANA);
3921 cast_magic_storm (op, tmp, power); 3880 cast_magic_storm (op, tmp, power);
3922 new_draw_info (NDI_UNIQUE, 0, op, "You unleash uncontrolled mana!"); 3881 op->failmsg ("You unleash uncontrolled mana!");
3923 tmp->destroy (); 3882 tmp->destroy ();
3924 } 3883 }
3925 } 3884 }
3926} 3885}
3927 3886
3992 if (!strcmp (walk->name, "NOCLASSFACECHANGE")) 3951 if (!strcmp (walk->name, "NOCLASSFACECHANGE"))
3993 flag_change_face = 0; 3952 flag_change_face = 0;
3994 3953
3995 if (flag_change_face) 3954 if (flag_change_face)
3996 { 3955 {
3997 pl->animation_id = GET_ANIM_ID (change);
3998 pl->face = change->face; 3956 pl->face = change->face;
3999 3957 pl->animation_id = change->animation_id;
4000 if (QUERY_FLAG (change, FLAG_ANIMATE)) 3958 pl->flag [FLAG_ANIMATE] = change->flag [FLAG_ANIMATE];
4001 SET_FLAG (pl, FLAG_ANIMATE);
4002 else
4003 CLEAR_FLAG (pl, FLAG_ANIMATE);
4004 } 3959 }
4005 3960
4006 /* check the special case of can't use weapons */ 3961 /* check the special case of can't use weapons */
4007 /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */ 3962 /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */
4008 if (!strcmp (change->name, "monk")) 3963 if (!strcmp (change->name, "monk"))
4039 3994
4040 marked = find_marked_object (pl); 3995 marked = find_marked_object (pl);
4041 3996
4042 if (!marked) 3997 if (!marked)
4043 { 3998 {
4044 new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); 3999 pl->failmsg (format ("Use the %s with what item?", query_name (transformer)));
4045 return; 4000 return;
4046 } 4001 }
4047 4002
4048 if (!marked->slaying) 4003 if (!marked->slaying)
4049 { 4004 {
4050 new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); 4005 pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked)));
4051 return; 4006 return;
4052 } 4007 }
4053 4008
4054 /* check whether they are compatible or not */ 4009 /* check whether they are compatible or not */
4055 find = strstr (marked->slaying, transformer->arch->archname); 4010 find = strstr (marked->slaying, transformer->arch->archname);
4056 if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) 4011 if (!find || (*(find + strlen (transformer->arch->archname)) != ':'))
4057 { 4012 {
4058 new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); 4013 pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked)));
4059 return; 4014 return;
4060 } 4015 }
4061 4016
4062 find += strlen (transformer->arch->archname) + 1; 4017 find += strlen (transformer->arch->archname) + 1;
4063 /* Item can be used, now find how many and what it yields */ 4018 /* Item can be used, now find how many and what it yields */
4073 else 4028 else
4074 yield = 1; 4029 yield = 1;
4075 4030
4076 while (isdigit (*find)) 4031 while (isdigit (*find))
4077 find++; 4032 find++;
4033
4078 while (*find == ' ') 4034 while (*find == ' ')
4079 find++; 4035 find++;
4080 4036
4081 memset (got, 0, MAX_BUF); 4037 memset (got, 0, MAX_BUF);
4082 4038
4093 4049
4094 /* Now create new item, remove used ones when required. */ 4050 /* Now create new item, remove used ones when required. */
4095 new_item = get_archetype (got); 4051 new_item = get_archetype (got);
4096 if (!new_item) 4052 if (!new_item)
4097 { 4053 {
4098 pl->errormsg (format ("This %s is strange, better to not use it.", query_base_name (marked, 0))); 4054 pl->failmsg (format ("This %s is strange, better to not use it.", query_base_name (marked, 0)));
4099 return; 4055 return;
4100 } 4056 }
4101 4057
4102 new_item->nrof = yield; 4058 new_item->nrof = yield;
4103 4059
4104 pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0))); 4060 pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0)));
4105 4061
4106 insert_ob_in_ob (new_item, pl); 4062 pl->insert (new_item);
4107 esrv_send_inventory (pl, pl);
4108 /* Eat up one item */ 4063 /* Eat up one item */
4109 decrease_ob_nr (marked, 1); 4064 marked->decrease ();
4110 4065
4111 /* Eat one transformer if needed */ 4066 /* Eat one transformer if needed */
4112 if (transformer->stats.food) 4067 if (transformer->stats.food)
4113 if (--transformer->stats.food == 0) 4068 if (--transformer->stats.food == 0)
4114 decrease_ob_nr (transformer, 1); 4069 transformer->decrease ();
4115} 4070}
4116 4071

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines