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.142 by root, Sun Apr 13 20:21:50 2008 UTC vs.
Revision 1.144 by root, Mon Apr 21 06:35:26 2008 UTC

217 217
218 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 218 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
219 { 219 {
220 op->drain_stat (); 220 op->drain_stat ();
221 op->update_stats (); 221 op->update_stats ();
222 decrease_ob (tmp); 222 tmp->decrease ();
223 return 1; 223 return 1;
224 } 224 }
225 225
226 if (!(at = archetype::find (ARCH_DEPLETION))) 226 if (!(at = archetype::find (ARCH_DEPLETION)))
227 { 227 {
240 op->update_stats (); 240 op->update_stats ();
241 } 241 }
242 else 242 else
243 op->statusmsg ("Your potion had no effect."); 243 op->statusmsg ("Your potion had no effect.");
244 244
245 decrease_ob (tmp); 245 tmp->decrease ();
246 return 1; 246 return 1;
247 } 247 }
248 248
249 /* improvement potion - only for players */ 249 /* improvement potion - only for players */
250 if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) 250 if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER))
318 } 318 }
319 else 319 else
320 op->statusmsg ("You are fortunate that you are so pathetic.", NDI_DK_ORANGE); 320 op->statusmsg ("You are fortunate that you are so pathetic.", NDI_DK_ORANGE);
321 } 321 }
322 322
323 decrease_ob (tmp); 323 tmp->decrease ();
324 return 1; 324 return 1;
325 } 325 }
326 326
327 327
328 /* A potion that casts a spell. Healing, restore spellpoint (power potion) 328 /* A potion that casts a spell. Healing, restore spellpoint (power potion)
347 insert_ob_in_map (fball, op->map, NULL, 0); 347 insert_ob_in_map (fball, op->map, NULL, 0);
348 } 348 }
349 else 349 else
350 cast_spell (op, tmp, op->facing, tmp->inv, NULL); 350 cast_spell (op, tmp, op->facing, tmp->inv, NULL);
351 351
352 decrease_ob (tmp); 352 tmp->decrease ();
353 353
354 /* if youre dead, no point in doing this... */ 354 /* if youre dead, no point in doing this... */
355 if (!QUERY_FLAG (op, FLAG_REMOVED)) 355 if (!QUERY_FLAG (op, FLAG_REMOVED))
356 op->update_stats (); 356 op->update_stats ();
357 357
388 force->speed_left = -1; 388 force->speed_left = -1;
389 force = insert_ob_in_ob (force, op); 389 force = insert_ob_in_ob (force, op);
390 CLEAR_FLAG (tmp, FLAG_APPLIED); 390 CLEAR_FLAG (tmp, FLAG_APPLIED);
391 SET_FLAG (force, FLAG_APPLIED); 391 SET_FLAG (force, FLAG_APPLIED);
392 change_abil (op, force); 392 change_abil (op, force);
393 decrease_ob (tmp); 393 tmp->decrease ();
394 return 1; 394 return 1;
395 } 395 }
396 396
397 /* Only thing left are the stat potions */ 397 /* Only thing left are the stat potions */
398 if (op->type == PLAYER) 398 if (op->type == PLAYER)
411 * stat will not be raised by them. fix_player just clears 411 * stat will not be raised by them. fix_player just clears
412 * up all the stats. 412 * up all the stats.
413 */ 413 */
414 CLEAR_FLAG (tmp, FLAG_APPLIED); 414 CLEAR_FLAG (tmp, FLAG_APPLIED);
415 op->update_stats (); 415 op->update_stats ();
416 decrease_ob (tmp); 416 op->decrease ();
417 return 1; 417 return 1;
418} 418}
419 419
420/**************************************************************************** 420/****************************************************************************
421 * Weapon improvement code follows 421 * Weapon improvement code follows
468 { 468 {
469 if (strcmp (op->arch->archname, item) == 0) 469 if (strcmp (op->arch->archname, item) == 0)
470 { 470 {
471 if (op->nrof >= nrof) 471 if (op->nrof >= nrof)
472 { 472 {
473 decrease_ob_nr (op, nrof); 473 op->decrease (nrof);
474 return; 474 return;
475 } 475 }
476 else 476 else
477 { 477 {
478 decrease_ob_nr (op, op->nrof); 478 op->decrease (nrof);
479 nrof -= op->nrof; 479 nrof -= op->nrof;
480 } 480 }
481 481
482 op = prev; 482 op = prev;
483 } 483 }
568static int 568static int
569improve_weapon_stat (object *op, object *improver, object *weapon, sint8 &stat, int sacrifice_count, const char *statname) 569improve_weapon_stat (object *op, object *improver, object *weapon, sint8 &stat, int sacrifice_count, const char *statname)
570{ 570{
571 stat += sacrifice_count; 571 stat += sacrifice_count;
572 weapon->last_eat++; 572 weapon->last_eat++;
573 decrease_ob (improver); 573 improver->decrease ();
574 574
575 /* So it updates the players stats and the window */ 575 /* So it updates the players stats and the window */
576 op->update_stats (); 576 op->update_stats ();
577 577
578 op->statusmsg (format ( 578 op->statusmsg (format (
646 646
647 sprintf (buf, "%s's %s", &op->name, &weapon->name); 647 sprintf (buf, "%s's %s", &op->name, &weapon->name);
648 weapon->name = weapon->name_pl = buf; 648 weapon->name = weapon->name_pl = buf;
649 weapon->nrof = 0; /* prevents preparing n weapons in the same 649 weapon->nrof = 0; /* prevents preparing n weapons in the same
650 slot at once! */ 650 slot at once! */
651 decrease_ob (improver); 651 improver->decrease ();
652 weapon->last_eat = 0; 652 weapon->last_eat = 0;
653 return 1; 653 return 1;
654} 654}
655 655
656 656
704 weapon->weight += 5000; /* 5 KG's */ 704 weapon->weight += 5000; /* 5 KG's */
705 op->statusmsg (format ("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));
706 weapon->last_eat++; 706 weapon->last_eat++;
707 707
708 weapon->item_power++; 708 weapon->item_power++;
709 decrease_ob (improver); 709 improver->decrease ();
710 return 1; 710 return 1;
711 } 711 }
712 712
713 if (improver->stats.sp == IMPROVE_WEIGHT) 713 if (improver->stats.sp == IMPROVE_WEIGHT)
714 { 714 {
718 weapon->weight = 1; 718 weapon->weight = 1;
719 719
720 op->statusmsg (format ("Weapon weight reduced to %6.1fkg.", (float) weapon->weight / 1000.0)); 720 op->statusmsg (format ("Weapon weight reduced to %6.1fkg.", (float) weapon->weight / 1000.0));
721 weapon->last_eat++; 721 weapon->last_eat++;
722 weapon->item_power++; 722 weapon->item_power++;
723 decrease_ob (improver); 723 improver->decrease ();
724 return 1; 724 return 1;
725 } 725 }
726 if (improver->stats.sp == IMPROVE_ENCHANT) 726 if (improver->stats.sp == IMPROVE_ENCHANT)
727 { 727 {
728 weapon->magic++; 728 weapon->magic++;
729 weapon->last_eat++; 729 weapon->last_eat++;
730 op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic)); 730 op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic));
731 decrease_ob (improver); 731 improver->decrease ();
732 weapon->item_power++; 732 weapon->item_power++;
733 return 1; 733 return 1;
734 } 734 }
735 735
736 sacrifice_needed = weapon->stats.Str + weapon->stats.Int + weapon->stats.Dex + 736 sacrifice_needed = weapon->stats.Str + weapon->stats.Int + weapon->stats.Dex +
905 esrv_send_item (op, armour); 905 esrv_send_item (op, armour);
906 if (QUERY_FLAG (armour, FLAG_APPLIED)) 906 if (QUERY_FLAG (armour, FLAG_APPLIED))
907 op->update_stats (); 907 op->update_stats ();
908 } 908 }
909 909
910 decrease_ob (improver); 910 improver->decrease ();
911 911
912 if (tmp) 912 if (tmp)
913 { 913 {
914 insert_ob_in_ob (tmp, op); 914 insert_ob_in_ob (tmp, op);
915 esrv_send_item (op, tmp); 915 esrv_send_item (op, tmp);
955 955
956 converter->play_sound (sound_find ("shop_buy")); 956 converter->play_sound (sound_find ("shop_buy"));
957 957
958 sint64 cost = (nr * need + item->value - 1) / item->value; 958 sint64 cost = (nr * need + item->value - 1) / item->value;
959 959
960 decrease_ob_nr (item, cost); 960 item->decrease (cost);
961 961
962 price_in = cost * item->value; 962 price_in = cost * item->value;
963 } 963 }
964 else 964 else
965 { 965 {
971 converter->play_sound (sound_find ("convert_item")); 971 converter->play_sound (sound_find ("convert_item"));
972 972
973 if (need) 973 if (need)
974 { 974 {
975 nr = sint64 (item->nrof) / need; 975 nr = sint64 (item->nrof) / need;
976 decrease_ob_nr (item, nr * need); 976 item->decrease (nr * need);
977 price_in = nr * need * item->value; 977 price_in = nr * need * item->value;
978 } 978 }
979 else 979 else
980 { 980 {
981 price_in = item->value; 981 price_in = item->value;
1448 1448
1449 if (!trap->value) 1449 if (!trap->value)
1450 { 1450 {
1451 int tot; 1451 int tot;
1452 1452
1453 for (ab = trap->above, tot = 0; ab != NULL; ab = ab->above) 1453 for (ab = trap->above, tot = 0; ab; ab = ab->above)
1454 if ((ab->move_type && trap->move_on) || ab->move_type == 0) 1454 if ((ab->move_type && trap->move_on) || ab->move_type == 0)
1455 tot += (ab->nrof ? ab->nrof : 1) * ab->weight + ab->carrying; 1455 tot += ab->head_ ()->total_weight ();
1456 1456
1457 if (!(trap->value = (tot > trap->weight) ? 1 : 0)) 1457 if (!(trap->value = (tot > trap->weight) ? 1 : 0))
1458 goto leave; 1458 goto leave;
1459 1459
1460 SET_ANIMATION (trap, trap->value); 1460 SET_ANIMATION (trap, trap->value);
1664 op->play_sound (sound_find ("generic_fail")); 1664 op->play_sound (sound_find ("generic_fail"));
1665 op->failmsg (format ("You already possess the knowledge held within the %s.", query_name (tmp))); 1665 op->failmsg (format ("You already possess the knowledge held within the %s.", query_name (tmp)));
1666 break; 1666 break;
1667 1667
1668 case 1: 1668 case 1:
1669 decrease_ob (tmp); 1669 tmp->decrease ();
1670 op->play_sound (sound_find ("skill_learn")); 1670 op->play_sound (sound_find ("skill_learn"));
1671 op->statusmsg (format ("You succeed in learning %s", &tmp->skill)); 1671 op->statusmsg (format ("You succeed in learning %s", &tmp->skill));
1672 break; 1672 break;
1673 1673
1674 default: 1674 default:
1675 decrease_ob (tmp); 1675 tmp->decrease ();
1676 op->play_sound (sound_find ("generic_fail")); 1676 op->play_sound (sound_find ("generic_fail"));
1677 op->failmsg (format ("You fail to learn the knowledge of the %s.\n", query_name (tmp))); 1677 op->failmsg (format ("You fail to learn the knowledge of the %s.\n", query_name (tmp)));
1678 break; 1678 break;
1679 } 1679 }
1680} 1680}
1871 { 1871 {
1872 op->contr->play_sound (sound_find ("fumble_spell")); 1872 op->contr->play_sound (sound_find ("fumble_spell"));
1873 op->failmsg ("You fail to learn the spell. H<Wis (priests) or Int (wizards) governs the chance of learning a prayer or spell.>\n"); 1873 op->failmsg ("You fail to learn the spell. H<Wis (priests) or Int (wizards) governs the chance of learning a prayer or spell.>\n");
1874 } 1874 }
1875 1875
1876 decrease_ob (tmp); 1876 tmp->decrease ();
1877} 1877}
1878 1878
1879/** 1879/**
1880 * Handles applying a spell scroll. 1880 * Handles applying a spell scroll.
1881 */ 1881 */
1920 identify (tmp); 1920 identify (tmp);
1921 1921
1922 op->statusmsg (format ("The scroll of %s turns to dust.", &tmp->inv->name)); 1922 op->statusmsg (format ("The scroll of %s turns to dust.", &tmp->inv->name));
1923 1923
1924 cast_spell (op, tmp, dir, tmp->inv, NULL); 1924 cast_spell (op, tmp, dir, tmp->inv, NULL);
1925 decrease_ob (tmp); 1925 tmp->decrease ();
1926} 1926}
1927 1927
1928/** 1928/**
1929 * Applies a treasure object - by default, chest. op 1929 * Applies a treasure object - by default, chest. op
1930 * is the person doing the applying, tmp is the treasure 1930 * is the person doing the applying, tmp is the treasure
1942 object *treas = tmp->inv; 1942 object *treas = tmp->inv;
1943 1943
1944 if (!treas) 1944 if (!treas)
1945 { 1945 {
1946 op->statusmsg ("The chest was empty."); 1946 op->statusmsg ("The chest was empty.");
1947 decrease_ob (tmp); 1947 tmp->decrease ();
1948 return; 1948 return;
1949 } 1949 }
1950 1950
1951 while (tmp->inv) 1951 while (tmp->inv)
1952 { 1952 {
1968 if (op->destroyed () || tmp->destroyed ()) 1968 if (op->destroyed () || tmp->destroyed ())
1969 break; 1969 break;
1970 } 1970 }
1971 1971
1972 if (!tmp->destroyed () && !tmp->inv) 1972 if (!tmp->destroyed () && !tmp->inv)
1973 decrease_ob (tmp); 1973 tmp->decrease ();
1974} 1974}
1975 1975
1976/** 1976/**
1977 * op eats food. 1977 * op eats food.
1978 * If player, takes care of messages and dragon special food. 1978 * If player, takes care of messages and dragon special food.
2044 eat_special_food (op, tmp); 2044 eat_special_food (op, tmp);
2045 } 2045 }
2046 } 2046 }
2047 2047
2048 handle_apply_yield (tmp); 2048 handle_apply_yield (tmp);
2049 decrease_ob (tmp); 2049 tmp->decrease ();
2050} 2050}
2051 2051
2052/** 2052/**
2053 * A dragon is eating some flesh. If the flesh contains resistances, 2053 * A dragon is eating some flesh. If the flesh contains resistances,
2054 * there is a chance for the dragon's skin to get improved. 2054 * there is a chance for the dragon's skin to get improved.
2260 hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); 2260 hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1);
2261 } 2261 }
2262 2262
2263 op->stats.food -= op->stats.food / 4; 2263 op->stats.food -= op->stats.food / 4;
2264 handle_apply_yield (tmp); 2264 handle_apply_yield (tmp);
2265 decrease_ob (tmp); 2265 tmp->decrease ();
2266} 2266}
2267 2267
2268/** 2268/**
2269 * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit. 2269 * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit.
2270 * A valid 2 way exit means: 2270 * A valid 2 way exit means:
4101 pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0))); 4101 pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0)));
4102 4102
4103 insert_ob_in_ob (new_item, pl); 4103 insert_ob_in_ob (new_item, pl);
4104 esrv_send_inventory (pl, pl); 4104 esrv_send_inventory (pl, pl);
4105 /* Eat up one item */ 4105 /* Eat up one item */
4106 decrease_ob_nr (marked, 1); 4106 marked->decrease ();
4107 4107
4108 /* Eat one transformer if needed */ 4108 /* Eat one transformer if needed */
4109 if (transformer->stats.food) 4109 if (transformer->stats.food)
4110 if (--transformer->stats.food == 0) 4110 if (--transformer->stats.food == 0)
4111 decrease_ob_nr (transformer, 1); 4111 transformer->decrease ();
4112} 4112}
4113 4113

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines