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 */ |
|
|
32 | # include <pwd.h> |
25 | #include <pwd.h> |
33 | #endif |
|
|
34 | #ifndef __CEXTRACT__ |
|
|
35 | # include <sproto.h> |
26 | #include <sproto.h> |
36 | #endif |
|
|
37 | #include <sounds.h> |
27 | #include <sounds.h> |
38 | #include <living.h> |
28 | #include <living.h> |
39 | #include <object.h> |
29 | #include <object.h> |
40 | #include <spells.h> |
30 | #include <spells.h> |
41 | #include <skills.h> |
31 | #include <skills.h> |
… | |
… | |
214 | * the one that is passed. |
204 | * the one that is passed. |
215 | */ |
205 | */ |
216 | static player * |
206 | static player * |
217 | get_player (player *p) |
207 | get_player (player *p) |
218 | { |
208 | { |
219 | object *op = arch_to_object (get_player_archetype (NULL)); |
209 | object *op = arch_to_object (get_player_archetype (0)); |
220 | int i; |
210 | int i; |
221 | |
|
|
222 | if (!p) |
|
|
223 | { |
|
|
224 | p = new player; |
|
|
225 | |
|
|
226 | /* This adds the player in the linked list. There is extra |
|
|
227 | * complexity here because we want to add the new player at the |
|
|
228 | * end of the list - there is in fact no compelling reason that |
|
|
229 | * that needs to be done except for things like output of |
|
|
230 | * 'who'. |
|
|
231 | */ |
|
|
232 | player *tmp = first_player; |
|
|
233 | |
|
|
234 | while (tmp != NULL && tmp->next != NULL) |
|
|
235 | tmp = tmp->next; |
|
|
236 | if (tmp != NULL) |
|
|
237 | tmp->next = p; |
|
|
238 | else |
|
|
239 | first_player = p; |
|
|
240 | |
|
|
241 | p->next = NULL; |
|
|
242 | } |
|
|
243 | |
211 | |
244 | /* Clears basically the entire player structure except |
212 | /* Clears basically the entire player structure except |
245 | * for next and socket. |
213 | * for next and socket. |
246 | */ |
214 | */ |
247 | p->clear (); |
215 | p->clear (); |
… | |
… | |
266 | op->speed_left = 0.5; |
234 | op->speed_left = 0.5; |
267 | op->speed = 1.0; |
235 | op->speed = 1.0; |
268 | op->direction = 5; /* So player faces south */ |
236 | op->direction = 5; /* So player faces south */ |
269 | op->stats.wc = 2; |
237 | op->stats.wc = 2; |
270 | op->run_away = 25; /* Then we panick... */ |
238 | op->run_away = 25; /* Then we panick... */ |
|
|
239 | |
|
|
240 | { |
|
|
241 | int oldmon = p->socket->monitor_spells; // what a hack |
271 | p->socket.monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ |
242 | p->socket->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ |
272 | |
|
|
273 | roll_stats (op); |
243 | roll_stats (op); |
|
|
244 | p->socket->monitor_spells = oldmon; |
|
|
245 | } |
274 | p->state = ST_ROLL_STAT; |
246 | p->state = ST_ROLL_STAT; |
275 | clear_los (op); |
247 | clear_los (op); |
276 | |
248 | |
277 | p->gen_sp_armour = 10; |
249 | p->gen_sp_armour = 10; |
278 | p->last_speed = -1; |
250 | p->last_speed = -1; |
… | |
… | |
285 | p->peaceful = 1; /* default peaceful */ |
257 | p->peaceful = 1; /* default peaceful */ |
286 | p->do_los = 1; |
258 | p->do_los = 1; |
287 | p->explore = 0; |
259 | p->explore = 0; |
288 | p->no_shout = 0; /* default can shout */ |
260 | p->no_shout = 0; /* default can shout */ |
289 | |
261 | |
290 | strncpy (p->title, op->arch->clone.name, sizeof (p->title) - 1); |
262 | assign (p->title, op->arch->clone.name); |
291 | p->title[sizeof (p->title) - 1] = '\0'; |
|
|
292 | op->race = op->arch->clone.race; |
263 | op->race = op->arch->clone.race; |
293 | |
264 | |
294 | CLEAR_FLAG (op, FLAG_READY_SKILL); |
265 | CLEAR_FLAG (op, FLAG_READY_SKILL); |
295 | |
266 | |
296 | /* we need to clear these to -1 and not zero - otherwise, |
267 | /* we need to clear these to -1 and not zero - otherwise, |
… | |
… | |
301 | for (i = 0; i < NUM_SKILLS; i++) |
272 | for (i = 0; i < NUM_SKILLS; i++) |
302 | { |
273 | { |
303 | p->last_skill_exp[i] = -1; |
274 | p->last_skill_exp[i] = -1; |
304 | p->last_skill_ob[i] = NULL; |
275 | p->last_skill_ob[i] = NULL; |
305 | } |
276 | } |
|
|
277 | |
306 | for (i = 0; i < NROFATTACKS; i++) |
278 | for (i = 0; i < NROFATTACKS; i++) |
307 | { |
|
|
308 | p->last_resist[i] = -1; |
279 | p->last_resist[i] = -1; |
309 | } |
280 | |
310 | p->last_stats.exp = -1; |
281 | p->last_stats.exp = -1; |
311 | p->last_weight = (uint32) - 1; |
282 | p->last_weight = (uint32) - 1; |
312 | |
283 | |
313 | p->socket.update_look = 0; |
284 | p->socket->update_look = 0; |
314 | p->socket.look_position = 0; |
285 | p->socket->look_position = 0; |
|
|
286 | |
315 | return p; |
287 | return p; |
316 | } |
288 | } |
317 | |
289 | |
318 | /* This loads the first map an puts the player on it. */ |
290 | /* This loads the first map an puts the player on it. */ |
319 | static void |
291 | static void |
… | |
… | |
329 | * All we can really get in this is some settings like host and display |
301 | * All we can really get in this is some settings like host and display |
330 | * mode. |
302 | * mode. |
331 | */ |
303 | */ |
332 | |
304 | |
333 | int |
305 | int |
334 | add_player (NewSocket * ns) |
306 | add_player (client_socket *ns) |
335 | { |
307 | { |
336 | player *p; |
308 | player *p = new player; |
337 | |
309 | |
338 | p = get_player (NULL); |
|
|
339 | p->socket = *ns; |
310 | p->socket = ns; |
340 | p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
311 | ns->pl = p; |
341 | if (p->socket.faces_sent == NULL) |
312 | |
342 | fatal (OUT_OF_MEMORY); |
313 | p->next = first_player; |
343 | memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
314 | first_player = p; |
344 | /* Needed because the socket we just copied over needs to be cleared. |
315 | |
345 | * Note that this can result in a client reset if there is partial data |
316 | p = get_player (p); |
346 | * on the uncoming socket. |
317 | |
347 | */ |
|
|
348 | p->socket.inbuf.len = 0; |
|
|
349 | set_first_map (p->ob); |
318 | set_first_map (p->ob); |
350 | |
319 | |
351 | CLEAR_FLAG (p->ob, FLAG_FRIENDLY); |
320 | CLEAR_FLAG (p->ob, FLAG_FRIENDLY); |
352 | add_friendly_object (p->ob); |
321 | add_friendly_object (p->ob); |
353 | send_rules (p->ob); |
322 | send_rules (p->ob); |
354 | send_news (p->ob); |
323 | send_news (p->ob); |
355 | display_motd (p->ob); |
324 | display_motd (p->ob); |
356 | get_name (p->ob); |
325 | get_name (p->ob); |
|
|
326 | |
357 | return 0; |
327 | return 0; |
358 | } |
328 | } |
359 | |
329 | |
360 | /* |
330 | /* |
361 | * get_player_archetype() return next player archetype from archetype |
331 | * get_player_archetype() return next player archetype from archetype |
… | |
… | |
496 | path_to_player (object *mon, object *pl, unsigned mindiff) |
466 | path_to_player (object *mon, object *pl, unsigned mindiff) |
497 | { |
467 | { |
498 | rv_vector rv; |
468 | rv_vector rv; |
499 | sint16 x, y; |
469 | sint16 x, y; |
500 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
470 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
501 | mapstruct *m, *lastmap; |
471 | maptile *m, *lastmap; |
502 | |
472 | |
503 | get_rangevector (mon, pl, &rv, 0); |
473 | get_rangevector (mon, pl, &rv, 0); |
504 | |
474 | |
505 | if (rv.distance < mindiff) |
475 | if (rv.distance < mindiff) |
506 | return 0; |
476 | return 0; |
… | |
… | |
650 | (op->type == ARMOUR || op->type == BOOTS || |
620 | (op->type == ARMOUR || op->type == BOOTS || |
651 | op->type == CLOAK || op->type == HELMET || |
621 | op->type == CLOAK || op->type == HELMET || |
652 | op->type == SHIELD || op->type == GLOVES || |
622 | op->type == SHIELD || op->type == GLOVES || |
653 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
623 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
654 | { |
624 | { |
655 | remove_ob (op); |
625 | op->destroy (); |
656 | free_object (op); |
|
|
657 | continue; |
626 | continue; |
658 | } |
627 | } |
659 | } |
628 | } |
660 | |
629 | |
661 | /* This really needs to be better - we should really give |
630 | /* This really needs to be better - we should really give |
… | |
… | |
672 | if (tmp->type == op->type && tmp->name == op->name) |
641 | if (tmp->type == op->type && tmp->name == op->name) |
673 | break; |
642 | break; |
674 | |
643 | |
675 | if (tmp) |
644 | if (tmp) |
676 | { |
645 | { |
677 | remove_ob (op); |
646 | op->destroy (); |
678 | free_object (op); |
|
|
679 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
647 | LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); |
680 | continue; |
648 | continue; |
681 | } |
649 | } |
|
|
650 | |
682 | if (op->nrof > 1) |
651 | if (op->nrof > 1) |
683 | op->nrof = 1; |
652 | op->nrof = 1; |
684 | } |
653 | } |
685 | |
654 | |
686 | if (op->type == SPELLBOOK && op->inv) |
655 | if (op->type == SPELLBOOK && op->inv) |
… | |
… | |
698 | CLEAR_FLAG (op, FLAG_CURSED); |
667 | CLEAR_FLAG (op, FLAG_CURSED); |
699 | CLEAR_FLAG (op, FLAG_DAMNED); |
668 | CLEAR_FLAG (op, FLAG_DAMNED); |
700 | } |
669 | } |
701 | if (op->type == SPELL) |
670 | if (op->type == SPELL) |
702 | { |
671 | { |
703 | remove_ob (op); |
672 | op->destroy (); |
704 | free_object (op); |
|
|
705 | continue; |
673 | continue; |
706 | } |
674 | } |
707 | else if (op->type == SKILL) |
675 | else if (op->type == SKILL) |
708 | { |
676 | { |
709 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
677 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
… | |
… | |
722 | void |
690 | void |
723 | get_name (object *op) |
691 | get_name (object *op) |
724 | { |
692 | { |
725 | op->contr->write_buf[0] = '\0'; |
693 | op->contr->write_buf[0] = '\0'; |
726 | op->contr->state = ST_GET_NAME; |
694 | op->contr->state = ST_GET_NAME; |
727 | send_query (&op->contr->socket, 0, "What is your name?\n:"); |
695 | send_query (op->contr->socket, 0, "What is your name?\n:"); |
728 | } |
696 | } |
729 | |
697 | |
730 | void |
698 | void |
731 | get_password (object *op) |
699 | get_password (object *op) |
732 | { |
700 | { |
733 | op->contr->write_buf[0] = '\0'; |
701 | op->contr->write_buf[0] = '\0'; |
734 | op->contr->state = ST_GET_PASSWORD; |
702 | op->contr->state = ST_GET_PASSWORD; |
735 | send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); |
703 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); |
736 | } |
704 | } |
737 | |
705 | |
738 | void |
706 | void |
739 | play_again (object *op) |
707 | play_again (object *op) |
740 | { |
708 | { |
741 | op->contr->state = ST_PLAY_AGAIN; |
709 | op->contr->state = ST_PLAY_AGAIN; |
742 | op->chosen_skill = NULL; |
710 | op->chosen_skill = NULL; |
743 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); |
711 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); |
744 | /* a bit of a hack, but there are various places early in th |
712 | /* a bit of a hack, but there are various places early in th |
745 | * player creation process that a user can quit (eg, roll |
713 | * player creation process that a user can quit (eg, roll |
746 | * stats) that isn't removing the player. Taking a quick |
714 | * stats) that isn't removing the player. Taking a quick |
747 | * look, there are many places that call play_again without |
715 | * look, there are many places that call play_again without |
748 | * removing the player - it probably makes more sense |
716 | * removing the player - it probably makes more sense |
749 | * to leave it to play_again to remove the object in all |
717 | * to leave it to play_again to remove the object in all |
750 | * cases. |
718 | * cases. |
751 | */ |
719 | */ |
752 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
720 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
753 | remove_ob (op); |
721 | op->remove (); |
754 | /* Need to set this to null - otherwise, it could point to garbage, |
722 | /* Need to set this to null - otherwise, it could point to garbage, |
755 | * and draw() doesn't check to see if the player is removed, only if |
723 | * and draw() doesn't check to see if the player is removed, only if |
756 | * the map is null or not swapped out. |
724 | * the map is null or not swapped out. |
757 | */ |
725 | */ |
758 | op->map = NULL; |
726 | op->map = NULL; |
… | |
… | |
772 | player *pl = op->contr; |
740 | player *pl = op->contr; |
773 | shstr name = op->name; |
741 | shstr name = op->name; |
774 | |
742 | |
775 | op->contr = 0; |
743 | op->contr = 0; |
776 | op->type = 0; |
744 | op->type = 0; |
777 | op->free (1); |
745 | op->destroy (1); |
778 | pl = get_player (pl); |
746 | pl = get_player (pl); |
779 | op = pl->ob; |
747 | op = pl->ob; |
780 | add_friendly_object (op); |
748 | add_friendly_object (op); |
781 | op->contr->password[0] = '~'; |
749 | op->contr->password[0] = '~'; |
782 | op->name = op->name_pl = 0; |
750 | op->name = op->name_pl = 0; |
… | |
… | |
797 | confirm_password (object *op) |
765 | confirm_password (object *op) |
798 | { |
766 | { |
799 | |
767 | |
800 | op->contr->write_buf[0] = '\0'; |
768 | op->contr->write_buf[0] = '\0'; |
801 | op->contr->state = ST_CONFIRM_PASSWORD; |
769 | op->contr->state = ST_CONFIRM_PASSWORD; |
802 | send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); |
770 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); |
803 | } |
771 | } |
804 | |
772 | |
805 | void |
773 | void |
806 | get_party_password (object *op, partylist *party) |
774 | get_party_password (object *op, partylist *party) |
807 | { |
775 | { |
… | |
… | |
811 | return; |
779 | return; |
812 | } |
780 | } |
813 | op->contr->write_buf[0] = '\0'; |
781 | op->contr->write_buf[0] = '\0'; |
814 | op->contr->state = ST_GET_PARTY_PASSWORD; |
782 | op->contr->state = ST_GET_PARTY_PASSWORD; |
815 | op->contr->party_to_join = party; |
783 | op->contr->party_to_join = party; |
816 | send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); |
784 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); |
817 | } |
785 | } |
818 | |
786 | |
819 | |
787 | |
820 | /* This rolls four 1-6 rolls and sums the best 3 of the 4. */ |
788 | /* This rolls four 1-6 rolls and sums the best 3 of the 4. */ |
821 | int |
789 | int |
… | |
… | |
918 | |
886 | |
919 | void |
887 | void |
920 | Roll_Again (object *op) |
888 | Roll_Again (object *op) |
921 | { |
889 | { |
922 | esrv_new_player (op->contr, 0); |
890 | esrv_new_player (op->contr, 0); |
923 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
891 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, |
924 | "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); |
892 | "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); |
925 | } |
893 | } |
926 | |
894 | |
927 | void |
895 | void |
928 | Swap_Stat (object *op, int Swap_Second) |
896 | Swap_Stat (object *op, int Swap_Second) |
… | |
… | |
995 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
963 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
996 | } |
964 | } |
997 | else |
965 | else |
998 | Swap_Stat (op, stat_trans[keynum]); |
966 | Swap_Stat (op, stat_trans[keynum]); |
999 | |
967 | |
1000 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
968 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
1001 | return 1; |
969 | return 1; |
1002 | } |
970 | } |
1003 | switch (key) |
971 | switch (key) |
1004 | { |
972 | { |
1005 | case 'n': |
973 | case 'n': |
1006 | case 'N': |
974 | case 'N': |
1007 | { |
975 | { |
1008 | SET_FLAG (op, FLAG_WIZ); |
976 | SET_FLAG (op, FLAG_WIZ); |
1009 | if (op->map == NULL) |
977 | if (op->map == NULL) |
1010 | { |
978 | { |
1011 | LOG (llevError, "Map == NULL in state 2\n"); |
979 | LOG (llevError, "Map == NULL in state 2\n"); |
1012 | break; |
980 | break; |
1013 | } |
981 | } |
1014 | |
982 | |
1015 | #if 0 |
983 | #if 0 |
1016 | /* So that enter_exit will put us at startx/starty */ |
984 | /* So that enter_exit will put us at startx/starty */ |
1017 | op->x = -1; |
985 | op->x = -1; |
1018 | |
986 | |
1019 | enter_exit (op, NULL); |
987 | enter_exit (op, NULL); |
1020 | #endif |
988 | #endif |
1021 | SET_ANIMATION (op, 2); /* So player faces south */ |
989 | SET_ANIMATION (op, 2); /* So player faces south */ |
1022 | /* Enter exit adds a player otherwise */ |
990 | /* Enter exit adds a player otherwise */ |
1023 | add_statbonus (op); |
991 | add_statbonus (op); |
1024 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
992 | 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"); |
993 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); |
1026 | op->contr->state = ST_CHANGE_CLASS; |
994 | op->contr->state = ST_CHANGE_CLASS; |
1027 | if (op->msg) |
995 | if (op->msg) |
1028 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
996 | 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; |
997 | return 0; |
|
|
998 | } |
|
|
999 | case 'y': |
|
|
1000 | case 'Y': |
|
|
1001 | roll_stats (op); |
|
|
1002 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
|
|
1003 | return 1; |
|
|
1004 | |
|
|
1005 | case 'q': |
|
|
1006 | case 'Q': |
|
|
1007 | play_again (op); |
|
|
1008 | return 1; |
|
|
1009 | |
|
|
1010 | default: |
|
|
1011 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
|
|
1012 | return 0; |
1045 | } |
1013 | } |
1046 | return 0; |
1014 | return 0; |
1047 | } |
1015 | } |
1048 | |
1016 | |
1049 | /* This function takes the key that is passed, and does the |
1017 | /* This function takes the key that is passed, and does the |
… | |
… | |
1058 | { |
1026 | { |
1059 | int tmp_loop; |
1027 | int tmp_loop; |
1060 | |
1028 | |
1061 | if (key == 'q' || key == 'Q') |
1029 | if (key == 'q' || key == 'Q') |
1062 | { |
1030 | { |
1063 | remove_ob (op); |
1031 | op->remove (); |
1064 | play_again (op); |
1032 | play_again (op); |
1065 | return 0; |
1033 | return 0; |
1066 | } |
1034 | } |
1067 | if (key == 'd' || key == 'D') |
1035 | if (key == 'd' || key == 'D') |
1068 | { |
1036 | { |
1069 | char buf[MAX_BUF]; |
1037 | char buf[MAX_BUF]; |
1070 | |
1038 | |
1071 | /* this must before then initial items are given */ |
1039 | /* this must before then initial items are given */ |
1072 | esrv_new_player (op->contr, op->weight + op->carrying); |
1040 | esrv_new_player (op->contr, op->weight + op->carrying); |
|
|
1041 | |
1073 | create_treasure (find_treasurelist ("starting_wealth"), op, 0, 0, 0); |
1042 | treasurelist *tl = find_treasurelist ("starting_wealth"); |
|
|
1043 | if (tl) |
|
|
1044 | create_treasure (tl, op, 0, 0, 0); |
1074 | |
1045 | |
1075 | INVOKE_PLAYER (BIRTH, op->contr); |
1046 | INVOKE_PLAYER (BIRTH, op->contr); |
1076 | INVOKE_PLAYER (LOGIN, op->contr); |
1047 | INVOKE_PLAYER (LOGIN, op->contr); |
1077 | |
1048 | |
1078 | op->contr->state = ST_PLAYING; |
1049 | op->contr->state = ST_PLAYING; |
… | |
… | |
1103 | { |
1074 | { |
1104 | object *tmp; |
1075 | object *tmp; |
1105 | char mapname[MAX_BUF]; |
1076 | char mapname[MAX_BUF]; |
1106 | |
1077 | |
1107 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
1078 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
1108 | tmp = get_object (); |
1079 | tmp = object::create (); |
1109 | EXIT_PATH (tmp) = mapname; |
1080 | EXIT_PATH (tmp) = mapname; |
1110 | EXIT_X (tmp) = op->x; |
1081 | EXIT_X (tmp) = op->x; |
1111 | EXIT_Y (tmp) = op->y; |
1082 | EXIT_Y (tmp) = op->y; |
1112 | enter_exit (op, tmp); /* we don't really care if it succeeded; |
1083 | enter_exit (op, tmp); /* we don't really care if it succeeded; |
1113 | * if the map isn't there, then stay on the |
1084 | * if the map isn't there, then stay on the |
1114 | * default initial map */ |
1085 | * default initial map */ |
1115 | free_object (tmp); |
1086 | tmp->destroy (); |
1116 | } |
1087 | } |
1117 | else |
1088 | else |
1118 | { |
1089 | { |
1119 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1090 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1120 | } |
1091 | } |
… | |
… | |
1130 | { |
1101 | { |
1131 | shstr name = op->name; |
1102 | shstr name = op->name; |
1132 | int x = op->x, y = op->y; |
1103 | int x = op->x, y = op->y; |
1133 | |
1104 | |
1134 | remove_statbonus (op); |
1105 | remove_statbonus (op); |
1135 | remove_ob (op); |
1106 | op->remove (); |
1136 | op->arch = get_player_archetype (op->arch); |
1107 | op->arch = get_player_archetype (op->arch); |
1137 | copy_object (&op->arch->clone, op); |
1108 | op->arch->clone.copy_to (op); |
1138 | op->instantiate (); |
1109 | op->instantiate (); |
1139 | op->stats = op->contr->orig_stats; |
1110 | op->stats = op->contr->orig_stats; |
1140 | op->name = op->name_pl = name; |
1111 | op->name = op->name_pl = name; |
1141 | op->x = x; |
1112 | op->x = x; |
1142 | op->y = y; |
1113 | op->y = y; |
1143 | SET_ANIMATION (op, 2); /* So player faces south */ |
1114 | SET_ANIMATION (op, 2); /* So player faces south */ |
1144 | insert_ob_in_map (op, op->map, op, 0); |
1115 | insert_ob_in_map (op, op->map, op, 0); |
1145 | strncpy (op->contr->title, op->arch->clone.name, sizeof (op->contr->title) - 1); |
1116 | assign (op->contr->title, op->arch->clone.name); |
1146 | op->contr->title[sizeof (op->contr->title) - 1] = '\0'; |
|
|
1147 | add_statbonus (op); |
1117 | add_statbonus (op); |
1148 | tmp_loop = allowed_class (op); |
1118 | tmp_loop = allowed_class (op); |
1149 | } |
1119 | } |
1150 | |
1120 | |
1151 | update_object (op, UP_OBJ_FACE); |
1121 | update_object (op, UP_OBJ_FACE); |
1152 | esrv_update_item (UPD_FACE, op, op); |
1122 | esrv_update_item (UPD_FACE, op, op); |
1153 | fix_player (op); |
1123 | fix_player (op); |
1154 | op->stats.hp = op->stats.maxhp; |
1124 | op->stats.hp = op->stats.maxhp; |
1155 | op->stats.sp = op->stats.maxsp; |
1125 | op->stats.sp = op->stats.maxsp; |
1156 | op->stats.grace = 0; |
1126 | op->stats.grace = 0; |
|
|
1127 | |
1157 | if (op->msg) |
1128 | if (op->msg) |
1158 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1129 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
|
|
1130 | |
1159 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); |
1131 | 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; |
1132 | return 0; |
1161 | } |
1133 | } |
1162 | |
1134 | |
1163 | int |
1135 | int |
1164 | key_confirm_quit (object *op, char key) |
1136 | key_confirm_quit (object *op, char key) |
… | |
… | |
1186 | if (settings.set_title == TRUE) |
1158 | if (settings.set_title == TRUE) |
1187 | op->contr->own_title[0] = '\0'; |
1159 | op->contr->own_title[0] = '\0'; |
1188 | |
1160 | |
1189 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1161 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1190 | { |
1162 | { |
1191 | mapstruct *mp, *next; |
1163 | maptile *mp, *next; |
1192 | |
1164 | |
1193 | /* We need to hunt for any per player unique maps in memory and |
1165 | /* 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, |
1166 | * 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 |
1167 | * so that players named 'Ab' won't match against players 'Abe' pathname |
1196 | */ |
1168 | */ |
… | |
… | |
1270 | */ |
1242 | */ |
1271 | int |
1243 | int |
1272 | check_pick (object *op) |
1244 | check_pick (object *op) |
1273 | { |
1245 | { |
1274 | object *tmp, *next; |
1246 | object *tmp, *next; |
1275 | tag_t next_tag = 0, op_tag; |
|
|
1276 | int stop = 0; |
1247 | int stop = 0; |
1277 | int j, k, wvratio; |
1248 | int j, k, wvratio; |
1278 | char putstring[128], tmpstr[16]; |
1249 | char putstring[128], tmpstr[16]; |
1279 | |
1250 | |
1280 | |
|
|
1281 | /* if you're flying, you cna't pick up anything */ |
1251 | /* if you're flying, you cna't pick up anything */ |
1282 | if (op->move_type & MOVE_FLYING) |
1252 | if (op->move_type & MOVE_FLYING) |
1283 | return 1; |
1253 | return 1; |
1284 | |
1254 | |
1285 | op_tag = op->count; |
|
|
1286 | |
|
|
1287 | next = op->below; |
1255 | next = op->below; |
1288 | if (next) |
|
|
1289 | next_tag = next->count; |
|
|
1290 | |
1256 | |
1291 | /* loop while there are items on the floor that are not marked as |
1257 | /* loop while there are items on the floor that are not marked as |
1292 | * destroyed */ |
1258 | * destroyed */ |
1293 | while (next && !was_destroyed (next, next_tag)) |
1259 | while (next && !next->destroyed ()) |
1294 | { |
1260 | { |
1295 | tmp = next; |
1261 | tmp = next; |
1296 | next = tmp->below; |
1262 | next = tmp->below; |
1297 | if (next) |
|
|
1298 | next_tag = next->count; |
|
|
1299 | |
1263 | |
1300 | if (was_destroyed (op, op_tag)) |
1264 | if (op->destroyed ()) |
1301 | return 0; |
1265 | return 0; |
1302 | |
1266 | |
1303 | if (!can_pick (op, tmp)) |
1267 | if (!can_pick (op, tmp)) |
1304 | continue; |
1268 | continue; |
1305 | |
1269 | |
… | |
… | |
1313 | /* high not bit set? We're using the old autopickup model */ |
1277 | /* high not bit set? We're using the old autopickup model */ |
1314 | if (!(op->contr->mode & PU_NEWMODE)) |
1278 | if (!(op->contr->mode & PU_NEWMODE)) |
1315 | { |
1279 | { |
1316 | switch (op->contr->mode) |
1280 | switch (op->contr->mode) |
1317 | { |
1281 | { |
1318 | case 0: |
1282 | case 0: |
1319 | return 1; /* don't pick up */ |
1283 | return 1; /* don't pick up */ |
1320 | case 1: |
1284 | case 1: |
|
|
1285 | pick_up (op, tmp); |
|
|
1286 | return 1; |
|
|
1287 | case 2: |
|
|
1288 | pick_up (op, tmp); |
|
|
1289 | return 0; |
|
|
1290 | case 3: |
|
|
1291 | return 0; /* stop before pickup */ |
|
|
1292 | case 4: |
|
|
1293 | pick_up (op, tmp); |
|
|
1294 | break; |
|
|
1295 | case 5: |
|
|
1296 | pick_up (op, tmp); |
|
|
1297 | stop = 1; |
|
|
1298 | break; |
|
|
1299 | case 6: |
|
|
1300 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1321 | pick_up (op, tmp); |
1301 | pick_up (op, tmp); |
1322 | return 1; |
1302 | break; |
|
|
1303 | |
1323 | case 2: |
1304 | case 7: |
|
|
1305 | if (tmp->type == MONEY || tmp->type == GEM) |
1324 | pick_up (op, tmp); |
1306 | pick_up (op, tmp); |
1325 | return 0; |
1307 | break; |
1326 | case 3: |
1308 | |
1327 | return 0; /* stop before pickup */ |
1309 | default: |
1328 | case 4: |
1310 | /* use value density */ |
|
|
1311 | if (!QUERY_FLAG (tmp, FLAG_UNPAID) |
|
|
1312 | && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) |
1329 | pick_up (op, tmp); |
1313 | 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 | } |
1314 | } |
1351 | } |
1315 | } |
1352 | else |
1316 | else |
1353 | { /* old model */ |
1317 | { /* old model */ |
1354 | /* NEW pickup handling */ |
1318 | /* NEW pickup handling */ |
… | |
… | |
1437 | /* question: don't pick up known-poisonous stuff? */ |
1401 | /* question: don't pick up known-poisonous stuff? */ |
1438 | if (op->contr->mode & PU_FOOD) |
1402 | if (op->contr->mode & PU_FOOD) |
1439 | if (tmp->type == FOOD) |
1403 | if (tmp->type == FOOD) |
1440 | { |
1404 | { |
1441 | pick_up (op, tmp); |
1405 | pick_up (op, tmp); |
1442 | if (0) |
|
|
1443 | fprintf (stderr, "FOOD\n"); |
|
|
1444 | continue; |
1406 | continue; |
1445 | } |
1407 | } |
|
|
1408 | |
1446 | if (op->contr->mode & PU_DRINK) |
1409 | if (op->contr->mode & PU_DRINK) |
1447 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1410 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1448 | { |
1411 | { |
1449 | pick_up (op, tmp); |
1412 | pick_up (op, tmp); |
1450 | if (0) |
|
|
1451 | fprintf (stderr, "DRINK\n"); |
|
|
1452 | continue; |
1413 | continue; |
1453 | } |
1414 | } |
1454 | |
1415 | |
1455 | if (op->contr->mode & PU_POTION) |
1416 | if (op->contr->mode & PU_POTION) |
1456 | if (tmp->type == POTION) |
1417 | if (tmp->type == POTION) |
1457 | { |
1418 | { |
1458 | pick_up (op, tmp); |
1419 | pick_up (op, tmp); |
1459 | if (0) |
|
|
1460 | fprintf (stderr, "POTION\n"); |
|
|
1461 | continue; |
1420 | continue; |
1462 | } |
1421 | } |
1463 | |
1422 | |
1464 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1423 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1465 | if (op->contr->mode & PU_SPELLBOOK) |
1424 | if (op->contr->mode & PU_SPELLBOOK) |
1466 | if (tmp->type == SPELLBOOK) |
1425 | if (tmp->type == SPELLBOOK) |
1467 | { |
1426 | { |
1468 | pick_up (op, tmp); |
1427 | pick_up (op, tmp); |
1469 | if (0) |
|
|
1470 | fprintf (stderr, "SPELLBOOK\n"); |
|
|
1471 | continue; |
1428 | continue; |
1472 | } |
1429 | } |
|
|
1430 | |
1473 | if (op->contr->mode & PU_SKILLSCROLL) |
1431 | if (op->contr->mode & PU_SKILLSCROLL) |
1474 | if (tmp->type == SKILLSCROLL) |
1432 | if (tmp->type == SKILLSCROLL) |
1475 | { |
1433 | { |
1476 | pick_up (op, tmp); |
1434 | pick_up (op, tmp); |
1477 | if (0) |
|
|
1478 | fprintf (stderr, "SKILLSCROLL\n"); |
|
|
1479 | continue; |
1435 | continue; |
1480 | } |
1436 | } |
|
|
1437 | |
1481 | if (op->contr->mode & PU_READABLES) |
1438 | if (op->contr->mode & PU_READABLES) |
1482 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1439 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1483 | { |
1440 | { |
1484 | pick_up (op, tmp); |
1441 | pick_up (op, tmp); |
1485 | if (0) |
|
|
1486 | fprintf (stderr, "READABLES\n"); |
|
|
1487 | continue; |
1442 | continue; |
1488 | } |
1443 | } |
1489 | |
1444 | |
1490 | /* wands/staves/rods/horns */ |
1445 | /* wands/staves/rods/horns */ |
1491 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1446 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1492 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1447 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1493 | { |
1448 | { |
1494 | pick_up (op, tmp); |
1449 | pick_up (op, tmp); |
1495 | if (0) |
|
|
1496 | fprintf (stderr, "MAGIC_DEVICE\n"); |
|
|
1497 | continue; |
1450 | continue; |
1498 | } |
1451 | } |
1499 | |
1452 | |
1500 | /* pick up all magical items */ |
1453 | /* pick up all magical items */ |
1501 | if (op->contr->mode & PU_MAGICAL) |
1454 | if (op->contr->mode & PU_MAGICAL) |
1502 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1455 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1503 | { |
1456 | { |
1504 | pick_up (op, tmp); |
1457 | pick_up (op, tmp); |
1505 | if (0) |
|
|
1506 | fprintf (stderr, "MAGICAL\n"); |
|
|
1507 | continue; |
1458 | continue; |
1508 | } |
1459 | } |
1509 | |
1460 | |
1510 | if (op->contr->mode & PU_VALUABLES) |
1461 | if (op->contr->mode & PU_VALUABLES) |
1511 | { |
1462 | { |
1512 | if (tmp->type == MONEY || tmp->type == GEM) |
1463 | if (tmp->type == MONEY || tmp->type == GEM) |
1513 | { |
1464 | { |
1514 | pick_up (op, tmp); |
1465 | pick_up (op, tmp); |
1515 | if (0) |
|
|
1516 | fprintf (stderr, "MONEY/GEM\n"); |
|
|
1517 | continue; |
1466 | continue; |
1518 | } |
1467 | } |
1519 | } |
1468 | } |
1520 | |
1469 | |
1521 | /* rings & amulets - talismans seems to be typed AMULET */ |
1470 | /* rings & amulets - talismans seems to be typed AMULET */ |
1522 | if (op->contr->mode & PU_JEWELS) |
1471 | if (op->contr->mode & PU_JEWELS) |
1523 | if (tmp->type == RING || tmp->type == AMULET) |
1472 | if (tmp->type == RING || tmp->type == AMULET) |
1524 | { |
1473 | { |
1525 | pick_up (op, tmp); |
1474 | pick_up (op, tmp); |
|
|
1475 | continue; |
1526 | if (0) |
1476 | } |
1527 | fprintf (stderr, "JEWELS\n"); |
1477 | |
|
|
1478 | /* we don't forget dragon food */ |
|
|
1479 | if (op->contr->mode & PU_FLESH) |
|
|
1480 | if (tmp->type == FLESH) |
|
|
1481 | { |
|
|
1482 | pick_up (op, tmp); |
1528 | continue; |
1483 | continue; |
1529 | } |
1484 | } |
1530 | |
1485 | |
1531 | /* bows and arrows. Bows are good for selling! */ |
1486 | /* bows and arrows. Bows are good for selling! */ |
1532 | if (op->contr->mode & PU_BOW) |
1487 | if (op->contr->mode & PU_BOW) |
1533 | if (tmp->type == BOW) |
1488 | if (tmp->type == BOW) |
1534 | { |
1489 | { |
1535 | pick_up (op, tmp); |
1490 | pick_up (op, tmp); |
1536 | if (0) |
|
|
1537 | fprintf (stderr, "BOW\n"); |
|
|
1538 | continue; |
1491 | continue; |
1539 | } |
1492 | } |
|
|
1493 | |
1540 | if (op->contr->mode & PU_ARROW) |
1494 | if (op->contr->mode & PU_ARROW) |
1541 | if (tmp->type == ARROW) |
1495 | if (tmp->type == ARROW) |
1542 | { |
1496 | { |
1543 | pick_up (op, tmp); |
1497 | pick_up (op, tmp); |
1544 | if (0) |
|
|
1545 | fprintf (stderr, "ARROW\n"); |
|
|
1546 | continue; |
1498 | continue; |
1547 | } |
1499 | } |
1548 | |
1500 | |
1549 | /* all kinds of armor etc. */ |
1501 | /* all kinds of armor etc. */ |
1550 | if (op->contr->mode & PU_ARMOUR) |
1502 | if (op->contr->mode & PU_ARMOUR) |
1551 | if (tmp->type == ARMOUR) |
1503 | if (tmp->type == ARMOUR) |
1552 | { |
1504 | { |
1553 | pick_up (op, tmp); |
1505 | pick_up (op, tmp); |
1554 | if (0) |
|
|
1555 | fprintf (stderr, "ARMOUR\n"); |
|
|
1556 | continue; |
1506 | continue; |
1557 | } |
1507 | } |
|
|
1508 | |
1558 | if (op->contr->mode & PU_HELMET) |
1509 | if (op->contr->mode & PU_HELMET) |
1559 | if (tmp->type == HELMET) |
1510 | if (tmp->type == HELMET) |
1560 | { |
1511 | { |
1561 | pick_up (op, tmp); |
1512 | pick_up (op, tmp); |
1562 | if (0) |
|
|
1563 | fprintf (stderr, "HELMET\n"); |
|
|
1564 | continue; |
1513 | continue; |
1565 | } |
1514 | } |
|
|
1515 | |
1566 | if (op->contr->mode & PU_SHIELD) |
1516 | if (op->contr->mode & PU_SHIELD) |
1567 | if (tmp->type == SHIELD) |
1517 | if (tmp->type == SHIELD) |
1568 | { |
1518 | { |
1569 | pick_up (op, tmp); |
1519 | pick_up (op, tmp); |
1570 | if (0) |
|
|
1571 | fprintf (stderr, "SHIELD\n"); |
|
|
1572 | continue; |
1520 | continue; |
1573 | } |
1521 | } |
|
|
1522 | |
1574 | if (op->contr->mode & PU_BOOTS) |
1523 | if (op->contr->mode & PU_BOOTS) |
1575 | if (tmp->type == BOOTS) |
1524 | if (tmp->type == BOOTS) |
1576 | { |
1525 | { |
1577 | pick_up (op, tmp); |
1526 | pick_up (op, tmp); |
1578 | if (0) |
|
|
1579 | fprintf (stderr, "BOOTS\n"); |
|
|
1580 | continue; |
1527 | continue; |
1581 | } |
1528 | } |
|
|
1529 | |
1582 | if (op->contr->mode & PU_GLOVES) |
1530 | if (op->contr->mode & PU_GLOVES) |
1583 | if (tmp->type == GLOVES) |
1531 | if (tmp->type == GLOVES) |
1584 | { |
1532 | { |
1585 | pick_up (op, tmp); |
1533 | pick_up (op, tmp); |
1586 | if (0) |
|
|
1587 | fprintf (stderr, "GLOVES\n"); |
|
|
1588 | continue; |
1534 | continue; |
1589 | } |
1535 | } |
|
|
1536 | |
1590 | if (op->contr->mode & PU_CLOAK) |
1537 | if (op->contr->mode & PU_CLOAK) |
1591 | if (tmp->type == CLOAK) |
1538 | if (tmp->type == CLOAK) |
1592 | { |
1539 | { |
1593 | pick_up (op, tmp); |
1540 | pick_up (op, tmp); |
1594 | if (0) |
|
|
1595 | fprintf (stderr, "GLOVES\n"); |
|
|
1596 | continue; |
1541 | continue; |
1597 | } |
1542 | } |
1598 | |
1543 | |
1599 | /* hoping to catch throwing daggers here */ |
1544 | /* hoping to catch throwing daggers here */ |
1600 | if (op->contr->mode & PU_MISSILEWEAPON) |
1545 | if (op->contr->mode & PU_MISSILEWEAPON) |
1601 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1546 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1602 | { |
1547 | { |
1603 | pick_up (op, tmp); |
1548 | pick_up (op, tmp); |
1604 | if (0) |
|
|
1605 | fprintf (stderr, "MISSILEWEAPON\n"); |
|
|
1606 | continue; |
1549 | continue; |
1607 | } |
1550 | } |
1608 | |
1551 | |
1609 | /* careful: chairs and tables are weapons! */ |
1552 | /* careful: chairs and tables are weapons! */ |
1610 | if (op->contr->mode & PU_ALLWEAPON) |
1553 | if (op->contr->mode & PU_ALLWEAPON) |
… | |
… | |
1613 | { |
1556 | { |
1614 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1557 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1615 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1558 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1616 | { |
1559 | { |
1617 | pick_up (op, tmp); |
1560 | pick_up (op, tmp); |
1618 | if (0) |
|
|
1619 | fprintf (stderr, "WEAPON\n"); |
|
|
1620 | continue; |
1561 | continue; |
1621 | } |
1562 | } |
1622 | } |
1563 | } |
|
|
1564 | |
1623 | if (tmp->type == WEAPON && tmp->name == NULL) |
1565 | if (tmp->type == WEAPON && tmp->name == NULL) |
1624 | { |
1566 | { |
1625 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1567 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1626 | { |
1568 | { |
1627 | pick_up (op, tmp); |
1569 | pick_up (op, tmp); |
1628 | if (0) |
|
|
1629 | fprintf (stderr, "WEAPON\n"); |
|
|
1630 | continue; |
1570 | continue; |
1631 | } |
1571 | } |
1632 | } |
1572 | } |
1633 | } |
1573 | } |
1634 | |
1574 | |
1635 | /* misc stuff that's useful */ |
1575 | /* misc stuff that's useful */ |
1636 | if (op->contr->mode & PU_KEY) |
1576 | if (op->contr->mode & PU_KEY) |
1637 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1577 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1638 | { |
1578 | { |
1639 | pick_up (op, tmp); |
1579 | pick_up (op, tmp); |
1640 | if (0) |
|
|
1641 | fprintf (stderr, "KEY\n"); |
|
|
1642 | continue; |
1580 | continue; |
1643 | } |
1581 | } |
1644 | |
1582 | |
1645 | /* any of the last 4 bits set means we use the ratio for value |
1583 | /* any of the last 4 bits set means we use the ratio for value |
1646 | * pickups */ |
1584 | * pickups */ |
… | |
… | |
1668 | continue; |
1606 | continue; |
1669 | } |
1607 | } |
1670 | } |
1608 | } |
1671 | } /* the new pickup model */ |
1609 | } /* the new pickup model */ |
1672 | } |
1610 | } |
|
|
1611 | |
1673 | return !stop; |
1612 | return !stop; |
1674 | } |
1613 | } |
1675 | |
1614 | |
1676 | /* |
1615 | /* |
1677 | * Find an arrow in the inventory and after that |
1616 | * Find an arrow in the inventory and after that |
… | |
… | |
1776 | |
1715 | |
1777 | object * |
1716 | object * |
1778 | pick_arrow_target (object *op, const char *type, int dir) |
1717 | pick_arrow_target (object *op, const char *type, int dir) |
1779 | { |
1718 | { |
1780 | object *tmp = NULL; |
1719 | object *tmp = NULL; |
1781 | mapstruct *m; |
1720 | maptile *m; |
1782 | int i, mflags, found, number; |
1721 | int i, mflags, found, number; |
1783 | sint16 x, y; |
1722 | sint16 x, y; |
1784 | |
1723 | |
1785 | if (op->map == NULL) |
1724 | if (op->map == NULL) |
1786 | return find_arrow (op, type); |
1725 | return find_arrow (op, type); |
… | |
… | |
1846 | */ |
1785 | */ |
1847 | int |
1786 | int |
1848 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1787 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1849 | { |
1788 | { |
1850 | object *left, *bow; |
1789 | object *left, *bow; |
1851 | tag_t left_tag, tag; |
|
|
1852 | int bowspeed, mflags; |
1790 | int bowspeed, mflags; |
1853 | mapstruct *m; |
1791 | maptile *m; |
1854 | |
1792 | |
1855 | if (!dir) |
1793 | if (!dir) |
1856 | { |
1794 | { |
1857 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1795 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1858 | return 0; |
1796 | return 0; |
… | |
… | |
1912 | } |
1850 | } |
1913 | |
1851 | |
1914 | /* this should not happen, but sometimes does */ |
1852 | /* this should not happen, but sometimes does */ |
1915 | if (arrow->nrof == 0) |
1853 | if (arrow->nrof == 0) |
1916 | { |
1854 | { |
1917 | remove_ob (arrow); |
1855 | arrow->destroy (); |
1918 | free_object (arrow); |
|
|
1919 | return 0; |
1856 | return 0; |
1920 | } |
1857 | } |
1921 | |
1858 | |
1922 | left = arrow; /* these are arrows left to the player */ |
1859 | left = arrow; /* these are arrows left to the player */ |
1923 | left_tag = left->count; |
|
|
1924 | arrow = get_split_ob (arrow, 1); |
1860 | arrow = get_split_ob (arrow, 1); |
1925 | if (arrow == NULL) |
1861 | if (arrow == NULL) |
1926 | { |
1862 | { |
1927 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1863 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1928 | return 0; |
1864 | return 0; |
1929 | } |
1865 | } |
1930 | set_owner (arrow, op); |
1866 | arrow->set_owner (op); |
1931 | arrow->skill = bow->skill; |
1867 | arrow->skill = bow->skill; |
1932 | |
1868 | |
1933 | arrow->direction = dir; |
1869 | arrow->direction = dir; |
1934 | arrow->x = sx; |
1870 | arrow->x = sx; |
1935 | arrow->y = sy; |
1871 | arrow->y = sy; |
… | |
… | |
1943 | SET_ANIMATION (arrow, arrow->direction); |
1879 | SET_ANIMATION (arrow, arrow->direction); |
1944 | arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ |
1880 | arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ |
1945 | arrow->stats.hp = arrow->stats.dam; |
1881 | arrow->stats.hp = arrow->stats.dam; |
1946 | arrow->stats.grace = arrow->attacktype; |
1882 | arrow->stats.grace = arrow->attacktype; |
1947 | if (arrow->slaying != NULL) |
1883 | if (arrow->slaying != NULL) |
1948 | arrow->spellarg = strdup_local (arrow->slaying); |
1884 | arrow->spellarg = strdup (arrow->slaying); |
1949 | |
1885 | |
1950 | /* Note that this was different for monsters - they got their level |
1886 | /* Note that this was different for monsters - they got their level |
1951 | * added to the damage. I think the strength bonus is more proper. |
1887 | * added to the damage. I think the strength bonus is more proper. |
1952 | */ |
1888 | */ |
1953 | |
1889 | |
… | |
… | |
1971 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1907 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1972 | } |
1908 | } |
1973 | else |
1909 | else |
1974 | { |
1910 | { |
1975 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1911 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1976 | |
|
|
1977 | arrow->level = op->level; |
1912 | arrow->level = op->level; |
1978 | } |
1913 | } |
|
|
1914 | |
1979 | if (arrow->attacktype == AT_PHYSICAL) |
1915 | if (arrow->attacktype == AT_PHYSICAL) |
1980 | arrow->attacktype |= bow->attacktype; |
1916 | arrow->attacktype |= bow->attacktype; |
|
|
1917 | |
1981 | if (bow->slaying != NULL) |
1918 | if (bow->slaying != NULL) |
1982 | arrow->slaying = bow->slaying; |
1919 | arrow->slaying = bow->slaying; |
1983 | |
1920 | |
1984 | arrow->map = m; |
1921 | arrow->map = m; |
1985 | arrow->move_type = MOVE_FLY_LOW; |
1922 | arrow->move_type = MOVE_FLY_LOW; |
1986 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1923 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1987 | |
1924 | |
1988 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1925 | 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); |
1926 | insert_ob_in_map (arrow, m, op, 0); |
1991 | |
1927 | |
1992 | if (!was_destroyed (arrow, tag)) |
1928 | if (!arrow->destroyed ()) |
1993 | move_arrow (arrow); |
1929 | move_arrow (arrow); |
1994 | |
1930 | |
1995 | if (op->type == PLAYER) |
1931 | if (op->type == PLAYER) |
1996 | { |
1932 | { |
1997 | if (was_destroyed (left, left_tag)) |
1933 | if (left->destroyed ()) |
1998 | esrv_del_item (op->contr, left_tag); |
1934 | esrv_del_item (op->contr, left->count); |
1999 | else |
1935 | else |
2000 | esrv_send_item (op, left); |
1936 | esrv_send_item (op, left); |
2001 | } |
1937 | } |
|
|
1938 | |
2002 | return 1; |
1939 | return 1; |
2003 | } |
1940 | } |
2004 | |
1941 | |
2005 | /* Special fire code for players - this takes into |
1942 | /* Special fire code for players - this takes into |
2006 | * account the special fire modes players can have |
1943 | * account the special fire modes players can have |
… | |
… | |
2126 | if (action_makes_visible (op)) |
2063 | if (action_makes_visible (op)) |
2127 | make_visible (op); |
2064 | make_visible (op); |
2128 | |
2065 | |
2129 | switch (op->contr->shoottype) |
2066 | switch (op->contr->shoottype) |
2130 | { |
2067 | { |
2131 | case range_none: |
2068 | case range_none: |
2132 | return; |
2069 | return; |
2133 | |
2070 | |
2134 | case range_bow: |
2071 | case range_bow: |
2135 | player_fire_bow (op, dir); |
2072 | player_fire_bow (op, dir); |
2136 | return; |
2073 | return; |
2137 | |
2074 | |
2138 | case range_magic: /* Casting spells */ |
2075 | 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)); |
2076 | spellcost = (cast_spell (op, op, dir, op->contr->ranges[range_magic], op->contr->spellparam[0] ? op->contr->spellparam : 0)); |
2140 | return; |
2077 | return; |
2141 | |
2078 | |
2142 | case range_misc: |
2079 | case range_misc: |
2143 | fire_misc_object (op, dir); |
2080 | fire_misc_object (op, dir); |
2144 | return; |
2081 | return; |
2145 | |
2082 | |
2146 | case range_golem: /* Control summoned monsters from scrolls */ |
2083 | 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) |
2084 | if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2148 | { |
2085 | { |
2149 | op->contr->ranges[range_golem] = NULL; |
2086 | op->contr->ranges[range_golem] = 0; |
2150 | op->contr->shoottype = range_none; |
2087 | op->contr->shoottype = range_none; |
2151 | op->contr->golem_count = 0; |
|
|
2152 | } |
2088 | } |
2153 | else |
2089 | else |
2154 | control_golem (op->contr->ranges[range_golem], dir); |
2090 | control_golem (op->contr->ranges[range_golem], dir); |
2155 | return; |
2091 | return; |
2156 | |
2092 | |
2157 | case range_skill: |
2093 | case range_skill: |
2158 | if (!op->chosen_skill) |
2094 | if (!op->chosen_skill) |
2159 | { |
2095 | { |
2160 | if (op->type == PLAYER) |
2096 | if (op->type == PLAYER) |
2161 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
2097 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
2162 | return; |
2098 | return; |
2163 | } |
2099 | } |
2164 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
2100 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
2165 | return; |
2101 | return; |
2166 | case range_builder: |
2102 | case range_builder: |
2167 | apply_map_builder (op, dir); |
2103 | apply_map_builder (op, dir); |
2168 | return; |
2104 | return; |
2169 | default: |
2105 | default: |
2170 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
2106 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
2171 | return; |
2107 | return; |
2172 | } |
2108 | } |
2173 | } |
2109 | } |
2174 | |
2110 | |
2175 | |
2111 | |
2176 | |
2112 | |
… | |
… | |
2318 | move_player_attack (object *op, int dir) |
2254 | move_player_attack (object *op, int dir) |
2319 | { |
2255 | { |
2320 | object *tmp, *mon; |
2256 | object *tmp, *mon; |
2321 | sint16 nx, ny; |
2257 | sint16 nx, ny; |
2322 | int on_battleground; |
2258 | int on_battleground; |
2323 | mapstruct *m; |
2259 | maptile *m; |
2324 | |
2260 | |
2325 | nx = freearr_x[dir] + op->x; |
2261 | nx = freearr_x[dir] + op->x; |
2326 | ny = freearr_y[dir] + op->y; |
2262 | ny = freearr_y[dir] + op->y; |
2327 | |
2263 | |
2328 | on_battleground = op_on_battleground (op, NULL, NULL); |
2264 | on_battleground = op_on_battleground (op, NULL, NULL); |
… | |
… | |
2364 | if (tmp == op) |
2300 | if (tmp == op) |
2365 | { |
2301 | { |
2366 | tmp = tmp->above; |
2302 | tmp = tmp->above; |
2367 | continue; |
2303 | continue; |
2368 | } |
2304 | } |
|
|
2305 | |
2369 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2306 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2370 | { |
2307 | { |
2371 | mon = tmp; |
2308 | mon = tmp; |
2372 | break; |
2309 | break; |
2373 | } |
2310 | } |
|
|
2311 | |
2374 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2312 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2375 | mon = tmp; |
2313 | mon = tmp; |
|
|
2314 | |
2376 | tmp = tmp->above; |
2315 | tmp = tmp->above; |
2377 | } |
2316 | } |
2378 | |
2317 | |
2379 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2318 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2380 | return; /* into a wall */ |
2319 | return; /* into a wall */ |
… | |
… | |
2399 | * player owns it and it is either friendly or unagressive. |
2338 | * player owns it and it is either friendly or unagressive. |
2400 | */ |
2339 | */ |
2401 | if ((op->type == PLAYER) |
2340 | if ((op->type == PLAYER) |
2402 | #if COZY_SERVER |
2341 | #if COZY_SERVER |
2403 | && |
2342 | && |
2404 | ((get_owner (mon) && get_owner (mon)->contr |
2343 | ((mon->owner && mon->owner->contr |
2405 | && same_party (get_owner (mon)->contr->party, op->contr->party)) || get_owner (mon) == op) |
2344 | && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op) |
2406 | #else |
2345 | #else |
2407 | && get_owner (mon) == op |
2346 | && mon->owner == op |
2408 | #endif |
2347 | #endif |
2409 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2348 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2410 | { |
2349 | { |
2411 | /* If we're braced, we don't want to switch places with it */ |
2350 | /* If we're braced, we don't want to switch places with it */ |
2412 | if (op->contr->braced) |
2351 | if (op->contr->braced) |
… | |
… | |
2599 | /* I've been seeing crashes where the golem has been destroyed, but |
2538 | /* I've been seeing crashes where the golem has been destroyed, but |
2600 | * the player object still points to the defunct golem. The code that |
2539 | * the player object still points to the defunct golem. The code that |
2601 | * destroys the golem looks correct, and it doesn't always happen, so |
2540 | * destroys the golem looks correct, and it doesn't always happen, so |
2602 | * put this in a a workaround to clean up the golem pointer. |
2541 | * put this in a a workaround to clean up the golem pointer. |
2603 | */ |
2542 | */ |
2604 | if (op->contr->ranges[range_golem] && |
|
|
2605 | ((op->contr->golem_count != op->contr->ranges[range_golem]->count) || QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))) |
2543 | if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2606 | { |
|
|
2607 | op->contr->ranges[range_golem] = NULL; |
2544 | op->contr->ranges[range_golem] = 0; |
2608 | op->contr->golem_count = 0; |
|
|
2609 | } |
|
|
2610 | |
2545 | |
2611 | /* call this here - we also will call this in do_ericserver, but |
2546 | /* call this here - we also will call this in do_ericserver, but |
2612 | * the players time has been increased when doericserver has been |
2547 | * the players time has been increased when doericserver has been |
2613 | * called, so we recheck it here. |
2548 | * called, so we recheck it here. |
2614 | */ |
2549 | */ |
2615 | HandleClient (&op->contr->socket, op->contr); |
2550 | HandleClient (op->contr->socket, op->contr); |
2616 | if (op->speed_left < 0) |
2551 | if (op->speed_left < 0) |
2617 | return 0; |
2552 | return 0; |
2618 | |
2553 | |
2619 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2554 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2620 | { |
2555 | { |
… | |
… | |
2629 | if (op->speed_left > 0) |
2564 | if (op->speed_left > 0) |
2630 | return 1; |
2565 | return 1; |
2631 | else |
2566 | else |
2632 | return 0; |
2567 | return 0; |
2633 | } |
2568 | } |
|
|
2569 | |
2634 | return 0; |
2570 | return 0; |
2635 | } |
2571 | } |
2636 | |
2572 | |
2637 | int |
2573 | int |
2638 | save_life (object *op) |
2574 | save_life (object *op) |
2639 | { |
2575 | { |
2640 | object *tmp; |
|
|
2641 | |
|
|
2642 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2576 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2643 | return 0; |
2577 | return 0; |
2644 | |
2578 | |
2645 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2579 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
2646 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2580 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2647 | { |
2581 | { |
2648 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); |
2582 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); |
2649 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2583 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
|
|
2584 | |
2650 | if (op->contr) |
2585 | if (op->contr) |
2651 | esrv_del_item (op->contr, tmp->count); |
2586 | esrv_del_item (op->contr, tmp->count); |
2652 | remove_ob (tmp); |
2587 | |
2653 | free_object (tmp); |
2588 | tmp->destroy (); |
2654 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2589 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
|
|
2590 | |
2655 | if (op->stats.hp < 0) |
2591 | if (op->stats.hp < 0) |
2656 | op->stats.hp = op->stats.maxhp; |
2592 | op->stats.hp = op->stats.maxhp; |
|
|
2593 | |
2657 | if (op->stats.food < 0) |
2594 | if (op->stats.food < 0) |
2658 | op->stats.food = 999; |
2595 | op->stats.food = 999; |
|
|
2596 | |
2659 | fix_player (op); |
2597 | fix_player (op); |
2660 | return 1; |
2598 | return 1; |
2661 | } |
2599 | } |
|
|
2600 | |
2662 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2601 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2663 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2602 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2664 | enter_player_savebed (op); /* bring him home. */ |
2603 | enter_player_savebed (op); /* bring him home. */ |
2665 | return 0; |
2604 | return 0; |
2666 | } |
2605 | } |
… | |
… | |
2680 | next = op->below; /* Make sure we have a good value, in case |
2619 | next = op->below; /* Make sure we have a good value, in case |
2681 | * we remove object 'op' |
2620 | * we remove object 'op' |
2682 | */ |
2621 | */ |
2683 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2622 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2684 | { |
2623 | { |
2685 | remove_ob (op); |
2624 | op->remove (); |
2686 | op->x = env->x; |
2625 | op->x = env->x; |
2687 | op->y = env->y; |
2626 | op->y = env->y; |
2688 | if (env->type == PLAYER) |
2627 | if (env->type == PLAYER) |
2689 | esrv_del_item (env->contr, op->count); |
2628 | esrv_del_item (env->contr, op->count); |
2690 | insert_ob_in_map (op, env->map, NULL, 0); |
2629 | insert_ob_in_map (op, env->map, NULL, 0); |
2691 | } |
2630 | } |
2692 | else if (op->inv) |
2631 | else if (op->inv) |
2693 | remove_unpaid_objects (op->inv, env); |
2632 | remove_unpaid_objects (op->inv, env); |
|
|
2633 | |
2694 | op = next; |
2634 | op = next; |
2695 | } |
2635 | } |
2696 | } |
2636 | } |
2697 | |
2637 | |
2698 | |
2638 | |
… | |
… | |
2713 | strcpy (buf2, " R.I.P.\n\n"); |
2653 | strcpy (buf2, " R.I.P.\n\n"); |
2714 | if (op->type == PLAYER) |
2654 | if (op->type == PLAYER) |
2715 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2655 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2716 | else |
2656 | else |
2717 | sprintf (buf, "%s\n", &op->name); |
2657 | sprintf (buf, "%s\n", &op->name); |
|
|
2658 | |
2718 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2659 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2719 | strcat (buf2, buf); |
2660 | strcat (buf2, buf); |
2720 | if (op->type == PLAYER) |
2661 | if (op->type == PLAYER) |
2721 | sprintf (buf, "who was in level %d when killed\n", op->level); |
2662 | sprintf (buf, "who was in level %d when killed\n", op->level); |
2722 | else |
2663 | else |
2723 | sprintf (buf, "who was in level %d when died.\n\n", op->level); |
2664 | sprintf (buf, "who was in level %d when died.\n\n", op->level); |
|
|
2665 | |
2724 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2666 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2725 | strcat (buf2, buf); |
2667 | strcat (buf2, buf); |
2726 | if (op->type == PLAYER) |
2668 | if (op->type == PLAYER) |
2727 | { |
2669 | { |
2728 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2670 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2729 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2671 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2730 | strcat (buf2, buf); |
2672 | strcat (buf2, buf); |
2731 | } |
2673 | } |
|
|
2674 | |
2732 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2675 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2733 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2676 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2734 | strcat (buf2, buf); |
2677 | strcat (buf2, buf); |
|
|
2678 | |
2735 | return buf2; |
2679 | return buf2; |
2736 | } |
2680 | } |
2737 | |
2681 | |
2738 | |
2682 | |
2739 | |
2683 | |
… | |
… | |
2958 | { |
2902 | { |
2959 | char buf[MAX_BUF]; |
2903 | char buf[MAX_BUF]; |
2960 | int x, y; |
2904 | int x, y; |
2961 | |
2905 | |
2962 | //int i; |
2906 | //int i; |
2963 | mapstruct *map; /* this is for resurrection */ |
2907 | maptile *map; /* this is for resurrection */ |
2964 | |
2908 | |
2965 | /* int z; |
2909 | /* int z; |
2966 | int num_stats_lose; |
2910 | int num_stats_lose; |
2967 | int lost_a_stat; |
2911 | int lost_a_stat; |
2968 | int lose_this_stat; |
2912 | int lose_this_stat; |
… | |
… | |
2983 | { |
2927 | { |
2984 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2928 | 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..."); |
2929 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
2986 | |
2930 | |
2987 | /* restore player */ |
2931 | /* restore player */ |
2988 | at = find_archetype ("poisoning"); |
2932 | at = archetype::find ("poisoning"); |
2989 | tmp = present_arch_in_ob (at, op); |
2933 | tmp = present_arch_in_ob (at, op); |
2990 | if (tmp) |
2934 | if (tmp) |
2991 | { |
2935 | { |
2992 | remove_ob (tmp); |
2936 | tmp->destroy (); |
2993 | free_object (tmp); |
|
|
2994 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2937 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2995 | } |
2938 | } |
2996 | |
2939 | |
2997 | at = find_archetype ("confusion"); |
2940 | at = archetype::find ("confusion"); |
2998 | tmp = present_arch_in_ob (at, op); |
2941 | tmp = present_arch_in_ob (at, op); |
2999 | if (tmp) |
2942 | if (tmp) |
3000 | { |
2943 | { |
3001 | remove_ob (tmp); |
2944 | tmp->destroy (); |
3002 | free_object (tmp); |
|
|
3003 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2945 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3004 | } |
2946 | } |
3005 | |
2947 | |
3006 | cure_disease (op, 0); /* remove any disease */ |
2948 | cure_disease (op, 0); /* remove any disease */ |
3007 | op->stats.hp = op->stats.maxhp; |
2949 | op->stats.hp = op->stats.maxhp; |
3008 | if (op->stats.food <= 0) |
2950 | if (op->stats.food <= 0) |
3009 | op->stats.food = 999; |
2951 | op->stats.food = 999; |
3010 | |
2952 | |
3011 | /* create a bodypart-trophy to make the winner happy */ |
2953 | /* create a bodypart-trophy to make the winner happy */ |
3012 | tmp = arch_to_object (find_archetype ("finger")); |
2954 | tmp = arch_to_object (archetype::find ("finger")); |
3013 | if (tmp != NULL) |
2955 | if (tmp != NULL) |
3014 | { |
2956 | { |
3015 | sprintf (buf, "%s's finger", &op->name); |
2957 | sprintf (buf, "%s's finger", &op->name); |
3016 | tmp->name = buf; |
2958 | tmp->name = buf; |
3017 | sprintf (buf, " This finger has been cut off %s\n" |
2959 | sprintf (buf, " This finger has been cut off %s\n" |
… | |
… | |
3114 | lost_a_stat = 1; |
3056 | lost_a_stat = 1; |
3115 | } |
3057 | } |
3116 | else |
3058 | else |
3117 | { |
3059 | { |
3118 | /* deplete a stat */ |
3060 | /* deplete a stat */ |
3119 | archetype *deparch = find_archetype ("depletion"); |
3061 | archetype *deparch = archetype::find ("depletion"); |
3120 | object *dep; |
3062 | object *dep; |
3121 | |
3063 | |
3122 | dep = present_arch_in_ob (deparch, op); |
3064 | dep = present_arch_in_ob (deparch, op); |
3123 | if (!dep) |
3065 | if (!dep) |
3124 | { |
3066 | { |
… | |
… | |
3184 | /* determine_god() seems to not work sometimes... why is this? |
3126 | /* determine_god() seems to not work sometimes... why is this? |
3185 | Should I be using something else? GD */ |
3127 | Should I be using something else? GD */ |
3186 | const char *god = determine_god (op); |
3128 | const char *god = determine_god (op); |
3187 | |
3129 | |
3188 | if (god && (strcmp (god, "none"))) |
3130 | if (god && (strcmp (god, "none"))) |
3189 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief " "moment you feel the holy presence of %s protecting" " you.", god); |
3131 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
3190 | else |
3132 | else |
3191 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); |
3133 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
3192 | } |
3134 | } |
|
|
3135 | #else |
|
|
3136 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
3193 | #endif |
3137 | #endif |
3194 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
|
|
3195 | |
3138 | |
3196 | /* Put a gravestone up where the character 'almost' died. List the |
3139 | /* Put a gravestone up where the character 'almost' died. List the |
3197 | * exp loss on the stone. |
3140 | * exp loss on the stone. |
3198 | */ |
3141 | */ |
3199 | tmp = arch_to_object (find_archetype ("gravestone")); |
3142 | tmp = arch_to_object (archetype::find ("gravestone")); |
3200 | sprintf (buf, "%s's gravestone", &op->name); |
3143 | sprintf (buf, "%s's gravestone", &op->name); |
3201 | tmp->name = buf; |
3144 | tmp->name = buf; |
3202 | sprintf (buf, "%s's gravestones", &op->name); |
3145 | sprintf (buf, "%s's gravestones", &op->name); |
3203 | tmp->name_pl = buf; |
3146 | 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); |
3147 | 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); |
3205 | tmp->msg = buf; |
3148 | tmp->msg = buf; |
3206 | tmp->x = op->x, tmp->y = op->y; |
3149 | tmp->x = op->x, tmp->y = op->y; |
3207 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3150 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3208 | |
3151 | |
3209 | /**************************************/ |
3152 | /**************************************/ |
3210 | /* */ |
3153 | /* */ |
3211 | /* Subtract the experience points, */ |
3154 | /* Subtract the experience points, */ |
3212 | /* if we died cause of food, give us */ |
3155 | /* if we died cause of food, give us */ |
3213 | /* food, and reset HP's... */ |
3156 | /* food, and reset HP's... */ |
3214 | /* */ |
3157 | /* */ |
3215 | |
|
|
3216 | /**************************************/ |
3158 | /**************************************/ |
3217 | |
3159 | |
3218 | /* remove any poisoning and confusion the character may be suffering. */ |
3160 | /* remove any poisoning and confusion the character may be suffering. */ |
3219 | /* restore player */ |
3161 | /* restore player */ |
3220 | at = find_archetype ("poisoning"); |
3162 | at = archetype::find ("poisoning"); |
|
|
3163 | tmp = present_arch_in_ob (at, op); |
|
|
3164 | |
|
|
3165 | if (tmp) |
|
|
3166 | { |
|
|
3167 | tmp->destroy (); |
|
|
3168 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
|
|
3169 | } |
|
|
3170 | |
|
|
3171 | at = archetype::find ("confusion"); |
3221 | tmp = present_arch_in_ob (at, op); |
3172 | tmp = present_arch_in_ob (at, op); |
3222 | if (tmp) |
3173 | if (tmp) |
3223 | { |
3174 | { |
3224 | remove_ob (tmp); |
3175 | tmp->destroy (); |
3225 | free_object (tmp); |
|
|
3226 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
|
|
3227 | } |
|
|
3228 | |
|
|
3229 | at = find_archetype ("confusion"); |
|
|
3230 | tmp = present_arch_in_ob (at, op); |
|
|
3231 | if (tmp) |
|
|
3232 | { |
|
|
3233 | remove_ob (tmp); |
|
|
3234 | free_object (tmp); |
|
|
3235 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3176 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3236 | } |
3177 | } |
|
|
3178 | |
3237 | cure_disease (op, 0); /* remove any disease */ |
3179 | cure_disease (op, 0); /* remove any disease */ |
3238 | |
3180 | |
3239 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3181 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3240 | apply_death_exp_penalty (op); |
3182 | apply_death_exp_penalty (op); |
3241 | if (op->stats.food < 100) |
3183 | if (op->stats.food < 100) |
… | |
… | |
3251 | */ |
3193 | */ |
3252 | |
3194 | |
3253 | if (is_in_shop (op)) |
3195 | if (is_in_shop (op)) |
3254 | remove_unpaid_objects (op->inv, op); |
3196 | remove_unpaid_objects (op->inv, op); |
3255 | |
3197 | |
3256 | /****************************************/ |
3198 | /****************************************/ |
3257 | /* */ |
3199 | /* */ |
3258 | /* Move player to his current respawn- */ |
3200 | /* Move player to his current respawn- */ |
3259 | /* position (usually last savebed) */ |
3201 | /* position (usually last savebed) */ |
3260 | /* */ |
3202 | /* */ |
3261 | |
|
|
3262 | /****************************************/ |
3203 | /****************************************/ |
3263 | |
3204 | |
3264 | enter_player_savebed (op); |
3205 | enter_player_savebed (op); |
3265 | |
3206 | |
3266 | /* Save the player before inserting the force to reduce |
3207 | /* Save the player before inserting the force to reduce |
3267 | * chance of abuse. |
3208 | * chance of abuse. |
… | |
… | |
3274 | * spell effects. So first see if there is a spell effect |
3215 | * spell effects. So first see if there is a spell effect |
3275 | * on the space that might harm the player. |
3216 | * on the space that might harm the player. |
3276 | */ |
3217 | */ |
3277 | will_kill_again = 0; |
3218 | will_kill_again = 0; |
3278 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3219 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3279 | { |
|
|
3280 | if (tmp->type == SPELL_EFFECT) |
3220 | if (tmp->type == SPELL_EFFECT) |
3281 | will_kill_again |= tmp->attacktype; |
3221 | will_kill_again |= tmp->attacktype; |
3282 | } |
3222 | |
3283 | if (will_kill_again) |
3223 | if (will_kill_again) |
3284 | { |
3224 | { |
3285 | object *force; |
3225 | object *force; |
3286 | int at; |
3226 | int at; |
3287 | |
3227 | |
… | |
… | |
3289 | /* 50 ticks should be enough time for the spell to abate */ |
3229 | /* 50 ticks should be enough time for the spell to abate */ |
3290 | force->speed = 0.1; |
3230 | force->speed = 0.1; |
3291 | force->speed_left = -5.0; |
3231 | force->speed_left = -5.0; |
3292 | SET_FLAG (force, FLAG_APPLIED); |
3232 | SET_FLAG (force, FLAG_APPLIED); |
3293 | for (at = 0; at < NROFATTACKS; at++) |
3233 | for (at = 0; at < NROFATTACKS; at++) |
3294 | { |
|
|
3295 | if (will_kill_again & (1 << at)) |
3234 | if (will_kill_again & (1 << at)) |
3296 | force->resist[at] = 100; |
3235 | force->resist[at] = 100; |
3297 | } |
3236 | |
3298 | insert_ob_in_ob (force, op); |
3237 | insert_ob_in_ob (force, op); |
3299 | fix_player (op); |
3238 | fix_player (op); |
3300 | |
3239 | |
3301 | } |
3240 | } |
3302 | |
3241 | |
… | |
… | |
3312 | op->contr->party = NULL; |
3251 | op->contr->party = NULL; |
3313 | if (settings.set_title == TRUE) |
3252 | if (settings.set_title == TRUE) |
3314 | op->contr->own_title[0] = '\0'; |
3253 | op->contr->own_title[0] = '\0'; |
3315 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3254 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3316 | check_score (op); |
3255 | check_score (op); |
|
|
3256 | |
3317 | if (op->contr->ranges[range_golem] != NULL) |
3257 | if (op->contr->ranges[range_golem]) |
3318 | { |
3258 | { |
3319 | remove_friendly_object (op->contr->ranges[range_golem]); |
3259 | remove_friendly_object (op->contr->ranges[range_golem]); |
3320 | remove_ob (op->contr->ranges[range_golem]); |
3260 | op->contr->ranges[range_golem]->destroy (); |
3321 | free_object (op->contr->ranges[range_golem]); |
|
|
3322 | op->contr->ranges[range_golem] = NULL; |
3261 | op->contr->ranges[range_golem] = 0; |
3323 | op->contr->golem_count = 0; |
|
|
3324 | } |
3262 | } |
|
|
3263 | |
3325 | loot_object (op); /* Remove some of the items for good */ |
3264 | loot_object (op); /* Remove some of the items for good */ |
3326 | remove_ob (op); |
3265 | op->remove (); |
3327 | op->direction = 0; |
3266 | op->direction = 0; |
3328 | |
3267 | |
3329 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3268 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3330 | { |
3269 | { |
3331 | delete_character (op->name, 0); |
3270 | delete_character (op->name, 0); |
… | |
… | |
3356 | } |
3295 | } |
3357 | |
3296 | |
3358 | play_again (op); |
3297 | play_again (op); |
3359 | |
3298 | |
3360 | /* peterm: added to create a corpse at deathsite. */ |
3299 | /* peterm: added to create a corpse at deathsite. */ |
3361 | tmp = arch_to_object (find_archetype ("corpse_pl")); |
3300 | tmp = arch_to_object (archetype::find ("corpse_pl")); |
3362 | sprintf (buf, "%s", &op->name); |
3301 | sprintf (buf, "%s", &op->name); |
3363 | tmp->name = tmp->name_pl = buf; |
3302 | tmp->name = tmp->name_pl = buf; |
3364 | tmp->level = op->level; |
3303 | tmp->level = op->level; |
3365 | tmp->x = x; |
3304 | tmp->x = x; |
3366 | tmp->y = y; |
3305 | tmp->y = y; |
… | |
… | |
3384 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3323 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3385 | { |
3324 | { |
3386 | next = tmp->below; |
3325 | next = tmp->below; |
3387 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3326 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3388 | continue; |
3327 | continue; |
3389 | remove_ob (tmp); |
3328 | tmp->remove (); |
3390 | tmp->x = op->x, tmp->y = op->y; |
3329 | tmp->x = op->x, tmp->y = op->y; |
3391 | if (tmp->type == CONTAINER) |
3330 | if (tmp->type == CONTAINER) |
3392 | { /* empty container to ground */ |
3331 | { /* empty container to ground */ |
3393 | loot_object (tmp); |
3332 | loot_object (tmp); |
3394 | } |
3333 | } |
3395 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
3334 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
3396 | { |
3335 | { |
3397 | if (tmp->nrof > 1) |
3336 | if (tmp->nrof > 1) |
3398 | { |
3337 | { |
3399 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3338 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3400 | free_object (tmp2); |
3339 | tmp2->destroy (); |
3401 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3340 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3402 | } |
3341 | } |
3403 | else |
3342 | else |
3404 | free_object (tmp); |
3343 | tmp->destroy (); |
3405 | } |
3344 | } |
3406 | else |
3345 | else |
3407 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3346 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3408 | } |
3347 | } |
3409 | } |
3348 | } |
… | |
… | |
3474 | if (op->type == PLAYER) |
3413 | if (op->type == PLAYER) |
3475 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); |
3414 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); |
3476 | |
3415 | |
3477 | cast_spell (op, throw_ob, dir, spob, NULL); |
3416 | cast_spell (op, throw_ob, dir, spob, NULL); |
3478 | |
3417 | |
3479 | if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) |
3418 | throw_ob->destroy (); |
3480 | remove_ob (throw_ob); |
|
|
3481 | free_object (throw_ob); |
|
|
3482 | } |
3419 | } |
3483 | |
3420 | |
3484 | void |
3421 | void |
3485 | make_visible (object *op) |
3422 | make_visible (object *op) |
3486 | { |
3423 | { |
… | |
… | |
3602 | int |
3539 | int |
3603 | stand_near_hostile (object *who) |
3540 | stand_near_hostile (object *who) |
3604 | { |
3541 | { |
3605 | object *tmp = NULL; |
3542 | object *tmp = NULL; |
3606 | int i, friendly = 0, player = 0, mflags; |
3543 | int i, friendly = 0, player = 0, mflags; |
3607 | mapstruct *m; |
3544 | maptile *m; |
3608 | sint16 x, y; |
3545 | sint16 x, y; |
3609 | |
3546 | |
3610 | if (!who) |
3547 | if (!who) |
3611 | return 0; |
3548 | return 0; |
3612 | |
3549 | |
… | |
… | |
3693 | |
3630 | |
3694 | /* only the viewable area the player sees is updated by LOS |
3631 | /* only the viewable area the player sees is updated by LOS |
3695 | * code, so we need to restrict ourselves to that range of values |
3632 | * code, so we need to restrict ourselves to that range of values |
3696 | * for any meaningful values. |
3633 | * for any meaningful values. |
3697 | */ |
3634 | */ |
3698 | if (FABS (dx) <= (pl->contr->socket.mapx / 2) && |
3635 | if (FABS (dx) <= (pl->contr->socket->mapx / 2) && |
3699 | FABS (dy) <= (pl->contr->socket.mapy / 2) && |
3636 | FABS (dy) <= (pl->contr->socket->mapy / 2) && |
3700 | !pl->contr->blocked_los[dx + (pl->contr->socket.mapx / 2)][dy + (pl->contr->socket.mapy / 2)]) |
3637 | !pl->contr->blocked_los[dx + (pl->contr->socket->mapx / 2)][dy + (pl->contr->socket->mapy / 2)]) |
3701 | return 1; |
3638 | return 1; |
3702 | op = op->more; |
3639 | op = op->more; |
3703 | } |
3640 | } |
3704 | return 0; |
3641 | return 0; |
3705 | } |
3642 | } |