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 |
… | |
… | |
215 | |
215 | |
216 | /* make sure he's a player -- needed because of class change. */ |
216 | /* make sure he's a player -- needed because of class change. */ |
217 | ob->type = PLAYER; // we are paranoid |
217 | ob->type = PLAYER; // we are paranoid |
218 | ob->race = ob->arch->race; |
218 | ob->race = ob->arch->race; |
219 | |
219 | |
220 | ob->carrying = sum_weight (ob); |
220 | ob->update_weight (); |
221 | link_player_skills (ob); |
221 | link_player_skills (ob); |
222 | |
222 | |
223 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
223 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
224 | |
224 | |
225 | assign (title, ob->arch->object::name); |
225 | assign (title, ob->arch->object::name); |
… | |
… | |
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 | |
… | |
… | |
321 | combat_ob = op; |
321 | combat_ob = op; |
322 | break; |
322 | break; |
323 | } |
323 | } |
324 | |
324 | |
325 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
325 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
326 | ob->deactivate (); // change_Weapon activates, fix this better |
326 | ob->deactivate (); // change_weapon activates, fix this better |
327 | } |
327 | } |
328 | |
328 | |
329 | void |
329 | void |
330 | player::set_observe (object *op) |
330 | player::set_observe (object *op) |
331 | { |
331 | { |
… | |
… | |
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 | |
… | |
… | |
864 | |
864 | |
865 | ob->contr->ns->state = ST_PLAYING; |
865 | ob->contr->ns->state = ST_PLAYING; |
866 | |
866 | |
867 | if (ob->msg) |
867 | if (ob->msg) |
868 | ob->msg = 0; |
868 | ob->msg = 0; |
869 | |
|
|
870 | /* We create this now because some of the unique maps will need it |
|
|
871 | * to save here. |
|
|
872 | */ |
|
|
873 | { |
|
|
874 | char buf[MAX_BUF]; |
|
|
875 | sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &ob->name); |
|
|
876 | make_path_to_file (buf); |
|
|
877 | } |
|
|
878 | |
869 | |
879 | start_info (ob); |
870 | start_info (ob); |
880 | CLEAR_FLAG (ob, FLAG_WIZ); |
871 | CLEAR_FLAG (ob, FLAG_WIZ); |
881 | give_initial_items (ob, ob->randomitems); |
872 | give_initial_items (ob, ob->randomitems); |
882 | link_player_skills (ob); |
873 | link_player_skills (ob); |
… | |
… | |
885 | |
876 | |
886 | /* This moves the player to a different start map, if there |
877 | /* This moves the player to a different start map, if there |
887 | * is one for this race |
878 | * is one for this race |
888 | */ |
879 | */ |
889 | if (*first_map_ext_path) |
880 | if (*first_map_ext_path) |
890 | { |
881 | ob->player_goto (format ("%s/%s", &first_map_ext_path, &ob->arch->archname), ob->x, ob->y); |
891 | object *tmp; |
|
|
892 | char mapname[MAX_BUF]; |
|
|
893 | |
|
|
894 | snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &ob->arch->archname); |
|
|
895 | tmp = object::create (); |
|
|
896 | EXIT_PATH (tmp) = mapname; |
|
|
897 | EXIT_X (tmp) = ob->x; |
|
|
898 | EXIT_Y (tmp) = ob->y; |
|
|
899 | ob->enter_exit (tmp); /* we don't really care if it succeeded; |
|
|
900 | * if the map isn't there, then stay on the |
|
|
901 | * default initial map */ |
|
|
902 | tmp->destroy (); |
|
|
903 | } |
|
|
904 | else |
882 | else |
905 | LOG (llevDebug, "first_map_ext_path not set\n"); |
883 | LOG (llevDebug, "first_map_ext_path not set\n"); |
906 | } |
884 | } |
907 | |
885 | |
908 | void |
886 | void |
… | |
… | |
1405 | } |
1383 | } |
1406 | } |
1384 | } |
1407 | else if (arrow->type == ARROW && arrow->race == type) |
1385 | else if (arrow->type == ARROW && arrow->race == type) |
1408 | { |
1386 | { |
1409 | /* allways prefer assasination/slaying */ |
1387 | /* allways prefer assasination/slaying */ |
1410 | if (target->race != NULL && arrow->slaying != NULL && strstr (arrow->slaying, target->race)) |
1388 | if (target->race && arrow->slaying && strstr (arrow->slaying, target->race)) |
1411 | { |
1389 | { |
1412 | if (arrow->attacktype & AT_DEATH) |
1390 | if (arrow->attacktype & AT_DEATH) |
1413 | { |
1391 | { |
1414 | *better = 100; |
1392 | *better = 100; |
1415 | return arrow; |
1393 | return arrow; |
… | |
… | |
1443 | betterby = 1 + arrow->magic + arrow->stats.dam; |
1421 | betterby = 1 + arrow->magic + arrow->stats.dam; |
1444 | } |
1422 | } |
1445 | } |
1423 | } |
1446 | } |
1424 | } |
1447 | } |
1425 | } |
|
|
1426 | |
1448 | if (tmp == NULL && arrow == NULL) |
1427 | if (tmp == NULL && arrow == NULL) |
1449 | return find_arrow (op, type); |
1428 | return find_arrow (op, type); |
1450 | |
1429 | |
1451 | *better = betterby; |
1430 | *better = betterby; |
1452 | return tmp; |
1431 | return tmp; |
… | |
… | |
1603 | arrow->destroy (); |
1582 | arrow->destroy (); |
1604 | return 0; |
1583 | return 0; |
1605 | } |
1584 | } |
1606 | |
1585 | |
1607 | left = arrow; /* these are arrows left to the player */ |
1586 | left = arrow; /* these are arrows left to the player */ |
1608 | arrow = get_split_ob (arrow, 1); |
1587 | arrow = arrow->split (); |
1609 | if (!arrow) |
1588 | if (!arrow) |
1610 | { |
1589 | { |
1611 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1590 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1612 | return 0; |
1591 | return 0; |
1613 | } |
1592 | } |
… | |
… | |
1680 | op->play_sound (sound_find ("fire_arrow")); |
1659 | op->play_sound (sound_find ("fire_arrow")); |
1681 | m->insert (arrow, sx, sy, op); |
1660 | m->insert (arrow, sx, sy, op); |
1682 | |
1661 | |
1683 | if (!arrow->destroyed ()) |
1662 | if (!arrow->destroyed ()) |
1684 | move_arrow (arrow); |
1663 | move_arrow (arrow); |
1685 | |
|
|
1686 | if (op->type == PLAYER) |
|
|
1687 | { |
|
|
1688 | if (left->destroyed ()) |
|
|
1689 | esrv_del_item (op->contr, left->count); |
|
|
1690 | else |
|
|
1691 | esrv_send_item (op, left); |
|
|
1692 | } |
|
|
1693 | |
1664 | |
1694 | return 1; |
1665 | return 1; |
1695 | } |
1666 | } |
1696 | |
1667 | |
1697 | /* Special fire code for players - this takes into |
1668 | /* Special fire code for players - this takes into |
… | |
… | |
1771 | return; |
1742 | return; |
1772 | } |
1743 | } |
1773 | } |
1744 | } |
1774 | else if (item->type == ROD || item->type == HORN) |
1745 | else if (item->type == ROD || item->type == HORN) |
1775 | { |
1746 | { |
1776 | if (item->stats.hp < MAX (item->inv->stats.sp, item->inv->stats.grace)) |
1747 | sint16 spell_sp = MAX (item->inv->stats.sp, item->inv->stats.grace); |
|
|
1748 | |
|
|
1749 | // using the maximum of the rods charge allows at least one spell cast |
|
|
1750 | // for a rod or horn, this fixes some broken rods. |
|
|
1751 | if (item->stats.hp < MIN (spell_sp, item->stats.maxhp)) |
1777 | { |
1752 | { |
1778 | op->contr->play_sound (sound_find ("wand_poof")); |
1753 | op->contr->play_sound (sound_find ("wand_poof")); |
1779 | |
1754 | |
1780 | if (item->type == ROD) |
1755 | if (item->type == ROD) |
1781 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); |
1756 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); |
… | |
… | |
1800 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1775 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1801 | item->face = item->arch->face; |
1776 | item->face = item->arch->face; |
1802 | item->set_speed (0); |
1777 | item->set_speed (0); |
1803 | } |
1778 | } |
1804 | |
1779 | |
1805 | if ((tmp = item->in_player ())) |
1780 | if (object *pl = item->visible_to ()) |
1806 | esrv_update_item (UPD_ANIM, tmp, item); |
1781 | esrv_update_item (UPD_ANIM, pl, item); |
1807 | } |
1782 | } |
1808 | } |
1783 | } |
1809 | else if (item->type == ROD || item->type == HORN) |
1784 | else if (item->type == ROD || item->type == HORN) |
1810 | drain_rod_charge (item); |
1785 | drain_rod_charge (item); |
1811 | } |
1786 | } |
… | |
… | |
1987 | op->statusmsg (format ("You open the door with the %s", query_short_name (key)), NDI_BROWN); |
1962 | op->statusmsg (format ("You open the door with the %s", query_short_name (key)), NDI_BROWN); |
1988 | remove_door2 (door); /* remove door without violence ;-) */ |
1963 | remove_door2 (door); /* remove door without violence ;-) */ |
1989 | } |
1964 | } |
1990 | |
1965 | |
1991 | /* Do this after we print the message */ |
1966 | /* Do this after we print the message */ |
1992 | decrease_ob (key); /* Use up one of the keys */ |
1967 | key->decrease (); /* Use up one of the keys */ |
1993 | /* Need to update the weight the container the key was in */ |
|
|
1994 | if (container != op) |
|
|
1995 | esrv_update_item (UPD_WEIGHT, op, container); |
|
|
1996 | |
1968 | |
1997 | return 1; /* Nothing more to do below */ |
1969 | return 1; /* Nothing more to do below */ |
1998 | } |
1970 | } |
1999 | else if (door->type == LOCKED_DOOR) |
1971 | else if (door->type == LOCKED_DOOR) |
2000 | { |
1972 | { |
… | |
… | |
2279 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2251 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2280 | { |
2252 | { |
2281 | op->play_sound (sound_find ("ob_evaporate")); |
2253 | op->play_sound (sound_find ("ob_evaporate")); |
2282 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2254 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2283 | |
2255 | |
2284 | if (op->contr) |
|
|
2285 | esrv_del_item (op->contr, tmp->count); |
|
|
2286 | |
|
|
2287 | tmp->destroy (); |
2256 | tmp->destroy (); |
2288 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2257 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2289 | |
2258 | |
2290 | if (op->stats.hp < 0) |
2259 | if (op->stats.hp < 0) |
2291 | op->stats.hp = op->stats.maxhp; |
2260 | op->stats.hp = op->stats.maxhp; |
… | |
… | |
2303 | return 0; |
2272 | return 0; |
2304 | } |
2273 | } |
2305 | |
2274 | |
2306 | /* This goes throws the inventory and removes unpaid objects, and puts them |
2275 | /* This goes throws the inventory and removes unpaid objects, and puts them |
2307 | * back in the map (location and map determined by values of env). This |
2276 | * back in the map (location and map determined by values of env). This |
2308 | * function will descend into containers. op is the object to start the search |
2277 | * function will descend into containers. op is the object to start the search |
2309 | * from. |
2278 | * from. |
2310 | */ |
2279 | */ |
2311 | static void |
2280 | static void |
2312 | drop_unpaid_items (object *op, object *env) |
2281 | drop_unpaid_items (object *op, object *env) |
2313 | { |
2282 | { |
2314 | while (op) |
2283 | while (op) |
2315 | { |
2284 | { |
2316 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2285 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2317 | |
2286 | |
2318 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2287 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2319 | { |
|
|
2320 | if (env->type == PLAYER) |
|
|
2321 | esrv_del_item (env->contr, op->count); |
|
|
2322 | |
|
|
2323 | op->insert_at (env); |
2288 | op->insert_at (env); |
2324 | } |
|
|
2325 | else if (op->inv) |
2289 | else if (op->inv) |
2326 | drop_unpaid_items (op->inv, env); |
2290 | drop_unpaid_items (op->inv, env); |
2327 | |
2291 | |
2328 | op = next; |
2292 | op = next; |
2329 | } |
2293 | } |
… | |
… | |
2341 | * Moved from apply.c to player.c - player.c is what |
2305 | * Moved from apply.c to player.c - player.c is what |
2342 | * actually uses this function. player.c may not be quite the |
2306 | * actually uses this function. player.c may not be quite the |
2343 | * best, a misc file for object actions is probably better, |
2307 | * best, a misc file for object actions is probably better, |
2344 | * but there isn't one in the server directory. |
2308 | * but there isn't one in the server directory. |
2345 | */ |
2309 | */ |
2346 | char * |
2310 | const char * |
2347 | gravestone_text (object *op) |
2311 | gravestone_text (object *op) |
2348 | { |
2312 | { |
2349 | static char buf2[MAX_BUF]; |
2313 | static dynbuf_text buf; |
2350 | char buf[MAX_BUF]; |
|
|
2351 | time_t now = time (NULL); |
|
|
2352 | |
2314 | |
2353 | strcpy (buf2, " R.I.P.\n\n"); |
2315 | buf << "---- R.I.P. ----\n\n"; |
|
|
2316 | op->name; |
|
|
2317 | |
2354 | if (op->type == PLAYER) |
2318 | if (op->type == PLAYER) |
2355 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2319 | buf << " the " << op->contr->title; |
2356 | else |
|
|
2357 | sprintf (buf, "%s\n", &op->name); |
|
|
2358 | |
2320 | |
2359 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2321 | buf << "\n\n"; |
2360 | strcat (buf2, buf); |
2322 | |
|
|
2323 | buf << "who was level "; |
|
|
2324 | buf << (sint32)op->level << "\n\n" // OO breakdown |
|
|
2325 | << " when " << (op->contr ? "killed" : "died") << "\n\n"; |
|
|
2326 | |
2361 | if (op->type == PLAYER) |
2327 | if (op->type == PLAYER) |
2362 | sprintf (buf, "who was in level %d when killed\n", op->level); |
2328 | buf << "by " << op->contr->killer_name () << ".\n\n"; |
2363 | else |
|
|
2364 | sprintf (buf, "who was in level %d when died.\n\n", op->level); |
|
|
2365 | |
2329 | |
2366 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
|
|
2367 | strcat (buf2, buf); |
|
|
2368 | if (op->type == PLAYER) |
|
|
2369 | { |
2330 | { |
2370 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2331 | static char buf2[128]; |
2371 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2332 | time_t now = time (NULL); |
2372 | strcat (buf2, buf); |
|
|
2373 | } |
|
|
2374 | |
|
|
2375 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2333 | strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now)); |
2376 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2334 | buf << buf2; |
2377 | strcat (buf2, buf); |
2335 | } |
2378 | |
2336 | |
2379 | return buf2; |
2337 | return buf; |
2380 | } |
2338 | } |
2381 | |
2339 | |
2382 | void |
2340 | void |
2383 | do_some_living (object *op) |
2341 | do_some_living (object *op) |
2384 | { |
2342 | { |
… | |
… | |
2565 | op->stats.food--; |
2523 | op->stats.food--; |
2566 | } |
2524 | } |
2567 | |
2525 | |
2568 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2526 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2569 | { |
2527 | { |
2570 | object *tmp, *flesh = 0; |
2528 | object *flesh = 0; |
2571 | |
2529 | |
2572 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2530 | for_inv_removable (op, tmp) |
2573 | { |
2531 | { |
2574 | if (!QUERY_FLAG (tmp, FLAG_UNPAID)) |
2532 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
|
|
2533 | continue; |
|
|
2534 | |
|
|
2535 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2575 | { |
2536 | { |
2576 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2537 | op->statusmsg ("You blindly grab for a bite of food. " |
2577 | { |
2538 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2578 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
|
|
2579 | manual_apply (op, tmp, 0); |
2539 | manual_apply (op, tmp, 0); |
|
|
2540 | |
2580 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2541 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2581 | break; |
2542 | break; |
2582 | } |
2543 | } |
2583 | else if (tmp->type == FLESH) |
2544 | else if (tmp->type == FLESH) |
2584 | flesh = tmp; |
2545 | flesh = tmp; |
2585 | } /* End if paid for object */ |
2546 | } |
2586 | } /* end of for loop */ |
|
|
2587 | |
2547 | |
2588 | /* If player is still starving, it means they don't have any food, so |
2548 | /* If player is still starving, it means they don't have any food, so |
2589 | * eat flesh instead. |
2549 | * eat flesh instead. |
2590 | */ |
2550 | */ |
2591 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2551 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2592 | { |
2552 | { |
2593 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2553 | op->statusmsg ("You blindly grab for a bite of food. " |
|
|
2554 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2594 | manual_apply (op, flesh, 0); |
2555 | manual_apply (op, flesh, 0); |
2595 | } |
2556 | } |
|
|
2557 | |
|
|
2558 | // If player is still starving, alert him! |
|
|
2559 | if (op->stats.food < 0) |
|
|
2560 | op->failmsg ("You are starving! " |
|
|
2561 | "H<Eat some food to increase your food and prevent you from an untimely death.>"); |
2596 | } |
2562 | } |
2597 | |
2563 | |
2598 | if (op->stats.food < 0) |
2564 | if (op->stats.food < 0) |
2599 | { |
2565 | { |
2600 | op->stats.hp += op->stats.food; |
2566 | op->stats.hp += op->stats.food; |
2601 | op->stats.food = 0; |
2567 | op->stats.food = 0; |
2602 | } |
2568 | } |
2603 | |
2569 | |
2604 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2570 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2605 | kill_player (op); |
2571 | kill_player (op); |
… | |
… | |
2658 | { |
2624 | { |
2659 | tmp->name = format ("%s's finger" , &op->name); |
2625 | tmp->name = format ("%s's finger" , &op->name); |
2660 | tmp->name_pl = format ("%s's fingers", &op->name); |
2626 | tmp->name_pl = format ("%s's fingers", &op->name); |
2661 | tmp->msg = format ( |
2627 | tmp->msg = format ( |
2662 | "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", |
2628 | "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", |
2663 | &op->name, op->contr->title, (int) (op->level), op->contr->killer |
2629 | &op->name, op->contr->title, |
|
|
2630 | (int)op->level, |
|
|
2631 | op->contr->killer_name () |
2664 | ); |
2632 | ); |
2665 | tmp->value = 0, tmp->type = 0; |
2633 | tmp->value = 0, tmp->type = 0; |
2666 | tmp->materialname = "organics"; |
2634 | tmp->materialname = "organics"; |
2667 | tmp->insert_at (op, tmp); |
2635 | tmp->insert_at (op, tmp); |
2668 | } |
2636 | } |
… | |
… | |
2676 | INVOKE_PLAYER (DEATH, op->contr); |
2644 | INVOKE_PLAYER (DEATH, op->contr); |
2677 | |
2645 | |
2678 | command_kill_pets (op, 0); |
2646 | command_kill_pets (op, 0); |
2679 | |
2647 | |
2680 | if (op->stats.food < 0) |
2648 | if (op->stats.food < 0) |
2681 | strcpy (op->contr->killer, "starvation"); |
2649 | { |
|
|
2650 | op->contr->killer = archetype::get ("killer_starvation"); |
|
|
2651 | op->contr->killer->destroy (); |
|
|
2652 | } |
2682 | |
2653 | |
2683 | op->contr->play_sound (sound_find ("player_dies")); |
2654 | op->contr->play_sound (sound_find ("player_dies")); |
2684 | |
2655 | |
2685 | /* save the map location for corpse, gravestone */ |
2656 | /* save the map location for corpse, gravestone */ |
2686 | x = op->x; |
2657 | x = op->x; |
… | |
… | |
2795 | lost_a_stat = 1; |
2766 | lost_a_stat = 1; |
2796 | } |
2767 | } |
2797 | } |
2768 | } |
2798 | } |
2769 | } |
2799 | } |
2770 | } |
|
|
2771 | |
2800 | /* If no stat lost, tell the player. */ |
2772 | /* If no stat lost, tell the player. */ |
2801 | if (!lost_a_stat) |
2773 | if (!lost_a_stat) |
2802 | { |
2774 | { |
2803 | /* determine_god() seems to not work sometimes... why is this? |
2775 | /* determine_god() seems to not work sometimes... why is this? |
2804 | Should I be using something else? GD */ |
2776 | Should I be using something else? GD */ |
… | |
… | |
2808 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
2780 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
2809 | else |
2781 | else |
2810 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
2782 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
2811 | } |
2783 | } |
2812 | #else |
2784 | #else |
2813 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
2785 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you from losing yourself completely."); |
2814 | #endif |
2786 | #endif |
2815 | |
2787 | |
2816 | /* Put a gravestone up where the character 'almost' died. List the |
2788 | /* Put a gravestone up where the character 'almost' died. List the |
2817 | * exp loss on the stone. |
2789 | * exp loss on the stone. |
2818 | */ |
2790 | */ |
2819 | tmp = arch_to_object (archetype::find ("gravestone")); |
2791 | tmp = arch_to_object (archetype::find ("gravestone")); |
2820 | sprintf (buf, "%s's gravestone", &op->name); |
2792 | tmp->name = format ("%s's gravestone", &op->name); |
2821 | tmp->name = buf; |
2793 | tmp->name_pl = format ("%s's gravestones", &op->name); |
2822 | sprintf (buf, "%s's gravestones", &op->name); |
|
|
2823 | tmp->name_pl = buf; |
|
|
2824 | 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); |
2794 | 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 ()); |
2825 | tmp->msg = buf; |
|
|
2826 | tmp->x = op->x, tmp->y = op->y; |
2795 | tmp->x = op->x, tmp->y = op->y; |
2827 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2796 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2828 | |
2797 | |
2829 | /**************************************/ |
2798 | /**************************************/ |
2830 | /* */ |
2799 | /* */ |
… | |
… | |
2853 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2822 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2854 | } |
2823 | } |
2855 | |
2824 | |
2856 | cure_disease (op, 0, 0); /* remove any disease */ |
2825 | cure_disease (op, 0, 0); /* remove any disease */ |
2857 | |
2826 | |
|
|
2827 | // remove all spell effects that are active |
|
|
2828 | // to avoid long-term effects such as word-of-recall |
|
|
2829 | for (object *item = op->inv; item; ) |
|
|
2830 | { |
|
|
2831 | object *next = item->below; |
|
|
2832 | |
|
|
2833 | if (item->type == SPELL_EFFECT && item->active) |
|
|
2834 | item->destroy (); |
|
|
2835 | |
|
|
2836 | item = next; |
|
|
2837 | } |
|
|
2838 | |
2858 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2839 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2859 | apply_death_exp_penalty (op); |
2840 | apply_death_exp_penalty (op); |
|
|
2841 | |
2860 | if (op->stats.food < 100) |
2842 | if (op->stats.food < 100) |
2861 | op->stats.food = 900; |
2843 | op->stats.food = 900; |
|
|
2844 | |
2862 | op->stats.hp = op->stats.maxhp; |
2845 | op->stats.hp = op->stats.maxhp; |
2863 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
2846 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
2864 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
2847 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
2865 | |
2848 | |
2866 | /* |
2849 | /* |
… | |
… | |
2934 | |
2917 | |
2935 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) |
2918 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) |
2936 | { |
2919 | { |
2937 | if (tmp->nrof > 1) |
2920 | if (tmp->nrof > 1) |
2938 | { |
2921 | { |
2939 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
2922 | tmp->decrease (rndm (1, tmp->nrof - 1)); |
2940 | tmp2->destroy (); |
|
|
2941 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2923 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2942 | } |
2924 | } |
2943 | else |
2925 | else |
2944 | tmp->destroy (); |
2926 | tmp->destroy (); |
2945 | } |
2927 | } |
… | |
… | |
2956 | void |
2938 | void |
2957 | fix_weight (void) |
2939 | fix_weight (void) |
2958 | { |
2940 | { |
2959 | for_all_players (pl) |
2941 | for_all_players (pl) |
2960 | { |
2942 | { |
2961 | int old = pl->ob->carrying, sum = sum_weight (pl->ob); |
2943 | sint32 old = pl->ob->carrying; |
2962 | |
2944 | |
2963 | if (old == sum) |
2945 | pl->ob->update_weight (); |
2964 | continue; |
2946 | |
|
|
2947 | if (old != pl->ob->carrying) |
|
|
2948 | { |
2965 | pl->ob->update_stats (); |
2949 | pl->ob->update_stats (); |
2966 | LOG (llevDebug, "Fixed inventory in %s (%d -> %d)\n", &pl->ob->name, old, sum); |
2950 | LOG (llevDebug, "Fixed inventory in %s (%d -> %d)\n", &pl->ob->name, (int)old, (int)pl->ob->carrying); |
|
|
2951 | } |
2967 | } |
2952 | } |
2968 | } |
2953 | } |
2969 | |
2954 | |
2970 | void |
2955 | void |
2971 | fix_luck (void) |
2956 | fix_luck (void) |
… | |
… | |
3085 | * spot (surrounded by clear terrain in broad daylight). -b.t. |
3070 | * spot (surrounded by clear terrain in broad daylight). -b.t. |
3086 | */ |
3071 | */ |
3087 | void |
3072 | void |
3088 | do_hidden_move (object *op) |
3073 | do_hidden_move (object *op) |
3089 | { |
3074 | { |
3090 | int hide = 0, num = random_roll (0, 19, op, PREFER_LOW); |
3075 | int hide = 0; |
3091 | object *skop; |
|
|
3092 | |
3076 | |
3093 | if (!op || !op->map) |
3077 | if (!op || !op->map) |
3094 | return; |
3078 | return; |
3095 | |
3079 | |
3096 | skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); |
3080 | object *skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); |
|
|
3081 | int num = random_roll (0, 19, op, PREFER_LOW); |
3097 | |
3082 | |
3098 | /* its *extremely* hard to run and sneak/hide at the same time! */ |
3083 | /* its *extremely* hard to run and sneak/hide at the same time! */ |
3099 | if (op->type == PLAYER && op->contr->run_on) |
3084 | if (op->type == PLAYER && op->contr->run_on) |
3100 | if (!skop || num >= skop->level) |
3085 | if (!skop || num >= skop->level) |
3101 | { |
3086 | { |
… | |
… | |
3111 | num -= hide; |
3096 | num -= hide; |
3112 | |
3097 | |
3113 | if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) |
3098 | if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) |
3114 | { |
3099 | { |
3115 | make_visible (op); |
3100 | make_visible (op); |
|
|
3101 | |
3116 | if (op->type == PLAYER) |
3102 | if (op->type == PLAYER) |
3117 | new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); |
3103 | new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); |
3118 | } |
3104 | } |
3119 | else if (op->type == PLAYER && skop) |
3105 | else if (op->type == PLAYER && skop) |
3120 | change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); |
3106 | change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); |
… | |
… | |
3461 | else |
3447 | else |
3462 | { |
3448 | { |
3463 | /* generate misc. treasure */ |
3449 | /* generate misc. treasure */ |
3464 | tmp = arch_to_object (tr->item); |
3450 | tmp = arch_to_object (tr->item); |
3465 | new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); |
3451 | new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); |
3466 | tmp = insert_ob_in_ob (tmp, who); |
3452 | who->insert (tmp); |
3467 | if (who->type == PLAYER) |
|
|
3468 | esrv_send_item (who, tmp); |
|
|
3469 | } |
3453 | } |
3470 | } |
3454 | } |
3471 | |
3455 | |
3472 | /** |
3456 | /** |
3473 | * Unready an object for a player. This function does nothing if the object was |
3457 | * Unready an object for a player. This function does nothing if the object was |