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.182 by root, Thu Apr 17 14:06:03 2008 UTC vs.
Revision 1.203 by root, Sun Sep 7 21:31:23 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';
215 218
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->carrying = sum_weight (ob); 223 ob->update_weight ();
221 link_player_skills (ob); 224 link_player_skills (ob);
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);
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;
404 * Note: there MUST be at least one player archetype! 406 * Note: there MUST be at least one player archetype!
405 */ 407 */
406archetype * 408archetype *
407get_player_archetype (archetype *at) 409get_player_archetype (archetype *at)
408{ 410{
411 // archetypes could have been reloaded
412 archetype *nat = at ? archetype::find (at->archname) : archetypes [0];
413
414 if (!nat)
415 return at;
416
409 archvec::iterator i = at ? archetypes.find (at) : archetypes.begin (); 417 archvec::iterator i = archetypes.find (nat);
410 418
411 for (;;) 419 for (;;)
412 { 420 {
413 if (++i == archetypes.end ()) 421 if (++i == archetypes.end ())
414 i = archetypes.begin (); 422 i = archetypes.begin ();
845 */ 853 */
846void 854void
847player::chargen_race_done () 855player::chargen_race_done ()
848{ 856{
849 /* this must before then initial items are given */ 857 /* this must before then initial items are given */
850 esrv_new_player (ob->contr, ob->weight + ob->carrying); 858 esrv_new_player (ob->contr);
851 859
852 treasurelist *tl = treasurelist::find ("starting_wealth"); 860 treasurelist *tl = treasurelist::find ("starting_wealth");
853 if (tl) 861 if (tl)
854 create_treasure (tl, ob, 0, 0, 0); 862 create_treasure (tl, ob, 0, 0, 0);
855 863
858 866
859 ob->contr->ns->state = ST_PLAYING; 867 ob->contr->ns->state = ST_PLAYING;
860 868
861 if (ob->msg) 869 if (ob->msg)
862 ob->msg = 0; 870 ob->msg = 0;
863
864 /* We create this now because some of the unique maps will need it
865 * to save here.
866 */
867 {
868 char buf[MAX_BUF];
869 sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &ob->name);
870 make_path_to_file (buf);
871 }
872 871
873 start_info (ob); 872 start_info (ob);
874 CLEAR_FLAG (ob, FLAG_WIZ); 873 CLEAR_FLAG (ob, FLAG_WIZ);
875 give_initial_items (ob, ob->randomitems); 874 give_initial_items (ob, ob->randomitems);
876 link_player_skills (ob); 875 link_player_skills (ob);
879 878
880 /* This moves the player to a different start map, if there 879 /* This moves the player to a different start map, if there
881 * is one for this race 880 * is one for this race
882 */ 881 */
883 if (*first_map_ext_path) 882 if (*first_map_ext_path)
884 { 883 ob->player_goto (format ("%s/%s", &first_map_ext_path, &ob->arch->archname), ob->x, ob->y);
885 object *tmp;
886 char mapname[MAX_BUF];
887
888 snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &ob->arch->archname);
889 tmp = object::create ();
890 EXIT_PATH (tmp) = mapname;
891 EXIT_X (tmp) = ob->x;
892 EXIT_Y (tmp) = ob->y;
893 ob->enter_exit (tmp); /* we don't really care if it succeeded;
894 * if the map isn't there, then stay on the
895 * default initial map */
896 tmp->destroy ();
897 }
898 else 884 else
899 LOG (llevDebug, "first_map_ext_path not set\n"); 885 LOG (llevDebug, "first_map_ext_path not set\n");
900} 886}
901 887
902void 888void
1321 if (op->contr->mode & PU_RATIO) 1307 if (op->contr->mode & PU_RATIO)
1322 { 1308 {
1323 /* use value density to decide what else to grab */ 1309 /* use value density to decide what else to grab */
1324 /* >=7 was >= op->contr->mode */ 1310 /* >=7 was >= op->contr->mode */
1325 /* >=7 is the old standard setting. Now we take the last 4 bits 1311 /* >=7 is the old standard setting. Now we take the last 4 bits
1326 * and multiply them by 5, giving 0..15*5== 5..75 */ 1312 */
1327 wvratio = (op->contr->mode & PU_RATIO) * 5; 1313 wvratio = op->contr->mode & PU_RATIO;
1328 if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio) 1314 if (1000 * query_cost (tmp, op, F_TRUE) / tmp->total_weight () >= wvratio * 100)
1329 { 1315 {
1330 CHK_PICK_PICKUP; 1316 CHK_PICK_PICKUP;
1331#if 0 1317#if 0
1332 fprintf (stderr, "HIGH WEIGHT/VALUE ["); 1318 fprintf (stderr, "HIGH WEIGHT/VALUE [");
1333 if (tmp->name != NULL) 1319 if (tmp->name != NULL)
1399 } 1385 }
1400 } 1386 }
1401 else if (arrow->type == ARROW && arrow->race == type) 1387 else if (arrow->type == ARROW && arrow->race == type)
1402 { 1388 {
1403 /* allways prefer assasination/slaying */ 1389 /* allways prefer assasination/slaying */
1404 if (target->race != NULL && arrow->slaying != NULL && strstr (arrow->slaying, target->race)) 1390 if (target->race && arrow->slaying && strstr (arrow->slaying, target->race))
1405 { 1391 {
1406 if (arrow->attacktype & AT_DEATH) 1392 if (arrow->attacktype & AT_DEATH)
1407 { 1393 {
1408 *better = 100; 1394 *better = 100;
1409 return arrow; 1395 return arrow;
1437 betterby = 1 + arrow->magic + arrow->stats.dam; 1423 betterby = 1 + arrow->magic + arrow->stats.dam;
1438 } 1424 }
1439 } 1425 }
1440 } 1426 }
1441 } 1427 }
1428
1442 if (tmp == NULL && arrow == NULL) 1429 if (tmp == NULL && arrow == NULL)
1443 return find_arrow (op, type); 1430 return find_arrow (op, type);
1444 1431
1445 *better = betterby; 1432 *better = betterby;
1446 return tmp; 1433 return tmp;
1597 arrow->destroy (); 1584 arrow->destroy ();
1598 return 0; 1585 return 0;
1599 } 1586 }
1600 1587
1601 left = arrow; /* these are arrows left to the player */ 1588 left = arrow; /* these are arrows left to the player */
1602 arrow = get_split_ob (arrow, 1); 1589 arrow = arrow->split ();
1603 if (!arrow) 1590 if (!arrow)
1604 { 1591 {
1605 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1592 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1606 return 0; 1593 return 0;
1607 } 1594 }
1674 op->play_sound (sound_find ("fire_arrow")); 1661 op->play_sound (sound_find ("fire_arrow"));
1675 m->insert (arrow, sx, sy, op); 1662 m->insert (arrow, sx, sy, op);
1676 1663
1677 if (!arrow->destroyed ()) 1664 if (!arrow->destroyed ())
1678 move_arrow (arrow); 1665 move_arrow (arrow);
1679
1680 if (op->type == PLAYER)
1681 {
1682 if (left->destroyed ())
1683 esrv_del_item (op->contr, left->count);
1684 else
1685 esrv_send_item (op, left);
1686 }
1687 1666
1688 return 1; 1667 return 1;
1689} 1668}
1690 1669
1691/* Special fire code for players - this takes into 1670/* Special fire code for players - this takes into
1765 return; 1744 return;
1766 } 1745 }
1767 } 1746 }
1768 else if (item->type == ROD || item->type == HORN) 1747 else if (item->type == ROD || item->type == HORN)
1769 { 1748 {
1770 if (item->stats.hp < MAX (item->inv->stats.sp, item->inv->stats.grace)) 1749 sint16 spell_sp = MAX (item->inv->stats.sp, item->inv->stats.grace);
1750
1751 // using the maximum of the rods charge allows at least one spell cast
1752 // for a rod or horn, this fixes some broken rods.
1753 if (item->stats.hp < MIN (spell_sp, item->stats.maxhp))
1771 { 1754 {
1772 op->contr->play_sound (sound_find ("wand_poof")); 1755 op->contr->play_sound (sound_find ("wand_poof"));
1773 1756
1774 if (item->type == ROD) 1757 if (item->type == ROD)
1775 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); 1758 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0));
1794 CLEAR_FLAG (item, FLAG_ANIMATE); 1777 CLEAR_FLAG (item, FLAG_ANIMATE);
1795 item->face = item->arch->face; 1778 item->face = item->arch->face;
1796 item->set_speed (0); 1779 item->set_speed (0);
1797 } 1780 }
1798 1781
1799 if ((tmp = item->in_player ())) 1782 if (object *pl = item->visible_to ())
1800 esrv_update_item (UPD_ANIM, tmp, item); 1783 esrv_update_item (UPD_ANIM, pl, item);
1801 } 1784 }
1802 } 1785 }
1803 else if (item->type == ROD || item->type == HORN) 1786 else if (item->type == ROD || item->type == HORN)
1804 drain_rod_charge (item); 1787 drain_rod_charge (item);
1805 } 1788 }
1981 op->statusmsg (format ("You open the door with the %s", query_short_name (key)), NDI_BROWN); 1964 op->statusmsg (format ("You open the door with the %s", query_short_name (key)), NDI_BROWN);
1982 remove_door2 (door); /* remove door without violence ;-) */ 1965 remove_door2 (door); /* remove door without violence ;-) */
1983 } 1966 }
1984 1967
1985 /* Do this after we print the message */ 1968 /* Do this after we print the message */
1986 decrease_ob (key); /* Use up one of the keys */ 1969 key->decrease (); /* Use up one of the keys */
1987 /* Need to update the weight the container the key was in */
1988 if (container != op)
1989 esrv_update_item (UPD_WEIGHT, op, container);
1990 1970
1991 return 1; /* Nothing more to do below */ 1971 return 1; /* Nothing more to do below */
1992 } 1972 }
1993 else if (door->type == LOCKED_DOOR) 1973 else if (door->type == LOCKED_DOOR)
1994 { 1974 {
2273 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2253 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2274 { 2254 {
2275 op->play_sound (sound_find ("ob_evaporate")); 2255 op->play_sound (sound_find ("ob_evaporate"));
2276 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); 2256 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2277 2257
2278 if (op->contr)
2279 esrv_del_item (op->contr, tmp->count);
2280
2281 tmp->destroy (); 2258 tmp->destroy ();
2282 CLEAR_FLAG (op, FLAG_LIFESAVE); 2259 CLEAR_FLAG (op, FLAG_LIFESAVE);
2283 2260
2284 if (op->stats.hp < 0) 2261 if (op->stats.hp < 0)
2285 op->stats.hp = op->stats.maxhp; 2262 op->stats.hp = op->stats.maxhp;
2297 return 0; 2274 return 0;
2298} 2275}
2299 2276
2300/* This goes throws the inventory and removes unpaid objects, and puts them 2277/* This goes throws the inventory and removes unpaid objects, and puts them
2301 * back in the map (location and map determined by values of env). This 2278 * back in the map (location and map determined by values of env). This
2302 * function will descend into containers. op is the object to start the search 2279 * function will descend into containers. op is the object to start the search
2303 * from. 2280 * from.
2304 */ 2281 */
2305static void 2282static void
2306drop_unpaid_items (object *op, object *env) 2283drop_unpaid_items (object *op, object *env)
2307{ 2284{
2308 while (op) 2285 while (op)
2309 { 2286 {
2310 object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ 2287 object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */
2311 2288
2312 if (QUERY_FLAG (op, FLAG_UNPAID)) 2289 if (QUERY_FLAG (op, FLAG_UNPAID))
2313 {
2314 if (env->type == PLAYER)
2315 esrv_del_item (env->contr, op->count);
2316
2317 op->insert_at (env); 2290 op->insert_at (env);
2318 }
2319 else if (op->inv) 2291 else if (op->inv)
2320 drop_unpaid_items (op->inv, env); 2292 drop_unpaid_items (op->inv, env);
2321 2293
2322 op = next; 2294 op = next;
2323 } 2295 }
2335 * Moved from apply.c to player.c - player.c is what 2307 * Moved from apply.c to player.c - player.c is what
2336 * actually uses this function. player.c may not be quite the 2308 * actually uses this function. player.c may not be quite the
2337 * best, a misc file for object actions is probably better, 2309 * best, a misc file for object actions is probably better,
2338 * but there isn't one in the server directory. 2310 * but there isn't one in the server directory.
2339 */ 2311 */
2340char * 2312const char *
2341gravestone_text (object *op) 2313gravestone_text (object *op)
2342{ 2314{
2343 static char buf2[MAX_BUF]; 2315 static dynbuf_text buf;
2344 char buf[MAX_BUF];
2345 time_t now = time (NULL);
2346 2316
2347 strcpy (buf2, " R.I.P.\n\n"); 2317 buf << "---- R.I.P. ----\n\n"
2318 << op->name;
2319
2348 if (op->type == PLAYER) 2320 if (op->type == PLAYER)
2349 sprintf (buf, "%s the %s\n", &op->name, op->contr->title); 2321 buf << " the " << op->contr->title;
2350 else
2351 sprintf (buf, "%s\n", &op->name);
2352 2322
2353 strncat (buf2, " ", 20 - strlen (buf) / 2); 2323 buf << "\n\n";
2354 strcat (buf2, buf); 2324
2325 buf << "who was level ";
2326 buf << (sint32)op->level << "\n\n" // OO breakdown
2327 << " when " << (op->contr ? "killed" : "died") << "\n\n";
2328
2355 if (op->type == PLAYER) 2329 if (op->type == PLAYER)
2356 sprintf (buf, "who was in level %d when killed\n", op->level); 2330 buf << "by " << op->contr->killer_name () << ".\n\n";
2357 else
2358 sprintf (buf, "who was in level %d when died.\n\n", op->level);
2359 2331
2360 strncat (buf2, " ", 20 - strlen (buf) / 2);
2361 strcat (buf2, buf);
2362 if (op->type == PLAYER)
2363 { 2332 {
2364 sprintf (buf, "by %s.\n\n", op->contr->killer); 2333 static char buf2[128];
2365 strncat (buf2, " ", 21 - strlen (buf) / 2); 2334 time_t now = time (NULL);
2366 strcat (buf2, buf);
2367 }
2368
2369 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); 2335 strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now));
2370 strncat (buf2, " ", 20 - strlen (buf) / 2); 2336 buf << buf2;
2371 strcat (buf2, buf); 2337 }
2372 2338
2373 return buf2; 2339 return buf;
2374} 2340}
2375 2341
2376void 2342void
2377do_some_living (object *op) 2343do_some_living (object *op)
2378{ 2344{
2559 op->stats.food--; 2525 op->stats.food--;
2560 } 2526 }
2561 2527
2562 if (op->stats.food < 0 && op->stats.hp >= 0) 2528 if (op->stats.food < 0 && op->stats.hp >= 0)
2563 { 2529 {
2564 object *tmp, *flesh = 0; 2530 object *flesh = 0;
2565 2531
2566 for (tmp = op->inv; tmp; tmp = tmp->below) 2532 for_inv_removable (op, tmp)
2567 { 2533 {
2568 if (!QUERY_FLAG (tmp, FLAG_UNPAID)) 2534 if (QUERY_FLAG (tmp, FLAG_UNPAID))
2535 continue;
2536
2537 if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON)
2569 { 2538 {
2570 if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) 2539 op->statusmsg ("You blindly grab for a bite of food. "
2571 { 2540 "H<To prevent you from starving, you ate some random item from your backpack.>");
2572 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food.");
2573 manual_apply (op, tmp, 0); 2541 manual_apply (op, tmp, 0);
2542
2574 if (op->stats.food >= 0 || op->stats.hp < 0) 2543 if (op->stats.food >= 0 || op->stats.hp < 0)
2575 break; 2544 break;
2576 } 2545 }
2577 else if (tmp->type == FLESH) 2546 else if (tmp->type == FLESH)
2578 flesh = tmp; 2547 flesh = tmp;
2579 } /* End if paid for object */ 2548 }
2580 } /* end of for loop */
2581 2549
2582 /* If player is still starving, it means they don't have any food, so 2550 /* If player is still starving, it means they don't have any food, so
2583 * eat flesh instead. 2551 * eat flesh instead.
2584 */ 2552 */
2585 if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) 2553 if (op->stats.food < 0 && op->stats.hp >= 0 && flesh)
2586 { 2554 {
2587 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); 2555 op->statusmsg ("You blindly grab for a bite of food. "
2556 "H<To prevent you from starving, you ate some random item from your backpack.>");
2588 manual_apply (op, flesh, 0); 2557 manual_apply (op, flesh, 0);
2589 } 2558 }
2559
2560 // If player is still starving, alert him!
2561 if (op->stats.food < 0)
2562 op->failmsg ("You are starving! "
2563 "H<Eat some food to increase your food and prevent you from an untimely death.>");
2590 } 2564 }
2591 2565
2592 if (op->stats.food < 0) 2566 if (op->stats.food < 0)
2593 { 2567 {
2594 op->stats.hp += op->stats.food; 2568 op->stats.hp += op->stats.food;
2595 op->stats.food = 0; 2569 op->stats.food = 0;
2570
2571 if (op->stats.hp < 0)
2572 {
2573 op->contr->killer = archetype::get ("killer_starvation");
2574 op->contr->killer->destroy ();
2596 } 2575 }
2576 }
2597 2577
2578 /* killer should be set here already */
2598 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) 2579 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ))
2599 kill_player (op); 2580 kill_player (op);
2600 } 2581 }
2601} 2582}
2602 2583
2652 { 2633 {
2653 tmp->name = format ("%s's finger" , &op->name); 2634 tmp->name = format ("%s's finger" , &op->name);
2654 tmp->name_pl = format ("%s's fingers", &op->name); 2635 tmp->name_pl = format ("%s's fingers", &op->name);
2655 tmp->msg = format ( 2636 tmp->msg = format (
2656 "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", 2637 "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n",
2657 &op->name, op->contr->title, (int) (op->level), op->contr->killer 2638 &op->name, op->contr->title,
2639 (int)op->level,
2640 op->contr->killer_name ()
2658 ); 2641 );
2659 tmp->value = 0, tmp->type = 0; 2642 tmp->value = 0, tmp->type = 0;
2660 tmp->materialname = "organics"; 2643 tmp->materialname = "organics";
2661 tmp->insert_at (op, tmp); 2644 tmp->insert_at (op, tmp);
2662 } 2645 }
2668 } 2651 }
2669 2652
2670 INVOKE_PLAYER (DEATH, op->contr); 2653 INVOKE_PLAYER (DEATH, op->contr);
2671 2654
2672 command_kill_pets (op, 0); 2655 command_kill_pets (op, 0);
2673
2674 if (op->stats.food < 0)
2675 strcpy (op->contr->killer, "starvation");
2676 2656
2677 op->contr->play_sound (sound_find ("player_dies")); 2657 op->contr->play_sound (sound_find ("player_dies"));
2678 2658
2679 /* save the map location for corpse, gravestone */ 2659 /* save the map location for corpse, gravestone */
2680 x = op->x; 2660 x = op->x;
2789 lost_a_stat = 1; 2769 lost_a_stat = 1;
2790 } 2770 }
2791 } 2771 }
2792 } 2772 }
2793 } 2773 }
2774
2794 /* If no stat lost, tell the player. */ 2775 /* If no stat lost, tell the player. */
2795 if (!lost_a_stat) 2776 if (!lost_a_stat)
2796 { 2777 {
2797 /* determine_god() seems to not work sometimes... why is this? 2778 /* determine_god() seems to not work sometimes... why is this?
2798 Should I be using something else? GD */ 2779 Should I be using something else? GD */
2802 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); 2783 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god);
2803 else 2784 else
2804 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); 2785 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you.");
2805 } 2786 }
2806#else 2787#else
2807 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); 2788 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you from losing yourself completely.");
2808#endif 2789#endif
2809 2790
2810 /* Put a gravestone up where the character 'almost' died. List the 2791 /* Put a gravestone up where the character 'almost' died. List the
2811 * exp loss on the stone. 2792 * exp loss on the stone.
2812 */ 2793 */
2813 tmp = arch_to_object (archetype::find ("gravestone")); 2794 tmp = arch_to_object (archetype::find ("gravestone"));
2814 sprintf (buf, "%s's gravestone", &op->name); 2795 tmp->name = format ("%s's gravestone", &op->name);
2815 tmp->name = buf; 2796 tmp->name_pl = format ("%s's gravestones", &op->name);
2816 sprintf (buf, "%s's gravestones", &op->name);
2817 tmp->name_pl = buf;
2818 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); 2797 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 ());
2819 tmp->msg = buf;
2820 tmp->x = op->x, tmp->y = op->y; 2798 tmp->x = op->x, tmp->y = op->y;
2821 insert_ob_in_map (tmp, op->map, NULL, 0); 2799 insert_ob_in_map (tmp, op->map, NULL, 0);
2822 2800
2823 /**************************************/ 2801 /**************************************/
2824 /* */ 2802 /* */
2847 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2825 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2848 } 2826 }
2849 2827
2850 cure_disease (op, 0, 0); /* remove any disease */ 2828 cure_disease (op, 0, 0); /* remove any disease */
2851 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
2852 /*add_exp(op, (op->stats.exp * -0.20)); */ 2842 /*add_exp(op, (op->stats.exp * -0.20)); */
2853 apply_death_exp_penalty (op); 2843 apply_death_exp_penalty (op);
2844
2854 if (op->stats.food < 100) 2845 if (op->stats.food < 100)
2855 op->stats.food = 900; 2846 op->stats.food = 900;
2847
2856 op->stats.hp = op->stats.maxhp; 2848 op->stats.hp = op->stats.maxhp;
2857 op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); 2849 op->stats.sp = MAX (op->stats.sp, op->stats.maxsp);
2858 op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); 2850 op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace);
2859 2851
2860 /* 2852 /*
2928 2920
2929 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) 2921 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3))))
2930 { 2922 {
2931 if (tmp->nrof > 1) 2923 if (tmp->nrof > 1)
2932 { 2924 {
2933 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 2925 tmp->decrease (rndm (1, tmp->nrof - 1));
2934 tmp2->destroy ();
2935 insert_ob_in_map (tmp, op->map, NULL, 0); 2926 insert_ob_in_map (tmp, op->map, NULL, 0);
2936 } 2927 }
2937 else 2928 else
2938 tmp->destroy (); 2929 tmp->destroy ();
2939 } 2930 }
2950void 2941void
2951fix_weight (void) 2942fix_weight (void)
2952{ 2943{
2953 for_all_players (pl) 2944 for_all_players (pl)
2954 { 2945 {
2955 int old = pl->ob->carrying, sum = sum_weight (pl->ob); 2946 sint32 old = pl->ob->carrying;
2956 2947
2957 if (old == sum) 2948 pl->ob->update_weight ();
2958 continue; 2949
2950 if (old != pl->ob->carrying)
2951 {
2959 pl->ob->update_stats (); 2952 pl->ob->update_stats ();
2960 LOG (llevDebug, "Fixed inventory in %s (%d -> %d)\n", &pl->ob->name, old, sum); 2953 LOG (llevDebug, "Fixed inventory in %s (%d -> %d)\n", &pl->ob->name, (int)old, (int)pl->ob->carrying);
2954 }
2961 } 2955 }
2962} 2956}
2963 2957
2964void 2958void
2965fix_luck (void) 2959fix_luck (void)
3079 * spot (surrounded by clear terrain in broad daylight). -b.t. 3073 * spot (surrounded by clear terrain in broad daylight). -b.t.
3080 */ 3074 */
3081void 3075void
3082do_hidden_move (object *op) 3076do_hidden_move (object *op)
3083{ 3077{
3084 int hide = 0, num = random_roll (0, 19, op, PREFER_LOW); 3078 int hide = 0;
3085 object *skop;
3086 3079
3087 if (!op || !op->map) 3080 if (!op || !op->map)
3088 return; 3081 return;
3089 3082
3090 skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); 3083 object *skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING);
3084 int num = random_roll (0, 19, op, PREFER_LOW);
3091 3085
3092 /* its *extremely* hard to run and sneak/hide at the same time! */ 3086 /* its *extremely* hard to run and sneak/hide at the same time! */
3093 if (op->type == PLAYER && op->contr->run_on) 3087 if (op->type == PLAYER && op->contr->run_on)
3094 if (!skop || num >= skop->level) 3088 if (!skop || num >= skop->level)
3095 { 3089 {
3105 num -= hide; 3099 num -= hide;
3106 3100
3107 if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) 3101 if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0))
3108 { 3102 {
3109 make_visible (op); 3103 make_visible (op);
3104
3110 if (op->type == PLAYER) 3105 if (op->type == PLAYER)
3111 new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); 3106 new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!");
3112 } 3107 }
3113 else if (op->type == PLAYER && skop) 3108 else if (op->type == PLAYER && skop)
3114 change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); 3109 change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0);
3455 else 3450 else
3456 { 3451 {
3457 /* generate misc. treasure */ 3452 /* generate misc. treasure */
3458 tmp = arch_to_object (tr->item); 3453 tmp = arch_to_object (tr->item);
3459 new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); 3454 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); 3455 who->insert (tmp);
3461 if (who->type == PLAYER)
3462 esrv_send_item (who, tmp);
3463 } 3456 }
3464} 3457}
3465 3458
3466/** 3459/**
3467 * Unready an object for a player. This function does nothing if the object was 3460 * Unready an object for a player. This function does nothing if the object was

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines