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.223 by elmex, Fri Mar 19 17:53:06 2010 UTC vs.
Revision 1.240 by root, Mon Apr 5 20:33:13 2010 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
30#include <skills.h> 30#include <skills.h>
31#include <tod.h> 31#include <tod.h>
32 32
33#include <sproto.h> 33#include <sproto.h>
34 34
35/* Want this regardless of rplay. */
36#include <sounds.h>
37
38/** 35/**
39 * Check if op should abort moving victim because of it's race or slaying. 36 * Check if op should abort moving victim because of it's race or slaying.
40 * Returns 1 if it should abort, returns 0 if it should continue. 37 * Returns 1 if it should abort, returns 0 if it should continue.
41 */ 38 */
42int 39int
172 */ 169 */
173int 170int
174apply_potion (object *op, object *tmp) 171apply_potion (object *op, object *tmp)
175{ 172{
176 int got_one = 0, i; 173 int got_one = 0, i;
177 object *force = 0, *floor = 0; 174 object *force = 0;
178 175
179 floor = GET_MAP_OB (op->map, op->x, op->y); 176 object *floor = GET_MAP_OB (op->map, op->x, op->y);
180 177
181 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 178 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
182 { 179 {
183 op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); 180 op->failmsg ("Gods prevent you from using this here, it's sacred ground!");
184 181
951 item->nrof *= nr; 948 item->nrof *= nr;
952 949
953 if (converter->flag [FLAG_PRECIOUS]) 950 if (converter->flag [FLAG_PRECIOUS])
954 SET_FLAG (item, FLAG_UNPAID); 951 SET_FLAG (item, FLAG_UNPAID);
955 952
956 if (is_in_shop (converter)) 953 if (converter->is_in_shop ())
957 { 954 {
958 // converters on shop floors don't work anymore, bug lets check for it 955 // converters on shop floors don't work anymore, bug lets check for it
959 // and report in case someone still does it. 956 // and report in case someone still does it.
960 LOG (llevDebug, "ITEMBUG: broken converter, converters on shop floor don't work: %s\n", 957 LOG (llevDebug, "ITEMBUG: broken converter, converters on shop floor don't work: %s\n",
961 converter->debug_desc ()); 958 converter->debug_desc ());
1164 /* this is only used for players */ 1161 /* this is only used for players */
1165 rv = teleport (shop_mat, SHOP_MAT, op); 1162 rv = teleport (shop_mat, SHOP_MAT, op);
1166 1163
1167 if (has_unpaid) 1164 if (has_unpaid)
1168 op->contr->play_sound (sound_find ("shop_buy")); 1165 op->contr->play_sound (sound_find ("shop_buy"));
1169 else if (is_in_shop (op)) 1166 else if (op->is_in_shop ())
1170 op->contr->play_sound (sound_find ("shop_enter")); 1167 op->contr->play_sound (sound_find ("shop_enter"));
1171 else 1168 else
1172 op->contr->play_sound (sound_find ("shop_leave")); 1169 op->contr->play_sound (sound_find ("shop_leave"));
1173 1170
1174 if (shop_mat->msg) 1171 if (shop_mat->msg)
1175 op->statusmsg (shop_mat->msg); 1172 op->statusmsg (shop_mat->msg);
1176 /* This check below is a bit simplistic - generally it should be correct, 1173 /* This check below is a bit simplistic - generally it should be correct,
1177 * but there is never a guarantee that the bottom space on the map is 1174 * but there is never a guarantee that the bottom space on the map is
1178 * actually the shop floor. 1175 * actually the shop floor.
1179 */ 1176 */
1180 else if (!rv && !is_in_shop (op)) 1177 else if (!rv && !op->is_in_shop ())
1181 { 1178 {
1182 opinion = shopkeeper_approval (op->map, op); 1179 opinion = shopkeeper_approval (op->map, op);
1183 1180
1184 op->statusmsg ( 1181 op->statusmsg (
1185 opinion >= 0.90 ? "The shopkeeper gives you a friendly wave." 1182 opinion >= 0.90 ? "The shopkeeper gives you a friendly wave."
1488 if (victim->type == PLAYER && EXIT_PATH (trap)) 1485 if (victim->type == PLAYER && EXIT_PATH (trap))
1489 { 1486 {
1490 /* Basically, don't show exits leading to random maps the 1487 /* Basically, don't show exits leading to random maps the
1491 * players output. 1488 * players output.
1492 */ 1489 */
1493 if (trap->msg && !EXIT_PATH (trap).starts_with ("/!")) 1490 if (trap->msg && EXIT_PATH (trap) != shstr_random_map_exit)
1494 victim->statusmsg (trap->msg, NDI_NAVY); 1491 victim->statusmsg (trap->msg, NDI_NAVY);
1495 1492
1496 trap->play_sound (trap->sound); 1493 trap->play_sound (trap->sound);
1497 victim->enter_exit (trap); 1494 victim->enter_exit (trap);
1498 } 1495 }
1742 LOG (llevError, "BUG: do_forget_spell(): spell not known\n"); 1739 LOG (llevError, "BUG: do_forget_spell(): spell not known\n");
1743 return; 1740 return;
1744 } 1741 }
1745 1742
1746 op->failmsg (format ("You lose knowledge of %s.", spell)); 1743 op->failmsg (format ("You lose knowledge of %s.", spell));
1747 player_unready_range_ob (op->contr, spob);
1748 esrv_remove_spell (op->contr, spob); 1744 esrv_remove_spell (op->contr, spob);
1749 spob->destroy (); 1745 spob->destroy ();
1750} 1746}
1751 1747
1752/** 1748/**
1809 op->failmsg (format ("You are unable to decipher the strange symbols. H<Your %s level is too low, it must be at least %d.>", 1805 op->failmsg (format ("You are unable to decipher the strange symbols. H<Your %s level is too low, it must be at least %d.>",
1810 &tmp->skill, learn_level)); 1806 &tmp->skill, learn_level));
1811 return; 1807 return;
1812 } 1808 }
1813 1809
1814 op->statusmsg (format ("The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name)); 1810 op->statusmsg (format ("The spellbook contains the %s level spell %s.", ordinal (spell->level), &spell->name));
1815 1811
1816 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 1812 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED))
1817 identify (tmp); 1813 identify (tmp);
1818 1814
1819 /* I removed the check for special_prayer_mark here - it didn't make 1815 /* I removed the check for special_prayer_mark here - it didn't make
1831 { 1827 {
1832 spell_skill = find_skill_by_name (op, spell->skill); 1828 spell_skill = find_skill_by_name (op, spell->skill);
1833 1829
1834 if (!spell_skill) 1830 if (!spell_skill)
1835 { 1831 {
1836 op->failmsg (format ("You lack the skill %s to use this spell.", &spell->skill)); 1832 op->failmsg (format ("You lack the %s skill to use this spell.", &spell->skill));
1837 return; 1833 return;
1838 } 1834 }
1839 1835
1840 if (spell_skill->level < spell->level) 1836 if (spell_skill->level < spell->level)
1841 { 1837 {
2019 which is not to be considered a dragon -> bail out */ 2015 which is not to be considered a dragon -> bail out */
2020 if (skin == NULL || abil == NULL) 2016 if (skin == NULL || abil == NULL)
2021 return 0; 2017 return 0;
2022 2018
2023 /* now start by filling stomache and health, according to food-value */ 2019 /* now start by filling stomache and health, according to food-value */
2024 if ((999 - op->stats.food) < meal->stats.food) 2020 if ((MAX_FOOD - op->stats.food) < meal->stats.food)
2025 op->stats.hp += (999 - op->stats.food) / 50; 2021 op->stats.hp += (MAX_FOOD - op->stats.food) / 50;
2026 else 2022 else
2027 op->stats.hp += meal->stats.food / 50; 2023 op->stats.hp += meal->stats.food / 50;
2028 2024
2029 if (op->stats.hp > op->stats.maxhp) 2025 min_it (op->stats.hp, op->stats.maxhp);
2030 op->stats.hp = op->stats.maxhp;
2031
2032 op->stats.food = min (999, op->stats.food + meal->stats.food); 2026 op->stats.food = min (MAX_FOOD, op->stats.food + meal->stats.food);
2033 2027
2034 /*LOG(llevDebug, "-> player: %d, flesh: %d\n", op->level, meal->level); */ 2028 /*LOG(llevDebug, "-> player: %d, flesh: %d\n", op->level, meal->level); */
2035 2029
2036 /* on to the interesting part: chances for adding resistance */ 2030 /* on to the interesting part: chances for adding resistance */
2037 for (i = 0; i < NROFATTACKS; i++) 2031 for (i = 0; i < NROFATTACKS; i++)
2154 if (tmp->type == FLESH && op->is_dragon () && dragon_eat_flesh (op, tmp)) 2148 if (tmp->type == FLESH && op->is_dragon () && dragon_eat_flesh (op, tmp))
2155 ; 2149 ;
2156 else 2150 else
2157 { 2151 {
2158 /* usual case - no dragon meal: */ 2152 /* usual case - no dragon meal: */
2159 if (op->stats.food + tmp->stats.food > 999) 2153 if (op->stats.food + tmp->stats.food > MAX_FOOD)
2160 { 2154 {
2161 if (tmp->type == FOOD || tmp->type == FLESH) 2155 if (tmp->type == FOOD || tmp->type == FLESH)
2162 op->failmsg ("You feel full, but what a waste of food!"); 2156 op->failmsg ("You feel full, but what a waste of food!");
2163 else 2157 else
2164 op->statusmsg ("Most of the drink goes down your face not your throat!"); 2158 op->statusmsg ("Most of the drink goes down your face not your throat!");
2188 /* eating message for dragon players */ 2182 /* eating message for dragon players */
2189 buf = format ("The %s tasted terrible!", &tmp->name); 2183 buf = format ("The %s tasted terrible!", &tmp->name);
2190 2184
2191 op->statusmsg (buf); 2185 op->statusmsg (buf);
2192 2186
2193 capacity_remaining = 999 - op->stats.food; 2187 capacity_remaining = MAX_FOOD - op->stats.food;
2194 op->stats.food += tmp->stats.food; 2188 op->stats.food += tmp->stats.food;
2195 if (capacity_remaining < tmp->stats.food) 2189 if (capacity_remaining < tmp->stats.food)
2196 op->stats.hp += capacity_remaining / 50; 2190 op->stats.hp += capacity_remaining / 50;
2197 else 2191 else
2198 op->stats.hp += tmp->stats.food / 50; 2192 op->stats.hp += tmp->stats.food / 50;
2199 2193
2200 if (op->stats.hp > op->stats.maxhp) 2194 min_it (op->stats.hp, op->stats.maxhp);
2201 op->stats.hp = op->stats.maxhp; 2195 min_it (op->stats.food, MAX_FOOD);
2202 if (op->stats.food > 999)
2203 op->stats.food = 999;
2204 } 2196 }
2205 2197
2206 /* special food hack -b.t. */ 2198 /* special food hack -b.t. */
2207 if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) 2199 if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED))
2208 eat_special_food (op, tmp); 2200 eat_special_food (op, tmp);
2269 hit_player (op, poison->stats.hp, tmp, AT_POISON, 1); 2261 hit_player (op, poison->stats.hp, tmp, AT_POISON, 1);
2270 } 2262 }
2271 2263
2272 op->stats.food -= op->stats.food / 4; 2264 op->stats.food -= op->stats.food / 4;
2273 poison->destroy (); 2265 poison->destroy ();
2274}
2275
2276/**
2277 * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit.
2278 * A valid 2 way exit means:
2279 * -You can come back (there is another exit at the other side)
2280 * -You are
2281 * ° the owner of the exit
2282 * ° or in the same party as the owner
2283 *
2284 * Note: a owner in a 2 way exit is saved as the owner's name
2285 * in the field exit->name cause the field exit->owner doesn't
2286 * survive in the swapping (in fact the whole exit doesn't survive).
2287 */
2288static int
2289is_legal_2ways_exit (object *op, object *exit)
2290{
2291 if (exit->stats.exp != 1)
2292 return 1; /*This is not a 2 way, so it is legal */
2293
2294#if 0 //TODO
2295 if (!has_been_loaded (EXIT_PATH (exit)) && exit->race)
2296 return 0; /* This is a reset town portal */
2297#endif
2298
2299 LOG (llevError | logBacktrace, "sync map load due to %s\n", exit->debug_desc ());
2300
2301 maptile *exitmap = maptile::find_sync (EXIT_PATH (exit), exit->map);
2302
2303 if (exitmap)
2304 {
2305 exitmap->load_sync ();
2306
2307 object *tmp = exitmap->at (EXIT_X (exit), EXIT_Y (exit)).bot;
2308
2309 if (!tmp)
2310 return 0;
2311
2312 for (; tmp; tmp = tmp->above)
2313 {
2314 if (tmp->type != EXIT)
2315 continue; /*Not an exit */
2316
2317 if (!EXIT_PATH (tmp))
2318 continue; /*Not a valid exit */
2319
2320 if ((EXIT_X (tmp) != exit->x) || (EXIT_Y (tmp) != exit->y))
2321 continue; /*Not in the same place */
2322
2323 if (exit->map->path != EXIT_PATH (tmp))
2324 continue; /*Not in the same map */
2325
2326 /* From here we have found the exit is valid. However we do
2327 * here the check of the exit owner. It is important for the
2328 * town portals to prevent strangers from visiting your appartments
2329 */
2330 if (!exit->race)
2331 return 1; /*No owner, free for all! */
2332
2333 object *exit_owner = 0;
2334
2335 for_all_players (pp)
2336 {
2337 if (!pp->ob)
2338 continue;
2339
2340 if (pp->ob->name != exit->race)
2341 continue;
2342
2343 exit_owner = pp->ob; /*We found a player which correspond to the player name */
2344 break;
2345 }
2346
2347 if (!exit_owner)
2348 return 0; /* No more owner */
2349
2350 if (exit_owner->contr == op->contr)
2351 return 1; /*It is your exit */
2352
2353 if (exit_owner && /*There is a owner */
2354 (op->contr) && /*A player tries to pass */
2355 ((exit_owner->contr->party == NULL) || /*No pass if controller has no party */
2356 (exit_owner->contr->party != op->contr->party))) /* Or not the same as op */
2357 return 0;
2358
2359 return 1;
2360 }
2361 }
2362
2363 return 0;
2364} 2266}
2365 2267
2366/** 2268/**
2367 * This function will try to apply a lighter and in case no lighter 2269 * This function will try to apply a lighter and in case no lighter
2368 * is specified it will try to find a lighter in the players inventory, 2270 * is specified it will try to find a lighter in the players inventory,
2724 * being applied. 2626 * being applied.
2725 * 2627 *
2726 * aflag is special (always apply/unapply) flags. Nothing is done with 2628 * aflag is special (always apply/unapply) flags. Nothing is done with
2727 * them in this function - they are passed to apply_special 2629 * them in this function - they are passed to apply_special
2728 */ 2630 */
2729int 2631static int
2730manual_apply (object *who, object *op, int aflag) 2632manual_apply (object *who, object *op, int aflag)
2731{ 2633{
2732 op = op->head_ (); 2634 op = op->head_ ();
2733 2635
2734 if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) 2636 if (op->flag [FLAG_UNPAID] && !op->flag [FLAG_APPLIED])
2735 { 2637 {
2736 if (who->type == PLAYER) 2638 if (who->type == PLAYER)
2737 { 2639 {
2738 examine (who, op); 2640 examine (who, op);
2739 //who->failmsg ("You should pay for it first! H<You cannot use items marked as unpaid.>");//TODO remove 2641 //who->failmsg ("You should pay for it first! H<You cannot use items marked as unpaid.>");//TODO remove
2770 2672
2771 case EXIT: 2673 case EXIT:
2772 if (who->type != PLAYER) 2674 if (who->type != PLAYER)
2773 return 0; 2675 return 0;
2774 2676
2775 if (!EXIT_PATH (op) || !is_legal_2ways_exit (who, op)) 2677 if (!EXIT_PATH (op))
2776 who->failmsg (format ("The %s is closed. H<And will stay closed, until somebody fires up the map editor and adds it.>", query_name (op))); 2678 who->failmsg (format ("The %s is closed. H<And will stay closed, until somebody fires up the map editor and adds it.>", query_name (op)));
2777 else 2679 else
2778 { 2680 {
2779 /* Don't display messages for random maps. */ 2681 /* Don't display messages for random maps. */
2780 if (op->msg && !EXIT_PATH (op).starts_with ("/!")) 2682 if (op->msg && EXIT_PATH (op) != shstr_random_map_exit)
2781 who->statusmsg (op->msg, NDI_NAVY); 2683 who->statusmsg (op->msg, NDI_NAVY);
2782 2684
2783 who->enter_exit (op); 2685 who->enter_exit (op);
2784 } 2686 }
2785 2687
2866 case CLOAK: 2768 case CLOAK:
2867 case WAND: 2769 case WAND:
2868 case ROD: 2770 case ROD:
2869 case HORN: 2771 case HORN:
2870 case SKILL: 2772 case SKILL:
2773 case SPELL:
2871 case BOW: 2774 case BOW:
2775 case RANGED:
2872 case BUILDER: 2776 case BUILDER:
2873 case SKILL_TOOL: 2777 case SKILL_TOOL:
2874 if (op->env != who) 2778 if (op->env != who)
2875 return 2; /* not in inventory */ 2779 who->failmsg (format ("You must get it first! H<You can only apply the %s if it is in your inventory.>\n", query_name (op)));
2876 2780 else
2877 apply_special (who, op, aflag); 2781 apply_special (who, op, aflag);
2782
2878 return 1; 2783 return 1;
2879 2784
2880 case DRINK: 2785 case DRINK:
2881 case FOOD: 2786 case FOOD:
2882 case FLESH: 2787 case FLESH:
2946 case ITEM_TRANSFORMER: 2851 case ITEM_TRANSFORMER:
2947 apply_item_transformer (who, op); 2852 apply_item_transformer (who, op);
2948 return 1; 2853 return 1;
2949 2854
2950 default: 2855 default:
2856 who->statusmsg (format ("I don't know how to apply the %s.", query_name (op)));
2951 return 0; 2857 return 0;
2952 } 2858 }
2953} 2859}
2954 2860
2955/* quiet suppresses the "don't know how to apply" and "you must get it first" 2861/*
2956 * messages as needed by player_apply_below(). But there can still be
2957 * "but you are floating high above the ground" messages.
2958 *
2959 * Same return value as apply() function. 2862 * Same return value as apply() function.
2960 */ 2863 */
2961int 2864bool
2962player_apply (object *pl, object *op, int aflag, int quiet) 2865player_apply (object *pl, object *op, int aflag)
2963{ 2866{
2964 if (!op->env && (pl->move_type & MOVE_FLYING)) 2867 if (!op->env && (pl->move_type & MOVE_FLYING))
2965 { 2868 {
2966 /* player is flying and applying object not in inventory */ 2869 /* player is flying and applying object not in inventory */
2967 if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) 2870 if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING))
2973 } 2876 }
2974 } 2877 }
2975 2878
2976 pl->contr->last_used = op; 2879 pl->contr->last_used = op;
2977 2880
2978 int tmp = manual_apply (pl, op, aflag); 2881 return pl->apply (op, aflag);
2979
2980 if (!quiet)
2981 {
2982 if (tmp == 0)
2983 pl->statusmsg (format ("I don't know how to apply the %s.", query_name (op)));
2984 else if (tmp == 2)
2985 pl->failmsg ("You must get it first!\n");
2986 }
2987
2988 return tmp;
2989} 2882}
2990 2883
2991/** 2884/**
2992 * player_apply_below attempts to apply the object 'below' the player. 2885 * player_apply_below attempts to apply the object 'below' the player.
2993 * If the player has an open container, we use that for below, otherwise 2886 * If the player has an open container, we use that for below, otherwise
3004 * we don't use a corrupt pointer for the next object, so we get the 2897 * we don't use a corrupt pointer for the next object, so we get the
3005 * next object in the stack before applying. This is can only be a 2898 * next object in the stack before applying. This is can only be a
3006 * problem if player_apply() has a bug in that it uses the object but does 2899 * problem if player_apply() has a bug in that it uses the object but does
3007 * not return a proper value. 2900 * not return a proper value.
3008 */ 2901 */
2902 //TODO: currently looks only at the topmost objetc, no longer at multiple floors
2903 // and also not on move_on floors. what was this for, anyways?
3009 for (object *next, *tmp = pl->container_ () ? pl->container_ ()->inv : pl->below; tmp; tmp = next) 2904 for (object *next, *tmp = pl->container_ () ? pl->container_ ()->inv : pl->below; tmp; tmp = next)
3010 { 2905 {
3011 next = tmp->below; 2906 next = tmp->below;
3012 2907
3013 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
3014 floors++;
3015 else if (floors > 0)
3016 return; /* process only floor objects after first floor object */
3017
3018 /* If it is visible, player can apply it. If it is applied by 2908 /* If it is visible, player can apply it.
3019 * person moving on it, also activate. Added code to make it
3020 * so that at least one of players movement types be that which
3021 * the item needs.
3022 */ 2909 */
3023 if (!tmp->invisible || (tmp->move_on & pl->move_type)) 2910 if (!tmp->invisible)
3024 if (player_apply (pl, tmp, 0, 1) == 1) 2911 if (player_apply (pl, tmp, 0))
3025 return; 2912 break;
3026 2913
3027 if (floors >= 2) 2914 break;
3028 return; /* process at most two floor objects */
3029 } 2915 }
3030} 2916}
3031 2917
3032/** 2918/**
3033 * Unapplies specified item. 2919 * Unapplies specified item.
3040{ 2926{
3041 if (INVOKE_OBJECT (BE_UNREADY, op, ARG_OBJECT (who), ARG_INT (aflags)) 2927 if (INVOKE_OBJECT (BE_UNREADY, op, ARG_OBJECT (who), ARG_INT (aflags))
3042 || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags))) 2928 || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags)))
3043 return RESULT_INT (0); 2929 return RESULT_INT (0);
3044 2930
3045 CLEAR_FLAG (op, FLAG_APPLIED); 2931 if (who->current_weapon == op)
2932 who->current_weapon = 0;
2933
2934 op->flag [FLAG_APPLIED] = false;
3046 2935
3047 switch (op->type) 2936 switch (op->type)
3048 { 2937 {
3049 case SKILL_TOOL: 2938 case SKILL:
2939 if (player *pl = who->contr)
2940 if (op->invisible)
2941 pl->statusmsg (format ("You can no longer use the %s skill.", &op->skill));
2942 else
2943 pl->statusmsg (format ("You stop using the %s.", query_name (op)));
2944
2945 change_abil (who, op);
2946 who->flag [FLAG_READY_SKILL] = false;
2947 break;
2948
2949 case WEAPON:
2950 who->statusmsg (format ("You unwield %s.", query_name (op)));
2951 change_abil (who, op);
2952 who->flag [FLAG_READY_WEAPON] = false;
2953
3050 // unapplying a skill tool should also unapply the skill it governs 2954 // unapplying a weapon or skill tool should also unapply the skill it governs
3051 // but this is hard, as it shouldn't do so when the skill can 2955 // but this is hard, as it shouldn't do so when the skill can
3052 // be used for other reasons 2956 // be used for other reasons
3053 for (object *tmp = who->inv; tmp; tmp = tmp->below) 2957 if (who->chosen_skill)
3054 if (tmp->skill == op->skill 2958 if (!who->chosen_skill->flag [FLAG_CAN_USE_SKILL])
3055 && tmp->type == SKILL
3056 && tmp->flag [FLAG_APPLIED]
3057 && !tmp->flag [FLAG_CAN_USE_SKILL])
3058 unapply_special (who, tmp, 0); 2959 unapply_special (who, op, 0);
3059 2960
3060 change_abil (who, op);
3061 break; 2961 break;
3062 2962
2963 case BOW:
3063 case WEAPON: 2964 case WAND:
2965 case ROD:
2966 case HORN:
2967 case RANGED:
3064 if (player *pl = who->contr) 2968 if (player *pl = who->contr)
3065 if (op == pl->combat_ob)
3066 {
3067 pl->combat_ob = 0;
3068 who->change_weapon (pl->ranged_ob);
3069 }
3070
3071 who->statusmsg (format ("You unwield %s.", query_name (op)));
3072
3073 change_abil (who, op);
3074 CLEAR_FLAG (who, FLAG_READY_WEAPON);
3075 break;
3076
3077 case SKILL:
3078 if (who->contr)
3079 { 2969 {
3080 if (IS_COMBAT_SKILL (op->subtype)) 2970 who->statusmsg (format ("You unready %s.", query_name (op)));
3081 who->change_weapon (who->contr->combat_ob = 0); 2971 change_abil (who, op);
3082 else if (IS_RANGED_SKILL (op->subtype)) 2972 }
3083 who->change_weapon (who->contr->ranged_ob = 0); 2973 else
2974 {
2975 who->change_skill (0);
3084 2976
3085 if (op->invisible) 2977 if (op->type == BOW)
3086 who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill)); 2978 op->flag [FLAG_READY_BOW ] = false;
3087 else 2979 else
3088 who->statusmsg (format ("You stop using the %s.", query_name (op))); 2980 op->flag [FLAG_READY_RANGE] = false;
3089 } 2981 }
3090 2982
3091 change_abil (who, op);
3092 CLEAR_FLAG (who, FLAG_READY_SKILL);
3093 break; 2983 break;
3094 2984
3095 case ARMOUR: 2985 case ARMOUR:
3096 case HELMET: 2986 case HELMET:
3097 case SHIELD: 2987 case SHIELD:
3104 case CLOAK: 2994 case CLOAK:
3105 who->statusmsg (format ("You unwear %s.", query_name (op))); 2995 who->statusmsg (format ("You unwear %s.", query_name (op)));
3106 change_abil (who, op); 2996 change_abil (who, op);
3107 break; 2997 break;
3108 2998
2999 case SPELL:
3109 case BOW: 3000 case BUILDER:
3110 case WAND:
3111 case ROD:
3112 case HORN:
3113 if (player *pl = who->contr)
3114 {
3115 if (op == pl->ranged_ob)
3116 {
3117 pl->ranged_ob = 0;
3118 who->change_weapon (pl->combat_ob);
3119 }
3120
3121 who->statusmsg (format ("You unready %s.", query_name (op))); 3001 who->statusmsg (format ("You unready %s.", query_name (op)));
3122 }
3123 else
3124 {
3125 who->change_skill (0);
3126
3127 if (op->type == BOW)
3128 CLEAR_FLAG (who, FLAG_READY_BOW);
3129 else
3130 CLEAR_FLAG (who, FLAG_READY_RANGE);
3131 }
3132
3133 break; 3002 break;
3134 3003
3135 case BUILDER: 3004 //case SKILL_TOOL://TODO
3136 if (who->contr)
3137 who->statusmsg (format ("You unready %s.", query_name (op)));
3138 break;
3139
3140 default: 3005 default:
3141 who->statusmsg (format ("You unapply %s.", query_name (op))); 3006 who->statusmsg (format ("You unapply %s.", query_name (op)));
3142 break; 3007 break;
3143 } 3008 }
3144 3009
3168static object * 3033static object *
3169get_next_item_from_body_location (int loc, object *start) 3034get_next_item_from_body_location (int loc, object *start)
3170{ 3035{
3171 for (object *tmp = start; tmp; tmp = tmp->below) 3036 for (object *tmp = start; tmp; tmp = tmp->below)
3172 if (tmp->flag [FLAG_APPLIED] 3037 if (tmp->flag [FLAG_APPLIED]
3173 && tmp->slot[loc].info 3038 && tmp->slot [loc].info
3174 && (!tmp->invisible || tmp->type == SKILL)) 3039 && (!tmp->invisible || tmp->type == SKILL || tmp->type == SPELL))
3175 return tmp; 3040 return tmp;
3176 3041
3177 return 0; 3042 return 0;
3178} 3043}
3179 3044
3324 continue; 3189 continue;
3325 } 3190 }
3326 3191
3327 object *tmp1 = get_next_item_from_body_location (i, who->inv); 3192 object *tmp1 = get_next_item_from_body_location (i, who->inv);
3328 if (!tmp1) 3193 if (!tmp1)
3329 {
3330#if 0
3331 /* This is sort of an error, but happens a lot when old players
3332 * join in with more stuff equipped than they are now allowed.
3333 */
3334 LOG (llevError, "Can't find object using location %d on %s\n", i, who->name);
3335#endif
3336 retval |= CAN_APPLY_NEVER; 3194 retval |= CAN_APPLY_NEVER;
3337 }
3338 else 3195 else
3339 { 3196 {
3340 /* need to unapply something. However, if this something 3197 /* need to unapply something. However, if this something
3341 * is different than we had found before, it means they need 3198 * is different than we had found before, it means they need
3342 * to apply multiple objects 3199 * to apply multiple objects
3393 if (op->type == BOW && !QUERY_FLAG (who, FLAG_USE_BOW)) 3250 if (op->type == BOW && !QUERY_FLAG (who, FLAG_USE_BOW))
3394 retval |= CAN_APPLY_RESTRICTION; 3251 retval |= CAN_APPLY_RESTRICTION;
3395 } 3252 }
3396 3253
3397 return retval; 3254 return retval;
3255}
3256
3257// saner interface, returns successful status
3258bool
3259object::apply (object *ob, int aflags)
3260{
3261 if (!ob) // simplifies a lot of callers
3262 return true;
3263
3264 bool want_apply =
3265 aflags & AP_APPLY ? true
3266 : aflags & AP_UNAPPLY ? false
3267 : !ob->flag [FLAG_APPLIED]; // AP_TOGGLE
3268
3269 object_ptr *slot = 0;
3270
3271 // detect the slot, if this is a player
3272 if (contr && !(aflags & AP_NO_SLOT))
3273 {
3274 object *oslot;
3275
3276 switch (ob->type)
3277 {
3278 case WEAPON:
3279 slot = &contr->combat_ob;
3280 oslot = contr->ranged_ob;
3281 break;
3282
3283 case BOW:
3284 case RANGED:
3285 case SPELL:
3286 case WAND:
3287 case ROD:
3288 case HORN:
3289 case BUILDER:
3290 slot = &contr->ranged_ob;
3291 oslot = contr->combat_ob;
3292 break;
3293
3294 // oh, the humanity
3295 case SKILL:
3296 if (aflags & AP_NO_SLOT)
3297 break;
3298
3299 if (skill_flags [ob->subtype] & SF_NEED_ITEM)
3300 break;
3301
3302 if (skill_flags [ob->subtype] & SF_COMBAT)
3303 {
3304 slot = &contr->combat_ob;
3305 oslot = contr->ranged_ob;
3306 }
3307 else if (skill_flags [ob->subtype] & SF_RANGED)
3308 {
3309 slot = &contr->ranged_ob;
3310 oslot = contr->combat_ob;
3311 }
3312
3313 break;
3314 }
3315
3316 // now handle slot exclusions
3317 if (slot)
3318 {
3319 // only one slot can be active
3320 if (want_apply)
3321 apply (oslot, AP_UNAPPLY);
3322
3323 // clear item from slot if applied
3324 if (!want_apply && *slot == ob)
3325 {
3326 *slot = 0;
3327
3328 if (current_weapon == ob)
3329 current_weapon = 0;
3330 }
3331 }
3332 }
3333
3334 if (ob->flag [FLAG_APPLIED] != want_apply)
3335 manual_apply (this, ob, aflags);
3336
3337 if (ob->flag [FLAG_APPLIED] != want_apply)
3338 return false;
3339
3340 if (slot)
3341 current_weapon = *slot = ob;
3342
3343 return true;
3398} 3344}
3399 3345
3400/** 3346/**
3401 * who is the object using the object. It can be a monster. 3347 * who is the object using the object. It can be a monster.
3402 * op is the object they are using. op is an equipment type item, 3348 * op is the object they are using. op is an equipment type item,
3425 " H<You lack enough unused item power to use this weapon, see the skills command.>" 3371 " H<You lack enough unused item power to use this weapon, see the skills command.>"
3426 3372
3427int 3373int
3428apply_special (object *who, object *op, int aflags) 3374apply_special (object *who, object *op, int aflags)
3429{ 3375{
3430 int basic_flag = aflags & AP_BASIC_FLAGS; 3376 int basic_flag = aflags & AP_MODE;
3431 object *tmp, *tmp2, *skop = NULL; 3377 object *tmp, *tmp2, *skop = NULL;
3432 3378
3433 if (who == NULL) 3379 if (who == NULL)
3434 { 3380 {
3435 LOG (llevError, "apply_special() from object without environment.\n"); 3381 LOG (llevError, "apply_special() from object without environment.\n");
3454 3400
3455 return unapply_special (who, op, aflags); 3401 return unapply_special (who, op, aflags);
3456 } 3402 }
3457 else if (basic_flag == AP_UNAPPLY) 3403 else if (basic_flag == AP_UNAPPLY)
3458 return 0; 3404 return 0;
3459
3460 // if the item is combat/ranged, wield the relevant slot first
3461 // to resolve conflicts.
3462 if (player *pl = who->contr)
3463 switch (op->slottype ())
3464 {
3465 case slot_combat: who->change_weapon (pl->combat_ob); break;
3466 case slot_ranged: who->change_weapon (pl->ranged_ob); break;
3467 }
3468 3405
3469 splay (op); 3406 splay (op);
3470 3407
3471 /* Can't just apply this object. Lets see what not and what to do */ 3408 /* Can't just apply this object. Lets see what not and what to do */
3472 if (int i = can_apply_object (who, op)) 3409 if (int i = can_apply_object (who, op))
3506 } 3443 }
3507 } 3444 }
3508 3445
3509 if (op->skill && op->type != SKILL && op->type != SKILL_TOOL) 3446 if (op->skill && op->type != SKILL && op->type != SKILL_TOOL)
3510 { 3447 {
3448 // try to ready attached skill first
3511 skop = find_skill_by_name (who, op->skill); 3449 skop = find_skill_by_name (who, op->skill);
3512 3450
3513 if (!skop) 3451 if (!skop)
3514 { 3452 {
3515 who->failmsg (format ("You need the %s skill to use this item!", &op->skill)); 3453 who->failmsg (format ("You need the %s skill to use this item!", &op->skill));
3516 return 1; 3454 return 1;
3517 } 3455 }
3518 else 3456 else if (!who->apply (skop, AP_APPLY | AP_NO_SLOT))
3519 /* While experience will be credited properly, we want to change the
3520 * skill so that the dam and wc get updated
3521 */ 3457 {
3522 who->change_skill (skop); 3458 who->failmsg (format ("You can't use the required %s skill!", &op->skill));
3459 return 1;
3460 }
3523 } 3461 }
3524 3462
3525 if (!check_item_power (who, op->item_power)) 3463 if (!check_item_power (who, op->item_power))
3526 { 3464 {
3527 who->failmsg ("Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); 3465 who->failmsg ("Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER);
3530 3468
3531 /* Ok. We are now at the state where we can apply the new object. 3469 /* Ok. We are now at the state where we can apply the new object.
3532 * Note that we don't have the checks for can_use_... 3470 * Note that we don't have the checks for can_use_...
3533 * below - that is already taken care of by can_apply_object. 3471 * below - that is already taken care of by can_apply_object.
3534 */ 3472 */
3473
3474 // split away all the other items from the stack, so only one item is left
3535 tmp = op->nrof > 1 ? op->split (op->nrof - 1) : 0; 3475 tmp = op->nrof > 1 ? op->split (op->nrof - 1) : 0;
3536 3476
3537 if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) || INVOKE_OBJECT (READY, who, ARG_OBJECT (op))) 3477 if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) || INVOKE_OBJECT (READY, who, ARG_OBJECT (op)))
3538 return RESULT_INT (0); 3478 return RESULT_INT (0);
3539 3479
3540 switch (op->type) 3480 switch (op->type)
3541 { 3481 {
3542 case WEAPON: 3482 case WEAPON:
3543 //TODO: this obviously fails for players using a shorter prefix 3483 if (op->level && (!op->name.starts_with (who->name) || op->name [who->name.length ()] != '\''))
3544 // i.e. "R" can use Ragnarok's sword.
3545 if (op->level && !op->name.starts_with (who->name))
3546 { 3484 {
3547 /* if the weapon does not have the name as the character, can't use it. */ 3485 /* if the weapon does not have the name as the character, can't use it. */
3548 /* (Ragnarok's sword attempted to be used by Foo: won't work) */ 3486 /* (Ragnarok's sword attempted to be used by Foo: won't work) */
3549 who->failmsg ("The weapon does not recognize you as its owner. H<Its name indicates that it belongs to somebody else.>"); 3487 who->failmsg ("The weapon does not recognize you as its owner. "
3550 3488 "H<Its name indicates that it belongs to somebody else.>");
3551 if (tmp) 3489 if (tmp) who->insert (tmp);
3552 insert_ob_in_ob (tmp, who);
3553
3554 return 1; 3490 return 1;
3555 } 3491 }
3556 3492
3557 if (!skop) 3493 op->flag [FLAG_APPLIED] = true;
3494
3495 if (player *pl = who->contr)
3558 { 3496 {
3559 who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO 3497 who->statusmsg (format ("You wield %s.", query_name (op)));
3560 return 1; 3498 change_abil (who, op);
3561 } 3499 }
3562 3500 else
3563 SET_FLAG (op, FLAG_APPLIED);
3564 who->change_skill (skop); 3501 who->change_skill (skop);
3565 3502
3566 if (who->contr) 3503 op->flag [FLAG_READY_WEAPON] = true;
3567 who->change_weapon (who->contr->combat_ob = op);
3568
3569 who->statusmsg (format ("You wield %s.", query_name (op)));
3570
3571 SET_FLAG (who, FLAG_READY_WEAPON);
3572 change_abil (who, op);
3573 break; 3504 break;
3574 3505
3575 case ARMOUR: 3506 case ARMOUR:
3576 case HELMET: 3507 case HELMET:
3577 case SHIELD: 3508 case SHIELD:
3586 who->statusmsg (format ("You wear %s.", query_name (op))); 3517 who->statusmsg (format ("You wear %s.", query_name (op)));
3587 change_abil (who, op); 3518 change_abil (who, op);
3588 break; 3519 break;
3589 3520
3590 case SKILL_TOOL: 3521 case SKILL_TOOL:
3591 // applying a skill tool also readies the skill 3522 // applying a skill tool does not ready the skill
3523 // if something needs the skill, it has to ready it itself
3524 //TODO: unapplying should unapply the skill, though
3592 SET_FLAG (op, FLAG_APPLIED); 3525 SET_FLAG (op, FLAG_APPLIED);
3526 break;
3593 3527
3528 case SKILL:
3594 if (!(aflags & AP_NO_READY)) 3529 if (!(aflags & AP_NO_SLOT))
3595 { 3530 {
3596 skop = find_skill_by_name (who, op->skill); 3531 // skill is used on it's own, as opposed to being a chosen_skill
3597 if (!skop->flag [FLAG_APPLIED])
3598 apply_special (who, skop, AP_APPLY);
3599 }
3600 break;
3601 3532
3602 case SKILL: 3533 if (skill_flags [op->subtype] & (SF_NEED_ITEM | SF_MANA))
3603 if (player *pl = who->contr)
3604 {
3605 if (IS_COMBAT_SKILL (op->subtype))
3606 { 3534 {
3607 if (skill_flags [op->subtype] & SF_NEED_WEAPON)
3608 {
3609 for (object *item = who->inv; item; item = item->below)
3610 if (item->type == WEAPON && item->flag [FLAG_APPLIED])
3611 {
3612 if (item->skill == op->skill)
3613 {
3614 who->change_weapon (pl->combat_ob = item);
3615 goto found_weapon;
3616 }
3617 }
3618
3619 who->failmsg (format ( 3535 who->failmsg (format (
3620 "You need to apply a '%s' melee weapon before readying this skill. " 3536 "You feel as if you wanted to do something funny, but you can't remember what. "
3621 "H<Some skills need an item, in this case a melee weapon, to function.>", 3537 "H<The %s skill needs something else to function, for example a tool, weapon, rod, or spell. "
3622 &op->skill 3538 "It cannot be used on its own.>",
3623 ));
3624 return 1;
3625
3626 found_weapon:;
3627 }
3628 else
3629 who->change_weapon (pl->combat_ob = op);
3630 }
3631 else if (IS_RANGED_SKILL (op->subtype))
3632 {
3633 if (skill_flags [op->subtype] & SF_NEED_BOW)
3634 {
3635 for (object *item = who->inv; item; item = item->below)
3636 if (item->type == BOW && item->flag [FLAG_APPLIED])
3637 {
3638 //TODO: bows should/must all have skill missile weapon right now
3639 who->change_weapon (pl->ranged_ob = item);
3640 goto found_bow;
3641 }
3642
3643 who->failmsg (
3644 "You need to apply a missile weapon before readying this skill. "
3645 "H<Some skills need an item, in this case a missile weapon, to function.>"
3646 );
3647 return 1;
3648
3649 found_bow:;
3650 }
3651 else
3652 who->change_weapon (pl->ranged_ob = op);
3653 }
3654
3655 if (!op->invisible)
3656 {
3657 who->statusmsg (format (
3658 "You ready %s."
3659 "You can now use the skill: %s.",
3660 query_name (op),
3661 &op->skill 3539 &op->skill
3662 )); 3540 ));
3541 if (tmp) who->insert (tmp);
3542 return 1;
3663 } 3543 }
3544
3545 if (skill_flags [op->subtype] & SF_AUTARK
3546 || !(skill_flags [op->subtype] & (SF_COMBAT | SF_RANGED)))
3547 {
3548 if (skill_flags [op->subtype] & SF_USE)
3549 who->failmsg (format (
3550 "You feel as if you wanted to do something funny, but you can't remember what. "
3551 "H<The %s skill cannot be readied, instead, try C<use_skill %s>.>",
3552 &op->skill, &op->skill
3553 ));
3664 else 3554 else
3665 who->statusmsg (format ("Readied skill: %s.", op->skill ? &op->skill : &op->name)); 3555 who->failmsg (format (
3556 "You feel as if you wanted to do something funny, but you can't remember what. "
3557 "H<The %s skill cannot be readied or used, it is always active.>",
3558 &op->skill, &op->skill
3559 ));
3560
3561 if (tmp) who->insert (tmp);
3562 return 1;
3563 }
3564
3565 if (who->contr)
3566 who->statusmsg (format (
3567 op->invisible ? "You can now use the %s skill." : "You ready %s.",
3568 query_name (op),
3569 &op->skill
3570 ));
3666 } 3571 }
3667 else 3572
3668 {
3669 SET_FLAG (op, FLAG_APPLIED);
3670 change_abil (who, op);
3671 who->chosen_skill = op;
3672 SET_FLAG (who, FLAG_READY_SKILL); 3573 SET_FLAG (who, FLAG_READY_SKILL);
3673 } 3574 SET_FLAG (op, FLAG_APPLIED);
3674 3575 change_abil (who, op);
3675 break; 3576 break;
3676 3577
3677 case BOW: 3578 case BOW:
3678 if (op->level && !op->name.starts_with (who->name)) 3579 if (op->level && (!op->name.starts_with (who->name) || op->name [who->name.length ()] != '\''))
3679 { 3580 {
3680 who->failmsg ("The weapon does not recognize you as its owner. " 3581 who->failmsg ("The weapon does not recognize you as its owner. "
3681 "H<Its name indicates that it belongs to somebody else.>"); 3582 "H<Its name indicates that it belongs to somebody else.>");
3682 if (tmp) 3583 if (tmp) who->insert (tmp);
3683 insert_ob_in_ob (tmp, who);
3684
3685 return 1; 3584 return 1;
3686 } 3585 }
3586
3587 if (player *pl = who->contr)
3588 {
3589 op->flag [FLAG_APPLIED] = true;
3590 who->statusmsg (format ("You wield the %s.", query_name (op)));
3591 change_abil (who, op);
3592 }
3593 break;
3594
3595 case RANGED:
3596 if (player *pl = who->contr)
3597 {
3598 op->flag [FLAG_APPLIED] = true;
3599 who->statusmsg (format ("You applied the %s.", query_name (op)));
3600 }
3601 break;
3602
3603 case SPELL:
3604 if (player *pl = who->contr)
3605 {
3606 op->flag [FLAG_APPLIED] = true;
3607 who->statusmsg (format ("You ready the spell %s.", query_name (op)));
3608 }
3609 break;
3687 3610
3688 /*FALLTHROUGH*/ 3611 /*FALLTHROUGH*/
3689 case WAND: 3612 case WAND:
3690 case ROD: 3613 case ROD:
3691 case HORN: 3614 case HORN:
3692 /* check for skill, alter player status */ 3615 /* check for skill, alter player status */
3693 3616
3694 if (!skop) 3617 if (!skop)
3695 { 3618 {
3696 who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO 3619 who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO
3620 if (tmp) who->insert (tmp);
3697 return 1; 3621 return 1;
3698 } 3622 }
3699 3623
3700 SET_FLAG (op, FLAG_APPLIED); 3624 op->flag [FLAG_APPLIED] = true;
3701 who->change_skill (skop);
3702 3625
3703 if (who->contr) 3626 if (player *pl = who->contr)
3704 { 3627 {
3705 who->contr->ranged_ob = op;
3706
3707 who->statusmsg (format ("You ready %s.", query_name (op))); 3628 who->statusmsg (format ("You ready %s.", query_name (op)));
3708 3629
3709 if (op->type == BOW) 3630 if (op->type == BOW)
3710 {
3711 who->current_weapon = op;
3712 change_abil (who, op);
3713 who->statusmsg (format ("You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op))); 3631 who->statusmsg (format ("You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op)));
3714 } 3632
3633 change_abil (who, op);
3715 } 3634 }
3716 else 3635 else
3717 { 3636 {
3637 who->change_skill (skop);
3638
3718 if (op->type == BOW) 3639 if (op->type == BOW)
3719 SET_FLAG (who, FLAG_READY_BOW); 3640 op->flag [FLAG_READY_BOW ] = true;
3720 else 3641 else
3721 SET_FLAG (who, FLAG_READY_RANGE); 3642 op->flag [FLAG_READY_RANGE] = true;
3722 } 3643 }
3723 3644
3724 break; 3645 break;
3725 3646
3726 case BUILDER: 3647 case BUILDER:
3727 if (who->type == PLAYER) 3648 if (player *pl = who->contr)
3728 { 3649 {
3729 //TODO: wtf does this do? shouldn't this be managed automatically (slots?)
3730 if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER)
3731 unapply_special (who, who->contr->ranged_ob, 0);
3732
3733 who->statusmsg (format ("You ready your %s.", query_name (op))); 3650 who->statusmsg (format ("You ready your %s.", query_name (op)));
3734 3651 //TODO: change_abil?
3735 who->contr->ranged_ob = op;
3736 } 3652 }
3737 break; 3653 break;
3738 3654
3739 default: 3655 default:
3740 who->statusmsg (format ("You apply %s.", query_name (op))); 3656 who->statusmsg (format ("You apply %s.", query_name (op)));
3741 } 3657 }
3742 3658
3743 SET_FLAG (op, FLAG_APPLIED); 3659 SET_FLAG (op, FLAG_APPLIED);
3744 3660
3745 if (tmp)
3746 who->insert (tmp); 3661 if (tmp) who->insert (tmp);
3747 3662
3748 who->update_stats (); 3663 who->update_stats ();
3749 3664
3750 /* We exclude spell casting objects. The fire code will set the 3665 /* We exclude spell casting objects. The fire code will set the
3751 * been applied flag when they are used - until that point, 3666 * been applied flag when they are used - until that point,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines