--- deliantra/server/server/apply.C 2007/07/10 05:51:38 1.113 +++ deliantra/server/server/apply.C 2007/07/10 06:44:31 1.114 @@ -577,18 +577,17 @@ } /* Types of improvements, hidden in the sp field. */ -#define IMPROVE_PREPARE 1 -#define IMPROVE_DAMAGE 2 -#define IMPROVE_WEIGHT 3 -#define IMPROVE_ENCHANT 4 -#define IMPROVE_STR 5 -#define IMPROVE_DEX 6 -#define IMPROVE_CON 7 -#define IMPROVE_WIS 8 -#define IMPROVE_CHA 9 -#define IMPROVE_INT 10 -#define IMPROVE_POW 11 - +#define IMPROVE_PREPARE 1 +#define IMPROVE_DAMAGE 2 +#define IMPROVE_WEIGHT 3 +#define IMPROVE_ENCHANT 4 +#define IMPROVE_STR 5 +#define IMPROVE_DEX 6 +#define IMPROVE_CON 7 +#define IMPROVE_WIS 8 +#define IMPROVE_CHA 9 +#define IMPROVE_INT 10 +#define IMPROVE_POW 11 /** * This does the prepare weapon scroll. @@ -1564,7 +1563,7 @@ skill_ob = find_skill_by_name (op, tmp->skill); if (!skill_ob) { - new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); + new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H"); return; } @@ -1734,8 +1733,7 @@ * instead of having their spell stored in stats.sp. These are * legacy spellbooks */ - - if (tmp->slaying != NULL) + if (tmp->slaying) { spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); if (!spell) @@ -1745,7 +1743,8 @@ } else insert_ob_in_ob (spell, tmp); - tmp->slaying = NULL; + + tmp->slaying = 0; } skop = find_skill_by_name (op, tmp->skill); @@ -1754,7 +1753,7 @@ * lower than the spell will make learning the spell more difficult */ if (!skop) { - new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails."); + new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails. H"); return; } @@ -1763,13 +1762,13 @@ if (!spell) { LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); - new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense."); + new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense. This is a bug, please report!"); return; } if (skop->level < int (sqrtf (spell->level) * 1.5f)) { - new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. [Your literacy level is too low]"); + new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H"); return; } @@ -1792,7 +1791,7 @@ */ if (check_spell_known (op, spell->name)) { - new_draw_info (NDI_UNIQUE, 0, op, "You already know that spell.\n"); + new_draw_info (NDI_UNIQUE, 0, op, "You already know that spell. H\n"); return; } @@ -1844,7 +1843,7 @@ else { play_sound_player_only (op->contr, SOUND_FUMBLE_SPELL, 0, 0); - new_draw_info (NDI_UNIQUE, 0, op, "You fail to learn the spell.\n"); + new_draw_info (NDI_UNIQUE, 0, op, "You fail to learn the spell. H\n"); } decrease_ob (tmp); @@ -1866,7 +1865,7 @@ if (!tmp->inv || tmp->inv->type != SPELL) { - new_draw_info (NDI_UNIQUE, 0, op, "The scroll just doesn't make sense!"); + new_draw_info (NDI_UNIQUE, 0, op, "The scroll just doesn't make sense! H<...and never will make sense.>"); return; } @@ -1882,7 +1881,7 @@ if (!skop) { - new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); + new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H"); return; } @@ -2013,6 +2012,7 @@ eat_special_food (op, tmp); } } + handle_apply_yield (tmp); decrease_ob (tmp); } @@ -2184,9 +2184,9 @@ { object *armor; - if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) + if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) { - new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll."); + new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll. H"); return; } @@ -2194,7 +2194,7 @@ if (!armor) { - new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object."); + 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."); return; } @@ -2219,11 +2219,13 @@ new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!"); strcpy (op->contr->killer, "poisonous booze"); } + if (tmp->stats.hp > 0) { LOG (llevDebug, "Trying to poison player/monster for %d hp\n", tmp->stats.hp); hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); } + op->stats.food -= op->stats.food / 4; handle_apply_yield (tmp); decrease_ob (tmp); @@ -2343,7 +2345,7 @@ { if (op->type == PLAYER) { - new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first."); + new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first. H"); return 1; } else @@ -2561,12 +2563,12 @@ { int tmp; - if (op->env == NULL && (pl->move_type & MOVE_FLYING)) + if (op->env && (pl->move_type & MOVE_FLYING)) { /* player is flying and applying object not in inventory */ if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) { - new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high " "above the ground!"); + new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high above the ground! H"); return 0; } } @@ -2581,6 +2583,7 @@ else if (tmp == 2) new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n"); } + return tmp; } @@ -2830,6 +2833,12 @@ * instead of doing it. This is a lot less code than having * another function that does just that. */ + +#define CANNOT_REMOVE_CURSED \ + "H" + int unapply_for_ob (object *who, object *op, int aflags) { @@ -2849,7 +2858,9 @@ * While we know it won't work, we want unapply_special to * at least generate the message. */ - new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove the %s.", query_name (tmp)); + new_draw_info_format (NDI_UNIQUE, 0, who, + "No matter how hard you try, you just can't remove the %s." CANNOT_REMOVE_CURSED, + query_name (tmp)); return 1; } @@ -2893,7 +2904,7 @@ * so it may not be critical (eg, putting on a ring and you have * one cursed ring.) */ - new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off", query_name (tmp)); + new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp)); } last = tmp->below; @@ -3056,6 +3067,10 @@ * * apply_special() doesn't check for unpaid items. */ + +#define LACK_ITEM_POWER \ + " H" + int apply_special (object *who, object *op, int aflags) { @@ -3080,7 +3095,9 @@ if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) { - new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove %s.", query_name (op)); + new_draw_info_format (NDI_UNIQUE, 0, who, + "No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, + query_name (op)); return 1; } @@ -3106,12 +3123,17 @@ { if (i & CAN_APPLY_NEVER) { - new_draw_info_format (NDI_UNIQUE, 0, who, "You don't have the body to use a %s\n", query_name (op)); + new_draw_info_format (NDI_UNIQUE, 0, who, + "You don't have the body to use a %s. H", + query_name (op)); return 1; } else if (i & CAN_APPLY_RESTRICTION) { - new_draw_info_format (NDI_UNIQUE, 0, who, "You have a prohibition against using a %s\n", query_name (op)); + new_draw_info_format (NDI_UNIQUE, 0, who, + "You have a prohibition against using a %s. " + "H", + query_name (op)); return 1; } @@ -3156,8 +3178,7 @@ && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) { new_draw_info (NDI_UNIQUE, 0, who, - "Equipping that combined with other items would consume your soul! " - "[use the skills command to check your available item power]"); + "Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); return 1; } @@ -3179,7 +3200,7 @@ if (!check_weapon_power (who, op->last_eat)) { new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " - "It would consume your soul!."); + "It would consume your soul!." LACK_ITEM_POWER); if (tmp) insert_ob_in_ob (tmp, who); @@ -3193,7 +3214,9 @@ { /* if the weapon does not have the name as the character, can't use it. */ /* (Ragnarok's sword attempted to be used by Foo: won't work) */ - new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); + new_draw_info (NDI_UNIQUE, 0, who, + "The weapon does not recognize you as its owner. " + "H"); if (tmp) insert_ob_in_ob (tmp, who); @@ -3237,7 +3260,9 @@ case LAMP: if (op->stats.food < 1) { - new_draw_info_format (NDI_UNIQUE, 0, who, "Your %s is out of fuel!", &op->name); + new_draw_info_format (NDI_UNIQUE, 0, who, + "Your %s is out of fuel! " + "H", &op->name); return 1; } @@ -3270,7 +3295,9 @@ if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) if (who->type == PLAYER) { - new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); + new_draw_info (NDI_UNIQUE, 0, who, + "Oops, it feels deadly cold! " + "H"); SET_FLAG (tmp2, FLAG_KNOWN_CURSED); } @@ -3308,7 +3335,10 @@ } } - new_draw_info_format (NDI_UNIQUE, 0, who, "You need to apply a '%s' melee weapon before readying this skill", &op->skill); + new_draw_info_format (NDI_UNIQUE, 0, who, + "You need to apply a '%s' melee weapon before readying this skill. " + "H", + &op->skill); return 1; found_weapon:; @@ -3328,7 +3358,9 @@ goto found_bow; } - new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill"); + new_draw_info (NDI_UNIQUE, 0, who, + "You need to apply a missile weapon before readying this skill. " + "H"); return 1; found_bow:; @@ -3358,8 +3390,8 @@ case BOW: if (!check_weapon_power (who, op->last_eat)) { - new_draw_info (NDI_UNIQUE, 0, who, "That weapon is too powerful for you to use."); - new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!."); + new_draw_info (NDI_UNIQUE, 0, who, + "That weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER); if (tmp) insert_ob_in_ob (tmp, who); @@ -3369,7 +3401,9 @@ if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) { - new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); + new_draw_info (NDI_UNIQUE, 0, who, + "The weapon does not recognize you as its owner. " + "H"); if (tmp) insert_ob_in_ob (tmp, who); @@ -3447,13 +3481,13 @@ SET_FLAG (op, FLAG_BEEN_APPLIED); if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) - { - if (who->type == PLAYER) - { - new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); - SET_FLAG (op, FLAG_KNOWN_CURSED); - } - } + if (who->type == PLAYER) + { + new_draw_info (NDI_UNIQUE, 0, who, + "Oops, it feels deadly cold! " + "H"); + SET_FLAG (op, FLAG_KNOWN_CURSED); + } if (who->type == PLAYER) { @@ -3472,6 +3506,7 @@ { if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) return 1; + return apply_special (who, op, aflags); } @@ -3807,7 +3842,7 @@ { /* wonder */ object *tmp; - new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); + new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!"); tmp = get_archetype (SPELL_WONDER); cast_wonder (op, op, 0, tmp); tmp->destroy (); @@ -3957,17 +3992,21 @@ if (!pl || !transformer) return; + marked = find_marked_object (pl); + if (!marked) { new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); return; } + if (!marked->slaying) { new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); return; } + /* check whether they are compatible or not */ find = strstr (marked->slaying, transformer->arch->archname); if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) @@ -3975,6 +4014,7 @@ new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); return; } + find += strlen (transformer->arch->archname) + 1; /* Item can be used, now find how many and what it yields */ if (isdigit (*(find))) @@ -3993,17 +4033,17 @@ find++; while (*find == ' ') find++; + memset (got, 0, MAX_BUF); + if ((separator = strchr (find, ';')) != NULL) - { - len = separator - find; - } + len = separator - find; else - { - len = strlen (find); - } + len = strlen (find); + if (len > MAX_BUF - 1) len = MAX_BUF - 1; + strcpy (got, find); got[len] = '\0'; @@ -4021,6 +4061,7 @@ esrv_send_inventory (pl, pl); /* Eat up one item */ decrease_ob_nr (marked, 1); + /* Eat one transformer if needed */ if (transformer->stats.food) if (--transformer->stats.food == 0)