… | |
… | |
575 | op->update_stats (); |
575 | op->update_stats (); |
576 | return 1; |
576 | return 1; |
577 | } |
577 | } |
578 | |
578 | |
579 | /* Types of improvements, hidden in the sp field. */ |
579 | /* Types of improvements, hidden in the sp field. */ |
580 | #define IMPROVE_PREPARE 1 |
580 | #define IMPROVE_PREPARE 1 |
581 | #define IMPROVE_DAMAGE 2 |
581 | #define IMPROVE_DAMAGE 2 |
582 | #define IMPROVE_WEIGHT 3 |
582 | #define IMPROVE_WEIGHT 3 |
583 | #define IMPROVE_ENCHANT 4 |
583 | #define IMPROVE_ENCHANT 4 |
584 | #define IMPROVE_STR 5 |
584 | #define IMPROVE_STR 5 |
585 | #define IMPROVE_DEX 6 |
585 | #define IMPROVE_DEX 6 |
586 | #define IMPROVE_CON 7 |
586 | #define IMPROVE_CON 7 |
587 | #define IMPROVE_WIS 8 |
587 | #define IMPROVE_WIS 8 |
588 | #define IMPROVE_CHA 9 |
588 | #define IMPROVE_CHA 9 |
589 | #define IMPROVE_INT 10 |
589 | #define IMPROVE_INT 10 |
590 | #define IMPROVE_POW 11 |
590 | #define IMPROVE_POW 11 |
591 | |
|
|
592 | |
591 | |
593 | /** |
592 | /** |
594 | * This does the prepare weapon scroll. |
593 | * This does the prepare weapon scroll. |
595 | * Checks for sacrifice, and so on. |
594 | * Checks for sacrifice, and so on. |
596 | */ |
595 | */ |
… | |
… | |
1562 | |
1561 | |
1563 | /* need a literacy skill to read stuff! */ |
1562 | /* need a literacy skill to read stuff! */ |
1564 | skill_ob = find_skill_by_name (op, tmp->skill); |
1563 | skill_ob = find_skill_by_name (op, tmp->skill); |
1565 | if (!skill_ob) |
1564 | if (!skill_ob) |
1566 | { |
1565 | { |
1567 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); |
1566 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<You lack the skill to read this>"); |
1568 | return; |
1567 | return; |
1569 | } |
1568 | } |
1570 | |
1569 | |
1571 | lev_diff = tmp->level - (skill_ob->level + 5); |
1570 | lev_diff = tmp->level - (skill_ob->level + 5); |
1572 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
1571 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
… | |
… | |
1732 | |
1731 | |
1733 | /* artifact_spellbooks have 'slaying' field point to a spell name, |
1732 | /* artifact_spellbooks have 'slaying' field point to a spell name, |
1734 | * instead of having their spell stored in stats.sp. These are |
1733 | * instead of having their spell stored in stats.sp. These are |
1735 | * legacy spellbooks |
1734 | * legacy spellbooks |
1736 | */ |
1735 | */ |
1737 | |
|
|
1738 | if (tmp->slaying != NULL) |
1736 | if (tmp->slaying) |
1739 | { |
1737 | { |
1740 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1738 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1741 | if (!spell) |
1739 | if (!spell) |
1742 | { |
1740 | { |
1743 | new_draw_info_format (NDI_UNIQUE, 0, op, "The book's formula for %s is incomplete", &tmp->slaying); |
1741 | new_draw_info_format (NDI_UNIQUE, 0, op, "The book's formula for %s is incomplete", &tmp->slaying); |
1744 | return; |
1742 | return; |
1745 | } |
1743 | } |
1746 | else |
1744 | else |
1747 | insert_ob_in_ob (spell, tmp); |
1745 | insert_ob_in_ob (spell, tmp); |
|
|
1746 | |
1748 | tmp->slaying = NULL; |
1747 | tmp->slaying = 0; |
1749 | } |
1748 | } |
1750 | |
1749 | |
1751 | skop = find_skill_by_name (op, tmp->skill); |
1750 | skop = find_skill_by_name (op, tmp->skill); |
1752 | |
1751 | |
1753 | /* need a literacy skill to learn spells. Also, having a literacy level |
1752 | /* need a literacy skill to learn spells. Also, having a literacy level |
1754 | * lower than the spell will make learning the spell more difficult */ |
1753 | * lower than the spell will make learning the spell more difficult */ |
1755 | if (!skop) |
1754 | if (!skop) |
1756 | { |
1755 | { |
1757 | new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails."); |
1756 | new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails. H<You lack the literacy skill.>"); |
1758 | return; |
1757 | return; |
1759 | } |
1758 | } |
1760 | |
1759 | |
1761 | spell = tmp->inv; |
1760 | spell = tmp->inv; |
1762 | |
1761 | |
1763 | if (!spell) |
1762 | if (!spell) |
1764 | { |
1763 | { |
1765 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1764 | LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); |
1766 | new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense."); |
1765 | new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense. This is a bug, please report!"); |
1767 | return; |
1766 | return; |
1768 | } |
1767 | } |
1769 | |
1768 | |
1770 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1769 | if (skop->level < int (sqrtf (spell->level) * 1.5f)) |
1771 | { |
1770 | { |
1772 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. [Your literacy level is too low]"); |
1771 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<Your literacy level is too low.>"); |
1773 | return; |
1772 | return; |
1774 | } |
1773 | } |
1775 | |
1774 | |
1776 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1775 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); |
1777 | |
1776 | |
… | |
… | |
1790 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1789 | * if the player doesn't know the spell, doesn't make a lot of sense that |
1791 | * they would have a special prayer mark. |
1790 | * they would have a special prayer mark. |
1792 | */ |
1791 | */ |
1793 | if (check_spell_known (op, spell->name)) |
1792 | if (check_spell_known (op, spell->name)) |
1794 | { |
1793 | { |
1795 | new_draw_info (NDI_UNIQUE, 0, op, "You already know that spell.\n"); |
1794 | new_draw_info (NDI_UNIQUE, 0, op, "You already know that spell. H<It makes no sense to leanr spells twice, and would only waste the spellbook.>\n"); |
1796 | return; |
1795 | return; |
1797 | } |
1796 | } |
1798 | |
1797 | |
1799 | if (spell->skill) |
1798 | if (spell->skill) |
1800 | { |
1799 | { |
… | |
… | |
1842 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
1841 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
1843 | } |
1842 | } |
1844 | else |
1843 | else |
1845 | { |
1844 | { |
1846 | play_sound_player_only (op->contr, SOUND_FUMBLE_SPELL, 0, 0); |
1845 | play_sound_player_only (op->contr, SOUND_FUMBLE_SPELL, 0, 0); |
1847 | new_draw_info (NDI_UNIQUE, 0, op, "You fail to learn the spell.\n"); |
1846 | new_draw_info (NDI_UNIQUE, 0, op, "You fail to learn the spell. H<Wis (priests) or Int (wizards) governs the chance of learning a prayer or spell.>\n"); |
1848 | } |
1847 | } |
1849 | |
1848 | |
1850 | decrease_ob (tmp); |
1849 | decrease_ob (tmp); |
1851 | } |
1850 | } |
1852 | |
1851 | |
… | |
… | |
1864 | return; |
1863 | return; |
1865 | } |
1864 | } |
1866 | |
1865 | |
1867 | if (!tmp->inv || tmp->inv->type != SPELL) |
1866 | if (!tmp->inv || tmp->inv->type != SPELL) |
1868 | { |
1867 | { |
1869 | new_draw_info (NDI_UNIQUE, 0, op, "The scroll just doesn't make sense!"); |
1868 | new_draw_info (NDI_UNIQUE, 0, op, "The scroll just doesn't make sense! H<...and never will make sense.>"); |
1870 | return; |
1869 | return; |
1871 | } |
1870 | } |
1872 | |
1871 | |
1873 | if (op->type == PLAYER) |
1872 | if (op->type == PLAYER) |
1874 | { |
1873 | { |
… | |
… | |
1880 | */ |
1879 | */ |
1881 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
1880 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
1882 | |
1881 | |
1883 | if (!skop) |
1882 | if (!skop) |
1884 | { |
1883 | { |
1885 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); |
1884 | new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<You lack the literacy skill.>"); |
1886 | return; |
1885 | return; |
1887 | } |
1886 | } |
1888 | |
1887 | |
1889 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
1888 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
1890 | change_exp (op, exp_gain, skop->skill, 0); |
1889 | change_exp (op, exp_gain, skop->skill, 0); |
… | |
… | |
2011 | /* special food hack -b.t. */ |
2010 | /* special food hack -b.t. */ |
2012 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
2011 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
2013 | eat_special_food (op, tmp); |
2012 | eat_special_food (op, tmp); |
2014 | } |
2013 | } |
2015 | } |
2014 | } |
|
|
2015 | |
2016 | handle_apply_yield (tmp); |
2016 | handle_apply_yield (tmp); |
2017 | decrease_ob (tmp); |
2017 | decrease_ob (tmp); |
2018 | } |
2018 | } |
2019 | |
2019 | |
2020 | /** |
2020 | /** |
… | |
… | |
2182 | static void |
2182 | static void |
2183 | apply_armour_improver (object *op, object *tmp) |
2183 | apply_armour_improver (object *op, object *tmp) |
2184 | { |
2184 | { |
2185 | object *armor; |
2185 | object *armor; |
2186 | |
2186 | |
2187 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
2187 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2188 | { |
2188 | { |
2189 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll."); |
2189 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll. H<The area prevents magic effects.>"); |
2190 | return; |
2190 | return; |
2191 | } |
2191 | } |
2192 | |
2192 | |
2193 | armor = find_marked_object (op); |
2193 | armor = find_marked_object (op); |
2194 | |
2194 | |
2195 | if (!armor) |
2195 | if (!armor) |
2196 | { |
2196 | { |
2197 | new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object."); |
2197 | new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object. Use the right mouse button popup or the mark command to do this."); |
2198 | return; |
2198 | return; |
2199 | } |
2199 | } |
2200 | |
2200 | |
2201 | if (armor->type != ARMOUR |
2201 | if (armor->type != ARMOUR |
2202 | && armor->type != CLOAK |
2202 | && armor->type != CLOAK |
… | |
… | |
2217 | { |
2217 | { |
2218 | play_sound_player_only (op->contr, SOUND_DRINK_POISON, 0, 0); |
2218 | play_sound_player_only (op->contr, SOUND_DRINK_POISON, 0, 0); |
2219 | new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!"); |
2219 | new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!"); |
2220 | strcpy (op->contr->killer, "poisonous booze"); |
2220 | strcpy (op->contr->killer, "poisonous booze"); |
2221 | } |
2221 | } |
|
|
2222 | |
2222 | if (tmp->stats.hp > 0) |
2223 | if (tmp->stats.hp > 0) |
2223 | { |
2224 | { |
2224 | LOG (llevDebug, "Trying to poison player/monster for %d hp\n", tmp->stats.hp); |
2225 | LOG (llevDebug, "Trying to poison player/monster for %d hp\n", tmp->stats.hp); |
2225 | hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); |
2226 | hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); |
2226 | } |
2227 | } |
|
|
2228 | |
2227 | op->stats.food -= op->stats.food / 4; |
2229 | op->stats.food -= op->stats.food / 4; |
2228 | handle_apply_yield (tmp); |
2230 | handle_apply_yield (tmp); |
2229 | decrease_ob (tmp); |
2231 | decrease_ob (tmp); |
2230 | } |
2232 | } |
2231 | |
2233 | |
… | |
… | |
2341 | |
2343 | |
2342 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2344 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2343 | { |
2345 | { |
2344 | if (op->type == PLAYER) |
2346 | if (op->type == PLAYER) |
2345 | { |
2347 | { |
2346 | new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first."); |
2348 | new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first. H<You cannot use items marked as unpaid.>"); |
2347 | return 1; |
2349 | return 1; |
2348 | } |
2350 | } |
2349 | else |
2351 | else |
2350 | return 0; /* monsters just skip unpaid items */ |
2352 | return 0; /* monsters just skip unpaid items */ |
2351 | } |
2353 | } |
… | |
… | |
2559 | int |
2561 | int |
2560 | player_apply (object *pl, object *op, int aflag, int quiet) |
2562 | player_apply (object *pl, object *op, int aflag, int quiet) |
2561 | { |
2563 | { |
2562 | int tmp; |
2564 | int tmp; |
2563 | |
2565 | |
2564 | if (op->env == NULL && (pl->move_type & MOVE_FLYING)) |
2566 | if (op->env && (pl->move_type & MOVE_FLYING)) |
2565 | { |
2567 | { |
2566 | /* player is flying and applying object not in inventory */ |
2568 | /* player is flying and applying object not in inventory */ |
2567 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2569 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2568 | { |
2570 | { |
2569 | new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high " "above the ground!"); |
2571 | new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high above the ground! H<You have to stop levitating first, if you can.>"); |
2570 | return 0; |
2572 | return 0; |
2571 | } |
2573 | } |
2572 | } |
2574 | } |
2573 | |
2575 | |
2574 | pl->contr->last_used = op; |
2576 | pl->contr->last_used = op; |
… | |
… | |
2579 | if (tmp == 0) |
2581 | if (tmp == 0) |
2580 | new_draw_info_format (NDI_UNIQUE, 0, pl, "I don't know how to apply the %s.", query_name (op)); |
2582 | new_draw_info_format (NDI_UNIQUE, 0, pl, "I don't know how to apply the %s.", query_name (op)); |
2581 | else if (tmp == 2) |
2583 | else if (tmp == 2) |
2582 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n"); |
2584 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n"); |
2583 | } |
2585 | } |
|
|
2586 | |
2584 | return tmp; |
2587 | return tmp; |
2585 | } |
2588 | } |
2586 | |
2589 | |
2587 | /** |
2590 | /** |
2588 | * player_apply_below attempts to apply the object 'below' the player. |
2591 | * player_apply_below attempts to apply the object 'below' the player. |
… | |
… | |
2828 | * Returns 0 on success, returns 1 if there is some problem. |
2831 | * Returns 0 on success, returns 1 if there is some problem. |
2829 | * if aflags is AP_PRINT, we instead print out waht to unapply |
2832 | * if aflags is AP_PRINT, we instead print out waht to unapply |
2830 | * instead of doing it. This is a lot less code than having |
2833 | * instead of doing it. This is a lot less code than having |
2831 | * another function that does just that. |
2834 | * another function that does just that. |
2832 | */ |
2835 | */ |
|
|
2836 | |
|
|
2837 | #define CANNOT_REMOVE_CURSED \ |
|
|
2838 | "H<You cannot remove cursed or damned items, you first have to remove the curse. " \ |
|
|
2839 | "Praying over an altar, scrolls of remove curse/damnation, " \ |
|
|
2840 | "priests or even other players might help.>" |
|
|
2841 | |
2833 | int |
2842 | int |
2834 | unapply_for_ob (object *who, object *op, int aflags) |
2843 | unapply_for_ob (object *who, object *op, int aflags) |
2835 | { |
2844 | { |
2836 | if (op->is_range ()) |
2845 | if (op->is_range ()) |
2837 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2846 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
… | |
… | |
2847 | { |
2856 | { |
2848 | /* In this case, we want to try and remove a cursed item. |
2857 | /* In this case, we want to try and remove a cursed item. |
2849 | * While we know it won't work, we want unapply_special to |
2858 | * While we know it won't work, we want unapply_special to |
2850 | * at least generate the message. |
2859 | * at least generate the message. |
2851 | */ |
2860 | */ |
2852 | new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove the %s.", query_name (tmp)); |
2861 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
2862 | "No matter how hard you try, you just can't remove the %s." CANNOT_REMOVE_CURSED, |
|
|
2863 | query_name (tmp)); |
2853 | return 1; |
2864 | return 1; |
2854 | } |
2865 | } |
2855 | |
2866 | |
2856 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2867 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
2857 | { |
2868 | { |
… | |
… | |
2891 | /* Cursed item that we can't unequip - tell the player. |
2902 | /* Cursed item that we can't unequip - tell the player. |
2892 | * Note this could be annoying if this is just one of a few, |
2903 | * Note this could be annoying if this is just one of a few, |
2893 | * so it may not be critical (eg, putting on a ring and you have |
2904 | * so it may not be critical (eg, putting on a ring and you have |
2894 | * one cursed ring.) |
2905 | * one cursed ring.) |
2895 | */ |
2906 | */ |
2896 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off", query_name (tmp)); |
2907 | new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp)); |
2897 | } |
2908 | } |
2898 | |
2909 | |
2899 | last = tmp->below; |
2910 | last = tmp->below; |
2900 | } |
2911 | } |
2901 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
2912 | /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the |
… | |
… | |
3054 | * |
3065 | * |
3055 | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
3066 | * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) |
3056 | * |
3067 | * |
3057 | * apply_special() doesn't check for unpaid items. |
3068 | * apply_special() doesn't check for unpaid items. |
3058 | */ |
3069 | */ |
|
|
3070 | |
|
|
3071 | #define LACK_ITEM_POWER \ |
|
|
3072 | " H<You lack enough unused item power to use this weapon, see the skills command.>" |
|
|
3073 | |
3059 | int |
3074 | int |
3060 | apply_special (object *who, object *op, int aflags) |
3075 | apply_special (object *who, object *op, int aflags) |
3061 | { |
3076 | { |
3062 | int basic_flag = aflags & AP_BASIC_FLAGS; |
3077 | int basic_flag = aflags & AP_BASIC_FLAGS; |
3063 | object *tmp, *tmp2, *skop = NULL; |
3078 | object *tmp, *tmp2, *skop = NULL; |
… | |
… | |
3078 | if (basic_flag == AP_APPLY) |
3093 | if (basic_flag == AP_APPLY) |
3079 | return 0; |
3094 | return 0; |
3080 | |
3095 | |
3081 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3096 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
3082 | { |
3097 | { |
3083 | new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove %s.", query_name (op)); |
3098 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3099 | "No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, |
|
|
3100 | query_name (op)); |
3084 | return 1; |
3101 | return 1; |
3085 | } |
3102 | } |
3086 | |
3103 | |
3087 | return unapply_special (who, op, aflags); |
3104 | return unapply_special (who, op, aflags); |
3088 | } |
3105 | } |
… | |
… | |
3104 | /* Can't just apply this object. Lets see what not and what to do */ |
3121 | /* Can't just apply this object. Lets see what not and what to do */ |
3105 | if (int i = can_apply_object (who, op)) |
3122 | if (int i = can_apply_object (who, op)) |
3106 | { |
3123 | { |
3107 | if (i & CAN_APPLY_NEVER) |
3124 | if (i & CAN_APPLY_NEVER) |
3108 | { |
3125 | { |
3109 | new_draw_info_format (NDI_UNIQUE, 0, who, "You don't have the body to use a %s\n", query_name (op)); |
3126 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3127 | "You don't have the body to use a %s. H<You can never apply this item.>", |
|
|
3128 | query_name (op)); |
3110 | return 1; |
3129 | return 1; |
3111 | } |
3130 | } |
3112 | else if (i & CAN_APPLY_RESTRICTION) |
3131 | else if (i & CAN_APPLY_RESTRICTION) |
3113 | { |
3132 | { |
3114 | new_draw_info_format (NDI_UNIQUE, 0, who, "You have a prohibition against using a %s\n", query_name (op)); |
3133 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3134 | "You have a prohibition against using a %s. " |
|
|
3135 | "H<Your belief, profession or class prevents you from applying this item.>", |
|
|
3136 | query_name (op)); |
3115 | return 1; |
3137 | return 1; |
3116 | } |
3138 | } |
3117 | |
3139 | |
3118 | if (who->type != PLAYER) |
3140 | if (who->type != PLAYER) |
3119 | { |
3141 | { |
… | |
… | |
3154 | if (who->type == PLAYER |
3176 | if (who->type == PLAYER |
3155 | && op->item_power |
3177 | && op->item_power |
3156 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3178 | && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) |
3157 | { |
3179 | { |
3158 | new_draw_info (NDI_UNIQUE, 0, who, |
3180 | new_draw_info (NDI_UNIQUE, 0, who, |
3159 | "Equipping that combined with other items would consume your soul! " |
3181 | "Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); |
3160 | "[use the skills command to check your available item power]"); |
|
|
3161 | return 1; |
3182 | return 1; |
3162 | } |
3183 | } |
3163 | |
3184 | |
3164 | /* Ok. We are now at the state where we can apply the new object. |
3185 | /* Ok. We are now at the state where we can apply the new object. |
3165 | * Note that we don't have the checks for can_use_... |
3186 | * Note that we don't have the checks for can_use_... |
… | |
… | |
3177 | { |
3198 | { |
3178 | case WEAPON: |
3199 | case WEAPON: |
3179 | if (!check_weapon_power (who, op->last_eat)) |
3200 | if (!check_weapon_power (who, op->last_eat)) |
3180 | { |
3201 | { |
3181 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " |
3202 | new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " |
3182 | "It would consume your soul!."); |
3203 | "It would consume your soul!." LACK_ITEM_POWER); |
3183 | |
3204 | |
3184 | if (tmp) |
3205 | if (tmp) |
3185 | insert_ob_in_ob (tmp, who); |
3206 | insert_ob_in_ob (tmp, who); |
3186 | |
3207 | |
3187 | return 1; |
3208 | return 1; |
… | |
… | |
3191 | // i.e. "R" can use Ragnarok's sword. |
3212 | // i.e. "R" can use Ragnarok's sword. |
3192 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3213 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3193 | { |
3214 | { |
3194 | /* if the weapon does not have the name as the character, can't use it. */ |
3215 | /* if the weapon does not have the name as the character, can't use it. */ |
3195 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3216 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3196 | new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); |
3217 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3218 | "The weapon does not recognize you as its owner. " |
|
|
3219 | "H<Its name indicates that it belongs to somebody else.>"); |
3197 | |
3220 | |
3198 | if (tmp) |
3221 | if (tmp) |
3199 | insert_ob_in_ob (tmp, who); |
3222 | insert_ob_in_ob (tmp, who); |
3200 | |
3223 | |
3201 | return 1; |
3224 | return 1; |
… | |
… | |
3235 | break; |
3258 | break; |
3236 | |
3259 | |
3237 | case LAMP: |
3260 | case LAMP: |
3238 | if (op->stats.food < 1) |
3261 | if (op->stats.food < 1) |
3239 | { |
3262 | { |
3240 | new_draw_info_format (NDI_UNIQUE, 0, who, "Your %s is out of fuel!", &op->name); |
3263 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3264 | "Your %s is out of fuel! " |
|
|
3265 | "H<Lamps and similar items need fuel. They cannot be refilled.>", &op->name); |
3241 | return 1; |
3266 | return 1; |
3242 | } |
3267 | } |
3243 | |
3268 | |
3244 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); |
3269 | new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); |
3245 | tmp2 = arch_to_object (op->other_arch); |
3270 | tmp2 = arch_to_object (op->other_arch); |
… | |
… | |
3268 | who->update_stats (); |
3293 | who->update_stats (); |
3269 | |
3294 | |
3270 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3295 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3271 | if (who->type == PLAYER) |
3296 | if (who->type == PLAYER) |
3272 | { |
3297 | { |
3273 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
3298 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3299 | "Oops, it feels deadly cold! " |
|
|
3300 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3274 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3301 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3275 | } |
3302 | } |
3276 | |
3303 | |
3277 | if (who->type == PLAYER) |
3304 | if (who->type == PLAYER) |
3278 | esrv_send_item (who, tmp2); |
3305 | esrv_send_item (who, tmp2); |
… | |
… | |
3306 | who->change_weapon (pl->combat_ob = item); |
3333 | who->change_weapon (pl->combat_ob = item); |
3307 | goto found_weapon; |
3334 | goto found_weapon; |
3308 | } |
3335 | } |
3309 | } |
3336 | } |
3310 | |
3337 | |
3311 | new_draw_info_format (NDI_UNIQUE, 0, who, "You need to apply a '%s' melee weapon before readying this skill", &op->skill); |
3338 | new_draw_info_format (NDI_UNIQUE, 0, who, |
|
|
3339 | "You need to apply a '%s' melee weapon before readying this skill. " |
|
|
3340 | "H<Some skills need an item, in this case a melee weapon, to function.>", |
|
|
3341 | &op->skill); |
3312 | return 1; |
3342 | return 1; |
3313 | |
3343 | |
3314 | found_weapon:; |
3344 | found_weapon:; |
3315 | } |
3345 | } |
3316 | else |
3346 | else |
… | |
… | |
3326 | //TODO: bows should/must all have skill missile weapon right now |
3356 | //TODO: bows should/must all have skill missile weapon right now |
3327 | who->change_weapon (pl->ranged_ob = item); |
3357 | who->change_weapon (pl->ranged_ob = item); |
3328 | goto found_bow; |
3358 | goto found_bow; |
3329 | } |
3359 | } |
3330 | |
3360 | |
|
|
3361 | new_draw_info (NDI_UNIQUE, 0, who, |
3331 | new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill"); |
3362 | "You need to apply a missile weapon before readying this skill. " |
|
|
3363 | "H<Some skills need an item, in this case a missile weapon, to function.>"); |
3332 | return 1; |
3364 | return 1; |
3333 | |
3365 | |
3334 | found_bow:; |
3366 | found_bow:; |
3335 | } |
3367 | } |
3336 | else |
3368 | else |
… | |
… | |
3356 | break; |
3388 | break; |
3357 | |
3389 | |
3358 | case BOW: |
3390 | case BOW: |
3359 | if (!check_weapon_power (who, op->last_eat)) |
3391 | if (!check_weapon_power (who, op->last_eat)) |
3360 | { |
3392 | { |
3361 | new_draw_info (NDI_UNIQUE, 0, who, "That weapon is too powerful for you to use."); |
3393 | new_draw_info (NDI_UNIQUE, 0, who, |
3362 | new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!."); |
3394 | "That weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER); |
3363 | |
3395 | |
3364 | if (tmp) |
3396 | if (tmp) |
3365 | insert_ob_in_ob (tmp, who); |
3397 | insert_ob_in_ob (tmp, who); |
3366 | |
3398 | |
3367 | return 1; |
3399 | return 1; |
3368 | } |
3400 | } |
3369 | |
3401 | |
3370 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3402 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3371 | { |
3403 | { |
3372 | new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); |
3404 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3405 | "The weapon does not recognize you as its owner. " |
|
|
3406 | "H<Its name indicates that it belongs to somebody else.>"); |
3373 | if (tmp) |
3407 | if (tmp) |
3374 | insert_ob_in_ob (tmp, who); |
3408 | insert_ob_in_ob (tmp, who); |
3375 | |
3409 | |
3376 | return 1; |
3410 | return 1; |
3377 | } |
3411 | } |
… | |
… | |
3445 | */ |
3479 | */ |
3446 | if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) |
3480 | if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) |
3447 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
3481 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
3448 | |
3482 | |
3449 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3483 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3450 | { |
|
|
3451 | if (who->type == PLAYER) |
3484 | if (who->type == PLAYER) |
3452 | { |
3485 | { |
3453 | new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); |
3486 | new_draw_info (NDI_UNIQUE, 0, who, |
|
|
3487 | "Oops, it feels deadly cold! " |
|
|
3488 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3454 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3489 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3455 | } |
3490 | } |
3456 | } |
|
|
3457 | |
3491 | |
3458 | if (who->type == PLAYER) |
3492 | if (who->type == PLAYER) |
3459 | { |
3493 | { |
3460 | /* if multiple objects were applied, update both slots */ |
3494 | /* if multiple objects were applied, update both slots */ |
3461 | if (tmp) |
3495 | if (tmp) |
… | |
… | |
3470 | int |
3504 | int |
3471 | monster_apply_special (object *who, object *op, int aflags) |
3505 | monster_apply_special (object *who, object *op, int aflags) |
3472 | { |
3506 | { |
3473 | if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) |
3507 | if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) |
3474 | return 1; |
3508 | return 1; |
|
|
3509 | |
3475 | return apply_special (who, op, aflags); |
3510 | return apply_special (who, op, aflags); |
3476 | } |
3511 | } |
3477 | |
3512 | |
3478 | /** |
3513 | /** |
3479 | * Map was just loaded, handle op's initialisation. |
3514 | * Map was just loaded, handle op's initialisation. |
… | |
… | |
3805 | |
3840 | |
3806 | if (failure <= -1 && failure > -15) |
3841 | if (failure <= -1 && failure > -15) |
3807 | { /* wonder */ |
3842 | { /* wonder */ |
3808 | object *tmp; |
3843 | object *tmp; |
3809 | |
3844 | |
3810 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); |
3845 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!"); |
3811 | tmp = get_archetype (SPELL_WONDER); |
3846 | tmp = get_archetype (SPELL_WONDER); |
3812 | cast_wonder (op, op, 0, tmp); |
3847 | cast_wonder (op, op, 0, tmp); |
3813 | tmp->destroy (); |
3848 | tmp->destroy (); |
3814 | } |
3849 | } |
3815 | else if (failure <= -15 && failure > -35) |
3850 | else if (failure <= -15 && failure > -35) |
… | |
… | |
3955 | char got[MAX_BUF]; |
3990 | char got[MAX_BUF]; |
3956 | int len; |
3991 | int len; |
3957 | |
3992 | |
3958 | if (!pl || !transformer) |
3993 | if (!pl || !transformer) |
3959 | return; |
3994 | return; |
|
|
3995 | |
3960 | marked = find_marked_object (pl); |
3996 | marked = find_marked_object (pl); |
|
|
3997 | |
3961 | if (!marked) |
3998 | if (!marked) |
3962 | { |
3999 | { |
3963 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); |
4000 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); |
3964 | return; |
4001 | return; |
3965 | } |
4002 | } |
|
|
4003 | |
3966 | if (!marked->slaying) |
4004 | if (!marked->slaying) |
3967 | { |
4005 | { |
3968 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
4006 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
3969 | return; |
4007 | return; |
3970 | } |
4008 | } |
|
|
4009 | |
3971 | /* check whether they are compatible or not */ |
4010 | /* check whether they are compatible or not */ |
3972 | find = strstr (marked->slaying, transformer->arch->archname); |
4011 | find = strstr (marked->slaying, transformer->arch->archname); |
3973 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
4012 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
3974 | { |
4013 | { |
3975 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
4014 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); |
3976 | return; |
4015 | return; |
3977 | } |
4016 | } |
|
|
4017 | |
3978 | find += strlen (transformer->arch->archname) + 1; |
4018 | find += strlen (transformer->arch->archname) + 1; |
3979 | /* Item can be used, now find how many and what it yields */ |
4019 | /* Item can be used, now find how many and what it yields */ |
3980 | if (isdigit (*(find))) |
4020 | if (isdigit (*(find))) |
3981 | { |
4021 | { |
3982 | yield = atoi (find); |
4022 | yield = atoi (find); |
… | |
… | |
3991 | |
4031 | |
3992 | while (isdigit (*find)) |
4032 | while (isdigit (*find)) |
3993 | find++; |
4033 | find++; |
3994 | while (*find == ' ') |
4034 | while (*find == ' ') |
3995 | find++; |
4035 | find++; |
|
|
4036 | |
3996 | memset (got, 0, MAX_BUF); |
4037 | memset (got, 0, MAX_BUF); |
|
|
4038 | |
3997 | if ((separator = strchr (find, ';')) != NULL) |
4039 | if ((separator = strchr (find, ';')) != NULL) |
3998 | { |
|
|
3999 | len = separator - find; |
4040 | len = separator - find; |
4000 | } |
|
|
4001 | else |
4041 | else |
4002 | { |
|
|
4003 | len = strlen (find); |
4042 | len = strlen (find); |
4004 | } |
4043 | |
4005 | if (len > MAX_BUF - 1) |
4044 | if (len > MAX_BUF - 1) |
4006 | len = MAX_BUF - 1; |
4045 | len = MAX_BUF - 1; |
|
|
4046 | |
4007 | strcpy (got, find); |
4047 | strcpy (got, find); |
4008 | got[len] = '\0'; |
4048 | got[len] = '\0'; |
4009 | |
4049 | |
4010 | /* Now create new item, remove used ones when required. */ |
4050 | /* Now create new item, remove used ones when required. */ |
4011 | new_item = get_archetype (got); |
4051 | new_item = get_archetype (got); |
… | |
… | |
4019 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); |
4059 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); |
4020 | insert_ob_in_ob (new_item, pl); |
4060 | insert_ob_in_ob (new_item, pl); |
4021 | esrv_send_inventory (pl, pl); |
4061 | esrv_send_inventory (pl, pl); |
4022 | /* Eat up one item */ |
4062 | /* Eat up one item */ |
4023 | decrease_ob_nr (marked, 1); |
4063 | decrease_ob_nr (marked, 1); |
|
|
4064 | |
4024 | /* Eat one transformer if needed */ |
4065 | /* Eat one transformer if needed */ |
4025 | if (transformer->stats.food) |
4066 | if (transformer->stats.food) |
4026 | if (--transformer->stats.food == 0) |
4067 | if (--transformer->stats.food == 0) |
4027 | decrease_ob_nr (transformer, 1); |
4068 | decrease_ob_nr (transformer, 1); |
4028 | } |
4069 | } |