… | |
… | |
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 | */ |
… | |
… | |
651 | slot at once! */ |
637 | slot at once! */ |
652 | improver->decrease (); |
638 | improver->decrease (); |
653 | weapon->last_eat = 0; |
639 | weapon->last_eat = 0; |
654 | return 1; |
640 | return 1; |
655 | } |
641 | } |
656 | |
|
|
657 | |
642 | |
658 | /** |
643 | /** |
659 | * 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. |
660 | * This is the new improve weapon code. |
645 | * This is the new improve weapon code. |
661 | * 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. |
… | |
… | |
899 | 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); |
900 | |
885 | |
901 | if (op->type == PLAYER) |
886 | if (op->type == PLAYER) |
902 | { |
887 | { |
903 | esrv_send_item (op, armour); |
888 | esrv_send_item (op, armour); |
|
|
889 | |
904 | if (QUERY_FLAG (armour, FLAG_APPLIED)) |
890 | if (QUERY_FLAG (armour, FLAG_APPLIED)) |
905 | op->update_stats (); |
891 | op->update_stats (); |
906 | } |
892 | } |
907 | |
893 | |
908 | improver->decrease (); |
894 | improver->decrease (); |
909 | |
895 | |
910 | if (tmp) |
896 | if (tmp) |
911 | { |
897 | op->insert (tmp); |
912 | insert_ob_in_ob (tmp, op); |
|
|
913 | esrv_send_item (op, tmp); |
|
|
914 | } |
|
|
915 | |
898 | |
916 | return 1; |
899 | return 1; |
917 | } |
900 | } |
918 | |
901 | |
919 | /* |
902 | /* |
… | |
… | |
1635 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1618 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1636 | { |
1619 | { |
1637 | /*exp_gain *= 2; because they just identified it too */ |
1620 | /*exp_gain *= 2; because they just identified it too */ |
1638 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
1621 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
1639 | |
1622 | |
1640 | /* If in a container, update how it looks */ |
1623 | if (object *pl = tmp->visible_to ()) |
1641 | if (tmp->env) |
|
|
1642 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
1624 | esrv_update_item (UPD_FLAGS | UPD_NAME, pl, tmp); |
1643 | else |
|
|
1644 | op->contr->ns->floorbox_update (); |
|
|
1645 | } |
1625 | } |
1646 | |
1626 | |
1647 | change_exp (op, exp_gain, skill_ob->skill, 0); |
1627 | change_exp (op, exp_gain, skill_ob->skill, 0); |
1648 | 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 */ |
1649 | } |
1629 | } |
… | |
… | |
1799 | } |
1779 | } |
1800 | |
1780 | |
1801 | 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)); |
1802 | |
1782 | |
1803 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1783 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1804 | { |
|
|
1805 | identify (tmp); |
1784 | identify (tmp); |
1806 | |
|
|
1807 | if (tmp->env) |
|
|
1808 | esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); |
|
|
1809 | else |
|
|
1810 | op->contr->ns->floorbox_update (); |
|
|
1811 | } |
|
|
1812 | |
1785 | |
1813 | /* 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 |
1814 | * 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 |
1815 | * 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 |
1816 | * they would have a special prayer mark. |
1789 | * they would have a special prayer mark. |
… | |
… | |
2756 | |
2729 | |
2757 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2730 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
2758 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2731 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
2759 | |
2732 | |
2760 | op->destroy (); |
2733 | op->destroy (); |
2761 | insert_ob_in_ob (tmp2, who); |
2734 | who->insert (tmp2); |
2762 | who->update_stats (); |
2735 | who->update_stats (); |
2763 | |
2736 | |
2764 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2737 | if (who->contr) |
2765 | { |
2738 | { |
2766 | if (who->contr) |
2739 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2767 | { |
2740 | { |
2768 | who->failmsg ("Oops, it feels deadly cold!"); |
2741 | who->failmsg ("Oops, it feels deadly cold!"); |
2769 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2742 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2770 | } |
2743 | } |
2771 | } |
2744 | } |
2772 | |
|
|
2773 | if (who->contr) |
|
|
2774 | esrv_send_item (who, tmp2); |
|
|
2775 | } |
2745 | } |
2776 | |
2746 | |
2777 | return 1; /* otherwise, an attempt to drop causes problems */ |
2747 | return 1; /* otherwise, an attempt to drop causes problems */ |
2778 | |
2748 | |
2779 | case BOW: |
2749 | case BOW: |
… | |
… | |
2813 | } |
2783 | } |
2814 | |
2784 | |
2815 | who->update_stats (); |
2785 | who->update_stats (); |
2816 | |
2786 | |
2817 | if (!(aflags & AP_NO_MERGE)) |
2787 | if (!(aflags & AP_NO_MERGE)) |
2818 | { |
2788 | merge_ob (op, 0); |
2819 | object *tmp = merge_ob (op, 0); |
|
|
2820 | |
|
|
2821 | if (who->contr) |
|
|
2822 | { |
|
|
2823 | if (tmp) |
|
|
2824 | { /* it was merged */ |
|
|
2825 | esrv_del_item (who->contr, op->count); |
|
|
2826 | op = tmp; |
|
|
2827 | } |
|
|
2828 | |
|
|
2829 | esrv_send_item (who, op); |
|
|
2830 | } |
|
|
2831 | } |
|
|
2832 | |
2789 | |
2833 | return 0; |
2790 | return 0; |
2834 | } |
2791 | } |
2835 | |
2792 | |
2836 | /** |
2793 | /** |
… | |
… | |
3300 | SET_FLAG (tmp2, FLAG_APPLIED); |
3257 | SET_FLAG (tmp2, FLAG_APPLIED); |
3301 | |
3258 | |
3302 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
3259 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
3303 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
3260 | SET_FLAG (tmp2, FLAG_INV_LOCKED); |
3304 | |
3261 | |
3305 | insert_ob_in_ob (tmp2, who); |
3262 | who->insert (tmp2); |
3306 | |
3263 | |
3307 | /* Remove the old lantern */ |
3264 | /* Remove the old lantern */ |
3308 | op->destroy (); |
3265 | op->destroy (); |
3309 | |
3266 | |
3310 | /* insert the portion that was split off */ |
3267 | /* insert the portion that was split off */ |
3311 | if (tmp) |
3268 | if (tmp) |
3312 | { |
3269 | who->insert (tmp); |
3313 | insert_ob_in_ob (tmp, who); |
|
|
3314 | if (who->type == PLAYER) |
|
|
3315 | esrv_send_item (who, tmp); |
|
|
3316 | } |
|
|
3317 | |
3270 | |
3318 | who->update_stats (); |
3271 | who->update_stats (); |
3319 | |
3272 | |
3320 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3273 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3321 | if (who->type == PLAYER) |
3274 | if (who->type == PLAYER) |
3322 | { |
3275 | { |
3323 | who->failmsg ("Oops, it feels deadly cold! H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3276 | who->failmsg ("Oops, it feels deadly cold! H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3324 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3277 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3325 | } |
3278 | } |
3326 | |
|
|
3327 | if (who->type == PLAYER) |
|
|
3328 | esrv_send_item (who, tmp2); |
|
|
3329 | |
3279 | |
3330 | return 0; |
3280 | return 0; |
3331 | |
3281 | |
3332 | case SKILL_TOOL: |
3282 | case SKILL_TOOL: |
3333 | // applying a skill tool also readies the skill |
3283 | // applying a skill tool also readies the skill |
… | |
… | |
3493 | } |
3443 | } |
3494 | |
3444 | |
3495 | SET_FLAG (op, FLAG_APPLIED); |
3445 | SET_FLAG (op, FLAG_APPLIED); |
3496 | |
3446 | |
3497 | if (tmp) |
3447 | if (tmp) |
3498 | tmp = insert_ob_in_ob (tmp, who); |
3448 | who->insert (tmp); |
3499 | |
3449 | |
3500 | who->update_stats (); |
3450 | who->update_stats (); |
3501 | |
3451 | |
3502 | /* We exclude spell casting objects. The fire code will set the |
3452 | /* We exclude spell casting objects. The fire code will set the |
3503 | * been applied flag when they are used - until that point, |
3453 | * been applied flag when they are used - until that point, |
… | |
… | |
3514 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>" |
3464 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>" |
3515 | ); |
3465 | ); |
3516 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3466 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3517 | } |
3467 | } |
3518 | |
3468 | |
3519 | if (who->type == PLAYER) |
3469 | if (object *pl = op->visible_to ()) |
3520 | { |
|
|
3521 | /* if multiple objects were applied, update both slots */ |
|
|
3522 | if (tmp) |
|
|
3523 | esrv_send_item (who, tmp); |
|
|
3524 | |
|
|
3525 | esrv_send_item (who, op); |
3470 | esrv_send_item (pl, op); |
3526 | } |
|
|
3527 | |
3471 | |
3528 | return 0; |
3472 | return 0; |
3529 | } |
3473 | } |
3530 | |
3474 | |
3531 | int |
3475 | int |
… | |
… | |
3806 | item = find_marked_object (who); |
3750 | item = find_marked_object (who); |
3807 | if (item) |
3751 | if (item) |
3808 | { |
3752 | { |
3809 | if (lighter->last_eat && lighter->stats.food) |
3753 | if (lighter->last_eat && lighter->stats.food) |
3810 | { /* lighter gets used up */ |
3754 | { /* lighter gets used up */ |
3811 | /* Split multiple lighters if they're being used up. Otherwise * |
|
|
3812 | * one charge from each would be used up. --DAMN */ |
|
|
3813 | if (lighter->nrof > 1) |
|
|
3814 | { |
|
|
3815 | object *oneLighter = lighter->clone (); |
3755 | object *oneLighter = lighter->split (); |
3816 | |
|
|
3817 | lighter->nrof -= 1; |
|
|
3818 | oneLighter->nrof = 1; |
|
|
3819 | oneLighter->stats.food--; |
3756 | oneLighter->stats.food--; |
3820 | esrv_send_item (who, lighter); |
3757 | who->insert (oneLighter); |
3821 | oneLighter = insert_ob_in_ob (oneLighter, who); |
|
|
3822 | esrv_send_item (who, oneLighter); |
|
|
3823 | } |
|
|
3824 | else |
|
|
3825 | lighter->stats.food--; |
|
|
3826 | } |
3758 | } |
3827 | else if (lighter->last_eat) |
3759 | else if (lighter->last_eat) |
3828 | { |
3760 | { |
3829 | /* no charges left in lighter */ |
3761 | /* no charges left in lighter */ |
3830 | who->failmsg (format ("You attempt to light the %s with a used up %s.", &item->name, &lighter->name)); |
3762 | who->failmsg (format ("You attempt to light the %s with a used up %s.", &item->name, &lighter->name)); |
… | |
… | |
4087 | |
4019 | |
4088 | new_item->nrof = yield; |
4020 | new_item->nrof = yield; |
4089 | |
4021 | |
4090 | pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0))); |
4022 | pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0))); |
4091 | |
4023 | |
4092 | insert_ob_in_ob (new_item, pl); |
4024 | pl->insert (new_item); |
4093 | esrv_send_inventory (pl, pl); |
|
|
4094 | /* Eat up one item */ |
4025 | /* Eat up one item */ |
4095 | marked->decrease (); |
4026 | marked->decrease (); |
4096 | |
4027 | |
4097 | /* Eat one transformer if needed */ |
4028 | /* Eat one transformer if needed */ |
4098 | if (transformer->stats.food) |
4029 | if (transformer->stats.food) |