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.240 by root, Fri Nov 6 12:49:19 2009 UTC vs.
Revision 1.243 by root, Sat Nov 7 18:30:06 2009 UTC

744player::chargen_race_done () 744player::chargen_race_done ()
745{ 745{
746 /* this must before then initial items are given */ 746 /* this must before then initial items are given */
747 esrv_new_player (ob->contr); 747 esrv_new_player (ob->contr);
748 748
749 treasurelist *tl = treasurelist::find ("starting_wealth"); 749 treasurelist *tl = treasurelist::find (shstr_starting_wealth);
750 if (tl) 750 if (tl)
751 create_treasure (tl, ob, 0, 0, 0); 751 create_treasure (tl, ob, 0, 0, 0);
752 752
753 INVOKE_PLAYER (BIRTH, ob->contr); 753 INVOKE_PLAYER (BIRTH, ob->contr);
754 INVOKE_PLAYER (LOGIN, ob->contr); 754 INVOKE_PLAYER (LOGIN, ob->contr);
807 ob->stats.hp = ob->stats.maxhp; 807 ob->stats.hp = ob->stats.maxhp;
808 ob->stats.sp = ob->stats.maxsp; 808 ob->stats.sp = ob->stats.maxsp;
809 ob->stats.grace = 0; 809 ob->stats.grace = 0;
810} 810}
811 811
812void 812static void
813flee_player (object *op) 813flee_player (object *op)
814{ 814{
815 int dir, diff; 815 int dir, diff;
816 rv_vector rv; 816 rv_vector rv;
817 817
903 if (op->contr->mode & PU_DEBUG) 903 if (op->contr->mode & PU_DEBUG)
904 { 904 {
905 /* some debugging code to figure out item information */ 905 /* some debugging code to figure out item information */
906 const char *str = tmp->name 906 const char *str = tmp->name
907 ? format ("item name: %s item type: %d weight/value: %d", 907 ? format ("item name: %s item type: %d weight/value: %d",
908 &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))) 908 &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * max (tmp->nrof, 1))))
909 : format ("item name: %s item type: %d weight/value: %d", 909 : format ("item name: %s item type: %d weight/value: %d",
910 &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); 910 &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * max (tmp->nrof, 1))));
911 911
912 new_draw_info (NDI_UNIQUE, 0, op, str); 912 new_draw_info (NDI_UNIQUE, 0, op, str);
913 } 913 }
914 914
915 if (op->contr->mode & PU_INHIBIT) 915 if (op->contr->mode & PU_INHIBIT)
1146 fprintf (stderr, "%s", tmp->name); 1146 fprintf (stderr, "%s", tmp->name);
1147 } 1147 }
1148 else 1148 else
1149 fprintf (stderr, "%s", tmp->arch->archname); 1149 fprintf (stderr, "%s", tmp->arch->archname);
1150 fprintf (stderr, ",%d] = ", tmp->type); 1150 fprintf (stderr, ",%d] = ", tmp->type);
1151 fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); 1151 fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * max (tmp->nrof, 1))));
1152#endif 1152#endif
1153 CHK_PICK_PICKUP; 1153 CHK_PICK_PICKUP;
1154 continue; 1154 continue;
1155 } 1155 }
1156 } /* the new pickup model */ 1156 } /* the new pickup model */
1300 * find_better_arrow to find a decent arrow to use. 1300 * find_better_arrow to find a decent arrow to use.
1301 * op = the shooter 1301 * op = the shooter
1302 * type = bow->race 1302 * type = bow->race
1303 * dir = fire direction 1303 * dir = fire direction
1304 */ 1304 */
1305object * 1305static object *
1306pick_arrow_target (object *op, shstr_cmp type, int dir) 1306pick_arrow_target (object *op, shstr_cmp type, int dir)
1307{ 1307{
1308 object *tmp = NULL; 1308 object *tmp = NULL;
1309 maptile *m; 1309 maptile *m;
1310 int i, mflags, found, number; 1310 int i, mflags, found, number;
1525 * but monsters can't. Putting that code here 1525 * but monsters can't. Putting that code here
1526 * makes the fire_bow code much cleaner. 1526 * makes the fire_bow code much cleaner.
1527 * this function should only be called if 'op' is a player, 1527 * this function should only be called if 'op' is a player,
1528 * hence the function name. 1528 * hence the function name.
1529 */ 1529 */
1530int 1530static int
1531player_fire_bow (object *op, int dir) 1531player_fire_bow (object *op, int dir)
1532{ 1532{
1533 int ret; 1533 int ret;
1534 1534
1535 if (op->contr->bowtype == bow_bestarrow) 1535 if (op->contr->bowtype == bow_bestarrow)
1563} 1563}
1564 1564
1565/* Fires a misc (wand/rod/horn) object in 'dir'. 1565/* Fires a misc (wand/rod/horn) object in 'dir'.
1566 * Broken apart from 'fire' to keep it more readable. 1566 * Broken apart from 'fire' to keep it more readable.
1567 */ 1567 */
1568void 1568static void
1569fire_misc_object (object *op, int dir) 1569fire_misc_object (object *op, int dir)
1570{ 1570{
1571 object *item = op->contr->ranged_ob; 1571 object *item = op->contr->ranged_ob;
1572 1572
1573 if (!item) 1573 if (!item)
1595 return; 1595 return;
1596 } 1596 }
1597 } 1597 }
1598 else if (item->type == ROD || item->type == HORN) 1598 else if (item->type == ROD || item->type == HORN)
1599 { 1599 {
1600 sint16 spell_sp = MAX (item->inv->stats.sp, item->inv->stats.grace); 1600 sint16 spell_sp = max (item->inv->stats.sp, item->inv->stats.grace);
1601 1601
1602 // using the maximum of the rods charge allows at least one spell cast 1602 // using the maximum of the rods charge allows at least one spell cast
1603 // for a rod or horn, this fixes some broken rods. 1603 // for a rod or horn, this fixes some broken rods.
1604 if (item->stats.hp < MIN (spell_sp, item->stats.maxhp)) 1604 if (item->stats.hp < min (spell_sp, item->stats.maxhp))
1605 { 1605 {
1606 op->contr->play_sound (sound_find ("wand_poof")); 1606 op->contr->play_sound (sound_find ("wand_poof"));
1607 1607
1608 if (item->type == ROD) 1608 if (item->type == ROD)
1609 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); 1609 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0));
2018} 2018}
2019 2019
2020bool 2020bool
2021move_player (object *op, int dir) 2021move_player (object *op, int dir)
2022{ 2022{
2023 int pick;
2024
2025 if (!op->map || op->map->in_memory != MAP_ACTIVE) 2023 if (!op->map || op->map->in_memory != MAP_ACTIVE)
2026 return 0; 2024 return 0;
2027 2025
2028 /* Sanity check: make sure dir is valid */ 2026 /* Sanity check: make sure dir is valid */
2029 if ((dir < 0) || (dir >= 9)) 2027 if ((dir < 0) || (dir >= 9))
2040 2038
2041 if (op->flag [FLAG_HIDDEN]) 2039 if (op->flag [FLAG_HIDDEN])
2042 do_hidden_move (op); 2040 do_hidden_move (op);
2043 2041
2044 bool retval; 2042 bool retval;
2043 int pick = 0;
2045 2044
2046 if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) 2045 if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir)))
2047 retval = RESULT_INT (0); 2046 retval = RESULT_INT (0);
2048 else if (op->contr->fire_on) 2047 else if (op->contr->fire_on)
2049 retval = fire (op, dir); 2048 retval = fire (op, dir);
2106 return move_player (op, op->direction); 2105 return move_player (op, op->direction);
2107 2106
2108 return false; 2107 return false;
2109} 2108}
2110 2109
2111int 2110static int
2112save_life (object *op) 2111save_life (object *op)
2113{ 2112{
2114 if (!QUERY_FLAG (op, FLAG_LIFESAVE)) 2113 if (!QUERY_FLAG (op, FLAG_LIFESAVE))
2115 return 0; 2114 return 0;
2116 2115
2163void 2162void
2164object::drop_unpaid_items () 2163object::drop_unpaid_items ()
2165{ 2164{
2166 if (!flag [FLAG_REMOVED]) 2165 if (!flag [FLAG_REMOVED])
2167 ::drop_unpaid_items (inv, this); 2166 ::drop_unpaid_items (inv, this);
2168}
2169
2170/*
2171 * Returns pointer a static string containing gravestone text
2172 * Moved from apply.c to player.c - player.c is what
2173 * actually uses this function. player.c may not be quite the
2174 * best, a misc file for object actions is probably better,
2175 * but there isn't one in the server directory.
2176 */
2177const char *
2178gravestone_text (object *op)
2179{
2180 static dynbuf_text buf;
2181
2182 buf << "---- R.I.P. ----\n\n"
2183 << op->name;
2184
2185 if (op->type == PLAYER)
2186 buf << " the " << op->contr->title;
2187
2188 buf << "\n\n";
2189
2190 buf << "who was level ";
2191 buf << (sint32)op->level << "\n\n" // OO breakdown
2192 << " when " << (op->contr ? "killed" : "died") << "\n\n";
2193
2194 if (op->type == PLAYER)
2195 buf << "by " << op->contr->killer_name () << ".\n\n";
2196
2197 {
2198 static char buf2[128];
2199 time_t now = time (NULL);
2200 strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now));
2201 buf << buf2;
2202 }
2203
2204 return buf;
2205} 2167}
2206 2168
2207void 2169void
2208do_some_living (object *op) 2170do_some_living (object *op)
2209{ 2171{
2464 return; 2426 return;
2465 2427
2466 dynbuf_text deathtab; 2428 dynbuf_text deathtab;
2467 2429
2468 /* restore player */ 2430 /* restore player */
2469 at = archetype::find ("poisoning"); 2431 at = archetype::find (shstr_poisoning);
2470 if (object *tmp = present_arch_in_ob (at, op)) 2432 if (object *tmp = present_arch_in_ob (at, op))
2471 { 2433 {
2472 tmp->destroy (); 2434 tmp->destroy ();
2473 deathtab << "Your body feels cleansed...\r"; 2435 deathtab << "Your body feels cleansed...\r";
2474 } 2436 }
2475 2437
2476 at = archetype::find ("confusion"); 2438 at = archetype::find (shstr_confusion);
2477 if (object *tmp = present_arch_in_ob (at, op)) 2439 if (object *tmp = present_arch_in_ob (at, op))
2478 { 2440 {
2479 tmp->destroy (); 2441 tmp->destroy ();
2480 deathtab << "Your mind feels clearer...\r"; 2442 deathtab << "Your mind feels clearer...\r";
2481 } 2443 }
2508 if (op_on_battleground (op, &x, &y)) 2470 if (op_on_battleground (op, &x, &y))
2509 { 2471 {
2510 deathtab << "You almost died in combat, but local medics have saved your life...\r"; 2472 deathtab << "You almost died in combat, but local medics have saved your life...\r";
2511 2473
2512 /* create a bodypart-trophy to make the winner happy */ 2474 /* create a bodypart-trophy to make the winner happy */
2513 if (object *tmp = arch_to_object (archetype::find ("finger"))) 2475 if (object *tmp = arch_to_object (archetype::find (shstr_finger)))
2514 { 2476 {
2515 tmp->name = format ("%s's finger" , &op->name); 2477 tmp->name = format ("%s's finger" , &op->name);
2516 tmp->name_pl = format ("%s's fingers", &op->name); 2478 tmp->name_pl = format ("%s's fingers", &op->name);
2517 tmp->msg = format ( 2479 tmp->msg = format (
2518 "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", 2480 "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n",
2593 lost_a_stat = 1; 2555 lost_a_stat = 1;
2594 } 2556 }
2595 else 2557 else
2596 { 2558 {
2597 /* deplete a stat */ 2559 /* deplete a stat */
2598 archetype *deparch = archetype::find ("depletion"); 2560 archetype *deparch = archetype::find (shstr_depletion);
2599 object *dep; 2561 object *dep;
2600 2562
2601 dep = present_arch_in_ob (deparch, op); 2563 dep = present_arch_in_ob (deparch, op);
2602 if (!dep) 2564 if (!dep)
2603 { 2565 {
2675#endif 2637#endif
2676 2638
2677 /* Put a gravestone up where the character 'almost' died. List the 2639 /* Put a gravestone up where the character 'almost' died. List the
2678 * exp loss on the stone. 2640 * exp loss on the stone.
2679 */ 2641 */
2680 tmp = arch_to_object (archetype::find ("gravestone")); 2642 tmp = arch_to_object (archetype::find (shstr_gravestone));
2681 tmp->name = format ("%s's gravestone", &op->name); 2643 tmp->name = format ("%s's gravestone", &op->name);
2682 tmp->name_pl = format ("%s's gravestones", &op->name); 2644 tmp->name_pl = format ("%s's gravestones", &op->name);
2683 tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n", 2645 tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n",
2684 &op->name, op->contr->title, op->contr->killer_name ()); 2646 &op->name, op->contr->title, op->contr->killer_name ());
2685 tmp->x = op->x, tmp->y = op->y; 2647 tmp->x = op->x, tmp->y = op->y;
2740 } 2702 }
2741 2703
2742 op->contr->infobox (MSG_CHANNEL ("death"), deathtab); 2704 op->contr->infobox (MSG_CHANNEL ("death"), deathtab);
2743} 2705}
2744 2706
2745void 2707static void
2746loot_object (object *op) 2708loot_object (object *op)
2747{ /* Grab and destroy some treasure */ 2709{ /* Grab and destroy some treasure */
2748 object *tmp, *tmp2, *next; 2710 object *tmp, *tmp2, *next;
2749 2711
2750 op->close_container (); /* close open sack first */ 2712 op->close_container (); /* close open sack first */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines