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.188 by root, Tue Apr 22 02:46:18 2008 UTC vs.
Revision 1.202 by root, Fri Aug 29 02:07:09 2008 UTC

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';
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;
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
864 866
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
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 871
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); 875 link_player_skills (ob);
885 878
886 /* This moves the player to a different start map, if there 879 /* This moves the player to a different start map, if there
887 * is one for this race 880 * is one for this race
888 */ 881 */
889 if (*first_map_ext_path) 882 if (*first_map_ext_path)
890 { 883 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 884 else
905 LOG (llevDebug, "first_map_ext_path not set\n"); 885 LOG (llevDebug, "first_map_ext_path not set\n");
906} 886}
907 887
908void 888void
1327 if (op->contr->mode & PU_RATIO) 1307 if (op->contr->mode & PU_RATIO)
1328 { 1308 {
1329 /* use value density to decide what else to grab */ 1309 /* use value density to decide what else to grab */
1330 /* >=7 was >= op->contr->mode */ 1310 /* >=7 was >= op->contr->mode */
1331 /* >=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
1332 * and multiply them by 5, giving 0..15*5== 5..75 */ 1312 */
1333 wvratio = (op->contr->mode & PU_RATIO) * 5; 1313 wvratio = op->contr->mode & PU_RATIO;
1334 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)
1335 { 1315 {
1336 CHK_PICK_PICKUP; 1316 CHK_PICK_PICKUP;
1337#if 0 1317#if 0
1338 fprintf (stderr, "HIGH WEIGHT/VALUE ["); 1318 fprintf (stderr, "HIGH WEIGHT/VALUE [");
1339 if (tmp->name != NULL) 1319 if (tmp->name != NULL)
1405 } 1385 }
1406 } 1386 }
1407 else if (arrow->type == ARROW && arrow->race == type) 1387 else if (arrow->type == ARROW && arrow->race == type)
1408 { 1388 {
1409 /* allways prefer assasination/slaying */ 1389 /* allways prefer assasination/slaying */
1410 if (target->race != NULL && arrow->slaying != NULL && strstr (arrow->slaying, target->race)) 1390 if (target->race && arrow->slaying && strstr (arrow->slaying, target->race))
1411 { 1391 {
1412 if (arrow->attacktype & AT_DEATH) 1392 if (arrow->attacktype & AT_DEATH)
1413 { 1393 {
1414 *better = 100; 1394 *better = 100;
1415 return arrow; 1395 return arrow;
1443 betterby = 1 + arrow->magic + arrow->stats.dam; 1423 betterby = 1 + arrow->magic + arrow->stats.dam;
1444 } 1424 }
1445 } 1425 }
1446 } 1426 }
1447 } 1427 }
1428
1448 if (tmp == NULL && arrow == NULL) 1429 if (tmp == NULL && arrow == NULL)
1449 return find_arrow (op, type); 1430 return find_arrow (op, type);
1450 1431
1451 *better = betterby; 1432 *better = betterby;
1452 return tmp; 1433 return tmp;
1763 return; 1744 return;
1764 } 1745 }
1765 } 1746 }
1766 else if (item->type == ROD || item->type == HORN) 1747 else if (item->type == ROD || item->type == HORN)
1767 { 1748 {
1768 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))
1769 { 1754 {
1770 op->contr->play_sound (sound_find ("wand_poof")); 1755 op->contr->play_sound (sound_find ("wand_poof"));
1771 1756
1772 if (item->type == ROD) 1757 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)); 1758 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); 1777 CLEAR_FLAG (item, FLAG_ANIMATE);
1793 item->face = item->arch->face; 1778 item->face = item->arch->face;
1794 item->set_speed (0); 1779 item->set_speed (0);
1795 } 1780 }
1796 1781
1797 if ((tmp = item->in_player ())) 1782 if (object *pl = item->visible_to ())
1798 esrv_update_item (UPD_ANIM, tmp, item); 1783 esrv_update_item (UPD_ANIM, pl, item);
1799 } 1784 }
1800 } 1785 }
1801 else if (item->type == ROD || item->type == HORN) 1786 else if (item->type == ROD || item->type == HORN)
1802 drain_rod_charge (item); 1787 drain_rod_charge (item);
1803 } 1788 }
1980 remove_door2 (door); /* remove door without violence ;-) */ 1965 remove_door2 (door); /* remove door without violence ;-) */
1981 } 1966 }
1982 1967
1983 /* Do this after we print the message */ 1968 /* Do this after we print the message */
1984 key->decrease (); /* Use up one of the keys */ 1969 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 1970
1989 return 1; /* Nothing more to do below */ 1971 return 1; /* Nothing more to do below */
1990 } 1972 }
1991 else if (door->type == LOCKED_DOOR) 1973 else if (door->type == LOCKED_DOOR)
1992 { 1974 {
2292 return 0; 2274 return 0;
2293} 2275}
2294 2276
2295/* 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
2296 * 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
2297 * 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
2298 * from. 2280 * from.
2299 */ 2281 */
2300static void 2282static void
2301drop_unpaid_items (object *op, object *env) 2283drop_unpaid_items (object *op, object *env)
2302{ 2284{
2303 while (op) 2285 while (op)
2304 { 2286 {
2305 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' */
2306 2288
2307 if (QUERY_FLAG (op, FLAG_UNPAID)) 2289 if (QUERY_FLAG (op, FLAG_UNPAID))
2308 {
2309 if (env->type == PLAYER)
2310 esrv_del_item (env->contr, op->count);
2311
2312 op->insert_at (env); 2290 op->insert_at (env);
2313 }
2314 else if (op->inv) 2291 else if (op->inv)
2315 drop_unpaid_items (op->inv, env); 2292 drop_unpaid_items (op->inv, env);
2316 2293
2317 op = next; 2294 op = next;
2318 } 2295 }
2330 * Moved from apply.c to player.c - player.c is what 2307 * Moved from apply.c to player.c - player.c is what
2331 * actually uses this function. player.c may not be quite the 2308 * actually uses this function. player.c may not be quite the
2332 * best, a misc file for object actions is probably better, 2309 * best, a misc file for object actions is probably better,
2333 * but there isn't one in the server directory. 2310 * but there isn't one in the server directory.
2334 */ 2311 */
2335char * 2312const char *
2336gravestone_text (object *op) 2313gravestone_text (object *op)
2337{ 2314{
2338 static char buf2[MAX_BUF]; 2315 static dynbuf_text buf;
2339 char buf[MAX_BUF];
2340 time_t now = time (NULL);
2341 2316
2342 strcpy (buf2, " R.I.P.\n\n"); 2317 buf << "---- R.I.P. ----\n\n";
2318 op->name;
2319
2343 if (op->type == PLAYER) 2320 if (op->type == PLAYER)
2344 sprintf (buf, "%s the %s\n", &op->name, op->contr->title); 2321 buf << " the " << op->contr->title;
2345 else
2346 sprintf (buf, "%s\n", &op->name);
2347 2322
2348 strncat (buf2, " ", 20 - strlen (buf) / 2); 2323 buf << "\n\n";
2349 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
2350 if (op->type == PLAYER) 2329 if (op->type == PLAYER)
2351 sprintf (buf, "who was in level %d when killed\n", op->level); 2330 buf << "by " << op->contr->killer_name () << ".\n\n";
2352 else
2353 sprintf (buf, "who was in level %d when died.\n\n", op->level);
2354 2331
2355 strncat (buf2, " ", 20 - strlen (buf) / 2);
2356 strcat (buf2, buf);
2357 if (op->type == PLAYER)
2358 { 2332 {
2359 sprintf (buf, "by %s.\n\n", op->contr->killer); 2333 static char buf2[128];
2360 strncat (buf2, " ", 21 - strlen (buf) / 2); 2334 time_t now = time (NULL);
2361 strcat (buf2, buf);
2362 }
2363
2364 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); 2335 strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now));
2365 strncat (buf2, " ", 20 - strlen (buf) / 2); 2336 buf << buf2;
2366 strcat (buf2, buf); 2337 }
2367 2338
2368 return buf2; 2339 return buf;
2369} 2340}
2370 2341
2371void 2342void
2372do_some_living (object *op) 2343do_some_living (object *op)
2373{ 2344{
2554 op->stats.food--; 2525 op->stats.food--;
2555 } 2526 }
2556 2527
2557 if (op->stats.food < 0 && op->stats.hp >= 0) 2528 if (op->stats.food < 0 && op->stats.hp >= 0)
2558 { 2529 {
2559 object *tmp, *flesh = 0; 2530 object *flesh = 0;
2560 2531
2561 for (tmp = op->inv; tmp; tmp = tmp->below) 2532 for_inv_removable (op, tmp)
2562 { 2533 {
2563 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)
2564 { 2538 {
2565 if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) 2539 op->statusmsg ("You blindly grab for a bite of food. "
2566 { 2540 "H<To prevent you from starving, you ate some random item from your backpack.>");
2567 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food.");
2568 manual_apply (op, tmp, 0); 2541 manual_apply (op, tmp, 0);
2542
2569 if (op->stats.food >= 0 || op->stats.hp < 0) 2543 if (op->stats.food >= 0 || op->stats.hp < 0)
2570 break; 2544 break;
2571 } 2545 }
2572 else if (tmp->type == FLESH) 2546 else if (tmp->type == FLESH)
2573 flesh = tmp; 2547 flesh = tmp;
2574 } /* End if paid for object */ 2548 }
2575 } /* end of for loop */
2576 2549
2577 /* 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
2578 * eat flesh instead. 2551 * eat flesh instead.
2579 */ 2552 */
2580 if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) 2553 if (op->stats.food < 0 && op->stats.hp >= 0 && flesh)
2581 { 2554 {
2582 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.>");
2583 manual_apply (op, flesh, 0); 2557 manual_apply (op, flesh, 0);
2584 } 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.>");
2585 } 2564 }
2586 2565
2587 if (op->stats.food < 0) 2566 if (op->stats.food < 0)
2588 { 2567 {
2589 op->stats.hp += op->stats.food; 2568 op->stats.hp += op->stats.food;
2590 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 ();
2591 } 2575 }
2576 }
2592 2577
2578 /* killer should be set here already */
2593 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) 2579 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ))
2594 kill_player (op); 2580 kill_player (op);
2595 } 2581 }
2596} 2582}
2597 2583
2647 { 2633 {
2648 tmp->name = format ("%s's finger" , &op->name); 2634 tmp->name = format ("%s's finger" , &op->name);
2649 tmp->name_pl = format ("%s's fingers", &op->name); 2635 tmp->name_pl = format ("%s's fingers", &op->name);
2650 tmp->msg = format ( 2636 tmp->msg = format (
2651 "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",
2652 &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 ()
2653 ); 2641 );
2654 tmp->value = 0, tmp->type = 0; 2642 tmp->value = 0, tmp->type = 0;
2655 tmp->materialname = "organics"; 2643 tmp->materialname = "organics";
2656 tmp->insert_at (op, tmp); 2644 tmp->insert_at (op, tmp);
2657 } 2645 }
2663 } 2651 }
2664 2652
2665 INVOKE_PLAYER (DEATH, op->contr); 2653 INVOKE_PLAYER (DEATH, op->contr);
2666 2654
2667 command_kill_pets (op, 0); 2655 command_kill_pets (op, 0);
2668
2669 if (op->stats.food < 0)
2670 strcpy (op->contr->killer, "starvation");
2671 2656
2672 op->contr->play_sound (sound_find ("player_dies")); 2657 op->contr->play_sound (sound_find ("player_dies"));
2673 2658
2674 /* save the map location for corpse, gravestone */ 2659 /* save the map location for corpse, gravestone */
2675 x = op->x; 2660 x = op->x;
2784 lost_a_stat = 1; 2769 lost_a_stat = 1;
2785 } 2770 }
2786 } 2771 }
2787 } 2772 }
2788 } 2773 }
2774
2789 /* If no stat lost, tell the player. */ 2775 /* If no stat lost, tell the player. */
2790 if (!lost_a_stat) 2776 if (!lost_a_stat)
2791 { 2777 {
2792 /* determine_god() seems to not work sometimes... why is this? 2778 /* determine_god() seems to not work sometimes... why is this?
2793 Should I be using something else? GD */ 2779 Should I be using something else? GD */
2797 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);
2798 else 2784 else
2799 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.");
2800 } 2786 }
2801#else 2787#else
2802 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.");
2803#endif 2789#endif
2804 2790
2805 /* Put a gravestone up where the character 'almost' died. List the 2791 /* Put a gravestone up where the character 'almost' died. List the
2806 * exp loss on the stone. 2792 * exp loss on the stone.
2807 */ 2793 */
2808 tmp = arch_to_object (archetype::find ("gravestone")); 2794 tmp = arch_to_object (archetype::find ("gravestone"));
2809 sprintf (buf, "%s's gravestone", &op->name); 2795 tmp->name = format ("%s's gravestone", &op->name);
2810 tmp->name = buf; 2796 tmp->name_pl = format ("%s's gravestones", &op->name);
2811 sprintf (buf, "%s's gravestones", &op->name);
2812 tmp->name_pl = buf;
2813 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 ());
2814 tmp->msg = buf;
2815 tmp->x = op->x, tmp->y = op->y; 2798 tmp->x = op->x, tmp->y = op->y;
2816 insert_ob_in_map (tmp, op->map, NULL, 0); 2799 insert_ob_in_map (tmp, op->map, NULL, 0);
2817 2800
2818 /**************************************/ 2801 /**************************************/
2819 /* */ 2802 /* */
2842 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2825 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2843 } 2826 }
2844 2827
2845 cure_disease (op, 0, 0); /* remove any disease */ 2828 cure_disease (op, 0, 0); /* remove any disease */
2846 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
2847 /*add_exp(op, (op->stats.exp * -0.20)); */ 2842 /*add_exp(op, (op->stats.exp * -0.20)); */
2848 apply_death_exp_penalty (op); 2843 apply_death_exp_penalty (op);
2844
2849 if (op->stats.food < 100) 2845 if (op->stats.food < 100)
2850 op->stats.food = 900; 2846 op->stats.food = 900;
2847
2851 op->stats.hp = op->stats.maxhp; 2848 op->stats.hp = op->stats.maxhp;
2852 op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); 2849 op->stats.sp = MAX (op->stats.sp, op->stats.maxsp);
2853 op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); 2850 op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace);
2854 2851
2855 /* 2852 /*
3076 * spot (surrounded by clear terrain in broad daylight). -b.t. 3073 * spot (surrounded by clear terrain in broad daylight). -b.t.
3077 */ 3074 */
3078void 3075void
3079do_hidden_move (object *op) 3076do_hidden_move (object *op)
3080{ 3077{
3081 int hide = 0, num = random_roll (0, 19, op, PREFER_LOW); 3078 int hide = 0;
3082 object *skop;
3083 3079
3084 if (!op || !op->map) 3080 if (!op || !op->map)
3085 return; 3081 return;
3086 3082
3087 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);
3088 3085
3089 /* 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! */
3090 if (op->type == PLAYER && op->contr->run_on) 3087 if (op->type == PLAYER && op->contr->run_on)
3091 if (!skop || num >= skop->level) 3088 if (!skop || num >= skop->level)
3092 { 3089 {
3102 num -= hide; 3099 num -= hide;
3103 3100
3104 if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) 3101 if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0))
3105 { 3102 {
3106 make_visible (op); 3103 make_visible (op);
3104
3107 if (op->type == PLAYER) 3105 if (op->type == PLAYER)
3108 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!");
3109 } 3107 }
3110 else if (op->type == PLAYER && skop) 3108 else if (op->type == PLAYER && skop)
3111 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);
3452 else 3450 else
3453 { 3451 {
3454 /* generate misc. treasure */ 3452 /* generate misc. treasure */
3455 tmp = arch_to_object (tr->item); 3453 tmp = arch_to_object (tr->item);
3456 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));
3457 tmp = insert_ob_in_ob (tmp, who); 3455 who->insert (tmp);
3458 if (who->type == PLAYER)
3459 esrv_send_item (who, tmp);
3460 } 3456 }
3461} 3457}
3462 3458
3463/** 3459/**
3464 * 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