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.198 by root, Sat May 17 00:17:02 2008 UTC vs.
Revision 1.210 by root, Fri Dec 19 22:47:30 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';
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
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{
868 ob->msg = 0; 870 ob->msg = 0;
869 871
870 start_info (ob); 872 start_info (ob);
871 CLEAR_FLAG (ob, FLAG_WIZ); 873 CLEAR_FLAG (ob, FLAG_WIZ);
872 give_initial_items (ob, ob->randomitems); 874 give_initial_items (ob, ob->randomitems);
873 link_player_skills (ob);
874 esrv_send_inventory (ob, ob); 875 esrv_send_inventory (ob, ob);
875 ob->update_stats (); 876 ob->update_stats ();
876 877
877 /* This moves the player to a different start map, if there 878 /* This moves the player to a different start map, if there
878 * is one for this race 879 * is one for this race
1305 if (op->contr->mode & PU_RATIO) 1306 if (op->contr->mode & PU_RATIO)
1306 { 1307 {
1307 /* use value density to decide what else to grab */ 1308 /* use value density to decide what else to grab */
1308 /* >=7 was >= op->contr->mode */ 1309 /* >=7 was >= op->contr->mode */
1309 /* >=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
1310 * and multiply them by 5, giving 0..15*5== 5..75 */ 1311 */
1311 wvratio = (op->contr->mode & PU_RATIO) * 5; 1312 wvratio = op->contr->mode & PU_RATIO;
1312 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)
1313 { 1314 {
1314 CHK_PICK_PICKUP; 1315 CHK_PICK_PICKUP;
1315#if 0 1316#if 0
1316 fprintf (stderr, "HIGH WEIGHT/VALUE ["); 1317 fprintf (stderr, "HIGH WEIGHT/VALUE [");
1317 if (tmp->name != NULL) 1318 if (tmp->name != NULL)
1577 } 1578 }
1578 1579
1579 /* this should not happen, but sometimes does */ 1580 /* this should not happen, but sometimes does */
1580 if (arrow->nrof == 0) 1581 if (arrow->nrof == 0)
1581 { 1582 {
1583 LOG (llevError | logBacktrace, "arrow (%s) has nrof 0\n", arrow->debug_desc ());
1582 arrow->destroy (); 1584 arrow->destroy ();
1583 return 0; 1585 return 0;
1584 } 1586 }
1585 1587
1586 left = arrow; /* these are arrows left to the player */ 1588 left = arrow; /* these are arrows left to the player */
1791bool 1793bool
1792fire (object *op, int dir) 1794fire (object *op, int dir)
1793{ 1795{
1794 int spellcost = 0; 1796 int spellcost = 0;
1795 1797
1796 /* check for loss of invisiblity/hide */
1797 if (action_makes_visible (op))
1798 make_visible (op);
1799
1800 player *pl = op->contr; 1798 player *pl = op->contr;
1801 1799
1802 if (pl->golem) 1800 if (pl->golem)
1803 { 1801 {
1804 control_golem (op->contr->golem, dir); 1802 control_golem (op->contr->golem, dir);
1806 } 1804 }
1807 1805
1808 object *ob = pl->ranged_ob; 1806 object *ob = pl->ranged_ob;
1809 1807
1810 if (!ob) 1808 if (!ob)
1811 return false;
1812
1813 if (!op->change_weapon (ob))
1814 return false; 1809 return false;
1815 1810
1816 if (op->speed_left > 0.f) 1811 if (op->speed_left > 0.f)
1817 --op->speed_left; 1812 --op->speed_left;
1818 else 1813 else
1819 return false; 1814 return false;
1815
1816 if (!op->change_weapon (ob))
1817 return false;
1818
1819 /* check for loss of invisiblity/hide */
1820 if (action_makes_visible (op))
1821 make_visible (op);
1820 1822
1821 switch (ob->type) 1823 switch (ob->type)
1822 { 1824 {
1823 case BOW: 1825 case BOW:
1824 player_fire_bow (op, dir); 1826 player_fire_bow (op, dir);
2069 --op->speed_left; 2071 --op->speed_left;
2070 2072
2071 op->play_sound (sound_find ("push_player")); 2073 op->play_sound (sound_find ("push_player"));
2072 push_ob (mon, dir, op); 2074 push_ob (mon, dir, op);
2073 2075
2074 if (op->contr->tmp_invis || op->hide) 2076 if (op->contr->tmp_invis || op->flag [FLAG_HIDDEN])
2075 make_visible (op); 2077 make_visible (op);
2076 2078
2077 return true; 2079 return true;
2078 } 2080 }
2079 else 2081 else
2101 push_ob (mon, dir, op); 2103 push_ob (mon, dir, op);
2102 } 2104 }
2103 else 2105 else
2104 op->statusmsg ("You withhold your attack"); 2106 op->statusmsg ("You withhold your attack");
2105 2107
2106 if (op->contr->tmp_invis || op->hide) 2108 if (op->contr->tmp_invis || op->flag [FLAG_HIDDEN])
2107 make_visible (op); 2109 make_visible (op);
2108 2110
2109 return true; 2111 return true;
2110 } 2112 }
2111 } 2113 }
2169 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) 2171 if (QUERY_FLAG (op, FLAG_CONFUSED) && dir)
2170 dir = absdir (dir + rndm (3) + rndm (3) - 2); 2172 dir = absdir (dir + rndm (3) + rndm (3) - 2);
2171 2173
2172 op->facing = dir; 2174 op->facing = dir;
2173 2175
2174 if (op->hide) 2176 if (op->flag [FLAG_HIDDEN])
2175 do_hidden_move (op); 2177 do_hidden_move (op);
2176 2178
2177 bool retval; 2179 bool retval;
2178 2180
2179 if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) 2181 if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir)))
2310const char * 2312const char *
2311gravestone_text (object *op) 2313gravestone_text (object *op)
2312{ 2314{
2313 static dynbuf_text buf; 2315 static dynbuf_text buf;
2314 2316
2315 buf << "---- R.I.P. ----\n\n"; 2317 buf << "---- R.I.P. ----\n\n"
2316 op->name; 2318 << op->name;
2317 2319
2318 if (op->type == PLAYER) 2320 if (op->type == PLAYER)
2319 buf << " the " << op->contr->title; 2321 buf << " the " << op->contr->title;
2320 2322
2321 buf << "\n\n"; 2323 buf << "\n\n";
2563 2565
2564 if (op->stats.food < 0) 2566 if (op->stats.food < 0)
2565 { 2567 {
2566 op->stats.hp += op->stats.food; 2568 op->stats.hp += op->stats.food;
2567 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 ();
2568 } 2575 }
2576 }
2569 2577
2578 /* killer should be set here already */
2570 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) 2579 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ))
2571 kill_player (op); 2580 kill_player (op);
2572 } 2581 }
2573} 2582}
2574 2583
2642 } 2651 }
2643 2652
2644 INVOKE_PLAYER (DEATH, op->contr); 2653 INVOKE_PLAYER (DEATH, op->contr);
2645 2654
2646 command_kill_pets (op, 0); 2655 command_kill_pets (op, 0);
2647
2648 if (op->stats.food < 0)
2649 {
2650 op->contr->killer = archetype::get ("killer_starvation");
2651 op->contr->killer->destroy ();
2652 }
2653 2656
2654 op->contr->play_sound (sound_find ("player_dies")); 2657 op->contr->play_sound (sound_find ("player_dies"));
2655 2658
2656 /* save the map location for corpse, gravestone */ 2659 /* save the map location for corpse, gravestone */
2657 x = op->x; 2660 x = op->x;
2789 * exp loss on the stone. 2792 * exp loss on the stone.
2790 */ 2793 */
2791 tmp = arch_to_object (archetype::find ("gravestone")); 2794 tmp = arch_to_object (archetype::find ("gravestone"));
2792 tmp->name = format ("%s's gravestone", &op->name); 2795 tmp->name = format ("%s's gravestone", &op->name);
2793 tmp->name_pl = format ("%s's gravestones", &op->name); 2796 tmp->name_pl = format ("%s's gravestones", &op->name);
2794 tmp->msg = format ("RIP\nHere rests the hero %s the %s,\nwho was killed\nby %s.\n", &op->name, op->contr->title, op->contr->killer_name ()); 2797 tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n",
2798 &op->name, op->contr->title, op->contr->killer_name ());
2795 tmp->x = op->x, tmp->y = op->y; 2799 tmp->x = op->x, tmp->y = op->y;
2796 insert_ob_in_map (tmp, op->map, NULL, 0); 2800 insert_ob_in_map (tmp, op->map, NULL, 0);
2797 2801
2798 /**************************************/ 2802 /**************************************/
2799 /* */ 2803 /* */
2887 if (will_kill_again & (1 << at)) 2891 if (will_kill_again & (1 << at))
2888 force->resist[at] = 100; 2892 force->resist[at] = 100;
2889 2893
2890 insert_ob_in_ob (force, op); 2894 insert_ob_in_ob (force, op);
2891 op->update_stats (); 2895 op->update_stats ();
2892
2893 } 2896 }
2894 2897
2895 new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); 2898 new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED.");
2896} 2899}
2897 2900
2998} 3001}
2999 3002
3000void 3003void
3001make_visible (object *op) 3004make_visible (object *op)
3002{ 3005{
3003 op->hide = 0; 3006 op->flag [FLAG_HIDDEN] = 0;
3004 op->invisible = 0; 3007 op->invisible = 0;
3005 3008
3006 if (op->type == PLAYER) 3009 if (op->type == PLAYER)
3007 { 3010 {
3008 op->contr->tmp_invis = 0; 3011 op->contr->tmp_invis = 0;
3200 3203
3201 /* only the viewable area the player sees is updated by LOS 3204 /* only the viewable area the player sees is updated by LOS
3202 * code, so we need to restrict ourselves to that range of values 3205 * code, so we need to restrict ourselves to that range of values
3203 * for any meaningful values. 3206 * for any meaningful values.
3204 */ 3207 */
3205 if (abs (dx) <= (pl->contr->ns->mapx / 2) && 3208 if (pl->contr->blocked_los (dx, dy) != LOS_BLOCKED)
3206 abs (dy) <= (pl->contr->ns->mapy / 2) &&
3207 !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)])
3208 return 1; 3209 return 1;
3209 3210
3210 op = op->more; 3211 op = op->more;
3211 } 3212 }
3212 3213
3229 3230
3230 if (op->contr && op->contr->tmp_invis == 0) 3231 if (op->contr && op->contr->tmp_invis == 0)
3231 return 0; 3232 return 0;
3232 3233
3233 /* If monsters, they should become visible */ 3234 /* If monsters, they should become visible */
3234 if (op->hide || !op->contr || (op->contr && op->contr->tmp_invis)) 3235 if (op->flag [FLAG_HIDDEN] || !op->contr || (op->contr && op->contr->tmp_invis))
3235 { 3236 {
3236 new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->hide ? "unhidden" : "visible"); 3237 new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->flag [FLAG_HIDDEN] ? "unhidden" : "visible");
3237 return 1; 3238 return 1;
3238 } 3239 }
3239 } 3240 }
3240 3241
3241 return 0; 3242 return 0;
3478 3479
3479 int dx, dy; 3480 int dx, dy;
3480 if (!adjacent_map (map, ns->current_map, &dx, &dy)) 3481 if (!adjacent_map (map, ns->current_map, &dx, &dy))
3481 return 0; 3482 return 0;
3482 3483
3483 x += dx - ns->current_x + ns->mapx / 2; 3484 x += dx - ns->current_x;
3484 y += dy - ns->current_y + ns->mapy / 2; 3485 y += dy - ns->current_y;
3485 3486
3486 if (!IN_RANGE_EXC (x, 0, ns->mapx) || !IN_RANGE_EXC (y, 0, ns->mapy))
3487 return 0;
3488
3489 return 100 - blocked_los [x][y]; 3487 return 100 - blocked_los (x, y);
3490} 3488}
3491 3489
3492void 3490void
3493player::infobox (const char *title, const char *msg, int color) 3491player::infobox (const char *title, const char *msg, int color)
3494{ 3492{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines