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.237 by root, Thu Nov 5 15:18:26 2009 UTC vs.
Revision 1.249 by root, Sun Nov 29 17:41:08 2009 UTC

20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25//+GPL
26
25#include <global.h> 27#include <global.h>
26#include <sproto.h> 28#include <sproto.h>
27#include <sounds.h> 29#include <sounds.h>
28#include <living.h> 30#include <living.h>
29#include <object.h> 31#include <object.h>
105 ob->race = ob->arch->race; 107 ob->race = ob->arch->race;
106 108
107 ob->update_weight (); 109 ob->update_weight ();
108 link_skills (); 110 link_skills ();
109 111
110 CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER);
111
112 assign (title, ob->arch->object::name); 112 assign (title, ob->arch->object::name);
113 113
114 /* if it's a dragon player, set the correct title here */ 114 /* if it's a dragon player, set the correct title here */
115 if (is_dragon_pl (ob)) 115 if (is_dragon_pl (ob))
116 { 116 {
168 observe = viewpoint = ob; 168 observe = viewpoint = ob;
169 169
170 deactivate (); 170 deactivate ();
171} 171}
172 172
173//-GPL
174
173// the need for this function can be explained 175// the need for this function can be explained
174// by load_object not returning the object 176// by load_object not returning the object
175void 177void
176player::set_object (object *op) 178player::set_object (object *op)
177{ 179{
223{ 225{
224 viewpoint = op ? op : (object *)observe; 226 viewpoint = op ? op : (object *)observe;
225 do_los = 1; 227 do_los = 1;
226} 228}
227 229
230//+GPL
231
228player::player () 232player::player ()
229{ 233{
230 /* There are some elements we want initialised to non zero value - 234 /* There are some elements we want initialised to non zero value -
231 * we deal with that below this point. 235 * we deal with that below this point.
232 */ 236 */
267{ 271{
268 /* Clear item stack */ 272 /* Clear item stack */
269 free (stack_items); 273 free (stack_items);
270} 274}
271 275
276/*
277 * get_player_archetype() return next player archetype from archetype
278 * list. Not very efficient routine, but used only creating new players.
279 * Note: there MUST be at least one player archetype!
280 */
281static archetype *
282get_player_archetype (archetype *at)
283{
284 // archetypes could have been reloaded
285 archetype *nat = at ? archetype::find (at->archname) : archetypes [0];
286
287 if (!nat)
288 return at;
289
290 archvec::iterator i = archetypes.find (nat);
291
292 for (;;)
293 {
294 if (++i == archetypes.end ())
295 i = archetypes.begin ();
296 else if (*i == at)
297 cleanup ("not a single player archetype found");
298
299 if ((*i)->type == PLAYER)
300 return *i;
301 }
302}
303
272/* Tries to add player on the connection passed in ns. 304/* Tries to add player on the connection passed in ns.
273 * All we can really get in this is some settings like host and display 305 * All we can really get in this is some settings like host and display
274 * mode. 306 * mode.
275 */ 307 */
276player * 308player *
277player::create () 309player::create ()
278{ 310{
279 player *pl = new player; 311 player *pl = new player;
280 312
281 pl->set_object (arch_to_object (get_player_archetype (0))); 313 pl->set_object (get_player_archetype (0)->instance ());
282 314
283 pl->ob->roll_stats (); 315 pl->ob->roll_stats ();
284 pl->ob->stats.wc = 2; 316 pl->ob->stats.wc = 2;
285 pl->ob->run_away = 25; /* Then we panick... */ 317 pl->ob->run_away = 25; /* Then we panick... */
286 318
287 set_first_map (pl->ob); 319 set_first_map (pl->ob);
288 320
289 return pl; 321 return pl;
290}
291
292/*
293 * get_player_archetype() return next player archetype from archetype
294 * list. Not very efficient routine, but used only creating new players.
295 * Note: there MUST be at least one player archetype!
296 */
297archetype *
298get_player_archetype (archetype *at)
299{
300 // archetypes could have been reloaded
301 archetype *nat = at ? archetype::find (at->archname) : archetypes [0];
302
303 if (!nat)
304 return at;
305
306 archvec::iterator i = archetypes.find (nat);
307
308 for (;;)
309 {
310 if (++i == archetypes.end ())
311 i = archetypes.begin ();
312 else if (*i == at)
313 cleanup ("not a single player archetype found");
314
315 if ((*i)->type == PLAYER)
316 return *i;
317 }
318} 322}
319 323
320object * 324object *
321get_nearest_player (object *mon) 325get_nearest_player (object *mon)
322{ 326{
631 send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "What is the password?\n:"); 635 send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "What is the password?\n:");
632} 636}
633 637
634/* This rolls four 1-6 rolls and sums the best 3 of the 4. */ 638/* This rolls four 1-6 rolls and sums the best 3 of the 4. */
635static int 639static int
636roll_stat (void) 640roll_stat ()
637{ 641{
638 int a[4], i, j, k; 642 int a[4], i, j, k;
639 643
640 for (i = 0; i < 4; i++) 644 for (i = 0; i < 4; i++)
641 a[i] = (int) rndm (6) + 1; 645 a[i] = (int) rndm (6) + 1;
738player::chargen_race_done () 742player::chargen_race_done ()
739{ 743{
740 /* this must before then initial items are given */ 744 /* this must before then initial items are given */
741 esrv_new_player (ob->contr); 745 esrv_new_player (ob->contr);
742 746
743 treasurelist *tl = treasurelist::find ("starting_wealth"); 747 treasurelist *tl = treasurelist::find (shstr_starting_wealth);
744 if (tl) 748 if (tl)
745 create_treasure (tl, ob, 0, 0, 0); 749 create_treasure (tl, ob, 0, 0, 0);
746 750
747 INVOKE_PLAYER (BIRTH, ob->contr); 751 INVOKE_PLAYER (BIRTH, ob->contr);
748 INVOKE_PLAYER (LOGIN, ob->contr); 752 INVOKE_PLAYER (LOGIN, ob->contr);
801 ob->stats.hp = ob->stats.maxhp; 805 ob->stats.hp = ob->stats.maxhp;
802 ob->stats.sp = ob->stats.maxsp; 806 ob->stats.sp = ob->stats.maxsp;
803 ob->stats.grace = 0; 807 ob->stats.grace = 0;
804} 808}
805 809
806void 810static void
807flee_player (object *op) 811flee_player (object *op)
808{ 812{
809 int dir, diff; 813 int dir, diff;
810 rv_vector rv; 814 rv_vector rv;
811 815
861 if (op->move_type & MOVE_FLYING) 865 if (op->move_type & MOVE_FLYING)
862 return 1; 866 return 1;
863 867
864 next = op->below; 868 next = op->below;
865 869
866 int cnt = MAX_ITEM_PER_DROP; 870 int cnt = MAX_ITEM_PER_ACTION;
867#define CHK_PICK_PICKUP do { pick_up (op, tmp); cnt--; } while (0) 871#define CHK_PICK_PICKUP do { pick_up (op, tmp); cnt--; } while (0)
868 872
869 /* loop while there are items on the floor that are not marked as 873 /* loop while there are items on the floor that are not marked as
870 * destroyed */ 874 * destroyed */
871 while (next && !next->destroyed ()) 875 while (next && !next->destroyed ())
897 if (op->contr->mode & PU_DEBUG) 901 if (op->contr->mode & PU_DEBUG)
898 { 902 {
899 /* some debugging code to figure out item information */ 903 /* some debugging code to figure out item information */
900 const char *str = tmp->name 904 const char *str = tmp->name
901 ? format ("item name: %s item type: %d weight/value: %d", 905 ? format ("item name: %s item type: %d weight/value: %d",
902 &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))) 906 &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * max (tmp->nrof, 1))))
903 : format ("item name: %s item type: %d weight/value: %d", 907 : format ("item name: %s item type: %d weight/value: %d",
904 &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); 908 &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * max (tmp->nrof, 1))));
905 909
906 new_draw_info (NDI_UNIQUE, 0, op, str); 910 new_draw_info (NDI_UNIQUE, 0, op, str);
907 } 911 }
908 912
909 if (op->contr->mode & PU_INHIBIT) 913 if (op->contr->mode & PU_INHIBIT)
996 continue; 1000 continue;
997 } 1001 }
998 1002
999 /* wands/staves/rods/horns */ 1003 /* wands/staves/rods/horns */
1000 if (op->contr->mode & PU_MAGIC_DEVICE) 1004 if (op->contr->mode & PU_MAGIC_DEVICE)
1001 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1005 if (tmp->type == WAND
1006 || tmp->type == ROD
1007 || tmp->type == HORN
1008 || tmp->type == POWER_CRYSTAL)
1002 { 1009 {
1003 CHK_PICK_PICKUP; 1010 CHK_PICK_PICKUP;
1004 continue; 1011 continue;
1005 } 1012 }
1006 1013
1007 /* pick up all magical items */ 1014 /* pick up all magical items */
1008 if (op->contr->mode & PU_MAGICAL) 1015 if (op->contr->mode & PU_MAGICAL)
1009 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) 1016 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL)
1017 && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1010 { 1018 {
1011 CHK_PICK_PICKUP; 1019 CHK_PICK_PICKUP;
1012 continue; 1020 continue;
1013 } 1021 }
1014 1022
1021 } 1029 }
1022 } 1030 }
1023 1031
1024 /* rings & amulets - talismans seems to be typed AMULET */ 1032 /* rings & amulets - talismans seems to be typed AMULET */
1025 if (op->contr->mode & PU_JEWELS) 1033 if (op->contr->mode & PU_JEWELS)
1026 if (tmp->type == RING || tmp->type == AMULET) 1034 if (tmp->type == RING
1035 || tmp->type == AMULET
1036 || tmp->type == GIRDLE
1037 || tmp->type == SKILL_TOOL)
1027 { 1038 {
1028 CHK_PICK_PICKUP; 1039 CHK_PICK_PICKUP;
1029 continue; 1040 continue;
1030 } 1041 }
1031 1042
1080 CHK_PICK_PICKUP; 1091 CHK_PICK_PICKUP;
1081 continue; 1092 continue;
1082 } 1093 }
1083 1094
1084 if (op->contr->mode & PU_GLOVES) 1095 if (op->contr->mode & PU_GLOVES)
1085 if (tmp->type == GLOVES) 1096 if (tmp->type == GLOVES || tmp->type == BRACERS)
1086 { 1097 {
1087 CHK_PICK_PICKUP; 1098 CHK_PICK_PICKUP;
1088 continue; 1099 continue;
1089 } 1100 }
1090 1101
1140 fprintf (stderr, "%s", tmp->name); 1151 fprintf (stderr, "%s", tmp->name);
1141 } 1152 }
1142 else 1153 else
1143 fprintf (stderr, "%s", tmp->arch->archname); 1154 fprintf (stderr, "%s", tmp->arch->archname);
1144 fprintf (stderr, ",%d] = ", tmp->type); 1155 fprintf (stderr, ",%d] = ", tmp->type);
1145 fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); 1156 fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * max (tmp->nrof, 1))));
1146#endif 1157#endif
1147 CHK_PICK_PICKUP; 1158 CHK_PICK_PICKUP;
1148 continue; 1159 continue;
1149 } 1160 }
1150 } /* the new pickup model */ 1161 } /* the new pickup model */
1151 } 1162 }
1152 1163
1153 return !stop; 1164 return !stop;
1154} 1165}
1155 1166
1167/* routine for both players and monsters. We call this when
1168 * there is a possibility for our action distrubing our hiding
1169 * place or invisiblity spell. Artefact invisiblity causes
1170 * "noise" instead. If we arent invisible to begin with, we
1171 * return 0.
1172 */
1173static int
1174action_makes_visible (object *op)
1175{
1176 if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE))
1177 {
1178 if (QUERY_FLAG (op, FLAG_MAKE_INVIS))
1179 {
1180 // artefact invisibility is permanent, but we still make noise
1181 // this is important for game-balance.
1182 if (op->contr)
1183 op->make_noise ();
1184
1185 return 0;
1186 }
1187
1188 if (op->contr && op->contr->tmp_invis == 0)
1189 return 0;
1190
1191 /* If monsters, they should become visible */
1192 if (op->flag [FLAG_HIDDEN] || !op->contr || (op->contr && op->contr->tmp_invis))
1193 {
1194 new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->flag [FLAG_HIDDEN] ? "unhidden" : "visible");
1195 return 1;
1196 }
1197 }
1198
1199 return 0;
1200}
1201
1156/* 1202/*
1157 * Find an arrow in the inventory and after that 1203 * Find an arrow in the inventory and after that
1158 * in the right type container (quiver). Pointer to the 1204 * in the right type container (quiver). Pointer to the
1159 * found object is returned. 1205 * found object is returned.
1160 */ 1206 */
1161object * 1207static object *
1162find_arrow (object *op, const char *type) 1208find_arrow (object *op, const char *type)
1163{ 1209{
1164 for (object *tmp = op->inv; tmp; tmp = tmp->below) 1210 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1165 if (tmp->type == ARROW && !strcmp (&tmp->race, type)) 1211 if (tmp->type == ARROW && !strcmp (&tmp->race, type))
1166 return splay (tmp); 1212 return splay (tmp);
1180 * Similar to find_arrow, but looks for (roughly) the best arrow to use 1226 * Similar to find_arrow, but looks for (roughly) the best arrow to use
1181 * against the target. A full test is not performed, simply a basic test 1227 * against the target. A full test is not performed, simply a basic test
1182 * of resistances. The archer is making a quick guess at what he sees down 1228 * of resistances. The archer is making a quick guess at what he sees down
1183 * the hall. Failing that it does it's best to pick the highest plus arrow. 1229 * the hall. Failing that it does it's best to pick the highest plus arrow.
1184 */ 1230 */
1185object * 1231static object *
1186find_better_arrow (object *op, object *target, shstr_cmp type, int *better) 1232find_better_arrow (object *op, object *target, shstr_cmp type, int *better)
1187{ 1233{
1188 object *tmp = NULL, *arrow, *ntmp; 1234 object *tmp = NULL, *arrow, *ntmp;
1189 int attacknum, attacktype, betterby = 0, i; 1235 int attacknum, attacktype, betterby = 0, i;
1190 1236
1259 * find_better_arrow to find a decent arrow to use. 1305 * find_better_arrow to find a decent arrow to use.
1260 * op = the shooter 1306 * op = the shooter
1261 * type = bow->race 1307 * type = bow->race
1262 * dir = fire direction 1308 * dir = fire direction
1263 */ 1309 */
1264object * 1310static object *
1265pick_arrow_target (object *op, shstr_cmp type, int dir) 1311pick_arrow_target (object *op, shstr_cmp type, int dir)
1266{ 1312{
1267 object *tmp = NULL; 1313 object *tmp = NULL;
1268 maptile *m; 1314 maptile *m;
1269 int i, mflags, found, number; 1315 int i, mflags, found, number;
1484 * but monsters can't. Putting that code here 1530 * but monsters can't. Putting that code here
1485 * makes the fire_bow code much cleaner. 1531 * makes the fire_bow code much cleaner.
1486 * this function should only be called if 'op' is a player, 1532 * this function should only be called if 'op' is a player,
1487 * hence the function name. 1533 * hence the function name.
1488 */ 1534 */
1489int 1535static int
1490player_fire_bow (object *op, int dir) 1536player_fire_bow (object *op, int dir)
1491{ 1537{
1492 int ret; 1538 int ret;
1493 1539
1494 if (op->contr->bowtype == bow_bestarrow) 1540 if (op->contr->bowtype == bow_bestarrow)
1522} 1568}
1523 1569
1524/* Fires a misc (wand/rod/horn) object in 'dir'. 1570/* Fires a misc (wand/rod/horn) object in 'dir'.
1525 * Broken apart from 'fire' to keep it more readable. 1571 * Broken apart from 'fire' to keep it more readable.
1526 */ 1572 */
1527void 1573static void
1528fire_misc_object (object *op, int dir) 1574fire_misc_object (object *op, int dir)
1529{ 1575{
1530 object *item = op->contr->ranged_ob; 1576 object *item = op->contr->ranged_ob;
1531 1577
1532 if (!item) 1578 if (!item)
1554 return; 1600 return;
1555 } 1601 }
1556 } 1602 }
1557 else if (item->type == ROD || item->type == HORN) 1603 else if (item->type == ROD || item->type == HORN)
1558 { 1604 {
1559 sint16 spell_sp = MAX (item->inv->stats.sp, item->inv->stats.grace); 1605 sint16 spell_sp = max (item->inv->stats.sp, item->inv->stats.grace);
1560 1606
1561 // using the maximum of the rods charge allows at least one spell cast 1607 // using the maximum of the rods charge allows at least one spell cast
1562 // for a rod or horn, this fixes some broken rods. 1608 // for a rod or horn, this fixes some broken rods.
1563 if (item->stats.hp < MIN (spell_sp, item->stats.maxhp)) 1609 if (item->stats.hp < min (spell_sp, item->stats.maxhp))
1564 { 1610 {
1565 op->contr->play_sound (sound_find ("wand_poof")); 1611 op->contr->play_sound (sound_find ("wand_poof"));
1566 1612
1567 if (item->type == ROD) 1613 if (item->type == ROD)
1568 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); 1614 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0));
1977} 2023}
1978 2024
1979bool 2025bool
1980move_player (object *op, int dir) 2026move_player (object *op, int dir)
1981{ 2027{
1982 int pick;
1983
1984 if (!op->map || op->map->in_memory != MAP_ACTIVE) 2028 if (!op->map || op->map->in_memory != MAP_ACTIVE)
1985 return 0; 2029 return 0;
1986 2030
1987 /* Sanity check: make sure dir is valid */ 2031 /* Sanity check: make sure dir is valid */
1988 if ((dir < 0) || (dir >= 9)) 2032 if ((dir < 0) || (dir >= 9))
1999 2043
2000 if (op->flag [FLAG_HIDDEN]) 2044 if (op->flag [FLAG_HIDDEN])
2001 do_hidden_move (op); 2045 do_hidden_move (op);
2002 2046
2003 bool retval; 2047 bool retval;
2048 int pick = 0;
2004 2049
2005 if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) 2050 if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir)))
2006 retval = RESULT_INT (0); 2051 retval = RESULT_INT (0);
2007 else if (op->contr->fire_on) 2052 else if (op->contr->fire_on)
2008 retval = fire (op, dir); 2053 retval = fire (op, dir);
2065 return move_player (op, op->direction); 2110 return move_player (op, op->direction);
2066 2111
2067 return false; 2112 return false;
2068} 2113}
2069 2114
2070int 2115static int
2071save_life (object *op) 2116save_life (object *op)
2072{ 2117{
2073 if (!QUERY_FLAG (op, FLAG_LIFESAVE)) 2118 if (!QUERY_FLAG (op, FLAG_LIFESAVE))
2074 return 0; 2119 return 0;
2075 2120
2122void 2167void
2123object::drop_unpaid_items () 2168object::drop_unpaid_items ()
2124{ 2169{
2125 if (!flag [FLAG_REMOVED]) 2170 if (!flag [FLAG_REMOVED])
2126 ::drop_unpaid_items (inv, this); 2171 ::drop_unpaid_items (inv, this);
2127}
2128
2129/*
2130 * Returns pointer a static string containing gravestone text
2131 * Moved from apply.c to player.c - player.c is what
2132 * actually uses this function. player.c may not be quite the
2133 * best, a misc file for object actions is probably better,
2134 * but there isn't one in the server directory.
2135 */
2136const char *
2137gravestone_text (object *op)
2138{
2139 static dynbuf_text buf;
2140
2141 buf << "---- R.I.P. ----\n\n"
2142 << op->name;
2143
2144 if (op->type == PLAYER)
2145 buf << " the " << op->contr->title;
2146
2147 buf << "\n\n";
2148
2149 buf << "who was level ";
2150 buf << (sint32)op->level << "\n\n" // OO breakdown
2151 << " when " << (op->contr ? "killed" : "died") << "\n\n";
2152
2153 if (op->type == PLAYER)
2154 buf << "by " << op->contr->killer_name () << ".\n\n";
2155
2156 {
2157 static char buf2[128];
2158 time_t now = time (NULL);
2159 strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now));
2160 buf << buf2;
2161 }
2162
2163 return buf;
2164} 2172}
2165 2173
2166void 2174void
2167do_some_living (object *op) 2175do_some_living (object *op)
2168{ 2176{
2423 return; 2431 return;
2424 2432
2425 dynbuf_text deathtab; 2433 dynbuf_text deathtab;
2426 2434
2427 /* restore player */ 2435 /* restore player */
2428 at = archetype::find ("poisoning"); 2436 at = archetype::find (shstr_poisoning);
2429 if (object *tmp = present_arch_in_ob (at, op)) 2437 if (object *tmp = present_arch_in_ob (at, op))
2430 { 2438 {
2431 tmp->destroy (); 2439 tmp->destroy ();
2432 deathtab << "Your body feels cleansed...\r"; 2440 deathtab << "Your body feels cleansed...\r";
2433 } 2441 }
2434 2442
2435 at = archetype::find ("confusion"); 2443 at = archetype::find (shstr_confusion);
2436 if (object *tmp = present_arch_in_ob (at, op)) 2444 if (object *tmp = present_arch_in_ob (at, op))
2437 { 2445 {
2438 tmp->destroy (); 2446 tmp->destroy ();
2439 deathtab << "Your mind feels clearer...\r"; 2447 deathtab << "Your mind feels clearer...\r";
2440 } 2448 }
2467 if (op_on_battleground (op, &x, &y)) 2475 if (op_on_battleground (op, &x, &y))
2468 { 2476 {
2469 deathtab << "You almost died in combat, but local medics have saved your life...\r"; 2477 deathtab << "You almost died in combat, but local medics have saved your life...\r";
2470 2478
2471 /* create a bodypart-trophy to make the winner happy */ 2479 /* create a bodypart-trophy to make the winner happy */
2472 if (object *tmp = arch_to_object (archetype::find ("finger"))) 2480 object *tmp = archetype::find (shstr_finger)->instance ();
2473 { 2481
2474 tmp->name = format ("%s's finger" , &op->name); 2482 tmp->name = format ("%s's finger" , &op->name);
2475 tmp->name_pl = format ("%s's fingers", &op->name); 2483 tmp->name_pl = format ("%s's fingers", &op->name);
2476 tmp->msg = format ( 2484 tmp->msg = format (
2477 "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", 2485 "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n",
2478 &op->name, op->contr->title, 2486 &op->name, op->contr->title,
2479 (int)op->level, 2487 (int)op->level,
2480 op->contr->killer_name () 2488 op->contr->killer_name ()
2481 ); 2489 );
2482 tmp->value = 0, tmp->type = 0; 2490 tmp->value = 0, tmp->type = 0;
2483 tmp->materialname = "organics"; 2491 tmp->material = name_to_material (shstr_organic);
2484 tmp->insert_at (op, tmp); 2492 tmp->insert_at (op, tmp);
2485 }
2486 2493
2487 /* teleport defeated player to new destination */ 2494 /* teleport defeated player to new destination */
2488 transfer_ob (op, x, y, 0, NULL); 2495 transfer_ob (op, x, y, 0, NULL);
2489 op->contr->braced = 0; 2496 op->contr->braced = 0;
2490 2497
2552 lost_a_stat = 1; 2559 lost_a_stat = 1;
2553 } 2560 }
2554 else 2561 else
2555 { 2562 {
2556 /* deplete a stat */ 2563 /* deplete a stat */
2557 archetype *deparch = archetype::find ("depletion"); 2564 archetype *deparch = archetype::find (shstr_depletion);
2558 object *dep; 2565 object *dep;
2559 2566
2560 dep = present_arch_in_ob (deparch, op); 2567 dep = present_arch_in_ob (deparch, op);
2561 if (!dep) 2568 if (!dep)
2562 { 2569 {
2563 dep = arch_to_object (deparch); 2570 dep = deparch->instance ();
2564 insert_ob_in_ob (dep, op); 2571 insert_ob_in_ob (dep, op);
2565 } 2572 }
2566 lose_this_stat = 1; 2573 lose_this_stat = 1;
2567 if (settings.balanced_stat_loss) 2574 if (settings.balanced_stat_loss)
2568 { 2575 {
2634#endif 2641#endif
2635 2642
2636 /* Put a gravestone up where the character 'almost' died. List the 2643 /* Put a gravestone up where the character 'almost' died. List the
2637 * exp loss on the stone. 2644 * exp loss on the stone.
2638 */ 2645 */
2639 tmp = arch_to_object (archetype::find ("gravestone")); 2646 tmp = archetype::find (shstr_gravestone)->instance ();
2640 tmp->name = format ("%s's gravestone", &op->name); 2647 tmp->name = format ("%s's gravestone", &op->name);
2641 tmp->name_pl = format ("%s's gravestones", &op->name); 2648 tmp->name_pl = format ("%s's gravestones", &op->name);
2642 tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n", 2649 tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n",
2643 &op->name, op->contr->title, op->contr->killer_name ()); 2650 &op->name, op->contr->title, op->contr->killer_name ());
2644 tmp->x = op->x, tmp->y = op->y; 2651 tmp->x = op->x, tmp->y = op->y;
2699 } 2706 }
2700 2707
2701 op->contr->infobox (MSG_CHANNEL ("death"), deathtab); 2708 op->contr->infobox (MSG_CHANNEL ("death"), deathtab);
2702} 2709}
2703 2710
2704void 2711static void
2705loot_object (object *op) 2712loot_object (object *op)
2706{ /* Grab and destroy some treasure */ 2713{ /* Grab and destroy some treasure */
2707 object *tmp, *tmp2, *next; 2714 object *tmp, *tmp2, *next;
2708 2715
2709 op->close_container (); /* close open sack first */ 2716 op->close_container (); /* close open sack first */
2740 * fix_weight(): Check recursively the weight of all players, and fix 2747 * fix_weight(): Check recursively the weight of all players, and fix
2741 * what needs to be fixed. Refresh windows and fix speed if anything 2748 * what needs to be fixed. Refresh windows and fix speed if anything
2742 * was changed. 2749 * was changed.
2743 */ 2750 */
2744void 2751void
2745fix_weight (void) 2752fix_weight ()
2746{ 2753{
2747 for_all_players (pl) 2754 for_all_players (pl)
2748 { 2755 {
2749 sint32 old = pl->ob->carrying; 2756 sint32 old = pl->ob->carrying;
2750 2757
2757 } 2764 }
2758 } 2765 }
2759} 2766}
2760 2767
2761void 2768void
2762fix_luck (void) 2769fix_luck ()
2763{ 2770{
2764 for_all_players (pl) 2771 for_all_players (pl)
2765 if (!pl->ob->contr->ns->state) 2772 if (!pl->ob->contr->ns->state)
2766 pl->ob->change_luck (0); 2773 pl->ob->change_luck (0);
2767} 2774}
3011 } 3018 }
3012 3019
3013 return 0; 3020 return 0;
3014} 3021}
3015 3022
3016/* routine for both players and monsters. We call this when
3017 * there is a possibility for our action distrubing our hiding
3018 * place or invisiblity spell. Artefact invisiblity causes
3019 * "noise" instead. If we arent invisible to begin with, we
3020 * return 0.
3021 */
3022int
3023action_makes_visible (object *op)
3024{
3025 if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE))
3026 {
3027 if (QUERY_FLAG (op, FLAG_MAKE_INVIS))
3028 {
3029 // artefact invisibility is permanent, but we still make noise
3030 // this is important for game-balance.
3031 if (op->contr)
3032 op->make_noise ();
3033
3034 return 0;
3035 }
3036
3037 if (op->contr && op->contr->tmp_invis == 0)
3038 return 0;
3039
3040 /* If monsters, they should become visible */
3041 if (op->flag [FLAG_HIDDEN] || !op->contr || (op->contr && op->contr->tmp_invis))
3042 {
3043 new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->flag [FLAG_HIDDEN] ? "unhidden" : "visible");
3044 return 1;
3045 }
3046 }
3047
3048 return 0;
3049}
3050
3051/* op_on_battleground - checks if the given object op (usually 3023/* op_on_battleground - checks if the given object op (usually
3052 * a player) is standing on a valid battleground-tile, 3024 * a player) is standing on a valid battleground-tile,
3053 * function returns TRUE/FALSE. If true x, y returns the battleground 3025 * function returns TRUE/FALSE. If true x, y returns the battleground
3054 * -exit-coord. (and if x, y not NULL) 3026 * -exit-coord. (and if x, y not NULL)
3055 * 19 March 2005 - josh@woosworld.net modifed to check if the battleground also has slaying, maxhp, and maxsp set 3027 * 19 March 2005 - josh@woosworld.net modifed to check if the battleground also has slaying, maxhp, and maxsp set
3252 new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, who, item->msg); 3224 new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, who, item->msg);
3253 } 3225 }
3254 else 3226 else
3255 { 3227 {
3256 /* generate misc. treasure */ 3228 /* generate misc. treasure */
3257 tmp = arch_to_object (tr->item); 3229 tmp = tr->item->instance ();
3258 new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); 3230 new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp));
3259 who->insert (tmp); 3231 who->insert (tmp);
3260 } 3232 }
3261} 3233}
3262 3234
3275 3247
3276 if (pl->ranged_ob == ob) 3248 if (pl->ranged_ob == ob)
3277 pl->ranged_ob = 0; 3249 pl->ranged_ob = 0;
3278} 3250}
3279 3251
3252//-GPL
3253
3280sint8 3254sint8
3281player::darkness_at (maptile *map, int x, int y) const 3255player::darkness_at (maptile *map, int x, int y) const
3282{ 3256{
3283 if (!ns) 3257 if (!ns)
3284 return LOS_BLOCKED; 3258 return LOS_BLOCKED;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines