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.192 by root, Wed Apr 30 06:40:28 2008 UTC vs.
Revision 1.201 by root, Sun Aug 17 01:26:35 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';
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{
865 ob->contr->ns->state = ST_PLAYING; 868 ob->contr->ns->state = ST_PLAYING;
866 869
867 if (ob->msg) 870 if (ob->msg)
868 ob->msg = 0; 871 ob->msg = 0;
869 872
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); 873 start_info (ob);
880 CLEAR_FLAG (ob, FLAG_WIZ); 874 CLEAR_FLAG (ob, FLAG_WIZ);
881 give_initial_items (ob, ob->randomitems); 875 give_initial_items (ob, ob->randomitems);
882 link_player_skills (ob); 876 link_player_skills (ob);
883 esrv_send_inventory (ob, ob); 877 esrv_send_inventory (ob, ob);
885 879
886 /* This moves the player to a different start map, if there 880 /* This moves the player to a different start map, if there
887 * is one for this race 881 * is one for this race
888 */ 882 */
889 if (*first_map_ext_path) 883 if (*first_map_ext_path)
890 { 884 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 885 else
905 LOG (llevDebug, "first_map_ext_path not set\n"); 886 LOG (llevDebug, "first_map_ext_path not set\n");
906} 887}
907 888
908void 889void
1327 if (op->contr->mode & PU_RATIO) 1308 if (op->contr->mode & PU_RATIO)
1328 { 1309 {
1329 /* use value density to decide what else to grab */ 1310 /* use value density to decide what else to grab */
1330 /* >=7 was >= op->contr->mode */ 1311 /* >=7 was >= op->contr->mode */
1331 /* >=7 is the old standard setting. Now we take the last 4 bits 1312 /* >=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 */ 1313 */
1333 wvratio = (op->contr->mode & PU_RATIO) * 5; 1314 wvratio = op->contr->mode & PU_RATIO;
1334 if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio) 1315 if (1000 * query_cost (tmp, op, F_TRUE) / tmp->total_weight () >= wvratio * 100)
1335 { 1316 {
1336 CHK_PICK_PICKUP; 1317 CHK_PICK_PICKUP;
1337#if 0 1318#if 0
1338 fprintf (stderr, "HIGH WEIGHT/VALUE ["); 1319 fprintf (stderr, "HIGH WEIGHT/VALUE [");
1339 if (tmp->name != NULL) 1320 if (tmp->name != NULL)
1443 betterby = 1 + arrow->magic + arrow->stats.dam; 1424 betterby = 1 + arrow->magic + arrow->stats.dam;
1444 } 1425 }
1445 } 1426 }
1446 } 1427 }
1447 } 1428 }
1429
1448 if (tmp == NULL && arrow == NULL) 1430 if (tmp == NULL && arrow == NULL)
1449 return find_arrow (op, type); 1431 return find_arrow (op, type);
1450 1432
1451 *better = betterby; 1433 *better = betterby;
1452 return tmp; 1434 return tmp;
2544 op->stats.food--; 2526 op->stats.food--;
2545 } 2527 }
2546 2528
2547 if (op->stats.food < 0 && op->stats.hp >= 0) 2529 if (op->stats.food < 0 && op->stats.hp >= 0)
2548 { 2530 {
2549 object *tmp, *flesh = 0; 2531 object *flesh = 0;
2550 2532
2551 for (tmp = op->inv; tmp; tmp = tmp->below) 2533 for_inv_removable (op, tmp)
2552 { 2534 {
2553 if (!QUERY_FLAG (tmp, FLAG_UNPAID)) 2535 if (QUERY_FLAG (tmp, FLAG_UNPAID))
2536 continue;
2537
2538 if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON)
2554 { 2539 {
2555 if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) 2540 op->statusmsg ("You blindly grab for a bite of food. "
2556 { 2541 "H<To prevent you from starving, you ate some random item from your backpack.>");
2557 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food.");
2558 manual_apply (op, tmp, 0); 2542 manual_apply (op, tmp, 0);
2543
2559 if (op->stats.food >= 0 || op->stats.hp < 0) 2544 if (op->stats.food >= 0 || op->stats.hp < 0)
2560 break; 2545 break;
2561 } 2546 }
2562 else if (tmp->type == FLESH) 2547 else if (tmp->type == FLESH)
2563 flesh = tmp; 2548 flesh = tmp;
2564 } /* End if paid for object */ 2549 }
2565 } /* end of for loop */
2566 2550
2567 /* If player is still starving, it means they don't have any food, so 2551 /* If player is still starving, it means they don't have any food, so
2568 * eat flesh instead. 2552 * eat flesh instead.
2569 */ 2553 */
2570 if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) 2554 if (op->stats.food < 0 && op->stats.hp >= 0 && flesh)
2571 { 2555 {
2572 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); 2556 op->statusmsg ("You blindly grab for a bite of food. "
2557 "H<To prevent you from starving, you ate some random item from your backpack.>");
2573 manual_apply (op, flesh, 0); 2558 manual_apply (op, flesh, 0);
2574 } 2559 }
2560
2561 // If player is still starving, alert him!
2562 if (op->stats.food < 0)
2563 op->failmsg ("You are starving! "
2564 "H<Eat some food to increase your food and prevent you from an untimely death.>");
2575 } 2565 }
2576 2566
2577 if (op->stats.food < 0) 2567 if (op->stats.food < 0)
2578 { 2568 {
2579 op->stats.hp += op->stats.food; 2569 op->stats.hp += op->stats.food;
2580 op->stats.food = 0; 2570 op->stats.food = 0;
2571
2572 if (op->stats.hp < 0)
2573 {
2574 op->contr->killer = archetype::get ("killer_starvation");
2575 op->contr->killer->destroy ();
2581 } 2576 }
2577 }
2582 2578
2579 /* killer should be set here already */
2583 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) 2580 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ))
2584 kill_player (op); 2581 kill_player (op);
2585 } 2582 }
2586} 2583}
2587 2584
2655 } 2652 }
2656 2653
2657 INVOKE_PLAYER (DEATH, op->contr); 2654 INVOKE_PLAYER (DEATH, op->contr);
2658 2655
2659 command_kill_pets (op, 0); 2656 command_kill_pets (op, 0);
2660
2661 if (op->stats.food < 0)
2662 {
2663 op->contr->killer = archetype::get ("killer_starvation");
2664 op->contr->killer->destroy ();
2665 }
2666 2657
2667 op->contr->play_sound (sound_find ("player_dies")); 2658 op->contr->play_sound (sound_find ("player_dies"));
2668 2659
2669 /* save the map location for corpse, gravestone */ 2660 /* save the map location for corpse, gravestone */
2670 x = op->x; 2661 x = op->x;
2779 lost_a_stat = 1; 2770 lost_a_stat = 1;
2780 } 2771 }
2781 } 2772 }
2782 } 2773 }
2783 } 2774 }
2775
2784 /* If no stat lost, tell the player. */ 2776 /* If no stat lost, tell the player. */
2785 if (!lost_a_stat) 2777 if (!lost_a_stat)
2786 { 2778 {
2787 /* determine_god() seems to not work sometimes... why is this? 2779 /* determine_god() seems to not work sometimes... why is this?
2788 Should I be using something else? GD */ 2780 Should I be using something else? GD */
2792 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); 2784 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god);
2793 else 2785 else
2794 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); 2786 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you.");
2795 } 2787 }
2796#else 2788#else
2797 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); 2789 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you from losing yourself completely.");
2798#endif 2790#endif
2799 2791
2800 /* Put a gravestone up where the character 'almost' died. List the 2792 /* Put a gravestone up where the character 'almost' died. List the
2801 * exp loss on the stone. 2793 * exp loss on the stone.
2802 */ 2794 */
2803 tmp = arch_to_object (archetype::find ("gravestone")); 2795 tmp = arch_to_object (archetype::find ("gravestone"));
2804 sprintf (buf, "%s's gravestone", &op->name); 2796 tmp->name = format ("%s's gravestone", &op->name);
2805 tmp->name = buf; 2797 tmp->name_pl = format ("%s's gravestones", &op->name);
2806 sprintf (buf, "%s's gravestones", &op->name);
2807 tmp->name_pl = buf;
2808 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_name ()); 2798 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 ());
2809 tmp->msg = buf;
2810 tmp->x = op->x, tmp->y = op->y; 2799 tmp->x = op->x, tmp->y = op->y;
2811 insert_ob_in_map (tmp, op->map, NULL, 0); 2800 insert_ob_in_map (tmp, op->map, NULL, 0);
2812 2801
2813 /**************************************/ 2802 /**************************************/
2814 /* */ 2803 /* */
2837 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2826 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2838 } 2827 }
2839 2828
2840 cure_disease (op, 0, 0); /* remove any disease */ 2829 cure_disease (op, 0, 0); /* remove any disease */
2841 2830
2831 // remove all spell effects that are active
2832 // to avoid long-term effects such as word-of-recall
2833 for (object *item = op->inv; item; )
2834 {
2835 object *next = item->below;
2836
2837 if (item->type == SPELL_EFFECT && item->active)
2838 item->destroy ();
2839
2840 item = next;
2841 }
2842
2842 /*add_exp(op, (op->stats.exp * -0.20)); */ 2843 /*add_exp(op, (op->stats.exp * -0.20)); */
2843 apply_death_exp_penalty (op); 2844 apply_death_exp_penalty (op);
2845
2844 if (op->stats.food < 100) 2846 if (op->stats.food < 100)
2845 op->stats.food = 900; 2847 op->stats.food = 900;
2848
2846 op->stats.hp = op->stats.maxhp; 2849 op->stats.hp = op->stats.maxhp;
2847 op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); 2850 op->stats.sp = MAX (op->stats.sp, op->stats.maxsp);
2848 op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); 2851 op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace);
2849 2852
2850 /* 2853 /*
3071 * spot (surrounded by clear terrain in broad daylight). -b.t. 3074 * spot (surrounded by clear terrain in broad daylight). -b.t.
3072 */ 3075 */
3073void 3076void
3074do_hidden_move (object *op) 3077do_hidden_move (object *op)
3075{ 3078{
3076 int hide = 0, num = random_roll (0, 19, op, PREFER_LOW); 3079 int hide = 0;
3077 object *skop;
3078 3080
3079 if (!op || !op->map) 3081 if (!op || !op->map)
3080 return; 3082 return;
3081 3083
3082 skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); 3084 object *skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING);
3085 int num = random_roll (0, 19, op, PREFER_LOW);
3083 3086
3084 /* its *extremely* hard to run and sneak/hide at the same time! */ 3087 /* its *extremely* hard to run and sneak/hide at the same time! */
3085 if (op->type == PLAYER && op->contr->run_on) 3088 if (op->type == PLAYER && op->contr->run_on)
3086 if (!skop || num >= skop->level) 3089 if (!skop || num >= skop->level)
3087 { 3090 {
3097 num -= hide; 3100 num -= hide;
3098 3101
3099 if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) 3102 if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0))
3100 { 3103 {
3101 make_visible (op); 3104 make_visible (op);
3105
3102 if (op->type == PLAYER) 3106 if (op->type == PLAYER)
3103 new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); 3107 new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!");
3104 } 3108 }
3105 else if (op->type == PLAYER && skop) 3109 else if (op->type == PLAYER && skop)
3106 change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); 3110 change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines