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.19 by root, Mon Sep 11 23:53:30 2006 UTC vs.
Revision 1.25 by root, Sat Sep 16 22:24:13 2006 UTC

1
2/*
3 * static char *rcsid_player_c =
4 * "$Id: player.C,v 1.19 2006/09/11 23:53:30 root Exp $";
5 */
6
7/* 1/*
8 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
9 3
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
22 16
23 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 20
27 The author can be reached via e-mail to crossfire-devel@real-time.com 21 The author can be reached via e-mail to <crossfire@schmorp.de>
28*/ 22*/
29 23
30#include <global.h> 24#include <global.h>
31#ifndef WIN32 /* ---win32 remove headers */ 25#ifndef WIN32 /* ---win32 remove headers */
32# include <pwd.h> 26# include <pwd.h>
285 p->peaceful = 1; /* default peaceful */ 279 p->peaceful = 1; /* default peaceful */
286 p->do_los = 1; 280 p->do_los = 1;
287 p->explore = 0; 281 p->explore = 0;
288 p->no_shout = 0; /* default can shout */ 282 p->no_shout = 0; /* default can shout */
289 283
290 strncpy (p->title, op->arch->clone.name, sizeof (p->title) - 1); 284 assign (p->title, op->arch->clone.name);
291 p->title[sizeof (p->title) - 1] = '\0';
292 op->race = op->arch->clone.race; 285 op->race = op->arch->clone.race;
293 286
294 CLEAR_FLAG (op, FLAG_READY_SKILL); 287 CLEAR_FLAG (op, FLAG_READY_SKILL);
295 288
296 /* we need to clear these to -1 and not zero - otherwise, 289 /* we need to clear these to -1 and not zero - otherwise,
496path_to_player (object *mon, object *pl, unsigned mindiff) 489path_to_player (object *mon, object *pl, unsigned mindiff)
497{ 490{
498 rv_vector rv; 491 rv_vector rv;
499 sint16 x, y; 492 sint16 x, y;
500 int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; 493 int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked;
501 mapstruct *m, *lastmap; 494 maptile *m, *lastmap;
502 495
503 get_rangevector (mon, pl, &rv, 0); 496 get_rangevector (mon, pl, &rv, 0);
504 497
505 if (rv.distance < mindiff) 498 if (rv.distance < mindiff)
506 return 0; 499 return 0;
1000 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 993 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "");
1001 return 1; 994 return 1;
1002 } 995 }
1003 switch (key) 996 switch (key)
1004 { 997 {
1005 case 'n': 998 case 'n':
1006 case 'N': 999 case 'N':
1007 { 1000 {
1008 SET_FLAG (op, FLAG_WIZ); 1001 SET_FLAG (op, FLAG_WIZ);
1009 if (op->map == NULL) 1002 if (op->map == NULL)
1010 { 1003 {
1011 LOG (llevError, "Map == NULL in state 2\n"); 1004 LOG (llevError, "Map == NULL in state 2\n");
1012 break; 1005 break;
1013 } 1006 }
1014 1007
1015#if 0 1008#if 0
1016 /* So that enter_exit will put us at startx/starty */ 1009 /* So that enter_exit will put us at startx/starty */
1017 op->x = -1; 1010 op->x = -1;
1018 1011
1019 enter_exit (op, NULL); 1012 enter_exit (op, NULL);
1020#endif 1013#endif
1021 SET_ANIMATION (op, 2); /* So player faces south */ 1014 SET_ANIMATION (op, 2); /* So player faces south */
1022 /* Enter exit adds a player otherwise */ 1015 /* Enter exit adds a player otherwise */
1023 add_statbonus (op); 1016 add_statbonus (op);
1024 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 1017 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR,
1025 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); 1018 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n");
1026 op->contr->state = ST_CHANGE_CLASS; 1019 op->contr->state = ST_CHANGE_CLASS;
1027 if (op->msg) 1020 if (op->msg)
1028 new_draw_info (NDI_BLUE, 0, op, op->msg); 1021 new_draw_info (NDI_BLUE, 0, op, op->msg);
1029 return 0;
1030 }
1031 case 'y':
1032 case 'Y':
1033 roll_stats (op);
1034 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "");
1035 return 1;
1036
1037 case 'q':
1038 case 'Q':
1039 play_again (op);
1040 return 1;
1041
1042 default:
1043 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?");
1044 return 0; 1022 return 0;
1023 }
1024 case 'y':
1025 case 'Y':
1026 roll_stats (op);
1027 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "");
1028 return 1;
1029
1030 case 'q':
1031 case 'Q':
1032 play_again (op);
1033 return 1;
1034
1035 default:
1036 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?");
1037 return 0;
1045 } 1038 }
1046 return 0; 1039 return 0;
1047} 1040}
1048 1041
1049/* This function takes the key that is passed, and does the 1042/* This function takes the key that is passed, and does the
1140 op->name = op->name_pl = name; 1133 op->name = op->name_pl = name;
1141 op->x = x; 1134 op->x = x;
1142 op->y = y; 1135 op->y = y;
1143 SET_ANIMATION (op, 2); /* So player faces south */ 1136 SET_ANIMATION (op, 2); /* So player faces south */
1144 insert_ob_in_map (op, op->map, op, 0); 1137 insert_ob_in_map (op, op->map, op, 0);
1145 strncpy (op->contr->title, op->arch->clone.name, sizeof (op->contr->title) - 1); 1138 assign (op->contr->title, op->arch->clone.name);
1146 op->contr->title[sizeof (op->contr->title) - 1] = '\0';
1147 add_statbonus (op); 1139 add_statbonus (op);
1148 tmp_loop = allowed_class (op); 1140 tmp_loop = allowed_class (op);
1149 } 1141 }
1150 1142
1151 update_object (op, UP_OBJ_FACE); 1143 update_object (op, UP_OBJ_FACE);
1152 esrv_update_item (UPD_FACE, op, op); 1144 esrv_update_item (UPD_FACE, op, op);
1153 fix_player (op); 1145 fix_player (op);
1154 op->stats.hp = op->stats.maxhp; 1146 op->stats.hp = op->stats.maxhp;
1155 op->stats.sp = op->stats.maxsp; 1147 op->stats.sp = op->stats.maxsp;
1156 op->stats.grace = 0; 1148 op->stats.grace = 0;
1149
1157 if (op->msg) 1150 if (op->msg)
1158 new_draw_info (NDI_BLUE, 0, op, op->msg); 1151 new_draw_info (NDI_BLUE, 0, op, op->msg);
1152
1159 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); 1153 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n");
1160 return 0; 1154 return 0;
1161} 1155}
1162 1156
1163int 1157int
1186 if (settings.set_title == TRUE) 1180 if (settings.set_title == TRUE)
1187 op->contr->own_title[0] = '\0'; 1181 op->contr->own_title[0] = '\0';
1188 1182
1189 if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) 1183 if (!QUERY_FLAG (op, FLAG_WAS_WIZ))
1190 { 1184 {
1191 mapstruct *mp, *next; 1185 maptile *mp, *next;
1192 1186
1193 /* We need to hunt for any per player unique maps in memory and 1187 /* We need to hunt for any per player unique maps in memory and
1194 * get rid of them. The trailing slash in the path is intentional, 1188 * get rid of them. The trailing slash in the path is intentional,
1195 * so that players named 'Ab' won't match against players 'Abe' pathname 1189 * so that players named 'Ab' won't match against players 'Abe' pathname
1196 */ 1190 */
1270 */ 1264 */
1271int 1265int
1272check_pick (object *op) 1266check_pick (object *op)
1273{ 1267{
1274 object *tmp, *next; 1268 object *tmp, *next;
1275 tag_t next_tag = 0, op_tag;
1276 int stop = 0; 1269 int stop = 0;
1277 int j, k, wvratio; 1270 int j, k, wvratio;
1278 char putstring[128], tmpstr[16]; 1271 char putstring[128], tmpstr[16];
1279 1272
1280
1281 /* if you're flying, you cna't pick up anything */ 1273 /* if you're flying, you cna't pick up anything */
1282 if (op->move_type & MOVE_FLYING) 1274 if (op->move_type & MOVE_FLYING)
1283 return 1; 1275 return 1;
1284 1276
1285 op_tag = op->count;
1286
1287 next = op->below; 1277 next = op->below;
1288 if (next)
1289 next_tag = next->count;
1290 1278
1291 /* loop while there are items on the floor that are not marked as 1279 /* loop while there are items on the floor that are not marked as
1292 * destroyed */ 1280 * destroyed */
1293 while (next && !was_destroyed (next, next_tag)) 1281 while (next && !next->destroyed ())
1294 { 1282 {
1295 tmp = next; 1283 tmp = next;
1296 next = tmp->below; 1284 next = tmp->below;
1297 if (next)
1298 next_tag = next->count;
1299 1285
1300 if (was_destroyed (op, op_tag)) 1286 if (op->destroyed ())
1301 return 0; 1287 return 0;
1302 1288
1303 if (!can_pick (op, tmp)) 1289 if (!can_pick (op, tmp))
1304 continue; 1290 continue;
1305 1291
1313 /* high not bit set? We're using the old autopickup model */ 1299 /* high not bit set? We're using the old autopickup model */
1314 if (!(op->contr->mode & PU_NEWMODE)) 1300 if (!(op->contr->mode & PU_NEWMODE))
1315 { 1301 {
1316 switch (op->contr->mode) 1302 switch (op->contr->mode)
1317 { 1303 {
1318 case 0: 1304 case 0:
1319 return 1; /* don't pick up */ 1305 return 1; /* don't pick up */
1320 case 1: 1306 case 1:
1307 pick_up (op, tmp);
1308 return 1;
1309 case 2:
1310 pick_up (op, tmp);
1311 return 0;
1312 case 3:
1313 return 0; /* stop before pickup */
1314 case 4:
1315 pick_up (op, tmp);
1316 break;
1317 case 5:
1318 pick_up (op, tmp);
1319 stop = 1;
1320 break;
1321 case 6:
1322 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1321 pick_up (op, tmp); 1323 pick_up (op, tmp);
1322 return 1; 1324 break;
1325
1323 case 2: 1326 case 7:
1327 if (tmp->type == MONEY || tmp->type == GEM)
1324 pick_up (op, tmp); 1328 pick_up (op, tmp);
1325 return 0; 1329 break;
1326 case 3: 1330
1327 return 0; /* stop before pickup */ 1331 default:
1328 case 4: 1332 /* use value density */
1333 if (!QUERY_FLAG (tmp, FLAG_UNPAID)
1334 && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode)
1329 pick_up (op, tmp); 1335 pick_up (op, tmp);
1330 break;
1331 case 5:
1332 pick_up (op, tmp);
1333 stop = 1;
1334 break;
1335 case 6:
1336 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1337 pick_up (op, tmp);
1338 break;
1339
1340 case 7:
1341 if (tmp->type == MONEY || tmp->type == GEM)
1342 pick_up (op, tmp);
1343 break;
1344
1345 default:
1346 /* use value density */
1347 if (!QUERY_FLAG (tmp, FLAG_UNPAID)
1348 && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode)
1349 pick_up (op, tmp);
1350 } 1336 }
1351 } 1337 }
1352 else 1338 else
1353 { /* old model */ 1339 { /* old model */
1354 /* NEW pickup handling */ 1340 /* NEW pickup handling */
1776 1762
1777object * 1763object *
1778pick_arrow_target (object *op, const char *type, int dir) 1764pick_arrow_target (object *op, const char *type, int dir)
1779{ 1765{
1780 object *tmp = NULL; 1766 object *tmp = NULL;
1781 mapstruct *m; 1767 maptile *m;
1782 int i, mflags, found, number; 1768 int i, mflags, found, number;
1783 sint16 x, y; 1769 sint16 x, y;
1784 1770
1785 if (op->map == NULL) 1771 if (op->map == NULL)
1786 return find_arrow (op, type); 1772 return find_arrow (op, type);
1846 */ 1832 */
1847int 1833int
1848fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) 1834fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy)
1849{ 1835{
1850 object *left, *bow; 1836 object *left, *bow;
1851 tag_t left_tag, tag;
1852 int bowspeed, mflags; 1837 int bowspeed, mflags;
1853 mapstruct *m; 1838 maptile *m;
1854 1839
1855 if (!dir) 1840 if (!dir)
1856 { 1841 {
1857 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); 1842 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!");
1858 return 0; 1843 return 0;
1918 free_object (arrow); 1903 free_object (arrow);
1919 return 0; 1904 return 0;
1920 } 1905 }
1921 1906
1922 left = arrow; /* these are arrows left to the player */ 1907 left = arrow; /* these are arrows left to the player */
1923 left_tag = left->count;
1924 arrow = get_split_ob (arrow, 1); 1908 arrow = get_split_ob (arrow, 1);
1925 if (arrow == NULL) 1909 if (arrow == NULL)
1926 { 1910 {
1927 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1911 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1928 return 0; 1912 return 0;
1971 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; 1955 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level;
1972 } 1956 }
1973 else 1957 else
1974 { 1958 {
1975 arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; 1959 arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod;
1976
1977 arrow->level = op->level; 1960 arrow->level = op->level;
1978 } 1961 }
1962
1979 if (arrow->attacktype == AT_PHYSICAL) 1963 if (arrow->attacktype == AT_PHYSICAL)
1980 arrow->attacktype |= bow->attacktype; 1964 arrow->attacktype |= bow->attacktype;
1965
1981 if (bow->slaying != NULL) 1966 if (bow->slaying != NULL)
1982 arrow->slaying = bow->slaying; 1967 arrow->slaying = bow->slaying;
1983 1968
1984 arrow->map = m; 1969 arrow->map = m;
1985 arrow->move_type = MOVE_FLY_LOW; 1970 arrow->move_type = MOVE_FLY_LOW;
1986 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1971 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
1987 1972
1988 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); 1973 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW);
1989 tag = arrow->count;
1990 insert_ob_in_map (arrow, m, op, 0); 1974 insert_ob_in_map (arrow, m, op, 0);
1991 1975
1992 if (!was_destroyed (arrow, tag)) 1976 if (!arrow->destroyed ())
1993 move_arrow (arrow); 1977 move_arrow (arrow);
1994 1978
1995 if (op->type == PLAYER) 1979 if (op->type == PLAYER)
1996 { 1980 {
1997 if (was_destroyed (left, left_tag)) 1981 if (left->destroyed ())
1998 esrv_del_item (op->contr, left_tag); 1982 esrv_del_item (op->contr, left->count);
1999 else 1983 else
2000 esrv_send_item (op, left); 1984 esrv_send_item (op, left);
2001 } 1985 }
1986
2002 return 1; 1987 return 1;
2003} 1988}
2004 1989
2005/* Special fire code for players - this takes into 1990/* Special fire code for players - this takes into
2006 * account the special fire modes players can have 1991 * account the special fire modes players can have
2126 if (action_makes_visible (op)) 2111 if (action_makes_visible (op))
2127 make_visible (op); 2112 make_visible (op);
2128 2113
2129 switch (op->contr->shoottype) 2114 switch (op->contr->shoottype)
2130 { 2115 {
2131 case range_none: 2116 case range_none:
2132 return; 2117 return;
2133 2118
2134 case range_bow: 2119 case range_bow:
2135 player_fire_bow (op, dir); 2120 player_fire_bow (op, dir);
2136 return; 2121 return;
2137 2122
2138 case range_magic: /* Casting spells */ 2123 case range_magic: /* Casting spells */
2139 spellcost = (cast_spell (op, op, dir, op->contr->ranges[range_magic], op->contr->spellparam[0] ? op->contr->spellparam : NULL)); 2124 spellcost = (cast_spell (op, op, dir, op->contr->ranges[range_magic], op->contr->spellparam[0] ? op->contr->spellparam : 0));
2140 return; 2125 return;
2141 2126
2142 case range_misc: 2127 case range_misc:
2143 fire_misc_object (op, dir); 2128 fire_misc_object (op, dir);
2144 return; 2129 return;
2145 2130
2146 case range_golem: /* Control summoned monsters from scrolls */ 2131 case range_golem: /* Control summoned monsters from scrolls */
2147 if (op->contr->ranges[range_golem] == NULL || op->contr->golem_count != op->contr->ranges[range_golem]->count) 2132 if (op->contr->ranges[range_golem] == NULL || op->contr->golem_count != op->contr->ranges[range_golem]->count)
2148 { 2133 {
2149 op->contr->ranges[range_golem] = NULL; 2134 op->contr->ranges[range_golem] = NULL;
2150 op->contr->shoottype = range_none; 2135 op->contr->shoottype = range_none;
2151 op->contr->golem_count = 0; 2136 op->contr->golem_count = 0;
2152 } 2137 }
2153 else 2138 else
2154 control_golem (op->contr->ranges[range_golem], dir); 2139 control_golem (op->contr->ranges[range_golem], dir);
2155 return; 2140 return;
2156 2141
2157 case range_skill: 2142 case range_skill:
2158 if (!op->chosen_skill) 2143 if (!op->chosen_skill)
2159 { 2144 {
2160 if (op->type == PLAYER) 2145 if (op->type == PLAYER)
2161 new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); 2146 new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use.");
2162 return; 2147 return;
2163 } 2148 }
2164 (void) do_skill (op, op, op->chosen_skill, dir, NULL); 2149 (void) do_skill (op, op, op->chosen_skill, dir, NULL);
2165 return; 2150 return;
2166 case range_builder: 2151 case range_builder:
2167 apply_map_builder (op, dir); 2152 apply_map_builder (op, dir);
2168 return; 2153 return;
2169 default: 2154 default:
2170 new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); 2155 new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type.");
2171 return; 2156 return;
2172 } 2157 }
2173} 2158}
2174 2159
2175 2160
2176 2161
2318move_player_attack (object *op, int dir) 2303move_player_attack (object *op, int dir)
2319{ 2304{
2320 object *tmp, *mon; 2305 object *tmp, *mon;
2321 sint16 nx, ny; 2306 sint16 nx, ny;
2322 int on_battleground; 2307 int on_battleground;
2323 mapstruct *m; 2308 maptile *m;
2324 2309
2325 nx = freearr_x[dir] + op->x; 2310 nx = freearr_x[dir] + op->x;
2326 ny = freearr_y[dir] + op->y; 2311 ny = freearr_y[dir] + op->y;
2327 2312
2328 on_battleground = op_on_battleground (op, NULL, NULL); 2313 on_battleground = op_on_battleground (op, NULL, NULL);
2958{ 2943{
2959 char buf[MAX_BUF]; 2944 char buf[MAX_BUF];
2960 int x, y; 2945 int x, y;
2961 2946
2962 //int i; 2947 //int i;
2963 mapstruct *map; /* this is for resurrection */ 2948 maptile *map; /* this is for resurrection */
2964 2949
2965 /* int z; 2950 /* int z;
2966 int num_stats_lose; 2951 int num_stats_lose;
2967 int lost_a_stat; 2952 int lost_a_stat;
2968 int lose_this_stat; 2953 int lose_this_stat;
2983 { 2968 {
2984 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); 2969 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!");
2985 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); 2970 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life...");
2986 2971
2987 /* restore player */ 2972 /* restore player */
2988 at = find_archetype ("poisoning"); 2973 at = archetype::find ("poisoning");
2989 tmp = present_arch_in_ob (at, op); 2974 tmp = present_arch_in_ob (at, op);
2990 if (tmp) 2975 if (tmp)
2991 { 2976 {
2992 remove_ob (tmp); 2977 remove_ob (tmp);
2993 free_object (tmp); 2978 free_object (tmp);
2994 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 2979 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
2995 } 2980 }
2996 2981
2997 at = find_archetype ("confusion"); 2982 at = archetype::find ("confusion");
2998 tmp = present_arch_in_ob (at, op); 2983 tmp = present_arch_in_ob (at, op);
2999 if (tmp) 2984 if (tmp)
3000 { 2985 {
3001 remove_ob (tmp); 2986 remove_ob (tmp);
3002 free_object (tmp); 2987 free_object (tmp);
3007 op->stats.hp = op->stats.maxhp; 2992 op->stats.hp = op->stats.maxhp;
3008 if (op->stats.food <= 0) 2993 if (op->stats.food <= 0)
3009 op->stats.food = 999; 2994 op->stats.food = 999;
3010 2995
3011 /* create a bodypart-trophy to make the winner happy */ 2996 /* create a bodypart-trophy to make the winner happy */
3012 tmp = arch_to_object (find_archetype ("finger")); 2997 tmp = arch_to_object (archetype::find ("finger"));
3013 if (tmp != NULL) 2998 if (tmp != NULL)
3014 { 2999 {
3015 sprintf (buf, "%s's finger", &op->name); 3000 sprintf (buf, "%s's finger", &op->name);
3016 tmp->name = buf; 3001 tmp->name = buf;
3017 sprintf (buf, " This finger has been cut off %s\n" 3002 sprintf (buf, " This finger has been cut off %s\n"
3114 lost_a_stat = 1; 3099 lost_a_stat = 1;
3115 } 3100 }
3116 else 3101 else
3117 { 3102 {
3118 /* deplete a stat */ 3103 /* deplete a stat */
3119 archetype *deparch = find_archetype ("depletion"); 3104 archetype *deparch = archetype::find ("depletion");
3120 object *dep; 3105 object *dep;
3121 3106
3122 dep = present_arch_in_ob (deparch, op); 3107 dep = present_arch_in_ob (deparch, op);
3123 if (!dep) 3108 if (!dep)
3124 { 3109 {
3194 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); 3179 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3195 3180
3196 /* Put a gravestone up where the character 'almost' died. List the 3181 /* Put a gravestone up where the character 'almost' died. List the
3197 * exp loss on the stone. 3182 * exp loss on the stone.
3198 */ 3183 */
3199 tmp = arch_to_object (find_archetype ("gravestone")); 3184 tmp = arch_to_object (archetype::find ("gravestone"));
3200 sprintf (buf, "%s's gravestone", &op->name); 3185 sprintf (buf, "%s's gravestone", &op->name);
3201 tmp->name = buf; 3186 tmp->name = buf;
3202 sprintf (buf, "%s's gravestones", &op->name); 3187 sprintf (buf, "%s's gravestones", &op->name);
3203 tmp->name_pl = buf; 3188 tmp->name_pl = buf;
3204 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); 3189 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);
3215 3200
3216 /**************************************/ 3201 /**************************************/
3217 3202
3218 /* remove any poisoning and confusion the character may be suffering. */ 3203 /* remove any poisoning and confusion the character may be suffering. */
3219 /* restore player */ 3204 /* restore player */
3220 at = find_archetype ("poisoning"); 3205 at = archetype::find ("poisoning");
3221 tmp = present_arch_in_ob (at, op); 3206 tmp = present_arch_in_ob (at, op);
3222 if (tmp) 3207 if (tmp)
3223 { 3208 {
3224 remove_ob (tmp); 3209 remove_ob (tmp);
3225 free_object (tmp); 3210 free_object (tmp);
3226 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 3211 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
3227 } 3212 }
3228 3213
3229 at = find_archetype ("confusion"); 3214 at = archetype::find ("confusion");
3230 tmp = present_arch_in_ob (at, op); 3215 tmp = present_arch_in_ob (at, op);
3231 if (tmp) 3216 if (tmp)
3232 { 3217 {
3233 remove_ob (tmp); 3218 remove_ob (tmp);
3234 free_object (tmp); 3219 free_object (tmp);
3356 } 3341 }
3357 3342
3358 play_again (op); 3343 play_again (op);
3359 3344
3360 /* peterm: added to create a corpse at deathsite. */ 3345 /* peterm: added to create a corpse at deathsite. */
3361 tmp = arch_to_object (find_archetype ("corpse_pl")); 3346 tmp = arch_to_object (archetype::find ("corpse_pl"));
3362 sprintf (buf, "%s", &op->name); 3347 sprintf (buf, "%s", &op->name);
3363 tmp->name = tmp->name_pl = buf; 3348 tmp->name = tmp->name_pl = buf;
3364 tmp->level = op->level; 3349 tmp->level = op->level;
3365 tmp->x = x; 3350 tmp->x = x;
3366 tmp->y = y; 3351 tmp->y = y;
3602int 3587int
3603stand_near_hostile (object *who) 3588stand_near_hostile (object *who)
3604{ 3589{
3605 object *tmp = NULL; 3590 object *tmp = NULL;
3606 int i, friendly = 0, player = 0, mflags; 3591 int i, friendly = 0, player = 0, mflags;
3607 mapstruct *m; 3592 maptile *m;
3608 sint16 x, y; 3593 sint16 x, y;
3609 3594
3610 if (!who) 3595 if (!who)
3611 return 0; 3596 return 0;
3612 3597

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines