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 |
… | |
… | |
160 | * matching item. |
160 | * matching item. |
161 | **/ |
161 | **/ |
162 | void |
162 | void |
163 | handle_apply_yield (object *tmp) |
163 | handle_apply_yield (object *tmp) |
164 | { |
164 | { |
165 | const char *yield; |
165 | if (shstr yield = tmp->kv (shstr_on_use_yield)) |
166 | |
166 | archetype::get (yield)->insert_at (tmp, tmp, INS_BELOW_ORIGINATOR); |
167 | yield = get_ob_key_value (tmp, "on_use_yield"); |
|
|
168 | if (yield != NULL) |
|
|
169 | { |
|
|
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 | } |
167 | } |
186 | |
168 | |
187 | /** |
169 | /** |
188 | * Handles applying a potion. |
170 | * Handles applying a potion. |
189 | */ |
171 | */ |
… | |
… | |
217 | |
199 | |
218 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
200 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
219 | { |
201 | { |
220 | op->drain_stat (); |
202 | op->drain_stat (); |
221 | op->update_stats (); |
203 | op->update_stats (); |
222 | decrease_ob (tmp); |
204 | tmp->decrease (); |
223 | return 1; |
205 | return 1; |
224 | } |
206 | } |
225 | |
207 | |
226 | if (!(at = archetype::find (ARCH_DEPLETION))) |
208 | if (!(at = archetype::find (ARCH_DEPLETION))) |
227 | { |
209 | { |
228 | LOG (llevError, "Could not find archetype depletion\n"); |
210 | LOG (llevError, "Could not find archetype depletion\n"); |
229 | return 0; |
211 | return 0; |
230 | } |
212 | } |
|
|
213 | |
231 | depl = present_arch_in_ob (at, op); |
214 | depl = present_arch_in_ob (at, op); |
232 | |
215 | |
233 | if (depl) |
216 | if (depl) |
234 | { |
217 | { |
235 | for (i = 0; i < NUM_STATS; i++) |
218 | for (i = 0; i < NUM_STATS; i++) |
… | |
… | |
240 | op->update_stats (); |
223 | op->update_stats (); |
241 | } |
224 | } |
242 | else |
225 | else |
243 | op->statusmsg ("Your potion had no effect."); |
226 | op->statusmsg ("Your potion had no effect."); |
244 | |
227 | |
245 | decrease_ob (tmp); |
228 | tmp->decrease (); |
246 | return 1; |
229 | return 1; |
247 | } |
230 | } |
248 | |
231 | |
249 | /* improvement potion - only for players */ |
232 | /* improvement potion - only for players */ |
250 | if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) |
233 | if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) |
… | |
… | |
318 | } |
301 | } |
319 | else |
302 | else |
320 | 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); |
321 | } |
304 | } |
322 | |
305 | |
323 | decrease_ob (tmp); |
306 | tmp->decrease (); |
324 | return 1; |
307 | return 1; |
325 | } |
308 | } |
326 | |
309 | |
327 | |
310 | |
328 | /* A potion that casts a spell. Healing, restore spellpoint (power potion) |
311 | /* A potion that casts a spell. Healing, restore spellpoint (power potion) |
… | |
… | |
347 | insert_ob_in_map (fball, op->map, NULL, 0); |
330 | insert_ob_in_map (fball, op->map, NULL, 0); |
348 | } |
331 | } |
349 | else |
332 | else |
350 | cast_spell (op, tmp, op->facing, tmp->inv, NULL); |
333 | cast_spell (op, tmp, op->facing, tmp->inv, NULL); |
351 | |
334 | |
352 | decrease_ob (tmp); |
335 | tmp->decrease (); |
353 | |
336 | |
354 | /* if youre dead, no point in doing this... */ |
337 | /* if youre dead, no point in doing this... */ |
355 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
338 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
356 | op->update_stats (); |
339 | op->update_stats (); |
357 | |
340 | |
… | |
… | |
388 | force->speed_left = -1; |
371 | force->speed_left = -1; |
389 | force = insert_ob_in_ob (force, op); |
372 | force = insert_ob_in_ob (force, op); |
390 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
373 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
391 | SET_FLAG (force, FLAG_APPLIED); |
374 | SET_FLAG (force, FLAG_APPLIED); |
392 | change_abil (op, force); |
375 | change_abil (op, force); |
393 | decrease_ob (tmp); |
376 | tmp->decrease (); |
394 | return 1; |
377 | return 1; |
395 | } |
378 | } |
396 | |
379 | |
397 | /* Only thing left are the stat potions */ |
380 | /* Only thing left are the stat potions */ |
398 | if (op->type == PLAYER) |
381 | if (op->type == PLAYER) |
… | |
… | |
411 | * stat will not be raised by them. fix_player just clears |
394 | * stat will not be raised by them. fix_player just clears |
412 | * up all the stats. |
395 | * up all the stats. |
413 | */ |
396 | */ |
414 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
397 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
415 | op->update_stats (); |
398 | op->update_stats (); |
416 | decrease_ob (tmp); |
399 | tmp->decrease (); |
417 | return 1; |
400 | return 1; |
418 | } |
401 | } |
419 | |
402 | |
420 | /**************************************************************************** |
403 | /**************************************************************************** |
421 | * Weapon improvement code follows |
404 | * Weapon improvement code follows |
… | |
… | |
468 | { |
451 | { |
469 | if (strcmp (op->arch->archname, item) == 0) |
452 | if (strcmp (op->arch->archname, item) == 0) |
470 | { |
453 | { |
471 | if (op->nrof >= nrof) |
454 | if (op->nrof >= nrof) |
472 | { |
455 | { |
473 | decrease_ob_nr (op, nrof); |
456 | op->decrease (nrof); |
474 | return; |
457 | return; |
475 | } |
458 | } |
476 | else |
459 | else |
477 | { |
460 | { |
478 | decrease_ob_nr (op, op->nrof); |
461 | op->decrease (nrof); |
479 | nrof -= op->nrof; |
462 | nrof -= op->nrof; |
480 | } |
463 | } |
481 | |
464 | |
482 | op = prev; |
465 | op = prev; |
483 | } |
466 | } |
… | |
… | |
568 | static int |
551 | static int |
569 | improve_weapon_stat (object *op, object *improver, object *weapon, sint8 &stat, int sacrifice_count, const char *statname) |
552 | improve_weapon_stat (object *op, object *improver, object *weapon, sint8 &stat, int sacrifice_count, const char *statname) |
570 | { |
553 | { |
571 | stat += sacrifice_count; |
554 | stat += sacrifice_count; |
572 | weapon->last_eat++; |
555 | weapon->last_eat++; |
573 | decrease_ob (improver); |
556 | improver->decrease (); |
574 | |
557 | |
575 | /* So it updates the players stats and the window */ |
558 | /* So it updates the players stats and the window */ |
576 | op->update_stats (); |
559 | op->update_stats (); |
577 | |
560 | |
578 | op->statusmsg (format ( |
561 | op->statusmsg (format ( |
… | |
… | |
625 | weapon->stats.exp || /* speed */ |
608 | weapon->stats.exp || /* speed */ |
626 | weapon->stats.ac) /* AC - only taifu's I think */ |
609 | weapon->stats.ac) /* AC - only taifu's I think */ |
627 | { |
610 | { |
628 | op->failmsg ("You cannot prepare magic weapons. " |
611 | op->failmsg ("You cannot prepare magic weapons. " |
629 | "H<A weapon is considered magical if it changes regeneration, " |
612 | "H<A weapon is considered magical if it changes regeneration, " |
630 | "speed or ac.>"); |
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) |
… | |
… | |
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. |
… | |
… | |
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 + |
… | |
… | |
785 | op->failmsg ("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->failmsg ("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 | } |
… | |
… | |
851 | } |
835 | } |
852 | |
836 | |
853 | /* Split objects if needed. Can't insert tmp until the |
837 | /* Split objects if needed. Can't insert tmp until the |
854 | * end of this function - otherwise it will just re-merge. |
838 | * end of this function - otherwise it will just re-merge. |
855 | */ |
839 | */ |
856 | if (armour->nrof > 1) |
840 | 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 | |
841 | |
861 | armour->magic++; |
842 | armour->magic++; |
862 | |
843 | |
863 | if (!settings.armor_speed_linear) |
844 | if (!settings.armor_speed_linear) |
864 | { |
845 | { |
… | |
… | |
901 | 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); |
902 | |
883 | |
903 | if (op->type == PLAYER) |
884 | if (op->type == PLAYER) |
904 | { |
885 | { |
905 | esrv_send_item (op, armour); |
886 | esrv_send_item (op, armour); |
|
|
887 | |
906 | if (QUERY_FLAG (armour, FLAG_APPLIED)) |
888 | if (QUERY_FLAG (armour, FLAG_APPLIED)) |
907 | op->update_stats (); |
889 | op->update_stats (); |
908 | } |
890 | } |
909 | |
891 | |
910 | decrease_ob (improver); |
892 | improver->decrease (); |
911 | |
893 | |
912 | if (tmp) |
894 | if (tmp) |
913 | { |
895 | op->insert (tmp); |
914 | insert_ob_in_ob (tmp, op); |
|
|
915 | esrv_send_item (op, tmp); |
|
|
916 | } |
|
|
917 | |
896 | |
918 | return 1; |
897 | return 1; |
919 | } |
898 | } |
920 | |
899 | |
921 | /* |
900 | /* |
… | |
… | |
955 | |
934 | |
956 | converter->play_sound (sound_find ("shop_buy")); |
935 | converter->play_sound (sound_find ("shop_buy")); |
957 | |
936 | |
958 | sint64 cost = (nr * need + item->value - 1) / item->value; |
937 | sint64 cost = (nr * need + item->value - 1) / item->value; |
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 | { |
… | |
… | |
971 | converter->play_sound (sound_find ("convert_item")); |
950 | converter->play_sound (sound_find ("convert_item")); |
972 | |
951 | |
973 | if (need) |
952 | if (need) |
974 | { |
953 | { |
975 | nr = sint64 (item->nrof) / need; |
954 | nr = sint64 (item->nrof) / need; |
976 | decrease_ob_nr (item, nr * need); |
955 | item->decrease (nr * need); |
977 | price_in = nr * need * item->value; |
956 | price_in = nr * need * item->value; |
978 | } |
957 | } |
979 | else |
958 | else |
980 | { |
959 | { |
981 | price_in = item->value; |
960 | price_in = item->value; |
… | |
… | |
993 | ob_to_copy = converter->inv; |
972 | ob_to_copy = converter->inv; |
994 | 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++) |
995 | if (rndm (0, i) == 0) |
974 | if (rndm (0, i) == 0) |
996 | ob_to_copy = ob; |
975 | ob_to_copy = ob; |
997 | |
976 | |
998 | item = object_create_clone (ob_to_copy); |
977 | item = ob_to_copy->deep_clone (); |
999 | CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); |
978 | CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); |
1000 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
979 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
1001 | } |
980 | } |
1002 | else |
981 | else |
1003 | { |
982 | { |
… | |
… | |
1028 | * 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 |
1029 | * hopefully had something in mind when doing this. |
1008 | * hopefully had something in mind when doing this. |
1030 | */ |
1009 | */ |
1031 | } |
1010 | } |
1032 | |
1011 | |
1033 | 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 | |
1034 | 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); |
1035 | return 1; |
1018 | return 1; |
1036 | } |
1019 | } |
1037 | |
1020 | |
1038 | /** |
1021 | /** |
… | |
… | |
1448 | |
1431 | |
1449 | if (!trap->value) |
1432 | if (!trap->value) |
1450 | { |
1433 | { |
1451 | int tot; |
1434 | int tot; |
1452 | |
1435 | |
1453 | for (ab = trap->above, tot = 0; ab != NULL; ab = ab->above) |
1436 | for (ab = trap->above, tot = 0; ab; ab = ab->above) |
1454 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1437 | if ((ab->move_type && trap->move_on) || ab->move_type == 0) |
1455 | tot += (ab->nrof ? ab->nrof : 1) * ab->weight + ab->carrying; |
1438 | tot += ab->head_ ()->total_weight (); |
1456 | |
1439 | |
1457 | if (!(trap->value = (tot > trap->weight) ? 1 : 0)) |
1440 | if (!(trap->value = (tot > trap->weight) ? 1 : 0)) |
1458 | goto leave; |
1441 | goto leave; |
1459 | |
1442 | |
1460 | SET_ANIMATION (trap, trap->value); |
1443 | SET_ANIMATION (trap, trap->value); |
… | |
… | |
1485 | |
1468 | |
1486 | case CONVERTER: |
1469 | case CONVERTER: |
1487 | if (convert_item (victim, trap) < 0) |
1470 | if (convert_item (victim, trap) < 0) |
1488 | { |
1471 | { |
1489 | originator->failmsg (format ("The %s seems to be broken!", query_name (trap))); |
1472 | originator->failmsg (format ("The %s seems to be broken!", query_name (trap))); |
1490 | get_archetype ("burnout")->insert_at (trap, trap); |
1473 | archetype::get (shstr_burnout)->insert_at (trap, trap); |
1491 | } |
1474 | } |
1492 | |
1475 | |
1493 | goto leave; |
1476 | goto leave; |
1494 | |
1477 | |
1495 | case TRIGGER_BUTTON: |
1478 | case TRIGGER_BUTTON: |
… | |
… | |
1637 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1620 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1638 | { |
1621 | { |
1639 | /*exp_gain *= 2; because they just identified it too */ |
1622 | /*exp_gain *= 2; because they just identified it too */ |
1640 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
1623 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
1641 | |
1624 | |
1642 | /* If in a container, update how it looks */ |
1625 | if (object *pl = tmp->visible_to ()) |
1643 | if (tmp->env) |
|
|
1644 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1626 | esrv_update_item (UPD_FLAGS | UPD_NAME, pl, tmp); |
1645 | else |
|
|
1646 | op->contr->ns->floorbox_update (); |
|
|
1647 | } |
1627 | } |
1648 | |
1628 | |
1649 | change_exp (op, exp_gain, skill_ob->skill, 0); |
1629 | 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 */ |
1630 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
1651 | } |
1631 | } |
… | |
… | |
1664 | op->play_sound (sound_find ("generic_fail")); |
1644 | op->play_sound (sound_find ("generic_fail")); |
1665 | op->failmsg (format ("You already possess the knowledge held within the %s.", query_name (tmp))); |
1645 | op->failmsg (format ("You already possess the knowledge held within the %s.", query_name (tmp))); |
1666 | break; |
1646 | break; |
1667 | |
1647 | |
1668 | case 1: |
1648 | case 1: |
1669 | decrease_ob (tmp); |
1649 | tmp->decrease (); |
1670 | op->play_sound (sound_find ("skill_learn")); |
1650 | op->play_sound (sound_find ("skill_learn")); |
1671 | op->statusmsg (format ("You succeed in learning %s", &tmp->skill)); |
1651 | op->statusmsg (format ("You succeed in learning %s", &tmp->skill)); |
1672 | break; |
1652 | break; |
1673 | |
1653 | |
1674 | default: |
1654 | default: |
1675 | decrease_ob (tmp); |
1655 | tmp->decrease (); |
1676 | op->play_sound (sound_find ("generic_fail")); |
1656 | op->play_sound (sound_find ("generic_fail")); |
1677 | op->failmsg (format ("You fail to learn the knowledge of the %s.\n", query_name (tmp))); |
1657 | op->failmsg (format ("You fail to learn the knowledge of the %s.\n", query_name (tmp))); |
1678 | break; |
1658 | break; |
1679 | } |
1659 | } |
1680 | } |
1660 | } |
… | |
… | |
1801 | } |
1781 | } |
1802 | |
1782 | |
1803 | op->statusmsg (format ("The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name)); |
1783 | op->statusmsg (format ("The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name)); |
1804 | |
1784 | |
1805 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1785 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1806 | { |
|
|
1807 | identify (tmp); |
1786 | 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 | |
1787 | |
1815 | /* I removed the check for special_prayer_mark here - it didn't make |
1788 | /* 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 |
1789 | * 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 |
1790 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1818 | * they would have a special prayer mark. |
1791 | * they would have a special prayer mark. |
… | |
… | |
1871 | { |
1844 | { |
1872 | op->contr->play_sound (sound_find ("fumble_spell")); |
1845 | 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"); |
1846 | 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 | } |
1847 | } |
1875 | |
1848 | |
1876 | decrease_ob (tmp); |
1849 | tmp->decrease (); |
1877 | } |
1850 | } |
1878 | |
1851 | |
1879 | /** |
1852 | /** |
1880 | * Handles applying a spell scroll. |
1853 | * Handles applying a spell scroll. |
1881 | */ |
1854 | */ |
… | |
… | |
1920 | identify (tmp); |
1893 | identify (tmp); |
1921 | |
1894 | |
1922 | op->statusmsg (format ("The scroll of %s turns to dust.", &tmp->inv->name)); |
1895 | op->statusmsg (format ("The scroll of %s turns to dust.", &tmp->inv->name)); |
1923 | |
1896 | |
1924 | cast_spell (op, tmp, dir, tmp->inv, NULL); |
1897 | cast_spell (op, tmp, dir, tmp->inv, NULL); |
1925 | decrease_ob (tmp); |
1898 | tmp->decrease (); |
1926 | } |
1899 | } |
1927 | |
1900 | |
1928 | /** |
1901 | /** |
1929 | * Applies a treasure object - by default, chest. op |
1902 | * Applies a treasure object - by default, chest. op |
1930 | * is the person doing the applying, tmp is the treasure |
1903 | * is the person doing the applying, tmp is the treasure |
… | |
… | |
1942 | object *treas = tmp->inv; |
1915 | object *treas = tmp->inv; |
1943 | |
1916 | |
1944 | if (!treas) |
1917 | if (!treas) |
1945 | { |
1918 | { |
1946 | op->statusmsg ("The chest was empty."); |
1919 | op->statusmsg ("The chest was empty."); |
1947 | decrease_ob (tmp); |
1920 | tmp->decrease (); |
1948 | return; |
1921 | return; |
1949 | } |
1922 | } |
1950 | |
1923 | |
1951 | while (tmp->inv) |
1924 | while (tmp->inv) |
1952 | { |
1925 | { |
… | |
… | |
1968 | if (op->destroyed () || tmp->destroyed ()) |
1941 | if (op->destroyed () || tmp->destroyed ()) |
1969 | break; |
1942 | break; |
1970 | } |
1943 | } |
1971 | |
1944 | |
1972 | if (!tmp->destroyed () && !tmp->inv) |
1945 | if (!tmp->destroyed () && !tmp->inv) |
1973 | decrease_ob (tmp); |
1946 | tmp->decrease (); |
1974 | } |
1947 | } |
1975 | |
1948 | |
1976 | /** |
1949 | /** |
1977 | * op eats food. |
1950 | * op eats food. |
1978 | * If player, takes care of messages and dragon special food. |
1951 | * If player, takes care of messages and dragon special food. |
… | |
… | |
2044 | eat_special_food (op, tmp); |
2017 | eat_special_food (op, tmp); |
2045 | } |
2018 | } |
2046 | } |
2019 | } |
2047 | |
2020 | |
2048 | handle_apply_yield (tmp); |
2021 | handle_apply_yield (tmp); |
2049 | decrease_ob (tmp); |
2022 | tmp->decrease (); |
2050 | } |
2023 | } |
2051 | |
2024 | |
2052 | /** |
2025 | /** |
2053 | * A dragon is eating some flesh. If the flesh contains resistances, |
2026 | * A dragon is eating some flesh. If the flesh contains resistances, |
2054 | * there is a chance for the dragon's skin to get improved. |
2027 | * there is a chance for the dragon's skin to get improved. |
… | |
… | |
2242 | |
2215 | |
2243 | op->statusmsg ("Applying armour enchantment."); |
2216 | op->statusmsg ("Applying armour enchantment."); |
2244 | improve_armour (op, tmp, armor); |
2217 | improve_armour (op, tmp, armor); |
2245 | } |
2218 | } |
2246 | |
2219 | |
2247 | extern void |
2220 | void |
2248 | apply_poison (object *op, object *tmp) |
2221 | apply_poison (object *op, object *tmp) |
2249 | { |
2222 | { |
|
|
2223 | // need to do it now when it is still on the map |
|
|
2224 | handle_apply_yield (tmp); |
|
|
2225 | |
|
|
2226 | object *poison = tmp->split (1); |
|
|
2227 | |
2250 | if (op->type == PLAYER) |
2228 | if (op->type == PLAYER) |
2251 | { |
2229 | { |
2252 | op->contr->play_sound (sound_find ("drink_poison")); |
2230 | op->contr->play_sound (sound_find ("drink_poison")); |
2253 | op->failmsg ("Yech! That tasted poisonous!"); |
2231 | op->failmsg ("Yech! That tasted poisonous!"); |
2254 | strcpy (op->contr->killer, "poisonous booze"); |
2232 | op->contr->killer = poison; |
2255 | } |
2233 | } |
2256 | |
2234 | |
2257 | if (tmp->stats.hp > 0) |
2235 | if (poison->stats.hp > 0) |
2258 | { |
2236 | { |
2259 | LOG (llevDebug, "Trying to poison player/monster for %d hp\n", tmp->stats.hp); |
2237 | LOG (llevDebug, "Trying to poison player/monster for %d hp\n", poison->stats.hp); |
2260 | hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); |
2238 | hit_player (op, poison->stats.hp, tmp, AT_POISON, 1); |
2261 | } |
2239 | } |
2262 | |
2240 | |
2263 | op->stats.food -= op->stats.food / 4; |
2241 | op->stats.food -= op->stats.food / 4; |
2264 | handle_apply_yield (tmp); |
2242 | poison->destroy (); |
2265 | decrease_ob (tmp); |
|
|
2266 | } |
2243 | } |
2267 | |
2244 | |
2268 | /** |
2245 | /** |
2269 | * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit. |
2246 | * 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: |
2247 | * A valid 2 way exit means: |
… | |
… | |
2372 | * them in this function - they are passed to apply_special |
2349 | * them in this function - they are passed to apply_special |
2373 | */ |
2350 | */ |
2374 | int |
2351 | int |
2375 | manual_apply (object *op, object *tmp, int aflag) |
2352 | manual_apply (object *op, object *tmp, int aflag) |
2376 | { |
2353 | { |
2377 | if (tmp->head) |
|
|
2378 | tmp = tmp->head; |
2354 | tmp = tmp->head_ (); |
2379 | |
2355 | |
2380 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2356 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2381 | { |
2357 | { |
2382 | if (op->type == PLAYER) |
2358 | if (op->type == PLAYER) |
2383 | { |
2359 | { |
… | |
… | |
2591 | default: |
2567 | default: |
2592 | return 0; |
2568 | return 0; |
2593 | } |
2569 | } |
2594 | } |
2570 | } |
2595 | |
2571 | |
2596 | |
|
|
2597 | /* quiet suppresses the "don't know how to apply" and "you must get it first" |
2572 | /* quiet suppresses the "don't know how to apply" and "you must get it first" |
2598 | * messages as needed by player_apply_below(). But there can still be |
2573 | * messages as needed by player_apply_below(). But there can still be |
2599 | * "but you are floating high above the ground" messages. |
2574 | * "but you are floating high above the ground" messages. |
2600 | * |
2575 | * |
2601 | * Same return value as apply() function. |
2576 | * Same return value as apply() function. |
2602 | */ |
2577 | */ |
2603 | int |
2578 | int |
2604 | player_apply (object *pl, object *op, int aflag, int quiet) |
2579 | player_apply (object *pl, object *op, int aflag, int quiet) |
2605 | { |
2580 | { |
2606 | int tmp; |
|
|
2607 | |
|
|
2608 | if (op->env && (pl->move_type & MOVE_FLYING)) |
2581 | if (!op->env && (pl->move_type & MOVE_FLYING)) |
2609 | { |
2582 | { |
2610 | /* player is flying and applying object not in inventory */ |
2583 | /* player is flying and applying object not in inventory */ |
2611 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2584 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2612 | { |
2585 | { |
2613 | pl->failmsg ("But you are floating high above the ground! H<You have to stop levitating first, if you can.>"); |
2586 | pl->failmsg ("But you are floating high above the ground! " |
|
|
2587 | "H<You have to stop levitating first, if you can, either by using your levitation skill, " |
|
|
2588 | "or waiting till the levitation effect wears off.>"); |
2614 | return 0; |
2589 | return 0; |
2615 | } |
2590 | } |
2616 | } |
2591 | } |
2617 | |
2592 | |
2618 | pl->contr->last_used = op; |
2593 | pl->contr->last_used = op; |
2619 | |
2594 | |
2620 | tmp = manual_apply (pl, op, aflag); |
2595 | int tmp = manual_apply (pl, op, aflag); |
|
|
2596 | |
2621 | if (!quiet) |
2597 | if (!quiet) |
2622 | { |
2598 | { |
2623 | if (tmp == 0) |
2599 | if (tmp == 0) |
2624 | pl->statusmsg (format ("I don't know how to apply the %s.", query_name (op))); |
2600 | pl->statusmsg (format ("I don't know how to apply the %s.", query_name (op))); |
2625 | else if (tmp == 2) |
2601 | else if (tmp == 2) |
… | |
… | |
2717 | break; |
2693 | break; |
2718 | |
2694 | |
2719 | case SKILL: |
2695 | case SKILL: |
2720 | if (who->contr) |
2696 | if (who->contr) |
2721 | { |
2697 | { |
|
|
2698 | if (IS_COMBAT_SKILL (op->subtype)) |
|
|
2699 | who->change_weapon (who->contr->combat_ob = 0); |
|
|
2700 | else if (IS_RANGED_SKILL (op->subtype)) |
|
|
2701 | who->change_weapon (who->contr->ranged_ob = 0); |
|
|
2702 | |
2722 | if (!op->invisible) |
2703 | if (op->invisible) |
|
|
2704 | who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill)); |
|
|
2705 | else |
2723 | who->statusmsg (format ("You stop using the %s.", query_name (op))); |
2706 | who->statusmsg (format ("You stop using the %s.", query_name (op))); |
2724 | else |
|
|
2725 | who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill)); |
|
|
2726 | } |
2707 | } |
2727 | |
2708 | |
2728 | change_abil (who, op); |
2709 | change_abil (who, op); |
2729 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
2710 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
2730 | break; |
2711 | break; |
… | |
… | |
2757 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
2738 | CLEAR_FLAG (tmp2, FLAG_APPLIED); |
2758 | |
2739 | |
2759 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2740 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2760 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2741 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2761 | |
2742 | |
|
|
2743 | op->destroy (); |
|
|
2744 | who->insert (tmp2); |
|
|
2745 | who->update_stats (); |
|
|
2746 | |
2762 | if (who->contr) |
2747 | 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 | { |
2748 | { |
2771 | if (who->contr) |
2749 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2772 | { |
2750 | { |
2773 | who->failmsg ("Oops, it feels deadly cold!"); |
2751 | who->failmsg ("Oops, it feels deadly cold!"); |
2774 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2752 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2775 | } |
2753 | } |
2776 | } |
2754 | } |
2777 | |
|
|
2778 | if (who->contr) |
|
|
2779 | esrv_send_item (who, tmp2); |
|
|
2780 | } |
2755 | } |
2781 | |
2756 | |
2782 | return 1; /* otherwise, an attempt to drop causes problems */ |
2757 | return 1; /* otherwise, an attempt to drop causes problems */ |
2783 | |
2758 | |
2784 | case BOW: |
2759 | case BOW: |
… | |
… | |
2815 | default: |
2790 | default: |
2816 | who->statusmsg (format ("You unapply %s.", query_name (op))); |
2791 | who->statusmsg (format ("You unapply %s.", query_name (op))); |
2817 | break; |
2792 | break; |
2818 | } |
2793 | } |
2819 | |
2794 | |
|
|
2795 | if (aflags & AP_NO_MERGE || !merge_ob (op, 0)) |
|
|
2796 | if (object *pl = op->visible_to ()) |
|
|
2797 | esrv_send_item (pl, op); |
|
|
2798 | |
2820 | who->update_stats (); |
2799 | 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 | |
2800 | |
2838 | return 0; |
2801 | return 0; |
2839 | } |
2802 | } |
2840 | |
2803 | |
2841 | /** |
2804 | /** |
… | |
… | |
3139 | return 1; |
3102 | return 1; |
3140 | } |
3103 | } |
3141 | |
3104 | |
3142 | return unapply_special (who, op, aflags); |
3105 | return unapply_special (who, op, aflags); |
3143 | } |
3106 | } |
3144 | |
|
|
3145 | if (basic_flag == AP_UNAPPLY) |
3107 | else if (basic_flag == AP_UNAPPLY) |
3146 | return 0; |
3108 | return 0; |
3147 | |
3109 | |
3148 | // if the item is combat/ranged, wield the relevant slot first |
3110 | // if the item is combat/ranged, wield the relevant slot first |
3149 | // to resolve conflicts. |
3111 | // to resolve conflicts. |
3150 | if (player *pl = who->contr) |
3112 | if (player *pl = who->contr) |
… | |
… | |
3220 | |
3182 | |
3221 | /* Ok. We are now at the state where we can apply the new object. |
3183 | /* 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_... |
3184 | * Note that we don't have the checks for can_use_... |
3223 | * below - that is already taken care of by can_apply_object. |
3185 | * below - that is already taken care of by can_apply_object. |
3224 | */ |
3186 | */ |
3225 | if (op->nrof > 1) |
3187 | 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 | |
3188 | |
3230 | if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) || INVOKE_OBJECT (READY, who, ARG_OBJECT (op))) |
3189 | if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) || INVOKE_OBJECT (READY, who, ARG_OBJECT (op))) |
3231 | return RESULT_INT (0); |
3190 | return RESULT_INT (0); |
3232 | |
3191 | |
3233 | switch (op->type) |
3192 | switch (op->type) |
3234 | { |
3193 | { |
3235 | case WEAPON: |
3194 | case WEAPON: |
3236 | if (!check_weapon_power (who, op->last_eat)) |
3195 | if (!check_weapon_power (who, op->last_eat)) |
3237 | { |
3196 | { |
3238 | op->failmsg ("This weapon is too powerful for you to use. It would consume your soul!." LACK_ITEM_POWER); |
3197 | op->failmsg ("This weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER); |
3239 | |
3198 | |
3240 | if (tmp) |
3199 | if (tmp) |
3241 | insert_ob_in_ob (tmp, who); |
3200 | insert_ob_in_ob (tmp, who); |
3242 | |
3201 | |
3243 | return 1; |
3202 | return 1; |
… | |
… | |
3308 | SET_FLAG (tmp2, FLAG_APPLIED); |
3267 | SET_FLAG (tmp2, FLAG_APPLIED); |
3309 | |
3268 | |
3310 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
3269 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
3311 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
3270 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
3312 | |
3271 | |
3313 | insert_ob_in_ob (tmp2, who); |
3272 | who->insert (tmp2); |
3314 | |
3273 | |
3315 | /* Remove the old lantern */ |
3274 | /* Remove the old lantern */ |
3316 | if (who->type == PLAYER) |
|
|
3317 | esrv_del_item (who->contr, op->count); |
|
|
3318 | |
|
|
3319 | op->destroy (); |
3275 | op->destroy (); |
3320 | |
3276 | |
3321 | /* insert the portion that was split off */ |
3277 | /* insert the portion that was split off */ |
3322 | if (tmp) |
3278 | if (tmp) |
3323 | { |
3279 | who->insert (tmp); |
3324 | insert_ob_in_ob (tmp, who); |
|
|
3325 | if (who->type == PLAYER) |
|
|
3326 | esrv_send_item (who, tmp); |
|
|
3327 | } |
|
|
3328 | |
3280 | |
3329 | who->update_stats (); |
3281 | who->update_stats (); |
3330 | |
3282 | |
3331 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3283 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3332 | if (who->type == PLAYER) |
3284 | if (who->type == PLAYER) |
3333 | { |
3285 | { |
3334 | who->failmsg ("Oops, it feels deadly cold! H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3286 | 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); |
3287 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3336 | } |
3288 | } |
3337 | |
|
|
3338 | if (who->type == PLAYER) |
|
|
3339 | esrv_send_item (who, tmp2); |
|
|
3340 | |
3289 | |
3341 | return 0; |
3290 | return 0; |
3342 | |
3291 | |
3343 | case SKILL_TOOL: |
3292 | case SKILL_TOOL: |
3344 | // applying a skill tool also readies the skill |
3293 | // applying a skill tool also readies the skill |
… | |
… | |
3504 | } |
3453 | } |
3505 | |
3454 | |
3506 | SET_FLAG (op, FLAG_APPLIED); |
3455 | SET_FLAG (op, FLAG_APPLIED); |
3507 | |
3456 | |
3508 | if (tmp) |
3457 | if (tmp) |
3509 | tmp = insert_ob_in_ob (tmp, who); |
3458 | who->insert (tmp); |
3510 | |
3459 | |
3511 | who->update_stats (); |
3460 | who->update_stats (); |
3512 | |
3461 | |
3513 | /* We exclude spell casting objects. The fire code will set the |
3462 | /* We exclude spell casting objects. The fire code will set the |
3514 | * been applied flag when they are used - until that point, |
3463 | * 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.>" |
3474 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>" |
3526 | ); |
3475 | ); |
3527 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3476 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3528 | } |
3477 | } |
3529 | |
3478 | |
3530 | if (who->type == PLAYER) |
3479 | 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); |
3480 | esrv_send_item (pl, op); |
3537 | } |
|
|
3538 | |
3481 | |
3539 | return 0; |
3482 | return 0; |
3540 | } |
3483 | } |
3541 | |
3484 | |
3542 | int |
3485 | int |
… | |
… | |
3556 | int |
3499 | int |
3557 | auto_apply (object *op) |
3500 | auto_apply (object *op) |
3558 | { |
3501 | { |
3559 | object *tmp = NULL, *tmp2; |
3502 | object *tmp = NULL, *tmp2; |
3560 | int i; |
3503 | int i; |
|
|
3504 | |
|
|
3505 | if (INVOKE_OBJECT (AUTO_APPLY, op)) |
|
|
3506 | return RESULT_INT (0); |
3561 | |
3507 | |
3562 | switch (op->type) |
3508 | switch (op->type) |
3563 | { |
3509 | { |
3564 | case SHOP_FLOOR: |
3510 | case SHOP_FLOOR: |
3565 | if (!op->has_random_items ()) |
3511 | if (!op->has_random_items ()) |
… | |
… | |
3767 | /* check for hp, sp change */ |
3713 | /* check for hp, sp change */ |
3768 | if (food->stats.hp != 0) |
3714 | if (food->stats.hp != 0) |
3769 | { |
3715 | { |
3770 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3716 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3771 | { |
3717 | { |
3772 | assign (who->contr->killer, food->name); |
3718 | who->contr->killer = food; |
3773 | hit_player (who, food->stats.hp, food, AT_POISON, 1); |
3719 | hit_player (who, food->stats.hp, food, AT_POISON, 1); |
3774 | who->failmsg ("Eck!...that was poisonous!"); |
3720 | who->failmsg ("Eck!...that was poisonous!"); |
3775 | } |
3721 | } |
3776 | else |
3722 | else |
3777 | { |
3723 | { |
… | |
… | |
3781 | who->failmsg ("Eck!...that was poisonous!"); |
3727 | who->failmsg ("Eck!...that was poisonous!"); |
3782 | |
3728 | |
3783 | who->stats.hp += food->stats.hp; |
3729 | who->stats.hp += food->stats.hp; |
3784 | } |
3730 | } |
3785 | } |
3731 | } |
|
|
3732 | |
3786 | if (food->stats.sp != 0) |
3733 | if (food->stats.sp != 0) |
3787 | { |
3734 | { |
3788 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3735 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3789 | { |
3736 | { |
3790 | who->failmsg ("You are drained of mana!"); |
3737 | who->failmsg ("You are drained of mana!"); |
… | |
… | |
3817 | item = find_marked_object (who); |
3764 | item = find_marked_object (who); |
3818 | if (item) |
3765 | if (item) |
3819 | { |
3766 | { |
3820 | if (lighter->last_eat && lighter->stats.food) |
3767 | if (lighter->last_eat && lighter->stats.food) |
3821 | { /* lighter gets used up */ |
3768 | { /* 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 (); |
3769 | object *oneLighter = lighter->split (); |
3827 | |
|
|
3828 | lighter->nrof -= 1; |
|
|
3829 | oneLighter->nrof = 1; |
|
|
3830 | oneLighter->stats.food--; |
3770 | oneLighter->stats.food--; |
3831 | esrv_send_item (who, lighter); |
3771 | 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 | } |
3772 | } |
3838 | else if (lighter->last_eat) |
3773 | else if (lighter->last_eat) |
3839 | { |
3774 | { |
3840 | /* no charges left in lighter */ |
3775 | /* no charges left in lighter */ |
3841 | who->failmsg (format ("You attempt to light the %s with a used up %s.", &item->name, &lighter->name)); |
3776 | who->failmsg (format ("You attempt to light the %s with a used up %s.", &item->name, &lighter->name)); |
… | |
… | |
3988 | if (!strcmp (walk->name, "NOCLASSFACECHANGE")) |
3923 | if (!strcmp (walk->name, "NOCLASSFACECHANGE")) |
3989 | flag_change_face = 0; |
3924 | flag_change_face = 0; |
3990 | |
3925 | |
3991 | if (flag_change_face) |
3926 | if (flag_change_face) |
3992 | { |
3927 | { |
3993 | pl->animation_id = GET_ANIM_ID (change); |
|
|
3994 | pl->face = change->face; |
3928 | pl->face = change->face; |
3995 | |
3929 | pl->animation_id = change->animation_id; |
3996 | if (QUERY_FLAG (change, FLAG_ANIMATE)) |
3930 | pl->flag [FLAG_ANIMATE] = change->flag [FLAG_ANIMATE]; |
3997 | SET_FLAG (pl, FLAG_ANIMATE); |
|
|
3998 | else |
|
|
3999 | CLEAR_FLAG (pl, FLAG_ANIMATE); |
|
|
4000 | } |
3931 | } |
4001 | |
3932 | |
4002 | /* check the special case of can't use weapons */ |
3933 | /* check the special case of can't use weapons */ |
4003 | /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */ |
3934 | /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */ |
4004 | if (!strcmp (change->name, "monk")) |
3935 | if (!strcmp (change->name, "monk")) |
… | |
… | |
4098 | |
4029 | |
4099 | new_item->nrof = yield; |
4030 | new_item->nrof = yield; |
4100 | |
4031 | |
4101 | pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0))); |
4032 | pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0))); |
4102 | |
4033 | |
4103 | insert_ob_in_ob (new_item, pl); |
4034 | pl->insert (new_item); |
4104 | esrv_send_inventory (pl, pl); |
|
|
4105 | /* Eat up one item */ |
4035 | /* Eat up one item */ |
4106 | decrease_ob_nr (marked, 1); |
4036 | marked->decrease (); |
4107 | |
4037 | |
4108 | /* Eat one transformer if needed */ |
4038 | /* Eat one transformer if needed */ |
4109 | if (transformer->stats.food) |
4039 | if (transformer->stats.food) |
4110 | if (--transformer->stats.food == 0) |
4040 | if (--transformer->stats.food == 0) |
4111 | decrease_ob_nr (transformer, 1); |
4041 | transformer->decrease (); |
4112 | } |
4042 | } |
4113 | |
4043 | |