… | |
… | |
20 | |
20 | |
21 | The author can be reached via e-mail to <crossfire@schmorp.de> |
21 | The author can be reached via e-mail to <crossfire@schmorp.de> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #ifndef WIN32 /* ---win32 remove headers */ |
|
|
26 | # include <pwd.h> |
25 | #include <pwd.h> |
27 | #endif |
|
|
28 | #ifndef __CEXTRACT__ |
|
|
29 | # include <sproto.h> |
26 | #include <sproto.h> |
30 | #endif |
|
|
31 | #include <sounds.h> |
27 | #include <sounds.h> |
32 | #include <living.h> |
28 | #include <living.h> |
33 | #include <object.h> |
29 | #include <object.h> |
34 | #include <spells.h> |
30 | #include <spells.h> |
35 | #include <skills.h> |
31 | #include <skills.h> |
… | |
… | |
208 | * the one that is passed. |
204 | * the one that is passed. |
209 | */ |
205 | */ |
210 | static player * |
206 | static player * |
211 | get_player (player *p) |
207 | get_player (player *p) |
212 | { |
208 | { |
213 | object *op = arch_to_object (get_player_archetype (NULL)); |
209 | object *op = arch_to_object (get_player_archetype (0)); |
214 | int i; |
210 | int i; |
215 | |
|
|
216 | if (!p) |
|
|
217 | { |
|
|
218 | p = new player; |
|
|
219 | |
|
|
220 | /* This adds the player in the linked list. There is extra |
|
|
221 | * complexity here because we want to add the new player at the |
|
|
222 | * end of the list - there is in fact no compelling reason that |
|
|
223 | * that needs to be done except for things like output of |
|
|
224 | * 'who'. |
|
|
225 | */ |
|
|
226 | player *tmp = first_player; |
|
|
227 | |
|
|
228 | while (tmp != NULL && tmp->next != NULL) |
|
|
229 | tmp = tmp->next; |
|
|
230 | if (tmp != NULL) |
|
|
231 | tmp->next = p; |
|
|
232 | else |
|
|
233 | first_player = p; |
|
|
234 | |
|
|
235 | p->next = NULL; |
|
|
236 | } |
|
|
237 | |
211 | |
238 | /* Clears basically the entire player structure except |
212 | /* Clears basically the entire player structure except |
239 | * for next and socket. |
213 | * for next and socket. |
240 | */ |
214 | */ |
241 | p->clear (); |
215 | p->clear (); |
… | |
… | |
260 | op->speed_left = 0.5; |
234 | op->speed_left = 0.5; |
261 | op->speed = 1.0; |
235 | op->speed = 1.0; |
262 | op->direction = 5; /* So player faces south */ |
236 | op->direction = 5; /* So player faces south */ |
263 | op->stats.wc = 2; |
237 | op->stats.wc = 2; |
264 | 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 |
265 | 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 */ |
266 | |
|
|
267 | roll_stats (op); |
243 | roll_stats (op); |
|
|
244 | p->socket->monitor_spells = oldmon; |
|
|
245 | } |
268 | p->state = ST_ROLL_STAT; |
246 | p->state = ST_ROLL_STAT; |
269 | clear_los (op); |
247 | clear_los (op); |
270 | |
248 | |
271 | p->gen_sp_armour = 10; |
249 | p->gen_sp_armour = 10; |
272 | p->last_speed = -1; |
250 | p->last_speed = -1; |
… | |
… | |
294 | for (i = 0; i < NUM_SKILLS; i++) |
272 | for (i = 0; i < NUM_SKILLS; i++) |
295 | { |
273 | { |
296 | p->last_skill_exp[i] = -1; |
274 | p->last_skill_exp[i] = -1; |
297 | p->last_skill_ob[i] = NULL; |
275 | p->last_skill_ob[i] = NULL; |
298 | } |
276 | } |
|
|
277 | |
299 | for (i = 0; i < NROFATTACKS; i++) |
278 | for (i = 0; i < NROFATTACKS; i++) |
300 | { |
|
|
301 | p->last_resist[i] = -1; |
279 | p->last_resist[i] = -1; |
302 | } |
280 | |
303 | p->last_stats.exp = -1; |
281 | p->last_stats.exp = -1; |
304 | p->last_weight = (uint32) - 1; |
282 | p->last_weight = (uint32) - 1; |
305 | |
283 | |
306 | p->socket.update_look = 0; |
284 | p->socket->update_look = 0; |
307 | p->socket.look_position = 0; |
285 | p->socket->look_position = 0; |
|
|
286 | |
308 | return p; |
287 | return p; |
309 | } |
288 | } |
310 | |
289 | |
311 | /* This loads the first map an puts the player on it. */ |
290 | /* This loads the first map an puts the player on it. */ |
312 | static void |
291 | static void |
… | |
… | |
322 | * 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 |
323 | * mode. |
302 | * mode. |
324 | */ |
303 | */ |
325 | |
304 | |
326 | int |
305 | int |
327 | add_player (NewSocket * ns) |
306 | add_player (client_socket *ns) |
328 | { |
307 | { |
329 | player *p; |
308 | player *p = new player; |
330 | |
309 | |
331 | p = get_player (NULL); |
|
|
332 | p->socket = *ns; |
310 | p->socket = ns; |
333 | p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
311 | ns->pl = p; |
334 | |
312 | |
335 | if (p->socket.faces_sent == NULL) |
313 | p->next = first_player; |
336 | fatal (OUT_OF_MEMORY); |
314 | first_player = p; |
337 | |
315 | |
338 | memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
316 | p = get_player (p); |
339 | /* Needed because the socket we just copied over needs to be cleared. |
317 | |
340 | * Note that this can result in a client reset if there is partial data |
|
|
341 | * on the uncoming socket. |
|
|
342 | */ |
|
|
343 | p->socket.inbuf.len = 0; |
|
|
344 | set_first_map (p->ob); |
318 | set_first_map (p->ob); |
345 | |
319 | |
346 | CLEAR_FLAG (p->ob, FLAG_FRIENDLY); |
320 | CLEAR_FLAG (p->ob, FLAG_FRIENDLY); |
347 | add_friendly_object (p->ob); |
321 | add_friendly_object (p->ob); |
348 | send_rules (p->ob); |
322 | send_rules (p->ob); |
… | |
… | |
646 | (op->type == ARMOUR || op->type == BOOTS || |
620 | (op->type == ARMOUR || op->type == BOOTS || |
647 | op->type == CLOAK || op->type == HELMET || |
621 | op->type == CLOAK || op->type == HELMET || |
648 | op->type == SHIELD || op->type == GLOVES || |
622 | op->type == SHIELD || op->type == GLOVES || |
649 | 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)) |
650 | { |
624 | { |
651 | remove_ob (op); |
625 | op->destroy (); |
652 | free_object (op); |
|
|
653 | continue; |
626 | continue; |
654 | } |
627 | } |
655 | } |
628 | } |
656 | |
629 | |
657 | /* This really needs to be better - we should really give |
630 | /* This really needs to be better - we should really give |
… | |
… | |
668 | if (tmp->type == op->type && tmp->name == op->name) |
641 | if (tmp->type == op->type && tmp->name == op->name) |
669 | break; |
642 | break; |
670 | |
643 | |
671 | if (tmp) |
644 | if (tmp) |
672 | { |
645 | { |
673 | remove_ob (op); |
646 | op->destroy (); |
674 | free_object (op); |
|
|
675 | 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); |
676 | continue; |
648 | continue; |
677 | } |
649 | } |
|
|
650 | |
678 | if (op->nrof > 1) |
651 | if (op->nrof > 1) |
679 | op->nrof = 1; |
652 | op->nrof = 1; |
680 | } |
653 | } |
681 | |
654 | |
682 | if (op->type == SPELLBOOK && op->inv) |
655 | if (op->type == SPELLBOOK && op->inv) |
… | |
… | |
694 | CLEAR_FLAG (op, FLAG_CURSED); |
667 | CLEAR_FLAG (op, FLAG_CURSED); |
695 | CLEAR_FLAG (op, FLAG_DAMNED); |
668 | CLEAR_FLAG (op, FLAG_DAMNED); |
696 | } |
669 | } |
697 | if (op->type == SPELL) |
670 | if (op->type == SPELL) |
698 | { |
671 | { |
699 | remove_ob (op); |
672 | op->destroy (); |
700 | free_object (op); |
|
|
701 | continue; |
673 | continue; |
702 | } |
674 | } |
703 | else if (op->type == SKILL) |
675 | else if (op->type == SKILL) |
704 | { |
676 | { |
705 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
677 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
… | |
… | |
718 | void |
690 | void |
719 | get_name (object *op) |
691 | get_name (object *op) |
720 | { |
692 | { |
721 | op->contr->write_buf[0] = '\0'; |
693 | op->contr->write_buf[0] = '\0'; |
722 | op->contr->state = ST_GET_NAME; |
694 | op->contr->state = ST_GET_NAME; |
723 | send_query (&op->contr->socket, 0, "What is your name?\n:"); |
695 | send_query (op->contr->socket, 0, "What is your name?\n:"); |
724 | } |
696 | } |
725 | |
697 | |
726 | void |
698 | void |
727 | get_password (object *op) |
699 | get_password (object *op) |
728 | { |
700 | { |
729 | op->contr->write_buf[0] = '\0'; |
701 | op->contr->write_buf[0] = '\0'; |
730 | op->contr->state = ST_GET_PASSWORD; |
702 | op->contr->state = ST_GET_PASSWORD; |
731 | 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:"); |
732 | } |
704 | } |
733 | |
705 | |
734 | void |
706 | void |
735 | play_again (object *op) |
707 | play_again (object *op) |
736 | { |
708 | { |
737 | op->contr->state = ST_PLAY_AGAIN; |
709 | op->contr->state = ST_PLAY_AGAIN; |
738 | op->chosen_skill = NULL; |
710 | op->chosen_skill = NULL; |
739 | 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)?"); |
740 | /* 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 |
741 | * player creation process that a user can quit (eg, roll |
713 | * player creation process that a user can quit (eg, roll |
742 | * stats) that isn't removing the player. Taking a quick |
714 | * stats) that isn't removing the player. Taking a quick |
743 | * look, there are many places that call play_again without |
715 | * look, there are many places that call play_again without |
744 | * removing the player - it probably makes more sense |
716 | * removing the player - it probably makes more sense |
745 | * 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 |
746 | * cases. |
718 | * cases. |
747 | */ |
719 | */ |
748 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
720 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
749 | remove_ob (op); |
721 | op->remove (); |
750 | /* 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, |
751 | * 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 |
752 | * the map is null or not swapped out. |
724 | * the map is null or not swapped out. |
753 | */ |
725 | */ |
754 | op->map = NULL; |
726 | op->map = NULL; |
… | |
… | |
768 | player *pl = op->contr; |
740 | player *pl = op->contr; |
769 | shstr name = op->name; |
741 | shstr name = op->name; |
770 | |
742 | |
771 | op->contr = 0; |
743 | op->contr = 0; |
772 | op->type = 0; |
744 | op->type = 0; |
773 | op->free (1); |
745 | op->destroy (1); |
774 | pl = get_player (pl); |
746 | pl = get_player (pl); |
775 | op = pl->ob; |
747 | op = pl->ob; |
776 | add_friendly_object (op); |
748 | add_friendly_object (op); |
777 | op->contr->password[0] = '~'; |
749 | op->contr->password[0] = '~'; |
778 | op->name = op->name_pl = 0; |
750 | op->name = op->name_pl = 0; |
… | |
… | |
793 | confirm_password (object *op) |
765 | confirm_password (object *op) |
794 | { |
766 | { |
795 | |
767 | |
796 | op->contr->write_buf[0] = '\0'; |
768 | op->contr->write_buf[0] = '\0'; |
797 | op->contr->state = ST_CONFIRM_PASSWORD; |
769 | op->contr->state = ST_CONFIRM_PASSWORD; |
798 | 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:"); |
799 | } |
771 | } |
800 | |
772 | |
801 | void |
773 | void |
802 | get_party_password (object *op, partylist *party) |
774 | get_party_password (object *op, partylist *party) |
803 | { |
775 | { |
… | |
… | |
807 | return; |
779 | return; |
808 | } |
780 | } |
809 | op->contr->write_buf[0] = '\0'; |
781 | op->contr->write_buf[0] = '\0'; |
810 | op->contr->state = ST_GET_PARTY_PASSWORD; |
782 | op->contr->state = ST_GET_PARTY_PASSWORD; |
811 | op->contr->party_to_join = party; |
783 | op->contr->party_to_join = party; |
812 | 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:"); |
813 | } |
785 | } |
814 | |
786 | |
815 | |
787 | |
816 | /* 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. */ |
817 | int |
789 | int |
… | |
… | |
914 | |
886 | |
915 | void |
887 | void |
916 | Roll_Again (object *op) |
888 | Roll_Again (object *op) |
917 | { |
889 | { |
918 | esrv_new_player (op->contr, 0); |
890 | esrv_new_player (op->contr, 0); |
919 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
891 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, |
920 | "[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)? "); |
921 | } |
893 | } |
922 | |
894 | |
923 | void |
895 | void |
924 | Swap_Stat (object *op, int Swap_Second) |
896 | Swap_Stat (object *op, int Swap_Second) |
… | |
… | |
991 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
963 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
992 | } |
964 | } |
993 | else |
965 | else |
994 | Swap_Stat (op, stat_trans[keynum]); |
966 | Swap_Stat (op, stat_trans[keynum]); |
995 | |
967 | |
996 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
968 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
997 | return 1; |
969 | return 1; |
998 | } |
970 | } |
999 | switch (key) |
971 | switch (key) |
1000 | { |
972 | { |
1001 | case 'n': |
973 | case 'n': |
… | |
… | |
1015 | enter_exit (op, NULL); |
987 | enter_exit (op, NULL); |
1016 | #endif |
988 | #endif |
1017 | SET_ANIMATION (op, 2); /* So player faces south */ |
989 | SET_ANIMATION (op, 2); /* So player faces south */ |
1018 | /* Enter exit adds a player otherwise */ |
990 | /* Enter exit adds a player otherwise */ |
1019 | add_statbonus (op); |
991 | add_statbonus (op); |
1020 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, |
992 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, |
1021 | "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"); |
1022 | op->contr->state = ST_CHANGE_CLASS; |
994 | op->contr->state = ST_CHANGE_CLASS; |
1023 | if (op->msg) |
995 | if (op->msg) |
1024 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
996 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1025 | return 0; |
997 | return 0; |
1026 | } |
998 | } |
1027 | case 'y': |
999 | case 'y': |
1028 | case 'Y': |
1000 | case 'Y': |
1029 | roll_stats (op); |
1001 | roll_stats (op); |
1030 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
1002 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
1031 | return 1; |
1003 | return 1; |
1032 | |
1004 | |
1033 | case 'q': |
1005 | case 'q': |
1034 | case 'Q': |
1006 | case 'Q': |
1035 | play_again (op); |
1007 | play_again (op); |
1036 | return 1; |
1008 | return 1; |
1037 | |
1009 | |
1038 | default: |
1010 | default: |
1039 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
1011 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
1040 | return 0; |
1012 | return 0; |
1041 | } |
1013 | } |
1042 | return 0; |
1014 | return 0; |
1043 | } |
1015 | } |
1044 | |
1016 | |
… | |
… | |
1054 | { |
1026 | { |
1055 | int tmp_loop; |
1027 | int tmp_loop; |
1056 | |
1028 | |
1057 | if (key == 'q' || key == 'Q') |
1029 | if (key == 'q' || key == 'Q') |
1058 | { |
1030 | { |
1059 | remove_ob (op); |
1031 | op->remove (); |
1060 | play_again (op); |
1032 | play_again (op); |
1061 | return 0; |
1033 | return 0; |
1062 | } |
1034 | } |
1063 | if (key == 'd' || key == 'D') |
1035 | if (key == 'd' || key == 'D') |
1064 | { |
1036 | { |
1065 | char buf[MAX_BUF]; |
1037 | char buf[MAX_BUF]; |
1066 | |
1038 | |
1067 | /* this must before then initial items are given */ |
1039 | /* this must before then initial items are given */ |
1068 | esrv_new_player (op->contr, op->weight + op->carrying); |
1040 | esrv_new_player (op->contr, op->weight + op->carrying); |
|
|
1041 | |
1069 | 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); |
1070 | |
1045 | |
1071 | INVOKE_PLAYER (BIRTH, op->contr); |
1046 | INVOKE_PLAYER (BIRTH, op->contr); |
1072 | INVOKE_PLAYER (LOGIN, op->contr); |
1047 | INVOKE_PLAYER (LOGIN, op->contr); |
1073 | |
1048 | |
1074 | op->contr->state = ST_PLAYING; |
1049 | op->contr->state = ST_PLAYING; |
… | |
… | |
1099 | { |
1074 | { |
1100 | object *tmp; |
1075 | object *tmp; |
1101 | char mapname[MAX_BUF]; |
1076 | char mapname[MAX_BUF]; |
1102 | |
1077 | |
1103 | 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); |
1104 | tmp = get_object (); |
1079 | tmp = object::create (); |
1105 | EXIT_PATH (tmp) = mapname; |
1080 | EXIT_PATH (tmp) = mapname; |
1106 | EXIT_X (tmp) = op->x; |
1081 | EXIT_X (tmp) = op->x; |
1107 | EXIT_Y (tmp) = op->y; |
1082 | EXIT_Y (tmp) = op->y; |
1108 | 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; |
1109 | * if the map isn't there, then stay on the |
1084 | * if the map isn't there, then stay on the |
1110 | * default initial map */ |
1085 | * default initial map */ |
1111 | free_object (tmp); |
1086 | tmp->destroy (); |
1112 | } |
1087 | } |
1113 | else |
1088 | else |
1114 | { |
1089 | { |
1115 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1090 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1116 | } |
1091 | } |
… | |
… | |
1126 | { |
1101 | { |
1127 | shstr name = op->name; |
1102 | shstr name = op->name; |
1128 | int x = op->x, y = op->y; |
1103 | int x = op->x, y = op->y; |
1129 | |
1104 | |
1130 | remove_statbonus (op); |
1105 | remove_statbonus (op); |
1131 | remove_ob (op); |
1106 | op->remove (); |
1132 | op->arch = get_player_archetype (op->arch); |
1107 | op->arch = get_player_archetype (op->arch); |
1133 | copy_object (&op->arch->clone, op); |
1108 | op->arch->clone.copy_to (op); |
1134 | op->instantiate (); |
1109 | op->instantiate (); |
1135 | op->stats = op->contr->orig_stats; |
1110 | op->stats = op->contr->orig_stats; |
1136 | op->name = op->name_pl = name; |
1111 | op->name = op->name_pl = name; |
1137 | op->x = x; |
1112 | op->x = x; |
1138 | op->y = y; |
1113 | op->y = y; |
… | |
… | |
1151 | op->stats.grace = 0; |
1126 | op->stats.grace = 0; |
1152 | |
1127 | |
1153 | if (op->msg) |
1128 | if (op->msg) |
1154 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1129 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1155 | |
1130 | |
1156 | 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"); |
1157 | return 0; |
1132 | return 0; |
1158 | } |
1133 | } |
1159 | |
1134 | |
1160 | int |
1135 | int |
1161 | key_confirm_quit (object *op, char key) |
1136 | key_confirm_quit (object *op, char key) |
… | |
… | |
1426 | /* question: don't pick up known-poisonous stuff? */ |
1401 | /* question: don't pick up known-poisonous stuff? */ |
1427 | if (op->contr->mode & PU_FOOD) |
1402 | if (op->contr->mode & PU_FOOD) |
1428 | if (tmp->type == FOOD) |
1403 | if (tmp->type == FOOD) |
1429 | { |
1404 | { |
1430 | pick_up (op, tmp); |
1405 | pick_up (op, tmp); |
1431 | if (0) |
|
|
1432 | fprintf (stderr, "FOOD\n"); |
|
|
1433 | continue; |
1406 | continue; |
1434 | } |
1407 | } |
|
|
1408 | |
1435 | if (op->contr->mode & PU_DRINK) |
1409 | if (op->contr->mode & PU_DRINK) |
1436 | 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))) |
1437 | { |
1411 | { |
1438 | pick_up (op, tmp); |
1412 | pick_up (op, tmp); |
1439 | if (0) |
|
|
1440 | fprintf (stderr, "DRINK\n"); |
|
|
1441 | continue; |
1413 | continue; |
1442 | } |
1414 | } |
1443 | |
1415 | |
1444 | if (op->contr->mode & PU_POTION) |
1416 | if (op->contr->mode & PU_POTION) |
1445 | if (tmp->type == POTION) |
1417 | if (tmp->type == POTION) |
1446 | { |
1418 | { |
1447 | pick_up (op, tmp); |
1419 | pick_up (op, tmp); |
1448 | if (0) |
|
|
1449 | fprintf (stderr, "POTION\n"); |
|
|
1450 | continue; |
1420 | continue; |
1451 | } |
1421 | } |
1452 | |
1422 | |
1453 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1423 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1454 | if (op->contr->mode & PU_SPELLBOOK) |
1424 | if (op->contr->mode & PU_SPELLBOOK) |
1455 | if (tmp->type == SPELLBOOK) |
1425 | if (tmp->type == SPELLBOOK) |
1456 | { |
1426 | { |
1457 | pick_up (op, tmp); |
1427 | pick_up (op, tmp); |
1458 | if (0) |
|
|
1459 | fprintf (stderr, "SPELLBOOK\n"); |
|
|
1460 | continue; |
1428 | continue; |
1461 | } |
1429 | } |
|
|
1430 | |
1462 | if (op->contr->mode & PU_SKILLSCROLL) |
1431 | if (op->contr->mode & PU_SKILLSCROLL) |
1463 | if (tmp->type == SKILLSCROLL) |
1432 | if (tmp->type == SKILLSCROLL) |
1464 | { |
1433 | { |
1465 | pick_up (op, tmp); |
1434 | pick_up (op, tmp); |
1466 | if (0) |
|
|
1467 | fprintf (stderr, "SKILLSCROLL\n"); |
|
|
1468 | continue; |
1435 | continue; |
1469 | } |
1436 | } |
|
|
1437 | |
1470 | if (op->contr->mode & PU_READABLES) |
1438 | if (op->contr->mode & PU_READABLES) |
1471 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1439 | if (tmp->type == BOOK || tmp->type == SCROLL) |
1472 | { |
1440 | { |
1473 | pick_up (op, tmp); |
1441 | pick_up (op, tmp); |
1474 | if (0) |
|
|
1475 | fprintf (stderr, "READABLES\n"); |
|
|
1476 | continue; |
1442 | continue; |
1477 | } |
1443 | } |
1478 | |
1444 | |
1479 | /* wands/staves/rods/horns */ |
1445 | /* wands/staves/rods/horns */ |
1480 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1446 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1481 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1447 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1482 | { |
1448 | { |
1483 | pick_up (op, tmp); |
1449 | pick_up (op, tmp); |
1484 | if (0) |
|
|
1485 | fprintf (stderr, "MAGIC_DEVICE\n"); |
|
|
1486 | continue; |
1450 | continue; |
1487 | } |
1451 | } |
1488 | |
1452 | |
1489 | /* pick up all magical items */ |
1453 | /* pick up all magical items */ |
1490 | if (op->contr->mode & PU_MAGICAL) |
1454 | if (op->contr->mode & PU_MAGICAL) |
1491 | 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)) |
1492 | { |
1456 | { |
1493 | pick_up (op, tmp); |
1457 | pick_up (op, tmp); |
1494 | if (0) |
|
|
1495 | fprintf (stderr, "MAGICAL\n"); |
|
|
1496 | continue; |
1458 | continue; |
1497 | } |
1459 | } |
1498 | |
1460 | |
1499 | if (op->contr->mode & PU_VALUABLES) |
1461 | if (op->contr->mode & PU_VALUABLES) |
1500 | { |
1462 | { |
1501 | if (tmp->type == MONEY || tmp->type == GEM) |
1463 | if (tmp->type == MONEY || tmp->type == GEM) |
1502 | { |
1464 | { |
1503 | pick_up (op, tmp); |
1465 | pick_up (op, tmp); |
1504 | if (0) |
|
|
1505 | fprintf (stderr, "MONEY/GEM\n"); |
|
|
1506 | continue; |
1466 | continue; |
1507 | } |
1467 | } |
1508 | } |
1468 | } |
1509 | |
1469 | |
1510 | /* rings & amulets - talismans seems to be typed AMULET */ |
1470 | /* rings & amulets - talismans seems to be typed AMULET */ |
1511 | if (op->contr->mode & PU_JEWELS) |
1471 | if (op->contr->mode & PU_JEWELS) |
1512 | if (tmp->type == RING || tmp->type == AMULET) |
1472 | if (tmp->type == RING || tmp->type == AMULET) |
1513 | { |
1473 | { |
1514 | pick_up (op, tmp); |
1474 | pick_up (op, tmp); |
|
|
1475 | continue; |
1515 | if (0) |
1476 | } |
1516 | 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); |
1517 | continue; |
1483 | continue; |
1518 | } |
1484 | } |
1519 | |
1485 | |
1520 | /* bows and arrows. Bows are good for selling! */ |
1486 | /* bows and arrows. Bows are good for selling! */ |
1521 | if (op->contr->mode & PU_BOW) |
1487 | if (op->contr->mode & PU_BOW) |
1522 | if (tmp->type == BOW) |
1488 | if (tmp->type == BOW) |
1523 | { |
1489 | { |
1524 | pick_up (op, tmp); |
1490 | pick_up (op, tmp); |
1525 | if (0) |
|
|
1526 | fprintf (stderr, "BOW\n"); |
|
|
1527 | continue; |
1491 | continue; |
1528 | } |
1492 | } |
|
|
1493 | |
1529 | if (op->contr->mode & PU_ARROW) |
1494 | if (op->contr->mode & PU_ARROW) |
1530 | if (tmp->type == ARROW) |
1495 | if (tmp->type == ARROW) |
1531 | { |
1496 | { |
1532 | pick_up (op, tmp); |
1497 | pick_up (op, tmp); |
1533 | if (0) |
|
|
1534 | fprintf (stderr, "ARROW\n"); |
|
|
1535 | continue; |
1498 | continue; |
1536 | } |
1499 | } |
1537 | |
1500 | |
1538 | /* all kinds of armor etc. */ |
1501 | /* all kinds of armor etc. */ |
1539 | if (op->contr->mode & PU_ARMOUR) |
1502 | if (op->contr->mode & PU_ARMOUR) |
1540 | if (tmp->type == ARMOUR) |
1503 | if (tmp->type == ARMOUR) |
1541 | { |
1504 | { |
1542 | pick_up (op, tmp); |
1505 | pick_up (op, tmp); |
1543 | if (0) |
|
|
1544 | fprintf (stderr, "ARMOUR\n"); |
|
|
1545 | continue; |
1506 | continue; |
1546 | } |
1507 | } |
|
|
1508 | |
1547 | if (op->contr->mode & PU_HELMET) |
1509 | if (op->contr->mode & PU_HELMET) |
1548 | if (tmp->type == HELMET) |
1510 | if (tmp->type == HELMET) |
1549 | { |
1511 | { |
1550 | pick_up (op, tmp); |
1512 | pick_up (op, tmp); |
1551 | if (0) |
|
|
1552 | fprintf (stderr, "HELMET\n"); |
|
|
1553 | continue; |
1513 | continue; |
1554 | } |
1514 | } |
|
|
1515 | |
1555 | if (op->contr->mode & PU_SHIELD) |
1516 | if (op->contr->mode & PU_SHIELD) |
1556 | if (tmp->type == SHIELD) |
1517 | if (tmp->type == SHIELD) |
1557 | { |
1518 | { |
1558 | pick_up (op, tmp); |
1519 | pick_up (op, tmp); |
1559 | if (0) |
|
|
1560 | fprintf (stderr, "SHIELD\n"); |
|
|
1561 | continue; |
1520 | continue; |
1562 | } |
1521 | } |
|
|
1522 | |
1563 | if (op->contr->mode & PU_BOOTS) |
1523 | if (op->contr->mode & PU_BOOTS) |
1564 | if (tmp->type == BOOTS) |
1524 | if (tmp->type == BOOTS) |
1565 | { |
1525 | { |
1566 | pick_up (op, tmp); |
1526 | pick_up (op, tmp); |
1567 | if (0) |
|
|
1568 | fprintf (stderr, "BOOTS\n"); |
|
|
1569 | continue; |
1527 | continue; |
1570 | } |
1528 | } |
|
|
1529 | |
1571 | if (op->contr->mode & PU_GLOVES) |
1530 | if (op->contr->mode & PU_GLOVES) |
1572 | if (tmp->type == GLOVES) |
1531 | if (tmp->type == GLOVES) |
1573 | { |
1532 | { |
1574 | pick_up (op, tmp); |
1533 | pick_up (op, tmp); |
1575 | if (0) |
|
|
1576 | fprintf (stderr, "GLOVES\n"); |
|
|
1577 | continue; |
1534 | continue; |
1578 | } |
1535 | } |
|
|
1536 | |
1579 | if (op->contr->mode & PU_CLOAK) |
1537 | if (op->contr->mode & PU_CLOAK) |
1580 | if (tmp->type == CLOAK) |
1538 | if (tmp->type == CLOAK) |
1581 | { |
1539 | { |
1582 | pick_up (op, tmp); |
1540 | pick_up (op, tmp); |
1583 | if (0) |
|
|
1584 | fprintf (stderr, "GLOVES\n"); |
|
|
1585 | continue; |
1541 | continue; |
1586 | } |
1542 | } |
1587 | |
1543 | |
1588 | /* hoping to catch throwing daggers here */ |
1544 | /* hoping to catch throwing daggers here */ |
1589 | if (op->contr->mode & PU_MISSILEWEAPON) |
1545 | if (op->contr->mode & PU_MISSILEWEAPON) |
1590 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1546 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1591 | { |
1547 | { |
1592 | pick_up (op, tmp); |
1548 | pick_up (op, tmp); |
1593 | if (0) |
|
|
1594 | fprintf (stderr, "MISSILEWEAPON\n"); |
|
|
1595 | continue; |
1549 | continue; |
1596 | } |
1550 | } |
1597 | |
1551 | |
1598 | /* careful: chairs and tables are weapons! */ |
1552 | /* careful: chairs and tables are weapons! */ |
1599 | if (op->contr->mode & PU_ALLWEAPON) |
1553 | if (op->contr->mode & PU_ALLWEAPON) |
… | |
… | |
1602 | { |
1556 | { |
1603 | 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 && |
1604 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1558 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1605 | { |
1559 | { |
1606 | pick_up (op, tmp); |
1560 | pick_up (op, tmp); |
1607 | if (0) |
|
|
1608 | fprintf (stderr, "WEAPON\n"); |
|
|
1609 | continue; |
1561 | continue; |
1610 | } |
1562 | } |
1611 | } |
1563 | } |
|
|
1564 | |
1612 | if (tmp->type == WEAPON && tmp->name == NULL) |
1565 | if (tmp->type == WEAPON && tmp->name == NULL) |
1613 | { |
1566 | { |
1614 | 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) |
1615 | { |
1568 | { |
1616 | pick_up (op, tmp); |
1569 | pick_up (op, tmp); |
1617 | if (0) |
|
|
1618 | fprintf (stderr, "WEAPON\n"); |
|
|
1619 | continue; |
1570 | continue; |
1620 | } |
1571 | } |
1621 | } |
1572 | } |
1622 | } |
1573 | } |
1623 | |
1574 | |
1624 | /* misc stuff that's useful */ |
1575 | /* misc stuff that's useful */ |
1625 | if (op->contr->mode & PU_KEY) |
1576 | if (op->contr->mode & PU_KEY) |
1626 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1577 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1627 | { |
1578 | { |
1628 | pick_up (op, tmp); |
1579 | pick_up (op, tmp); |
1629 | if (0) |
|
|
1630 | fprintf (stderr, "KEY\n"); |
|
|
1631 | continue; |
1580 | continue; |
1632 | } |
1581 | } |
1633 | |
1582 | |
1634 | /* 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 |
1635 | * pickups */ |
1584 | * pickups */ |
… | |
… | |
1657 | continue; |
1606 | continue; |
1658 | } |
1607 | } |
1659 | } |
1608 | } |
1660 | } /* the new pickup model */ |
1609 | } /* the new pickup model */ |
1661 | } |
1610 | } |
|
|
1611 | |
1662 | return !stop; |
1612 | return !stop; |
1663 | } |
1613 | } |
1664 | |
1614 | |
1665 | /* |
1615 | /* |
1666 | * Find an arrow in the inventory and after that |
1616 | * Find an arrow in the inventory and after that |
… | |
… | |
1900 | } |
1850 | } |
1901 | |
1851 | |
1902 | /* this should not happen, but sometimes does */ |
1852 | /* this should not happen, but sometimes does */ |
1903 | if (arrow->nrof == 0) |
1853 | if (arrow->nrof == 0) |
1904 | { |
1854 | { |
1905 | remove_ob (arrow); |
1855 | arrow->destroy (); |
1906 | free_object (arrow); |
|
|
1907 | return 0; |
1856 | return 0; |
1908 | } |
1857 | } |
1909 | |
1858 | |
1910 | left = arrow; /* these are arrows left to the player */ |
1859 | left = arrow; /* these are arrows left to the player */ |
1911 | arrow = get_split_ob (arrow, 1); |
1860 | arrow = get_split_ob (arrow, 1); |
1912 | if (arrow == NULL) |
1861 | if (arrow == NULL) |
1913 | { |
1862 | { |
1914 | 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); |
1915 | return 0; |
1864 | return 0; |
1916 | } |
1865 | } |
1917 | set_owner (arrow, op); |
1866 | arrow->set_owner (op); |
1918 | arrow->skill = bow->skill; |
1867 | arrow->skill = bow->skill; |
1919 | |
1868 | |
1920 | arrow->direction = dir; |
1869 | arrow->direction = dir; |
1921 | arrow->x = sx; |
1870 | arrow->x = sx; |
1922 | arrow->y = sy; |
1871 | arrow->y = sy; |
… | |
… | |
1930 | SET_ANIMATION (arrow, arrow->direction); |
1879 | SET_ANIMATION (arrow, arrow->direction); |
1931 | arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ |
1880 | arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ |
1932 | arrow->stats.hp = arrow->stats.dam; |
1881 | arrow->stats.hp = arrow->stats.dam; |
1933 | arrow->stats.grace = arrow->attacktype; |
1882 | arrow->stats.grace = arrow->attacktype; |
1934 | if (arrow->slaying != NULL) |
1883 | if (arrow->slaying != NULL) |
1935 | arrow->spellarg = strdup_local (arrow->slaying); |
1884 | arrow->spellarg = strdup (arrow->slaying); |
1936 | |
1885 | |
1937 | /* Note that this was different for monsters - they got their level |
1886 | /* Note that this was different for monsters - they got their level |
1938 | * 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. |
1939 | */ |
1888 | */ |
1940 | |
1889 | |
… | |
… | |
2130 | case range_misc: |
2079 | case range_misc: |
2131 | fire_misc_object (op, dir); |
2080 | fire_misc_object (op, dir); |
2132 | return; |
2081 | return; |
2133 | |
2082 | |
2134 | case range_golem: /* Control summoned monsters from scrolls */ |
2083 | case range_golem: /* Control summoned monsters from scrolls */ |
2135 | 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)) |
2136 | { |
2085 | { |
2137 | op->contr->ranges[range_golem] = NULL; |
2086 | op->contr->ranges[range_golem] = 0; |
2138 | op->contr->shoottype = range_none; |
2087 | op->contr->shoottype = range_none; |
2139 | op->contr->golem_count = 0; |
|
|
2140 | } |
2088 | } |
2141 | else |
2089 | else |
2142 | control_golem (op->contr->ranges[range_golem], dir); |
2090 | control_golem (op->contr->ranges[range_golem], dir); |
2143 | return; |
2091 | return; |
2144 | |
2092 | |
… | |
… | |
2352 | if (tmp == op) |
2300 | if (tmp == op) |
2353 | { |
2301 | { |
2354 | tmp = tmp->above; |
2302 | tmp = tmp->above; |
2355 | continue; |
2303 | continue; |
2356 | } |
2304 | } |
|
|
2305 | |
2357 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2306 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
2358 | { |
2307 | { |
2359 | mon = tmp; |
2308 | mon = tmp; |
2360 | break; |
2309 | break; |
2361 | } |
2310 | } |
|
|
2311 | |
2362 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2312 | if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) |
2363 | mon = tmp; |
2313 | mon = tmp; |
|
|
2314 | |
2364 | tmp = tmp->above; |
2315 | tmp = tmp->above; |
2365 | } |
2316 | } |
2366 | |
2317 | |
2367 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2318 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2368 | return; /* into a wall */ |
2319 | return; /* into a wall */ |
… | |
… | |
2387 | * player owns it and it is either friendly or unagressive. |
2338 | * player owns it and it is either friendly or unagressive. |
2388 | */ |
2339 | */ |
2389 | if ((op->type == PLAYER) |
2340 | if ((op->type == PLAYER) |
2390 | #if COZY_SERVER |
2341 | #if COZY_SERVER |
2391 | && |
2342 | && |
2392 | ((get_owner (mon) && get_owner (mon)->contr |
2343 | ((mon->owner && mon->owner->contr |
2393 | && 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) |
2394 | #else |
2345 | #else |
2395 | && get_owner (mon) == op |
2346 | && mon->owner == op |
2396 | #endif |
2347 | #endif |
2397 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2348 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2398 | { |
2349 | { |
2399 | /* 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 */ |
2400 | if (op->contr->braced) |
2351 | if (op->contr->braced) |
… | |
… | |
2587 | /* 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 |
2588 | * 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 |
2589 | * 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 |
2590 | * 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. |
2591 | */ |
2542 | */ |
2592 | if (op->contr->ranges[range_golem] && |
|
|
2593 | ((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)) |
2594 | { |
|
|
2595 | op->contr->ranges[range_golem] = NULL; |
2544 | op->contr->ranges[range_golem] = 0; |
2596 | op->contr->golem_count = 0; |
|
|
2597 | } |
|
|
2598 | |
2545 | |
2599 | /* 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 |
2600 | * the players time has been increased when doericserver has been |
2547 | * the players time has been increased when doericserver has been |
2601 | * called, so we recheck it here. |
2548 | * called, so we recheck it here. |
2602 | */ |
2549 | */ |
2603 | HandleClient (&op->contr->socket, op->contr); |
2550 | HandleClient (op->contr->socket, op->contr); |
2604 | if (op->speed_left < 0) |
2551 | if (op->speed_left < 0) |
2605 | return 0; |
2552 | return 0; |
2606 | |
2553 | |
2607 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2554 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2608 | { |
2555 | { |
… | |
… | |
2617 | if (op->speed_left > 0) |
2564 | if (op->speed_left > 0) |
2618 | return 1; |
2565 | return 1; |
2619 | else |
2566 | else |
2620 | return 0; |
2567 | return 0; |
2621 | } |
2568 | } |
|
|
2569 | |
2622 | return 0; |
2570 | return 0; |
2623 | } |
2571 | } |
2624 | |
2572 | |
2625 | int |
2573 | int |
2626 | save_life (object *op) |
2574 | save_life (object *op) |
2627 | { |
2575 | { |
2628 | object *tmp; |
|
|
2629 | |
|
|
2630 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2576 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2631 | return 0; |
2577 | return 0; |
2632 | |
2578 | |
2633 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2579 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
2634 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2580 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2635 | { |
2581 | { |
2636 | 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); |
2637 | 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 | |
2638 | if (op->contr) |
2585 | if (op->contr) |
2639 | esrv_del_item (op->contr, tmp->count); |
2586 | esrv_del_item (op->contr, tmp->count); |
2640 | remove_ob (tmp); |
2587 | |
2641 | free_object (tmp); |
2588 | tmp->destroy (); |
2642 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2589 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
|
|
2590 | |
2643 | if (op->stats.hp < 0) |
2591 | if (op->stats.hp < 0) |
2644 | op->stats.hp = op->stats.maxhp; |
2592 | op->stats.hp = op->stats.maxhp; |
|
|
2593 | |
2645 | if (op->stats.food < 0) |
2594 | if (op->stats.food < 0) |
2646 | op->stats.food = 999; |
2595 | op->stats.food = 999; |
|
|
2596 | |
2647 | fix_player (op); |
2597 | fix_player (op); |
2648 | return 1; |
2598 | return 1; |
2649 | } |
2599 | } |
|
|
2600 | |
2650 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2601 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2651 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2602 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2652 | enter_player_savebed (op); /* bring him home. */ |
2603 | enter_player_savebed (op); /* bring him home. */ |
2653 | return 0; |
2604 | return 0; |
2654 | } |
2605 | } |
… | |
… | |
2668 | 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 |
2669 | * we remove object 'op' |
2620 | * we remove object 'op' |
2670 | */ |
2621 | */ |
2671 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2622 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2672 | { |
2623 | { |
2673 | remove_ob (op); |
2624 | op->remove (); |
2674 | op->x = env->x; |
2625 | op->x = env->x; |
2675 | op->y = env->y; |
2626 | op->y = env->y; |
2676 | if (env->type == PLAYER) |
2627 | if (env->type == PLAYER) |
2677 | esrv_del_item (env->contr, op->count); |
2628 | esrv_del_item (env->contr, op->count); |
2678 | insert_ob_in_map (op, env->map, NULL, 0); |
2629 | insert_ob_in_map (op, env->map, NULL, 0); |
2679 | } |
2630 | } |
2680 | else if (op->inv) |
2631 | else if (op->inv) |
2681 | remove_unpaid_objects (op->inv, env); |
2632 | remove_unpaid_objects (op->inv, env); |
|
|
2633 | |
2682 | op = next; |
2634 | op = next; |
2683 | } |
2635 | } |
2684 | } |
2636 | } |
2685 | |
2637 | |
2686 | |
2638 | |
… | |
… | |
2701 | strcpy (buf2, " R.I.P.\n\n"); |
2653 | strcpy (buf2, " R.I.P.\n\n"); |
2702 | if (op->type == PLAYER) |
2654 | if (op->type == PLAYER) |
2703 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2655 | sprintf (buf, "%s the %s\n", &op->name, op->contr->title); |
2704 | else |
2656 | else |
2705 | sprintf (buf, "%s\n", &op->name); |
2657 | sprintf (buf, "%s\n", &op->name); |
|
|
2658 | |
2706 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2659 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2707 | strcat (buf2, buf); |
2660 | strcat (buf2, buf); |
2708 | if (op->type == PLAYER) |
2661 | if (op->type == PLAYER) |
2709 | 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); |
2710 | else |
2663 | else |
2711 | 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 | |
2712 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2666 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2713 | strcat (buf2, buf); |
2667 | strcat (buf2, buf); |
2714 | if (op->type == PLAYER) |
2668 | if (op->type == PLAYER) |
2715 | { |
2669 | { |
2716 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2670 | sprintf (buf, "by %s.\n\n", op->contr->killer); |
2717 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2671 | strncat (buf2, " ", 21 - strlen (buf) / 2); |
2718 | strcat (buf2, buf); |
2672 | strcat (buf2, buf); |
2719 | } |
2673 | } |
|
|
2674 | |
2720 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2675 | strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); |
2721 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2676 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2722 | strcat (buf2, buf); |
2677 | strcat (buf2, buf); |
|
|
2678 | |
2723 | return buf2; |
2679 | return buf2; |
2724 | } |
2680 | } |
2725 | |
2681 | |
2726 | |
2682 | |
2727 | |
2683 | |
… | |
… | |
2975 | /* restore player */ |
2931 | /* restore player */ |
2976 | at = archetype::find ("poisoning"); |
2932 | at = archetype::find ("poisoning"); |
2977 | tmp = present_arch_in_ob (at, op); |
2933 | tmp = present_arch_in_ob (at, op); |
2978 | if (tmp) |
2934 | if (tmp) |
2979 | { |
2935 | { |
2980 | remove_ob (tmp); |
2936 | tmp->destroy (); |
2981 | free_object (tmp); |
|
|
2982 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2937 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
2983 | } |
2938 | } |
2984 | |
2939 | |
2985 | at = archetype::find ("confusion"); |
2940 | at = archetype::find ("confusion"); |
2986 | tmp = present_arch_in_ob (at, op); |
2941 | tmp = present_arch_in_ob (at, op); |
2987 | if (tmp) |
2942 | if (tmp) |
2988 | { |
2943 | { |
2989 | remove_ob (tmp); |
2944 | tmp->destroy (); |
2990 | free_object (tmp); |
|
|
2991 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2945 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
2992 | } |
2946 | } |
2993 | |
2947 | |
2994 | cure_disease (op, 0); /* remove any disease */ |
2948 | cure_disease (op, 0); /* remove any disease */ |
2995 | op->stats.hp = op->stats.maxhp; |
2949 | op->stats.hp = op->stats.maxhp; |
… | |
… | |
3172 | /* determine_god() seems to not work sometimes... why is this? |
3126 | /* determine_god() seems to not work sometimes... why is this? |
3173 | Should I be using something else? GD */ |
3127 | Should I be using something else? GD */ |
3174 | const char *god = determine_god (op); |
3128 | const char *god = determine_god (op); |
3175 | |
3129 | |
3176 | if (god && (strcmp (god, "none"))) |
3130 | if (god && (strcmp (god, "none"))) |
3177 | 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); |
3178 | else |
3132 | else |
3179 | 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."); |
3180 | } |
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."); |
3181 | #endif |
3137 | #endif |
3182 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
|
|
3183 | |
3138 | |
3184 | /* Put a gravestone up where the character 'almost' died. List the |
3139 | /* Put a gravestone up where the character 'almost' died. List the |
3185 | * exp loss on the stone. |
3140 | * exp loss on the stone. |
3186 | */ |
3141 | */ |
3187 | tmp = arch_to_object (archetype::find ("gravestone")); |
3142 | tmp = arch_to_object (archetype::find ("gravestone")); |
… | |
… | |
3192 | 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); |
3193 | tmp->msg = buf; |
3148 | tmp->msg = buf; |
3194 | tmp->x = op->x, tmp->y = op->y; |
3149 | tmp->x = op->x, tmp->y = op->y; |
3195 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3150 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3196 | |
3151 | |
3197 | /**************************************/ |
3152 | /**************************************/ |
3198 | /* */ |
3153 | /* */ |
3199 | /* Subtract the experience points, */ |
3154 | /* Subtract the experience points, */ |
3200 | /* if we died cause of food, give us */ |
3155 | /* if we died cause of food, give us */ |
3201 | /* food, and reset HP's... */ |
3156 | /* food, and reset HP's... */ |
3202 | /* */ |
3157 | /* */ |
3203 | |
|
|
3204 | /**************************************/ |
3158 | /**************************************/ |
3205 | |
3159 | |
3206 | /* remove any poisoning and confusion the character may be suffering. */ |
3160 | /* remove any poisoning and confusion the character may be suffering. */ |
3207 | /* restore player */ |
3161 | /* restore player */ |
3208 | at = archetype::find ("poisoning"); |
3162 | at = archetype::find ("poisoning"); |
3209 | tmp = present_arch_in_ob (at, op); |
3163 | tmp = present_arch_in_ob (at, op); |
|
|
3164 | |
3210 | if (tmp) |
3165 | if (tmp) |
3211 | { |
3166 | { |
3212 | remove_ob (tmp); |
3167 | tmp->destroy (); |
3213 | free_object (tmp); |
|
|
3214 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
3168 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
3215 | } |
3169 | } |
3216 | |
3170 | |
3217 | at = archetype::find ("confusion"); |
3171 | at = archetype::find ("confusion"); |
3218 | tmp = present_arch_in_ob (at, op); |
3172 | tmp = present_arch_in_ob (at, op); |
3219 | if (tmp) |
3173 | if (tmp) |
3220 | { |
3174 | { |
3221 | remove_ob (tmp); |
3175 | tmp->destroy (); |
3222 | free_object (tmp); |
|
|
3223 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3176 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
3224 | } |
3177 | } |
|
|
3178 | |
3225 | cure_disease (op, 0); /* remove any disease */ |
3179 | cure_disease (op, 0); /* remove any disease */ |
3226 | |
3180 | |
3227 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3181 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
3228 | apply_death_exp_penalty (op); |
3182 | apply_death_exp_penalty (op); |
3229 | if (op->stats.food < 100) |
3183 | if (op->stats.food < 100) |
… | |
… | |
3239 | */ |
3193 | */ |
3240 | |
3194 | |
3241 | if (is_in_shop (op)) |
3195 | if (is_in_shop (op)) |
3242 | remove_unpaid_objects (op->inv, op); |
3196 | remove_unpaid_objects (op->inv, op); |
3243 | |
3197 | |
3244 | /****************************************/ |
3198 | /****************************************/ |
3245 | /* */ |
3199 | /* */ |
3246 | /* Move player to his current respawn- */ |
3200 | /* Move player to his current respawn- */ |
3247 | /* position (usually last savebed) */ |
3201 | /* position (usually last savebed) */ |
3248 | /* */ |
3202 | /* */ |
3249 | |
|
|
3250 | /****************************************/ |
3203 | /****************************************/ |
3251 | |
3204 | |
3252 | enter_player_savebed (op); |
3205 | enter_player_savebed (op); |
3253 | |
3206 | |
3254 | /* Save the player before inserting the force to reduce |
3207 | /* Save the player before inserting the force to reduce |
3255 | * chance of abuse. |
3208 | * chance of abuse. |
… | |
… | |
3262 | * spell effects. So first see if there is a spell effect |
3215 | * spell effects. So first see if there is a spell effect |
3263 | * on the space that might harm the player. |
3216 | * on the space that might harm the player. |
3264 | */ |
3217 | */ |
3265 | will_kill_again = 0; |
3218 | will_kill_again = 0; |
3266 | 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) |
3267 | { |
|
|
3268 | if (tmp->type == SPELL_EFFECT) |
3220 | if (tmp->type == SPELL_EFFECT) |
3269 | will_kill_again |= tmp->attacktype; |
3221 | will_kill_again |= tmp->attacktype; |
3270 | } |
3222 | |
3271 | if (will_kill_again) |
3223 | if (will_kill_again) |
3272 | { |
3224 | { |
3273 | object *force; |
3225 | object *force; |
3274 | int at; |
3226 | int at; |
3275 | |
3227 | |
… | |
… | |
3277 | /* 50 ticks should be enough time for the spell to abate */ |
3229 | /* 50 ticks should be enough time for the spell to abate */ |
3278 | force->speed = 0.1; |
3230 | force->speed = 0.1; |
3279 | force->speed_left = -5.0; |
3231 | force->speed_left = -5.0; |
3280 | SET_FLAG (force, FLAG_APPLIED); |
3232 | SET_FLAG (force, FLAG_APPLIED); |
3281 | for (at = 0; at < NROFATTACKS; at++) |
3233 | for (at = 0; at < NROFATTACKS; at++) |
3282 | { |
|
|
3283 | if (will_kill_again & (1 << at)) |
3234 | if (will_kill_again & (1 << at)) |
3284 | force->resist[at] = 100; |
3235 | force->resist[at] = 100; |
3285 | } |
3236 | |
3286 | insert_ob_in_ob (force, op); |
3237 | insert_ob_in_ob (force, op); |
3287 | fix_player (op); |
3238 | fix_player (op); |
3288 | |
3239 | |
3289 | } |
3240 | } |
3290 | |
3241 | |
… | |
… | |
3300 | op->contr->party = NULL; |
3251 | op->contr->party = NULL; |
3301 | if (settings.set_title == TRUE) |
3252 | if (settings.set_title == TRUE) |
3302 | op->contr->own_title[0] = '\0'; |
3253 | op->contr->own_title[0] = '\0'; |
3303 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3254 | new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); |
3304 | check_score (op); |
3255 | check_score (op); |
|
|
3256 | |
3305 | if (op->contr->ranges[range_golem] != NULL) |
3257 | if (op->contr->ranges[range_golem]) |
3306 | { |
3258 | { |
3307 | remove_friendly_object (op->contr->ranges[range_golem]); |
3259 | remove_friendly_object (op->contr->ranges[range_golem]); |
3308 | remove_ob (op->contr->ranges[range_golem]); |
3260 | op->contr->ranges[range_golem]->destroy (); |
3309 | free_object (op->contr->ranges[range_golem]); |
|
|
3310 | op->contr->ranges[range_golem] = NULL; |
3261 | op->contr->ranges[range_golem] = 0; |
3311 | op->contr->golem_count = 0; |
|
|
3312 | } |
3262 | } |
|
|
3263 | |
3313 | loot_object (op); /* Remove some of the items for good */ |
3264 | loot_object (op); /* Remove some of the items for good */ |
3314 | remove_ob (op); |
3265 | op->remove (); |
3315 | op->direction = 0; |
3266 | op->direction = 0; |
3316 | |
3267 | |
3317 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3268 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) |
3318 | { |
3269 | { |
3319 | delete_character (op->name, 0); |
3270 | delete_character (op->name, 0); |
… | |
… | |
3372 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3323 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3373 | { |
3324 | { |
3374 | next = tmp->below; |
3325 | next = tmp->below; |
3375 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3326 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3376 | continue; |
3327 | continue; |
3377 | remove_ob (tmp); |
3328 | tmp->remove (); |
3378 | tmp->x = op->x, tmp->y = op->y; |
3329 | tmp->x = op->x, tmp->y = op->y; |
3379 | if (tmp->type == CONTAINER) |
3330 | if (tmp->type == CONTAINER) |
3380 | { /* empty container to ground */ |
3331 | { /* empty container to ground */ |
3381 | loot_object (tmp); |
3332 | loot_object (tmp); |
3382 | } |
3333 | } |
3383 | 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))) |
3384 | { |
3335 | { |
3385 | if (tmp->nrof > 1) |
3336 | if (tmp->nrof > 1) |
3386 | { |
3337 | { |
3387 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3338 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3388 | free_object (tmp2); |
3339 | tmp2->destroy (); |
3389 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3340 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3390 | } |
3341 | } |
3391 | else |
3342 | else |
3392 | free_object (tmp); |
3343 | tmp->destroy (); |
3393 | } |
3344 | } |
3394 | else |
3345 | else |
3395 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3346 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3396 | } |
3347 | } |
3397 | } |
3348 | } |
… | |
… | |
3462 | if (op->type == PLAYER) |
3413 | if (op->type == PLAYER) |
3463 | 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); |
3464 | |
3415 | |
3465 | cast_spell (op, throw_ob, dir, spob, NULL); |
3416 | cast_spell (op, throw_ob, dir, spob, NULL); |
3466 | |
3417 | |
3467 | if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) |
3418 | throw_ob->destroy (); |
3468 | remove_ob (throw_ob); |
|
|
3469 | free_object (throw_ob); |
|
|
3470 | } |
3419 | } |
3471 | |
3420 | |
3472 | void |
3421 | void |
3473 | make_visible (object *op) |
3422 | make_visible (object *op) |
3474 | { |
3423 | { |
… | |
… | |
3681 | |
3630 | |
3682 | /* only the viewable area the player sees is updated by LOS |
3631 | /* only the viewable area the player sees is updated by LOS |
3683 | * 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 |
3684 | * for any meaningful values. |
3633 | * for any meaningful values. |
3685 | */ |
3634 | */ |
3686 | if (FABS (dx) <= (pl->contr->socket.mapx / 2) && |
3635 | if (FABS (dx) <= (pl->contr->socket->mapx / 2) && |
3687 | FABS (dy) <= (pl->contr->socket.mapy / 2) && |
3636 | FABS (dy) <= (pl->contr->socket->mapy / 2) && |
3688 | !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)]) |
3689 | return 1; |
3638 | return 1; |
3690 | op = op->more; |
3639 | op = op->more; |
3691 | } |
3640 | } |
3692 | return 0; |
3641 | return 0; |
3693 | } |
3642 | } |