… | |
… | |
82 | int comp; |
82 | int comp; |
83 | int size; |
83 | int size; |
84 | |
84 | |
85 | sprintf (buf, "%s/%s", settings.confdir, settings.motd); |
85 | sprintf (buf, "%s/%s", settings.confdir, settings.motd); |
86 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
86 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
87 | { |
|
|
88 | return; |
87 | return; |
89 | } |
88 | |
90 | motd[0] = '\0'; |
89 | motd[0] = '\0'; |
91 | size = 0; |
90 | size = 0; |
|
|
91 | |
92 | while (fgets (buf, MAX_BUF, fp) != NULL) |
92 | while (fgets (buf, MAX_BUF, fp) != NULL) |
93 | { |
93 | { |
94 | if (*buf == '#') |
94 | if (*buf == '#') |
95 | continue; |
95 | continue; |
|
|
96 | |
96 | strncat (motd + size, buf, HUGE_BUF - size); |
97 | strncat (motd + size, buf, HUGE_BUF - size); |
97 | size += strlen (buf); |
98 | size += strlen (buf); |
98 | } |
99 | } |
|
|
100 | |
99 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL); |
101 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL); |
100 | close_and_delete (fp, comp); |
102 | close_and_delete (fp, comp); |
101 | } |
103 | } |
102 | |
104 | |
103 | void |
105 | void |
… | |
… | |
109 | int comp; |
111 | int comp; |
110 | int size; |
112 | int size; |
111 | |
113 | |
112 | sprintf (buf, "%s/%s", settings.confdir, settings.rules); |
114 | sprintf (buf, "%s/%s", settings.confdir, settings.rules); |
113 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
115 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
114 | { |
|
|
115 | return; |
116 | return; |
116 | } |
117 | |
117 | rules[0] = '\0'; |
118 | rules[0] = '\0'; |
118 | size = 0; |
119 | size = 0; |
|
|
120 | |
119 | while (fgets (buf, MAX_BUF, fp) != NULL) |
121 | while (fgets (buf, MAX_BUF, fp) != NULL) |
120 | { |
122 | { |
121 | if (*buf == '#') |
123 | if (*buf == '#') |
122 | continue; |
124 | continue; |
|
|
125 | |
123 | if (size + strlen (buf) >= HUGE_BUF) |
126 | if (size + strlen (buf) >= HUGE_BUF) |
124 | { |
127 | { |
125 | LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF); |
128 | LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF); |
126 | break; |
129 | break; |
127 | } |
130 | } |
|
|
131 | |
128 | strncat (rules + size, buf, HUGE_BUF - size); |
132 | strncat (rules + size, buf, HUGE_BUF - size); |
129 | size += strlen (buf); |
133 | size += strlen (buf); |
130 | } |
134 | } |
|
|
135 | |
131 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL); |
136 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL); |
132 | close_and_delete (fp, comp); |
137 | close_and_delete (fp, comp); |
133 | } |
138 | } |
134 | |
139 | |
135 | void |
140 | void |
… | |
… | |
143 | int size; |
148 | int size; |
144 | |
149 | |
145 | sprintf (buf, "%s/%s", settings.confdir, settings.news); |
150 | sprintf (buf, "%s/%s", settings.confdir, settings.news); |
146 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
151 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
147 | return; |
152 | return; |
|
|
153 | |
148 | news[0] = '\0'; |
154 | news[0] = '\0'; |
149 | subject[0] = '\0'; |
155 | subject[0] = '\0'; |
150 | size = 0; |
156 | size = 0; |
|
|
157 | |
151 | while (fgets (buf, MAX_BUF, fp) != NULL) |
158 | while (fgets (buf, MAX_BUF, fp) != NULL) |
152 | { |
159 | { |
153 | if (*buf == '#') |
160 | if (*buf == '#') |
154 | continue; |
161 | continue; |
|
|
162 | |
155 | if (*buf == '%') |
163 | if (*buf == '%') |
156 | { /* send one news */ |
164 | { /* send one news */ |
157 | if (size > 0) |
165 | if (size > 0) |
158 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */ |
166 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */ |
159 | strcpy (subject, buf + 1); |
167 | strcpy (subject, buf + 1); |
… | |
… | |
186 | return 0; |
194 | return 0; |
187 | |
195 | |
188 | for (; *cp != '\0'; cp++) |
196 | for (; *cp != '\0'; cp++) |
189 | if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_') |
197 | if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_') |
190 | return 0; |
198 | return 0; |
|
|
199 | |
191 | return 1; |
200 | return 1; |
192 | } |
201 | } |
193 | |
202 | |
194 | /* This no longer sets the player map. Also, it now updates |
203 | /* This no longer sets the player map. Also, it now updates |
195 | * all the pointers so the caller doesn't need to do that. |
204 | * all the pointers so the caller doesn't need to do that. |
… | |
… | |
235 | op->direction = 5; /* So player faces south */ |
244 | op->direction = 5; /* So player faces south */ |
236 | op->stats.wc = 2; |
245 | op->stats.wc = 2; |
237 | op->run_away = 25; /* Then we panick... */ |
246 | op->run_away = 25; /* Then we panick... */ |
238 | |
247 | |
239 | { |
248 | { |
240 | int oldmon = p->socket->monitor_spells; // what a hack |
249 | int oldmon = p->ns->monitor_spells; // what a hack |
241 | p->socket->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ |
250 | p->ns->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ |
242 | roll_stats (op); |
251 | roll_stats (op); |
243 | p->socket->monitor_spells = oldmon; |
252 | p->ns->monitor_spells = oldmon; |
244 | } |
253 | } |
245 | p->state = ST_ROLL_STAT; |
254 | p->ns->state = ST_ROLL_STAT; |
246 | clear_los (op); |
255 | clear_los (op); |
247 | |
256 | |
248 | p->gen_sp_armour = 10; |
257 | p->gen_sp_armour = 10; |
249 | p->last_speed = -1; |
258 | p->last_speed = -1; |
250 | p->shoottype = range_none; |
259 | p->shoottype = range_none; |
… | |
… | |
254 | p->usekeys = containers; |
263 | p->usekeys = containers; |
255 | p->last_weapon_sp = -1; |
264 | p->last_weapon_sp = -1; |
256 | p->peaceful = 1; /* default peaceful */ |
265 | p->peaceful = 1; /* default peaceful */ |
257 | p->do_los = 1; |
266 | p->do_los = 1; |
258 | p->explore = 0; |
267 | p->explore = 0; |
259 | p->no_shout = 0; /* default can shout */ |
|
|
260 | |
268 | |
261 | assign (p->title, op->arch->clone.name); |
269 | assign (p->title, op->arch->clone.name); |
262 | op->race = op->arch->clone.race; |
270 | op->race = op->arch->clone.race; |
263 | |
271 | |
264 | CLEAR_FLAG (op, FLAG_READY_SKILL); |
272 | CLEAR_FLAG (op, FLAG_READY_SKILL); |
… | |
… | |
278 | p->last_resist[i] = -1; |
286 | p->last_resist[i] = -1; |
279 | |
287 | |
280 | p->last_stats.exp = -1; |
288 | p->last_stats.exp = -1; |
281 | p->last_weight = (uint32) - 1; |
289 | p->last_weight = (uint32) - 1; |
282 | |
290 | |
283 | p->socket->update_look = 0; |
291 | p->ns->update_look = 0; |
284 | p->socket->look_position = 0; |
292 | p->ns->look_position = 0; |
285 | |
293 | |
286 | return p; |
294 | return p; |
287 | } |
295 | } |
288 | |
296 | |
289 | /* This loads the first map an puts the player on it. */ |
297 | /* This loads the first map an puts the player on it. */ |
… | |
… | |
291 | set_first_map (object *op) |
299 | set_first_map (object *op) |
292 | { |
300 | { |
293 | strcpy (op->contr->maplevel, first_map_path); |
301 | strcpy (op->contr->maplevel, first_map_path); |
294 | op->x = -1; |
302 | op->x = -1; |
295 | op->y = -1; |
303 | op->y = -1; |
296 | enter_exit (op, NULL); |
304 | enter_exit (op, 0); |
297 | } |
305 | } |
298 | |
306 | |
299 | /* Tries to add player on the connection passwd in ns. |
307 | /* Tries to add player on the connection passwd in ns. |
300 | * All we can really get in this is some settings like host and display |
308 | * All we can really get in this is some settings like host and display |
301 | * mode. |
309 | * mode. |
… | |
… | |
304 | int |
312 | int |
305 | add_player (client *ns) |
313 | add_player (client *ns) |
306 | { |
314 | { |
307 | player *p = new player; |
315 | player *p = new player; |
308 | |
316 | |
309 | p->socket = ns; |
317 | p->ns = ns; |
310 | ns->pl = p; |
318 | ns->pl = p; |
311 | |
319 | |
312 | p->next = first_player; |
320 | p->next = first_player; |
313 | first_player = p; |
321 | first_player = p; |
314 | |
322 | |
… | |
… | |
319 | CLEAR_FLAG (p->ob, FLAG_FRIENDLY); |
327 | CLEAR_FLAG (p->ob, FLAG_FRIENDLY); |
320 | add_friendly_object (p->ob); |
328 | add_friendly_object (p->ob); |
321 | send_rules (p->ob); |
329 | send_rules (p->ob); |
322 | send_news (p->ob); |
330 | send_news (p->ob); |
323 | display_motd (p->ob); |
331 | display_motd (p->ob); |
|
|
332 | |
324 | get_name (p->ob); |
333 | get_name (p->ob); |
325 | |
334 | |
326 | return 0; |
335 | return 0; |
327 | } |
336 | } |
328 | |
337 | |
… | |
… | |
340 | { |
349 | { |
341 | if (at == NULL || at->next == NULL) |
350 | if (at == NULL || at->next == NULL) |
342 | at = first_archetype; |
351 | at = first_archetype; |
343 | else |
352 | else |
344 | at = at->next; |
353 | at = at->next; |
|
|
354 | |
345 | if (at->clone.type == PLAYER) |
355 | if (at->clone.type == PLAYER) |
346 | return at; |
356 | return at; |
|
|
357 | |
347 | if (at == start) |
358 | if (at == start) |
348 | { |
359 | { |
349 | LOG (llevError, "No Player archetypes\n"); |
360 | LOG (llevError, "No Player archetypes\n"); |
350 | exit (-1); |
361 | exit (-1); |
351 | } |
362 | } |
352 | } |
363 | } |
353 | } |
364 | } |
354 | |
|
|
355 | |
365 | |
356 | object * |
366 | object * |
357 | get_nearest_player (object *mon) |
367 | get_nearest_player (object *mon) |
358 | { |
368 | { |
359 | object *op = NULL; |
369 | object *op = NULL; |
… | |
… | |
688 | |
698 | |
689 | void |
699 | void |
690 | get_name (object *op) |
700 | get_name (object *op) |
691 | { |
701 | { |
692 | op->contr->write_buf[0] = '\0'; |
702 | op->contr->write_buf[0] = '\0'; |
693 | op->contr->state = ST_GET_NAME; |
703 | op->contr->ns->state = ST_GET_NAME; |
694 | send_query (op->contr->socket, 0, "What is your name?\n:"); |
704 | send_query (op->contr->ns, 0, "What is your name?\n:"); |
695 | } |
705 | } |
696 | |
706 | |
697 | void |
707 | void |
698 | get_password (object *op) |
708 | get_password (object *op) |
699 | { |
709 | { |
700 | op->contr->write_buf[0] = '\0'; |
710 | op->contr->write_buf[0] = '\0'; |
701 | op->contr->state = ST_GET_PASSWORD; |
711 | op->contr->ns->state = ST_GET_PASSWORD; |
702 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); |
712 | send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "What is your password?\n:"); |
703 | } |
713 | } |
704 | |
714 | |
705 | void |
715 | void |
706 | play_again (object *op) |
716 | play_again (object *op) |
707 | { |
717 | { |
708 | op->contr->state = ST_PLAY_AGAIN; |
718 | op->contr->ns->state = ST_PLAY_AGAIN; |
709 | op->chosen_skill = NULL; |
719 | op->chosen_skill = NULL; |
710 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); |
720 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); |
711 | /* a bit of a hack, but there are various places early in th |
721 | /* a bit of a hack, but there are various places early in th |
712 | * player creation process that a user can quit (eg, roll |
722 | * player creation process that a user can quit (eg, roll |
713 | * stats) that isn't removing the player. Taking a quick |
723 | * stats) that isn't removing the player. Taking a quick |
714 | * look, there are many places that call play_again without |
724 | * look, there are many places that call play_again without |
715 | * removing the player - it probably makes more sense |
725 | * removing the player - it probably makes more sense |
716 | * to leave it to play_again to remove the object in all |
726 | * to leave it to play_again to remove the object in all |
717 | * cases. |
727 | * cases. |
718 | */ |
728 | */ |
719 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
729 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
720 | op->remove (); |
730 | op->remove (); |
|
|
731 | |
721 | /* Need to set this to null - otherwise, it could point to garbage, |
732 | /* Need to set this to null - otherwise, it could point to garbage, |
722 | * and draw() doesn't check to see if the player is removed, only if |
733 | * and draw() doesn't check to see if the player is removed, only if |
723 | * the map is null or not swapped out. |
734 | * the map is null or not swapped out. |
724 | */ |
735 | */ |
725 | op->map = NULL; |
736 | op->map = NULL; |
… | |
… | |
763 | void |
774 | void |
764 | confirm_password (object *op) |
775 | confirm_password (object *op) |
765 | { |
776 | { |
766 | |
777 | |
767 | op->contr->write_buf[0] = '\0'; |
778 | op->contr->write_buf[0] = '\0'; |
768 | op->contr->state = ST_CONFIRM_PASSWORD; |
779 | op->contr->ns->state = ST_CONFIRM_PASSWORD; |
769 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); |
780 | send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); |
770 | } |
781 | } |
771 | |
782 | |
772 | void |
783 | void |
773 | get_party_password (object *op, partylist *party) |
784 | get_party_password (object *op, partylist *party) |
774 | { |
785 | { |
… | |
… | |
776 | { |
787 | { |
777 | LOG (llevError, "get_party_password(): tried to make player %s join a NULL party", &op->name); |
788 | LOG (llevError, "get_party_password(): tried to make player %s join a NULL party", &op->name); |
778 | return; |
789 | return; |
779 | } |
790 | } |
780 | op->contr->write_buf[0] = '\0'; |
791 | op->contr->write_buf[0] = '\0'; |
781 | op->contr->state = ST_GET_PARTY_PASSWORD; |
792 | op->contr->ns->state = ST_GET_PARTY_PASSWORD; |
782 | op->contr->party_to_join = party; |
793 | op->contr->party_to_join = party; |
783 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); |
794 | send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "What is the password?\n:"); |
784 | } |
795 | } |
785 | |
796 | |
786 | |
797 | |
787 | /* This rolls four 1-6 rolls and sums the best 3 of the 4. */ |
798 | /* This rolls four 1-6 rolls and sums the best 3 of the 4. */ |
788 | int |
799 | int |
… | |
… | |
885 | |
896 | |
886 | void |
897 | void |
887 | Roll_Again (object *op) |
898 | Roll_Again (object *op) |
888 | { |
899 | { |
889 | esrv_new_player (op->contr, 0); |
900 | esrv_new_player (op->contr, 0); |
890 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, |
901 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, |
891 | "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); |
902 | "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); |
892 | } |
903 | } |
893 | |
904 | |
894 | void |
905 | void |
895 | Swap_Stat (object *op, int Swap_Second) |
906 | Swap_Stat (object *op, int Swap_Second) |
… | |
… | |
962 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
973 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
963 | } |
974 | } |
964 | else |
975 | else |
965 | Swap_Stat (op, stat_trans[keynum]); |
976 | Swap_Stat (op, stat_trans[keynum]); |
966 | |
977 | |
967 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
978 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, ""); |
968 | return 1; |
979 | return 1; |
969 | } |
980 | } |
970 | switch (key) |
981 | switch (key) |
971 | { |
982 | { |
972 | case 'n': |
983 | case 'n': |
… | |
… | |
986 | enter_exit (op, NULL); |
997 | enter_exit (op, NULL); |
987 | #endif |
998 | #endif |
988 | SET_ANIMATION (op, 2); /* So player faces south */ |
999 | SET_ANIMATION (op, 2); /* So player faces south */ |
989 | /* Enter exit adds a player otherwise */ |
1000 | /* Enter exit adds a player otherwise */ |
990 | add_statbonus (op); |
1001 | add_statbonus (op); |
991 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, |
1002 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, |
992 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); |
1003 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); |
993 | op->contr->state = ST_CHANGE_CLASS; |
1004 | op->contr->ns->state = ST_CHANGE_CLASS; |
994 | if (op->msg) |
1005 | if (op->msg) |
995 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1006 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
996 | return 0; |
1007 | return 0; |
997 | } |
1008 | } |
998 | case 'y': |
1009 | case 'y': |
999 | case 'Y': |
1010 | case 'Y': |
1000 | roll_stats (op); |
1011 | roll_stats (op); |
1001 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
1012 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, ""); |
1002 | return 1; |
1013 | return 1; |
1003 | |
1014 | |
1004 | case 'q': |
1015 | case 'q': |
1005 | case 'Q': |
1016 | case 'Q': |
1006 | play_again (op); |
1017 | play_again (op); |
1007 | return 1; |
1018 | return 1; |
1008 | |
1019 | |
1009 | default: |
1020 | default: |
1010 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
1021 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
1011 | return 0; |
1022 | return 0; |
1012 | } |
1023 | } |
1013 | return 0; |
1024 | return 0; |
1014 | } |
1025 | } |
1015 | |
1026 | |
… | |
… | |
1043 | create_treasure (tl, op, 0, 0, 0); |
1054 | create_treasure (tl, op, 0, 0, 0); |
1044 | |
1055 | |
1045 | INVOKE_PLAYER (BIRTH, op->contr); |
1056 | INVOKE_PLAYER (BIRTH, op->contr); |
1046 | INVOKE_PLAYER (LOGIN, op->contr); |
1057 | INVOKE_PLAYER (LOGIN, op->contr); |
1047 | |
1058 | |
1048 | op->contr->state = ST_PLAYING; |
1059 | op->contr->ns->state = ST_PLAYING; |
1049 | |
1060 | |
1050 | if (op->msg) |
1061 | if (op->msg) |
1051 | op->msg = NULL; |
1062 | op->msg = NULL; |
1052 | |
1063 | |
1053 | /* We create this now because some of the unique maps will need it |
1064 | /* We create this now because some of the unique maps will need it |
… | |
… | |
1083 | * if the map isn't there, then stay on the |
1094 | * if the map isn't there, then stay on the |
1084 | * default initial map */ |
1095 | * default initial map */ |
1085 | tmp->destroy (); |
1096 | tmp->destroy (); |
1086 | } |
1097 | } |
1087 | else |
1098 | else |
1088 | { |
|
|
1089 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1099 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1090 | } |
1100 | |
1091 | return 0; |
1101 | return 0; |
1092 | } |
1102 | } |
1093 | |
1103 | |
1094 | /* Following actually changes the race - this is the default command |
1104 | /* Following actually changes the race - this is the default command |
1095 | * if we don't match with one of the options above. |
1105 | * if we don't match with one of the options above. |
… | |
… | |
1125 | op->stats.grace = 0; |
1135 | op->stats.grace = 0; |
1126 | |
1136 | |
1127 | if (op->msg) |
1137 | if (op->msg) |
1128 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1138 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1129 | |
1139 | |
1130 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); |
1140 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); |
1131 | return 0; |
1141 | return 0; |
1132 | } |
1142 | } |
1133 | |
1143 | |
1134 | int |
1144 | int |
1135 | key_confirm_quit (object *op, char key) |
1145 | key_confirm_quit (object *op, char key) |
1136 | { |
1146 | { |
1137 | char buf[MAX_BUF]; |
1147 | char buf[MAX_BUF]; |
1138 | |
1148 | |
1139 | if (key != 'y' && key != 'Y' && key != 'q' && key != 'Q') |
1149 | if (key != 'y' && key != 'Y' && key != 'q' && key != 'Q') |
1140 | { |
1150 | { |
1141 | op->contr->state = ST_PLAYING; |
1151 | op->contr->ns->state = ST_PLAYING; |
1142 | new_draw_info (NDI_UNIQUE, 0, op, "OK, continuing to play."); |
1152 | new_draw_info (NDI_UNIQUE, 0, op, "OK, continuing to play."); |
1143 | return 1; |
1153 | return 1; |
1144 | } |
1154 | } |
1145 | |
1155 | |
1146 | INVOKE_PLAYER (LOGOUT, op->contr); |
1156 | INVOKE_PLAYER (LOGOUT, op->contr); |
… | |
… | |
1215 | { |
1225 | { |
1216 | op->enemy = NULL; |
1226 | op->enemy = NULL; |
1217 | CLEAR_FLAG (op, FLAG_SCARED); |
1227 | CLEAR_FLAG (op, FLAG_SCARED); |
1218 | return; |
1228 | return; |
1219 | } |
1229 | } |
|
|
1230 | |
1220 | get_rangevector (op, op->enemy, &rv, 0); |
1231 | get_rangevector (op, op->enemy, &rv, 0); |
1221 | |
1232 | |
1222 | dir = absdir (4 + rv.direction); |
1233 | dir = absdir (4 + rv.direction); |
1223 | for (diff = 0; diff < 3; diff++) |
1234 | for (diff = 0; diff < 3; diff++) |
1224 | { |
1235 | { |
1225 | int m = 1 - (RANDOM () & 2); |
1236 | int m = 1 - (RANDOM () & 2); |
1226 | |
1237 | |
1227 | if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) |
1238 | if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) |
1228 | { |
|
|
1229 | return; |
1239 | return; |
1230 | } |
|
|
1231 | } |
1240 | } |
|
|
1241 | |
1232 | /* Cornered, get rid of scared */ |
1242 | /* Cornered, get rid of scared */ |
1233 | CLEAR_FLAG (op, FLAG_SCARED); |
1243 | CLEAR_FLAG (op, FLAG_SCARED); |
1234 | op->enemy = NULL; |
1244 | op->enemy = NULL; |
1235 | } |
1245 | } |
1236 | |
1246 | |
… | |
… | |
1792 | if (!dir) |
1802 | if (!dir) |
1793 | { |
1803 | { |
1794 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1804 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1795 | return 0; |
1805 | return 0; |
1796 | } |
1806 | } |
|
|
1807 | |
1797 | if (op->type == PLAYER) |
1808 | if (op->type == PLAYER) |
1798 | bow = op->contr->ranges[range_bow]; |
1809 | bow = op->contr->ranges[range_bow]; |
1799 | else |
1810 | else |
1800 | { |
1811 | { |
1801 | for (bow = op->inv; bow; bow = bow->below) |
1812 | for (bow = op->inv; bow; bow = bow->below) |
… | |
… | |
1809 | { |
1820 | { |
1810 | LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); |
1821 | LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); |
1811 | return 0; |
1822 | return 0; |
1812 | } |
1823 | } |
1813 | } |
1824 | } |
|
|
1825 | |
1814 | if (!bow->race || !bow->skill) |
1826 | if (!bow->race || !bow->skill) |
1815 | { |
1827 | { |
1816 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1828 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1817 | return 0; |
1829 | return 0; |
1818 | } |
1830 | } |
… | |
… | |
1820 | bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; |
1832 | bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; |
1821 | |
1833 | |
1822 | /* penalize ROF for bestarrow */ |
1834 | /* penalize ROF for bestarrow */ |
1823 | if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) |
1835 | if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) |
1824 | bowspeed -= dex_bonus[op->stats.Dex] + 5; |
1836 | bowspeed -= dex_bonus[op->stats.Dex] + 5; |
|
|
1837 | |
1825 | if (bowspeed < 1) |
1838 | if (bowspeed < 1) |
1826 | bowspeed = 1; |
1839 | bowspeed = 1; |
1827 | |
1840 | |
1828 | if (arrow == NULL) |
1841 | if (arrow == NULL) |
1829 | { |
1842 | { |
… | |
… | |
1835 | else |
1848 | else |
1836 | CLEAR_FLAG (op, FLAG_READY_BOW); |
1849 | CLEAR_FLAG (op, FLAG_READY_BOW); |
1837 | return 0; |
1850 | return 0; |
1838 | } |
1851 | } |
1839 | } |
1852 | } |
|
|
1853 | |
1840 | mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy); |
1854 | mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy); |
1841 | if (mflags & P_OUT_OF_MAP) |
1855 | if (mflags & P_OUT_OF_MAP) |
1842 | { |
|
|
1843 | return 0; |
1856 | return 0; |
1844 | } |
1857 | |
1845 | if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW) |
1858 | if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW) |
1846 | { |
1859 | { |
1847 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1860 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1848 | return 0; |
1861 | return 0; |
1849 | } |
1862 | } |
… | |
… | |
1855 | return 0; |
1868 | return 0; |
1856 | } |
1869 | } |
1857 | |
1870 | |
1858 | left = arrow; /* these are arrows left to the player */ |
1871 | left = arrow; /* these are arrows left to the player */ |
1859 | arrow = get_split_ob (arrow, 1); |
1872 | arrow = get_split_ob (arrow, 1); |
1860 | if (arrow == NULL) |
1873 | if (!arrow) |
1861 | { |
1874 | { |
1862 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1875 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1863 | return 0; |
1876 | return 0; |
1864 | } |
1877 | } |
|
|
1878 | |
1865 | arrow->set_owner (op); |
1879 | arrow->set_owner (op); |
1866 | arrow->skill = bow->skill; |
1880 | arrow->skill = bow->skill; |
1867 | |
1881 | |
1868 | arrow->direction = dir; |
1882 | arrow->direction = dir; |
1869 | arrow->x = sx; |
1883 | arrow->x = sx; |
… | |
… | |
1912 | } |
1926 | } |
1913 | |
1927 | |
1914 | if (arrow->attacktype == AT_PHYSICAL) |
1928 | if (arrow->attacktype == AT_PHYSICAL) |
1915 | arrow->attacktype |= bow->attacktype; |
1929 | arrow->attacktype |= bow->attacktype; |
1916 | |
1930 | |
1917 | if (bow->slaying != NULL) |
1931 | if (bow->slaying) |
1918 | arrow->slaying = bow->slaying; |
1932 | arrow->slaying = bow->slaying; |
1919 | |
1933 | |
1920 | arrow->map = m; |
1934 | arrow->map = m; |
1921 | arrow->move_type = MOVE_FLY_LOW; |
1935 | arrow->move_type = MOVE_FLY_LOW; |
1922 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1936 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
… | |
… | |
2038 | CLEAR_FLAG (item, FLAG_ANIMATE); |
2052 | CLEAR_FLAG (item, FLAG_ANIMATE); |
2039 | item->face = item->arch->clone.face; |
2053 | item->face = item->arch->clone.face; |
2040 | item->speed = 0; |
2054 | item->speed = 0; |
2041 | update_ob_speed (item); |
2055 | update_ob_speed (item); |
2042 | } |
2056 | } |
2043 | if ((tmp = is_player_inv (item))) |
2057 | if ((tmp = item->in_player ())) |
2044 | esrv_update_item (UPD_ANIM, tmp, item); |
2058 | esrv_update_item (UPD_ANIM, tmp, item); |
2045 | } |
2059 | } |
2046 | } |
2060 | } |
2047 | else if (item->type == ROD || item->type == HORN) |
2061 | else if (item->type == ROD || item->type == HORN) |
2048 | { |
2062 | { |
… | |
… | |
2198 | * 0 otherwise |
2212 | * 0 otherwise |
2199 | */ |
2213 | */ |
2200 | static int |
2214 | static int |
2201 | player_attack_door (object *op, object *door) |
2215 | player_attack_door (object *op, object *door) |
2202 | { |
2216 | { |
2203 | |
|
|
2204 | /* If its a door, try to find a use a key. If we do destroy the door, |
2217 | /* If its a door, try to find a use a key. If we do destroy the door, |
2205 | * might as well return immediately as there is nothing more to do - |
2218 | * might as well return immediately as there is nothing more to do - |
2206 | * otherwise, we fall through to the rest of the code. |
2219 | * otherwise, we fall through to the rest of the code. |
2207 | */ |
2220 | */ |
2208 | object *key = find_key (op, op, door); |
2221 | object *key = find_key (op, op, door); |
… | |
… | |
2246 | * It should keep the code cleaner. |
2259 | * It should keep the code cleaner. |
2247 | * When this is called, the players direction has been updated |
2260 | * When this is called, the players direction has been updated |
2248 | * (taking into account confusion.) The player is also actually |
2261 | * (taking into account confusion.) The player is also actually |
2249 | * going to try and move (not fire weapons). |
2262 | * going to try and move (not fire weapons). |
2250 | */ |
2263 | */ |
2251 | |
|
|
2252 | void |
2264 | void |
2253 | move_player_attack (object *op, int dir) |
2265 | move_player_attack (object *op, int dir) |
2254 | { |
2266 | { |
2255 | object *tmp, *mon; |
2267 | object *tmp, *mon; |
2256 | sint16 nx, ny; |
2268 | sint16 nx, ny; |
… | |
… | |
2258 | maptile *m; |
2270 | maptile *m; |
2259 | |
2271 | |
2260 | nx = freearr_x[dir] + op->x; |
2272 | nx = freearr_x[dir] + op->x; |
2261 | ny = freearr_y[dir] + op->y; |
2273 | ny = freearr_y[dir] + op->y; |
2262 | |
2274 | |
2263 | on_battleground = op_on_battleground (op, NULL, NULL); |
2275 | on_battleground = op_on_battleground (op, 0, 0); |
2264 | |
2276 | |
2265 | /* If braced, or can't move to the square, and it is not out of the |
2277 | /* If braced, or can't move to the square, and it is not out of the |
2266 | * map, attack it. Note order of if statement is important - don't |
2278 | * map, attack it. Note order of if statement is important - don't |
2267 | * want to be calling move_ob if braced, because move_ob will move the |
2279 | * want to be calling move_ob if braced, because move_ob will move the |
2268 | * player. This is a pretty nasty hack, because if we could |
2280 | * player. This is a pretty nasty hack, because if we could |
… | |
… | |
2280 | return; /* Don't think this should happen */ |
2292 | return; /* Don't think this should happen */ |
2281 | } |
2293 | } |
2282 | else |
2294 | else |
2283 | m = op->map; |
2295 | m = op->map; |
2284 | |
2296 | |
2285 | if ((tmp = get_map_ob (m, nx, ny)) == NULL) |
2297 | if ((tmp = GET_MAP_OB (m, nx, ny)) == NULL) |
2286 | { |
2298 | { |
2287 | /* LOG(llevError,"player_move_attack: get_map_ob returns NULL, but player can not more there.\n"); */ |
2299 | /* LOG(llevError,"player_move_attack: GET_MAP_OB returns NULL, but player can not move there.\n"); */ |
2288 | return; |
2300 | return; |
2289 | } |
2301 | } |
2290 | |
2302 | |
2291 | mon = NULL; |
2303 | mon = 0; |
2292 | /* Go through all the objects, and find ones of interest. Only stop if |
2304 | /* Go through all the objects, and find ones of interest. Only stop if |
2293 | * we find a monster - that is something we know we want to attack. |
2305 | * we find a monster - that is something we know we want to attack. |
2294 | * if its a door or barrel (can roll) see if there may be monsters |
2306 | * if its a door or barrel (can roll) see if there may be monsters |
2295 | * on the space |
2307 | * on the space |
2296 | */ |
2308 | */ |
2297 | while (tmp != NULL) |
2309 | while (tmp) |
2298 | { |
2310 | { |
2299 | if (tmp == op) |
2311 | if (tmp == op) |
2300 | { |
2312 | { |
2301 | tmp = tmp->above; |
2313 | tmp = tmp->above; |
2302 | continue; |
2314 | continue; |
… | |
… | |
2312 | mon = tmp; |
2324 | mon = tmp; |
2313 | |
2325 | |
2314 | tmp = tmp->above; |
2326 | tmp = tmp->above; |
2315 | } |
2327 | } |
2316 | |
2328 | |
2317 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2329 | if (!mon) /* This happens anytime the player tries to move */ |
2318 | return; /* into a wall */ |
2330 | return; /* into a wall */ |
2319 | |
2331 | |
2320 | if (mon->head != NULL) |
2332 | if (mon->head) |
2321 | mon = mon->head; |
2333 | mon = mon->head; |
2322 | |
2334 | |
2323 | if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR)) |
2335 | if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR)) |
2324 | if (player_attack_door (op, mon)) |
2336 | if (player_attack_door (op, mon)) |
2325 | return; |
2337 | return; |
… | |
… | |
2362 | * attack them either. |
2374 | * attack them either. |
2363 | */ |
2375 | */ |
2364 | if ((mon->type == PLAYER || mon->enemy != op) && |
2376 | if ((mon->type == PLAYER || mon->enemy != op) && |
2365 | (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( |
2377 | (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( |
2366 | #ifdef PROHIBIT_PLAYERKILL |
2378 | #ifdef PROHIBIT_PLAYERKILL |
2367 | (op->contr->peaceful |
2379 | (op->contr->peaceful |
2368 | || (mon->type == PLAYER |
2380 | || (mon->type == PLAYER |
2369 | && mon->contr-> |
2381 | && mon->contr-> |
2370 | peaceful)) && |
2382 | peaceful)) && |
2371 | #else |
2383 | #else |
2372 | op->contr->peaceful && |
2384 | op->contr->peaceful && |
2373 | #endif |
2385 | #endif |
2374 | !on_battleground)) |
2386 | !on_battleground)) |
2375 | { |
2387 | { |
2376 | if (!op->contr->braced) |
2388 | if (!op->contr->braced) |
2377 | { |
2389 | { |
2378 | play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2390 | play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2379 | (void) push_ob (mon, dir, op); |
2391 | (void) push_ob (mon, dir, op); |
2380 | } |
2392 | } |
2381 | else |
2393 | else |
2382 | { |
|
|
2383 | new_draw_info (0, 0, op, "You withhold your attack"); |
2394 | new_draw_info (0, 0, op, "You withhold your attack"); |
2384 | } |
2395 | |
2385 | if (op->contr->tmp_invis || op->hide) |
2396 | if (op->contr->tmp_invis || op->hide) |
2386 | make_visible (op); |
2397 | make_visible (op); |
2387 | } |
2398 | } |
2388 | |
2399 | |
2389 | /* If the object is a boulder or other rollable object, then |
2400 | /* If the object is a boulder or other rollable object, then |
… | |
… | |
2417 | op->speed_left += op->speed / op->contr->weapon_sp; |
2428 | op->speed_left += op->speed / op->contr->weapon_sp; |
2418 | |
2429 | |
2419 | op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ |
2430 | op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ |
2420 | } |
2431 | } |
2421 | |
2432 | |
2422 | skill_attack (mon, op, 0, NULL, NULL); |
2433 | skill_attack (mon, op, 0, 0, 0); |
2423 | |
2434 | |
2424 | /* If attacking another player, that player gets automatic |
2435 | /* If attacking another player, that player gets automatic |
2425 | * hitback, and doesn't loose luck either. |
2436 | * hitback, and doesn't loose luck either. |
2426 | * Disable hitback on the battleground or if the target is |
2437 | * Disable hitback on the battleground or if the target is |
2427 | * the wiz. |
2438 | * the wiz. |
… | |
… | |
2429 | if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ)) |
2440 | if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ)) |
2430 | { |
2441 | { |
2431 | short luck = mon->stats.luck; |
2442 | short luck = mon->stats.luck; |
2432 | |
2443 | |
2433 | mon->contr->has_hit = 1; |
2444 | mon->contr->has_hit = 1; |
2434 | skill_attack (op, mon, 0, NULL, NULL); |
2445 | skill_attack (op, mon, 0, 0, 0); |
2435 | mon->stats.luck = luck; |
2446 | mon->stats.luck = luck; |
2436 | } |
2447 | } |
|
|
2448 | |
2437 | if (action_makes_visible (op)) |
2449 | if (action_makes_visible (op)) |
2438 | make_visible (op); |
2450 | make_visible (op); |
2439 | } |
2451 | } |
2440 | } /* if player should attack something */ |
2452 | } /* if player should attack something */ |
2441 | } |
2453 | } |
… | |
… | |
2476 | |
2488 | |
2477 | /* Add special check for newcs players and fire on - this way, the |
2489 | /* Add special check for newcs players and fire on - this way, the |
2478 | * server can handle repeat firing. |
2490 | * server can handle repeat firing. |
2479 | */ |
2491 | */ |
2480 | if (op->contr->fire_on || (op->contr->run_on && pick != 0)) |
2492 | if (op->contr->fire_on || (op->contr->run_on && pick != 0)) |
2481 | { |
|
|
2482 | op->direction = dir; |
2493 | op->direction = dir; |
2483 | } |
|
|
2484 | else |
2494 | else |
2485 | { |
|
|
2486 | op->direction = 0; |
2495 | op->direction = 0; |
2487 | } |
2496 | |
2488 | /* Update how the player looks. Use the facing, so direction may |
2497 | /* Update how the player looks. Use the facing, so direction may |
2489 | * get reset to zero. This allows for full animation capabilities |
2498 | * get reset to zero. This allows for full animation capabilities |
2490 | * for players. |
2499 | * for players. |
2491 | */ |
2500 | */ |
2492 | animate_object (op, op->facing); |
2501 | animate_object (op, op->facing); |
… | |
… | |
2544 | |
2553 | |
2545 | /* call this here - we also will call this in do_ericserver, but |
2554 | /* call this here - we also will call this in do_ericserver, but |
2546 | * the players time has been increased when doericserver has been |
2555 | * the players time has been increased when doericserver has been |
2547 | * called, so we recheck it here. |
2556 | * called, so we recheck it here. |
2548 | */ |
2557 | */ |
2549 | HandleClient (op->contr->socket, op->contr); |
2558 | //TODO: better than handling 8 commands, use some more intelligent rate-limiting |
|
|
2559 | for (int rep = 8; --rep && op->contr->ns->handle_command (); ) |
|
|
2560 | ; |
|
|
2561 | |
2550 | if (op->speed_left < 0) |
2562 | if (op->speed_left < 0) |
2551 | return 0; |
2563 | return 0; |
2552 | |
2564 | |
2553 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2565 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2554 | { |
2566 | { |
… | |
… | |
2699 | for (i = 0; i < NUM_OUTPUT_BUFS; i++) |
2711 | for (i = 0; i < NUM_OUTPUT_BUFS; i++) |
2700 | if (op->contr->outputs[i].buf != NULL && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2712 | if (op->contr->outputs[i].buf != NULL && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2701 | flush_output_element (op, &op->contr->outputs[i]); |
2713 | flush_output_element (op, &op->contr->outputs[i]); |
2702 | } |
2714 | } |
2703 | |
2715 | |
2704 | if (op->contr->state == ST_PLAYING) |
2716 | if (op->contr->ns->state == ST_PLAYING) |
2705 | { |
2717 | { |
2706 | |
2718 | |
2707 | /* these next three if clauses make it possible to SLOW DOWN |
2719 | /* these next three if clauses make it possible to SLOW DOWN |
2708 | hp/grace/spellpoint regeneration. */ |
2720 | hp/grace/spellpoint regeneration. */ |
2709 | if (op->contr->gen_hp >= 0) |
2721 | if (op->contr->gen_hp >= 0) |
… | |
… | |
2851 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2863 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2852 | op->stats.food--; |
2864 | op->stats.food--; |
2853 | } |
2865 | } |
2854 | } |
2866 | } |
2855 | |
2867 | |
2856 | if (op->contr->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0) |
2868 | if (op->contr->ns->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0) |
2857 | { |
2869 | { |
2858 | object *tmp, *flesh = NULL; |
2870 | object *tmp, *flesh = NULL; |
2859 | |
2871 | |
2860 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2872 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2861 | { |
2873 | { |
… | |
… | |
2883 | } /* end if player is starving */ |
2895 | } /* end if player is starving */ |
2884 | |
2896 | |
2885 | while (op->stats.food < 0 && op->stats.hp > 0) |
2897 | while (op->stats.food < 0 && op->stats.hp > 0) |
2886 | op->stats.food++, op->stats.hp--; |
2898 | op->stats.food++, op->stats.hp--; |
2887 | |
2899 | |
2888 | if (!op->contr->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0)) |
2900 | if (!op->contr->ns->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0)) |
2889 | kill_player (op); |
2901 | kill_player (op); |
2890 | } |
2902 | } |
2891 | |
2903 | |
2892 | |
2904 | |
2893 | |
2905 | |
… | |
… | |
3213 | * at his savebed location, and that can have long lasting |
3225 | * at his savebed location, and that can have long lasting |
3214 | * spell effects. So first see if there is a spell effect |
3226 | * spell effects. So first see if there is a spell effect |
3215 | * on the space that might harm the player. |
3227 | * on the space that might harm the player. |
3216 | */ |
3228 | */ |
3217 | will_kill_again = 0; |
3229 | will_kill_again = 0; |
3218 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3230 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3219 | if (tmp->type == SPELL_EFFECT) |
3231 | if (tmp->type == SPELL_EFFECT) |
3220 | will_kill_again |= tmp->attacktype; |
3232 | will_kill_again |= tmp->attacktype; |
3221 | |
3233 | |
3222 | if (will_kill_again) |
3234 | if (will_kill_again) |
3223 | { |
3235 | { |
… | |
… | |
3320 | } |
3332 | } |
3321 | |
3333 | |
3322 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3334 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3323 | { |
3335 | { |
3324 | next = tmp->below; |
3336 | next = tmp->below; |
3325 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3337 | if (tmp->invisible) |
3326 | continue; |
3338 | continue; |
3327 | tmp->remove (); |
3339 | tmp->remove (); |
3328 | tmp->x = op->x, tmp->y = op->y; |
3340 | tmp->x = op->x, tmp->y = op->y; |
3329 | if (tmp->type == CONTAINER) |
3341 | if (tmp->type == CONTAINER) |
3330 | { /* empty container to ground */ |
3342 | { /* empty container to ground */ |
… | |
… | |
3372 | fix_luck (void) |
3384 | fix_luck (void) |
3373 | { |
3385 | { |
3374 | player *pl; |
3386 | player *pl; |
3375 | |
3387 | |
3376 | for (pl = first_player; pl != NULL; pl = pl->next) |
3388 | for (pl = first_player; pl != NULL; pl = pl->next) |
3377 | if (!pl->ob->contr->state) |
3389 | if (!pl->ob->contr->ns->state) |
3378 | change_luck (pl->ob, 0); |
3390 | change_luck (pl->ob, 0); |
3379 | } |
3391 | } |
3380 | |
3392 | |
3381 | |
3393 | |
3382 | /* cast_dust() - handles op throwing objects of type 'DUST'. |
3394 | /* cast_dust() - handles op throwing objects of type 'DUST'. |
… | |
… | |
3436 | object *tmp = NULL; |
3448 | object *tmp = NULL; |
3437 | |
3449 | |
3438 | if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) |
3450 | if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) |
3439 | return 1; |
3451 | return 1; |
3440 | |
3452 | |
3441 | if (op->type == PLAYER) |
|
|
3442 | for (tmp = op->inv; tmp; tmp = tmp->below) |
|
|
3443 | if (tmp->type == EXPERIENCE && tmp->stats.Wis) |
|
|
3444 | if (QUERY_FLAG (tmp, FLAG_UNDEAD)) |
|
|
3445 | return 1; |
|
|
3446 | return 0; |
3453 | return 0; |
3447 | } |
3454 | } |
3448 | |
3455 | |
3449 | /* look at the surrounding terrain to determine |
3456 | /* look at the surrounding terrain to determine |
3450 | * the hideability of this object. Positive levels |
3457 | * the hideability of this object. Positive levels |
… | |
… | |
3565 | if (mflags & P_OUT_OF_MAP) |
3572 | if (mflags & P_OUT_OF_MAP) |
3566 | continue; |
3573 | continue; |
3567 | if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) |
3574 | if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) |
3568 | continue; |
3575 | continue; |
3569 | |
3576 | |
3570 | for (tmp = get_map_ob (m, x, y); tmp; tmp = tmp->above) |
3577 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
3571 | { |
3578 | { |
3572 | if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) |
3579 | if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) |
3573 | return 1; |
3580 | return 1; |
3574 | else if (tmp->type == PLAYER) |
3581 | else if (tmp->type == PLAYER) |
3575 | { |
3582 | { |
… | |
… | |
3629 | |
3636 | |
3630 | /* only the viewable area the player sees is updated by LOS |
3637 | /* only the viewable area the player sees is updated by LOS |
3631 | * code, so we need to restrict ourselves to that range of values |
3638 | * code, so we need to restrict ourselves to that range of values |
3632 | * for any meaningful values. |
3639 | * for any meaningful values. |
3633 | */ |
3640 | */ |
3634 | if (FABS (dx) <= (pl->contr->socket->mapx / 2) && |
3641 | if (FABS (dx) <= (pl->contr->ns->mapx / 2) && |
3635 | FABS (dy) <= (pl->contr->socket->mapy / 2) && |
3642 | FABS (dy) <= (pl->contr->ns->mapy / 2) && |
3636 | !pl->contr->blocked_los[dx + (pl->contr->socket->mapx / 2)][dy + (pl->contr->socket->mapy / 2)]) |
3643 | !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)]) |
3637 | return 1; |
3644 | return 1; |
3638 | op = op->more; |
3645 | op = op->more; |
3639 | } |
3646 | } |
3640 | return 0; |
3647 | return 0; |
3641 | } |
3648 | } |
… | |
… | |
3827 | { |
3834 | { |
3828 | /* forces in the treasurelist can alter the player's stats */ |
3835 | /* forces in the treasurelist can alter the player's stats */ |
3829 | object *skin; |
3836 | object *skin; |
3830 | |
3837 | |
3831 | /* first get the dragon skin force */ |
3838 | /* first get the dragon skin force */ |
|
|
3839 | shstr_cmp dragon_skin_force ("dragon_skin_force"); |
3832 | for (skin = who->inv; skin != NULL && strcmp (skin->arch->name, "dragon_skin_force") != 0; skin = skin->below); |
3840 | for (skin = who->inv; skin && !(skin->arch->name == dragon_skin_force); skin = skin->below) |
|
|
3841 | ; |
|
|
3842 | |
3833 | if (skin == NULL) |
3843 | if (!skin) |
3834 | return; |
3844 | return; |
3835 | |
3845 | |
3836 | /* adding new spellpath attunements */ |
3846 | /* adding new spellpath attunements */ |
3837 | if (item->path_attuned > 0 && !(skin->path_attuned & item->path_attuned)) |
3847 | if (item->path_attuned > 0 && !(skin->path_attuned & item->path_attuned)) |
3838 | { |
3848 | { |