1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_player_c = |
|
|
4 | * "$Id: player.C,v 1.18 2006/09/10 15:59:57 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; |
… | |
… | |
756 | * the map is null or not swapped out. |
752 | * the map is null or not swapped out. |
757 | */ |
753 | */ |
758 | op->map = NULL; |
754 | op->map = NULL; |
759 | } |
755 | } |
760 | |
756 | |
761 | |
|
|
762 | int |
757 | int |
763 | receive_play_again (object *op, char key) |
758 | receive_play_again (object *op, char key) |
764 | { |
759 | { |
765 | if (key == 'q' || key == 'Q') |
760 | if (key == 'q' || key == 'Q') |
766 | { |
761 | { |
… | |
… | |
771 | else if (key == 'a' || key == 'A') |
766 | else if (key == 'a' || key == 'A') |
772 | { |
767 | { |
773 | player *pl = op->contr; |
768 | player *pl = op->contr; |
774 | shstr name = op->name; |
769 | shstr name = op->name; |
775 | |
770 | |
776 | remove_friendly_object (op); |
771 | op->contr = 0; |
777 | free_object (op); |
772 | op->type = 0; |
|
|
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; |
… | |
… | |
785 | get_name (op); |
781 | get_name (op); |
786 | op->name = op->name_pl = name; |
782 | op->name = op->name_pl = name; |
787 | set_first_map (op); |
783 | set_first_map (op); |
788 | } |
784 | } |
789 | else |
785 | else |
790 | { |
|
|
791 | /* user pressed something else so just ask again... */ |
786 | /* user pressed something else so just ask again... */ |
792 | play_again (op); |
787 | play_again (op); |
793 | } |
788 | |
794 | return 0; |
789 | return 0; |
795 | } |
790 | } |
796 | |
791 | |
797 | void |
792 | void |
798 | confirm_password (object *op) |
793 | confirm_password (object *op) |
… | |
… | |
1001 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
996 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
1002 | return 1; |
997 | return 1; |
1003 | } |
998 | } |
1004 | switch (key) |
999 | switch (key) |
1005 | { |
1000 | { |
1006 | case 'n': |
1001 | case 'n': |
1007 | case 'N': |
1002 | case 'N': |
1008 | { |
1003 | { |
1009 | SET_FLAG (op, FLAG_WIZ); |
1004 | SET_FLAG (op, FLAG_WIZ); |
1010 | if (op->map == NULL) |
1005 | if (op->map == NULL) |
1011 | { |
1006 | { |
1012 | LOG (llevError, "Map == NULL in state 2\n"); |
1007 | LOG (llevError, "Map == NULL in state 2\n"); |
1013 | break; |
1008 | break; |
1014 | } |
1009 | } |
1015 | |
1010 | |
1016 | #if 0 |
1011 | #if 0 |
1017 | /* So that enter_exit will put us at startx/starty */ |
1012 | /* So that enter_exit will put us at startx/starty */ |
1018 | op->x = -1; |
1013 | op->x = -1; |
1019 | |
1014 | |
1020 | enter_exit (op, NULL); |
1015 | enter_exit (op, NULL); |
1021 | #endif |
1016 | #endif |
1022 | SET_ANIMATION (op, 2); /* So player faces south */ |
1017 | SET_ANIMATION (op, 2); /* So player faces south */ |
1023 | /* Enter exit adds a player otherwise */ |
1018 | /* Enter exit adds a player otherwise */ |
1024 | add_statbonus (op); |
1019 | add_statbonus (op); |
1025 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
1020 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
1026 | "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"); |
1027 | op->contr->state = ST_CHANGE_CLASS; |
1022 | op->contr->state = ST_CHANGE_CLASS; |
1028 | if (op->msg) |
1023 | if (op->msg) |
1029 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1024 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1030 | return 0; |
|
|
1031 | } |
|
|
1032 | case 'y': |
|
|
1033 | case 'Y': |
|
|
1034 | roll_stats (op); |
|
|
1035 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
|
|
1036 | return 1; |
|
|
1037 | |
|
|
1038 | case 'q': |
|
|
1039 | case 'Q': |
|
|
1040 | play_again (op); |
|
|
1041 | return 1; |
|
|
1042 | |
|
|
1043 | default: |
|
|
1044 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
|
|
1045 | 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; |
1046 | } |
1041 | } |
1047 | return 0; |
1042 | return 0; |
1048 | } |
1043 | } |
1049 | |
1044 | |
1050 | /* This function takes the key that is passed, and does the |
1045 | /* This function takes the key that is passed, and does the |
… | |
… | |
1141 | op->name = op->name_pl = name; |
1136 | op->name = op->name_pl = name; |
1142 | op->x = x; |
1137 | op->x = x; |
1143 | op->y = y; |
1138 | op->y = y; |
1144 | SET_ANIMATION (op, 2); /* So player faces south */ |
1139 | SET_ANIMATION (op, 2); /* So player faces south */ |
1145 | insert_ob_in_map (op, op->map, op, 0); |
1140 | insert_ob_in_map (op, op->map, op, 0); |
1146 | strncpy (op->contr->title, op->arch->clone.name, sizeof (op->contr->title) - 1); |
1141 | assign (op->contr->title, op->arch->clone.name); |
1147 | op->contr->title[sizeof (op->contr->title) - 1] = '\0'; |
|
|
1148 | add_statbonus (op); |
1142 | add_statbonus (op); |
1149 | tmp_loop = allowed_class (op); |
1143 | tmp_loop = allowed_class (op); |
1150 | } |
1144 | } |
|
|
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 | */ |
… | |
… | |
1202 | delete_map (mp); |
1199 | delete_map (mp); |
1203 | } |
1200 | } |
1204 | |
1201 | |
1205 | delete_character (op->name, 1); |
1202 | delete_character (op->name, 1); |
1206 | } |
1203 | } |
|
|
1204 | |
1207 | play_again (op); |
1205 | play_again (op); |
1208 | return 1; |
1206 | return 1; |
1209 | } |
1207 | } |
1210 | |
1208 | |
1211 | void |
1209 | void |
… | |
… | |
1269 | */ |
1267 | */ |
1270 | int |
1268 | int |
1271 | check_pick (object *op) |
1269 | check_pick (object *op) |
1272 | { |
1270 | { |
1273 | object *tmp, *next; |
1271 | object *tmp, *next; |
1274 | tag_t next_tag = 0, op_tag; |
|
|
1275 | int stop = 0; |
1272 | int stop = 0; |
1276 | int j, k, wvratio; |
1273 | int j, k, wvratio; |
1277 | char putstring[128], tmpstr[16]; |
1274 | char putstring[128], tmpstr[16]; |
1278 | |
1275 | |
1279 | |
|
|
1280 | /* if you're flying, you cna't pick up anything */ |
1276 | /* if you're flying, you cna't pick up anything */ |
1281 | if (op->move_type & MOVE_FLYING) |
1277 | if (op->move_type & MOVE_FLYING) |
1282 | return 1; |
1278 | return 1; |
1283 | |
1279 | |
1284 | op_tag = op->count; |
|
|
1285 | |
|
|
1286 | next = op->below; |
1280 | next = op->below; |
1287 | if (next) |
|
|
1288 | next_tag = next->count; |
|
|
1289 | |
1281 | |
1290 | /* 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 |
1291 | * destroyed */ |
1283 | * destroyed */ |
1292 | while (next && !was_destroyed (next, next_tag)) |
1284 | while (next && !next->destroyed ()) |
1293 | { |
1285 | { |
1294 | tmp = next; |
1286 | tmp = next; |
1295 | next = tmp->below; |
1287 | next = tmp->below; |
1296 | if (next) |
|
|
1297 | next_tag = next->count; |
|
|
1298 | |
1288 | |
1299 | if (was_destroyed (op, op_tag)) |
1289 | if (op->destroyed ()) |
1300 | return 0; |
1290 | return 0; |
1301 | |
1291 | |
1302 | if (!can_pick (op, tmp)) |
1292 | if (!can_pick (op, tmp)) |
1303 | continue; |
1293 | continue; |
1304 | |
1294 | |
… | |
… | |
1312 | /* high not bit set? We're using the old autopickup model */ |
1302 | /* high not bit set? We're using the old autopickup model */ |
1313 | if (!(op->contr->mode & PU_NEWMODE)) |
1303 | if (!(op->contr->mode & PU_NEWMODE)) |
1314 | { |
1304 | { |
1315 | switch (op->contr->mode) |
1305 | switch (op->contr->mode) |
1316 | { |
1306 | { |
1317 | case 0: |
1307 | case 0: |
1318 | return 1; /* don't pick up */ |
1308 | return 1; /* don't pick up */ |
1319 | 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)) |
1320 | pick_up (op, tmp); |
1326 | pick_up (op, tmp); |
1321 | return 1; |
1327 | break; |
|
|
1328 | |
1322 | case 2: |
1329 | case 7: |
|
|
1330 | if (tmp->type == MONEY || tmp->type == GEM) |
1323 | pick_up (op, tmp); |
1331 | pick_up (op, tmp); |
1324 | return 0; |
1332 | break; |
1325 | case 3: |
1333 | |
1326 | return 0; /* stop before pickup */ |
1334 | default: |
1327 | 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) |
1328 | pick_up (op, tmp); |
1338 | pick_up (op, tmp); |
1329 | break; |
|
|
1330 | case 5: |
|
|
1331 | pick_up (op, tmp); |
|
|
1332 | stop = 1; |
|
|
1333 | break; |
|
|
1334 | case 6: |
|
|
1335 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
|
|
1336 | pick_up (op, tmp); |
|
|
1337 | break; |
|
|
1338 | |
|
|
1339 | case 7: |
|
|
1340 | if (tmp->type == MONEY || tmp->type == GEM) |
|
|
1341 | pick_up (op, tmp); |
|
|
1342 | break; |
|
|
1343 | |
|
|
1344 | default: |
|
|
1345 | /* use value density */ |
|
|
1346 | if (!QUERY_FLAG (tmp, FLAG_UNPAID) |
|
|
1347 | && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) |
|
|
1348 | pick_up (op, tmp); |
|
|
1349 | } |
1339 | } |
1350 | } |
1340 | } |
1351 | else |
1341 | else |
1352 | { /* old model */ |
1342 | { /* old model */ |
1353 | /* NEW pickup handling */ |
1343 | /* NEW pickup handling */ |
… | |
… | |
1436 | /* question: don't pick up known-poisonous stuff? */ |
1426 | /* question: don't pick up known-poisonous stuff? */ |
1437 | if (op->contr->mode & PU_FOOD) |
1427 | if (op->contr->mode & PU_FOOD) |
1438 | if (tmp->type == FOOD) |
1428 | if (tmp->type == FOOD) |
1439 | { |
1429 | { |
1440 | pick_up (op, tmp); |
1430 | pick_up (op, tmp); |
1441 | if (0) |
|
|
1442 | fprintf (stderr, "FOOD\n"); |
|
|
1443 | continue; |
1431 | continue; |
1444 | } |
1432 | } |
|
|
1433 | |
1445 | if (op->contr->mode & PU_DRINK) |
1434 | if (op->contr->mode & PU_DRINK) |
1446 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1435 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1447 | { |
1436 | { |
1448 | pick_up (op, tmp); |
1437 | pick_up (op, tmp); |
1449 | if (0) |
|
|
1450 | fprintf (stderr, "DRINK\n"); |
|
|
1451 | continue; |
1438 | continue; |
1452 | } |
1439 | } |
1453 | |
1440 | |
1454 | if (op->contr->mode & PU_POTION) |
1441 | if (op->contr->mode & PU_POTION) |
1455 | if (tmp->type == POTION) |
1442 | if (tmp->type == POTION) |
1456 | { |
1443 | { |
1457 | pick_up (op, tmp); |
1444 | pick_up (op, tmp); |
1458 | if (0) |
|
|
1459 | fprintf (stderr, "POTION\n"); |
|
|
1460 | continue; |
1445 | continue; |
1461 | } |
1446 | } |
1462 | |
1447 | |
1463 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1448 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1464 | if (op->contr->mode & PU_SPELLBOOK) |
1449 | if (op->contr->mode & PU_SPELLBOOK) |
1465 | if (tmp->type == SPELLBOOK) |
1450 | if (tmp->type == SPELLBOOK) |
1466 | { |
1451 | { |
1467 | pick_up (op, tmp); |
1452 | pick_up (op, tmp); |
1468 | if (0) |
|
|
1469 | fprintf (stderr, "SPELLBOOK\n"); |
|
|
1470 | continue; |
1453 | continue; |
1471 | } |
1454 | } |
|
|
1455 | |
1472 | if (op->contr->mode & PU_SKILLSCROLL) |
1456 | if (op->contr->mode & PU_SKILLSCROLL) |
1473 | if (tmp->type == SKILLSCROLL) |
1457 | if (tmp->type == SKILLSCROLL) |
1474 | { |
1458 | { |
1475 | pick_up (op, tmp); |
1459 | pick_up (op, tmp); |
1476 | if (0) |
|
|
1477 | fprintf (stderr, "SKILLSCROLL\n"); |
|
|
1478 | continue; |
1460 | continue; |
1479 | } |
1461 | } |
|
|
1462 | |
1480 | if (op->contr->mode & PU_READABLES) |
1463 | if (op->contr->mode & PU_READABLES) |
1481 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1464 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1482 | { |
1465 | { |
1483 | pick_up (op, tmp); |
1466 | pick_up (op, tmp); |
1484 | if (0) |
|
|
1485 | fprintf (stderr, "READABLES\n"); |
|
|
1486 | continue; |
1467 | continue; |
1487 | } |
1468 | } |
1488 | |
1469 | |
1489 | /* wands/staves/rods/horns */ |
1470 | /* wands/staves/rods/horns */ |
1490 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1471 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1491 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1472 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1492 | { |
1473 | { |
1493 | pick_up (op, tmp); |
1474 | pick_up (op, tmp); |
1494 | if (0) |
|
|
1495 | fprintf (stderr, "MAGIC_DEVICE\n"); |
|
|
1496 | continue; |
1475 | continue; |
1497 | } |
1476 | } |
1498 | |
1477 | |
1499 | /* pick up all magical items */ |
1478 | /* pick up all magical items */ |
1500 | if (op->contr->mode & PU_MAGICAL) |
1479 | if (op->contr->mode & PU_MAGICAL) |
1501 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1480 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1502 | { |
1481 | { |
1503 | pick_up (op, tmp); |
1482 | pick_up (op, tmp); |
1504 | if (0) |
|
|
1505 | fprintf (stderr, "MAGICAL\n"); |
|
|
1506 | continue; |
1483 | continue; |
1507 | } |
1484 | } |
1508 | |
1485 | |
1509 | if (op->contr->mode & PU_VALUABLES) |
1486 | if (op->contr->mode & PU_VALUABLES) |
1510 | { |
1487 | { |
1511 | if (tmp->type == MONEY || tmp->type == GEM) |
1488 | if (tmp->type == MONEY || tmp->type == GEM) |
1512 | { |
1489 | { |
1513 | pick_up (op, tmp); |
1490 | pick_up (op, tmp); |
1514 | if (0) |
|
|
1515 | fprintf (stderr, "MONEY/GEM\n"); |
|
|
1516 | continue; |
1491 | continue; |
1517 | } |
1492 | } |
1518 | } |
1493 | } |
1519 | |
1494 | |
1520 | /* rings & amulets - talismans seems to be typed AMULET */ |
1495 | /* rings & amulets - talismans seems to be typed AMULET */ |
1521 | if (op->contr->mode & PU_JEWELS) |
1496 | if (op->contr->mode & PU_JEWELS) |
1522 | if (tmp->type == RING || tmp->type == AMULET) |
1497 | if (tmp->type == RING || tmp->type == AMULET) |
1523 | { |
1498 | { |
1524 | pick_up (op, tmp); |
1499 | pick_up (op, tmp); |
|
|
1500 | continue; |
1525 | if (0) |
1501 | } |
1526 | fprintf (stderr, "JEWELS\n"); |
1502 | |
|
|
1503 | /* we don't forget dragon food */ |
|
|
1504 | if (op->contr->mode & PU_FLESH) |
|
|
1505 | if (tmp->type == FLESH) |
|
|
1506 | { |
|
|
1507 | pick_up (op, tmp); |
1527 | continue; |
1508 | continue; |
1528 | } |
1509 | } |
1529 | |
1510 | |
1530 | /* bows and arrows. Bows are good for selling! */ |
1511 | /* bows and arrows. Bows are good for selling! */ |
1531 | if (op->contr->mode & PU_BOW) |
1512 | if (op->contr->mode & PU_BOW) |
1532 | if (tmp->type == BOW) |
1513 | if (tmp->type == BOW) |
1533 | { |
1514 | { |
1534 | pick_up (op, tmp); |
1515 | pick_up (op, tmp); |
1535 | if (0) |
|
|
1536 | fprintf (stderr, "BOW\n"); |
|
|
1537 | continue; |
1516 | continue; |
1538 | } |
1517 | } |
|
|
1518 | |
1539 | if (op->contr->mode & PU_ARROW) |
1519 | if (op->contr->mode & PU_ARROW) |
1540 | if (tmp->type == ARROW) |
1520 | if (tmp->type == ARROW) |
1541 | { |
1521 | { |
1542 | pick_up (op, tmp); |
1522 | pick_up (op, tmp); |
1543 | if (0) |
|
|
1544 | fprintf (stderr, "ARROW\n"); |
|
|
1545 | continue; |
1523 | continue; |
1546 | } |
1524 | } |
1547 | |
1525 | |
1548 | /* all kinds of armor etc. */ |
1526 | /* all kinds of armor etc. */ |
1549 | if (op->contr->mode & PU_ARMOUR) |
1527 | if (op->contr->mode & PU_ARMOUR) |
1550 | if (tmp->type == ARMOUR) |
1528 | if (tmp->type == ARMOUR) |
1551 | { |
1529 | { |
1552 | pick_up (op, tmp); |
1530 | pick_up (op, tmp); |
1553 | if (0) |
|
|
1554 | fprintf (stderr, "ARMOUR\n"); |
|
|
1555 | continue; |
1531 | continue; |
1556 | } |
1532 | } |
|
|
1533 | |
1557 | if (op->contr->mode & PU_HELMET) |
1534 | if (op->contr->mode & PU_HELMET) |
1558 | if (tmp->type == HELMET) |
1535 | if (tmp->type == HELMET) |
1559 | { |
1536 | { |
1560 | pick_up (op, tmp); |
1537 | pick_up (op, tmp); |
1561 | if (0) |
|
|
1562 | fprintf (stderr, "HELMET\n"); |
|
|
1563 | continue; |
1538 | continue; |
1564 | } |
1539 | } |
|
|
1540 | |
1565 | if (op->contr->mode & PU_SHIELD) |
1541 | if (op->contr->mode & PU_SHIELD) |
1566 | if (tmp->type == SHIELD) |
1542 | if (tmp->type == SHIELD) |
1567 | { |
1543 | { |
1568 | pick_up (op, tmp); |
1544 | pick_up (op, tmp); |
1569 | if (0) |
|
|
1570 | fprintf (stderr, "SHIELD\n"); |
|
|
1571 | continue; |
1545 | continue; |
1572 | } |
1546 | } |
|
|
1547 | |
1573 | if (op->contr->mode & PU_BOOTS) |
1548 | if (op->contr->mode & PU_BOOTS) |
1574 | if (tmp->type == BOOTS) |
1549 | if (tmp->type == BOOTS) |
1575 | { |
1550 | { |
1576 | pick_up (op, tmp); |
1551 | pick_up (op, tmp); |
1577 | if (0) |
|
|
1578 | fprintf (stderr, "BOOTS\n"); |
|
|
1579 | continue; |
1552 | continue; |
1580 | } |
1553 | } |
|
|
1554 | |
1581 | if (op->contr->mode & PU_GLOVES) |
1555 | if (op->contr->mode & PU_GLOVES) |
1582 | if (tmp->type == GLOVES) |
1556 | if (tmp->type == GLOVES) |
1583 | { |
1557 | { |
1584 | pick_up (op, tmp); |
1558 | pick_up (op, tmp); |
1585 | if (0) |
|
|
1586 | fprintf (stderr, "GLOVES\n"); |
|
|
1587 | continue; |
1559 | continue; |
1588 | } |
1560 | } |
|
|
1561 | |
1589 | if (op->contr->mode & PU_CLOAK) |
1562 | if (op->contr->mode & PU_CLOAK) |
1590 | if (tmp->type == CLOAK) |
1563 | if (tmp->type == CLOAK) |
1591 | { |
1564 | { |
1592 | pick_up (op, tmp); |
1565 | pick_up (op, tmp); |
1593 | if (0) |
|
|
1594 | fprintf (stderr, "GLOVES\n"); |
|
|
1595 | continue; |
1566 | continue; |
1596 | } |
1567 | } |
1597 | |
1568 | |
1598 | /* hoping to catch throwing daggers here */ |
1569 | /* hoping to catch throwing daggers here */ |
1599 | if (op->contr->mode & PU_MISSILEWEAPON) |
1570 | if (op->contr->mode & PU_MISSILEWEAPON) |
1600 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1571 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1601 | { |
1572 | { |
1602 | pick_up (op, tmp); |
1573 | pick_up (op, tmp); |
1603 | if (0) |
|
|
1604 | fprintf (stderr, "MISSILEWEAPON\n"); |
|
|
1605 | continue; |
1574 | continue; |
1606 | } |
1575 | } |
1607 | |
1576 | |
1608 | /* careful: chairs and tables are weapons! */ |
1577 | /* careful: chairs and tables are weapons! */ |
1609 | if (op->contr->mode & PU_ALLWEAPON) |
1578 | if (op->contr->mode & PU_ALLWEAPON) |
… | |
… | |
1612 | { |
1581 | { |
1613 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1582 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1614 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1583 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1615 | { |
1584 | { |
1616 | pick_up (op, tmp); |
1585 | pick_up (op, tmp); |
1617 | if (0) |
|
|
1618 | fprintf (stderr, "WEAPON\n"); |
|
|
1619 | continue; |
1586 | continue; |
1620 | } |
1587 | } |
1621 | } |
1588 | } |
|
|
1589 | |
1622 | if (tmp->type == WEAPON && tmp->name == NULL) |
1590 | if (tmp->type == WEAPON && tmp->name == NULL) |
1623 | { |
1591 | { |
1624 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1592 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1625 | { |
1593 | { |
1626 | pick_up (op, tmp); |
1594 | pick_up (op, tmp); |
1627 | if (0) |
|
|
1628 | fprintf (stderr, "WEAPON\n"); |
|
|
1629 | continue; |
1595 | continue; |
1630 | } |
1596 | } |
1631 | } |
1597 | } |
1632 | } |
1598 | } |
1633 | |
1599 | |
1634 | /* misc stuff that's useful */ |
1600 | /* misc stuff that's useful */ |
1635 | if (op->contr->mode & PU_KEY) |
1601 | if (op->contr->mode & PU_KEY) |
1636 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1602 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1637 | { |
1603 | { |
1638 | pick_up (op, tmp); |
1604 | pick_up (op, tmp); |
1639 | if (0) |
|
|
1640 | fprintf (stderr, "KEY\n"); |
|
|
1641 | continue; |
1605 | continue; |
1642 | } |
1606 | } |
1643 | |
1607 | |
1644 | /* any of the last 4 bits set means we use the ratio for value |
1608 | /* any of the last 4 bits set means we use the ratio for value |
1645 | * pickups */ |
1609 | * pickups */ |
… | |
… | |
1667 | continue; |
1631 | continue; |
1668 | } |
1632 | } |
1669 | } |
1633 | } |
1670 | } /* the new pickup model */ |
1634 | } /* the new pickup model */ |
1671 | } |
1635 | } |
|
|
1636 | |
1672 | return !stop; |
1637 | return !stop; |
1673 | } |
1638 | } |
1674 | |
1639 | |
1675 | /* |
1640 | /* |
1676 | * Find an arrow in the inventory and after that |
1641 | * Find an arrow in the inventory and after that |
… | |
… | |
1775 | |
1740 | |
1776 | object * |
1741 | object * |
1777 | pick_arrow_target (object *op, const char *type, int dir) |
1742 | pick_arrow_target (object *op, const char *type, int dir) |
1778 | { |
1743 | { |
1779 | object *tmp = NULL; |
1744 | object *tmp = NULL; |
1780 | mapstruct *m; |
1745 | maptile *m; |
1781 | int i, mflags, found, number; |
1746 | int i, mflags, found, number; |
1782 | sint16 x, y; |
1747 | sint16 x, y; |
1783 | |
1748 | |
1784 | if (op->map == NULL) |
1749 | if (op->map == NULL) |
1785 | return find_arrow (op, type); |
1750 | return find_arrow (op, type); |
… | |
… | |
1845 | */ |
1810 | */ |
1846 | int |
1811 | int |
1847 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1812 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1848 | { |
1813 | { |
1849 | object *left, *bow; |
1814 | object *left, *bow; |
1850 | tag_t left_tag, tag; |
|
|
1851 | int bowspeed, mflags; |
1815 | int bowspeed, mflags; |
1852 | mapstruct *m; |
1816 | maptile *m; |
1853 | |
1817 | |
1854 | if (!dir) |
1818 | if (!dir) |
1855 | { |
1819 | { |
1856 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1820 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1857 | return 0; |
1821 | return 0; |
… | |
… | |
1917 | free_object (arrow); |
1881 | free_object (arrow); |
1918 | return 0; |
1882 | return 0; |
1919 | } |
1883 | } |
1920 | |
1884 | |
1921 | left = arrow; /* these are arrows left to the player */ |
1885 | left = arrow; /* these are arrows left to the player */ |
1922 | left_tag = left->count; |
|
|
1923 | arrow = get_split_ob (arrow, 1); |
1886 | arrow = get_split_ob (arrow, 1); |
1924 | if (arrow == NULL) |
1887 | if (arrow == NULL) |
1925 | { |
1888 | { |
1926 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1889 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1927 | return 0; |
1890 | return 0; |
… | |
… | |
1970 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1933 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1971 | } |
1934 | } |
1972 | else |
1935 | else |
1973 | { |
1936 | { |
1974 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1937 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1975 | |
|
|
1976 | arrow->level = op->level; |
1938 | arrow->level = op->level; |
1977 | } |
1939 | } |
|
|
1940 | |
1978 | if (arrow->attacktype == AT_PHYSICAL) |
1941 | if (arrow->attacktype == AT_PHYSICAL) |
1979 | arrow->attacktype |= bow->attacktype; |
1942 | arrow->attacktype |= bow->attacktype; |
|
|
1943 | |
1980 | if (bow->slaying != NULL) |
1944 | if (bow->slaying != NULL) |
1981 | arrow->slaying = bow->slaying; |
1945 | arrow->slaying = bow->slaying; |
1982 | |
1946 | |
1983 | arrow->map = m; |
1947 | arrow->map = m; |
1984 | arrow->move_type = MOVE_FLY_LOW; |
1948 | arrow->move_type = MOVE_FLY_LOW; |
1985 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1949 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1986 | |
1950 | |
1987 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1951 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1988 | tag = arrow->count; |
|
|
1989 | insert_ob_in_map (arrow, m, op, 0); |
1952 | insert_ob_in_map (arrow, m, op, 0); |
1990 | |
1953 | |
1991 | if (!was_destroyed (arrow, tag)) |
1954 | if (!arrow->destroyed ()) |
1992 | move_arrow (arrow); |
1955 | move_arrow (arrow); |
1993 | |
1956 | |
1994 | if (op->type == PLAYER) |
1957 | if (op->type == PLAYER) |
1995 | { |
1958 | { |
1996 | if (was_destroyed (left, left_tag)) |
1959 | if (left->destroyed ()) |
1997 | esrv_del_item (op->contr, left_tag); |
1960 | esrv_del_item (op->contr, left->count); |
1998 | else |
1961 | else |
1999 | esrv_send_item (op, left); |
1962 | esrv_send_item (op, left); |
2000 | } |
1963 | } |
|
|
1964 | |
2001 | return 1; |
1965 | return 1; |
2002 | } |
1966 | } |
2003 | |
1967 | |
2004 | /* Special fire code for players - this takes into |
1968 | /* Special fire code for players - this takes into |
2005 | * account the special fire modes players can have |
1969 | * account the special fire modes players can have |
… | |
… | |
2125 | if (action_makes_visible (op)) |
2089 | if (action_makes_visible (op)) |
2126 | make_visible (op); |
2090 | make_visible (op); |
2127 | |
2091 | |
2128 | switch (op->contr->shoottype) |
2092 | switch (op->contr->shoottype) |
2129 | { |
2093 | { |
2130 | case range_none: |
2094 | case range_none: |
2131 | return; |
2095 | return; |
2132 | |
2096 | |
2133 | case range_bow: |
2097 | case range_bow: |
2134 | player_fire_bow (op, dir); |
2098 | player_fire_bow (op, dir); |
2135 | return; |
2099 | return; |
2136 | |
2100 | |
2137 | case range_magic: /* Casting spells */ |
2101 | case range_magic: /* Casting spells */ |
2138 | spellcost = (cast_spell (op, op, dir, op->contr->ranges[range_magic], op->contr->spellparam[0] ? op->contr->spellparam : NULL)); |
2102 | spellcost = (cast_spell (op, op, dir, op->contr->ranges[range_magic], op->contr->spellparam[0] ? op->contr->spellparam : 0)); |
2139 | return; |
2103 | return; |
2140 | |
2104 | |
2141 | case range_misc: |
2105 | case range_misc: |
2142 | fire_misc_object (op, dir); |
2106 | fire_misc_object (op, dir); |
2143 | return; |
2107 | return; |
2144 | |
2108 | |
2145 | case range_golem: /* Control summoned monsters from scrolls */ |
2109 | case range_golem: /* Control summoned monsters from scrolls */ |
2146 | if (op->contr->ranges[range_golem] == NULL || op->contr->golem_count != op->contr->ranges[range_golem]->count) |
2110 | if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2147 | { |
2111 | { |
2148 | op->contr->ranges[range_golem] = NULL; |
2112 | op->contr->ranges[range_golem] = 0; |
2149 | op->contr->shoottype = range_none; |
2113 | op->contr->shoottype = range_none; |
2150 | op->contr->golem_count = 0; |
|
|
2151 | } |
2114 | } |
2152 | else |
2115 | else |
2153 | control_golem (op->contr->ranges[range_golem], dir); |
2116 | control_golem (op->contr->ranges[range_golem], dir); |
2154 | return; |
2117 | return; |
2155 | |
2118 | |
2156 | case range_skill: |
2119 | case range_skill: |
2157 | if (!op->chosen_skill) |
2120 | if (!op->chosen_skill) |
2158 | { |
2121 | { |
2159 | if (op->type == PLAYER) |
2122 | if (op->type == PLAYER) |
2160 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
2123 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
2161 | return; |
2124 | return; |
2162 | } |
2125 | } |
2163 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
2126 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
2164 | return; |
2127 | return; |
2165 | case range_builder: |
2128 | case range_builder: |
2166 | apply_map_builder (op, dir); |
2129 | apply_map_builder (op, dir); |
2167 | return; |
2130 | return; |
2168 | default: |
2131 | default: |
2169 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
2132 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
2170 | return; |
2133 | return; |
2171 | } |
2134 | } |
2172 | } |
2135 | } |
2173 | |
2136 | |
2174 | |
2137 | |
2175 | |
2138 | |
… | |
… | |
2317 | move_player_attack (object *op, int dir) |
2280 | move_player_attack (object *op, int dir) |
2318 | { |
2281 | { |
2319 | object *tmp, *mon; |
2282 | object *tmp, *mon; |
2320 | sint16 nx, ny; |
2283 | sint16 nx, ny; |
2321 | int on_battleground; |
2284 | int on_battleground; |
2322 | mapstruct *m; |
2285 | maptile *m; |
2323 | |
2286 | |
2324 | nx = freearr_x[dir] + op->x; |
2287 | nx = freearr_x[dir] + op->x; |
2325 | ny = freearr_y[dir] + op->y; |
2288 | ny = freearr_y[dir] + op->y; |
2326 | |
2289 | |
2327 | on_battleground = op_on_battleground (op, NULL, NULL); |
2290 | on_battleground = op_on_battleground (op, NULL, NULL); |
… | |
… | |
2363 | if (tmp == op) |
2326 | if (tmp == op) |
2364 | { |
2327 | { |
2365 | tmp = tmp->above; |
2328 | tmp = tmp->above; |
2366 | continue; |
2329 | continue; |
2367 | } |
2330 | } |
|
|
2331 | |
2368 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2332 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2369 | { |
2333 | { |
2370 | mon = tmp; |
2334 | mon = tmp; |
2371 | break; |
2335 | break; |
2372 | } |
2336 | } |
|
|
2337 | |
2373 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2338 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2374 | mon = tmp; |
2339 | mon = tmp; |
|
|
2340 | |
2375 | tmp = tmp->above; |
2341 | tmp = tmp->above; |
2376 | } |
2342 | } |
2377 | |
2343 | |
2378 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2344 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2379 | return; /* into a wall */ |
2345 | return; /* into a wall */ |
… | |
… | |
2598 | /* I've been seeing crashes where the golem has been destroyed, but |
2564 | /* I've been seeing crashes where the golem has been destroyed, but |
2599 | * the player object still points to the defunct golem. The code that |
2565 | * the player object still points to the defunct golem. The code that |
2600 | * destroys the golem looks correct, and it doesn't always happen, so |
2566 | * destroys the golem looks correct, and it doesn't always happen, so |
2601 | * put this in a a workaround to clean up the golem pointer. |
2567 | * put this in a a workaround to clean up the golem pointer. |
2602 | */ |
2568 | */ |
2603 | if (op->contr->ranges[range_golem] && |
|
|
2604 | ((op->contr->golem_count != op->contr->ranges[range_golem]->count) || QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))) |
2569 | if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2605 | { |
|
|
2606 | op->contr->ranges[range_golem] = NULL; |
2570 | op->contr->ranges[range_golem] = 0; |
2607 | op->contr->golem_count = 0; |
|
|
2608 | } |
|
|
2609 | |
2571 | |
2610 | /* call this here - we also will call this in do_ericserver, but |
2572 | /* call this here - we also will call this in do_ericserver, but |
2611 | * the players time has been increased when doericserver has been |
2573 | * the players time has been increased when doericserver has been |
2612 | * called, so we recheck it here. |
2574 | * called, so we recheck it here. |
2613 | */ |
2575 | */ |
… | |
… | |
2957 | { |
2919 | { |
2958 | char buf[MAX_BUF]; |
2920 | char buf[MAX_BUF]; |
2959 | int x, y; |
2921 | int x, y; |
2960 | |
2922 | |
2961 | //int i; |
2923 | //int i; |
2962 | mapstruct *map; /* this is for resurrection */ |
2924 | maptile *map; /* this is for resurrection */ |
2963 | |
2925 | |
2964 | /* int z; |
2926 | /* int z; |
2965 | int num_stats_lose; |
2927 | int num_stats_lose; |
2966 | int lost_a_stat; |
2928 | int lost_a_stat; |
2967 | int lose_this_stat; |
2929 | int lose_this_stat; |
… | |
… | |
2982 | { |
2944 | { |
2983 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2945 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2984 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
2946 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
2985 | |
2947 | |
2986 | /* restore player */ |
2948 | /* restore player */ |
2987 | at = find_archetype ("poisoning"); |
2949 | at = archetype::find ("poisoning"); |
2988 | tmp = present_arch_in_ob (at, op); |
2950 | tmp = present_arch_in_ob (at, op); |
2989 | if (tmp) |
2951 | if (tmp) |
2990 | { |
2952 | { |
2991 | remove_ob (tmp); |
2953 | remove_ob (tmp); |
2992 | free_object (tmp); |
2954 | free_object (tmp); |
2993 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2955 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2994 | } |
2956 | } |
2995 | |
2957 | |
2996 | at = find_archetype ("confusion"); |
2958 | at = archetype::find ("confusion"); |
2997 | tmp = present_arch_in_ob (at, op); |
2959 | tmp = present_arch_in_ob (at, op); |
2998 | if (tmp) |
2960 | if (tmp) |
2999 | { |
2961 | { |
3000 | remove_ob (tmp); |
2962 | remove_ob (tmp); |
3001 | free_object (tmp); |
2963 | free_object (tmp); |
… | |
… | |
3006 | op->stats.hp = op->stats.maxhp; |
2968 | op->stats.hp = op->stats.maxhp; |
3007 | if (op->stats.food <= 0) |
2969 | if (op->stats.food <= 0) |
3008 | op->stats.food = 999; |
2970 | op->stats.food = 999; |
3009 | |
2971 | |
3010 | /* create a bodypart-trophy to make the winner happy */ |
2972 | /* create a bodypart-trophy to make the winner happy */ |
3011 | tmp = arch_to_object (find_archetype ("finger")); |
2973 | tmp = arch_to_object (archetype::find ("finger")); |
3012 | if (tmp != NULL) |
2974 | if (tmp != NULL) |
3013 | { |
2975 | { |
3014 | sprintf (buf, "%s's finger", &op->name); |
2976 | sprintf (buf, "%s's finger", &op->name); |
3015 | tmp->name = buf; |
2977 | tmp->name = buf; |
3016 | sprintf (buf, " This finger has been cut off %s\n" |
2978 | sprintf (buf, " This finger has been cut off %s\n" |
… | |
… | |
3113 | lost_a_stat = 1; |
3075 | lost_a_stat = 1; |
3114 | } |
3076 | } |
3115 | else |
3077 | else |
3116 | { |
3078 | { |
3117 | /* deplete a stat */ |
3079 | /* deplete a stat */ |
3118 | archetype *deparch = find_archetype ("depletion"); |
3080 | archetype *deparch = archetype::find ("depletion"); |
3119 | object *dep; |
3081 | object *dep; |
3120 | |
3082 | |
3121 | dep = present_arch_in_ob (deparch, op); |
3083 | dep = present_arch_in_ob (deparch, op); |
3122 | if (!dep) |
3084 | if (!dep) |
3123 | { |
3085 | { |
… | |
… | |
3183 | /* determine_god() seems to not work sometimes... why is this? |
3145 | /* determine_god() seems to not work sometimes... why is this? |
3184 | Should I be using something else? GD */ |
3146 | Should I be using something else? GD */ |
3185 | const char *god = determine_god (op); |
3147 | const char *god = determine_god (op); |
3186 | |
3148 | |
3187 | if (god && (strcmp (god, "none"))) |
3149 | if (god && (strcmp (god, "none"))) |
3188 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief " "moment you feel the holy presence of %s protecting" " you.", god); |
3150 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
3189 | else |
3151 | else |
3190 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); |
3152 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
3191 | } |
3153 | } |
|
|
3154 | #else |
|
|
3155 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
3192 | #endif |
3156 | #endif |
3193 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
|
|
3194 | |
3157 | |
3195 | /* Put a gravestone up where the character 'almost' died. List the |
3158 | /* Put a gravestone up where the character 'almost' died. List the |
3196 | * exp loss on the stone. |
3159 | * exp loss on the stone. |
3197 | */ |
3160 | */ |
3198 | tmp = arch_to_object (find_archetype ("gravestone")); |
3161 | tmp = arch_to_object (archetype::find ("gravestone")); |
3199 | sprintf (buf, "%s's gravestone", &op->name); |
3162 | sprintf (buf, "%s's gravestone", &op->name); |
3200 | tmp->name = buf; |
3163 | tmp->name = buf; |
3201 | sprintf (buf, "%s's gravestones", &op->name); |
3164 | sprintf (buf, "%s's gravestones", &op->name); |
3202 | tmp->name_pl = buf; |
3165 | tmp->name_pl = buf; |
3203 | 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); |
3166 | 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); |
3204 | tmp->msg = buf; |
3167 | tmp->msg = buf; |
3205 | tmp->x = op->x, tmp->y = op->y; |
3168 | tmp->x = op->x, tmp->y = op->y; |
3206 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3169 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3207 | |
3170 | |
3208 | /**************************************/ |
3171 | /**************************************/ |
3209 | /* */ |
3172 | /* */ |
3210 | /* Subtract the experience points, */ |
3173 | /* Subtract the experience points, */ |
3211 | /* if we died cause of food, give us */ |
3174 | /* if we died cause of food, give us */ |
3212 | /* food, and reset HP's... */ |
3175 | /* food, and reset HP's... */ |
3213 | /* */ |
3176 | /* */ |
3214 | |
|
|
3215 | /**************************************/ |
3177 | /**************************************/ |
3216 | |
3178 | |
3217 | /* remove any poisoning and confusion the character may be suffering. */ |
3179 | /* remove any poisoning and confusion the character may be suffering. */ |
3218 | /* restore player */ |
3180 | /* restore player */ |
3219 | at = find_archetype ("poisoning"); |
3181 | at = archetype::find ("poisoning"); |
3220 | tmp = present_arch_in_ob (at, op); |
3182 | tmp = present_arch_in_ob (at, op); |
3221 | if (tmp) |
3183 | if (tmp) |
3222 | { |
3184 | { |
3223 | remove_ob (tmp); |
3185 | remove_ob (tmp); |
3224 | free_object (tmp); |
3186 | free_object (tmp); |
3225 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
3187 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
3226 | } |
3188 | } |
3227 | |
3189 | |
3228 | at = find_archetype ("confusion"); |
3190 | at = archetype::find ("confusion"); |
3229 | tmp = present_arch_in_ob (at, op); |
3191 | tmp = present_arch_in_ob (at, op); |
3230 | if (tmp) |
3192 | if (tmp) |
3231 | { |
3193 | { |
3232 | remove_ob (tmp); |
3194 | remove_ob (tmp); |
3233 | free_object (tmp); |
3195 | free_object (tmp); |
3234 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3196 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3235 | } |
3197 | } |
|
|
3198 | |
3236 | cure_disease (op, 0); /* remove any disease */ |
3199 | cure_disease (op, 0); /* remove any disease */ |
3237 | |
3200 | |
3238 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3201 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3239 | apply_death_exp_penalty (op); |
3202 | apply_death_exp_penalty (op); |
3240 | if (op->stats.food < 100) |
3203 | if (op->stats.food < 100) |
… | |
… | |
3250 | */ |
3213 | */ |
3251 | |
3214 | |
3252 | if (is_in_shop (op)) |
3215 | if (is_in_shop (op)) |
3253 | remove_unpaid_objects (op->inv, op); |
3216 | remove_unpaid_objects (op->inv, op); |
3254 | |
3217 | |
3255 | /****************************************/ |
3218 | /****************************************/ |
3256 | /* */ |
3219 | /* */ |
3257 | /* Move player to his current respawn- */ |
3220 | /* Move player to his current respawn- */ |
3258 | /* position (usually last savebed) */ |
3221 | /* position (usually last savebed) */ |
3259 | /* */ |
3222 | /* */ |
3260 | |
|
|
3261 | /****************************************/ |
3223 | /****************************************/ |
3262 | |
3224 | |
3263 | enter_player_savebed (op); |
3225 | enter_player_savebed (op); |
3264 | |
3226 | |
3265 | /* Save the player before inserting the force to reduce |
3227 | /* Save the player before inserting the force to reduce |
3266 | * chance of abuse. |
3228 | * chance of abuse. |
… | |
… | |
3273 | * spell effects. So first see if there is a spell effect |
3235 | * spell effects. So first see if there is a spell effect |
3274 | * on the space that might harm the player. |
3236 | * on the space that might harm the player. |
3275 | */ |
3237 | */ |
3276 | will_kill_again = 0; |
3238 | will_kill_again = 0; |
3277 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3239 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3278 | { |
|
|
3279 | if (tmp->type == SPELL_EFFECT) |
3240 | if (tmp->type == SPELL_EFFECT) |
3280 | will_kill_again |= tmp->attacktype; |
3241 | will_kill_again |= tmp->attacktype; |
3281 | } |
3242 | |
3282 | if (will_kill_again) |
3243 | if (will_kill_again) |
3283 | { |
3244 | { |
3284 | object *force; |
3245 | object *force; |
3285 | int at; |
3246 | int at; |
3286 | |
3247 | |
… | |
… | |
3288 | /* 50 ticks should be enough time for the spell to abate */ |
3249 | /* 50 ticks should be enough time for the spell to abate */ |
3289 | force->speed = 0.1; |
3250 | force->speed = 0.1; |
3290 | force->speed_left = -5.0; |
3251 | force->speed_left = -5.0; |
3291 | SET_FLAG (force, FLAG_APPLIED); |
3252 | SET_FLAG (force, FLAG_APPLIED); |
3292 | for (at = 0; at < NROFATTACKS; at++) |
3253 | for (at = 0; at < NROFATTACKS; at++) |
3293 | { |
|
|
3294 | if (will_kill_again & (1 << at)) |
3254 | if (will_kill_again & (1 << at)) |
3295 | force->resist[at] = 100; |
3255 | force->resist[at] = 100; |
3296 | } |
3256 | |
3297 | insert_ob_in_ob (force, op); |
3257 | insert_ob_in_ob (force, op); |
3298 | fix_player (op); |
3258 | fix_player (op); |
3299 | |
3259 | |
3300 | } |
3260 | } |
3301 | |
|
|
3302 | /**************************************/ |
|
|
3303 | /* */ |
|
|
3304 | /* Repaint the characters inv, and */ |
|
|
3305 | /* stats, and show a nasty message ;) */ |
|
|
3306 | /* */ |
|
|
3307 | |
|
|
3308 | /**************************************/ |
|
|
3309 | |
3261 | |
3310 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
3262 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
3311 | return; |
3263 | return; |
3312 | } /* NOT_PERMADETH */ |
3264 | } /* NOT_PERMADETH */ |
3313 | else |
3265 | else |
… | |
… | |
3319 | op->contr->party = NULL; |
3271 | op->contr->party = NULL; |
3320 | if (settings.set_title == TRUE) |
3272 | if (settings.set_title == TRUE) |
3321 | op->contr->own_title[0] = '\0'; |
3273 | op->contr->own_title[0] = '\0'; |
3322 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3274 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3323 | check_score (op); |
3275 | check_score (op); |
|
|
3276 | |
3324 | if (op->contr->ranges[range_golem] != NULL) |
3277 | if (op->contr->ranges[range_golem]) |
3325 | { |
3278 | { |
3326 | remove_friendly_object (op->contr->ranges[range_golem]); |
3279 | remove_friendly_object (op->contr->ranges[range_golem]); |
3327 | remove_ob (op->contr->ranges[range_golem]); |
3280 | remove_ob (op->contr->ranges[range_golem]); |
3328 | free_object (op->contr->ranges[range_golem]); |
3281 | free_object (op->contr->ranges[range_golem]); |
3329 | op->contr->ranges[range_golem] = NULL; |
3282 | op->contr->ranges[range_golem] = 0; |
3330 | op->contr->golem_count = 0; |
|
|
3331 | } |
3283 | } |
|
|
3284 | |
3332 | loot_object (op); /* Remove some of the items for good */ |
3285 | loot_object (op); /* Remove some of the items for good */ |
3333 | remove_ob (op); |
3286 | remove_ob (op); |
3334 | op->direction = 0; |
3287 | op->direction = 0; |
3335 | |
3288 | |
3336 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3289 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
… | |
… | |
3357 | op->map = map; |
3310 | op->map = map; |
3358 | /* please see resurrection.c: peterm */ |
3311 | /* please see resurrection.c: peterm */ |
3359 | dead_player (op); |
3312 | dead_player (op); |
3360 | } |
3313 | } |
3361 | else |
3314 | else |
3362 | { |
|
|
3363 | delete_character (op->name, 1); |
3315 | delete_character (op->name, 1); |
3364 | } |
3316 | } |
3365 | } |
3317 | |
3366 | play_again (op); |
3318 | play_again (op); |
3367 | |
3319 | |
3368 | /* peterm: added to create a corpse at deathsite. */ |
3320 | /* peterm: added to create a corpse at deathsite. */ |
3369 | tmp = arch_to_object (find_archetype ("corpse_pl")); |
3321 | tmp = arch_to_object (archetype::find ("corpse_pl")); |
3370 | sprintf (buf, "%s", &op->name); |
3322 | sprintf (buf, "%s", &op->name); |
3371 | tmp->name = tmp->name_pl = buf; |
3323 | tmp->name = tmp->name_pl = buf; |
3372 | tmp->level = op->level; |
3324 | tmp->level = op->level; |
3373 | tmp->x = x; |
3325 | tmp->x = x; |
3374 | tmp->y = y; |
3326 | tmp->y = y; |
… | |
… | |
3610 | int |
3562 | int |
3611 | stand_near_hostile (object *who) |
3563 | stand_near_hostile (object *who) |
3612 | { |
3564 | { |
3613 | object *tmp = NULL; |
3565 | object *tmp = NULL; |
3614 | int i, friendly = 0, player = 0, mflags; |
3566 | int i, friendly = 0, player = 0, mflags; |
3615 | mapstruct *m; |
3567 | maptile *m; |
3616 | sint16 x, y; |
3568 | sint16 x, y; |
3617 | |
3569 | |
3618 | if (!who) |
3570 | if (!who) |
3619 | return 0; |
3571 | return 0; |
3620 | |
3572 | |