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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
239 | set_dragon_name (ob, abil, skin); |
239 | set_dragon_name (ob, abil, skin); |
240 | } |
240 | } |
241 | |
241 | |
242 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
242 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
243 | |
243 | |
244 | esrv_new_player (this, ob->weight + ob->carrying); |
244 | esrv_new_player (this); |
245 | |
245 | |
246 | ob->update_stats (); |
246 | ob->update_stats (); |
247 | |
247 | |
248 | ns->floorbox_update (); |
248 | ns->floorbox_update (); |
249 | esrv_send_inventory (ob, ob); |
249 | esrv_send_inventory (ob, ob); |
… | |
… | |
291 | player::set_object (object *op) |
291 | player::set_object (object *op) |
292 | { |
292 | { |
293 | ob = observe = op; |
293 | ob = observe = op; |
294 | ob->contr = this; /* this aren't yet in archetype */ |
294 | ob->contr = this; /* this aren't yet in archetype */ |
295 | |
295 | |
296 | ob->speed = 1.0f; |
296 | ob->speed = 1.0f; |
297 | ob->speed_left = 0.5f; |
297 | ob->speed_left = 0.5f; |
298 | |
298 | |
299 | ob->direction = 5; /* So player faces south */ |
299 | ob->direction = 5; /* So player faces south */ |
300 | |
300 | |
301 | ob->flag [FLAG_READY_WEAPON] = false; |
301 | ob->flag [FLAG_READY_WEAPON] = false; |
302 | ob->flag [FLAG_READY_SKILL] = false; |
302 | ob->flag [FLAG_READY_SKILL] = false; |
303 | ob->flag [FLAG_READY_BOW] = false; |
303 | ob->flag [FLAG_READY_BOW] = false; |
304 | |
304 | |
… | |
… | |
851 | */ |
851 | */ |
852 | void |
852 | void |
853 | player::chargen_race_done () |
853 | player::chargen_race_done () |
854 | { |
854 | { |
855 | /* this must before then initial items are given */ |
855 | /* this must before then initial items are given */ |
856 | esrv_new_player (ob->contr, ob->weight + ob->carrying); |
856 | esrv_new_player (ob->contr); |
857 | |
857 | |
858 | treasurelist *tl = treasurelist::find ("starting_wealth"); |
858 | treasurelist *tl = treasurelist::find ("starting_wealth"); |
859 | if (tl) |
859 | if (tl) |
860 | create_treasure (tl, ob, 0, 0, 0); |
860 | create_treasure (tl, ob, 0, 0, 0); |
861 | |
861 | |
… | |
… | |
1405 | } |
1405 | } |
1406 | } |
1406 | } |
1407 | else if (arrow->type == ARROW && arrow->race == type) |
1407 | else if (arrow->type == ARROW && arrow->race == type) |
1408 | { |
1408 | { |
1409 | /* allways prefer assasination/slaying */ |
1409 | /* allways prefer assasination/slaying */ |
1410 | if (target->race != NULL && arrow->slaying != NULL && strstr (arrow->slaying, target->race)) |
1410 | if (target->race && arrow->slaying && strstr (arrow->slaying, target->race)) |
1411 | { |
1411 | { |
1412 | if (arrow->attacktype & AT_DEATH) |
1412 | if (arrow->attacktype & AT_DEATH) |
1413 | { |
1413 | { |
1414 | *better = 100; |
1414 | *better = 100; |
1415 | return arrow; |
1415 | return arrow; |
… | |
… | |
1443 | betterby = 1 + arrow->magic + arrow->stats.dam; |
1443 | betterby = 1 + arrow->magic + arrow->stats.dam; |
1444 | } |
1444 | } |
1445 | } |
1445 | } |
1446 | } |
1446 | } |
1447 | } |
1447 | } |
|
|
1448 | |
1448 | if (tmp == NULL && arrow == NULL) |
1449 | if (tmp == NULL && arrow == NULL) |
1449 | return find_arrow (op, type); |
1450 | return find_arrow (op, type); |
1450 | |
1451 | |
1451 | *better = betterby; |
1452 | *better = betterby; |
1452 | return tmp; |
1453 | return tmp; |
… | |
… | |
1763 | return; |
1764 | return; |
1764 | } |
1765 | } |
1765 | } |
1766 | } |
1766 | else if (item->type == ROD || item->type == HORN) |
1767 | else if (item->type == ROD || item->type == HORN) |
1767 | { |
1768 | { |
1768 | if (item->stats.hp < MAX (item->inv->stats.sp, item->inv->stats.grace)) |
1769 | sint16 spell_sp = MAX (item->inv->stats.sp, item->inv->stats.grace); |
|
|
1770 | |
|
|
1771 | // using the maximum of the rods charge allows at least one spell cast |
|
|
1772 | // for a rod or horn, this fixes some broken rods. |
|
|
1773 | if (item->stats.hp < MIN (spell_sp, item->stats.maxhp)) |
1769 | { |
1774 | { |
1770 | op->contr->play_sound (sound_find ("wand_poof")); |
1775 | op->contr->play_sound (sound_find ("wand_poof")); |
1771 | |
1776 | |
1772 | if (item->type == ROD) |
1777 | if (item->type == ROD) |
1773 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); |
1778 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); |
… | |
… | |
1792 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1797 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1793 | item->face = item->arch->face; |
1798 | item->face = item->arch->face; |
1794 | item->set_speed (0); |
1799 | item->set_speed (0); |
1795 | } |
1800 | } |
1796 | |
1801 | |
1797 | if ((tmp = item->in_player ())) |
1802 | if (object *pl = item->visible_to ()) |
1798 | esrv_update_item (UPD_ANIM, tmp, item); |
1803 | esrv_update_item (UPD_ANIM, pl, item); |
1799 | } |
1804 | } |
1800 | } |
1805 | } |
1801 | else if (item->type == ROD || item->type == HORN) |
1806 | else if (item->type == ROD || item->type == HORN) |
1802 | drain_rod_charge (item); |
1807 | drain_rod_charge (item); |
1803 | } |
1808 | } |
… | |
… | |
1980 | remove_door2 (door); /* remove door without violence ;-) */ |
1985 | remove_door2 (door); /* remove door without violence ;-) */ |
1981 | } |
1986 | } |
1982 | |
1987 | |
1983 | /* Do this after we print the message */ |
1988 | /* Do this after we print the message */ |
1984 | key->decrease (); /* Use up one of the keys */ |
1989 | key->decrease (); /* Use up one of the keys */ |
1985 | /* Need to update the weight the container the key was in */ |
|
|
1986 | if (container != op) |
|
|
1987 | esrv_update_item (UPD_WEIGHT, op, container); |
|
|
1988 | |
1990 | |
1989 | return 1; /* Nothing more to do below */ |
1991 | return 1; /* Nothing more to do below */ |
1990 | } |
1992 | } |
1991 | else if (door->type == LOCKED_DOOR) |
1993 | else if (door->type == LOCKED_DOOR) |
1992 | { |
1994 | { |
… | |
… | |
2271 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2273 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2272 | { |
2274 | { |
2273 | op->play_sound (sound_find ("ob_evaporate")); |
2275 | op->play_sound (sound_find ("ob_evaporate")); |
2274 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2276 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2275 | |
2277 | |
2276 | if (op->contr) |
|
|
2277 | esrv_del_item (op->contr, tmp->count); |
|
|
2278 | |
|
|
2279 | tmp->destroy (); |
2278 | tmp->destroy (); |
2280 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2279 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2281 | |
2280 | |
2282 | if (op->stats.hp < 0) |
2281 | if (op->stats.hp < 0) |
2283 | op->stats.hp = op->stats.maxhp; |
2282 | op->stats.hp = op->stats.maxhp; |
… | |
… | |
2295 | return 0; |
2294 | return 0; |
2296 | } |
2295 | } |
2297 | |
2296 | |
2298 | /* This goes throws the inventory and removes unpaid objects, and puts them |
2297 | /* This goes throws the inventory and removes unpaid objects, and puts them |
2299 | * back in the map (location and map determined by values of env). This |
2298 | * back in the map (location and map determined by values of env). This |
2300 | * function will descend into containers. op is the object to start the search |
2299 | * function will descend into containers. op is the object to start the search |
2301 | * from. |
2300 | * from. |
2302 | */ |
2301 | */ |
2303 | static void |
2302 | static void |
2304 | drop_unpaid_items (object *op, object *env) |
2303 | drop_unpaid_items (object *op, object *env) |
2305 | { |
2304 | { |
2306 | while (op) |
2305 | while (op) |
2307 | { |
2306 | { |
2308 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2307 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2309 | |
2308 | |
2310 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2309 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2311 | { |
|
|
2312 | if (env->type == PLAYER) |
|
|
2313 | esrv_del_item (env->contr, op->count); |
|
|
2314 | |
|
|
2315 | op->insert_at (env); |
2310 | op->insert_at (env); |
2316 | } |
|
|
2317 | else if (op->inv) |
2311 | else if (op->inv) |
2318 | drop_unpaid_items (op->inv, env); |
2312 | drop_unpaid_items (op->inv, env); |
2319 | |
2313 | |
2320 | op = next; |
2314 | op = next; |
2321 | } |
2315 | } |
… | |
… | |
2333 | * Moved from apply.c to player.c - player.c is what |
2327 | * Moved from apply.c to player.c - player.c is what |
2334 | * actually uses this function. player.c may not be quite the |
2328 | * actually uses this function. player.c may not be quite the |
2335 | * best, a misc file for object actions is probably better, |
2329 | * best, a misc file for object actions is probably better, |
2336 | * but there isn't one in the server directory. |
2330 | * but there isn't one in the server directory. |
2337 | */ |
2331 | */ |
2338 | char * |
2332 | const char * |
2339 | gravestone_text (object *op) |
2333 | gravestone_text (object *op) |
2340 | { |
2334 | { |
2341 | static char buf2[MAX_BUF]; |
2335 | static dynbuf_text buf; |
2342 | char buf[MAX_BUF]; |
|
|
2343 | time_t now = time (NULL); |
|
|
2344 | |
2336 | |
2345 | strcpy (buf2, " R.I.P.\n\n"); |
2337 | buf << "---- R.I.P. ----\n\n"; |
|
|
2338 | op->name; |
|
|
2339 | |
2346 | if (op->type == PLAYER) |
2340 | if (op->type == PLAYER) |
2347 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2341 | buf << " the " << op->contr->title; |
2348 | else |
|
|
2349 | sprintf (buf, "%s\n", &op->name); |
|
|
2350 | |
2342 | |
2351 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2343 | buf << "\n\n"; |
2352 | strcat (buf2, buf); |
2344 | |
|
|
2345 | buf << "who was level "; |
|
|
2346 | buf << (sint32)op->level << "\n\n" // OO breakdown |
|
|
2347 | << " when " << (op->contr ? "killed" : "died") << "\n\n"; |
|
|
2348 | |
2353 | if (op->type == PLAYER) |
2349 | if (op->type == PLAYER) |
2354 | sprintf (buf, "who was in level %d when killed\n", op->level); |
2350 | buf << "by " << op->contr->killer_name () << ".\n\n"; |
2355 | else |
|
|
2356 | sprintf (buf, "who was in level %d when died.\n\n", op->level); |
|
|
2357 | |
2351 | |
2358 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
|
|
2359 | strcat (buf2, buf); |
|
|
2360 | if (op->type == PLAYER) |
|
|
2361 | { |
2352 | { |
2362 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2353 | static char buf2[128]; |
2363 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2354 | time_t now = time (NULL); |
2364 | strcat (buf2, buf); |
|
|
2365 | } |
|
|
2366 | |
|
|
2367 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2355 | strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now)); |
2368 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2356 | buf << buf2; |
2369 | strcat (buf2, buf); |
2357 | } |
2370 | |
2358 | |
2371 | return buf2; |
2359 | return buf; |
2372 | } |
2360 | } |
2373 | |
2361 | |
2374 | void |
2362 | void |
2375 | do_some_living (object *op) |
2363 | do_some_living (object *op) |
2376 | { |
2364 | { |
… | |
… | |
2557 | op->stats.food--; |
2545 | op->stats.food--; |
2558 | } |
2546 | } |
2559 | |
2547 | |
2560 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2548 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2561 | { |
2549 | { |
2562 | object *tmp, *flesh = 0; |
2550 | object *flesh = 0; |
2563 | |
2551 | |
2564 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2552 | for_inv_removable (op, tmp) |
2565 | { |
2553 | { |
2566 | if (!QUERY_FLAG (tmp, FLAG_UNPAID)) |
2554 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
|
|
2555 | continue; |
|
|
2556 | |
|
|
2557 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2567 | { |
2558 | { |
2568 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2559 | op->statusmsg ("You blindly grab for a bite of food. " |
2569 | { |
2560 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2570 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
|
|
2571 | manual_apply (op, tmp, 0); |
2561 | manual_apply (op, tmp, 0); |
|
|
2562 | |
2572 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2563 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2573 | break; |
2564 | break; |
2574 | } |
2565 | } |
2575 | else if (tmp->type == FLESH) |
2566 | else if (tmp->type == FLESH) |
2576 | flesh = tmp; |
2567 | flesh = tmp; |
2577 | } /* End if paid for object */ |
2568 | } |
2578 | } /* end of for loop */ |
|
|
2579 | |
2569 | |
2580 | /* If player is still starving, it means they don't have any food, so |
2570 | /* If player is still starving, it means they don't have any food, so |
2581 | * eat flesh instead. |
2571 | * eat flesh instead. |
2582 | */ |
2572 | */ |
2583 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2573 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2584 | { |
2574 | { |
2585 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2575 | op->statusmsg ("You blindly grab for a bite of food. " |
|
|
2576 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2586 | manual_apply (op, flesh, 0); |
2577 | manual_apply (op, flesh, 0); |
2587 | } |
2578 | } |
|
|
2579 | |
|
|
2580 | // If player is still starving, alert him! |
|
|
2581 | if (op->stats.food < 0) |
|
|
2582 | op->failmsg ("You are starving! " |
|
|
2583 | "H<Eat some food to increase your food and prevent you from an untimely death.>"); |
2588 | } |
2584 | } |
2589 | |
2585 | |
2590 | if (op->stats.food < 0) |
2586 | if (op->stats.food < 0) |
2591 | { |
2587 | { |
2592 | op->stats.hp += op->stats.food; |
2588 | op->stats.hp += op->stats.food; |
2593 | op->stats.food = 0; |
2589 | op->stats.food = 0; |
2594 | } |
2590 | } |
2595 | |
2591 | |
2596 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2592 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2597 | kill_player (op); |
2593 | kill_player (op); |
… | |
… | |
2650 | { |
2646 | { |
2651 | tmp->name = format ("%s's finger" , &op->name); |
2647 | tmp->name = format ("%s's finger" , &op->name); |
2652 | tmp->name_pl = format ("%s's fingers", &op->name); |
2648 | tmp->name_pl = format ("%s's fingers", &op->name); |
2653 | tmp->msg = format ( |
2649 | tmp->msg = format ( |
2654 | "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", |
2650 | "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", |
2655 | &op->name, op->contr->title, (int) (op->level), op->contr->killer |
2651 | &op->name, op->contr->title, |
|
|
2652 | (int)op->level, |
|
|
2653 | op->contr->killer_name () |
2656 | ); |
2654 | ); |
2657 | tmp->value = 0, tmp->type = 0; |
2655 | tmp->value = 0, tmp->type = 0; |
2658 | tmp->materialname = "organics"; |
2656 | tmp->materialname = "organics"; |
2659 | tmp->insert_at (op, tmp); |
2657 | tmp->insert_at (op, tmp); |
2660 | } |
2658 | } |
… | |
… | |
2668 | INVOKE_PLAYER (DEATH, op->contr); |
2666 | INVOKE_PLAYER (DEATH, op->contr); |
2669 | |
2667 | |
2670 | command_kill_pets (op, 0); |
2668 | command_kill_pets (op, 0); |
2671 | |
2669 | |
2672 | if (op->stats.food < 0) |
2670 | if (op->stats.food < 0) |
2673 | strcpy (op->contr->killer, "starvation"); |
2671 | { |
|
|
2672 | op->contr->killer = archetype::get ("killer_starvation"); |
|
|
2673 | op->contr->killer->destroy (); |
|
|
2674 | } |
2674 | |
2675 | |
2675 | op->contr->play_sound (sound_find ("player_dies")); |
2676 | op->contr->play_sound (sound_find ("player_dies")); |
2676 | |
2677 | |
2677 | /* save the map location for corpse, gravestone */ |
2678 | /* save the map location for corpse, gravestone */ |
2678 | x = op->x; |
2679 | x = op->x; |
… | |
… | |
2787 | lost_a_stat = 1; |
2788 | lost_a_stat = 1; |
2788 | } |
2789 | } |
2789 | } |
2790 | } |
2790 | } |
2791 | } |
2791 | } |
2792 | } |
|
|
2793 | |
2792 | /* If no stat lost, tell the player. */ |
2794 | /* If no stat lost, tell the player. */ |
2793 | if (!lost_a_stat) |
2795 | if (!lost_a_stat) |
2794 | { |
2796 | { |
2795 | /* determine_god() seems to not work sometimes... why is this? |
2797 | /* determine_god() seems to not work sometimes... why is this? |
2796 | Should I be using something else? GD */ |
2798 | Should I be using something else? GD */ |
… | |
… | |
2800 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
2802 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
2801 | else |
2803 | else |
2802 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
2804 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
2803 | } |
2805 | } |
2804 | #else |
2806 | #else |
2805 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
2807 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you from losing yourself completely."); |
2806 | #endif |
2808 | #endif |
2807 | |
2809 | |
2808 | /* Put a gravestone up where the character 'almost' died. List the |
2810 | /* Put a gravestone up where the character 'almost' died. List the |
2809 | * exp loss on the stone. |
2811 | * exp loss on the stone. |
2810 | */ |
2812 | */ |
2811 | tmp = arch_to_object (archetype::find ("gravestone")); |
2813 | tmp = arch_to_object (archetype::find ("gravestone")); |
2812 | sprintf (buf, "%s's gravestone", &op->name); |
2814 | tmp->name = format ("%s's gravestone", &op->name); |
2813 | tmp->name = buf; |
2815 | tmp->name_pl = format ("%s's gravestones", &op->name); |
2814 | sprintf (buf, "%s's gravestones", &op->name); |
|
|
2815 | tmp->name_pl = buf; |
|
|
2816 | sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer); |
2816 | tmp->msg = format ("RIP\nHere rests the hero %s the %s,\nwho was killed\nby %s.\n", &op->name, op->contr->title, op->contr->killer_name ()); |
2817 | tmp->msg = buf; |
|
|
2818 | tmp->x = op->x, tmp->y = op->y; |
2817 | tmp->x = op->x, tmp->y = op->y; |
2819 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2818 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2820 | |
2819 | |
2821 | /**************************************/ |
2820 | /**************************************/ |
2822 | /* */ |
2821 | /* */ |
… | |
… | |
2845 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2844 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2846 | } |
2845 | } |
2847 | |
2846 | |
2848 | cure_disease (op, 0, 0); /* remove any disease */ |
2847 | cure_disease (op, 0, 0); /* remove any disease */ |
2849 | |
2848 | |
|
|
2849 | // remove all spell effects that are active |
|
|
2850 | // to avoid long-term effects such as word-of-recall |
|
|
2851 | for (object *item = op->inv; item; ) |
|
|
2852 | { |
|
|
2853 | object *next = item->below; |
|
|
2854 | |
|
|
2855 | if (item->type == SPELL_EFFECT && item->active) |
|
|
2856 | item->destroy (); |
|
|
2857 | |
|
|
2858 | item = next; |
|
|
2859 | } |
|
|
2860 | |
2850 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2861 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2851 | apply_death_exp_penalty (op); |
2862 | apply_death_exp_penalty (op); |
|
|
2863 | |
2852 | if (op->stats.food < 100) |
2864 | if (op->stats.food < 100) |
2853 | op->stats.food = 900; |
2865 | op->stats.food = 900; |
|
|
2866 | |
2854 | op->stats.hp = op->stats.maxhp; |
2867 | op->stats.hp = op->stats.maxhp; |
2855 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
2868 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
2856 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
2869 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
2857 | |
2870 | |
2858 | /* |
2871 | /* |
… | |
… | |
3079 | * spot (surrounded by clear terrain in broad daylight). -b.t. |
3092 | * spot (surrounded by clear terrain in broad daylight). -b.t. |
3080 | */ |
3093 | */ |
3081 | void |
3094 | void |
3082 | do_hidden_move (object *op) |
3095 | do_hidden_move (object *op) |
3083 | { |
3096 | { |
3084 | int hide = 0, num = random_roll (0, 19, op, PREFER_LOW); |
3097 | int hide = 0; |
3085 | object *skop; |
|
|
3086 | |
3098 | |
3087 | if (!op || !op->map) |
3099 | if (!op || !op->map) |
3088 | return; |
3100 | return; |
3089 | |
3101 | |
3090 | skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); |
3102 | object *skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); |
|
|
3103 | int num = random_roll (0, 19, op, PREFER_LOW); |
3091 | |
3104 | |
3092 | /* its *extremely* hard to run and sneak/hide at the same time! */ |
3105 | /* its *extremely* hard to run and sneak/hide at the same time! */ |
3093 | if (op->type == PLAYER && op->contr->run_on) |
3106 | if (op->type == PLAYER && op->contr->run_on) |
3094 | if (!skop || num >= skop->level) |
3107 | if (!skop || num >= skop->level) |
3095 | { |
3108 | { |
… | |
… | |
3105 | num -= hide; |
3118 | num -= hide; |
3106 | |
3119 | |
3107 | if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) |
3120 | if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) |
3108 | { |
3121 | { |
3109 | make_visible (op); |
3122 | make_visible (op); |
|
|
3123 | |
3110 | if (op->type == PLAYER) |
3124 | if (op->type == PLAYER) |
3111 | new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); |
3125 | new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); |
3112 | } |
3126 | } |
3113 | else if (op->type == PLAYER && skop) |
3127 | else if (op->type == PLAYER && skop) |
3114 | change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); |
3128 | change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); |
… | |
… | |
3455 | else |
3469 | else |
3456 | { |
3470 | { |
3457 | /* generate misc. treasure */ |
3471 | /* generate misc. treasure */ |
3458 | tmp = arch_to_object (tr->item); |
3472 | tmp = arch_to_object (tr->item); |
3459 | new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); |
3473 | new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); |
3460 | tmp = insert_ob_in_ob (tmp, who); |
3474 | who->insert (tmp); |
3461 | if (who->type == PLAYER) |
|
|
3462 | esrv_send_item (who, tmp); |
|
|
3463 | } |
3475 | } |
3464 | } |
3476 | } |
3465 | |
3477 | |
3466 | /** |
3478 | /** |
3467 | * Unready an object for a player. This function does nothing if the object was |
3479 | * Unready an object for a player. This function does nothing if the object was |