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. |
… | |
… | |
172 | */ |
172 | */ |
173 | int |
173 | int |
174 | apply_potion (object *op, object *tmp) |
174 | apply_potion (object *op, object *tmp) |
175 | { |
175 | { |
176 | int got_one = 0, i; |
176 | int got_one = 0, i; |
177 | object *force = 0, *floor = 0; |
177 | object *force = 0; |
178 | |
178 | |
179 | floor = GET_MAP_OB (op->map, op->x, op->y); |
179 | object *floor = GET_MAP_OB (op->map, op->x, op->y); |
180 | |
180 | |
181 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
181 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
182 | { |
182 | { |
183 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
183 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
184 | |
184 | |
… | |
… | |
1353 | trap->stats.maxsp = 2; |
1353 | trap->stats.maxsp = 2; |
1354 | |
1354 | |
1355 | /* Is this correct? From the docs, it doesn't look like it |
1355 | /* Is this correct? From the docs, it doesn't look like it |
1356 | * should be divided by trap->speed |
1356 | * should be divided by trap->speed |
1357 | */ |
1357 | */ |
1358 | victim->speed_left = -fabs (trap->stats.maxsp * victim->speed / trap->speed); |
1358 | victim->speed_left = -trap->stats.maxsp * victim->speed / trap->speed; |
1359 | |
1359 | |
1360 | /* Just put in some sanity check. I think there is a bug in the |
1360 | /* Just put in some sanity check. I think there is a bug in the |
1361 | * above with some objects have zero speed, and thus the player |
1361 | * above with some objects have zero speed, and thus the player |
1362 | * getting permanently paralyzed. |
1362 | * getting permanently paralyzed. |
1363 | */ |
1363 | */ |
… | |
… | |
1488 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1488 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1489 | { |
1489 | { |
1490 | /* Basically, don't show exits leading to random maps the |
1490 | /* Basically, don't show exits leading to random maps the |
1491 | * players output. |
1491 | * players output. |
1492 | */ |
1492 | */ |
1493 | if (trap->msg && !EXIT_PATH (trap).starts_with ("/!")) |
1493 | if (trap->msg && EXIT_PATH (trap) != shstr_random_map_exit) |
1494 | victim->statusmsg (trap->msg, NDI_NAVY); |
1494 | victim->statusmsg (trap->msg, NDI_NAVY); |
1495 | |
1495 | |
1496 | trap->play_sound (trap->sound); |
1496 | trap->play_sound (trap->sound); |
1497 | victim->enter_exit (trap); |
1497 | victim->enter_exit (trap); |
1498 | } |
1498 | } |
… | |
… | |
1576 | : lev_diff < 15 ? "This book is way beyond your comprehension." |
1576 | : lev_diff < 15 ? "This book is way beyond your comprehension." |
1577 | : "This book is totally beyond your comprehension."); |
1577 | : "This book is totally beyond your comprehension."); |
1578 | return; |
1578 | return; |
1579 | } |
1579 | } |
1580 | |
1580 | |
|
|
1581 | // we currently don't use the message types for anything. |
1581 | readable_message_type *msgType = get_readable_message_type (tmp); |
1582 | // readable_message_type *msgType = get_readable_message_type (tmp); |
|
|
1583 | |
|
|
1584 | tmp->play_sound (tmp->sound ? tmp->sound : sound_find ("apply_book")); |
1582 | |
1585 | |
1583 | if (player *pl = op->contr) |
1586 | if (player *pl = op->contr) |
1584 | if (client *ns = pl->ns) |
1587 | if (client *ns = pl->ns) |
1585 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
1588 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
1586 | |
1589 | |
… | |
… | |
1739 | LOG (llevError, "BUG: do_forget_spell(): spell not known\n"); |
1742 | LOG (llevError, "BUG: do_forget_spell(): spell not known\n"); |
1740 | return; |
1743 | return; |
1741 | } |
1744 | } |
1742 | |
1745 | |
1743 | op->failmsg (format ("You lose knowledge of %s.", spell)); |
1746 | op->failmsg (format ("You lose knowledge of %s.", spell)); |
1744 | player_unready_range_ob (op->contr, spob); |
|
|
1745 | esrv_remove_spell (op->contr, spob); |
1747 | esrv_remove_spell (op->contr, spob); |
1746 | spob->destroy (); |
1748 | spob->destroy (); |
1747 | } |
1749 | } |
1748 | |
1750 | |
1749 | /** |
1751 | /** |
… | |
… | |
1766 | * instead of having their spell stored in stats.sp. These are |
1768 | * instead of having their spell stored in stats.sp. These are |
1767 | * legacy spellbooks |
1769 | * legacy spellbooks |
1768 | */ |
1770 | */ |
1769 | if (tmp->slaying) |
1771 | if (tmp->slaying) |
1770 | { |
1772 | { |
1771 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1773 | spell = find_archetype_by_object_name (tmp->slaying)->instance (); |
|
|
1774 | |
1772 | if (!spell) |
1775 | if (!spell) |
1773 | { |
1776 | { |
1774 | op->failmsg (format ("The book's formula for %s is incomplete.", &tmp->slaying)); |
1777 | op->failmsg (format ("The book's formula for %s is incomplete.", &tmp->slaying)); |
1775 | return; |
1778 | return; |
1776 | } |
1779 | } |
… | |
… | |
1997 | int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */ |
2000 | int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */ |
1998 | int winners = 0; /* number of winners */ |
2001 | int winners = 0; /* number of winners */ |
1999 | int i; /* index */ |
2002 | int i; /* index */ |
2000 | |
2003 | |
2001 | /* let's make sure and doublecheck the parameters */ |
2004 | /* let's make sure and doublecheck the parameters */ |
2002 | if (meal->type != FLESH || !is_dragon_pl (op)) |
2005 | if (meal->type != FLESH || !op->is_dragon ()) |
2003 | return 0; |
2006 | return 0; |
2004 | |
2007 | |
2005 | /* now grab the 'dragon_skin'- and 'dragon_ability'-forces |
2008 | /* now grab the 'dragon_skin'- and 'dragon_ability'-forces |
2006 | from the player's inventory */ |
2009 | from the player's inventory */ |
2007 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2010 | for (tmp = op->inv; tmp; tmp = tmp->below) |
… | |
… | |
2015 | which is not to be considered a dragon -> bail out */ |
2018 | which is not to be considered a dragon -> bail out */ |
2016 | if (skin == NULL || abil == NULL) |
2019 | if (skin == NULL || abil == NULL) |
2017 | return 0; |
2020 | return 0; |
2018 | |
2021 | |
2019 | /* now start by filling stomache and health, according to food-value */ |
2022 | /* now start by filling stomache and health, according to food-value */ |
2020 | if ((999 - op->stats.food) < meal->stats.food) |
2023 | if ((MAX_FOOD - op->stats.food) < meal->stats.food) |
2021 | op->stats.hp += (999 - op->stats.food) / 50; |
2024 | op->stats.hp += (MAX_FOOD - op->stats.food) / 50; |
2022 | else |
2025 | else |
2023 | op->stats.hp += meal->stats.food / 50; |
2026 | op->stats.hp += meal->stats.food / 50; |
2024 | |
2027 | |
2025 | if (op->stats.hp > op->stats.maxhp) |
2028 | min_it (op->stats.hp, op->stats.maxhp); |
2026 | op->stats.hp = op->stats.maxhp; |
|
|
2027 | |
|
|
2028 | op->stats.food = min (999, op->stats.food + meal->stats.food); |
2029 | op->stats.food = min (MAX_FOOD, op->stats.food + meal->stats.food); |
2029 | |
2030 | |
2030 | /*LOG(llevDebug, "-> player: %d, flesh: %d\n", op->level, meal->level); */ |
2031 | /*LOG(llevDebug, "-> player: %d, flesh: %d\n", op->level, meal->level); */ |
2031 | |
2032 | |
2032 | /* on to the interesting part: chances for adding resistance */ |
2033 | /* on to the interesting part: chances for adding resistance */ |
2033 | for (i = 0; i < NROFATTACKS; i++) |
2034 | for (i = 0; i < NROFATTACKS; i++) |
… | |
… | |
2145 | if (op->type != PLAYER) |
2146 | if (op->type != PLAYER) |
2146 | op->stats.hp = op->stats.maxhp; |
2147 | op->stats.hp = op->stats.maxhp; |
2147 | else |
2148 | else |
2148 | { |
2149 | { |
2149 | /* check if this is a dragon (player), eating some flesh */ |
2150 | /* check if this is a dragon (player), eating some flesh */ |
2150 | if (tmp->type == FLESH && is_dragon_pl (op) && dragon_eat_flesh (op, tmp)) |
2151 | if (tmp->type == FLESH && op->is_dragon () && dragon_eat_flesh (op, tmp)) |
2151 | ; |
2152 | ; |
2152 | else |
2153 | else |
2153 | { |
2154 | { |
2154 | /* usual case - no dragon meal: */ |
2155 | /* usual case - no dragon meal: */ |
2155 | if (op->stats.food + tmp->stats.food > 999) |
2156 | if (op->stats.food + tmp->stats.food > MAX_FOOD) |
2156 | { |
2157 | { |
2157 | if (tmp->type == FOOD || tmp->type == FLESH) |
2158 | if (tmp->type == FOOD || tmp->type == FLESH) |
2158 | op->failmsg ("You feel full, but what a waste of food!"); |
2159 | op->failmsg ("You feel full, but what a waste of food!"); |
2159 | else |
2160 | else |
2160 | op->statusmsg ("Most of the drink goes down your face not your throat!"); |
2161 | op->statusmsg ("Most of the drink goes down your face not your throat!"); |
… | |
… | |
2170 | |
2171 | |
2171 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2172 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2172 | { |
2173 | { |
2173 | const char *buf; |
2174 | const char *buf; |
2174 | |
2175 | |
2175 | if (!is_dragon_pl (op)) |
2176 | if (!op->is_dragon ()) |
2176 | { |
2177 | { |
2177 | /* eating message for normal players */ |
2178 | /* eating message for normal players */ |
2178 | if (tmp->type == DRINK) |
2179 | if (tmp->type == DRINK) |
2179 | buf = format ("Ahhh...that %s tasted good.", &tmp->name); |
2180 | buf = format ("Ahhh...that %s tasted good.", &tmp->name); |
2180 | else |
2181 | else |
… | |
… | |
2184 | /* eating message for dragon players */ |
2185 | /* eating message for dragon players */ |
2185 | buf = format ("The %s tasted terrible!", &tmp->name); |
2186 | buf = format ("The %s tasted terrible!", &tmp->name); |
2186 | |
2187 | |
2187 | op->statusmsg (buf); |
2188 | op->statusmsg (buf); |
2188 | |
2189 | |
2189 | capacity_remaining = 999 - op->stats.food; |
2190 | capacity_remaining = MAX_FOOD - op->stats.food; |
2190 | op->stats.food += tmp->stats.food; |
2191 | op->stats.food += tmp->stats.food; |
2191 | if (capacity_remaining < tmp->stats.food) |
2192 | if (capacity_remaining < tmp->stats.food) |
2192 | op->stats.hp += capacity_remaining / 50; |
2193 | op->stats.hp += capacity_remaining / 50; |
2193 | else |
2194 | else |
2194 | op->stats.hp += tmp->stats.food / 50; |
2195 | op->stats.hp += tmp->stats.food / 50; |
2195 | |
2196 | |
2196 | if (op->stats.hp > op->stats.maxhp) |
2197 | min_it (op->stats.hp, op->stats.maxhp); |
2197 | op->stats.hp = op->stats.maxhp; |
2198 | min_it (op->stats.food, MAX_FOOD); |
2198 | if (op->stats.food > 999) |
|
|
2199 | op->stats.food = 999; |
|
|
2200 | } |
2199 | } |
2201 | |
2200 | |
2202 | /* special food hack -b.t. */ |
2201 | /* special food hack -b.t. */ |
2203 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
2202 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
2204 | eat_special_food (op, tmp); |
2203 | eat_special_food (op, tmp); |
… | |
… | |
2265 | hit_player (op, poison->stats.hp, tmp, AT_POISON, 1); |
2264 | hit_player (op, poison->stats.hp, tmp, AT_POISON, 1); |
2266 | } |
2265 | } |
2267 | |
2266 | |
2268 | op->stats.food -= op->stats.food / 4; |
2267 | op->stats.food -= op->stats.food / 4; |
2269 | poison->destroy (); |
2268 | poison->destroy (); |
2270 | } |
|
|
2271 | |
|
|
2272 | /** |
|
|
2273 | * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit. |
|
|
2274 | * A valid 2 way exit means: |
|
|
2275 | * -You can come back (there is another exit at the other side) |
|
|
2276 | * -You are |
|
|
2277 | * ° the owner of the exit |
|
|
2278 | * ° or in the same party as the owner |
|
|
2279 | * |
|
|
2280 | * Note: a owner in a 2 way exit is saved as the owner's name |
|
|
2281 | * in the field exit->name cause the field exit->owner doesn't |
|
|
2282 | * survive in the swapping (in fact the whole exit doesn't survive). |
|
|
2283 | */ |
|
|
2284 | static int |
|
|
2285 | is_legal_2ways_exit (object *op, object *exit) |
|
|
2286 | { |
|
|
2287 | if (exit->stats.exp != 1) |
|
|
2288 | return 1; /*This is not a 2 way, so it is legal */ |
|
|
2289 | |
|
|
2290 | #if 0 //TODO |
|
|
2291 | if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) |
|
|
2292 | return 0; /* This is a reset town portal */ |
|
|
2293 | #endif |
|
|
2294 | |
|
|
2295 | LOG (llevError | logBacktrace, "sync map load due to %s\n", exit->debug_desc ()); |
|
|
2296 | |
|
|
2297 | maptile *exitmap = maptile::find_sync (EXIT_PATH (exit), exit->map); |
|
|
2298 | |
|
|
2299 | if (exitmap) |
|
|
2300 | { |
|
|
2301 | exitmap->load_sync (); |
|
|
2302 | |
|
|
2303 | object *tmp = exitmap->at (EXIT_X (exit), EXIT_Y (exit)).bot; |
|
|
2304 | |
|
|
2305 | if (!tmp) |
|
|
2306 | return 0; |
|
|
2307 | |
|
|
2308 | for (; tmp; tmp = tmp->above) |
|
|
2309 | { |
|
|
2310 | if (tmp->type != EXIT) |
|
|
2311 | continue; /*Not an exit */ |
|
|
2312 | |
|
|
2313 | if (!EXIT_PATH (tmp)) |
|
|
2314 | continue; /*Not a valid exit */ |
|
|
2315 | |
|
|
2316 | if ((EXIT_X (tmp) != exit->x) || (EXIT_Y (tmp) != exit->y)) |
|
|
2317 | continue; /*Not in the same place */ |
|
|
2318 | |
|
|
2319 | if (exit->map->path != EXIT_PATH (tmp)) |
|
|
2320 | continue; /*Not in the same map */ |
|
|
2321 | |
|
|
2322 | /* From here we have found the exit is valid. However we do |
|
|
2323 | * here the check of the exit owner. It is important for the |
|
|
2324 | * town portals to prevent strangers from visiting your appartments |
|
|
2325 | */ |
|
|
2326 | if (!exit->race) |
|
|
2327 | return 1; /*No owner, free for all! */ |
|
|
2328 | |
|
|
2329 | object *exit_owner = 0; |
|
|
2330 | |
|
|
2331 | for_all_players (pp) |
|
|
2332 | { |
|
|
2333 | if (!pp->ob) |
|
|
2334 | continue; |
|
|
2335 | |
|
|
2336 | if (pp->ob->name != exit->race) |
|
|
2337 | continue; |
|
|
2338 | |
|
|
2339 | exit_owner = pp->ob; /*We found a player which correspond to the player name */ |
|
|
2340 | break; |
|
|
2341 | } |
|
|
2342 | |
|
|
2343 | if (!exit_owner) |
|
|
2344 | return 0; /* No more owner */ |
|
|
2345 | |
|
|
2346 | if (exit_owner->contr == op->contr) |
|
|
2347 | return 1; /*It is your exit */ |
|
|
2348 | |
|
|
2349 | if (exit_owner && /*There is a owner */ |
|
|
2350 | (op->contr) && /*A player tries to pass */ |
|
|
2351 | ((exit_owner->contr->party == NULL) || /*No pass if controller has no party */ |
|
|
2352 | (exit_owner->contr->party != op->contr->party))) /* Or not the same as op */ |
|
|
2353 | return 0; |
|
|
2354 | |
|
|
2355 | return 1; |
|
|
2356 | } |
|
|
2357 | } |
|
|
2358 | |
|
|
2359 | return 0; |
|
|
2360 | } |
2269 | } |
2361 | |
2270 | |
2362 | /** |
2271 | /** |
2363 | * This function will try to apply a lighter and in case no lighter |
2272 | * This function will try to apply a lighter and in case no lighter |
2364 | * is specified it will try to find a lighter in the players inventory, |
2273 | * is specified it will try to find a lighter in the players inventory, |
… | |
… | |
2619 | static void |
2528 | static void |
2620 | apply_item_transformer (object *pl, object *transformer) |
2529 | apply_item_transformer (object *pl, object *transformer) |
2621 | { |
2530 | { |
2622 | object *marked; |
2531 | object *marked; |
2623 | object *new_item; |
2532 | object *new_item; |
2624 | char *find; |
2533 | const char *find; |
2625 | char *separator; |
2534 | char *separator; |
2626 | int yield; |
2535 | int yield; |
2627 | char got[MAX_BUF]; |
2536 | char got[MAX_BUF]; |
2628 | int len; |
2537 | int len; |
2629 | |
2538 | |
… | |
… | |
2672 | while (*find == ' ') |
2581 | while (*find == ' ') |
2673 | find++; |
2582 | find++; |
2674 | |
2583 | |
2675 | memset (got, 0, MAX_BUF); |
2584 | memset (got, 0, MAX_BUF); |
2676 | |
2585 | |
2677 | if ((separator = strchr (find, ';')) != NULL) |
2586 | if ((separator = (char *) strchr (find, ';'))) |
2678 | len = separator - find; |
2587 | len = separator - find; |
2679 | else |
2588 | else |
2680 | len = strlen (find); |
2589 | len = strlen (find); |
2681 | |
2590 | |
2682 | if (len > MAX_BUF - 1) |
2591 | min_it (len, MAX_BUF - 1); |
2683 | len = MAX_BUF - 1; |
|
|
2684 | |
2592 | |
2685 | strcpy (got, find); |
2593 | strcpy (got, find); |
2686 | got[len] = '\0'; |
2594 | got[len] = '\0'; |
2687 | |
2595 | |
2688 | /* Now create new item, remove used ones when required. */ |
2596 | /* Now create new item, remove used ones when required. */ |
… | |
… | |
2767 | |
2675 | |
2768 | case EXIT: |
2676 | case EXIT: |
2769 | if (who->type != PLAYER) |
2677 | if (who->type != PLAYER) |
2770 | return 0; |
2678 | return 0; |
2771 | |
2679 | |
2772 | if (!EXIT_PATH (op) || !is_legal_2ways_exit (who, op)) |
2680 | if (!EXIT_PATH (op)) |
2773 | 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))); |
2681 | 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))); |
2774 | else |
2682 | else |
2775 | { |
2683 | { |
2776 | /* Don't display messages for random maps. */ |
2684 | /* Don't display messages for random maps. */ |
2777 | if (op->msg && !EXIT_PATH (op).starts_with ("/!")) |
2685 | if (op->msg && EXIT_PATH (op) != shstr_random_map_exit) |
2778 | who->statusmsg (op->msg, NDI_NAVY); |
2686 | who->statusmsg (op->msg, NDI_NAVY); |
2779 | |
2687 | |
2780 | who->enter_exit (op); |
2688 | who->enter_exit (op); |
2781 | } |
2689 | } |
2782 | |
2690 | |
… | |
… | |
2863 | case CLOAK: |
2771 | case CLOAK: |
2864 | case WAND: |
2772 | case WAND: |
2865 | case ROD: |
2773 | case ROD: |
2866 | case HORN: |
2774 | case HORN: |
2867 | case SKILL: |
2775 | case SKILL: |
|
|
2776 | case SPELL: |
2868 | case BOW: |
2777 | case BOW: |
|
|
2778 | case RANGED: |
2869 | case BUILDER: |
2779 | case BUILDER: |
2870 | case SKILL_TOOL: |
2780 | case SKILL_TOOL: |
2871 | if (op->env != who) |
2781 | if (op->env != who) |
2872 | return 2; /* not in inventory */ |
2782 | return 2; /* not in inventory */ |
2873 | |
2783 | |
… | |
… | |
3037 | { |
2947 | { |
3038 | if (INVOKE_OBJECT (BE_UNREADY, op, ARG_OBJECT (who), ARG_INT (aflags)) |
2948 | if (INVOKE_OBJECT (BE_UNREADY, op, ARG_OBJECT (who), ARG_INT (aflags)) |
3039 | || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags))) |
2949 | || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags))) |
3040 | return RESULT_INT (0); |
2950 | return RESULT_INT (0); |
3041 | |
2951 | |
3042 | CLEAR_FLAG (op, FLAG_APPLIED); |
2952 | if (who->current_weapon == op) |
|
|
2953 | who->current_weapon = 0; |
|
|
2954 | |
|
|
2955 | op->flag [FLAG_APPLIED] = false; |
3043 | |
2956 | |
3044 | switch (op->type) |
2957 | switch (op->type) |
3045 | { |
2958 | { |
3046 | case SKILL_TOOL: |
2959 | case SKILL: |
|
|
2960 | if (player *pl = who->contr) |
|
|
2961 | if (op->invisible) |
|
|
2962 | pl->statusmsg (format ("You can no longer use the skill: %s.", &op->skill)); |
|
|
2963 | else |
|
|
2964 | pl->statusmsg (format ("You stop using the %s.", query_name (op))); |
|
|
2965 | |
|
|
2966 | change_abil (who, op); |
|
|
2967 | who->flag [FLAG_READY_SKILL] = false; |
|
|
2968 | break; |
|
|
2969 | |
|
|
2970 | case WEAPON: |
|
|
2971 | who->statusmsg (format ("You unwield %s.", query_name (op))); |
|
|
2972 | change_abil (who, op); |
|
|
2973 | who->flag [FLAG_READY_WEAPON] = false; |
|
|
2974 | |
3047 | // unapplying a skill tool should also unapply the skill it governs |
2975 | // unapplying a weapon or skill tool should also unapply the skill it governs |
3048 | // but this is hard, as it shouldn't do so when the skill can |
2976 | // but this is hard, as it shouldn't do so when the skill can |
3049 | // be used for other reasons |
2977 | // be used for other reasons |
3050 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2978 | if (who->chosen_skill) |
3051 | if (tmp->skill == op->skill |
2979 | if (!who->chosen_skill->flag [FLAG_CAN_USE_SKILL]) |
3052 | && tmp->type == SKILL |
|
|
3053 | && tmp->flag [FLAG_APPLIED] |
|
|
3054 | && !tmp->flag [FLAG_CAN_USE_SKILL]) |
|
|
3055 | unapply_special (who, tmp, 0); |
2980 | unapply_special (who, op, 0); |
3056 | |
2981 | |
3057 | change_abil (who, op); |
|
|
3058 | break; |
2982 | break; |
3059 | |
2983 | |
|
|
2984 | case BOW: |
3060 | case WEAPON: |
2985 | case WAND: |
|
|
2986 | case ROD: |
|
|
2987 | case HORN: |
|
|
2988 | case RANGED: |
3061 | if (player *pl = who->contr) |
2989 | if (player *pl = who->contr) |
3062 | if (op == pl->combat_ob) |
|
|
3063 | { |
|
|
3064 | pl->combat_ob = 0; |
|
|
3065 | who->change_weapon (pl->ranged_ob); |
|
|
3066 | } |
|
|
3067 | |
|
|
3068 | who->statusmsg (format ("You unwield %s.", query_name (op))); |
|
|
3069 | |
|
|
3070 | change_abil (who, op); |
|
|
3071 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
|
|
3072 | break; |
|
|
3073 | |
|
|
3074 | case SKILL: |
|
|
3075 | if (who->contr) |
|
|
3076 | { |
2990 | { |
3077 | if (IS_COMBAT_SKILL (op->subtype)) |
2991 | who->statusmsg (format ("You unready %s.", query_name (op))); |
3078 | who->change_weapon (who->contr->combat_ob = 0); |
2992 | change_abil (who, op); |
3079 | else if (IS_RANGED_SKILL (op->subtype)) |
2993 | } |
3080 | who->change_weapon (who->contr->ranged_ob = 0); |
2994 | else |
|
|
2995 | { |
|
|
2996 | who->change_skill (0); |
3081 | |
2997 | |
3082 | if (op->invisible) |
2998 | if (op->type == BOW) |
3083 | who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill)); |
2999 | op->flag [FLAG_READY_BOW ] = false; |
3084 | else |
3000 | else |
3085 | who->statusmsg (format ("You stop using the %s.", query_name (op))); |
3001 | op->flag [FLAG_READY_RANGE] = false; |
3086 | } |
3002 | } |
3087 | |
3003 | |
3088 | change_abil (who, op); |
|
|
3089 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
|
|
3090 | break; |
3004 | break; |
3091 | |
3005 | |
3092 | case ARMOUR: |
3006 | case ARMOUR: |
3093 | case HELMET: |
3007 | case HELMET: |
3094 | case SHIELD: |
3008 | case SHIELD: |
… | |
… | |
3101 | case CLOAK: |
3015 | case CLOAK: |
3102 | who->statusmsg (format ("You unwear %s.", query_name (op))); |
3016 | who->statusmsg (format ("You unwear %s.", query_name (op))); |
3103 | change_abil (who, op); |
3017 | change_abil (who, op); |
3104 | break; |
3018 | break; |
3105 | |
3019 | |
|
|
3020 | case SPELL: |
3106 | case BOW: |
3021 | case BUILDER: |
3107 | case WAND: |
|
|
3108 | case ROD: |
|
|
3109 | case HORN: |
|
|
3110 | if (player *pl = who->contr) |
|
|
3111 | { |
|
|
3112 | if (op == pl->ranged_ob) |
|
|
3113 | { |
|
|
3114 | pl->ranged_ob = 0; |
|
|
3115 | who->change_weapon (pl->combat_ob); |
|
|
3116 | } |
|
|
3117 | |
|
|
3118 | who->statusmsg (format ("You unready %s.", query_name (op))); |
3022 | who->statusmsg (format ("You unready %s.", query_name (op))); |
3119 | } |
|
|
3120 | else |
|
|
3121 | { |
|
|
3122 | who->change_skill (0); |
|
|
3123 | |
|
|
3124 | if (op->type == BOW) |
|
|
3125 | CLEAR_FLAG (who, FLAG_READY_BOW); |
|
|
3126 | else |
|
|
3127 | CLEAR_FLAG (who, FLAG_READY_RANGE); |
|
|
3128 | } |
|
|
3129 | |
|
|
3130 | break; |
3023 | break; |
3131 | |
3024 | |
3132 | case BUILDER: |
3025 | //case SKILL_TOOL://TODO |
3133 | if (who->contr) |
|
|
3134 | who->statusmsg (format ("You unready %s.", query_name (op))); |
|
|
3135 | break; |
|
|
3136 | |
|
|
3137 | default: |
3026 | default: |
3138 | who->statusmsg (format ("You unapply %s.", query_name (op))); |
3027 | who->statusmsg (format ("You unapply %s.", query_name (op))); |
3139 | break; |
3028 | break; |
3140 | } |
3029 | } |
3141 | |
3030 | |
… | |
… | |
3390 | if (op->type == BOW && !QUERY_FLAG (who, FLAG_USE_BOW)) |
3279 | if (op->type == BOW && !QUERY_FLAG (who, FLAG_USE_BOW)) |
3391 | retval |= CAN_APPLY_RESTRICTION; |
3280 | retval |= CAN_APPLY_RESTRICTION; |
3392 | } |
3281 | } |
3393 | |
3282 | |
3394 | return retval; |
3283 | return retval; |
|
|
3284 | } |
|
|
3285 | |
|
|
3286 | // saner interface, returns successful status |
|
|
3287 | bool |
|
|
3288 | object::apply (object *ob, int aflags) |
|
|
3289 | { |
|
|
3290 | bool want_apply = aflags & AP_APPLY; |
|
|
3291 | |
|
|
3292 | if (ob->flag [FLAG_APPLIED] == want_apply) |
|
|
3293 | return true; |
|
|
3294 | |
|
|
3295 | manual_apply (this, ob, aflags); |
|
|
3296 | |
|
|
3297 | return ob->flag [FLAG_APPLIED] == want_apply; |
3395 | } |
3298 | } |
3396 | |
3299 | |
3397 | /** |
3300 | /** |
3398 | * who is the object using the object. It can be a monster. |
3301 | * who is the object using the object. It can be a monster. |
3399 | * op is the object they are using. op is an equipment type item, |
3302 | * op is the object they are using. op is an equipment type item, |
… | |
… | |
3452 | return unapply_special (who, op, aflags); |
3355 | return unapply_special (who, op, aflags); |
3453 | } |
3356 | } |
3454 | else if (basic_flag == AP_UNAPPLY) |
3357 | else if (basic_flag == AP_UNAPPLY) |
3455 | return 0; |
3358 | return 0; |
3456 | |
3359 | |
3457 | // if the item is combat/ranged, wield the relevant slot first |
|
|
3458 | // to resolve conflicts. |
|
|
3459 | if (player *pl = who->contr) |
|
|
3460 | switch (op->slottype ()) |
|
|
3461 | { |
|
|
3462 | case slot_combat: who->change_weapon (pl->combat_ob); break; |
|
|
3463 | case slot_ranged: who->change_weapon (pl->ranged_ob); break; |
|
|
3464 | } |
|
|
3465 | |
|
|
3466 | splay (op); |
3360 | splay (op); |
3467 | |
3361 | |
3468 | /* Can't just apply this object. Lets see what not and what to do */ |
3362 | /* Can't just apply this object. Lets see what not and what to do */ |
3469 | if (int i = can_apply_object (who, op)) |
3363 | if (int i = can_apply_object (who, op)) |
3470 | { |
3364 | { |
… | |
… | |
3503 | } |
3397 | } |
3504 | } |
3398 | } |
3505 | |
3399 | |
3506 | if (op->skill && op->type != SKILL && op->type != SKILL_TOOL) |
3400 | if (op->skill && op->type != SKILL && op->type != SKILL_TOOL) |
3507 | { |
3401 | { |
|
|
3402 | // try to ready attached skill first |
3508 | skop = find_skill_by_name (who, op->skill); |
3403 | skop = find_skill_by_name (who, op->skill); |
3509 | |
3404 | |
3510 | if (!skop) |
3405 | if (!skop) |
3511 | { |
3406 | { |
3512 | who->failmsg (format ("You need the %s skill to use this item!", &op->skill)); |
3407 | who->failmsg (format ("You need the %s skill to use this item!", &op->skill)); |
3513 | return 1; |
3408 | return 1; |
3514 | } |
3409 | } |
3515 | else |
3410 | else if (!who->apply (skop, AP_APPLY | AP_HAVE_WEAPON)) |
3516 | /* While experience will be credited properly, we want to change the |
|
|
3517 | * skill so that the dam and wc get updated |
|
|
3518 | */ |
3411 | { |
3519 | who->change_skill (skop); |
3412 | who->failmsg (format ("You can't use the required %s skill!", &op->skill)); |
|
|
3413 | return 1; |
|
|
3414 | } |
3520 | } |
3415 | } |
3521 | |
3416 | |
3522 | if (!check_item_power (who, op->item_power)) |
3417 | if (!check_item_power (who, op->item_power)) |
3523 | { |
3418 | { |
3524 | who->failmsg ("Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); |
3419 | who->failmsg ("Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER); |
… | |
… | |
3527 | |
3422 | |
3528 | /* Ok. We are now at the state where we can apply the new object. |
3423 | /* Ok. We are now at the state where we can apply the new object. |
3529 | * Note that we don't have the checks for can_use_... |
3424 | * Note that we don't have the checks for can_use_... |
3530 | * below - that is already taken care of by can_apply_object. |
3425 | * below - that is already taken care of by can_apply_object. |
3531 | */ |
3426 | */ |
|
|
3427 | |
|
|
3428 | // split away all the other items from the stack, so only one item is left |
3532 | tmp = op->nrof > 1 ? op->split (op->nrof - 1) : 0; |
3429 | tmp = op->nrof > 1 ? op->split (op->nrof - 1) : 0; |
3533 | |
3430 | |
3534 | if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) || INVOKE_OBJECT (READY, who, ARG_OBJECT (op))) |
3431 | if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) || INVOKE_OBJECT (READY, who, ARG_OBJECT (op))) |
3535 | return RESULT_INT (0); |
3432 | return RESULT_INT (0); |
3536 | |
3433 | |
3537 | switch (op->type) |
3434 | switch (op->type) |
3538 | { |
3435 | { |
3539 | case WEAPON: |
3436 | case WEAPON: |
3540 | //TODO: this obviously fails for players using a shorter prefix |
3437 | if (op->level && (!op->name.starts_with (who->name) || op->name [who->name.length ()] != '\'')) |
3541 | // i.e. "R" can use Ragnarok's sword. |
|
|
3542 | if (op->level && !op->name.starts_with (who->name)) |
|
|
3543 | { |
3438 | { |
3544 | /* if the weapon does not have the name as the character, can't use it. */ |
3439 | /* if the weapon does not have the name as the character, can't use it. */ |
3545 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3440 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3546 | who->failmsg ("The weapon does not recognize you as its owner. H<Its name indicates that it belongs to somebody else.>"); |
3441 | who->failmsg ("The weapon does not recognize you as its owner. " |
3547 | |
3442 | "H<Its name indicates that it belongs to somebody else.>"); |
3548 | if (tmp) |
3443 | if (tmp) who->insert (tmp); |
3549 | insert_ob_in_ob (tmp, who); |
|
|
3550 | |
|
|
3551 | return 1; |
3444 | return 1; |
3552 | } |
3445 | } |
3553 | |
3446 | |
3554 | if (!skop) |
3447 | op->flag [FLAG_APPLIED] = true; |
|
|
3448 | |
|
|
3449 | if (player *pl = who->contr) |
3555 | { |
3450 | { |
3556 | who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO |
3451 | who->current_weapon = pl->combat_ob = op; |
3557 | return 1; |
3452 | who->statusmsg (format ("You wield %s.", query_name (op))); |
|
|
3453 | change_abil (who, op); |
3558 | } |
3454 | } |
3559 | |
3455 | else |
3560 | SET_FLAG (op, FLAG_APPLIED); |
|
|
3561 | who->change_skill (skop); |
3456 | who->change_skill (skop); |
3562 | |
3457 | |
3563 | if (who->contr) |
3458 | op->flag [FLAG_READY_WEAPON] = true; |
3564 | who->change_weapon (who->contr->combat_ob = op); |
|
|
3565 | |
|
|
3566 | who->statusmsg (format ("You wield %s.", query_name (op))); |
|
|
3567 | |
|
|
3568 | SET_FLAG (who, FLAG_READY_WEAPON); |
|
|
3569 | change_abil (who, op); |
|
|
3570 | break; |
3459 | break; |
3571 | |
3460 | |
3572 | case ARMOUR: |
3461 | case ARMOUR: |
3573 | case HELMET: |
3462 | case HELMET: |
3574 | case SHIELD: |
3463 | case SHIELD: |
… | |
… | |
3583 | who->statusmsg (format ("You wear %s.", query_name (op))); |
3472 | who->statusmsg (format ("You wear %s.", query_name (op))); |
3584 | change_abil (who, op); |
3473 | change_abil (who, op); |
3585 | break; |
3474 | break; |
3586 | |
3475 | |
3587 | case SKILL_TOOL: |
3476 | case SKILL_TOOL: |
3588 | // applying a skill tool also readies the skill |
3477 | // applying a skill tool does not ready the skill |
|
|
3478 | // if something needs the skill, it has to ready it itself |
|
|
3479 | //TODO: unapplying should unapply the skill, though |
3589 | SET_FLAG (op, FLAG_APPLIED); |
3480 | SET_FLAG (op, FLAG_APPLIED); |
|
|
3481 | break; |
3590 | |
3482 | |
3591 | if (!(aflags & AP_NO_READY)) |
3483 | case SKILL: |
|
|
3484 | if (skill_flags [op->subtype] & SF_NEED_ITEM && !(aflags & AP_HAVE_WEAPON)) |
3592 | { |
3485 | { |
3593 | skop = find_skill_by_name (who, op->skill); |
3486 | who->failmsg (format ( |
3594 | if (!skop->flag [FLAG_APPLIED]) |
3487 | "You feel as if you wanted to do something funny, but you can't remember what. " |
3595 | apply_special (who, skop, AP_APPLY); |
3488 | "H<The skill %s needs an item to function, it cannot be used on its own.>", |
|
|
3489 | &op->skill |
|
|
3490 | )); |
|
|
3491 | if (tmp) who->insert (tmp); |
|
|
3492 | return 1; |
3596 | } |
3493 | } |
3597 | break; |
|
|
3598 | |
3494 | |
3599 | case SKILL: |
|
|
3600 | if (player *pl = who->contr) |
3495 | if (player *pl = who->contr) |
3601 | { |
3496 | { |
3602 | if (IS_COMBAT_SKILL (op->subtype)) |
|
|
3603 | { |
|
|
3604 | if (skill_flags [op->subtype] & SF_NEED_WEAPON) |
3497 | if (skill_flags [op->subtype] & SF_COMBAT) |
3605 | { |
|
|
3606 | for (object *item = who->inv; item; item = item->below) |
|
|
3607 | if (item->type == WEAPON && item->flag [FLAG_APPLIED]) |
|
|
3608 | { |
|
|
3609 | if (item->skill == op->skill) |
|
|
3610 | { |
|
|
3611 | who->change_weapon (pl->combat_ob = item); |
|
|
3612 | goto found_weapon; |
|
|
3613 | } |
|
|
3614 | } |
|
|
3615 | |
|
|
3616 | who->failmsg (format ( |
|
|
3617 | "You need to apply a '%s' melee weapon before readying this skill. " |
|
|
3618 | "H<Some skills need an item, in this case a melee weapon, to function.>", |
|
|
3619 | &op->skill |
|
|
3620 | )); |
|
|
3621 | return 1; |
|
|
3622 | |
|
|
3623 | found_weapon:; |
|
|
3624 | } |
|
|
3625 | else |
|
|
3626 | who->change_weapon (pl->combat_ob = op); |
3498 | who->current_weapon = pl->combat_ob = op; |
3627 | } |
3499 | |
3628 | else if (IS_RANGED_SKILL (op->subtype)) |
|
|
3629 | { |
|
|
3630 | if (skill_flags [op->subtype] & SF_NEED_BOW) |
3500 | if (skill_flags [op->subtype] & SF_RANGED) |
3631 | { |
|
|
3632 | for (object *item = who->inv; item; item = item->below) |
|
|
3633 | if (item->type == BOW && item->flag [FLAG_APPLIED]) |
|
|
3634 | { |
|
|
3635 | //TODO: bows should/must all have skill missile weapon right now |
|
|
3636 | who->change_weapon (pl->ranged_ob = item); |
|
|
3637 | goto found_bow; |
|
|
3638 | } |
|
|
3639 | |
|
|
3640 | who->failmsg ( |
|
|
3641 | "You need to apply a missile weapon before readying this skill. " |
|
|
3642 | "H<Some skills need an item, in this case a missile weapon, to function.>" |
|
|
3643 | ); |
|
|
3644 | return 1; |
|
|
3645 | |
|
|
3646 | found_bow:; |
|
|
3647 | } |
|
|
3648 | else |
|
|
3649 | who->change_weapon (pl->ranged_ob = op); |
3501 | who->current_weapon = pl->ranged_ob = op; |
3650 | } |
|
|
3651 | |
3502 | |
3652 | if (!op->invisible) |
3503 | if (op->invisible) |
3653 | { |
3504 | who->statusmsg (format ("Readied skill: %s.", op->skill ? &op->skill : &op->name)); |
3654 | who->statusmsg (format ( |
|
|
3655 | "You ready %s." |
|
|
3656 | "You can now use the skill: %s.", |
|
|
3657 | query_name (op), |
|
|
3658 | &op->skill |
|
|
3659 | )); |
|
|
3660 | } |
|
|
3661 | else |
3505 | else |
3662 | who->statusmsg (format ("Readied skill: %s.", op->skill ? &op->skill : &op->name)); |
3506 | who->statusmsg (format ( |
|
|
3507 | "You ready %s." |
|
|
3508 | "You can now use the skill: %s.", |
|
|
3509 | query_name (op), |
|
|
3510 | &op->skill |
|
|
3511 | )); |
3663 | } |
3512 | } |
3664 | else |
3513 | |
3665 | { |
|
|
3666 | SET_FLAG (op, FLAG_APPLIED); |
|
|
3667 | change_abil (who, op); |
|
|
3668 | who->chosen_skill = op; |
|
|
3669 | SET_FLAG (who, FLAG_READY_SKILL); |
3514 | SET_FLAG (who, FLAG_READY_SKILL); |
3670 | } |
3515 | SET_FLAG (op, FLAG_APPLIED); |
3671 | |
3516 | change_abil (who, op); |
3672 | break; |
3517 | break; |
3673 | |
3518 | |
3674 | case BOW: |
3519 | case BOW: |
3675 | if (op->level && !op->name.starts_with (who->name)) |
3520 | if (op->level && (!op->name.starts_with (who->name) || op->name [who->name.length ()] != '\'')) |
3676 | { |
3521 | { |
3677 | who->failmsg ("The weapon does not recognize you as its owner. " |
3522 | who->failmsg ("The weapon does not recognize you as its owner. " |
3678 | "H<Its name indicates that it belongs to somebody else.>"); |
3523 | "H<Its name indicates that it belongs to somebody else.>"); |
3679 | if (tmp) |
3524 | if (tmp) who->insert (tmp); |
3680 | insert_ob_in_ob (tmp, who); |
|
|
3681 | |
|
|
3682 | return 1; |
3525 | return 1; |
3683 | } |
3526 | } |
|
|
3527 | |
|
|
3528 | if (player *pl = who->contr) |
|
|
3529 | { |
|
|
3530 | op->flag [FLAG_APPLIED] = true; |
|
|
3531 | who->current_weapon = pl->ranged_ob = op; |
|
|
3532 | who->statusmsg (format ("You wield the %s.", query_name (op))); |
|
|
3533 | change_abil (who, op); |
|
|
3534 | } |
|
|
3535 | break; |
|
|
3536 | |
|
|
3537 | case RANGED: |
|
|
3538 | if (player *pl = who->contr) |
|
|
3539 | { |
|
|
3540 | op->flag [FLAG_APPLIED] = true; |
|
|
3541 | who->current_weapon = pl->ranged_ob = op; |
|
|
3542 | who->statusmsg (format ("You applied the %s.", query_name (op))); |
|
|
3543 | } |
|
|
3544 | break; |
|
|
3545 | |
|
|
3546 | case SPELL: |
|
|
3547 | if (player *pl = who->contr) |
|
|
3548 | { |
|
|
3549 | op->flag [FLAG_APPLIED] = true; |
|
|
3550 | who->current_weapon = pl->ranged_ob = op; |
|
|
3551 | who->statusmsg (format ("You ready the spell %s.", query_name (op))); |
|
|
3552 | } |
|
|
3553 | break; |
3684 | |
3554 | |
3685 | /*FALLTHROUGH*/ |
3555 | /*FALLTHROUGH*/ |
3686 | case WAND: |
3556 | case WAND: |
3687 | case ROD: |
3557 | case ROD: |
3688 | case HORN: |
3558 | case HORN: |
3689 | /* check for skill, alter player status */ |
3559 | /* check for skill, alter player status */ |
3690 | |
3560 | |
3691 | if (!skop) |
3561 | if (!skop) |
3692 | { |
3562 | { |
3693 | who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO |
3563 | who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO |
|
|
3564 | if (tmp) who->insert (tmp); |
3694 | return 1; |
3565 | return 1; |
3695 | } |
3566 | } |
3696 | |
3567 | |
3697 | SET_FLAG (op, FLAG_APPLIED); |
3568 | op->flag [FLAG_APPLIED] = true; |
3698 | who->change_skill (skop); |
|
|
3699 | |
3569 | |
3700 | if (who->contr) |
3570 | if (player *pl = who->contr) |
3701 | { |
3571 | { |
3702 | who->contr->ranged_ob = op; |
|
|
3703 | |
|
|
3704 | who->statusmsg (format ("You ready %s.", query_name (op))); |
3572 | who->statusmsg (format ("You ready %s.", query_name (op))); |
|
|
3573 | who->current_weapon = pl->ranged_ob = op; |
3705 | |
3574 | |
3706 | if (op->type == BOW) |
3575 | if (op->type == BOW) |
3707 | { |
|
|
3708 | who->current_weapon = op; |
|
|
3709 | change_abil (who, op); |
|
|
3710 | who->statusmsg (format ("You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op))); |
3576 | who->statusmsg (format ("You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op))); |
3711 | } |
3577 | |
|
|
3578 | change_abil (who, op); |
3712 | } |
3579 | } |
3713 | else |
3580 | else |
3714 | { |
3581 | { |
|
|
3582 | who->change_skill (skop); |
|
|
3583 | |
3715 | if (op->type == BOW) |
3584 | if (op->type == BOW) |
3716 | SET_FLAG (who, FLAG_READY_BOW); |
3585 | op->flag [FLAG_READY_BOW ] = true; |
3717 | else |
3586 | else |
3718 | SET_FLAG (who, FLAG_READY_RANGE); |
3587 | op->flag [FLAG_READY_RANGE] = true; |
3719 | } |
3588 | } |
3720 | |
3589 | |
3721 | break; |
3590 | break; |
3722 | |
3591 | |
3723 | case BUILDER: |
3592 | case BUILDER: |
3724 | if (who->type == PLAYER) |
3593 | if (player *pl = who->contr) |
3725 | { |
3594 | { |
3726 | //TODO: wtf does this do? shouldn't this be managed automatically (slots?) |
3595 | who->current_weapon = pl->ranged_ob = op; |
3727 | if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) |
|
|
3728 | unapply_special (who, who->contr->ranged_ob, 0); |
|
|
3729 | |
|
|
3730 | who->statusmsg (format ("You ready your %s.", query_name (op))); |
3596 | who->statusmsg (format ("You ready your %s.", query_name (op))); |
3731 | |
3597 | //TODO: change_abil? |
3732 | who->contr->ranged_ob = op; |
|
|
3733 | } |
3598 | } |
3734 | break; |
3599 | break; |
3735 | |
3600 | |
3736 | default: |
3601 | default: |
3737 | who->statusmsg (format ("You apply %s.", query_name (op))); |
3602 | who->statusmsg (format ("You apply %s.", query_name (op))); |
3738 | } |
3603 | } |
3739 | |
3604 | |
3740 | SET_FLAG (op, FLAG_APPLIED); |
3605 | SET_FLAG (op, FLAG_APPLIED); |
3741 | |
3606 | |
3742 | if (tmp) |
|
|
3743 | who->insert (tmp); |
3607 | if (tmp) who->insert (tmp); |
3744 | |
3608 | |
3745 | who->update_stats (); |
3609 | who->update_stats (); |
3746 | |
3610 | |
3747 | /* We exclude spell casting objects. The fire code will set the |
3611 | /* We exclude spell casting objects. The fire code will set the |
3748 | * been applied flag when they are used - until that point, |
3612 | * been applied flag when they are used - until that point, |
… | |
… | |
3879 | * treasure again for this object |
3743 | * treasure again for this object |
3880 | */ |
3744 | */ |
3881 | invtmp->randomitems = NULL; |
3745 | invtmp->randomitems = NULL; |
3882 | } |
3746 | } |
3883 | } |
3747 | } |
|
|
3748 | |
3884 | /* This is really temporary - the code at the bottom will |
3749 | /* This is really temporary - the code at the bottom will |
3885 | * also set randomitems to null. The problem is there are bunches |
3750 | * also set randomitems to null. The problem is there are bunches |
3886 | * of maps/players already out there with items that have spells |
3751 | * of maps/players already out there with items that have spells |
3887 | * which haven't had the randomitems set to null yet. |
3752 | * which haven't had the randomitems set to null yet. |
3888 | * MSW 2004-05-13 |
3753 | * MSW 2004-05-13 |
… | |
… | |
3892 | * Ryo 2004-08-16 |
3757 | * Ryo 2004-08-16 |
3893 | */ |
3758 | */ |
3894 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3759 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3895 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3760 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3896 | tmp->randomitems = NULL; |
3761 | tmp->randomitems = NULL; |
3897 | |
|
|
3898 | } |
3762 | } |
3899 | |
3763 | |
3900 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3764 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3901 | auto_apply (tmp); |
3765 | auto_apply (tmp); |
3902 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
3766 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
… | |
… | |
3959 | /* bigger morsel of food = longer effect time */ |
3823 | /* bigger morsel of food = longer effect time */ |
3960 | int duration = TIME2TICK (food->stats.food); |
3824 | int duration = TIME2TICK (food->stats.food); |
3961 | |
3825 | |
3962 | if (force = who->force_find (key)) |
3826 | if (force = who->force_find (key)) |
3963 | { |
3827 | { |
3964 | if (duration > abs (force->speed_left / force->speed)) |
3828 | if (duration > fabs (force->speed_left / force->speed)) |
3965 | { |
3829 | { |
3966 | new_draw_info_format (NDI_UNIQUE, 0, who, "More magical force spreads through you. H<The effect will last for about %.10g more seconds.>", TICK2TIME (duration)); |
3830 | new_draw_info_format (NDI_UNIQUE, 0, who, "More magical force spreads through you. H<The effect will last for about %.10g more seconds.>", TICK2TIME (duration)); |
3967 | force->force_set_timer (duration); |
3831 | force->force_set_timer (duration); |
3968 | } |
3832 | } |
3969 | else |
3833 | else |