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 | |
… | |
… | |
1766 | * instead of having their spell stored in stats.sp. These are |
1769 | * instead of having their spell stored in stats.sp. These are |
1767 | * legacy spellbooks |
1770 | * legacy spellbooks |
1768 | */ |
1771 | */ |
1769 | if (tmp->slaying) |
1772 | if (tmp->slaying) |
1770 | { |
1773 | { |
1771 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1774 | spell = find_archetype_by_object_name (tmp->slaying)->instance (); |
|
|
1775 | |
1772 | if (!spell) |
1776 | if (!spell) |
1773 | { |
1777 | { |
1774 | op->failmsg (format ("The book's formula for %s is incomplete.", &tmp->slaying)); |
1778 | op->failmsg (format ("The book's formula for %s is incomplete.", &tmp->slaying)); |
1775 | return; |
1779 | return; |
1776 | } |
1780 | } |
… | |
… | |
1997 | int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */ |
2001 | int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */ |
1998 | int winners = 0; /* number of winners */ |
2002 | int winners = 0; /* number of winners */ |
1999 | int i; /* index */ |
2003 | int i; /* index */ |
2000 | |
2004 | |
2001 | /* let's make sure and doublecheck the parameters */ |
2005 | /* let's make sure and doublecheck the parameters */ |
2002 | if (meal->type != FLESH || !is_dragon_pl (op)) |
2006 | if (meal->type != FLESH || !op->is_dragon ()) |
2003 | return 0; |
2007 | return 0; |
2004 | |
2008 | |
2005 | /* now grab the 'dragon_skin'- and 'dragon_ability'-forces |
2009 | /* now grab the 'dragon_skin'- and 'dragon_ability'-forces |
2006 | from the player's inventory */ |
2010 | from the player's inventory */ |
2007 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2011 | for (tmp = op->inv; tmp; tmp = tmp->below) |
… | |
… | |
2145 | if (op->type != PLAYER) |
2149 | if (op->type != PLAYER) |
2146 | op->stats.hp = op->stats.maxhp; |
2150 | op->stats.hp = op->stats.maxhp; |
2147 | else |
2151 | else |
2148 | { |
2152 | { |
2149 | /* check if this is a dragon (player), eating some flesh */ |
2153 | /* check if this is a dragon (player), eating some flesh */ |
2150 | if (tmp->type == FLESH && is_dragon_pl (op) && dragon_eat_flesh (op, tmp)) |
2154 | if (tmp->type == FLESH && op->is_dragon () && dragon_eat_flesh (op, tmp)) |
2151 | ; |
2155 | ; |
2152 | else |
2156 | else |
2153 | { |
2157 | { |
2154 | /* usual case - no dragon meal: */ |
2158 | /* usual case - no dragon meal: */ |
2155 | if (op->stats.food + tmp->stats.food > 999) |
2159 | if (op->stats.food + tmp->stats.food > 999) |
… | |
… | |
2170 | |
2174 | |
2171 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2175 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2172 | { |
2176 | { |
2173 | const char *buf; |
2177 | const char *buf; |
2174 | |
2178 | |
2175 | if (!is_dragon_pl (op)) |
2179 | if (!op->is_dragon ()) |
2176 | { |
2180 | { |
2177 | /* eating message for normal players */ |
2181 | /* eating message for normal players */ |
2178 | if (tmp->type == DRINK) |
2182 | if (tmp->type == DRINK) |
2179 | buf = format ("Ahhh...that %s tasted good.", &tmp->name); |
2183 | buf = format ("Ahhh...that %s tasted good.", &tmp->name); |
2180 | else |
2184 | else |
… | |
… | |
2265 | hit_player (op, poison->stats.hp, tmp, AT_POISON, 1); |
2269 | hit_player (op, poison->stats.hp, tmp, AT_POISON, 1); |
2266 | } |
2270 | } |
2267 | |
2271 | |
2268 | op->stats.food -= op->stats.food / 4; |
2272 | op->stats.food -= op->stats.food / 4; |
2269 | poison->destroy (); |
2273 | 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 | } |
2274 | } |
2361 | |
2275 | |
2362 | /** |
2276 | /** |
2363 | * This function will try to apply a lighter and in case no lighter |
2277 | * 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, |
2278 | * is specified it will try to find a lighter in the players inventory, |
… | |
… | |
2619 | static void |
2533 | static void |
2620 | apply_item_transformer (object *pl, object *transformer) |
2534 | apply_item_transformer (object *pl, object *transformer) |
2621 | { |
2535 | { |
2622 | object *marked; |
2536 | object *marked; |
2623 | object *new_item; |
2537 | object *new_item; |
2624 | char *find; |
2538 | const char *find; |
2625 | char *separator; |
2539 | char *separator; |
2626 | int yield; |
2540 | int yield; |
2627 | char got[MAX_BUF]; |
2541 | char got[MAX_BUF]; |
2628 | int len; |
2542 | int len; |
2629 | |
2543 | |
… | |
… | |
2672 | while (*find == ' ') |
2586 | while (*find == ' ') |
2673 | find++; |
2587 | find++; |
2674 | |
2588 | |
2675 | memset (got, 0, MAX_BUF); |
2589 | memset (got, 0, MAX_BUF); |
2676 | |
2590 | |
2677 | if ((separator = strchr (find, ';')) != NULL) |
2591 | if ((separator = (char *) strchr (find, ';'))) |
2678 | len = separator - find; |
2592 | len = separator - find; |
2679 | else |
2593 | else |
2680 | len = strlen (find); |
2594 | len = strlen (find); |
2681 | |
2595 | |
2682 | if (len > MAX_BUF - 1) |
2596 | min_it (len, MAX_BUF - 1); |
2683 | len = MAX_BUF - 1; |
|
|
2684 | |
2597 | |
2685 | strcpy (got, find); |
2598 | strcpy (got, find); |
2686 | got[len] = '\0'; |
2599 | got[len] = '\0'; |
2687 | |
2600 | |
2688 | /* Now create new item, remove used ones when required. */ |
2601 | /* Now create new item, remove used ones when required. */ |
… | |
… | |
2767 | |
2680 | |
2768 | case EXIT: |
2681 | case EXIT: |
2769 | if (who->type != PLAYER) |
2682 | if (who->type != PLAYER) |
2770 | return 0; |
2683 | return 0; |
2771 | |
2684 | |
2772 | if (!EXIT_PATH (op) || !is_legal_2ways_exit (who, op)) |
2685 | 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))); |
2686 | 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 |
2687 | else |
2775 | { |
2688 | { |
2776 | /* Don't display messages for random maps. */ |
2689 | /* Don't display messages for random maps. */ |
2777 | if (op->msg && !EXIT_PATH (op).starts_with ("/!")) |
2690 | if (op->msg && EXIT_PATH (op) != shstr_random_map_exit) |
2778 | who->statusmsg (op->msg, NDI_NAVY); |
2691 | who->statusmsg (op->msg, NDI_NAVY); |
2779 | |
2692 | |
2780 | who->enter_exit (op); |
2693 | who->enter_exit (op); |
2781 | } |
2694 | } |
2782 | |
2695 | |
… | |
… | |
3042 | CLEAR_FLAG (op, FLAG_APPLIED); |
2955 | CLEAR_FLAG (op, FLAG_APPLIED); |
3043 | |
2956 | |
3044 | switch (op->type) |
2957 | switch (op->type) |
3045 | { |
2958 | { |
3046 | case SKILL_TOOL: |
2959 | case SKILL_TOOL: |
|
|
2960 | case WEAPON: |
3047 | // unapplying a skill tool should also unapply the skill it governs |
2961 | // 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 |
2962 | // but this is hard, as it shouldn't do so when the skill can |
3049 | // be used for other reasons |
2963 | // be used for other reasons |
3050 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
2964 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
3051 | if (tmp->skill == op->skill |
2965 | if (tmp->skill == op->skill |
3052 | && tmp->type == SKILL |
2966 | && tmp->type == SKILL |
3053 | && tmp->flag [FLAG_APPLIED] |
2967 | && tmp->flag [FLAG_APPLIED] |
3054 | && !tmp->flag [FLAG_CAN_USE_SKILL]) |
2968 | && !tmp->flag [FLAG_CAN_USE_SKILL]) |
3055 | unapply_special (who, tmp, 0); |
2969 | unapply_special (who, tmp, 0); |
3056 | |
2970 | |
3057 | change_abil (who, op); |
|
|
3058 | break; |
|
|
3059 | |
|
|
3060 | case WEAPON: |
|
|
3061 | if (player *pl = who->contr) |
2971 | if (player *pl = who->contr) |
3062 | if (op == pl->combat_ob) |
2972 | if (op == pl->combat_ob) |
3063 | { |
2973 | { |
3064 | pl->combat_ob = 0; |
2974 | pl->combat_ob = 0; |
3065 | who->change_weapon (pl->ranged_ob); |
2975 | who->change_weapon (pl->ranged_ob); |
3066 | } |
2976 | } |
3067 | |
2977 | |
3068 | who->statusmsg (format ("You unwield %s.", query_name (op))); |
|
|
3069 | |
|
|
3070 | change_abil (who, op); |
2978 | change_abil (who, op); |
3071 | CLEAR_FLAG (who, FLAG_READY_WEAPON); |
2979 | |
|
|
2980 | if (op->type == WEAPON) |
|
|
2981 | { |
|
|
2982 | who->flag [FLAG_READY_WEAPON] = false; |
|
|
2983 | who->statusmsg (format ("You unwield %s.", query_name (op))); |
|
|
2984 | } |
|
|
2985 | else |
|
|
2986 | who->flag [FLAG_READY_SKILL] = false; |
|
|
2987 | |
3072 | break; |
2988 | break; |
3073 | |
2989 | |
3074 | case SKILL: |
2990 | case SKILL: |
3075 | if (who->contr) |
2991 | if (who->contr) |
3076 | { |
2992 | { |
3077 | if (IS_COMBAT_SKILL (op->subtype)) |
2993 | if (op == who->contr->combat_ob) |
|
|
2994 | { |
3078 | who->change_weapon (who->contr->combat_ob = 0); |
2995 | who->contr->combat_ob = 0; |
3079 | else if (IS_RANGED_SKILL (op->subtype)) |
|
|
3080 | who->change_weapon (who->contr->ranged_ob = 0); |
2996 | who->change_weapon (who->contr->ranged_ob); |
|
|
2997 | } |
|
|
2998 | |
|
|
2999 | if (op == who->contr->ranged_ob) |
|
|
3000 | { |
|
|
3001 | who->contr->ranged_ob = 0; |
|
|
3002 | who->change_weapon (who->contr->combat_ob); |
|
|
3003 | } |
3081 | |
3004 | |
3082 | if (op->invisible) |
3005 | if (op->invisible) |
3083 | who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill)); |
3006 | who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill)); |
3084 | else |
3007 | else |
3085 | who->statusmsg (format ("You stop using the %s.", query_name (op))); |
3008 | who->statusmsg (format ("You stop using the %s.", query_name (op))); |
… | |
… | |
3120 | else |
3043 | else |
3121 | { |
3044 | { |
3122 | who->change_skill (0); |
3045 | who->change_skill (0); |
3123 | |
3046 | |
3124 | if (op->type == BOW) |
3047 | if (op->type == BOW) |
3125 | CLEAR_FLAG (who, FLAG_READY_BOW); |
3048 | op->flag [FLAG_READY_BOW ] = false; |
3126 | else |
3049 | else |
3127 | CLEAR_FLAG (who, FLAG_READY_RANGE); |
3050 | op->flag [FLAG_READY_RANGE] = false; |
3128 | } |
3051 | } |
3129 | |
3052 | |
3130 | break; |
3053 | break; |
3131 | |
3054 | |
3132 | case BUILDER: |
3055 | case BUILDER: |
… | |
… | |
3555 | { |
3478 | { |
3556 | who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO |
3479 | who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO |
3557 | return 1; |
3480 | return 1; |
3558 | } |
3481 | } |
3559 | |
3482 | |
3560 | SET_FLAG (op, FLAG_APPLIED); |
3483 | op->flag [FLAG_APPLIED] = true; |
3561 | who->change_skill (skop); |
|
|
3562 | |
3484 | |
3563 | if (who->contr) |
3485 | if (who->contr) |
3564 | who->change_weapon (who->contr->combat_ob = op); |
3486 | who->change_weapon (who->contr->combat_ob = op); |
|
|
3487 | else |
|
|
3488 | who->change_skill (skop); |
3565 | |
3489 | |
3566 | who->statusmsg (format ("You wield %s.", query_name (op))); |
3490 | who->statusmsg (format ("You wield %s.", query_name (op))); |
3567 | |
3491 | |
3568 | SET_FLAG (who, FLAG_READY_WEAPON); |
3492 | op->flag [FLAG_READY_WEAPON] = true; |
3569 | change_abil (who, op); |
3493 | change_abil (who, op); |
3570 | break; |
3494 | break; |
3571 | |
3495 | |
3572 | case ARMOUR: |
3496 | case ARMOUR: |
3573 | case HELMET: |
3497 | case HELMET: |
… | |
… | |
3599 | case SKILL: |
3523 | case SKILL: |
3600 | if (player *pl = who->contr) |
3524 | if (player *pl = who->contr) |
3601 | { |
3525 | { |
3602 | if (IS_COMBAT_SKILL (op->subtype)) |
3526 | if (IS_COMBAT_SKILL (op->subtype)) |
3603 | { |
3527 | { |
3604 | if (skill_flags [op->subtype] & SF_NEED_WEAPON) |
3528 | if (skill_flags [op->subtype] & SF_NEED_ITEM) |
3605 | { |
3529 | { |
|
|
3530 | // try to find the weapon, and apply it instead |
3606 | for (object *item = who->inv; item; item = item->below) |
3531 | for (object *item = who->inv; item; item = item->below) |
3607 | if (item->type == WEAPON && item->flag [FLAG_APPLIED]) |
3532 | if (item->type == op->weapontype && item->flag [FLAG_APPLIED]) |
3608 | { |
3533 | { |
3609 | if (item->skill == op->skill) |
3534 | if (item->skill == op->skill) |
3610 | { |
3535 | { |
3611 | who->change_weapon (pl->combat_ob = item); |
3536 | who->change_weapon (pl->combat_ob = item); |
3612 | goto found_weapon; |
3537 | goto found_weapon; |
… | |
… | |
3625 | else |
3550 | else |
3626 | who->change_weapon (pl->combat_ob = op); |
3551 | who->change_weapon (pl->combat_ob = op); |
3627 | } |
3552 | } |
3628 | else if (IS_RANGED_SKILL (op->subtype)) |
3553 | else if (IS_RANGED_SKILL (op->subtype)) |
3629 | { |
3554 | { |
3630 | if (skill_flags [op->subtype] & SF_NEED_BOW) |
3555 | if (skill_flags [op->subtype] & SF_NEED_ITEM) |
3631 | { |
3556 | { |
3632 | for (object *item = who->inv; item; item = item->below) |
3557 | for (object *item = who->inv; item; item = item->below) |
3633 | if (item->type == BOW && item->flag [FLAG_APPLIED]) |
3558 | if (item->type == op->weapontype && item->flag [FLAG_APPLIED]) |
3634 | { |
3559 | { |
3635 | //TODO: bows should/must all have skill missile weapon right now |
3560 | //TODO: bows should/must all have skill missile weapon right now |
3636 | who->change_weapon (pl->ranged_ob = item); |
3561 | who->change_weapon (pl->ranged_ob = item); |
3637 | goto found_bow; |
3562 | goto found_bow; |
3638 | } |
3563 | } |
… | |
… | |
3692 | { |
3617 | { |
3693 | who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO |
3618 | who->failmsg (format ("The %s is broken, please report this to the dungeon master!", query_name (op)));//TODO |
3694 | return 1; |
3619 | return 1; |
3695 | } |
3620 | } |
3696 | |
3621 | |
3697 | SET_FLAG (op, FLAG_APPLIED); |
3622 | op->flag [FLAG_APPLIED] = true; |
3698 | who->change_skill (skop); |
|
|
3699 | |
3623 | |
3700 | if (who->contr) |
3624 | if (who->contr) |
3701 | { |
3625 | { |
3702 | who->contr->ranged_ob = op; |
|
|
3703 | |
|
|
3704 | who->statusmsg (format ("You ready %s.", query_name (op))); |
3626 | who->statusmsg (format ("You ready %s.", query_name (op))); |
|
|
3627 | who->change_weapon (who->contr->ranged_ob = op); |
3705 | |
3628 | |
3706 | if (op->type == BOW) |
3629 | 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))); |
3630 | who->statusmsg (format ("You will now fire %s with %s.", op->race ? &op->race : "nothing", query_name (op))); |
3711 | } |
|
|
3712 | } |
3631 | } |
3713 | else |
3632 | else |
3714 | { |
3633 | { |
|
|
3634 | who->change_skill (skop); |
|
|
3635 | |
3715 | if (op->type == BOW) |
3636 | if (op->type == BOW) |
3716 | SET_FLAG (who, FLAG_READY_BOW); |
3637 | op->flag [FLAG_READY_BOW ] = true; |
3717 | else |
3638 | else |
3718 | SET_FLAG (who, FLAG_READY_RANGE); |
3639 | op->flag [FLAG_READY_RANGE] = true; |
3719 | } |
3640 | } |
3720 | |
3641 | |
3721 | break; |
3642 | break; |
3722 | |
3643 | |
3723 | case BUILDER: |
3644 | case BUILDER: |
… | |
… | |
3726 | //TODO: wtf does this do? shouldn't this be managed automatically (slots?) |
3647 | //TODO: wtf does this do? shouldn't this be managed automatically (slots?) |
3727 | if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) |
3648 | if (who->contr->ranged_ob && who->contr->ranged_ob->type == BUILDER) |
3728 | unapply_special (who, who->contr->ranged_ob, 0); |
3649 | unapply_special (who, who->contr->ranged_ob, 0); |
3729 | |
3650 | |
3730 | who->statusmsg (format ("You ready your %s.", query_name (op))); |
3651 | who->statusmsg (format ("You ready your %s.", query_name (op))); |
3731 | |
|
|
3732 | who->contr->ranged_ob = op; |
3652 | who->change_weapon (who->contr->ranged_ob = op); |
3733 | } |
3653 | } |
3734 | break; |
3654 | break; |
3735 | |
3655 | |
3736 | default: |
3656 | default: |
3737 | who->statusmsg (format ("You apply %s.", query_name (op))); |
3657 | who->statusmsg (format ("You apply %s.", query_name (op))); |
… | |
… | |
3879 | * treasure again for this object |
3799 | * treasure again for this object |
3880 | */ |
3800 | */ |
3881 | invtmp->randomitems = NULL; |
3801 | invtmp->randomitems = NULL; |
3882 | } |
3802 | } |
3883 | } |
3803 | } |
|
|
3804 | |
3884 | /* This is really temporary - the code at the bottom will |
3805 | /* This is really temporary - the code at the bottom will |
3885 | * also set randomitems to null. The problem is there are bunches |
3806 | * also set randomitems to null. The problem is there are bunches |
3886 | * of maps/players already out there with items that have spells |
3807 | * of maps/players already out there with items that have spells |
3887 | * which haven't had the randomitems set to null yet. |
3808 | * which haven't had the randomitems set to null yet. |
3888 | * MSW 2004-05-13 |
3809 | * MSW 2004-05-13 |
… | |
… | |
3892 | * Ryo 2004-08-16 |
3813 | * Ryo 2004-08-16 |
3893 | */ |
3814 | */ |
3894 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3815 | 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) |
3816 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3896 | tmp->randomitems = NULL; |
3817 | tmp->randomitems = NULL; |
3897 | |
|
|
3898 | } |
3818 | } |
3899 | |
3819 | |
3900 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3820 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3901 | auto_apply (tmp); |
3821 | auto_apply (tmp); |
3902 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
3822 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
… | |
… | |
3959 | /* bigger morsel of food = longer effect time */ |
3879 | /* bigger morsel of food = longer effect time */ |
3960 | int duration = TIME2TICK (food->stats.food); |
3880 | int duration = TIME2TICK (food->stats.food); |
3961 | |
3881 | |
3962 | if (force = who->force_find (key)) |
3882 | if (force = who->force_find (key)) |
3963 | { |
3883 | { |
3964 | if (duration > abs (force->speed_left / force->speed)) |
3884 | if (duration > fabs (force->speed_left / force->speed)) |
3965 | { |
3885 | { |
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)); |
3886 | 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); |
3887 | force->force_set_timer (duration); |
3968 | } |
3888 | } |
3969 | else |
3889 | else |