ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/player.C
(Generate patch)

Comparing deliantra/server/server/player.C (file contents):
Revision 1.187 by root, Mon Apr 21 07:07:36 2008 UTC vs.
Revision 1.205 by root, Thu Sep 25 04:09:57 2008 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 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
122 continue; 122 continue;
123 123
124 if (*buf == '%') 124 if (*buf == '%')
125 { /* send one news */ 125 { /* send one news */
126 if (size > 0) 126 if (size > 0)
127 draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", (char *)"%s\n%s", subject, news); /*send previously read news */ 127 draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op,
128 MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS,
129 "INFORMATION: %s\n%s", (char *)"%s\n%s",
130 subject, news); /*send previously read news */
128 131
129 strcpy (subject, buf + 1); 132 strcpy (subject, buf + 1);
130 strip_endline (subject); 133 strip_endline (subject);
131 size = 0; 134 size = 0;
132 news[0] = '\0'; 135 news[0] = '\0';
216 /* make sure he's a player -- needed because of class change. */ 219 /* make sure he's a player -- needed because of class change. */
217 ob->type = PLAYER; // we are paranoid 220 ob->type = PLAYER; // we are paranoid
218 ob->race = ob->arch->race; 221 ob->race = ob->arch->race;
219 222
220 ob->update_weight (); 223 ob->update_weight ();
221 link_player_skills (ob); 224 link_skills ();
222 225
223 CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); 226 CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER);
224 227
225 assign (title, ob->arch->object::name); 228 assign (title, ob->arch->object::name);
226 229
239 set_dragon_name (ob, abil, skin); 242 set_dragon_name (ob, abil, skin);
240 } 243 }
241 244
242 new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); 245 new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!");
243 246
244 esrv_new_player (this, ob->weight + ob->carrying); 247 esrv_new_player (this);
245 248
246 ob->update_stats (); 249 ob->update_stats ();
247 250
248 ns->floorbox_update (); 251 ns->floorbox_update ();
249 esrv_send_inventory (ob, ob); 252 esrv_send_inventory (ob, ob);
291player::set_object (object *op) 294player::set_object (object *op)
292{ 295{
293 ob = observe = op; 296 ob = observe = op;
294 ob->contr = this; /* this aren't yet in archetype */ 297 ob->contr = this; /* this aren't yet in archetype */
295 298
296 ob->speed = 1.0f; 299 ob->speed = 1.0f;
297 ob->speed_left = 0.5f; 300 ob->speed_left = 0.5f;
298 301
299 ob->direction = 5; /* So player faces south */ 302 ob->direction = 5; /* So player faces south */
300 303
301 ob->flag [FLAG_READY_WEAPON] = false; 304 ob->flag [FLAG_READY_WEAPON] = false;
302 ob->flag [FLAG_READY_SKILL] = false; 305 ob->flag [FLAG_READY_SKILL] = false;
303 ob->flag [FLAG_READY_BOW] = false; 306 ob->flag [FLAG_READY_BOW] = false;
304 307
321 combat_ob = op; 324 combat_ob = op;
322 break; 325 break;
323 } 326 }
324 327
325 ob->change_weapon (combat_ob ? combat_ob : ranged_ob); 328 ob->change_weapon (combat_ob ? combat_ob : ranged_ob);
326 ob->deactivate (); // change_Weapon activates, fix this better 329 ob->deactivate (); // change_weapon activates, fix this better
327} 330}
328 331
329void 332void
330player::set_observe (object *op) 333player::set_observe (object *op)
331{ 334{
345 savebed_map = first_map_path; /* Init. respawn position */ 348 savebed_map = first_map_path; /* Init. respawn position */
346 349
347 gen_sp_armour = 10; 350 gen_sp_armour = 10;
348 bowtype = bow_normal; 351 bowtype = bow_normal;
349 petmode = pet_normal; 352 petmode = pet_normal;
350 listening = 10;
351 usekeys = containers; 353 usekeys = containers;
352 peaceful = 1; /* default peaceful */ 354 peaceful = 1; /* default peaceful */
353 do_los = 1; 355 do_los = 1;
354 356
355 weapon_sp = 1.0f; 357 weapon_sp = 1.0f;
726 else /* lock all 'normal items by default */ 728 else /* lock all 'normal items by default */
727 SET_FLAG (op, FLAG_INV_LOCKED); 729 SET_FLAG (op, FLAG_INV_LOCKED);
728 } /* for loop of objects in player inv */ 730 } /* for loop of objects in player inv */
729 731
730 /* Need to set up the skill pointers */ 732 /* Need to set up the skill pointers */
731 link_player_skills (pl); 733 pl->contr->link_skills ();
732} 734}
733 735
734void 736void
735get_party_password (object *op, partylist *party) 737get_party_password (object *op, partylist *party)
736{ 738{
851 */ 853 */
852void 854void
853player::chargen_race_done () 855player::chargen_race_done ()
854{ 856{
855 /* this must before then initial items are given */ 857 /* this must before then initial items are given */
856 esrv_new_player (ob->contr, ob->weight + ob->carrying); 858 esrv_new_player (ob->contr);
857 859
858 treasurelist *tl = treasurelist::find ("starting_wealth"); 860 treasurelist *tl = treasurelist::find ("starting_wealth");
859 if (tl) 861 if (tl)
860 create_treasure (tl, ob, 0, 0, 0); 862 create_treasure (tl, ob, 0, 0, 0);
861 863
865 ob->contr->ns->state = ST_PLAYING; 867 ob->contr->ns->state = ST_PLAYING;
866 868
867 if (ob->msg) 869 if (ob->msg)
868 ob->msg = 0; 870 ob->msg = 0;
869 871
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
879 start_info (ob); 872 start_info (ob);
880 CLEAR_FLAG (ob, FLAG_WIZ); 873 CLEAR_FLAG (ob, FLAG_WIZ);
881 give_initial_items (ob, ob->randomitems); 874 give_initial_items (ob, ob->randomitems);
882 link_player_skills (ob);
883 esrv_send_inventory (ob, ob); 875 esrv_send_inventory (ob, ob);
884 ob->update_stats (); 876 ob->update_stats ();
885 877
886 /* This moves the player to a different start map, if there 878 /* This moves the player to a different start map, if there
887 * is one for this race 879 * is one for this race
888 */ 880 */
889 if (*first_map_ext_path) 881 if (*first_map_ext_path)
890 { 882 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 883 else
905 LOG (llevDebug, "first_map_ext_path not set\n"); 884 LOG (llevDebug, "first_map_ext_path not set\n");
906} 885}
907 886
908void 887void
1327 if (op->contr->mode & PU_RATIO) 1306 if (op->contr->mode & PU_RATIO)
1328 { 1307 {
1329 /* use value density to decide what else to grab */ 1308 /* use value density to decide what else to grab */
1330 /* >=7 was >= op->contr->mode */ 1309 /* >=7 was >= op->contr->mode */
1331 /* >=7 is the old standard setting. Now we take the last 4 bits 1310 /* >=7 is the old standard setting. Now we take the last 4 bits
1332 * and multiply them by 5, giving 0..15*5== 5..75 */ 1311 */
1333 wvratio = (op->contr->mode & PU_RATIO) * 5; 1312 wvratio = op->contr->mode & PU_RATIO;
1334 if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio) 1313 if (1000 * query_cost (tmp, op, F_TRUE) / tmp->total_weight () >= wvratio * 100)
1335 { 1314 {
1336 CHK_PICK_PICKUP; 1315 CHK_PICK_PICKUP;
1337#if 0 1316#if 0
1338 fprintf (stderr, "HIGH WEIGHT/VALUE ["); 1317 fprintf (stderr, "HIGH WEIGHT/VALUE [");
1339 if (tmp->name != NULL) 1318 if (tmp->name != NULL)
1405 } 1384 }
1406 } 1385 }
1407 else if (arrow->type == ARROW && arrow->race == type) 1386 else if (arrow->type == ARROW && arrow->race == type)
1408 { 1387 {
1409 /* allways prefer assasination/slaying */ 1388 /* allways prefer assasination/slaying */
1410 if (target->race != NULL && arrow->slaying != NULL && strstr (arrow->slaying, target->race)) 1389 if (target->race && arrow->slaying && strstr (arrow->slaying, target->race))
1411 { 1390 {
1412 if (arrow->attacktype & AT_DEATH) 1391 if (arrow->attacktype & AT_DEATH)
1413 { 1392 {
1414 *better = 100; 1393 *better = 100;
1415 return arrow; 1394 return arrow;
1443 betterby = 1 + arrow->magic + arrow->stats.dam; 1422 betterby = 1 + arrow->magic + arrow->stats.dam;
1444 } 1423 }
1445 } 1424 }
1446 } 1425 }
1447 } 1426 }
1427
1448 if (tmp == NULL && arrow == NULL) 1428 if (tmp == NULL && arrow == NULL)
1449 return find_arrow (op, type); 1429 return find_arrow (op, type);
1450 1430
1451 *better = betterby; 1431 *better = betterby;
1452 return tmp; 1432 return tmp;
1763 return; 1743 return;
1764 } 1744 }
1765 } 1745 }
1766 else if (item->type == ROD || item->type == HORN) 1746 else if (item->type == ROD || item->type == HORN)
1767 { 1747 {
1768 if (item->stats.hp < MAX (item->inv->stats.sp, item->inv->stats.grace)) 1748 sint16 spell_sp = MAX (item->inv->stats.sp, item->inv->stats.grace);
1749
1750 // using the maximum of the rods charge allows at least one spell cast
1751 // for a rod or horn, this fixes some broken rods.
1752 if (item->stats.hp < MIN (spell_sp, item->stats.maxhp))
1769 { 1753 {
1770 op->contr->play_sound (sound_find ("wand_poof")); 1754 op->contr->play_sound (sound_find ("wand_poof"));
1771 1755
1772 if (item->type == ROD) 1756 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)); 1757 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); 1776 CLEAR_FLAG (item, FLAG_ANIMATE);
1793 item->face = item->arch->face; 1777 item->face = item->arch->face;
1794 item->set_speed (0); 1778 item->set_speed (0);
1795 } 1779 }
1796 1780
1797 if ((tmp = item->in_player ())) 1781 if (object *pl = item->visible_to ())
1798 esrv_update_item (UPD_ANIM, tmp, item); 1782 esrv_update_item (UPD_ANIM, pl, item);
1799 } 1783 }
1800 } 1784 }
1801 else if (item->type == ROD || item->type == HORN) 1785 else if (item->type == ROD || item->type == HORN)
1802 drain_rod_charge (item); 1786 drain_rod_charge (item);
1803 } 1787 }
1980 remove_door2 (door); /* remove door without violence ;-) */ 1964 remove_door2 (door); /* remove door without violence ;-) */
1981 } 1965 }
1982 1966
1983 /* Do this after we print the message */ 1967 /* Do this after we print the message */
1984 key->decrease (); /* Use up one of the keys */ 1968 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 1969
1989 return 1; /* Nothing more to do below */ 1970 return 1; /* Nothing more to do below */
1990 } 1971 }
1991 else if (door->type == LOCKED_DOOR) 1972 else if (door->type == LOCKED_DOOR)
1992 { 1973 {
2271 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2252 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2272 { 2253 {
2273 op->play_sound (sound_find ("ob_evaporate")); 2254 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)); 2255 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2275 2256
2276 if (op->contr)
2277 esrv_del_item (op->contr, tmp->count);
2278
2279 tmp->destroy (); 2257 tmp->destroy ();
2280 CLEAR_FLAG (op, FLAG_LIFESAVE); 2258 CLEAR_FLAG (op, FLAG_LIFESAVE);
2281 2259
2282 if (op->stats.hp < 0) 2260 if (op->stats.hp < 0)
2283 op->stats.hp = op->stats.maxhp; 2261 op->stats.hp = op->stats.maxhp;
2295 return 0; 2273 return 0;
2296} 2274}
2297 2275
2298/* This goes throws the inventory and removes unpaid objects, and puts them 2276/* 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 2277 * 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 2278 * function will descend into containers. op is the object to start the search
2301 * from. 2279 * from.
2302 */ 2280 */
2303static void 2281static void
2304drop_unpaid_items (object *op, object *env) 2282drop_unpaid_items (object *op, object *env)
2305{ 2283{
2306 while (op) 2284 while (op)
2307 { 2285 {
2308 object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ 2286 object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */
2309 2287
2310 if (QUERY_FLAG (op, FLAG_UNPAID)) 2288 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); 2289 op->insert_at (env);
2316 }
2317 else if (op->inv) 2290 else if (op->inv)
2318 drop_unpaid_items (op->inv, env); 2291 drop_unpaid_items (op->inv, env);
2319 2292
2320 op = next; 2293 op = next;
2321 } 2294 }
2333 * Moved from apply.c to player.c - player.c is what 2306 * Moved from apply.c to player.c - player.c is what
2334 * actually uses this function. player.c may not be quite the 2307 * actually uses this function. player.c may not be quite the
2335 * best, a misc file for object actions is probably better, 2308 * best, a misc file for object actions is probably better,
2336 * but there isn't one in the server directory. 2309 * but there isn't one in the server directory.
2337 */ 2310 */
2338char * 2311const char *
2339gravestone_text (object *op) 2312gravestone_text (object *op)
2340{ 2313{
2341 static char buf2[MAX_BUF]; 2314 static dynbuf_text buf;
2342 char buf[MAX_BUF];
2343 time_t now = time (NULL);
2344 2315
2345 strcpy (buf2, " R.I.P.\n\n"); 2316 buf << "---- R.I.P. ----\n\n"
2317 << op->name;
2318
2346 if (op->type == PLAYER) 2319 if (op->type == PLAYER)
2347 sprintf (buf, "%s the %s\n", &op->name, op->contr->title); 2320 buf << " the " << op->contr->title;
2348 else
2349 sprintf (buf, "%s\n", &op->name);
2350 2321
2351 strncat (buf2, " ", 20 - strlen (buf) / 2); 2322 buf << "\n\n";
2352 strcat (buf2, buf); 2323
2324 buf << "who was level ";
2325 buf << (sint32)op->level << "\n\n" // OO breakdown
2326 << " when " << (op->contr ? "killed" : "died") << "\n\n";
2327
2353 if (op->type == PLAYER) 2328 if (op->type == PLAYER)
2354 sprintf (buf, "who was in level %d when killed\n", op->level); 2329 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 2330
2358 strncat (buf2, " ", 20 - strlen (buf) / 2);
2359 strcat (buf2, buf);
2360 if (op->type == PLAYER)
2361 { 2331 {
2362 sprintf (buf, "by %s.\n\n", op->contr->killer); 2332 static char buf2[128];
2363 strncat (buf2, " ", 21 - strlen (buf) / 2); 2333 time_t now = time (NULL);
2364 strcat (buf2, buf);
2365 }
2366
2367 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); 2334 strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now));
2368 strncat (buf2, " ", 20 - strlen (buf) / 2); 2335 buf << buf2;
2369 strcat (buf2, buf); 2336 }
2370 2337
2371 return buf2; 2338 return buf;
2372} 2339}
2373 2340
2374void 2341void
2375do_some_living (object *op) 2342do_some_living (object *op)
2376{ 2343{
2557 op->stats.food--; 2524 op->stats.food--;
2558 } 2525 }
2559 2526
2560 if (op->stats.food < 0 && op->stats.hp >= 0) 2527 if (op->stats.food < 0 && op->stats.hp >= 0)
2561 { 2528 {
2562 object *tmp, *flesh = 0; 2529 object *flesh = 0;
2563 2530
2564 for (tmp = op->inv; tmp; tmp = tmp->below) 2531 for_inv_removable (op, tmp)
2565 { 2532 {
2566 if (!QUERY_FLAG (tmp, FLAG_UNPAID)) 2533 if (QUERY_FLAG (tmp, FLAG_UNPAID))
2534 continue;
2535
2536 if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON)
2567 { 2537 {
2568 if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) 2538 op->statusmsg ("You blindly grab for a bite of food. "
2569 { 2539 "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); 2540 manual_apply (op, tmp, 0);
2541
2572 if (op->stats.food >= 0 || op->stats.hp < 0) 2542 if (op->stats.food >= 0 || op->stats.hp < 0)
2573 break; 2543 break;
2574 } 2544 }
2575 else if (tmp->type == FLESH) 2545 else if (tmp->type == FLESH)
2576 flesh = tmp; 2546 flesh = tmp;
2577 } /* End if paid for object */ 2547 }
2578 } /* end of for loop */
2579 2548
2580 /* If player is still starving, it means they don't have any food, so 2549 /* If player is still starving, it means they don't have any food, so
2581 * eat flesh instead. 2550 * eat flesh instead.
2582 */ 2551 */
2583 if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) 2552 if (op->stats.food < 0 && op->stats.hp >= 0 && flesh)
2584 { 2553 {
2585 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); 2554 op->statusmsg ("You blindly grab for a bite of food. "
2555 "H<To prevent you from starving, you ate some random item from your backpack.>");
2586 manual_apply (op, flesh, 0); 2556 manual_apply (op, flesh, 0);
2587 } 2557 }
2558
2559 // If player is still starving, alert him!
2560 if (op->stats.food < 0)
2561 op->failmsg ("You are starving! "
2562 "H<Eat some food to increase your food and prevent you from an untimely death.>");
2588 } 2563 }
2589 2564
2590 if (op->stats.food < 0) 2565 if (op->stats.food < 0)
2591 { 2566 {
2592 op->stats.hp += op->stats.food; 2567 op->stats.hp += op->stats.food;
2593 op->stats.food = 0; 2568 op->stats.food = 0;
2569
2570 if (op->stats.hp < 0)
2571 {
2572 op->contr->killer = archetype::get ("killer_starvation");
2573 op->contr->killer->destroy ();
2594 } 2574 }
2575 }
2595 2576
2577 /* killer should be set here already */
2596 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) 2578 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ))
2597 kill_player (op); 2579 kill_player (op);
2598 } 2580 }
2599} 2581}
2600 2582
2650 { 2632 {
2651 tmp->name = format ("%s's finger" , &op->name); 2633 tmp->name = format ("%s's finger" , &op->name);
2652 tmp->name_pl = format ("%s's fingers", &op->name); 2634 tmp->name_pl = format ("%s's fingers", &op->name);
2653 tmp->msg = format ( 2635 tmp->msg = format (
2654 "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", 2636 "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 2637 &op->name, op->contr->title,
2638 (int)op->level,
2639 op->contr->killer_name ()
2656 ); 2640 );
2657 tmp->value = 0, tmp->type = 0; 2641 tmp->value = 0, tmp->type = 0;
2658 tmp->materialname = "organics"; 2642 tmp->materialname = "organics";
2659 tmp->insert_at (op, tmp); 2643 tmp->insert_at (op, tmp);
2660 } 2644 }
2666 } 2650 }
2667 2651
2668 INVOKE_PLAYER (DEATH, op->contr); 2652 INVOKE_PLAYER (DEATH, op->contr);
2669 2653
2670 command_kill_pets (op, 0); 2654 command_kill_pets (op, 0);
2671
2672 if (op->stats.food < 0)
2673 strcpy (op->contr->killer, "starvation");
2674 2655
2675 op->contr->play_sound (sound_find ("player_dies")); 2656 op->contr->play_sound (sound_find ("player_dies"));
2676 2657
2677 /* save the map location for corpse, gravestone */ 2658 /* save the map location for corpse, gravestone */
2678 x = op->x; 2659 x = op->x;
2787 lost_a_stat = 1; 2768 lost_a_stat = 1;
2788 } 2769 }
2789 } 2770 }
2790 } 2771 }
2791 } 2772 }
2773
2792 /* If no stat lost, tell the player. */ 2774 /* If no stat lost, tell the player. */
2793 if (!lost_a_stat) 2775 if (!lost_a_stat)
2794 { 2776 {
2795 /* determine_god() seems to not work sometimes... why is this? 2777 /* determine_god() seems to not work sometimes... why is this?
2796 Should I be using something else? GD */ 2778 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); 2782 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god);
2801 else 2783 else
2802 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); 2784 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you.");
2803 } 2785 }
2804#else 2786#else
2805 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); 2787 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you from losing yourself completely.");
2806#endif 2788#endif
2807 2789
2808 /* Put a gravestone up where the character 'almost' died. List the 2790 /* Put a gravestone up where the character 'almost' died. List the
2809 * exp loss on the stone. 2791 * exp loss on the stone.
2810 */ 2792 */
2811 tmp = arch_to_object (archetype::find ("gravestone")); 2793 tmp = arch_to_object (archetype::find ("gravestone"));
2812 sprintf (buf, "%s's gravestone", &op->name); 2794 tmp->name = format ("%s's gravestone", &op->name);
2813 tmp->name = buf; 2795 tmp->name_pl = format ("%s's gravestones", &op->name);
2814 sprintf (buf, "%s's gravestones", &op->name); 2796 tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n",
2815 tmp->name_pl = buf; 2797 &op->name, op->contr->title, op->contr->killer_name ());
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);
2817 tmp->msg = buf;
2818 tmp->x = op->x, tmp->y = op->y; 2798 tmp->x = op->x, tmp->y = op->y;
2819 insert_ob_in_map (tmp, op->map, NULL, 0); 2799 insert_ob_in_map (tmp, op->map, NULL, 0);
2820 2800
2821 /**************************************/ 2801 /**************************************/
2822 /* */ 2802 /* */
2845 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2825 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2846 } 2826 }
2847 2827
2848 cure_disease (op, 0, 0); /* remove any disease */ 2828 cure_disease (op, 0, 0); /* remove any disease */
2849 2829
2830 // remove all spell effects that are active
2831 // to avoid long-term effects such as word-of-recall
2832 for (object *item = op->inv; item; )
2833 {
2834 object *next = item->below;
2835
2836 if (item->type == SPELL_EFFECT && item->active)
2837 item->destroy ();
2838
2839 item = next;
2840 }
2841
2850 /*add_exp(op, (op->stats.exp * -0.20)); */ 2842 /*add_exp(op, (op->stats.exp * -0.20)); */
2851 apply_death_exp_penalty (op); 2843 apply_death_exp_penalty (op);
2844
2852 if (op->stats.food < 100) 2845 if (op->stats.food < 100)
2853 op->stats.food = 900; 2846 op->stats.food = 900;
2847
2854 op->stats.hp = op->stats.maxhp; 2848 op->stats.hp = op->stats.maxhp;
2855 op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); 2849 op->stats.sp = MAX (op->stats.sp, op->stats.maxsp);
2856 op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); 2850 op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace);
2857 2851
2858 /* 2852 /*
2896 if (will_kill_again & (1 << at)) 2890 if (will_kill_again & (1 << at))
2897 force->resist[at] = 100; 2891 force->resist[at] = 100;
2898 2892
2899 insert_ob_in_ob (force, op); 2893 insert_ob_in_ob (force, op);
2900 op->update_stats (); 2894 op->update_stats ();
2901
2902 } 2895 }
2903 2896
2904 new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); 2897 new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED.");
2905} 2898}
2906 2899
3079 * spot (surrounded by clear terrain in broad daylight). -b.t. 3072 * spot (surrounded by clear terrain in broad daylight). -b.t.
3080 */ 3073 */
3081void 3074void
3082do_hidden_move (object *op) 3075do_hidden_move (object *op)
3083{ 3076{
3084 int hide = 0, num = random_roll (0, 19, op, PREFER_LOW); 3077 int hide = 0;
3085 object *skop;
3086 3078
3087 if (!op || !op->map) 3079 if (!op || !op->map)
3088 return; 3080 return;
3089 3081
3090 skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); 3082 object *skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING);
3083 int num = random_roll (0, 19, op, PREFER_LOW);
3091 3084
3092 /* its *extremely* hard to run and sneak/hide at the same time! */ 3085 /* its *extremely* hard to run and sneak/hide at the same time! */
3093 if (op->type == PLAYER && op->contr->run_on) 3086 if (op->type == PLAYER && op->contr->run_on)
3094 if (!skop || num >= skop->level) 3087 if (!skop || num >= skop->level)
3095 { 3088 {
3105 num -= hide; 3098 num -= hide;
3106 3099
3107 if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) 3100 if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0))
3108 { 3101 {
3109 make_visible (op); 3102 make_visible (op);
3103
3110 if (op->type == PLAYER) 3104 if (op->type == PLAYER)
3111 new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); 3105 new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!");
3112 } 3106 }
3113 else if (op->type == PLAYER && skop) 3107 else if (op->type == PLAYER && skop)
3114 change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); 3108 change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0);
3455 else 3449 else
3456 { 3450 {
3457 /* generate misc. treasure */ 3451 /* generate misc. treasure */
3458 tmp = arch_to_object (tr->item); 3452 tmp = arch_to_object (tr->item);
3459 new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); 3453 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); 3454 who->insert (tmp);
3461 if (who->type == PLAYER)
3462 esrv_send_item (who, tmp);
3463 } 3455 }
3464} 3456}
3465 3457
3466/** 3458/**
3467 * Unready an object for a player. This function does nothing if the object was 3459 * Unready an object for a player. This function does nothing if the object was

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines