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 */ |
|
|
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; |
759 | } |
727 | } |
760 | |
728 | |
761 | |
|
|
762 | int |
729 | int |
763 | receive_play_again (object *op, char key) |
730 | receive_play_again (object *op, char key) |
764 | { |
731 | { |
765 | if (key == 'q' || key == 'Q') |
732 | if (key == 'q' || key == 'Q') |
766 | { |
733 | { |
… | |
… | |
771 | else if (key == 'a' || key == 'A') |
738 | else if (key == 'a' || key == 'A') |
772 | { |
739 | { |
773 | player *pl = op->contr; |
740 | player *pl = op->contr; |
774 | shstr name = op->name; |
741 | shstr name = op->name; |
775 | |
742 | |
776 | remove_friendly_object (op); |
743 | op->contr = 0; |
777 | free_object (op); |
744 | op->type = 0; |
|
|
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; |
… | |
… | |
785 | get_name (op); |
753 | get_name (op); |
786 | op->name = op->name_pl = name; |
754 | op->name = op->name_pl = name; |
787 | set_first_map (op); |
755 | set_first_map (op); |
788 | } |
756 | } |
789 | else |
757 | else |
790 | { |
|
|
791 | /* user pressed something else so just ask again... */ |
758 | /* user pressed something else so just ask again... */ |
792 | play_again (op); |
759 | play_again (op); |
793 | } |
760 | |
794 | return 0; |
761 | return 0; |
795 | } |
762 | } |
796 | |
763 | |
797 | void |
764 | void |
798 | confirm_password (object *op) |
765 | confirm_password (object *op) |
799 | { |
766 | { |
800 | |
767 | |
801 | op->contr->write_buf[0] = '\0'; |
768 | op->contr->write_buf[0] = '\0'; |
802 | op->contr->state = ST_CONFIRM_PASSWORD; |
769 | op->contr->state = ST_CONFIRM_PASSWORD; |
803 | 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:"); |
804 | } |
771 | } |
805 | |
772 | |
806 | void |
773 | void |
807 | get_party_password (object *op, partylist *party) |
774 | get_party_password (object *op, partylist *party) |
808 | { |
775 | { |
… | |
… | |
812 | return; |
779 | return; |
813 | } |
780 | } |
814 | op->contr->write_buf[0] = '\0'; |
781 | op->contr->write_buf[0] = '\0'; |
815 | op->contr->state = ST_GET_PARTY_PASSWORD; |
782 | op->contr->state = ST_GET_PARTY_PASSWORD; |
816 | op->contr->party_to_join = party; |
783 | op->contr->party_to_join = party; |
817 | 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:"); |
818 | } |
785 | } |
819 | |
786 | |
820 | |
787 | |
821 | /* 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. */ |
822 | int |
789 | int |
… | |
… | |
919 | |
886 | |
920 | void |
887 | void |
921 | Roll_Again (object *op) |
888 | Roll_Again (object *op) |
922 | { |
889 | { |
923 | esrv_new_player (op->contr, 0); |
890 | esrv_new_player (op->contr, 0); |
924 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
891 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, |
925 | "[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)? "); |
926 | } |
893 | } |
927 | |
894 | |
928 | void |
895 | void |
929 | Swap_Stat (object *op, int Swap_Second) |
896 | Swap_Stat (object *op, int Swap_Second) |
… | |
… | |
996 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
963 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
997 | } |
964 | } |
998 | else |
965 | else |
999 | Swap_Stat (op, stat_trans[keynum]); |
966 | Swap_Stat (op, stat_trans[keynum]); |
1000 | |
967 | |
1001 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
968 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
1002 | return 1; |
969 | return 1; |
1003 | } |
970 | } |
1004 | switch (key) |
971 | switch (key) |
1005 | { |
972 | { |
1006 | case 'n': |
973 | case 'n': |
1007 | case 'N': |
974 | case 'N': |
1008 | { |
975 | { |
1009 | SET_FLAG (op, FLAG_WIZ); |
976 | SET_FLAG (op, FLAG_WIZ); |
1010 | if (op->map == NULL) |
977 | if (op->map == NULL) |
1011 | { |
978 | { |
1012 | LOG (llevError, "Map == NULL in state 2\n"); |
979 | LOG (llevError, "Map == NULL in state 2\n"); |
1013 | break; |
980 | break; |
1014 | } |
981 | } |
1015 | |
982 | |
1016 | #if 0 |
983 | #if 0 |
1017 | /* So that enter_exit will put us at startx/starty */ |
984 | /* So that enter_exit will put us at startx/starty */ |
1018 | op->x = -1; |
985 | op->x = -1; |
1019 | |
986 | |
1020 | enter_exit (op, NULL); |
987 | enter_exit (op, NULL); |
1021 | #endif |
988 | #endif |
1022 | SET_ANIMATION (op, 2); /* So player faces south */ |
989 | SET_ANIMATION (op, 2); /* So player faces south */ |
1023 | /* Enter exit adds a player otherwise */ |
990 | /* Enter exit adds a player otherwise */ |
1024 | add_statbonus (op); |
991 | add_statbonus (op); |
1025 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
992 | 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"); |
993 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); |
1027 | op->contr->state = ST_CHANGE_CLASS; |
994 | op->contr->state = ST_CHANGE_CLASS; |
1028 | if (op->msg) |
995 | if (op->msg) |
1029 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
996 | 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; |
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; |
1046 | } |
1013 | } |
1047 | return 0; |
1014 | return 0; |
1048 | } |
1015 | } |
1049 | |
1016 | |
1050 | /* This function takes the key that is passed, and does the |
1017 | /* This function takes the key that is passed, and does the |
… | |
… | |
1059 | { |
1026 | { |
1060 | int tmp_loop; |
1027 | int tmp_loop; |
1061 | |
1028 | |
1062 | if (key == 'q' || key == 'Q') |
1029 | if (key == 'q' || key == 'Q') |
1063 | { |
1030 | { |
1064 | remove_ob (op); |
1031 | op->remove (); |
1065 | play_again (op); |
1032 | play_again (op); |
1066 | return 0; |
1033 | return 0; |
1067 | } |
1034 | } |
1068 | if (key == 'd' || key == 'D') |
1035 | if (key == 'd' || key == 'D') |
1069 | { |
1036 | { |
1070 | char buf[MAX_BUF]; |
1037 | char buf[MAX_BUF]; |
1071 | |
1038 | |
1072 | /* this must before then initial items are given */ |
1039 | /* this must before then initial items are given */ |
1073 | esrv_new_player (op->contr, op->weight + op->carrying); |
1040 | esrv_new_player (op->contr, op->weight + op->carrying); |
|
|
1041 | |
1074 | 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); |
1075 | |
1045 | |
1076 | INVOKE_PLAYER (BIRTH, op->contr); |
1046 | INVOKE_PLAYER (BIRTH, op->contr); |
1077 | INVOKE_PLAYER (LOGIN, op->contr); |
1047 | INVOKE_PLAYER (LOGIN, op->contr); |
1078 | |
1048 | |
1079 | op->contr->state = ST_PLAYING; |
1049 | op->contr->state = ST_PLAYING; |
… | |
… | |
1104 | { |
1074 | { |
1105 | object *tmp; |
1075 | object *tmp; |
1106 | char mapname[MAX_BUF]; |
1076 | char mapname[MAX_BUF]; |
1107 | |
1077 | |
1108 | 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); |
1109 | tmp = get_object (); |
1079 | tmp = object::create (); |
1110 | EXIT_PATH (tmp) = mapname; |
1080 | EXIT_PATH (tmp) = mapname; |
1111 | EXIT_X (tmp) = op->x; |
1081 | EXIT_X (tmp) = op->x; |
1112 | EXIT_Y (tmp) = op->y; |
1082 | EXIT_Y (tmp) = op->y; |
1113 | 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; |
1114 | * if the map isn't there, then stay on the |
1084 | * if the map isn't there, then stay on the |
1115 | * default initial map */ |
1085 | * default initial map */ |
1116 | free_object (tmp); |
1086 | tmp->destroy (); |
1117 | } |
1087 | } |
1118 | else |
1088 | else |
1119 | { |
1089 | { |
1120 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1090 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1121 | } |
1091 | } |
… | |
… | |
1131 | { |
1101 | { |
1132 | shstr name = op->name; |
1102 | shstr name = op->name; |
1133 | int x = op->x, y = op->y; |
1103 | int x = op->x, y = op->y; |
1134 | |
1104 | |
1135 | remove_statbonus (op); |
1105 | remove_statbonus (op); |
1136 | remove_ob (op); |
1106 | op->remove (); |
1137 | op->arch = get_player_archetype (op->arch); |
1107 | op->arch = get_player_archetype (op->arch); |
1138 | copy_object (&op->arch->clone, op); |
1108 | op->arch->clone.copy_to (op); |
1139 | op->instantiate (); |
1109 | op->instantiate (); |
1140 | op->stats = op->contr->orig_stats; |
1110 | op->stats = op->contr->orig_stats; |
1141 | op->name = op->name_pl = name; |
1111 | op->name = op->name_pl = name; |
1142 | op->x = x; |
1112 | op->x = x; |
1143 | op->y = y; |
1113 | op->y = y; |
1144 | SET_ANIMATION (op, 2); /* So player faces south */ |
1114 | SET_ANIMATION (op, 2); /* So player faces south */ |
1145 | insert_ob_in_map (op, op->map, op, 0); |
1115 | insert_ob_in_map (op, op->map, op, 0); |
1146 | strncpy (op->contr->title, op->arch->clone.name, sizeof (op->contr->title) - 1); |
1116 | assign (op->contr->title, op->arch->clone.name); |
1147 | op->contr->title[sizeof (op->contr->title) - 1] = '\0'; |
|
|
1148 | add_statbonus (op); |
1117 | add_statbonus (op); |
1149 | tmp_loop = allowed_class (op); |
1118 | tmp_loop = allowed_class (op); |
1150 | } |
1119 | } |
|
|
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 | */ |
… | |
… | |
1202 | delete_map (mp); |
1174 | delete_map (mp); |
1203 | } |
1175 | } |
1204 | |
1176 | |
1205 | delete_character (op->name, 1); |
1177 | delete_character (op->name, 1); |
1206 | } |
1178 | } |
|
|
1179 | |
1207 | play_again (op); |
1180 | play_again (op); |
1208 | return 1; |
1181 | return 1; |
1209 | } |
1182 | } |
1210 | |
1183 | |
1211 | void |
1184 | void |
… | |
… | |
1269 | */ |
1242 | */ |
1270 | int |
1243 | int |
1271 | check_pick (object *op) |
1244 | check_pick (object *op) |
1272 | { |
1245 | { |
1273 | object *tmp, *next; |
1246 | object *tmp, *next; |
1274 | tag_t next_tag = 0, op_tag; |
|
|
1275 | int stop = 0; |
1247 | int stop = 0; |
1276 | int j, k, wvratio; |
1248 | int j, k, wvratio; |
1277 | char putstring[128], tmpstr[16]; |
1249 | char putstring[128], tmpstr[16]; |
1278 | |
1250 | |
1279 | |
|
|
1280 | /* if you're flying, you cna't pick up anything */ |
1251 | /* if you're flying, you cna't pick up anything */ |
1281 | if (op->move_type & MOVE_FLYING) |
1252 | if (op->move_type & MOVE_FLYING) |
1282 | return 1; |
1253 | return 1; |
1283 | |
1254 | |
1284 | op_tag = op->count; |
|
|
1285 | |
|
|
1286 | next = op->below; |
1255 | next = op->below; |
1287 | if (next) |
|
|
1288 | next_tag = next->count; |
|
|
1289 | |
1256 | |
1290 | /* 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 |
1291 | * destroyed */ |
1258 | * destroyed */ |
1292 | while (next && !was_destroyed (next, next_tag)) |
1259 | while (next && !next->destroyed ()) |
1293 | { |
1260 | { |
1294 | tmp = next; |
1261 | tmp = next; |
1295 | next = tmp->below; |
1262 | next = tmp->below; |
1296 | if (next) |
|
|
1297 | next_tag = next->count; |
|
|
1298 | |
1263 | |
1299 | if (was_destroyed (op, op_tag)) |
1264 | if (op->destroyed ()) |
1300 | return 0; |
1265 | return 0; |
1301 | |
1266 | |
1302 | if (!can_pick (op, tmp)) |
1267 | if (!can_pick (op, tmp)) |
1303 | continue; |
1268 | continue; |
1304 | |
1269 | |
… | |
… | |
1312 | /* high not bit set? We're using the old autopickup model */ |
1277 | /* high not bit set? We're using the old autopickup model */ |
1313 | if (!(op->contr->mode & PU_NEWMODE)) |
1278 | if (!(op->contr->mode & PU_NEWMODE)) |
1314 | { |
1279 | { |
1315 | switch (op->contr->mode) |
1280 | switch (op->contr->mode) |
1316 | { |
1281 | { |
1317 | case 0: |
1282 | case 0: |
1318 | return 1; /* don't pick up */ |
1283 | return 1; /* don't pick up */ |
1319 | 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)) |
1320 | pick_up (op, tmp); |
1301 | pick_up (op, tmp); |
1321 | return 1; |
1302 | break; |
|
|
1303 | |
1322 | case 2: |
1304 | case 7: |
|
|
1305 | if (tmp->type == MONEY || tmp->type == GEM) |
1323 | pick_up (op, tmp); |
1306 | pick_up (op, tmp); |
1324 | return 0; |
1307 | break; |
1325 | case 3: |
1308 | |
1326 | return 0; /* stop before pickup */ |
1309 | default: |
1327 | 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) |
1328 | pick_up (op, tmp); |
1313 | 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 | } |
1314 | } |
1350 | } |
1315 | } |
1351 | else |
1316 | else |
1352 | { /* old model */ |
1317 | { /* old model */ |
1353 | /* NEW pickup handling */ |
1318 | /* NEW pickup handling */ |
… | |
… | |
1436 | /* question: don't pick up known-poisonous stuff? */ |
1401 | /* question: don't pick up known-poisonous stuff? */ |
1437 | if (op->contr->mode & PU_FOOD) |
1402 | if (op->contr->mode & PU_FOOD) |
1438 | if (tmp->type == FOOD) |
1403 | if (tmp->type == FOOD) |
1439 | { |
1404 | { |
1440 | pick_up (op, tmp); |
1405 | pick_up (op, tmp); |
1441 | if (0) |
|
|
1442 | fprintf (stderr, "FOOD\n"); |
|
|
1443 | continue; |
1406 | continue; |
1444 | } |
1407 | } |
|
|
1408 | |
1445 | if (op->contr->mode & PU_DRINK) |
1409 | if (op->contr->mode & PU_DRINK) |
1446 | 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))) |
1447 | { |
1411 | { |
1448 | pick_up (op, tmp); |
1412 | pick_up (op, tmp); |
1449 | if (0) |
|
|
1450 | fprintf (stderr, "DRINK\n"); |
|
|
1451 | continue; |
1413 | continue; |
1452 | } |
1414 | } |
1453 | |
1415 | |
1454 | if (op->contr->mode & PU_POTION) |
1416 | if (op->contr->mode & PU_POTION) |
1455 | if (tmp->type == POTION) |
1417 | if (tmp->type == POTION) |
1456 | { |
1418 | { |
1457 | pick_up (op, tmp); |
1419 | pick_up (op, tmp); |
1458 | if (0) |
|
|
1459 | fprintf (stderr, "POTION\n"); |
|
|
1460 | continue; |
1420 | continue; |
1461 | } |
1421 | } |
1462 | |
1422 | |
1463 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1423 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1464 | if (op->contr->mode & PU_SPELLBOOK) |
1424 | if (op->contr->mode & PU_SPELLBOOK) |
1465 | if (tmp->type == SPELLBOOK) |
1425 | if (tmp->type == SPELLBOOK) |
1466 | { |
1426 | { |
1467 | pick_up (op, tmp); |
1427 | pick_up (op, tmp); |
1468 | if (0) |
|
|
1469 | fprintf (stderr, "SPELLBOOK\n"); |
|
|
1470 | continue; |
1428 | continue; |
1471 | } |
1429 | } |
|
|
1430 | |
1472 | if (op->contr->mode & PU_SKILLSCROLL) |
1431 | if (op->contr->mode & PU_SKILLSCROLL) |
1473 | if (tmp->type == SKILLSCROLL) |
1432 | if (tmp->type == SKILLSCROLL) |
1474 | { |
1433 | { |
1475 | pick_up (op, tmp); |
1434 | pick_up (op, tmp); |
1476 | if (0) |
|
|
1477 | fprintf (stderr, "SKILLSCROLL\n"); |
|
|
1478 | continue; |
1435 | continue; |
1479 | } |
1436 | } |
|
|
1437 | |
1480 | if (op->contr->mode & PU_READABLES) |
1438 | if (op->contr->mode & PU_READABLES) |
1481 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1439 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1482 | { |
1440 | { |
1483 | pick_up (op, tmp); |
1441 | pick_up (op, tmp); |
1484 | if (0) |
|
|
1485 | fprintf (stderr, "READABLES\n"); |
|
|
1486 | continue; |
1442 | continue; |
1487 | } |
1443 | } |
1488 | |
1444 | |
1489 | /* wands/staves/rods/horns */ |
1445 | /* wands/staves/rods/horns */ |
1490 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1446 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1491 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1447 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1492 | { |
1448 | { |
1493 | pick_up (op, tmp); |
1449 | pick_up (op, tmp); |
1494 | if (0) |
|
|
1495 | fprintf (stderr, "MAGIC_DEVICE\n"); |
|
|
1496 | continue; |
1450 | continue; |
1497 | } |
1451 | } |
1498 | |
1452 | |
1499 | /* pick up all magical items */ |
1453 | /* pick up all magical items */ |
1500 | if (op->contr->mode & PU_MAGICAL) |
1454 | if (op->contr->mode & PU_MAGICAL) |
1501 | 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)) |
1502 | { |
1456 | { |
1503 | pick_up (op, tmp); |
1457 | pick_up (op, tmp); |
1504 | if (0) |
|
|
1505 | fprintf (stderr, "MAGICAL\n"); |
|
|
1506 | continue; |
1458 | continue; |
1507 | } |
1459 | } |
1508 | |
1460 | |
1509 | if (op->contr->mode & PU_VALUABLES) |
1461 | if (op->contr->mode & PU_VALUABLES) |
1510 | { |
1462 | { |
1511 | if (tmp->type == MONEY || tmp->type == GEM) |
1463 | if (tmp->type == MONEY || tmp->type == GEM) |
1512 | { |
1464 | { |
1513 | pick_up (op, tmp); |
1465 | pick_up (op, tmp); |
1514 | if (0) |
|
|
1515 | fprintf (stderr, "MONEY/GEM\n"); |
|
|
1516 | continue; |
1466 | continue; |
1517 | } |
1467 | } |
1518 | } |
1468 | } |
1519 | |
1469 | |
1520 | /* rings & amulets - talismans seems to be typed AMULET */ |
1470 | /* rings & amulets - talismans seems to be typed AMULET */ |
1521 | if (op->contr->mode & PU_JEWELS) |
1471 | if (op->contr->mode & PU_JEWELS) |
1522 | if (tmp->type == RING || tmp->type == AMULET) |
1472 | if (tmp->type == RING || tmp->type == AMULET) |
1523 | { |
1473 | { |
1524 | pick_up (op, tmp); |
1474 | pick_up (op, tmp); |
|
|
1475 | continue; |
1525 | if (0) |
1476 | } |
1526 | 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); |
1527 | continue; |
1483 | continue; |
1528 | } |
1484 | } |
1529 | |
1485 | |
1530 | /* bows and arrows. Bows are good for selling! */ |
1486 | /* bows and arrows. Bows are good for selling! */ |
1531 | if (op->contr->mode & PU_BOW) |
1487 | if (op->contr->mode & PU_BOW) |
1532 | if (tmp->type == BOW) |
1488 | if (tmp->type == BOW) |
1533 | { |
1489 | { |
1534 | pick_up (op, tmp); |
1490 | pick_up (op, tmp); |
1535 | if (0) |
|
|
1536 | fprintf (stderr, "BOW\n"); |
|
|
1537 | continue; |
1491 | continue; |
1538 | } |
1492 | } |
|
|
1493 | |
1539 | if (op->contr->mode & PU_ARROW) |
1494 | if (op->contr->mode & PU_ARROW) |
1540 | if (tmp->type == ARROW) |
1495 | if (tmp->type == ARROW) |
1541 | { |
1496 | { |
1542 | pick_up (op, tmp); |
1497 | pick_up (op, tmp); |
1543 | if (0) |
|
|
1544 | fprintf (stderr, "ARROW\n"); |
|
|
1545 | continue; |
1498 | continue; |
1546 | } |
1499 | } |
1547 | |
1500 | |
1548 | /* all kinds of armor etc. */ |
1501 | /* all kinds of armor etc. */ |
1549 | if (op->contr->mode & PU_ARMOUR) |
1502 | if (op->contr->mode & PU_ARMOUR) |
1550 | if (tmp->type == ARMOUR) |
1503 | if (tmp->type == ARMOUR) |
1551 | { |
1504 | { |
1552 | pick_up (op, tmp); |
1505 | pick_up (op, tmp); |
1553 | if (0) |
|
|
1554 | fprintf (stderr, "ARMOUR\n"); |
|
|
1555 | continue; |
1506 | continue; |
1556 | } |
1507 | } |
|
|
1508 | |
1557 | if (op->contr->mode & PU_HELMET) |
1509 | if (op->contr->mode & PU_HELMET) |
1558 | if (tmp->type == HELMET) |
1510 | if (tmp->type == HELMET) |
1559 | { |
1511 | { |
1560 | pick_up (op, tmp); |
1512 | pick_up (op, tmp); |
1561 | if (0) |
|
|
1562 | fprintf (stderr, "HELMET\n"); |
|
|
1563 | continue; |
1513 | continue; |
1564 | } |
1514 | } |
|
|
1515 | |
1565 | if (op->contr->mode & PU_SHIELD) |
1516 | if (op->contr->mode & PU_SHIELD) |
1566 | if (tmp->type == SHIELD) |
1517 | if (tmp->type == SHIELD) |
1567 | { |
1518 | { |
1568 | pick_up (op, tmp); |
1519 | pick_up (op, tmp); |
1569 | if (0) |
|
|
1570 | fprintf (stderr, "SHIELD\n"); |
|
|
1571 | continue; |
1520 | continue; |
1572 | } |
1521 | } |
|
|
1522 | |
1573 | if (op->contr->mode & PU_BOOTS) |
1523 | if (op->contr->mode & PU_BOOTS) |
1574 | if (tmp->type == BOOTS) |
1524 | if (tmp->type == BOOTS) |
1575 | { |
1525 | { |
1576 | pick_up (op, tmp); |
1526 | pick_up (op, tmp); |
1577 | if (0) |
|
|
1578 | fprintf (stderr, "BOOTS\n"); |
|
|
1579 | continue; |
1527 | continue; |
1580 | } |
1528 | } |
|
|
1529 | |
1581 | if (op->contr->mode & PU_GLOVES) |
1530 | if (op->contr->mode & PU_GLOVES) |
1582 | if (tmp->type == GLOVES) |
1531 | if (tmp->type == GLOVES) |
1583 | { |
1532 | { |
1584 | pick_up (op, tmp); |
1533 | pick_up (op, tmp); |
1585 | if (0) |
|
|
1586 | fprintf (stderr, "GLOVES\n"); |
|
|
1587 | continue; |
1534 | continue; |
1588 | } |
1535 | } |
|
|
1536 | |
1589 | if (op->contr->mode & PU_CLOAK) |
1537 | if (op->contr->mode & PU_CLOAK) |
1590 | if (tmp->type == CLOAK) |
1538 | if (tmp->type == CLOAK) |
1591 | { |
1539 | { |
1592 | pick_up (op, tmp); |
1540 | pick_up (op, tmp); |
1593 | if (0) |
|
|
1594 | fprintf (stderr, "GLOVES\n"); |
|
|
1595 | continue; |
1541 | continue; |
1596 | } |
1542 | } |
1597 | |
1543 | |
1598 | /* hoping to catch throwing daggers here */ |
1544 | /* hoping to catch throwing daggers here */ |
1599 | if (op->contr->mode & PU_MISSILEWEAPON) |
1545 | if (op->contr->mode & PU_MISSILEWEAPON) |
1600 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1546 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1601 | { |
1547 | { |
1602 | pick_up (op, tmp); |
1548 | pick_up (op, tmp); |
1603 | if (0) |
|
|
1604 | fprintf (stderr, "MISSILEWEAPON\n"); |
|
|
1605 | continue; |
1549 | continue; |
1606 | } |
1550 | } |
1607 | |
1551 | |
1608 | /* careful: chairs and tables are weapons! */ |
1552 | /* careful: chairs and tables are weapons! */ |
1609 | if (op->contr->mode & PU_ALLWEAPON) |
1553 | if (op->contr->mode & PU_ALLWEAPON) |
… | |
… | |
1612 | { |
1556 | { |
1613 | 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 && |
1614 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1558 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1615 | { |
1559 | { |
1616 | pick_up (op, tmp); |
1560 | pick_up (op, tmp); |
1617 | if (0) |
|
|
1618 | fprintf (stderr, "WEAPON\n"); |
|
|
1619 | continue; |
1561 | continue; |
1620 | } |
1562 | } |
1621 | } |
1563 | } |
|
|
1564 | |
1622 | if (tmp->type == WEAPON && tmp->name == NULL) |
1565 | if (tmp->type == WEAPON && tmp->name == NULL) |
1623 | { |
1566 | { |
1624 | 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) |
1625 | { |
1568 | { |
1626 | pick_up (op, tmp); |
1569 | pick_up (op, tmp); |
1627 | if (0) |
|
|
1628 | fprintf (stderr, "WEAPON\n"); |
|
|
1629 | continue; |
1570 | continue; |
1630 | } |
1571 | } |
1631 | } |
1572 | } |
1632 | } |
1573 | } |
1633 | |
1574 | |
1634 | /* misc stuff that's useful */ |
1575 | /* misc stuff that's useful */ |
1635 | if (op->contr->mode & PU_KEY) |
1576 | if (op->contr->mode & PU_KEY) |
1636 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1577 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1637 | { |
1578 | { |
1638 | pick_up (op, tmp); |
1579 | pick_up (op, tmp); |
1639 | if (0) |
|
|
1640 | fprintf (stderr, "KEY\n"); |
|
|
1641 | continue; |
1580 | continue; |
1642 | } |
1581 | } |
1643 | |
1582 | |
1644 | /* 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 |
1645 | * pickups */ |
1584 | * pickups */ |
… | |
… | |
1667 | continue; |
1606 | continue; |
1668 | } |
1607 | } |
1669 | } |
1608 | } |
1670 | } /* the new pickup model */ |
1609 | } /* the new pickup model */ |
1671 | } |
1610 | } |
|
|
1611 | |
1672 | return !stop; |
1612 | return !stop; |
1673 | } |
1613 | } |
1674 | |
1614 | |
1675 | /* |
1615 | /* |
1676 | * Find an arrow in the inventory and after that |
1616 | * Find an arrow in the inventory and after that |
… | |
… | |
1775 | |
1715 | |
1776 | object * |
1716 | object * |
1777 | pick_arrow_target (object *op, const char *type, int dir) |
1717 | pick_arrow_target (object *op, const char *type, int dir) |
1778 | { |
1718 | { |
1779 | object *tmp = NULL; |
1719 | object *tmp = NULL; |
1780 | mapstruct *m; |
1720 | maptile *m; |
1781 | int i, mflags, found, number; |
1721 | int i, mflags, found, number; |
1782 | sint16 x, y; |
1722 | sint16 x, y; |
1783 | |
1723 | |
1784 | if (op->map == NULL) |
1724 | if (op->map == NULL) |
1785 | return find_arrow (op, type); |
1725 | return find_arrow (op, type); |
… | |
… | |
1845 | */ |
1785 | */ |
1846 | int |
1786 | int |
1847 | 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) |
1848 | { |
1788 | { |
1849 | object *left, *bow; |
1789 | object *left, *bow; |
1850 | tag_t left_tag, tag; |
|
|
1851 | int bowspeed, mflags; |
1790 | int bowspeed, mflags; |
1852 | mapstruct *m; |
1791 | maptile *m; |
1853 | |
1792 | |
1854 | if (!dir) |
1793 | if (!dir) |
1855 | { |
1794 | { |
1856 | 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!"); |
1857 | return 0; |
1796 | return 0; |
… | |
… | |
1911 | } |
1850 | } |
1912 | |
1851 | |
1913 | /* this should not happen, but sometimes does */ |
1852 | /* this should not happen, but sometimes does */ |
1914 | if (arrow->nrof == 0) |
1853 | if (arrow->nrof == 0) |
1915 | { |
1854 | { |
1916 | remove_ob (arrow); |
1855 | arrow->destroy (); |
1917 | free_object (arrow); |
|
|
1918 | return 0; |
1856 | return 0; |
1919 | } |
1857 | } |
1920 | |
1858 | |
1921 | left = arrow; /* these are arrows left to the player */ |
1859 | left = arrow; /* these are arrows left to the player */ |
1922 | left_tag = left->count; |
|
|
1923 | arrow = get_split_ob (arrow, 1); |
1860 | arrow = get_split_ob (arrow, 1); |
1924 | if (arrow == NULL) |
1861 | if (arrow == NULL) |
1925 | { |
1862 | { |
1926 | 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); |
1927 | return 0; |
1864 | return 0; |
1928 | } |
1865 | } |
1929 | set_owner (arrow, op); |
1866 | arrow->set_owner (op); |
1930 | arrow->skill = bow->skill; |
1867 | arrow->skill = bow->skill; |
1931 | |
1868 | |
1932 | arrow->direction = dir; |
1869 | arrow->direction = dir; |
1933 | arrow->x = sx; |
1870 | arrow->x = sx; |
1934 | arrow->y = sy; |
1871 | arrow->y = sy; |
… | |
… | |
1942 | SET_ANIMATION (arrow, arrow->direction); |
1879 | SET_ANIMATION (arrow, arrow->direction); |
1943 | arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ |
1880 | arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ |
1944 | arrow->stats.hp = arrow->stats.dam; |
1881 | arrow->stats.hp = arrow->stats.dam; |
1945 | arrow->stats.grace = arrow->attacktype; |
1882 | arrow->stats.grace = arrow->attacktype; |
1946 | if (arrow->slaying != NULL) |
1883 | if (arrow->slaying != NULL) |
1947 | arrow->spellarg = strdup_local (arrow->slaying); |
1884 | arrow->spellarg = strdup (arrow->slaying); |
1948 | |
1885 | |
1949 | /* Note that this was different for monsters - they got their level |
1886 | /* Note that this was different for monsters - they got their level |
1950 | * 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. |
1951 | */ |
1888 | */ |
1952 | |
1889 | |
… | |
… | |
1970 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1907 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1971 | } |
1908 | } |
1972 | else |
1909 | else |
1973 | { |
1910 | { |
1974 | 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; |
1975 | |
|
|
1976 | arrow->level = op->level; |
1912 | arrow->level = op->level; |
1977 | } |
1913 | } |
|
|
1914 | |
1978 | if (arrow->attacktype == AT_PHYSICAL) |
1915 | if (arrow->attacktype == AT_PHYSICAL) |
1979 | arrow->attacktype |= bow->attacktype; |
1916 | arrow->attacktype |= bow->attacktype; |
|
|
1917 | |
1980 | if (bow->slaying != NULL) |
1918 | if (bow->slaying != NULL) |
1981 | arrow->slaying = bow->slaying; |
1919 | arrow->slaying = bow->slaying; |
1982 | |
1920 | |
1983 | arrow->map = m; |
1921 | arrow->map = m; |
1984 | arrow->move_type = MOVE_FLY_LOW; |
1922 | arrow->move_type = MOVE_FLY_LOW; |
1985 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1923 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1986 | |
1924 | |
1987 | 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); |
1988 | tag = arrow->count; |
|
|
1989 | insert_ob_in_map (arrow, m, op, 0); |
1926 | insert_ob_in_map (arrow, m, op, 0); |
1990 | |
1927 | |
1991 | if (!was_destroyed (arrow, tag)) |
1928 | if (!arrow->destroyed ()) |
1992 | move_arrow (arrow); |
1929 | move_arrow (arrow); |
1993 | |
1930 | |
1994 | if (op->type == PLAYER) |
1931 | if (op->type == PLAYER) |
1995 | { |
1932 | { |
1996 | if (was_destroyed (left, left_tag)) |
1933 | if (left->destroyed ()) |
1997 | esrv_del_item (op->contr, left_tag); |
1934 | esrv_del_item (op->contr, left->count); |
1998 | else |
1935 | else |
1999 | esrv_send_item (op, left); |
1936 | esrv_send_item (op, left); |
2000 | } |
1937 | } |
|
|
1938 | |
2001 | return 1; |
1939 | return 1; |
2002 | } |
1940 | } |
2003 | |
1941 | |
2004 | /* Special fire code for players - this takes into |
1942 | /* Special fire code for players - this takes into |
2005 | * account the special fire modes players can have |
1943 | * account the special fire modes players can have |
… | |
… | |
2125 | if (action_makes_visible (op)) |
2063 | if (action_makes_visible (op)) |
2126 | make_visible (op); |
2064 | make_visible (op); |
2127 | |
2065 | |
2128 | switch (op->contr->shoottype) |
2066 | switch (op->contr->shoottype) |
2129 | { |
2067 | { |
2130 | case range_none: |
2068 | case range_none: |
2131 | return; |
2069 | return; |
2132 | |
2070 | |
2133 | case range_bow: |
2071 | case range_bow: |
2134 | player_fire_bow (op, dir); |
2072 | player_fire_bow (op, dir); |
2135 | return; |
2073 | return; |
2136 | |
2074 | |
2137 | case range_magic: /* Casting spells */ |
2075 | 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)); |
2076 | spellcost = (cast_spell (op, op, dir, op->contr->ranges[range_magic], op->contr->spellparam[0] ? op->contr->spellparam : 0)); |
2139 | return; |
2077 | return; |
2140 | |
2078 | |
2141 | case range_misc: |
2079 | case range_misc: |
2142 | fire_misc_object (op, dir); |
2080 | fire_misc_object (op, dir); |
2143 | return; |
2081 | return; |
2144 | |
2082 | |
2145 | case range_golem: /* Control summoned monsters from scrolls */ |
2083 | 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) |
2084 | if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2147 | { |
2085 | { |
2148 | op->contr->ranges[range_golem] = NULL; |
2086 | op->contr->ranges[range_golem] = 0; |
2149 | op->contr->shoottype = range_none; |
2087 | op->contr->shoottype = range_none; |
2150 | op->contr->golem_count = 0; |
|
|
2151 | } |
2088 | } |
2152 | else |
2089 | else |
2153 | control_golem (op->contr->ranges[range_golem], dir); |
2090 | control_golem (op->contr->ranges[range_golem], dir); |
2154 | return; |
2091 | return; |
2155 | |
2092 | |
2156 | case range_skill: |
2093 | case range_skill: |
2157 | if (!op->chosen_skill) |
2094 | if (!op->chosen_skill) |
2158 | { |
2095 | { |
2159 | if (op->type == PLAYER) |
2096 | if (op->type == PLAYER) |
2160 | 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."); |
2161 | return; |
2098 | return; |
2162 | } |
2099 | } |
2163 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
2100 | (void) do_skill (op, op, op->chosen_skill, dir, NULL); |
2164 | return; |
2101 | return; |
2165 | case range_builder: |
2102 | case range_builder: |
2166 | apply_map_builder (op, dir); |
2103 | apply_map_builder (op, dir); |
2167 | return; |
2104 | return; |
2168 | default: |
2105 | default: |
2169 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
2106 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
2170 | return; |
2107 | return; |
2171 | } |
2108 | } |
2172 | } |
2109 | } |
2173 | |
2110 | |
2174 | |
2111 | |
2175 | |
2112 | |
… | |
… | |
2317 | move_player_attack (object *op, int dir) |
2254 | move_player_attack (object *op, int dir) |
2318 | { |
2255 | { |
2319 | object *tmp, *mon; |
2256 | object *tmp, *mon; |
2320 | sint16 nx, ny; |
2257 | sint16 nx, ny; |
2321 | int on_battleground; |
2258 | int on_battleground; |
2322 | mapstruct *m; |
2259 | maptile *m; |
2323 | |
2260 | |
2324 | nx = freearr_x[dir] + op->x; |
2261 | nx = freearr_x[dir] + op->x; |
2325 | ny = freearr_y[dir] + op->y; |
2262 | ny = freearr_y[dir] + op->y; |
2326 | |
2263 | |
2327 | on_battleground = op_on_battleground (op, NULL, NULL); |
2264 | on_battleground = op_on_battleground (op, NULL, NULL); |
… | |
… | |
2363 | if (tmp == op) |
2300 | if (tmp == op) |
2364 | { |
2301 | { |
2365 | tmp = tmp->above; |
2302 | tmp = tmp->above; |
2366 | continue; |
2303 | continue; |
2367 | } |
2304 | } |
|
|
2305 | |
2368 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2306 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2369 | { |
2307 | { |
2370 | mon = tmp; |
2308 | mon = tmp; |
2371 | break; |
2309 | break; |
2372 | } |
2310 | } |
|
|
2311 | |
2373 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2312 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2374 | mon = tmp; |
2313 | mon = tmp; |
|
|
2314 | |
2375 | tmp = tmp->above; |
2315 | tmp = tmp->above; |
2376 | } |
2316 | } |
2377 | |
2317 | |
2378 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2318 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2379 | return; /* into a wall */ |
2319 | return; /* into a wall */ |
… | |
… | |
2398 | * player owns it and it is either friendly or unagressive. |
2338 | * player owns it and it is either friendly or unagressive. |
2399 | */ |
2339 | */ |
2400 | if ((op->type == PLAYER) |
2340 | if ((op->type == PLAYER) |
2401 | #if COZY_SERVER |
2341 | #if COZY_SERVER |
2402 | && |
2342 | && |
2403 | ((get_owner (mon) && get_owner (mon)->contr |
2343 | ((mon->owner && mon->owner->contr |
2404 | && 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) |
2405 | #else |
2345 | #else |
2406 | && get_owner (mon) == op |
2346 | && mon->owner == op |
2407 | #endif |
2347 | #endif |
2408 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2348 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2409 | { |
2349 | { |
2410 | /* 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 */ |
2411 | if (op->contr->braced) |
2351 | if (op->contr->braced) |
… | |
… | |
2598 | /* 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 |
2599 | * 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 |
2600 | * 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 |
2601 | * 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. |
2602 | */ |
2542 | */ |
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))) |
2543 | if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
2605 | { |
|
|
2606 | op->contr->ranges[range_golem] = NULL; |
2544 | op->contr->ranges[range_golem] = 0; |
2607 | op->contr->golem_count = 0; |
|
|
2608 | } |
|
|
2609 | |
2545 | |
2610 | /* 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 |
2611 | * the players time has been increased when doericserver has been |
2547 | * the players time has been increased when doericserver has been |
2612 | * called, so we recheck it here. |
2548 | * called, so we recheck it here. |
2613 | */ |
2549 | */ |
2614 | HandleClient (&op->contr->socket, op->contr); |
2550 | HandleClient (op->contr->socket, op->contr); |
2615 | if (op->speed_left < 0) |
2551 | if (op->speed_left < 0) |
2616 | return 0; |
2552 | return 0; |
2617 | |
2553 | |
2618 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2554 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2619 | { |
2555 | { |
… | |
… | |
2628 | if (op->speed_left > 0) |
2564 | if (op->speed_left > 0) |
2629 | return 1; |
2565 | return 1; |
2630 | else |
2566 | else |
2631 | return 0; |
2567 | return 0; |
2632 | } |
2568 | } |
|
|
2569 | |
2633 | return 0; |
2570 | return 0; |
2634 | } |
2571 | } |
2635 | |
2572 | |
2636 | int |
2573 | int |
2637 | save_life (object *op) |
2574 | save_life (object *op) |
2638 | { |
2575 | { |
2639 | object *tmp; |
|
|
2640 | |
|
|
2641 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2576 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2642 | return 0; |
2577 | return 0; |
2643 | |
2578 | |
2644 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2579 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
2645 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2580 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2646 | { |
2581 | { |
2647 | 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); |
2648 | 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 | |
2649 | if (op->contr) |
2585 | if (op->contr) |
2650 | esrv_del_item (op->contr, tmp->count); |
2586 | esrv_del_item (op->contr, tmp->count); |
2651 | remove_ob (tmp); |
2587 | |
2652 | free_object (tmp); |
2588 | tmp->destroy (); |
2653 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2589 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
|
|
2590 | |
2654 | if (op->stats.hp < 0) |
2591 | if (op->stats.hp < 0) |
2655 | op->stats.hp = op->stats.maxhp; |
2592 | op->stats.hp = op->stats.maxhp; |
|
|
2593 | |
2656 | if (op->stats.food < 0) |
2594 | if (op->stats.food < 0) |
2657 | op->stats.food = 999; |
2595 | op->stats.food = 999; |
|
|
2596 | |
2658 | fix_player (op); |
2597 | fix_player (op); |
2659 | return 1; |
2598 | return 1; |
2660 | } |
2599 | } |
|
|
2600 | |
2661 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2601 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2662 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2602 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2663 | enter_player_savebed (op); /* bring him home. */ |
2603 | enter_player_savebed (op); /* bring him home. */ |
2664 | return 0; |
2604 | return 0; |
2665 | } |
2605 | } |
… | |
… | |
2679 | 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 |
2680 | * we remove object 'op' |
2620 | * we remove object 'op' |
2681 | */ |
2621 | */ |
2682 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2622 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2683 | { |
2623 | { |
2684 | remove_ob (op); |
2624 | op->remove (); |
2685 | op->x = env->x; |
2625 | op->x = env->x; |
2686 | op->y = env->y; |
2626 | op->y = env->y; |
2687 | if (env->type == PLAYER) |
2627 | if (env->type == PLAYER) |
2688 | esrv_del_item (env->contr, op->count); |
2628 | esrv_del_item (env->contr, op->count); |
2689 | insert_ob_in_map (op, env->map, NULL, 0); |
2629 | insert_ob_in_map (op, env->map, NULL, 0); |
2690 | } |
2630 | } |
2691 | else if (op->inv) |
2631 | else if (op->inv) |
2692 | remove_unpaid_objects (op->inv, env); |
2632 | remove_unpaid_objects (op->inv, env); |
|
|
2633 | |
2693 | op = next; |
2634 | op = next; |
2694 | } |
2635 | } |
2695 | } |
2636 | } |
2696 | |
2637 | |
2697 | |
2638 | |
… | |
… | |
2712 | strcpy (buf2, " R.I.P.\n\n"); |
2653 | strcpy (buf2, " R.I.P.\n\n"); |
2713 | if (op->type == PLAYER) |
2654 | if (op->type == PLAYER) |
2714 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2655 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2715 | else |
2656 | else |
2716 | sprintf (buf, "%s\n", &op->name); |
2657 | sprintf (buf, "%s\n", &op->name); |
|
|
2658 | |
2717 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2659 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2718 | strcat (buf2, buf); |
2660 | strcat (buf2, buf); |
2719 | if (op->type == PLAYER) |
2661 | if (op->type == PLAYER) |
2720 | 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); |
2721 | else |
2663 | else |
2722 | 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 | |
2723 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2666 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2724 | strcat (buf2, buf); |
2667 | strcat (buf2, buf); |
2725 | if (op->type == PLAYER) |
2668 | if (op->type == PLAYER) |
2726 | { |
2669 | { |
2727 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2670 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2728 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2671 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2729 | strcat (buf2, buf); |
2672 | strcat (buf2, buf); |
2730 | } |
2673 | } |
|
|
2674 | |
2731 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2675 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2732 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2676 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2733 | strcat (buf2, buf); |
2677 | strcat (buf2, buf); |
|
|
2678 | |
2734 | return buf2; |
2679 | return buf2; |
2735 | } |
2680 | } |
2736 | |
2681 | |
2737 | |
2682 | |
2738 | |
2683 | |
… | |
… | |
2957 | { |
2902 | { |
2958 | char buf[MAX_BUF]; |
2903 | char buf[MAX_BUF]; |
2959 | int x, y; |
2904 | int x, y; |
2960 | |
2905 | |
2961 | //int i; |
2906 | //int i; |
2962 | mapstruct *map; /* this is for resurrection */ |
2907 | maptile *map; /* this is for resurrection */ |
2963 | |
2908 | |
2964 | /* int z; |
2909 | /* int z; |
2965 | int num_stats_lose; |
2910 | int num_stats_lose; |
2966 | int lost_a_stat; |
2911 | int lost_a_stat; |
2967 | int lose_this_stat; |
2912 | int lose_this_stat; |
… | |
… | |
2982 | { |
2927 | { |
2983 | 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!"); |
2984 | 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..."); |
2985 | |
2930 | |
2986 | /* restore player */ |
2931 | /* restore player */ |
2987 | at = find_archetype ("poisoning"); |
2932 | at = archetype::find ("poisoning"); |
2988 | tmp = present_arch_in_ob (at, op); |
2933 | tmp = present_arch_in_ob (at, op); |
2989 | if (tmp) |
2934 | if (tmp) |
2990 | { |
2935 | { |
2991 | remove_ob (tmp); |
2936 | tmp->destroy (); |
2992 | free_object (tmp); |
|
|
2993 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2937 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2994 | } |
2938 | } |
2995 | |
2939 | |
2996 | at = find_archetype ("confusion"); |
2940 | at = archetype::find ("confusion"); |
2997 | tmp = present_arch_in_ob (at, op); |
2941 | tmp = present_arch_in_ob (at, op); |
2998 | if (tmp) |
2942 | if (tmp) |
2999 | { |
2943 | { |
3000 | remove_ob (tmp); |
2944 | tmp->destroy (); |
3001 | free_object (tmp); |
|
|
3002 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2945 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3003 | } |
2946 | } |
3004 | |
2947 | |
3005 | cure_disease (op, 0); /* remove any disease */ |
2948 | cure_disease (op, 0); /* remove any disease */ |
3006 | op->stats.hp = op->stats.maxhp; |
2949 | op->stats.hp = op->stats.maxhp; |
3007 | if (op->stats.food <= 0) |
2950 | if (op->stats.food <= 0) |
3008 | op->stats.food = 999; |
2951 | op->stats.food = 999; |
3009 | |
2952 | |
3010 | /* create a bodypart-trophy to make the winner happy */ |
2953 | /* create a bodypart-trophy to make the winner happy */ |
3011 | tmp = arch_to_object (find_archetype ("finger")); |
2954 | tmp = arch_to_object (archetype::find ("finger")); |
3012 | if (tmp != NULL) |
2955 | if (tmp != NULL) |
3013 | { |
2956 | { |
3014 | sprintf (buf, "%s's finger", &op->name); |
2957 | sprintf (buf, "%s's finger", &op->name); |
3015 | tmp->name = buf; |
2958 | tmp->name = buf; |
3016 | sprintf (buf, " This finger has been cut off %s\n" |
2959 | sprintf (buf, " This finger has been cut off %s\n" |
… | |
… | |
3113 | lost_a_stat = 1; |
3056 | lost_a_stat = 1; |
3114 | } |
3057 | } |
3115 | else |
3058 | else |
3116 | { |
3059 | { |
3117 | /* deplete a stat */ |
3060 | /* deplete a stat */ |
3118 | archetype *deparch = find_archetype ("depletion"); |
3061 | archetype *deparch = archetype::find ("depletion"); |
3119 | object *dep; |
3062 | object *dep; |
3120 | |
3063 | |
3121 | dep = present_arch_in_ob (deparch, op); |
3064 | dep = present_arch_in_ob (deparch, op); |
3122 | if (!dep) |
3065 | if (!dep) |
3123 | { |
3066 | { |
… | |
… | |
3183 | /* determine_god() seems to not work sometimes... why is this? |
3126 | /* determine_god() seems to not work sometimes... why is this? |
3184 | Should I be using something else? GD */ |
3127 | Should I be using something else? GD */ |
3185 | const char *god = determine_god (op); |
3128 | const char *god = determine_god (op); |
3186 | |
3129 | |
3187 | if (god && (strcmp (god, "none"))) |
3130 | 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); |
3131 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
3189 | else |
3132 | else |
3190 | 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."); |
3191 | } |
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."); |
3192 | #endif |
3137 | #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 | |
3138 | |
3195 | /* Put a gravestone up where the character 'almost' died. List the |
3139 | /* Put a gravestone up where the character 'almost' died. List the |
3196 | * exp loss on the stone. |
3140 | * exp loss on the stone. |
3197 | */ |
3141 | */ |
3198 | tmp = arch_to_object (find_archetype ("gravestone")); |
3142 | tmp = arch_to_object (archetype::find ("gravestone")); |
3199 | sprintf (buf, "%s's gravestone", &op->name); |
3143 | sprintf (buf, "%s's gravestone", &op->name); |
3200 | tmp->name = buf; |
3144 | tmp->name = buf; |
3201 | sprintf (buf, "%s's gravestones", &op->name); |
3145 | sprintf (buf, "%s's gravestones", &op->name); |
3202 | tmp->name_pl = buf; |
3146 | 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); |
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); |
3204 | tmp->msg = buf; |
3148 | tmp->msg = buf; |
3205 | tmp->x = op->x, tmp->y = op->y; |
3149 | tmp->x = op->x, tmp->y = op->y; |
3206 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3150 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3207 | |
3151 | |
3208 | /**************************************/ |
3152 | /**************************************/ |
3209 | /* */ |
3153 | /* */ |
3210 | /* Subtract the experience points, */ |
3154 | /* Subtract the experience points, */ |
3211 | /* if we died cause of food, give us */ |
3155 | /* if we died cause of food, give us */ |
3212 | /* food, and reset HP's... */ |
3156 | /* food, and reset HP's... */ |
3213 | /* */ |
3157 | /* */ |
3214 | |
|
|
3215 | /**************************************/ |
3158 | /**************************************/ |
3216 | |
3159 | |
3217 | /* remove any poisoning and confusion the character may be suffering. */ |
3160 | /* remove any poisoning and confusion the character may be suffering. */ |
3218 | /* restore player */ |
3161 | /* restore player */ |
3219 | 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"); |
3220 | tmp = present_arch_in_ob (at, op); |
3172 | tmp = present_arch_in_ob (at, op); |
3221 | if (tmp) |
3173 | if (tmp) |
3222 | { |
3174 | { |
3223 | remove_ob (tmp); |
3175 | tmp->destroy (); |
3224 | free_object (tmp); |
|
|
3225 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
|
|
3226 | } |
|
|
3227 | |
|
|
3228 | at = find_archetype ("confusion"); |
|
|
3229 | tmp = present_arch_in_ob (at, op); |
|
|
3230 | if (tmp) |
|
|
3231 | { |
|
|
3232 | remove_ob (tmp); |
|
|
3233 | free_object (tmp); |
|
|
3234 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3176 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3235 | } |
3177 | } |
|
|
3178 | |
3236 | cure_disease (op, 0); /* remove any disease */ |
3179 | cure_disease (op, 0); /* remove any disease */ |
3237 | |
3180 | |
3238 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3181 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3239 | apply_death_exp_penalty (op); |
3182 | apply_death_exp_penalty (op); |
3240 | if (op->stats.food < 100) |
3183 | if (op->stats.food < 100) |
… | |
… | |
3250 | */ |
3193 | */ |
3251 | |
3194 | |
3252 | if (is_in_shop (op)) |
3195 | if (is_in_shop (op)) |
3253 | remove_unpaid_objects (op->inv, op); |
3196 | remove_unpaid_objects (op->inv, op); |
3254 | |
3197 | |
3255 | /****************************************/ |
3198 | /****************************************/ |
3256 | /* */ |
3199 | /* */ |
3257 | /* Move player to his current respawn- */ |
3200 | /* Move player to his current respawn- */ |
3258 | /* position (usually last savebed) */ |
3201 | /* position (usually last savebed) */ |
3259 | /* */ |
3202 | /* */ |
3260 | |
|
|
3261 | /****************************************/ |
3203 | /****************************************/ |
3262 | |
3204 | |
3263 | enter_player_savebed (op); |
3205 | enter_player_savebed (op); |
3264 | |
3206 | |
3265 | /* Save the player before inserting the force to reduce |
3207 | /* Save the player before inserting the force to reduce |
3266 | * chance of abuse. |
3208 | * chance of abuse. |
… | |
… | |
3273 | * spell effects. So first see if there is a spell effect |
3215 | * spell effects. So first see if there is a spell effect |
3274 | * on the space that might harm the player. |
3216 | * on the space that might harm the player. |
3275 | */ |
3217 | */ |
3276 | will_kill_again = 0; |
3218 | will_kill_again = 0; |
3277 | 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) |
3278 | { |
|
|
3279 | if (tmp->type == SPELL_EFFECT) |
3220 | if (tmp->type == SPELL_EFFECT) |
3280 | will_kill_again |= tmp->attacktype; |
3221 | will_kill_again |= tmp->attacktype; |
3281 | } |
3222 | |
3282 | if (will_kill_again) |
3223 | if (will_kill_again) |
3283 | { |
3224 | { |
3284 | object *force; |
3225 | object *force; |
3285 | int at; |
3226 | int at; |
3286 | |
3227 | |
… | |
… | |
3288 | /* 50 ticks should be enough time for the spell to abate */ |
3229 | /* 50 ticks should be enough time for the spell to abate */ |
3289 | force->speed = 0.1; |
3230 | force->speed = 0.1; |
3290 | force->speed_left = -5.0; |
3231 | force->speed_left = -5.0; |
3291 | SET_FLAG (force, FLAG_APPLIED); |
3232 | SET_FLAG (force, FLAG_APPLIED); |
3292 | for (at = 0; at < NROFATTACKS; at++) |
3233 | for (at = 0; at < NROFATTACKS; at++) |
3293 | { |
|
|
3294 | if (will_kill_again & (1 << at)) |
3234 | if (will_kill_again & (1 << at)) |
3295 | force->resist[at] = 100; |
3235 | force->resist[at] = 100; |
3296 | } |
3236 | |
3297 | insert_ob_in_ob (force, op); |
3237 | insert_ob_in_ob (force, op); |
3298 | fix_player (op); |
3238 | fix_player (op); |
3299 | |
3239 | |
3300 | } |
3240 | } |
3301 | |
|
|
3302 | /**************************************/ |
|
|
3303 | /* */ |
|
|
3304 | /* Repaint the characters inv, and */ |
|
|
3305 | /* stats, and show a nasty message ;) */ |
|
|
3306 | /* */ |
|
|
3307 | |
|
|
3308 | /**************************************/ |
|
|
3309 | |
3241 | |
3310 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
3242 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
3311 | return; |
3243 | return; |
3312 | } /* NOT_PERMADETH */ |
3244 | } /* NOT_PERMADETH */ |
3313 | else |
3245 | else |
… | |
… | |
3319 | op->contr->party = NULL; |
3251 | op->contr->party = NULL; |
3320 | if (settings.set_title == TRUE) |
3252 | if (settings.set_title == TRUE) |
3321 | op->contr->own_title[0] = '\0'; |
3253 | op->contr->own_title[0] = '\0'; |
3322 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3254 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3323 | check_score (op); |
3255 | check_score (op); |
|
|
3256 | |
3324 | if (op->contr->ranges[range_golem] != NULL) |
3257 | if (op->contr->ranges[range_golem]) |
3325 | { |
3258 | { |
3326 | remove_friendly_object (op->contr->ranges[range_golem]); |
3259 | remove_friendly_object (op->contr->ranges[range_golem]); |
3327 | remove_ob (op->contr->ranges[range_golem]); |
3260 | op->contr->ranges[range_golem]->destroy (); |
3328 | free_object (op->contr->ranges[range_golem]); |
|
|
3329 | op->contr->ranges[range_golem] = NULL; |
3261 | op->contr->ranges[range_golem] = 0; |
3330 | op->contr->golem_count = 0; |
|
|
3331 | } |
3262 | } |
|
|
3263 | |
3332 | loot_object (op); /* Remove some of the items for good */ |
3264 | loot_object (op); /* Remove some of the items for good */ |
3333 | remove_ob (op); |
3265 | op->remove (); |
3334 | op->direction = 0; |
3266 | op->direction = 0; |
3335 | |
3267 | |
3336 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3268 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3337 | { |
3269 | { |
3338 | delete_character (op->name, 0); |
3270 | delete_character (op->name, 0); |
… | |
… | |
3357 | op->map = map; |
3289 | op->map = map; |
3358 | /* please see resurrection.c: peterm */ |
3290 | /* please see resurrection.c: peterm */ |
3359 | dead_player (op); |
3291 | dead_player (op); |
3360 | } |
3292 | } |
3361 | else |
3293 | else |
3362 | { |
|
|
3363 | delete_character (op->name, 1); |
3294 | delete_character (op->name, 1); |
3364 | } |
3295 | } |
3365 | } |
3296 | |
3366 | play_again (op); |
3297 | play_again (op); |
3367 | |
3298 | |
3368 | /* peterm: added to create a corpse at deathsite. */ |
3299 | /* peterm: added to create a corpse at deathsite. */ |
3369 | tmp = arch_to_object (find_archetype ("corpse_pl")); |
3300 | tmp = arch_to_object (archetype::find ("corpse_pl")); |
3370 | sprintf (buf, "%s", &op->name); |
3301 | sprintf (buf, "%s", &op->name); |
3371 | tmp->name = tmp->name_pl = buf; |
3302 | tmp->name = tmp->name_pl = buf; |
3372 | tmp->level = op->level; |
3303 | tmp->level = op->level; |
3373 | tmp->x = x; |
3304 | tmp->x = x; |
3374 | tmp->y = y; |
3305 | tmp->y = y; |
… | |
… | |
3392 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3323 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3393 | { |
3324 | { |
3394 | next = tmp->below; |
3325 | next = tmp->below; |
3395 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3326 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3396 | continue; |
3327 | continue; |
3397 | remove_ob (tmp); |
3328 | tmp->remove (); |
3398 | tmp->x = op->x, tmp->y = op->y; |
3329 | tmp->x = op->x, tmp->y = op->y; |
3399 | if (tmp->type == CONTAINER) |
3330 | if (tmp->type == CONTAINER) |
3400 | { /* empty container to ground */ |
3331 | { /* empty container to ground */ |
3401 | loot_object (tmp); |
3332 | loot_object (tmp); |
3402 | } |
3333 | } |
3403 | 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))) |
3404 | { |
3335 | { |
3405 | if (tmp->nrof > 1) |
3336 | if (tmp->nrof > 1) |
3406 | { |
3337 | { |
3407 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3338 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3408 | free_object (tmp2); |
3339 | tmp2->destroy (); |
3409 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3340 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3410 | } |
3341 | } |
3411 | else |
3342 | else |
3412 | free_object (tmp); |
3343 | tmp->destroy (); |
3413 | } |
3344 | } |
3414 | else |
3345 | else |
3415 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3346 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3416 | } |
3347 | } |
3417 | } |
3348 | } |
… | |
… | |
3482 | if (op->type == PLAYER) |
3413 | if (op->type == PLAYER) |
3483 | 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); |
3484 | |
3415 | |
3485 | cast_spell (op, throw_ob, dir, spob, NULL); |
3416 | cast_spell (op, throw_ob, dir, spob, NULL); |
3486 | |
3417 | |
3487 | if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) |
3418 | throw_ob->destroy (); |
3488 | remove_ob (throw_ob); |
|
|
3489 | free_object (throw_ob); |
|
|
3490 | } |
3419 | } |
3491 | |
3420 | |
3492 | void |
3421 | void |
3493 | make_visible (object *op) |
3422 | make_visible (object *op) |
3494 | { |
3423 | { |
… | |
… | |
3610 | int |
3539 | int |
3611 | stand_near_hostile (object *who) |
3540 | stand_near_hostile (object *who) |
3612 | { |
3541 | { |
3613 | object *tmp = NULL; |
3542 | object *tmp = NULL; |
3614 | int i, friendly = 0, player = 0, mflags; |
3543 | int i, friendly = 0, player = 0, mflags; |
3615 | mapstruct *m; |
3544 | maptile *m; |
3616 | sint16 x, y; |
3545 | sint16 x, y; |
3617 | |
3546 | |
3618 | if (!who) |
3547 | if (!who) |
3619 | return 0; |
3548 | return 0; |
3620 | |
3549 | |
… | |
… | |
3701 | |
3630 | |
3702 | /* only the viewable area the player sees is updated by LOS |
3631 | /* only the viewable area the player sees is updated by LOS |
3703 | * 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 |
3704 | * for any meaningful values. |
3633 | * for any meaningful values. |
3705 | */ |
3634 | */ |
3706 | if (FABS (dx) <= (pl->contr->socket.mapx / 2) && |
3635 | if (FABS (dx) <= (pl->contr->socket->mapx / 2) && |
3707 | FABS (dy) <= (pl->contr->socket.mapy / 2) && |
3636 | FABS (dy) <= (pl->contr->socket->mapy / 2) && |
3708 | !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)]) |
3709 | return 1; |
3638 | return 1; |
3710 | op = op->more; |
3639 | op = op->more; |
3711 | } |
3640 | } |
3712 | return 0; |
3641 | return 0; |
3713 | } |
3642 | } |