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