1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra 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 | * Deliantra 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 |
… | |
… | |
163 | handle_apply_yield (object *tmp) |
163 | handle_apply_yield (object *tmp) |
164 | { |
164 | { |
165 | const char *yield; |
165 | const char *yield; |
166 | |
166 | |
167 | yield = get_ob_key_value (tmp, "on_use_yield"); |
167 | yield = get_ob_key_value (tmp, "on_use_yield"); |
|
|
168 | |
168 | if (yield != NULL) |
169 | if (yield) |
169 | { |
170 | get_archetype (yield)->insert_at (tmp, tmp, INS_BELOW_ORIGINATOR); |
170 | object *drop = get_archetype (yield); |
|
|
171 | |
|
|
172 | if (tmp->env) |
|
|
173 | { |
|
|
174 | drop = insert_ob_in_ob (drop, tmp->env); |
|
|
175 | if (tmp->env->type == PLAYER) |
|
|
176 | esrv_send_item (tmp->env, drop); |
|
|
177 | } |
|
|
178 | else |
|
|
179 | { |
|
|
180 | drop->x = tmp->x; |
|
|
181 | drop->y = tmp->y; |
|
|
182 | insert_ob_in_map (drop, tmp->map, tmp, INS_BELOW_ORIGINATOR); |
|
|
183 | } |
|
|
184 | } |
|
|
185 | } |
171 | } |
186 | |
172 | |
187 | /** |
173 | /** |
188 | * Handles applying a potion. |
174 | * Handles applying a potion. |
189 | */ |
175 | */ |
… | |
… | |
217 | |
203 | |
218 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
204 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
219 | { |
205 | { |
220 | op->drain_stat (); |
206 | op->drain_stat (); |
221 | op->update_stats (); |
207 | op->update_stats (); |
222 | decrease_ob (tmp); |
208 | tmp->decrease (); |
223 | return 1; |
209 | return 1; |
224 | } |
210 | } |
225 | |
211 | |
226 | if (!(at = archetype::find (ARCH_DEPLETION))) |
212 | if (!(at = archetype::find (ARCH_DEPLETION))) |
227 | { |
213 | { |
228 | LOG (llevError, "Could not find archetype depletion\n"); |
214 | LOG (llevError, "Could not find archetype depletion\n"); |
229 | return 0; |
215 | return 0; |
230 | } |
216 | } |
|
|
217 | |
231 | depl = present_arch_in_ob (at, op); |
218 | depl = present_arch_in_ob (at, op); |
232 | |
219 | |
233 | if (depl) |
220 | if (depl) |
234 | { |
221 | { |
235 | for (i = 0; i < NUM_STATS; i++) |
222 | for (i = 0; i < NUM_STATS; i++) |
… | |
… | |
240 | op->update_stats (); |
227 | op->update_stats (); |
241 | } |
228 | } |
242 | else |
229 | else |
243 | op->statusmsg ("Your potion had no effect."); |
230 | op->statusmsg ("Your potion had no effect."); |
244 | |
231 | |
245 | decrease_ob (tmp); |
232 | tmp->decrease (); |
246 | return 1; |
233 | return 1; |
247 | } |
234 | } |
248 | |
235 | |
249 | /* improvement potion - only for players */ |
236 | /* improvement potion - only for players */ |
250 | if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) |
237 | if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) |
… | |
… | |
318 | } |
305 | } |
319 | else |
306 | else |
320 | op->statusmsg ("You are fortunate that you are so pathetic.", NDI_DK_ORANGE); |
307 | op->statusmsg ("You are fortunate that you are so pathetic.", NDI_DK_ORANGE); |
321 | } |
308 | } |
322 | |
309 | |
323 | decrease_ob (tmp); |
310 | tmp->decrease (); |
324 | return 1; |
311 | return 1; |
325 | } |
312 | } |
326 | |
313 | |
327 | |
314 | |
328 | /* A potion that casts a spell. Healing, restore spellpoint (power potion) |
315 | /* A potion that casts a spell. Healing, restore spellpoint (power potion) |
… | |
… | |
347 | insert_ob_in_map (fball, op->map, NULL, 0); |
334 | insert_ob_in_map (fball, op->map, NULL, 0); |
348 | } |
335 | } |
349 | else |
336 | else |
350 | cast_spell (op, tmp, op->facing, tmp->inv, NULL); |
337 | cast_spell (op, tmp, op->facing, tmp->inv, NULL); |
351 | |
338 | |
352 | decrease_ob (tmp); |
339 | tmp->decrease (); |
353 | |
340 | |
354 | /* if youre dead, no point in doing this... */ |
341 | /* if youre dead, no point in doing this... */ |
355 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
342 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
356 | op->update_stats (); |
343 | op->update_stats (); |
357 | |
344 | |
… | |
… | |
388 | force->speed_left = -1; |
375 | force->speed_left = -1; |
389 | force = insert_ob_in_ob (force, op); |
376 | force = insert_ob_in_ob (force, op); |
390 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
377 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
391 | SET_FLAG (force, FLAG_APPLIED); |
378 | SET_FLAG (force, FLAG_APPLIED); |
392 | change_abil (op, force); |
379 | change_abil (op, force); |
393 | decrease_ob (tmp); |
380 | tmp->decrease (); |
394 | return 1; |
381 | return 1; |
395 | } |
382 | } |
396 | |
383 | |
397 | /* Only thing left are the stat potions */ |
384 | /* Only thing left are the stat potions */ |
398 | if (op->type == PLAYER) |
385 | if (op->type == PLAYER) |
… | |
… | |
411 | * stat will not be raised by them. fix_player just clears |
398 | * stat will not be raised by them. fix_player just clears |
412 | * up all the stats. |
399 | * up all the stats. |
413 | */ |
400 | */ |
414 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
401 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
415 | op->update_stats (); |
402 | op->update_stats (); |
416 | decrease_ob (tmp); |
403 | tmp->decrease (); |
417 | return 1; |
404 | return 1; |
418 | } |
405 | } |
419 | |
406 | |
420 | /**************************************************************************** |
407 | /**************************************************************************** |
421 | * Weapon improvement code follows |
408 | * Weapon improvement code follows |
… | |
… | |
468 | { |
455 | { |
469 | if (strcmp (op->arch->archname, item) == 0) |
456 | if (strcmp (op->arch->archname, item) == 0) |
470 | { |
457 | { |
471 | if (op->nrof >= nrof) |
458 | if (op->nrof >= nrof) |
472 | { |
459 | { |
473 | decrease_ob_nr (op, nrof); |
460 | op->decrease (nrof); |
474 | return; |
461 | return; |
475 | } |
462 | } |
476 | else |
463 | else |
477 | { |
464 | { |
478 | decrease_ob_nr (op, op->nrof); |
465 | op->decrease (nrof); |
479 | nrof -= op->nrof; |
466 | nrof -= op->nrof; |
480 | } |
467 | } |
481 | |
468 | |
482 | op = prev; |
469 | op = prev; |
483 | } |
470 | } |
… | |
… | |
568 | static int |
555 | static int |
569 | improve_weapon_stat (object *op, object *improver, object *weapon, sint8 &stat, int sacrifice_count, const char *statname) |
556 | improve_weapon_stat (object *op, object *improver, object *weapon, sint8 &stat, int sacrifice_count, const char *statname) |
570 | { |
557 | { |
571 | stat += sacrifice_count; |
558 | stat += sacrifice_count; |
572 | weapon->last_eat++; |
559 | weapon->last_eat++; |
573 | decrease_ob (improver); |
560 | improver->decrease (); |
574 | |
561 | |
575 | /* So it updates the players stats and the window */ |
562 | /* So it updates the players stats and the window */ |
576 | op->update_stats (); |
563 | op->update_stats (); |
577 | |
564 | |
578 | op->statusmsg (format ( |
565 | op->statusmsg (format ( |
… | |
… | |
646 | |
633 | |
647 | sprintf (buf, "%s's %s", &op->name, &weapon->name); |
634 | sprintf (buf, "%s's %s", &op->name, &weapon->name); |
648 | weapon->name = weapon->name_pl = buf; |
635 | weapon->name = weapon->name_pl = buf; |
649 | weapon->nrof = 0; /* prevents preparing n weapons in the same |
636 | weapon->nrof = 0; /* prevents preparing n weapons in the same |
650 | slot at once! */ |
637 | slot at once! */ |
651 | decrease_ob (improver); |
638 | improver->decrease (); |
652 | weapon->last_eat = 0; |
639 | weapon->last_eat = 0; |
653 | return 1; |
640 | return 1; |
654 | } |
641 | } |
655 | |
|
|
656 | |
642 | |
657 | /** |
643 | /** |
658 | * Does the dirty job for 'improve weapon' scroll, prepare or add something. |
644 | * Does the dirty job for 'improve weapon' scroll, prepare or add something. |
659 | * This is the new improve weapon code. |
645 | * This is the new improve weapon code. |
660 | * Returns 0 if it was not able to work for some reason. |
646 | * Returns 0 if it was not able to work for some reason. |
… | |
… | |
704 | weapon->weight += 5000; /* 5 KG's */ |
690 | weapon->weight += 5000; /* 5 KG's */ |
705 | op->statusmsg (format ("Damage has been increased by 5 to %d.", weapon->stats.dam)); |
691 | op->statusmsg (format ("Damage has been increased by 5 to %d.", weapon->stats.dam)); |
706 | weapon->last_eat++; |
692 | weapon->last_eat++; |
707 | |
693 | |
708 | weapon->item_power++; |
694 | weapon->item_power++; |
709 | decrease_ob (improver); |
695 | improver->decrease (); |
710 | return 1; |
696 | return 1; |
711 | } |
697 | } |
712 | |
698 | |
713 | if (improver->stats.sp == IMPROVE_WEIGHT) |
699 | if (improver->stats.sp == IMPROVE_WEIGHT) |
714 | { |
700 | { |
… | |
… | |
718 | weapon->weight = 1; |
704 | weapon->weight = 1; |
719 | |
705 | |
720 | op->statusmsg (format ("Weapon weight reduced to %6.1fkg.", (float) weapon->weight / 1000.0)); |
706 | op->statusmsg (format ("Weapon weight reduced to %6.1fkg.", (float) weapon->weight / 1000.0)); |
721 | weapon->last_eat++; |
707 | weapon->last_eat++; |
722 | weapon->item_power++; |
708 | weapon->item_power++; |
723 | decrease_ob (improver); |
709 | improver->decrease (); |
724 | return 1; |
710 | return 1; |
725 | } |
711 | } |
726 | if (improver->stats.sp == IMPROVE_ENCHANT) |
712 | if (improver->stats.sp == IMPROVE_ENCHANT) |
727 | { |
713 | { |
728 | weapon->magic++; |
714 | weapon->magic++; |
729 | weapon->last_eat++; |
715 | weapon->last_eat++; |
730 | op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic)); |
716 | op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic)); |
731 | decrease_ob (improver); |
717 | improver->decrease (); |
732 | weapon->item_power++; |
718 | weapon->item_power++; |
733 | return 1; |
719 | return 1; |
734 | } |
720 | } |
735 | |
721 | |
736 | sacrifice_needed = weapon->stats.Str + weapon->stats.Int + weapon->stats.Dex + |
722 | sacrifice_needed = weapon->stats.Str + weapon->stats.Int + weapon->stats.Dex + |
… | |
… | |
851 | } |
837 | } |
852 | |
838 | |
853 | /* Split objects if needed. Can't insert tmp until the |
839 | /* Split objects if needed. Can't insert tmp until the |
854 | * end of this function - otherwise it will just re-merge. |
840 | * end of this function - otherwise it will just re-merge. |
855 | */ |
841 | */ |
856 | if (armour->nrof > 1) |
842 | tmp = armour->nrof > 1 ? armour->split (armour->nrof - 1) : 0; |
857 | tmp = get_split_ob (armour, armour->nrof - 1); |
|
|
858 | else |
|
|
859 | tmp = NULL; |
|
|
860 | |
843 | |
861 | armour->magic++; |
844 | armour->magic++; |
862 | |
845 | |
863 | if (!settings.armor_speed_linear) |
846 | if (!settings.armor_speed_linear) |
864 | { |
847 | { |
… | |
… | |
901 | armour->item_power = get_power_from_ench (armour->arch->item_power + armour->magic); |
884 | armour->item_power = get_power_from_ench (armour->arch->item_power + armour->magic); |
902 | |
885 | |
903 | if (op->type == PLAYER) |
886 | if (op->type == PLAYER) |
904 | { |
887 | { |
905 | esrv_send_item (op, armour); |
888 | esrv_send_item (op, armour); |
|
|
889 | |
906 | if (QUERY_FLAG (armour, FLAG_APPLIED)) |
890 | if (QUERY_FLAG (armour, FLAG_APPLIED)) |
907 | op->update_stats (); |
891 | op->update_stats (); |
908 | } |
892 | } |
909 | |
893 | |
910 | decrease_ob (improver); |
894 | improver->decrease (); |
911 | |
895 | |
912 | if (tmp) |
896 | if (tmp) |
913 | { |
897 | op->insert (tmp); |
914 | insert_ob_in_ob (tmp, op); |
|
|
915 | esrv_send_item (op, tmp); |
|
|
916 | } |
|
|
917 | |
898 | |
918 | return 1; |
899 | return 1; |
919 | } |
900 | } |
920 | |
901 | |
921 | /* |
902 | /* |
… | |
… | |
955 | |
936 | |
956 | converter->play_sound (sound_find ("shop_buy")); |
937 | converter->play_sound (sound_find ("shop_buy")); |
957 | |
938 | |
958 | sint64 cost = (nr * need + item->value - 1) / item->value; |
939 | sint64 cost = (nr * need + item->value - 1) / item->value; |
959 | |
940 | |
960 | decrease_ob_nr (item, cost); |
941 | item->decrease (cost); |
961 | |
942 | |
962 | price_in = cost * item->value; |
943 | price_in = cost * item->value; |
963 | } |
944 | } |
964 | else |
945 | else |
965 | { |
946 | { |
… | |
… | |
971 | converter->play_sound (sound_find ("convert_item")); |
952 | converter->play_sound (sound_find ("convert_item")); |
972 | |
953 | |
973 | if (need) |
954 | if (need) |
974 | { |
955 | { |
975 | nr = sint64 (item->nrof) / need; |
956 | nr = sint64 (item->nrof) / need; |
976 | decrease_ob_nr (item, nr * need); |
957 | item->decrease (nr * need); |
977 | price_in = nr * need * item->value; |
958 | price_in = nr * need * item->value; |
978 | } |
959 | } |
979 | else |
960 | else |
980 | { |
961 | { |
981 | price_in = item->value; |
962 | price_in = item->value; |
… | |
… | |
1448 | |
1429 | |
1449 | if (!trap->value) |
1430 | if (!trap->value) |
1450 | { |
1431 | { |
1451 | int tot; |
1432 | int tot; |
1452 | |
1433 | |
1453 | for (ab = trap->above, tot = 0; ab != NULL; ab = ab->above) |
1434 | for (ab = trap->above, tot = 0; ab; ab = ab->above) |
1454 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1435 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1455 | tot += (ab->nrof ? ab->nrof : 1) * ab->weight + ab->carrying; |
1436 | tot += ab->head_ ()->total_weight (); |
1456 | |
1437 | |
1457 | if (!(trap->value = (tot > trap->weight) ? 1 : 0)) |
1438 | if (!(trap->value = (tot > trap->weight) ? 1 : 0)) |
1458 | goto leave; |
1439 | goto leave; |
1459 | |
1440 | |
1460 | SET_ANIMATION (trap, trap->value); |
1441 | SET_ANIMATION (trap, trap->value); |
… | |
… | |
1637 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1618 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1638 | { |
1619 | { |
1639 | /*exp_gain *= 2; because they just identified it too */ |
1620 | /*exp_gain *= 2; because they just identified it too */ |
1640 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
1621 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
1641 | |
1622 | |
1642 | /* If in a container, update how it looks */ |
1623 | if (object *pl = tmp->visible_to ()) |
1643 | if (tmp->env) |
|
|
1644 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1624 | esrv_update_item (UPD_FLAGS | UPD_NAME, pl, tmp); |
1645 | else |
|
|
1646 | op->contr->ns->floorbox_update (); |
|
|
1647 | } |
1625 | } |
1648 | |
1626 | |
1649 | change_exp (op, exp_gain, skill_ob->skill, 0); |
1627 | change_exp (op, exp_gain, skill_ob->skill, 0); |
1650 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
1628 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
1651 | } |
1629 | } |
… | |
… | |
1664 | op->play_sound (sound_find ("generic_fail")); |
1642 | op->play_sound (sound_find ("generic_fail")); |
1665 | op->failmsg (format ("You already possess the knowledge held within the %s.", query_name (tmp))); |
1643 | op->failmsg (format ("You already possess the knowledge held within the %s.", query_name (tmp))); |
1666 | break; |
1644 | break; |
1667 | |
1645 | |
1668 | case 1: |
1646 | case 1: |
1669 | decrease_ob (tmp); |
1647 | tmp->decrease (); |
1670 | op->play_sound (sound_find ("skill_learn")); |
1648 | op->play_sound (sound_find ("skill_learn")); |
1671 | op->statusmsg (format ("You succeed in learning %s", &tmp->skill)); |
1649 | op->statusmsg (format ("You succeed in learning %s", &tmp->skill)); |
1672 | break; |
1650 | break; |
1673 | |
1651 | |
1674 | default: |
1652 | default: |
1675 | decrease_ob (tmp); |
1653 | tmp->decrease (); |
1676 | op->play_sound (sound_find ("generic_fail")); |
1654 | op->play_sound (sound_find ("generic_fail")); |
1677 | op->failmsg (format ("You fail to learn the knowledge of the %s.\n", query_name (tmp))); |
1655 | op->failmsg (format ("You fail to learn the knowledge of the %s.\n", query_name (tmp))); |
1678 | break; |
1656 | break; |
1679 | } |
1657 | } |
1680 | } |
1658 | } |
… | |
… | |
1801 | } |
1779 | } |
1802 | |
1780 | |
1803 | op->statusmsg (format ("The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name)); |
1781 | op->statusmsg (format ("The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name)); |
1804 | |
1782 | |
1805 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1783 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1806 | { |
|
|
1807 | identify (tmp); |
1784 | identify (tmp); |
1808 | |
|
|
1809 | if (tmp->env) |
|
|
1810 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
|
|
1811 | else |
|
|
1812 | op->contr->ns->floorbox_update (); |
|
|
1813 | } |
|
|
1814 | |
1785 | |
1815 | /* I removed the check for special_prayer_mark here - it didn't make |
1786 | /* I removed the check for special_prayer_mark here - it didn't make |
1816 | * a lot of sense - special prayers are not found in spellbooks, and |
1787 | * a lot of sense - special prayers are not found in spellbooks, and |
1817 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1788 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1818 | * they would have a special prayer mark. |
1789 | * they would have a special prayer mark. |
… | |
… | |
1871 | { |
1842 | { |
1872 | op->contr->play_sound (sound_find ("fumble_spell")); |
1843 | 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"); |
1844 | 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 | } |
1845 | } |
1875 | |
1846 | |
1876 | decrease_ob (tmp); |
1847 | tmp->decrease (); |
1877 | } |
1848 | } |
1878 | |
1849 | |
1879 | /** |
1850 | /** |
1880 | * Handles applying a spell scroll. |
1851 | * Handles applying a spell scroll. |
1881 | */ |
1852 | */ |
… | |
… | |
1920 | identify (tmp); |
1891 | identify (tmp); |
1921 | |
1892 | |
1922 | op->statusmsg (format ("The scroll of %s turns to dust.", &tmp->inv->name)); |
1893 | op->statusmsg (format ("The scroll of %s turns to dust.", &tmp->inv->name)); |
1923 | |
1894 | |
1924 | cast_spell (op, tmp, dir, tmp->inv, NULL); |
1895 | cast_spell (op, tmp, dir, tmp->inv, NULL); |
1925 | decrease_ob (tmp); |
1896 | tmp->decrease (); |
1926 | } |
1897 | } |
1927 | |
1898 | |
1928 | /** |
1899 | /** |
1929 | * Applies a treasure object - by default, chest. op |
1900 | * Applies a treasure object - by default, chest. op |
1930 | * is the person doing the applying, tmp is the treasure |
1901 | * is the person doing the applying, tmp is the treasure |
… | |
… | |
1942 | object *treas = tmp->inv; |
1913 | object *treas = tmp->inv; |
1943 | |
1914 | |
1944 | if (!treas) |
1915 | if (!treas) |
1945 | { |
1916 | { |
1946 | op->statusmsg ("The chest was empty."); |
1917 | op->statusmsg ("The chest was empty."); |
1947 | decrease_ob (tmp); |
1918 | tmp->decrease (); |
1948 | return; |
1919 | return; |
1949 | } |
1920 | } |
1950 | |
1921 | |
1951 | while (tmp->inv) |
1922 | while (tmp->inv) |
1952 | { |
1923 | { |
… | |
… | |
1968 | if (op->destroyed () || tmp->destroyed ()) |
1939 | if (op->destroyed () || tmp->destroyed ()) |
1969 | break; |
1940 | break; |
1970 | } |
1941 | } |
1971 | |
1942 | |
1972 | if (!tmp->destroyed () && !tmp->inv) |
1943 | if (!tmp->destroyed () && !tmp->inv) |
1973 | decrease_ob (tmp); |
1944 | tmp->decrease (); |
1974 | } |
1945 | } |
1975 | |
1946 | |
1976 | /** |
1947 | /** |
1977 | * op eats food. |
1948 | * op eats food. |
1978 | * If player, takes care of messages and dragon special food. |
1949 | * If player, takes care of messages and dragon special food. |
… | |
… | |
2044 | eat_special_food (op, tmp); |
2015 | eat_special_food (op, tmp); |
2045 | } |
2016 | } |
2046 | } |
2017 | } |
2047 | |
2018 | |
2048 | handle_apply_yield (tmp); |
2019 | handle_apply_yield (tmp); |
2049 | decrease_ob (tmp); |
2020 | tmp->decrease (); |
2050 | } |
2021 | } |
2051 | |
2022 | |
2052 | /** |
2023 | /** |
2053 | * A dragon is eating some flesh. If the flesh contains resistances, |
2024 | * A dragon is eating some flesh. If the flesh contains resistances, |
2054 | * there is a chance for the dragon's skin to get improved. |
2025 | * there is a chance for the dragon's skin to get improved. |
… | |
… | |
2260 | hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); |
2231 | hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); |
2261 | } |
2232 | } |
2262 | |
2233 | |
2263 | op->stats.food -= op->stats.food / 4; |
2234 | op->stats.food -= op->stats.food / 4; |
2264 | handle_apply_yield (tmp); |
2235 | handle_apply_yield (tmp); |
2265 | decrease_ob (tmp); |
2236 | tmp->decrease (); |
2266 | } |
2237 | } |
2267 | |
2238 | |
2268 | /** |
2239 | /** |
2269 | * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit. |
2240 | * 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: |
2241 | * A valid 2 way exit means: |
… | |
… | |
2757 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
2728 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
2758 | |
2729 | |
2759 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2730 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2760 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2731 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2761 | |
2732 | |
|
|
2733 | op->destroy (); |
|
|
2734 | who->insert (tmp2); |
|
|
2735 | who->update_stats (); |
|
|
2736 | |
2762 | if (who->contr) |
2737 | if (who->contr) |
2763 | esrv_del_item (who->contr, op->count); |
|
|
2764 | |
|
|
2765 | op->destroy (); |
|
|
2766 | insert_ob_in_ob (tmp2, who); |
|
|
2767 | who->update_stats (); |
|
|
2768 | |
|
|
2769 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
|
|
2770 | { |
2738 | { |
2771 | if (who->contr) |
2739 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2772 | { |
2740 | { |
2773 | who->failmsg ("Oops, it feels deadly cold!"); |
2741 | who->failmsg ("Oops, it feels deadly cold!"); |
2774 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2742 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2775 | } |
2743 | } |
2776 | } |
2744 | } |
2777 | |
|
|
2778 | if (who->contr) |
|
|
2779 | esrv_send_item (who, tmp2); |
|
|
2780 | } |
2745 | } |
2781 | |
2746 | |
2782 | return 1; /* otherwise, an attempt to drop causes problems */ |
2747 | return 1; /* otherwise, an attempt to drop causes problems */ |
2783 | |
2748 | |
2784 | case BOW: |
2749 | case BOW: |
… | |
… | |
2815 | default: |
2780 | default: |
2816 | who->statusmsg (format ("You unapply %s.", query_name (op))); |
2781 | who->statusmsg (format ("You unapply %s.", query_name (op))); |
2817 | break; |
2782 | break; |
2818 | } |
2783 | } |
2819 | |
2784 | |
|
|
2785 | if (aflags & AP_NO_MERGE || !merge_ob (op, 0)) |
|
|
2786 | if (object *pl = op->visible_to ()) |
|
|
2787 | esrv_send_item (pl, op); |
|
|
2788 | |
2820 | who->update_stats (); |
2789 | who->update_stats (); |
2821 | |
|
|
2822 | if (!(aflags & AP_NO_MERGE)) |
|
|
2823 | { |
|
|
2824 | object *tmp = merge_ob (op, 0); |
|
|
2825 | |
|
|
2826 | if (who->contr) |
|
|
2827 | { |
|
|
2828 | if (tmp) |
|
|
2829 | { /* it was merged */ |
|
|
2830 | esrv_del_item (who->contr, op->count); |
|
|
2831 | op = tmp; |
|
|
2832 | } |
|
|
2833 | |
|
|
2834 | esrv_send_item (who, op); |
|
|
2835 | } |
|
|
2836 | } |
|
|
2837 | |
2790 | |
2838 | return 0; |
2791 | return 0; |
2839 | } |
2792 | } |
2840 | |
2793 | |
2841 | /** |
2794 | /** |
… | |
… | |
3220 | |
3173 | |
3221 | /* Ok. We are now at the state where we can apply the new object. |
3174 | /* Ok. We are now at the state where we can apply the new object. |
3222 | * Note that we don't have the checks for can_use_... |
3175 | * Note that we don't have the checks for can_use_... |
3223 | * below - that is already taken care of by can_apply_object. |
3176 | * below - that is already taken care of by can_apply_object. |
3224 | */ |
3177 | */ |
3225 | if (op->nrof > 1) |
3178 | tmp = op->nrof > 1 ? op->split (op->nrof - 1) : 0; |
3226 | tmp = get_split_ob (op, op->nrof - 1); |
|
|
3227 | else |
|
|
3228 | tmp = 0; |
|
|
3229 | |
3179 | |
3230 | if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) || INVOKE_OBJECT (READY, who, ARG_OBJECT (op))) |
3180 | if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) || INVOKE_OBJECT (READY, who, ARG_OBJECT (op))) |
3231 | return RESULT_INT (0); |
3181 | return RESULT_INT (0); |
3232 | |
3182 | |
3233 | switch (op->type) |
3183 | switch (op->type) |
… | |
… | |
3308 | SET_FLAG (tmp2, FLAG_APPLIED); |
3258 | SET_FLAG (tmp2, FLAG_APPLIED); |
3309 | |
3259 | |
3310 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
3260 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
3311 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
3261 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
3312 | |
3262 | |
3313 | insert_ob_in_ob (tmp2, who); |
3263 | who->insert (tmp2); |
3314 | |
3264 | |
3315 | /* Remove the old lantern */ |
3265 | /* Remove the old lantern */ |
3316 | if (who->type == PLAYER) |
|
|
3317 | esrv_del_item (who->contr, op->count); |
|
|
3318 | |
|
|
3319 | op->destroy (); |
3266 | op->destroy (); |
3320 | |
3267 | |
3321 | /* insert the portion that was split off */ |
3268 | /* insert the portion that was split off */ |
3322 | if (tmp) |
3269 | if (tmp) |
3323 | { |
3270 | who->insert (tmp); |
3324 | insert_ob_in_ob (tmp, who); |
|
|
3325 | if (who->type == PLAYER) |
|
|
3326 | esrv_send_item (who, tmp); |
|
|
3327 | } |
|
|
3328 | |
3271 | |
3329 | who->update_stats (); |
3272 | who->update_stats (); |
3330 | |
3273 | |
3331 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3274 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3332 | if (who->type == PLAYER) |
3275 | if (who->type == PLAYER) |
3333 | { |
3276 | { |
3334 | who->failmsg ("Oops, it feels deadly cold! H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3277 | who->failmsg ("Oops, it feels deadly cold! H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3335 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3278 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3336 | } |
3279 | } |
3337 | |
|
|
3338 | if (who->type == PLAYER) |
|
|
3339 | esrv_send_item (who, tmp2); |
|
|
3340 | |
3280 | |
3341 | return 0; |
3281 | return 0; |
3342 | |
3282 | |
3343 | case SKILL_TOOL: |
3283 | case SKILL_TOOL: |
3344 | // applying a skill tool also readies the skill |
3284 | // applying a skill tool also readies the skill |
… | |
… | |
3504 | } |
3444 | } |
3505 | |
3445 | |
3506 | SET_FLAG (op, FLAG_APPLIED); |
3446 | SET_FLAG (op, FLAG_APPLIED); |
3507 | |
3447 | |
3508 | if (tmp) |
3448 | if (tmp) |
3509 | tmp = insert_ob_in_ob (tmp, who); |
3449 | who->insert (tmp); |
3510 | |
3450 | |
3511 | who->update_stats (); |
3451 | who->update_stats (); |
3512 | |
3452 | |
3513 | /* We exclude spell casting objects. The fire code will set the |
3453 | /* We exclude spell casting objects. The fire code will set the |
3514 | * been applied flag when they are used - until that point, |
3454 | * been applied flag when they are used - until that point, |
… | |
… | |
3525 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>" |
3465 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>" |
3526 | ); |
3466 | ); |
3527 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3467 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3528 | } |
3468 | } |
3529 | |
3469 | |
3530 | if (who->type == PLAYER) |
3470 | if (object *pl = op->visible_to ()) |
3531 | { |
|
|
3532 | /* if multiple objects were applied, update both slots */ |
|
|
3533 | if (tmp) |
|
|
3534 | esrv_send_item (who, tmp); |
|
|
3535 | |
|
|
3536 | esrv_send_item (who, op); |
3471 | esrv_send_item (pl, op); |
3537 | } |
|
|
3538 | |
3472 | |
3539 | return 0; |
3473 | return 0; |
3540 | } |
3474 | } |
3541 | |
3475 | |
3542 | int |
3476 | int |
… | |
… | |
3817 | item = find_marked_object (who); |
3751 | item = find_marked_object (who); |
3818 | if (item) |
3752 | if (item) |
3819 | { |
3753 | { |
3820 | if (lighter->last_eat && lighter->stats.food) |
3754 | if (lighter->last_eat && lighter->stats.food) |
3821 | { /* lighter gets used up */ |
3755 | { /* lighter gets used up */ |
3822 | /* Split multiple lighters if they're being used up. Otherwise * |
|
|
3823 | * one charge from each would be used up. --DAMN */ |
|
|
3824 | if (lighter->nrof > 1) |
|
|
3825 | { |
|
|
3826 | object *oneLighter = lighter->clone (); |
3756 | object *oneLighter = lighter->split (); |
3827 | |
|
|
3828 | lighter->nrof -= 1; |
|
|
3829 | oneLighter->nrof = 1; |
|
|
3830 | oneLighter->stats.food--; |
3757 | oneLighter->stats.food--; |
3831 | esrv_send_item (who, lighter); |
3758 | who->insert (oneLighter); |
3832 | oneLighter = insert_ob_in_ob (oneLighter, who); |
|
|
3833 | esrv_send_item (who, oneLighter); |
|
|
3834 | } |
|
|
3835 | else |
|
|
3836 | lighter->stats.food--; |
|
|
3837 | } |
3759 | } |
3838 | else if (lighter->last_eat) |
3760 | else if (lighter->last_eat) |
3839 | { |
3761 | { |
3840 | /* no charges left in lighter */ |
3762 | /* no charges left in lighter */ |
3841 | who->failmsg (format ("You attempt to light the %s with a used up %s.", &item->name, &lighter->name)); |
3763 | who->failmsg (format ("You attempt to light the %s with a used up %s.", &item->name, &lighter->name)); |
… | |
… | |
4098 | |
4020 | |
4099 | new_item->nrof = yield; |
4021 | new_item->nrof = yield; |
4100 | |
4022 | |
4101 | pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0))); |
4023 | pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0))); |
4102 | |
4024 | |
4103 | insert_ob_in_ob (new_item, pl); |
4025 | pl->insert (new_item); |
4104 | esrv_send_inventory (pl, pl); |
|
|
4105 | /* Eat up one item */ |
4026 | /* Eat up one item */ |
4106 | decrease_ob_nr (marked, 1); |
4027 | marked->decrease (); |
4107 | |
4028 | |
4108 | /* Eat one transformer if needed */ |
4029 | /* Eat one transformer if needed */ |
4109 | if (transformer->stats.food) |
4030 | if (transformer->stats.food) |
4110 | if (--transformer->stats.food == 0) |
4031 | if (--transformer->stats.food == 0) |
4111 | decrease_ob_nr (transformer, 1); |
4032 | transformer->decrease (); |
4112 | } |
4033 | } |
4113 | |
4034 | |