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.122 by root, Sun Aug 12 05:59:25 2007 UTC vs.
Revision 1.123 by root, Thu Aug 16 06:36:56 2007 UTC

92 * Return value: 1 if money was destroyed, 0 if not. 92 * Return value: 1 if money was destroyed, 0 if not.
93 */ 93 */
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;
98
97 object *id, *marked; 99 object *id, *marked;
98 int success = 0;
99 100
100 if (pl == NULL || pl->type != PLAYER) 101 if (pl == NULL || pl->type != PLAYER)
101 return 0; 102 return 0;
102 103
103 /* Check for MONEY type is a special hack - it prevents 'nothing needs 104 /* Check for MONEY type is a special hack - it prevents 'nothing needs
106 if (!check_altar_sacrifice (altar, money) || money->type != MONEY) 107 if (!check_altar_sacrifice (altar, money) || money->type != MONEY)
107 return 0; 108 return 0;
108 109
109 marked = find_marked_object (pl); 110 marked = find_marked_object (pl);
110 /* if the player has a marked item, identify that if it needs to be 111 /* if the player has a marked item, identify that if it needs to be
111 * identified. IF it doesn't, then go through the player inventory. 112 * identified. If it doesn't, then go through the player inventory.
112 */ 113 */
113 if (marked && !QUERY_FLAG (marked, FLAG_IDENTIFIED) && need_identify (marked)) 114 if (marked && !QUERY_FLAG (marked, FLAG_IDENTIFIED) && need_identify (marked))
114 { 115 {
115 if (operate_altar (altar, &money)) 116 if (operate_altar (altar, &money))
116 { 117 {
117 identify (marked); 118 identify (marked);
118 new_draw_info_format (NDI_UNIQUE, 0, pl, "You have %s.", long_desc (marked, pl)); 119
120 buf.printf ("You have %s.", long_desc (marked, pl));
119 if (marked->msg) 121 if (marked->msg)
120 { 122 buf << "The item has a story:\n" << marked->msg;
121 new_draw_info (NDI_UNIQUE, 0, pl, "The item has a story:"); 123
122 new_draw_info (NDI_UNIQUE, 0, pl, marked->msg);
123 }
124 return money == NULL; 124 return money == NULL;
125 } 125 }
126 } 126 }
127 127
128 for (id = pl->inv; id; id = id->below) 128 for (id = pl->inv; id; id = id->below)
130 if (!QUERY_FLAG (id, FLAG_IDENTIFIED) && !id->invisible && need_identify (id)) 130 if (!QUERY_FLAG (id, FLAG_IDENTIFIED) && !id->invisible && need_identify (id))
131 { 131 {
132 if (operate_altar (altar, &money)) 132 if (operate_altar (altar, &money))
133 { 133 {
134 identify (id); 134 identify (id);
135 new_draw_info_format (NDI_UNIQUE, 0, pl, "You have %s.", long_desc (id, pl)); 135
136 buf.printf ("You have %s.", long_desc (id, pl));
136 if (id->msg) 137 if (marked->msg)
137 { 138 buf << "The item has a story:\n" << marked->msg;
138 new_draw_info (NDI_UNIQUE, 0, pl, "The item has a story:"); 139
139 new_draw_info (NDI_UNIQUE, 0, pl, id->msg);
140 }
141 success = 1;
142 /* If no more money, might as well quit now */ 140 /* If no more money, might as well quit now */
143 if (money == NULL || !check_altar_sacrifice (altar, money)) 141 if (money == NULL || !check_altar_sacrifice (altar, money))
144 break; 142 break;
145 } 143 }
146 else 144 else
148 LOG (llevError, "check_id_altar: Couldn't do sacrifice when we should have been able to\n"); 146 LOG (llevError, "check_id_altar: Couldn't do sacrifice when we should have been able to\n");
149 break; 147 break;
150 } 148 }
151 } 149 }
152 } 150 }
153 if (!success) 151
154 new_draw_info (NDI_UNIQUE, 0, pl, "You have nothing that needs identifying"); 152 if (buf.empty ())
153 buf << ("You have nothing that needs identifying");
154
155 pl->contr->infobox (buf);
156
155 return money == NULL; 157 return !money;
156} 158}
157 159
158/** 160/**
159 * This checks whether the object has a "on_use_yield" field, and if so generated and drops 161 * This checks whether the object has a "on_use_yield" field, and if so generated and drops
160 * matching item. 162 * matching item.
195 197
196 floor = GET_MAP_OB (op->map, op->x, op->y); 198 floor = GET_MAP_OB (op->map, op->x, op->y);
197 199
198 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 200 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
199 { 201 {
200 if (op->type == PLAYER)
201 new_draw_info (NDI_UNIQUE, 0, op, "Gods prevent you from using this here, it's sacred ground!"); 202 op->errormsg ("Gods prevent you from using this here, it's sacred ground!");
203
202 CLEAR_FLAG (tmp, FLAG_APPLIED); 204 CLEAR_FLAG (tmp, FLAG_APPLIED);
203 return 0; 205 return 0;
204 } 206 }
205 207
206 if (op->type == PLAYER) 208 if (op->type == PLAYER)
232 234
233 if (depl) 235 if (depl)
234 { 236 {
235 for (i = 0; i < NUM_STATS; i++) 237 for (i = 0; i < NUM_STATS; i++)
236 if (depl->stats.stat (i)) 238 if (depl->stats.stat (i))
237 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); 239 op->statusmsg (restore_msg[i]);
238 240
239 depl->destroy (); 241 depl->destroy ();
240 op->update_stats (); 242 op->update_stats ();
241 } 243 }
242 else 244 else
243 new_draw_info (NDI_UNIQUE, 0, op, "You potion had no effect."); 245 op->statusmsg ("Your potion had no effect.");
244 246
245 decrease_ob (tmp); 247 decrease_ob (tmp);
246 return 1; 248 return 1;
247 } 249 }
248 250
249 /* improvement potion - only for players */ 251 /* improvement potion - only for players */
250 if (op->type == PLAYER && tmp->attacktype & AT_GODPOWER) 252 if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER))
251 { 253 {
252 for (i = 1; i < MIN (11, op->level); i++) 254 for (i = 1; i < MIN (11, op->level); i++)
253 { 255 {
254 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 256 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
255 { 257 {
256 if (op->contr->levhp[i] != 1) 258 if (op->contr->levhp[i] != 1)
257 { 259 {
258 op->contr->levhp[i] = 1; 260 op->contr->levhp[i] = 1;
259 break; 261 break;
260 } 262 }
263
261 if (op->contr->levsp[i] != 1) 264 if (op->contr->levsp[i] != 1)
262 { 265 {
263 op->contr->levsp[i] = 1; 266 op->contr->levsp[i] = 1;
264 break; 267 break;
265 } 268 }
269
266 if (op->contr->levgrace[i] != 1) 270 if (op->contr->levgrace[i] != 1)
267 { 271 {
268 op->contr->levgrace[i] = 1; 272 op->contr->levgrace[i] = 1;
269 break; 273 break;
270 } 274 }
274 if (op->contr->levhp[i] < 9) 278 if (op->contr->levhp[i] < 9)
275 { 279 {
276 op->contr->levhp[i] = 9; 280 op->contr->levhp[i] = 9;
277 break; 281 break;
278 } 282 }
283
279 if (op->contr->levsp[i] < 6) 284 if (op->contr->levsp[i] < 6)
280 { 285 {
281 op->contr->levsp[i] = 6; 286 op->contr->levsp[i] = 6;
282 break; 287 break;
283 } 288 }
289
284 if (op->contr->levgrace[i] < 3) 290 if (op->contr->levgrace[i] < 3)
285 { 291 {
286 op->contr->levgrace[i] = 3; 292 op->contr->levgrace[i] = 3;
287 break; 293 break;
288 } 294 }
296 if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)) 302 if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED))
297 { 303 {
298 if (got_one) 304 if (got_one)
299 { 305 {
300 op->update_stats (); 306 op->update_stats ();
301 new_draw_info (NDI_UNIQUE, 0, op, "The Gods smile upon you and remake you"); 307 op->statusmsg ("The Gods smile upon you and remake you "
302 new_draw_info (NDI_UNIQUE, 0, op, "a little more in their image."); 308 "a little more in their image. "
303 new_draw_info (NDI_UNIQUE, 0, op, "You feel a little more perfect."); 309 "You feel a little more perfect.", NDI_GREEN);
304 } 310 }
305 else 311 else
306 new_draw_info (NDI_UNIQUE, 0, op, "The potion had no effect - you are already perfect"); 312 op->statusmsg ("The potion had no effect - you are already perfect.");
307 } 313 }
308 else 314 else
309 { /* cursed potion */ 315 { /* cursed potion */
310 if (got_one) 316 if (got_one)
311 { 317 {
312 op->update_stats (); 318 op->update_stats ();
313 new_draw_info (NDI_UNIQUE, 0, op, "The Gods are angry and punish you."); 319 op->errormsg ("The Gods are angry and punish you.");
314 } 320 }
315 else 321 else
316 new_draw_info (NDI_UNIQUE, 0, op, "You are fortunate that you are so pathetic."); 322 op->statusmsg ("You are fortunate that you are so pathetic.", NDI_DK_ORANGE);
317 } 323 }
318 324
319 decrease_ob (tmp); 325 decrease_ob (tmp);
320 return 1; 326 return 1;
321 } 327 }
330 { 336 {
331 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 337 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
332 { 338 {
333 object *fball; 339 object *fball;
334 340
335 new_draw_info (NDI_UNIQUE, 0, op, "Yech! Your lungs are on fire!"); 341 op->errormsg ("Yech! Your lungs are on fire!");
342
336 /* Explodes a fireball centered at player */ 343 /* Explodes a fireball centered at player */
337 fball = get_archetype (EXPLODING_FIREBALL); 344 fball = get_archetype (EXPLODING_FIREBALL);
338 fball->dam_modifier = random_roll (1, op->level, op, PREFER_LOW) / 5 + 1; 345 fball->dam_modifier = random_roll (1, op->level, op, PREFER_LOW) / 5 + 1;
339 fball->stats.maxhp = random_roll (1, op->level, op, PREFER_LOW) / 10 + 2; 346 fball->stats.maxhp = random_roll (1, op->level, op, PREFER_LOW) / 10 + 2;
340 fball->x = op->x; 347 fball->x = op->x;
343 } 350 }
344 else 351 else
345 cast_spell (op, tmp, op->facing, tmp->inv, NULL); 352 cast_spell (op, tmp, op->facing, tmp->inv, NULL);
346 353
347 decrease_ob (tmp); 354 decrease_ob (tmp);
355
348 /* if youre dead, no point in doing this... */ 356 /* if youre dead, no point in doing this... */
349 if (!QUERY_FLAG (op, FLAG_REMOVED)) 357 if (!QUERY_FLAG (op, FLAG_REMOVED))
350 op->update_stats (); 358 op->update_stats ();
359
351 return 1; 360 return 1;
352 } 361 }
353 362
354 /* Deal with protection potions */ 363 /* Deal with protection potions */
355 force = NULL; 364 force = NULL;
357 { 366 {
358 if (tmp->resist[i]) 367 if (tmp->resist[i])
359 { 368 {
360 if (!force) 369 if (!force)
361 force = get_archetype (FORCE_NAME); 370 force = get_archetype (FORCE_NAME);
371
362 memcpy (force->resist, tmp->resist, sizeof (tmp->resist)); 372 memcpy (force->resist, tmp->resist, sizeof (tmp->resist));
363 force->type = POTION_EFFECT; 373 force->type = POTION_EFFECT;
364 break; /* Only need to find one protection since we copy entire batch */ 374 break; /* Only need to find one protection since we copy entire batch */
365 } 375 }
366 } 376 }
377
367 /* This is a protection potion */ 378 /* This is a protection potion */
368 if (force) 379 if (force)
369 { 380 {
370 /* cursed items last longer */ 381 /* cursed items last longer */
371 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 382 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
390 { /* only for players */ 401 { /* only for players */
391 if ((QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) && tmp->value != 0) 402 if ((QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) && tmp->value != 0)
392 CLEAR_FLAG (tmp, FLAG_APPLIED); 403 CLEAR_FLAG (tmp, FLAG_APPLIED);
393 else 404 else
394 SET_FLAG (tmp, FLAG_APPLIED); 405 SET_FLAG (tmp, FLAG_APPLIED);
406
395 if (!change_abil (op, tmp)) 407 if (!change_abil (op, tmp))
396 new_draw_info (NDI_UNIQUE, 0, op, "Nothing happened."); 408 op->statusmsg ("Nothing happened.");
397 } 409 }
398 410
399 /* CLEAR_FLAG is so that if the character has other potions 411 /* CLEAR_FLAG is so that if the character has other potions
400 * that were grouped with the one consumed, his 412 * that were grouped with the one consumed, his
401 * stat will not be raised by them. fix_player just clears 413 * stat will not be raised by them. fix_player just clears
417static int 429static int
418check_item (object *op, const char *item) 430check_item (object *op, const char *item)
419{ 431{
420 int count = 0; 432 int count = 0;
421 433
422 434 if (!item)
423 if (item == NULL)
424 return 0; 435 return 0;
425 436
426 op = op->below; 437 for (op = op->below; op; op = op->below)
427 while (op != NULL)
428 { 438 {
429 if (strcmp (op->arch->archname, item) == 0) 439 if (strcmp (op->arch->archname, item) == 0)
430 { 440 {
431 if (!QUERY_FLAG (op, FLAG_CURSED) && !QUERY_FLAG (op, FLAG_DAMNED) 441 if (!QUERY_FLAG (op, FLAG_CURSED) && !QUERY_FLAG (op, FLAG_DAMNED)
432 /* Loophole bug? -FD- */ && !QUERY_FLAG (op, FLAG_UNPAID)) 442 /* Loophole bug? -FD- */ && !QUERY_FLAG (op, FLAG_UNPAID))
435 count++; 445 count++;
436 else 446 else
437 count += op->nrof; 447 count += op->nrof;
438 } 448 }
439 } 449 }
440
441 op = op->below;
442 } 450 }
443 451
444 return count; 452 return count;
445} 453}
446 454
456 object *prev; 464 object *prev;
457 465
458 prev = op; 466 prev = op;
459 op = op->below; 467 op = op->below;
460 468
461 while (op != NULL) 469 while (op)
462 { 470 {
463 if (strcmp (op->arch->archname, item) == 0) 471 if (strcmp (op->arch->archname, item) == 0)
464 { 472 {
465 if (op->nrof >= nrof) 473 if (op->nrof >= nrof)
466 { 474 {
470 else 478 else
471 { 479 {
472 decrease_ob_nr (op, op->nrof); 480 decrease_ob_nr (op, op->nrof);
473 nrof -= op->nrof; 481 nrof -= op->nrof;
474 } 482 }
483
475 op = prev; 484 op = prev;
476 } 485 }
486
477 prev = op; 487 prev = op;
478 op = op->below; 488 op = op->below;
479 } 489 }
480} 490}
481 491
487 * we return 1 (true) if the player can use the weapon. 497 * we return 1 (true) if the player can use the weapon.
488 */ 498 */
489static int 499static int
490check_weapon_power (const object *who, int improvs) 500check_weapon_power (const object *who, int improvs)
491{ 501{
492
493/* Old code is below (commented out). Basically, since weapons are the only 502/* Old code is below (commented out). Basically, since weapons are the only
494 * object players really have any control to improve, it's a bit harsh to 503 * object players really have any control to improve, it's a bit harsh to
495 * require high level in some combat skill, so we just use overall level. 504 * require high level in some combat skill, so we just use overall level.
496 */ 505 */
497#if 1 506#if 1
538static int 547static int
539check_sacrifice (object *op, const object *improver) 548check_sacrifice (object *op, const object *improver)
540{ 549{
541 int count = 0; 550 int count = 0;
542 551
543 if (improver->slaying != NULL) 552 if (improver->slaying)
544 { 553 {
545 count = check_item (op, improver->slaying); 554 count = check_item (op, improver->slaying);
546 if (count < 1) 555 if (count < 1)
547 { 556 {
548 char buf[200];
549
550 sprintf (buf, "The gods want more %ss", &improver->slaying); 557 op->errormsg (format ("The gods want more %ss", &improver->slaying));
551 new_draw_info (NDI_UNIQUE, 0, op, buf);
552 return 0; 558 return 0;
553 } 559 }
554 } 560 }
555 else 561 else
556 count = 1; 562 count = 1;
559} 565}
560 566
561/** 567/**
562 * Actually improves the weapon, and tells user. 568 * Actually improves the weapon, and tells user.
563 */ 569 */
564int 570static int
565improve_weapon_stat (object *op, object *improver, object *weapon, signed char *stat, int sacrifice_count, const char *statname) 571improve_weapon_stat (object *op, object *improver, object *weapon, sint8 &stat, int sacrifice_count, const char *statname)
566{ 572{
567
568 new_draw_info (NDI_UNIQUE, 0, op, "Your sacrifice was accepted.");
569 *stat += sacrifice_count; 573 stat += sacrifice_count;
570 weapon->last_eat++; 574 weapon->last_eat++;
571 new_draw_info_format (NDI_UNIQUE, 0, op, "Weapon's bonus to %s improved by %d", statname, sacrifice_count);
572 decrease_ob (improver); 575 decrease_ob (improver);
573 576
574 /* So it updates the players stats and the window */ 577 /* So it updates the players stats and the window */
575 op->update_stats (); 578 op->update_stats ();
579
580 op->statusmsg (format (
581 "Your sacrifice was accepted.\n"
582 "Weapon's bonus to %s improved by %d.",
583 statname, sacrifice_count
584 ));
585
576 return 1; 586 return 1;
577} 587}
578 588
579/* Types of improvements, hidden in the sp field. */ 589/* Types of improvements, hidden in the sp field. */
580#define IMPROVE_PREPARE 1 590#define IMPROVE_PREPARE 1
599 int sacrifice_count, i; 609 int sacrifice_count, i;
600 char buf[MAX_BUF]; 610 char buf[MAX_BUF];
601 611
602 if (weapon->level != 0) 612 if (weapon->level != 0)
603 { 613 {
604 new_draw_info (NDI_UNIQUE, 0, op, "Weapon already prepared."); 614 op->errormsg ("Weapon is already prepared!");
605 return 0; 615 return 0;
606 } 616 }
607 617
608 for (i = 0; i < NROFATTACKS; i++) 618 for (i = 0; i < NROFATTACKS; i++)
609 if (weapon->resist[i]) 619 if (weapon->resist[i])
615 if (i < NROFATTACKS || weapon->stats.hp || /* regeneration */ 625 if (i < NROFATTACKS || weapon->stats.hp || /* regeneration */
616 (weapon->stats.sp && weapon->type == WEAPON) || /* sp regeneration */ 626 (weapon->stats.sp && weapon->type == WEAPON) || /* sp regeneration */
617 weapon->stats.exp || /* speed */ 627 weapon->stats.exp || /* speed */
618 weapon->stats.ac) /* AC - only taifu's I think */ 628 weapon->stats.ac) /* AC - only taifu's I think */
619 { 629 {
620 new_draw_info (NDI_UNIQUE, 0, op, "Cannot prepare magic weapons."); 630 op->errormsg ("You cannot prepare magic weapons.");
621 return 0; 631 return 0;
622 } 632 }
623 633
624 sacrifice_count = check_sacrifice (op, improver); 634 sacrifice_count = check_sacrifice (op, improver);
625 if (sacrifice_count <= 0) 635 if (sacrifice_count <= 0)
626 return 0; 636 return 0;
627 637
628 weapon->level = isqrt (sacrifice_count); 638 weapon->level = isqrt (sacrifice_count);
629 new_draw_info (NDI_UNIQUE, 0, op, "Your sacrifice was accepted.");
630 eat_item (op, improver->slaying, sacrifice_count); 639 eat_item (op, improver->slaying, sacrifice_count);
631 640
632 new_draw_info_format (NDI_UNIQUE, 0, op, "Your *%s may be improved %d times.", &weapon->name, weapon->level); 641 op->statusmsg (format (
642 "Your sacrifice was accepted."
643 "Your *%s may be improved %d times.",
644 &weapon->name, weapon->level
645 ));
633 646
634 sprintf (buf, "%s's %s", &op->name, &weapon->name); 647 sprintf (buf, "%s's %s", &op->name, &weapon->name);
635 weapon->name = weapon->name_pl = buf; 648 weapon->name = weapon->name_pl = buf;
636 weapon->nrof = 0; /* prevents preparing n weapons in the same 649 weapon->nrof = 0; /* prevents preparing n weapons in the same
637 slot at once! */ 650 slot at once! */
656improve_weapon (object *op, object *improver, object *weapon) 669improve_weapon (object *op, object *improver, object *weapon)
657{ 670{
658 int sacrifice_count, sacrifice_needed = 0; 671 int sacrifice_count, sacrifice_needed = 0;
659 672
660 if (improver->stats.sp == IMPROVE_PREPARE) 673 if (improver->stats.sp == IMPROVE_PREPARE)
661 {
662 return prepare_weapon (op, improver, weapon); 674 return prepare_weapon (op, improver, weapon);
663 } 675
664 if (weapon->level == 0) 676 if (weapon->level == 0)
665 { 677 {
666 new_draw_info (NDI_UNIQUE, 0, op, "This weapon has not been prepared."); 678 op->errormsg ("This weapon has not been prepared. H<You first ahve to prepare a weapon with a prepare weapon scroll.>");
667 return 0; 679 return 0;
668 } 680 }
681
669 if (weapon->level == weapon->last_eat && weapon->item_power >= 100) 682 if (weapon->level == weapon->last_eat && weapon->item_power >= 100)
670 { 683 {
671 new_draw_info (NDI_UNIQUE, 0, op, "This weapon cannot be improved any more."); 684 op->errormsg ("This weapon cannot be improved any more.");
672 return 0; 685 return 0;
673 } 686 }
687
674 if (QUERY_FLAG (weapon, FLAG_APPLIED) && !check_weapon_power (op, weapon->last_eat + 1)) 688 if (QUERY_FLAG (weapon, FLAG_APPLIED) && !check_weapon_power (op, weapon->last_eat + 1))
675 { 689 {
676 new_draw_info (NDI_UNIQUE, 0, op, "Improving the weapon will make it too"); 690 op->errormsg ("Improving the weapon will make it too "
677 new_draw_info (NDI_UNIQUE, 0, op, "powerful for you to use. Unready it if you"); 691 "powerful for you to use. Unready it if you "
678 new_draw_info (NDI_UNIQUE, 0, op, "really want to improve it."); 692 "really want to improve it.");
679 return 0; 693 return 0;
680 } 694 }
695
681 /* This just increases damage by 5 points, no matter what. No sacrifice 696 /* This just increases damage by 5 points, no matter what. No sacrifice
682 * is needed. Since stats.dam is now a 16 bit value and not 8 bit, 697 * is needed. Since stats.dam is now a 16 bit value and not 8 bit,
683 * don't put any maximum value on damage - the limit is how much the 698 * don't put any maximum value on damage - the limit is how much the
684 * weapon can be improved. 699 * weapon can be improved.
685 */ 700 */
686 if (improver->stats.sp == IMPROVE_DAMAGE) 701 if (improver->stats.sp == IMPROVE_DAMAGE)
687 { 702 {
688 weapon->stats.dam += 5; 703 weapon->stats.dam += 5;
689 weapon->weight += 5000; /* 5 KG's */ 704 weapon->weight += 5000; /* 5 KG's */
690 new_draw_info_format (NDI_UNIQUE, 0, op, "Damage has been increased by 5 to %d", weapon->stats.dam); 705 op->statusmsg (format ("Damage has been increased by 5 to %d.", weapon->stats.dam));
691 weapon->last_eat++; 706 weapon->last_eat++;
692 707
693 weapon->item_power++; 708 weapon->item_power++;
694 decrease_ob (improver); 709 decrease_ob (improver);
695 return 1; 710 return 1;
696 } 711 }
712
697 if (improver->stats.sp == IMPROVE_WEIGHT) 713 if (improver->stats.sp == IMPROVE_WEIGHT)
698 { 714 {
699 /* Reduce weight by 20% */ 715 /* Reduce weight by 20% */
700 weapon->weight = (weapon->weight * 8) / 10; 716 weapon->weight = (weapon->weight * 8) / 10;
701 if (weapon->weight < 1) 717 if (weapon->weight < 1)
702 weapon->weight = 1; 718 weapon->weight = 1;
719
703 new_draw_info_format (NDI_UNIQUE, 0, op, "Weapon weight reduced to %6.1f kg", (float) weapon->weight / 1000.0); 720 op->statusmsg (format ("Weapon weight reduced to %6.1fkg.", (float) weapon->weight / 1000.0));
704 weapon->last_eat++; 721 weapon->last_eat++;
705 weapon->item_power++; 722 weapon->item_power++;
706 decrease_ob (improver); 723 decrease_ob (improver);
707 return 1; 724 return 1;
708 } 725 }
709 if (improver->stats.sp == IMPROVE_ENCHANT) 726 if (improver->stats.sp == IMPROVE_ENCHANT)
710 { 727 {
711 weapon->magic++; 728 weapon->magic++;
712 weapon->last_eat++; 729 weapon->last_eat++;
713 new_draw_info_format (NDI_UNIQUE, 0, op, "Weapon magic increased to %d", weapon->magic); 730 op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic));
714 decrease_ob (improver); 731 decrease_ob (improver);
715 weapon->item_power++; 732 weapon->item_power++;
716 return 1; 733 return 1;
717 } 734 }
718 735
724 sacrifice_needed *= 2; 741 sacrifice_needed *= 2;
725 742
726 sacrifice_count = check_sacrifice (op, improver); 743 sacrifice_count = check_sacrifice (op, improver);
727 if (sacrifice_count < sacrifice_needed) 744 if (sacrifice_count < sacrifice_needed)
728 { 745 {
729 new_draw_info_format (NDI_UNIQUE, 0, op, "You need at least %d %s", sacrifice_needed, &improver->slaying); 746 op->errormsg (format ("You need at least %d %s.", sacrifice_needed, &improver->slaying));
730 return 0; 747 return 0;
731 } 748 }
749
732 eat_item (op, improver->slaying, sacrifice_needed); 750 eat_item (op, improver->slaying, sacrifice_needed);
733 weapon->item_power++; 751 weapon->item_power++;
734 752
735 switch (improver->stats.sp) 753 switch (improver->stats.sp)
736 { 754 {
737 case IMPROVE_STR:
738 return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Str), 1, "strength"); 755 case IMPROVE_STR: return improve_weapon_stat (op, improver, weapon, weapon->stats.Str, 1, "strength");
739 case IMPROVE_DEX:
740 return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Dex), 1, "dexterity"); 756 case IMPROVE_DEX: return improve_weapon_stat (op, improver, weapon, weapon->stats.Dex, 1, "dexterity");
741 case IMPROVE_CON:
742 return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Con), 1, "constitution"); 757 case IMPROVE_CON: return improve_weapon_stat (op, improver, weapon, weapon->stats.Con, 1, "constitution");
743 case IMPROVE_WIS:
744 return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Wis), 1, "wisdom"); 758 case IMPROVE_WIS: return improve_weapon_stat (op, improver, weapon, weapon->stats.Wis, 1, "wisdom");
745 case IMPROVE_CHA:
746 return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Cha), 1, "charisma"); 759 case IMPROVE_CHA: return improve_weapon_stat (op, improver, weapon, weapon->stats.Cha, 1, "charisma");
747 case IMPROVE_INT:
748 return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Int), 1, "intelligence"); 760 case IMPROVE_INT: return improve_weapon_stat (op, improver, weapon, weapon->stats.Int, 1, "intelligence");
749 case IMPROVE_POW:
750 return improve_weapon_stat (op, improver, weapon, (signed char *) &(weapon->stats.Pow), 1, "power"); 761 case IMPROVE_POW: return improve_weapon_stat (op, improver, weapon, weapon->stats.Pow, 1, "power");
751 default: 762 default:
752 new_draw_info (NDI_UNIQUE, 0, op, "Unknown improvement type."); 763 op->errormsg ("Unknown improvement type.");
753 } 764 }
765
754 LOG (llevError, "improve_weapon: Got to end of function\n"); 766 LOG (llevError, "improve_weapon: Got to end of function\n");
755 return 0; 767 return 0;
756} 768}
757 769
758/** 770/**
768 if (op->type != PLAYER) 780 if (op->type != PLAYER)
769 return 0; 781 return 0;
770 782
771 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) 783 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC))
772 { 784 {
773 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll."); 785 op->errormsg ("Something blocks the magic of the scroll!");
774 return 0; 786 return 0;
775 } 787 }
776 788
777 otmp = find_marked_object (op); 789 otmp = find_marked_object (op);
778 if (!otmp) 790 if (!otmp)
779 { 791 {
780 new_draw_info (NDI_UNIQUE, 0, op, "You need to mark a weapon object."); 792 op->errormsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>");
781 return 0; 793 return 0;
782 } 794 }
783 795
784 if (otmp->type != WEAPON && otmp->type != BOW) 796 if (otmp->type != WEAPON && otmp->type != BOW)
785 { 797 {
786 new_draw_info (NDI_UNIQUE, 0, op, "Marked item is not a weapon or bow"); 798 op->errormsg ("Marked item is not a weapon or bow!");
787 return 0; 799 return 0;
788 } 800 }
789 801
790 new_draw_info (NDI_UNIQUE, 0, op, "Applied weapon builder."); 802 op->statusmsg ("Applied weapon builder.");
803
791 improve_weapon (op, tmp, otmp); 804 improve_weapon (op, tmp, otmp);
792 esrv_send_item (op, otmp); 805 esrv_send_item (op, otmp);
793 return 1; 806 return 1;
794} 807}
795 808
820{ 833{
821 object *tmp; 834 object *tmp;
822 835
823 if (armour->magic >= settings.armor_max_enchant) 836 if (armour->magic >= settings.armor_max_enchant)
824 { 837 {
825 new_draw_info (NDI_UNIQUE, 0, op, "This armour can not be enchanted any further."); 838 op->errormsg ("This armour can not be enchanted any further!");
826 return 0; 839 return 0;
827 } 840 }
828 /* Dealing with random artifact armor is a lot trickier (in terms of value, weight, 841 /* Dealing with random artifact armor is a lot trickier (in terms of value, weight,
829 * etc), so take the easy way out and don't worry about it. 842 * etc), so take the easy way out and don't worry about it.
830 * Note - maybe add scrolls which make the random artifact versions (eg, armour 843 * Note - maybe add scrolls which make the random artifact versions (eg, armour
831 * of gnarg and what not?) 844 * of gnarg and what not?)
832 */ 845 */
833 if (armour->title) 846 if (armour->title)
834 { 847 {
835 new_draw_info (NDI_UNIQUE, 0, op, "This armour will not accept further enchantment."); 848 op->errormsg ("This armour will not accept further enchantment.");
836 return 0; 849 return 0;
837 } 850 }
838 851
839 /* Split objects if needed. Can't insert tmp until the 852 /* Split objects if needed. Can't insert tmp until the
840 * end of this function - otherwise it will just re-merge. 853 * end of this function - otherwise it will just re-merge.
890 { 903 {
891 esrv_send_item (op, armour); 904 esrv_send_item (op, armour);
892 if (QUERY_FLAG (armour, FLAG_APPLIED)) 905 if (QUERY_FLAG (armour, FLAG_APPLIED))
893 op->update_stats (); 906 op->update_stats ();
894 } 907 }
908
895 decrease_ob (improver); 909 decrease_ob (improver);
910
896 if (tmp) 911 if (tmp)
897 { 912 {
898 insert_ob_in_ob (tmp, op); 913 insert_ob_in_ob (tmp, op);
899 esrv_send_item (op, tmp); 914 esrv_send_item (op, tmp);
900 } 915 }
916
901 return 1; 917 return 1;
902} 918}
903 919
904/* 920/*
905 * convert_item() returns 1 if anything was converted, 0 if the item was not 921 * convert_item() returns 1 if anything was converted, 0 if the item was not
4077 4093
4078 /* Now create new item, remove used ones when required. */ 4094 /* Now create new item, remove used ones when required. */
4079 new_item = get_archetype (got); 4095 new_item = get_archetype (got);
4080 if (!new_item) 4096 if (!new_item)
4081 { 4097 {
4082 new_draw_info_format (NDI_UNIQUE, 0, pl, "This %s is strange, better to not use it.", query_base_name (marked, 0)); 4098 pl->errormsg (format ("This %s is strange, better to not use it.", query_base_name (marked, 0)));
4083 return; 4099 return;
4084 } 4100 }
4085 4101
4086 new_item->nrof = yield; 4102 new_item->nrof = yield;
4103
4087 new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); 4104 pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0)));
4105
4088 insert_ob_in_ob (new_item, pl); 4106 insert_ob_in_ob (new_item, pl);
4089 esrv_send_inventory (pl, pl); 4107 esrv_send_inventory (pl, pl);
4090 /* Eat up one item */ 4108 /* Eat up one item */
4091 decrease_ob_nr (marked, 1); 4109 decrease_ob_nr (marked, 1);
4092 4110
4093 /* Eat one transformer if needed */ 4111 /* Eat one transformer if needed */
4094 if (transformer->stats.food) 4112 if (transformer->stats.food)
4095 if (--transformer->stats.food == 0) 4113 if (--transformer->stats.food == 0)
4096 decrease_ob_nr (transformer, 1); 4114 decrease_ob_nr (transformer, 1);
4097} 4115}
4116

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines