ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/apply.C
(Generate patch)

Comparing deliantra/server/server/apply.C (file contents):
Revision 1.113 by root, Tue Jul 10 05:51:38 2007 UTC vs.
Revision 1.117 by elmex, Mon Jul 16 14:49:01 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines