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, |
… | |
… | |
336 | player *p; |
329 | player *p; |
337 | |
330 | |
338 | p = get_player (NULL); |
331 | p = get_player (NULL); |
339 | p->socket = *ns; |
332 | p->socket = *ns; |
340 | p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
333 | p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
|
|
334 | |
341 | if (p->socket.faces_sent == NULL) |
335 | if (p->socket.faces_sent == NULL) |
342 | fatal (OUT_OF_MEMORY); |
336 | fatal (OUT_OF_MEMORY); |
|
|
337 | |
343 | memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
338 | memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
344 | /* Needed because the socket we just copied over needs to be cleared. |
339 | /* Needed because the socket we just copied over needs to be cleared. |
345 | * Note that this can result in a client reset if there is partial data |
340 | * Note that this can result in a client reset if there is partial data |
346 | * on the uncoming socket. |
341 | * on the uncoming socket. |
347 | */ |
342 | */ |
… | |
… | |
352 | add_friendly_object (p->ob); |
347 | add_friendly_object (p->ob); |
353 | send_rules (p->ob); |
348 | send_rules (p->ob); |
354 | send_news (p->ob); |
349 | send_news (p->ob); |
355 | display_motd (p->ob); |
350 | display_motd (p->ob); |
356 | get_name (p->ob); |
351 | get_name (p->ob); |
|
|
352 | |
357 | return 0; |
353 | return 0; |
358 | } |
354 | } |
359 | |
355 | |
360 | /* |
356 | /* |
361 | * get_player_archetype() return next player archetype from archetype |
357 | * get_player_archetype() return next player archetype from archetype |
… | |
… | |
496 | path_to_player (object *mon, object *pl, unsigned mindiff) |
492 | path_to_player (object *mon, object *pl, unsigned mindiff) |
497 | { |
493 | { |
498 | rv_vector rv; |
494 | rv_vector rv; |
499 | sint16 x, y; |
495 | sint16 x, y; |
500 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
496 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
501 | mapstruct *m, *lastmap; |
497 | maptile *m, *lastmap; |
502 | |
498 | |
503 | get_rangevector (mon, pl, &rv, 0); |
499 | get_rangevector (mon, pl, &rv, 0); |
504 | |
500 | |
505 | if (rv.distance < mindiff) |
501 | if (rv.distance < mindiff) |
506 | return 0; |
502 | return 0; |
… | |
… | |
772 | player *pl = op->contr; |
768 | player *pl = op->contr; |
773 | shstr name = op->name; |
769 | shstr name = op->name; |
774 | |
770 | |
775 | op->contr = 0; |
771 | op->contr = 0; |
776 | op->type = 0; |
772 | op->type = 0; |
777 | op->free (1); |
773 | op->destroy (1); |
778 | pl = get_player (pl); |
774 | pl = get_player (pl); |
779 | op = pl->ob; |
775 | op = pl->ob; |
780 | add_friendly_object (op); |
776 | add_friendly_object (op); |
781 | op->contr->password[0] = '~'; |
777 | op->contr->password[0] = '~'; |
782 | op->name = op->name_pl = 0; |
778 | op->name = op->name_pl = 0; |
… | |
… | |
1000 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
996 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
1001 | return 1; |
997 | return 1; |
1002 | } |
998 | } |
1003 | switch (key) |
999 | switch (key) |
1004 | { |
1000 | { |
1005 | case 'n': |
1001 | case 'n': |
1006 | case 'N': |
1002 | case 'N': |
1007 | { |
1003 | { |
1008 | SET_FLAG (op, FLAG_WIZ); |
1004 | SET_FLAG (op, FLAG_WIZ); |
1009 | if (op->map == NULL) |
1005 | if (op->map == NULL) |
1010 | { |
1006 | { |
1011 | LOG (llevError, "Map == NULL in state 2\n"); |
1007 | LOG (llevError, "Map == NULL in state 2\n"); |
1012 | break; |
1008 | break; |
1013 | } |
1009 | } |
1014 | |
1010 | |
1015 | #if 0 |
1011 | #if 0 |
1016 | /* So that enter_exit will put us at startx/starty */ |
1012 | /* So that enter_exit will put us at startx/starty */ |
1017 | op->x = -1; |
1013 | op->x = -1; |
1018 | |
1014 | |
1019 | enter_exit (op, NULL); |
1015 | enter_exit (op, NULL); |
1020 | #endif |
1016 | #endif |
1021 | SET_ANIMATION (op, 2); /* So player faces south */ |
1017 | SET_ANIMATION (op, 2); /* So player faces south */ |
1022 | /* Enter exit adds a player otherwise */ |
1018 | /* Enter exit adds a player otherwise */ |
1023 | add_statbonus (op); |
1019 | add_statbonus (op); |
1024 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
1020 | 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"); |
1021 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); |
1026 | op->contr->state = ST_CHANGE_CLASS; |
1022 | op->contr->state = ST_CHANGE_CLASS; |
1027 | if (op->msg) |
1023 | if (op->msg) |
1028 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1024 | 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; |
1025 | return 0; |
|
|
1026 | } |
|
|
1027 | case 'y': |
|
|
1028 | case 'Y': |
|
|
1029 | roll_stats (op); |
|
|
1030 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
|
|
1031 | return 1; |
|
|
1032 | |
|
|
1033 | case 'q': |
|
|
1034 | case 'Q': |
|
|
1035 | play_again (op); |
|
|
1036 | return 1; |
|
|
1037 | |
|
|
1038 | default: |
|
|
1039 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
|
|
1040 | return 0; |
1045 | } |
1041 | } |
1046 | return 0; |
1042 | return 0; |
1047 | } |
1043 | } |
1048 | |
1044 | |
1049 | /* This function takes the key that is passed, and does the |
1045 | /* This function takes the key that is passed, and does the |
… | |
… | |
1140 | op->name = op->name_pl = name; |
1136 | op->name = op->name_pl = name; |
1141 | op->x = x; |
1137 | op->x = x; |
1142 | op->y = y; |
1138 | op->y = y; |
1143 | SET_ANIMATION (op, 2); /* So player faces south */ |
1139 | SET_ANIMATION (op, 2); /* So player faces south */ |
1144 | insert_ob_in_map (op, op->map, op, 0); |
1140 | insert_ob_in_map (op, op->map, op, 0); |
1145 | strncpy (op->contr->title, op->arch->clone.name, sizeof (op->contr->title) - 1); |
1141 | assign (op->contr->title, op->arch->clone.name); |
1146 | op->contr->title[sizeof (op->contr->title) - 1] = '\0'; |
|
|
1147 | add_statbonus (op); |
1142 | add_statbonus (op); |
1148 | tmp_loop = allowed_class (op); |
1143 | tmp_loop = allowed_class (op); |
1149 | } |
1144 | } |
1150 | |
1145 | |
1151 | update_object (op, UP_OBJ_FACE); |
1146 | update_object (op, UP_OBJ_FACE); |
1152 | esrv_update_item (UPD_FACE, op, op); |
1147 | esrv_update_item (UPD_FACE, op, op); |
1153 | fix_player (op); |
1148 | fix_player (op); |
1154 | op->stats.hp = op->stats.maxhp; |
1149 | op->stats.hp = op->stats.maxhp; |
1155 | op->stats.sp = op->stats.maxsp; |
1150 | op->stats.sp = op->stats.maxsp; |
1156 | op->stats.grace = 0; |
1151 | op->stats.grace = 0; |
|
|
1152 | |
1157 | if (op->msg) |
1153 | if (op->msg) |
1158 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1154 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
|
|
1155 | |
1159 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); |
1156 | 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; |
1157 | return 0; |
1161 | } |
1158 | } |
1162 | |
1159 | |
1163 | int |
1160 | int |
… | |
… | |
1186 | if (settings.set_title == TRUE) |
1183 | if (settings.set_title == TRUE) |
1187 | op->contr->own_title[0] = '\0'; |
1184 | op->contr->own_title[0] = '\0'; |
1188 | |
1185 | |
1189 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1186 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1190 | { |
1187 | { |
1191 | mapstruct *mp, *next; |
1188 | maptile *mp, *next; |
1192 | |
1189 | |
1193 | /* We need to hunt for any per player unique maps in memory and |
1190 | /* 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, |
1191 | * 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 |
1192 | * so that players named 'Ab' won't match against players 'Abe' pathname |
1196 | */ |
1193 | */ |
… | |
… | |
1270 | */ |
1267 | */ |
1271 | int |
1268 | int |
1272 | check_pick (object *op) |
1269 | check_pick (object *op) |
1273 | { |
1270 | { |
1274 | object *tmp, *next; |
1271 | object *tmp, *next; |
1275 | tag_t next_tag = 0, op_tag; |
|
|
1276 | int stop = 0; |
1272 | int stop = 0; |
1277 | int j, k, wvratio; |
1273 | int j, k, wvratio; |
1278 | char putstring[128], tmpstr[16]; |
1274 | char putstring[128], tmpstr[16]; |
1279 | |
1275 | |
1280 | |
|
|
1281 | /* if you're flying, you cna't pick up anything */ |
1276 | /* if you're flying, you cna't pick up anything */ |
1282 | if (op->move_type & MOVE_FLYING) |
1277 | if (op->move_type & MOVE_FLYING) |
1283 | return 1; |
1278 | return 1; |
1284 | |
1279 | |
1285 | op_tag = op->count; |
|
|
1286 | |
|
|
1287 | next = op->below; |
1280 | next = op->below; |
1288 | if (next) |
|
|
1289 | next_tag = next->count; |
|
|
1290 | |
1281 | |
1291 | /* loop while there are items on the floor that are not marked as |
1282 | /* loop while there are items on the floor that are not marked as |
1292 | * destroyed */ |
1283 | * destroyed */ |
1293 | while (next && !was_destroyed (next, next_tag)) |
1284 | while (next && !next->destroyed ()) |
1294 | { |
1285 | { |
1295 | tmp = next; |
1286 | tmp = next; |
1296 | next = tmp->below; |
1287 | next = tmp->below; |
1297 | if (next) |
|
|
1298 | next_tag = next->count; |
|
|
1299 | |
1288 | |
1300 | if (was_destroyed (op, op_tag)) |
1289 | if (op->destroyed ()) |
1301 | return 0; |
1290 | return 0; |
1302 | |
1291 | |
1303 | if (!can_pick (op, tmp)) |
1292 | if (!can_pick (op, tmp)) |
1304 | continue; |
1293 | continue; |
1305 | |
1294 | |
… | |
… | |
1313 | /* high not bit set? We're using the old autopickup model */ |
1302 | /* high not bit set? We're using the old autopickup model */ |
1314 | if (!(op->contr->mode & PU_NEWMODE)) |
1303 | if (!(op->contr->mode & PU_NEWMODE)) |
1315 | { |
1304 | { |
1316 | switch (op->contr->mode) |
1305 | switch (op->contr->mode) |
1317 | { |
1306 | { |
1318 | case 0: |
1307 | case 0: |
1319 | return 1; /* don't pick up */ |
1308 | return 1; /* don't pick up */ |
1320 | case 1: |
1309 | case 1: |
|
|
1310 | pick_up (op, tmp); |
|
|
1311 | return 1; |
|
|
1312 | case 2: |
|
|
1313 | pick_up (op, tmp); |
|
|
1314 | return 0; |
|
|
1315 | case 3: |
|
|
1316 | return 0; /* stop before pickup */ |
|
|
1317 | case 4: |
|
|
1318 | pick_up (op, tmp); |
|
|
1319 | break; |
|
|
1320 | case 5: |
|
|
1321 | pick_up (op, tmp); |
|
|
1322 | stop = 1; |
|
|
1323 | break; |
|
|
1324 | case 6: |
|
|
1325 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1321 | pick_up (op, tmp); |
1326 | pick_up (op, tmp); |
1322 | return 1; |
1327 | break; |
|
|
1328 | |
1323 | case 2: |
1329 | case 7: |
|
|
1330 | if (tmp->type == MONEY || tmp->type == GEM) |
1324 | pick_up (op, tmp); |
1331 | pick_up (op, tmp); |
1325 | return 0; |
1332 | break; |
1326 | case 3: |
1333 | |
1327 | return 0; /* stop before pickup */ |
1334 | default: |
1328 | case 4: |
1335 | /* use value density */ |
|
|
1336 | if (!QUERY_FLAG (tmp, FLAG_UNPAID) |
|
|
1337 | && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) |
1329 | pick_up (op, tmp); |
1338 | 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 | } |
1339 | } |
1351 | } |
1340 | } |
1352 | else |
1341 | else |
1353 | { /* old model */ |
1342 | { /* old model */ |
1354 | /* NEW pickup handling */ |
1343 | /* NEW pickup handling */ |
… | |
… | |
1776 | |
1765 | |
1777 | object * |
1766 | object * |
1778 | pick_arrow_target (object *op, const char *type, int dir) |
1767 | pick_arrow_target (object *op, const char *type, int dir) |
1779 | { |
1768 | { |
1780 | object *tmp = NULL; |
1769 | object *tmp = NULL; |
1781 | mapstruct *m; |
1770 | maptile *m; |
1782 | int i, mflags, found, number; |
1771 | int i, mflags, found, number; |
1783 | sint16 x, y; |
1772 | sint16 x, y; |
1784 | |
1773 | |
1785 | if (op->map == NULL) |
1774 | if (op->map == NULL) |
1786 | return find_arrow (op, type); |
1775 | return find_arrow (op, type); |
… | |
… | |
1846 | */ |
1835 | */ |
1847 | int |
1836 | int |
1848 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1837 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1849 | { |
1838 | { |
1850 | object *left, *bow; |
1839 | object *left, *bow; |
1851 | tag_t left_tag, tag; |
|
|
1852 | int bowspeed, mflags; |
1840 | int bowspeed, mflags; |
1853 | mapstruct *m; |
1841 | maptile *m; |
1854 | |
1842 | |
1855 | if (!dir) |
1843 | if (!dir) |
1856 | { |
1844 | { |
1857 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1845 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1858 | return 0; |
1846 | return 0; |
… | |
… | |
1918 | free_object (arrow); |
1906 | free_object (arrow); |
1919 | return 0; |
1907 | return 0; |
1920 | } |
1908 | } |
1921 | |
1909 | |
1922 | left = arrow; /* these are arrows left to the player */ |
1910 | left = arrow; /* these are arrows left to the player */ |
1923 | left_tag = left->count; |
|
|
1924 | arrow = get_split_ob (arrow, 1); |
1911 | arrow = get_split_ob (arrow, 1); |
1925 | if (arrow == NULL) |
1912 | if (arrow == NULL) |
1926 | { |
1913 | { |
1927 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1914 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1928 | return 0; |
1915 | return 0; |
… | |
… | |
1971 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1958 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1972 | } |
1959 | } |
1973 | else |
1960 | else |
1974 | { |
1961 | { |
1975 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1962 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1976 | |
|
|
1977 | arrow->level = op->level; |
1963 | arrow->level = op->level; |
1978 | } |
1964 | } |
|
|
1965 | |
1979 | if (arrow->attacktype == AT_PHYSICAL) |
1966 | if (arrow->attacktype == AT_PHYSICAL) |
1980 | arrow->attacktype |= bow->attacktype; |
1967 | arrow->attacktype |= bow->attacktype; |
|
|
1968 | |
1981 | if (bow->slaying != NULL) |
1969 | if (bow->slaying != NULL) |
1982 | arrow->slaying = bow->slaying; |
1970 | arrow->slaying = bow->slaying; |
1983 | |
1971 | |
1984 | arrow->map = m; |
1972 | arrow->map = m; |
1985 | arrow->move_type = MOVE_FLY_LOW; |
1973 | arrow->move_type = MOVE_FLY_LOW; |
1986 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1974 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1987 | |
1975 | |
1988 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1976 | 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); |
1977 | insert_ob_in_map (arrow, m, op, 0); |
1991 | |
1978 | |
1992 | if (!was_destroyed (arrow, tag)) |
1979 | if (!arrow->destroyed ()) |
1993 | move_arrow (arrow); |
1980 | move_arrow (arrow); |
1994 | |
1981 | |
1995 | if (op->type == PLAYER) |
1982 | if (op->type == PLAYER) |
1996 | { |
1983 | { |
1997 | if (was_destroyed (left, left_tag)) |
1984 | if (left->destroyed ()) |
1998 | esrv_del_item (op->contr, left_tag); |
1985 | esrv_del_item (op->contr, left->count); |
1999 | else |
1986 | else |
2000 | esrv_send_item (op, left); |
1987 | esrv_send_item (op, left); |
2001 | } |
1988 | } |
|
|
1989 | |
2002 | return 1; |
1990 | return 1; |
2003 | } |
1991 | } |
2004 | |
1992 | |
2005 | /* Special fire code for players - this takes into |
1993 | /* Special fire code for players - this takes into |
2006 | * account the special fire modes players can have |
1994 | * account the special fire modes players can have |
… | |
… | |
2126 | if (action_makes_visible (op)) |
2114 | if (action_makes_visible (op)) |
2127 | make_visible (op); |
2115 | make_visible (op); |
2128 | |
2116 | |
2129 | switch (op->contr->shoottype) |
2117 | switch (op->contr->shoottype) |
2130 | { |
2118 | { |
2131 | case range_none: |
2119 | case range_none: |
2132 | return; |
2120 | return; |
2133 | |
2121 | |
2134 | case range_bow: |
2122 | case range_bow: |
2135 | player_fire_bow (op, dir); |
2123 | player_fire_bow (op, dir); |
2136 | return; |
2124 | return; |
2137 | |
2125 | |
2138 | case range_magic: /* Casting spells */ |
2126 | 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)); |
2127 | spellcost = (cast_spell (op, op, dir, op->contr->ranges[range_magic], op->contr->spellparam[0] ? op->contr->spellparam : 0)); |
2140 | return; |
2128 | return; |
2141 | |
2129 | |
2142 | case range_misc: |
2130 | case range_misc: |
2143 | fire_misc_object (op, dir); |
2131 | fire_misc_object (op, dir); |
2144 | return; |
2132 | return; |
2145 | |
2133 | |
2146 | case range_golem: /* Control summoned monsters from scrolls */ |
2134 | 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) |
2135 | if (op->contr->ranges[range_golem] == NULL || op->contr->golem_count != op->contr->ranges[range_golem]->count) |
2148 | { |
2136 | { |
2149 | op->contr->ranges[range_golem] = NULL; |
2137 | op->contr->ranges[range_golem] = NULL; |
2150 | op->contr->shoottype = range_none; |
2138 | op->contr->shoottype = range_none; |
2151 | op->contr->golem_count = 0; |
2139 | op->contr->golem_count = 0; |
2152 | } |
2140 | } |
2153 | else |
2141 | else |
2154 | control_golem (op->contr->ranges[range_golem], dir); |
2142 | control_golem (op->contr->ranges[range_golem], dir); |
2155 | return; |
2143 | return; |
2156 | |
2144 | |
2157 | case range_skill: |
2145 | case range_skill: |
2158 | if (!op->chosen_skill) |
2146 | if (!op->chosen_skill) |
2159 | { |
2147 | { |
2160 | if (op->type == PLAYER) |
2148 | if (op->type == PLAYER) |
2161 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
2149 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
2162 | return; |
2150 | return; |
2163 | } |
2151 | } |
2164 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
2152 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
2165 | return; |
2153 | return; |
2166 | case range_builder: |
2154 | case range_builder: |
2167 | apply_map_builder (op, dir); |
2155 | apply_map_builder (op, dir); |
2168 | return; |
2156 | return; |
2169 | default: |
2157 | default: |
2170 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
2158 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
2171 | return; |
2159 | return; |
2172 | } |
2160 | } |
2173 | } |
2161 | } |
2174 | |
2162 | |
2175 | |
2163 | |
2176 | |
2164 | |
… | |
… | |
2318 | move_player_attack (object *op, int dir) |
2306 | move_player_attack (object *op, int dir) |
2319 | { |
2307 | { |
2320 | object *tmp, *mon; |
2308 | object *tmp, *mon; |
2321 | sint16 nx, ny; |
2309 | sint16 nx, ny; |
2322 | int on_battleground; |
2310 | int on_battleground; |
2323 | mapstruct *m; |
2311 | maptile *m; |
2324 | |
2312 | |
2325 | nx = freearr_x[dir] + op->x; |
2313 | nx = freearr_x[dir] + op->x; |
2326 | ny = freearr_y[dir] + op->y; |
2314 | ny = freearr_y[dir] + op->y; |
2327 | |
2315 | |
2328 | on_battleground = op_on_battleground (op, NULL, NULL); |
2316 | on_battleground = op_on_battleground (op, NULL, NULL); |
… | |
… | |
2364 | if (tmp == op) |
2352 | if (tmp == op) |
2365 | { |
2353 | { |
2366 | tmp = tmp->above; |
2354 | tmp = tmp->above; |
2367 | continue; |
2355 | continue; |
2368 | } |
2356 | } |
|
|
2357 | |
2369 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2358 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2370 | { |
2359 | { |
2371 | mon = tmp; |
2360 | mon = tmp; |
2372 | break; |
2361 | break; |
2373 | } |
2362 | } |
|
|
2363 | |
2374 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2364 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2375 | mon = tmp; |
2365 | mon = tmp; |
|
|
2366 | |
2376 | tmp = tmp->above; |
2367 | tmp = tmp->above; |
2377 | } |
2368 | } |
2378 | |
2369 | |
2379 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2370 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2380 | return; /* into a wall */ |
2371 | return; /* into a wall */ |
… | |
… | |
2958 | { |
2949 | { |
2959 | char buf[MAX_BUF]; |
2950 | char buf[MAX_BUF]; |
2960 | int x, y; |
2951 | int x, y; |
2961 | |
2952 | |
2962 | //int i; |
2953 | //int i; |
2963 | mapstruct *map; /* this is for resurrection */ |
2954 | maptile *map; /* this is for resurrection */ |
2964 | |
2955 | |
2965 | /* int z; |
2956 | /* int z; |
2966 | int num_stats_lose; |
2957 | int num_stats_lose; |
2967 | int lost_a_stat; |
2958 | int lost_a_stat; |
2968 | int lose_this_stat; |
2959 | int lose_this_stat; |
… | |
… | |
2983 | { |
2974 | { |
2984 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2975 | 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..."); |
2976 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
2986 | |
2977 | |
2987 | /* restore player */ |
2978 | /* restore player */ |
2988 | at = find_archetype ("poisoning"); |
2979 | at = archetype::find ("poisoning"); |
2989 | tmp = present_arch_in_ob (at, op); |
2980 | tmp = present_arch_in_ob (at, op); |
2990 | if (tmp) |
2981 | if (tmp) |
2991 | { |
2982 | { |
2992 | remove_ob (tmp); |
2983 | remove_ob (tmp); |
2993 | free_object (tmp); |
2984 | free_object (tmp); |
2994 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2985 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2995 | } |
2986 | } |
2996 | |
2987 | |
2997 | at = find_archetype ("confusion"); |
2988 | at = archetype::find ("confusion"); |
2998 | tmp = present_arch_in_ob (at, op); |
2989 | tmp = present_arch_in_ob (at, op); |
2999 | if (tmp) |
2990 | if (tmp) |
3000 | { |
2991 | { |
3001 | remove_ob (tmp); |
2992 | remove_ob (tmp); |
3002 | free_object (tmp); |
2993 | free_object (tmp); |
… | |
… | |
3007 | op->stats.hp = op->stats.maxhp; |
2998 | op->stats.hp = op->stats.maxhp; |
3008 | if (op->stats.food <= 0) |
2999 | if (op->stats.food <= 0) |
3009 | op->stats.food = 999; |
3000 | op->stats.food = 999; |
3010 | |
3001 | |
3011 | /* create a bodypart-trophy to make the winner happy */ |
3002 | /* create a bodypart-trophy to make the winner happy */ |
3012 | tmp = arch_to_object (find_archetype ("finger")); |
3003 | tmp = arch_to_object (archetype::find ("finger")); |
3013 | if (tmp != NULL) |
3004 | if (tmp != NULL) |
3014 | { |
3005 | { |
3015 | sprintf (buf, "%s's finger", &op->name); |
3006 | sprintf (buf, "%s's finger", &op->name); |
3016 | tmp->name = buf; |
3007 | tmp->name = buf; |
3017 | sprintf (buf, " This finger has been cut off %s\n" |
3008 | sprintf (buf, " This finger has been cut off %s\n" |
… | |
… | |
3114 | lost_a_stat = 1; |
3105 | lost_a_stat = 1; |
3115 | } |
3106 | } |
3116 | else |
3107 | else |
3117 | { |
3108 | { |
3118 | /* deplete a stat */ |
3109 | /* deplete a stat */ |
3119 | archetype *deparch = find_archetype ("depletion"); |
3110 | archetype *deparch = archetype::find ("depletion"); |
3120 | object *dep; |
3111 | object *dep; |
3121 | |
3112 | |
3122 | dep = present_arch_in_ob (deparch, op); |
3113 | dep = present_arch_in_ob (deparch, op); |
3123 | if (!dep) |
3114 | if (!dep) |
3124 | { |
3115 | { |
… | |
… | |
3194 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
3185 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
3195 | |
3186 | |
3196 | /* Put a gravestone up where the character 'almost' died. List the |
3187 | /* Put a gravestone up where the character 'almost' died. List the |
3197 | * exp loss on the stone. |
3188 | * exp loss on the stone. |
3198 | */ |
3189 | */ |
3199 | tmp = arch_to_object (find_archetype ("gravestone")); |
3190 | tmp = arch_to_object (archetype::find ("gravestone")); |
3200 | sprintf (buf, "%s's gravestone", &op->name); |
3191 | sprintf (buf, "%s's gravestone", &op->name); |
3201 | tmp->name = buf; |
3192 | tmp->name = buf; |
3202 | sprintf (buf, "%s's gravestones", &op->name); |
3193 | sprintf (buf, "%s's gravestones", &op->name); |
3203 | tmp->name_pl = buf; |
3194 | 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); |
3195 | 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 | |
3206 | |
3216 | /**************************************/ |
3207 | /**************************************/ |
3217 | |
3208 | |
3218 | /* remove any poisoning and confusion the character may be suffering. */ |
3209 | /* remove any poisoning and confusion the character may be suffering. */ |
3219 | /* restore player */ |
3210 | /* restore player */ |
3220 | at = find_archetype ("poisoning"); |
3211 | at = archetype::find ("poisoning"); |
3221 | tmp = present_arch_in_ob (at, op); |
3212 | tmp = present_arch_in_ob (at, op); |
3222 | if (tmp) |
3213 | if (tmp) |
3223 | { |
3214 | { |
3224 | remove_ob (tmp); |
3215 | remove_ob (tmp); |
3225 | free_object (tmp); |
3216 | free_object (tmp); |
3226 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
3217 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
3227 | } |
3218 | } |
3228 | |
3219 | |
3229 | at = find_archetype ("confusion"); |
3220 | at = archetype::find ("confusion"); |
3230 | tmp = present_arch_in_ob (at, op); |
3221 | tmp = present_arch_in_ob (at, op); |
3231 | if (tmp) |
3222 | if (tmp) |
3232 | { |
3223 | { |
3233 | remove_ob (tmp); |
3224 | remove_ob (tmp); |
3234 | free_object (tmp); |
3225 | free_object (tmp); |
… | |
… | |
3356 | } |
3347 | } |
3357 | |
3348 | |
3358 | play_again (op); |
3349 | play_again (op); |
3359 | |
3350 | |
3360 | /* peterm: added to create a corpse at deathsite. */ |
3351 | /* peterm: added to create a corpse at deathsite. */ |
3361 | tmp = arch_to_object (find_archetype ("corpse_pl")); |
3352 | tmp = arch_to_object (archetype::find ("corpse_pl")); |
3362 | sprintf (buf, "%s", &op->name); |
3353 | sprintf (buf, "%s", &op->name); |
3363 | tmp->name = tmp->name_pl = buf; |
3354 | tmp->name = tmp->name_pl = buf; |
3364 | tmp->level = op->level; |
3355 | tmp->level = op->level; |
3365 | tmp->x = x; |
3356 | tmp->x = x; |
3366 | tmp->y = y; |
3357 | tmp->y = y; |
… | |
… | |
3602 | int |
3593 | int |
3603 | stand_near_hostile (object *who) |
3594 | stand_near_hostile (object *who) |
3604 | { |
3595 | { |
3605 | object *tmp = NULL; |
3596 | object *tmp = NULL; |
3606 | int i, friendly = 0, player = 0, mflags; |
3597 | int i, friendly = 0, player = 0, mflags; |
3607 | mapstruct *m; |
3598 | maptile *m; |
3608 | sint16 x, y; |
3599 | sint16 x, y; |
3609 | |
3600 | |
3610 | if (!who) |
3601 | if (!who) |
3611 | return 0; |
3602 | return 0; |
3612 | |
3603 | |