… | |
… | |
116 | |
116 | |
117 | news[0] = '\0'; |
117 | news[0] = '\0'; |
118 | subject[0] = '\0'; |
118 | subject[0] = '\0'; |
119 | size = 0; |
119 | size = 0; |
120 | |
120 | |
121 | while (fgets (buf, MAX_BUF, fp) != NULL) |
121 | while (fgets (buf, MAX_BUF, fp)) |
122 | { |
122 | { |
123 | if (*buf == '#') |
123 | if (*buf == '#') |
124 | continue; |
124 | continue; |
125 | |
125 | |
126 | if (*buf == '%') |
126 | if (*buf == '%') |
127 | { /* send one news */ |
127 | { /* send one news */ |
128 | if (size > 0) |
128 | if (size > 0) |
129 | 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 */ |
129 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", (char *)"%s\n%s", subject, news); /*send previously read news */ |
130 | |
130 | |
131 | strcpy (subject, buf + 1); |
131 | strcpy (subject, buf + 1); |
132 | strip_endline (subject); |
132 | strip_endline (subject); |
133 | size = 0; |
133 | size = 0; |
134 | news[0] = '\0'; |
134 | news[0] = '\0'; |
… | |
… | |
144 | size += strlen (buf); |
144 | size += strlen (buf); |
145 | } |
145 | } |
146 | } |
146 | } |
147 | |
147 | |
148 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, |
148 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, |
149 | MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s\n", "%s\n%s", subject, news); |
149 | MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s\n", (char *)"%s\n%s", subject, news); |
150 | close_and_delete (fp, comp); |
150 | close_and_delete (fp, comp); |
151 | } |
151 | } |
152 | |
152 | |
153 | /* This loads the first map an puts the player on it. */ |
153 | /* This loads the first map an puts the player on it. */ |
154 | static void |
154 | static void |
… | |
… | |
194 | return; |
194 | return; |
195 | |
195 | |
196 | terminate_all_pets (ob); |
196 | terminate_all_pets (ob); |
197 | remove_friendly_object (ob); |
197 | remove_friendly_object (ob); |
198 | ob->deactivate_recursive (); |
198 | ob->deactivate_recursive (); |
|
|
199 | |
|
|
200 | if (ob->map) |
|
|
201 | maplevel = ob->map->path; |
|
|
202 | |
199 | ob->remove (); |
203 | ob->remove (); |
200 | ob->map = 0; |
204 | ob->map = 0; |
|
|
205 | party = 0; |
201 | |
206 | |
202 | // for weird reasons, this is often "ob", keeping a circular reference |
207 | // for weird reasons, this is often "ob", keeping a circular reference |
203 | ranges [range_skill] = 0; |
208 | ranges [range_skill] = 0; |
204 | |
209 | |
205 | players.erase (this); |
210 | players.erase (this); |
… | |
… | |
211 | player::connect (client *ns) |
216 | player::connect (client *ns) |
212 | { |
217 | { |
213 | this->ns = ns; |
218 | this->ns = ns; |
214 | ns->pl = this; |
219 | ns->pl = this; |
215 | |
220 | |
|
|
221 | run_on = 0; |
|
|
222 | fire_on = 0; |
|
|
223 | ob->close_container (); //TODO: client-specific |
|
|
224 | |
216 | ns->update_look = 0; |
225 | ns->update_look = 0; |
217 | ns->look_position = 0; |
226 | ns->look_position = 0; |
218 | |
227 | |
219 | clear_los (ob); |
228 | clear_los (ob); |
220 | |
229 | |
221 | //TODO: must move into client |
230 | ns->reset_stats (); |
222 | /* we need to clear these to -1 and not zero - otherwise, |
|
|
223 | * if a player quits and starts a new character, we wont |
|
|
224 | * send new values to the client, as things like exp start |
|
|
225 | * at zero. |
|
|
226 | */ |
|
|
227 | for (int i = 0; i < NUM_SKILLS; i++) |
|
|
228 | last_skill_exp[i] = -1; |
|
|
229 | |
|
|
230 | for (int i = 0; i < NROFATTACKS; i++) |
|
|
231 | last_resist[i] = -1; |
|
|
232 | |
|
|
233 | last_weapon_sp = -1; |
|
|
234 | last_level = -1; |
|
|
235 | last_stats.exp = -1; |
|
|
236 | last_weight = (uint32) - 1; |
|
|
237 | last_flags = 0; |
|
|
238 | last_weight = 0; |
|
|
239 | last_weight_limit = 0; |
|
|
240 | last_path_attuned = 0; |
|
|
241 | last_path_repelled = 0; |
|
|
242 | last_path_denied = 0; |
|
|
243 | last_speed = 0; |
|
|
244 | run_on = 0; |
|
|
245 | fire_on = 0; |
|
|
246 | memset (&last_stats, 0, sizeof (living)); //TODO dirty |
|
|
247 | |
231 | |
248 | /* make sure he's a player -- needed because of class change. */ |
232 | /* make sure he's a player -- needed because of class change. */ |
249 | ob->type = PLAYER; // we are paranoid |
233 | ob->type = PLAYER; // we are paranoid |
250 | ob->race = ob->arch->clone.race; |
234 | ob->race = ob->arch->clone.race; |
251 | |
235 | |
… | |
… | |
256 | link_player_skills (ob); |
240 | link_player_skills (ob); |
257 | |
241 | |
258 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
242 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
259 | |
243 | |
260 | assign (title, ob->arch->clone.name); |
244 | assign (title, ob->arch->clone.name); |
261 | |
|
|
262 | /* can_use_shield is a new flag. However, the can_use.. seems to largely come |
|
|
263 | * from the class, and not race. I don't see any way to get the class information |
|
|
264 | * to then update this. I don't think this will actually break anything - anyone |
|
|
265 | * that can use armour should be able to use a shield. What this may 'break' |
|
|
266 | * are features new characters get, eg, if someone starts up with a Q, they |
|
|
267 | * should be able to use a shield. However, old Q's won't get that advantage. |
|
|
268 | */ |
|
|
269 | if (QUERY_FLAG (ob, FLAG_USE_ARMOUR)) |
|
|
270 | SET_FLAG (ob, FLAG_USE_SHIELD); |
|
|
271 | |
245 | |
272 | /* if it's a dragon player, set the correct title here */ |
246 | /* if it's a dragon player, set the correct title here */ |
273 | if (is_dragon_pl (ob)) |
247 | if (is_dragon_pl (ob)) |
274 | { |
248 | { |
275 | object *tmp, *abil = 0, *skin = 0; |
249 | object *tmp, *abil = 0, *skin = 0; |
… | |
… | |
315 | if (active) |
289 | if (active) |
316 | INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); |
290 | INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); |
317 | |
291 | |
318 | INVOKE_PLAYER (DISCONNECT, this); |
292 | INVOKE_PLAYER (DISCONNECT, this); |
319 | |
293 | |
|
|
294 | ns->reset_stats (); |
320 | ns->pl = 0; |
295 | ns->pl = 0; |
321 | this->ns = 0; |
296 | this->ns = 0; |
322 | } |
297 | } |
|
|
298 | |
|
|
299 | if (ob) |
|
|
300 | ob->close_container (); //TODO: client-specific |
323 | |
301 | |
324 | deactivate (); |
302 | deactivate (); |
325 | } |
303 | } |
326 | |
304 | |
327 | // the need for this function can be explained |
305 | // the need for this function can be explained |
328 | // by load_object not returning the object |
306 | // by load_object not returning the object |
329 | void |
307 | void |
330 | player::set_object (object *op) |
308 | player::set_object (object *op) |
331 | { |
309 | { |
332 | ob = op; |
310 | ob = op; |
333 | ob->contr = this; /* this aren't yet in archetype */ |
311 | ob->contr = this; /* this aren't yet in archetype */ |
334 | |
312 | |
335 | ob->speed_left = 0.5; |
313 | ob->speed_left = 0.5; |
336 | ob->speed = 1.0; |
314 | ob->speed = 1.0; |
337 | ob->direction = 5; /* So player faces south */ |
315 | ob->direction = 5; /* So player faces south */ |
338 | ob->stats.wc = 2; |
|
|
339 | ob->run_away = 25; /* Then we panick... */ |
|
|
340 | |
|
|
341 | ob->roll_stats (); |
|
|
342 | } |
316 | } |
343 | |
317 | |
344 | player::player () |
318 | player::player () |
345 | { |
319 | { |
346 | /* There are some elements we want initialised to non zero value - |
320 | /* There are some elements we want initialised to non zero value - |
347 | * we deal with that below this point. |
321 | * we deal with that below this point. |
348 | */ |
322 | */ |
349 | outputs_sync = 16; /* Every 2 seconds */ |
323 | outputs_sync = 6; /* Every 2 seconds */ |
350 | outputs_count = 8; /* Keeps present behaviour */ |
324 | outputs_count = 10; /* Keeps present behaviour */ |
351 | unapply = unapply_nochoice; |
325 | unapply = unapply_nochoice; |
352 | |
326 | |
353 | savebed_map = first_map_path; /* Init. respawn position */ |
327 | savebed_map = first_map_path; /* Init. respawn position */ |
354 | |
328 | |
355 | gen_sp_armour = 10; |
329 | gen_sp_armour = 10; |
… | |
… | |
390 | player::create () |
364 | player::create () |
391 | { |
365 | { |
392 | player *pl = new player; |
366 | player *pl = new player; |
393 | |
367 | |
394 | pl->set_object (arch_to_object (get_player_archetype (0))); |
368 | pl->set_object (arch_to_object (get_player_archetype (0))); |
|
|
369 | |
|
|
370 | pl->ob->roll_stats (); |
|
|
371 | pl->ob->stats.wc = 2; |
|
|
372 | pl->ob->run_away = 25; /* Then we panick... */ |
|
|
373 | |
395 | set_first_map (pl->ob); |
374 | set_first_map (pl->ob); |
396 | |
375 | |
397 | return pl; |
376 | return pl; |
398 | } |
377 | } |
399 | |
378 | |
… | |
… | |
545 | x = mon->x; |
524 | x = mon->x; |
546 | y = mon->y; |
525 | y = mon->y; |
547 | m = mon->map; |
526 | m = mon->map; |
548 | dir = rv.direction; |
527 | dir = rv.direction; |
549 | lastdir = firstdir = rv.direction; /* perhaps we stand next to pl, init firstdir too */ |
528 | lastdir = firstdir = rv.direction; /* perhaps we stand next to pl, init firstdir too */ |
550 | diff = FABS (rv.distance_x) > FABS (rv.distance_y) ? FABS (rv.distance_x) : FABS (rv.distance_y); |
529 | diff = ::max (abs (rv.distance_x), abs (rv.distance_y)); |
|
|
530 | |
551 | /* If we can't solve it within the search distance, return now. */ |
531 | /* If we can't solve it within the search distance, return now. */ |
552 | if (diff > max) |
532 | if (diff > max) |
553 | return 0; |
533 | return 0; |
|
|
534 | |
554 | while (diff > 1 && max > 0) |
535 | while (diff > 1 && max > 0) |
555 | { |
536 | { |
556 | lastx = x; |
537 | lastx = x; |
557 | lasty = y; |
538 | lasty = y; |
558 | lastmap = m; |
539 | lastmap = m; |
… | |
… | |
640 | max--; |
621 | max--; |
641 | lastdir = dir; |
622 | lastdir = dir; |
642 | if (!firstdir) |
623 | if (!firstdir) |
643 | firstdir = dir; |
624 | firstdir = dir; |
644 | } |
625 | } |
|
|
626 | |
645 | if (diff <= 1) |
627 | if (diff <= 1) |
646 | { |
628 | { |
647 | /* Recalculate diff (distance) because we may not have actually |
629 | /* Recalculate diff (distance) because we may not have actually |
648 | * headed toward player for entire distance. |
630 | * headed toward player for entire distance. |
649 | */ |
631 | */ |
650 | get_rangevector_from_mapcoord (m, x, y, pl, &rv, 0); |
632 | get_rangevector_from_mapcoord (m, x, y, pl, &rv, 0); |
651 | diff = FABS (rv.distance_x) > FABS (rv.distance_y) ? FABS (rv.distance_x) : FABS (rv.distance_y); |
633 | diff = ::max (abs (rv.distance_x), abs (rv.distance_y)); |
652 | } |
634 | } |
|
|
635 | |
653 | if (diff > max) |
636 | if (diff > max) |
654 | return 0; |
637 | return 0; |
655 | } |
638 | } |
|
|
639 | |
656 | /* If we reached the max, didn't find a direction in time */ |
640 | /* If we reached the max, didn't find a direction in time */ |
657 | if (!max) |
641 | if (!max) |
658 | return 0; |
642 | return 0; |
659 | |
643 | |
660 | return firstdir; |
644 | return firstdir; |
… | |
… | |
774 | roll_stat (void) |
758 | roll_stat (void) |
775 | { |
759 | { |
776 | int a[4], i, j, k; |
760 | int a[4], i, j, k; |
777 | |
761 | |
778 | for (i = 0; i < 4; i++) |
762 | for (i = 0; i < 4; i++) |
779 | a[i] = (int) RANDOM () % 6 + 1; |
763 | a[i] = (int) rndm (6) + 1; |
780 | |
764 | |
781 | for (i = 0, j = 0, k = 7; i < 4; i++) |
765 | for (i = 0, j = 0, k = 7; i < 4; i++) |
782 | if (a[i] < k) |
766 | if (a[i] < k) |
783 | k = a[i], j = i; |
767 | k = a[i], j = i; |
784 | |
768 | |
… | |
… | |
884 | * appropriate action with it (change race, or other things). |
868 | * appropriate action with it (change race, or other things). |
885 | * The function name is for historical reasons - now we have |
869 | * The function name is for historical reasons - now we have |
886 | * separate race and class; this actually changes the RACE, |
870 | * separate race and class; this actually changes the RACE, |
887 | * not the class. |
871 | * not the class. |
888 | */ |
872 | */ |
889 | int |
873 | void |
890 | key_change_class (object *op, char key) |
874 | player::chargen_race_done () |
891 | { |
875 | { |
892 | int tmp_loop; |
|
|
893 | |
|
|
894 | if (key == 'd' || key == 'D') |
|
|
895 | { |
|
|
896 | char buf[MAX_BUF]; |
|
|
897 | |
|
|
898 | /* this must before then initial items are given */ |
876 | /* this must before then initial items are given */ |
899 | esrv_new_player (op->contr, op->weight + op->carrying); |
877 | esrv_new_player (ob->contr, ob->weight + ob->carrying); |
900 | |
878 | |
901 | treasurelist *tl = find_treasurelist ("starting_wealth"); |
879 | treasurelist *tl = treasurelist::find ("starting_wealth"); |
902 | if (tl) |
880 | if (tl) |
903 | create_treasure (tl, op, 0, 0, 0); |
881 | create_treasure (tl, ob, 0, 0, 0); |
904 | |
882 | |
905 | INVOKE_PLAYER (BIRTH, op->contr); |
883 | INVOKE_PLAYER (BIRTH, ob->contr); |
906 | INVOKE_PLAYER (LOGIN, op->contr); |
884 | INVOKE_PLAYER (LOGIN, ob->contr); |
907 | |
885 | |
908 | op->contr->ns->state = ST_PLAYING; |
886 | ob->contr->ns->state = ST_PLAYING; |
909 | |
887 | |
910 | if (op->msg) |
888 | if (ob->msg) |
911 | op->msg = NULL; |
889 | ob->msg = 0; |
912 | |
890 | |
913 | /* We create this now because some of the unique maps will need it |
891 | /* We create this now because some of the unique maps will need it |
914 | * to save here. |
892 | * to save here. |
915 | */ |
893 | */ |
|
|
894 | { |
|
|
895 | char buf[MAX_BUF]; |
916 | sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &op->name); |
896 | sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &ob->name); |
917 | make_path_to_file (buf); |
897 | make_path_to_file (buf); |
|
|
898 | } |
918 | |
899 | |
919 | #ifdef AUTOSAVE |
|
|
920 | op->contr->last_save_tick = pticks; |
|
|
921 | #endif |
|
|
922 | start_info (op); |
900 | start_info (ob); |
923 | CLEAR_FLAG (op, FLAG_WIZ); |
901 | CLEAR_FLAG (ob, FLAG_WIZ); |
924 | give_initial_items (op, op->randomitems); |
902 | give_initial_items (ob, ob->randomitems); |
925 | link_player_skills (op); |
903 | link_player_skills (ob); |
926 | esrv_send_inventory (op, op); |
904 | esrv_send_inventory (ob, ob); |
927 | op->update_stats (); |
905 | ob->update_stats (); |
928 | |
906 | |
929 | /* This moves the player to a different start map, if there |
907 | /* This moves the player to a different start map, if there |
930 | * is one for this race |
908 | * is one for this race |
931 | */ |
909 | */ |
932 | if (*first_map_ext_path) |
910 | if (*first_map_ext_path) |
933 | { |
911 | { |
934 | object *tmp; |
912 | object *tmp; |
935 | char mapname[MAX_BUF]; |
913 | char mapname[MAX_BUF]; |
936 | |
914 | |
937 | snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &op->arch->name); |
915 | snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &ob->arch->name); |
938 | tmp = object::create (); |
916 | tmp = object::create (); |
939 | EXIT_PATH (tmp) = mapname; |
917 | EXIT_PATH (tmp) = mapname; |
940 | EXIT_X (tmp) = op->x; |
918 | EXIT_X (tmp) = ob->x; |
941 | EXIT_Y (tmp) = op->y; |
919 | EXIT_Y (tmp) = ob->y; |
942 | op->enter_exit (tmp); /* we don't really care if it succeeded; |
920 | ob->enter_exit (tmp); /* we don't really care if it succeeded; |
943 | * if the map isn't there, then stay on the |
921 | * if the map isn't there, then stay on the |
944 | * default initial map */ |
922 | * default initial map */ |
945 | tmp->destroy (); |
923 | tmp->destroy (); |
946 | } |
924 | } |
947 | else |
925 | else |
948 | LOG (llevDebug, "first_map_ext_path not set\n"); |
926 | LOG (llevDebug, "first_map_ext_path not set\n"); |
|
|
927 | } |
949 | |
928 | |
950 | return 0; |
929 | void |
951 | } |
930 | player::chargen_race_next () |
952 | |
931 | { |
953 | /* Following actually changes the race - this is the default command |
932 | /* Following actually changes the race - this is the default command |
954 | * if we don't match with one of the options above. |
933 | * if we don't match with one of the options above. |
955 | */ |
934 | */ |
956 | |
935 | |
957 | tmp_loop = 0; |
936 | do |
958 | while (!tmp_loop) |
|
|
959 | { |
937 | { |
960 | shstr name = op->name; |
938 | shstr name = ob->name; |
961 | int x = op->x, y = op->y; |
939 | int x = ob->x, y = ob->y; |
962 | |
940 | |
963 | op->remove_statbonus (); |
941 | ob->remove_statbonus (); |
964 | op->remove (); |
942 | ob->remove (); |
965 | op->arch = get_player_archetype (op->arch); |
943 | ob->arch = get_player_archetype (ob->arch); |
966 | op->arch->clone.copy_to (op); |
944 | ob->arch->clone.copy_to (ob); |
967 | op->instantiate (); |
945 | ob->instantiate (); |
968 | op->stats = op->contr->orig_stats; |
946 | ob->stats = ob->contr->orig_stats; |
969 | op->name = op->name_pl = name; |
947 | ob->name = ob->name_pl = name; |
970 | op->x = x; |
948 | ob->x = x; |
971 | op->y = y; |
949 | ob->y = y; |
972 | SET_ANIMATION (op, 2); /* So player faces south */ |
950 | SET_ANIMATION (ob, 2); /* So player faces south */ |
973 | insert_ob_in_map (op, op->map, op, 0); |
951 | insert_ob_in_map (ob, ob->map, ob, 0); |
974 | assign (op->contr->title, op->arch->clone.name); |
952 | assign (ob->contr->title, ob->arch->clone.name); |
975 | op->add_statbonus (); |
953 | ob->add_statbonus (); |
976 | tmp_loop = allowed_class (op); |
|
|
977 | } |
954 | } |
|
|
955 | while (!allowed_class (ob)); |
978 | |
956 | |
979 | update_object (op, UP_OBJ_FACE); |
957 | update_object (ob, UP_OBJ_FACE); |
980 | esrv_update_item (UPD_FACE, op, op); |
958 | esrv_update_item (UPD_FACE, ob, ob); |
981 | op->update_stats (); |
959 | ob->update_stats (); |
982 | op->stats.hp = op->stats.maxhp; |
960 | ob->stats.hp = ob->stats.maxhp; |
983 | op->stats.sp = op->stats.maxsp; |
961 | ob->stats.sp = ob->stats.maxsp; |
984 | op->stats.grace = 0; |
962 | ob->stats.grace = 0; |
985 | |
|
|
986 | if (op->msg) |
|
|
987 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
|
|
988 | |
|
|
989 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); |
|
|
990 | return 0; |
|
|
991 | } |
963 | } |
992 | |
964 | |
993 | void |
965 | void |
994 | flee_player (object *op) |
966 | flee_player (object *op) |
995 | { |
967 | { |
… | |
… | |
1052 | int |
1024 | int |
1053 | check_pick (object *op) |
1025 | check_pick (object *op) |
1054 | { |
1026 | { |
1055 | object *tmp, *next; |
1027 | object *tmp, *next; |
1056 | int stop = 0; |
1028 | int stop = 0; |
1057 | int j, k, wvratio; |
1029 | int wvratio; |
1058 | char putstring[128], tmpstr[16]; |
1030 | char putstring[128]; |
1059 | |
1031 | |
1060 | /* if you're flying, you cna't pick up anything */ |
1032 | /* if you're flying, you cna't pick up anything */ |
1061 | if (op->move_type & MOVE_FLYING) |
1033 | if (op->move_type & MOVE_FLYING) |
1062 | return 1; |
1034 | return 1; |
1063 | |
1035 | |
… | |
… | |
1400 | * found object is returned. |
1372 | * found object is returned. |
1401 | */ |
1373 | */ |
1402 | object * |
1374 | object * |
1403 | find_arrow (object *op, const char *type) |
1375 | find_arrow (object *op, const char *type) |
1404 | { |
1376 | { |
1405 | object *tmp = NULL; |
1377 | object *tmp = 0; |
1406 | |
1378 | |
1407 | for (op = op->inv; op; op = op->below) |
1379 | for (op = op->inv; op; op = op->below) |
1408 | if (!tmp && op->type == CONTAINER && op->race == type && QUERY_FLAG (op, FLAG_APPLIED)) |
1380 | if (!tmp && op->type == CONTAINER && op->race == type && QUERY_FLAG (op, FLAG_APPLIED)) |
1409 | tmp = find_arrow (op, type); |
1381 | tmp = find_arrow (op, type); |
1410 | else if (op->type == ARROW && op->race == type) |
1382 | else if (op->type == ARROW && op->race == type) |
1411 | return op; |
1383 | return op; |
|
|
1384 | |
1412 | return tmp; |
1385 | return tmp; |
1413 | } |
1386 | } |
1414 | |
1387 | |
1415 | /* |
1388 | /* |
1416 | * Similar to find_arrow, but looks for (roughly) the best arrow to use |
1389 | * Similar to find_arrow, but looks for (roughly) the best arrow to use |
1417 | * against the target. A full test is not performed, simply a basic test |
1390 | * against the target. A full test is not performed, simply a basic test |
1418 | * of resistances. The archer is making a quick guess at what he sees down |
1391 | * of resistances. The archer is making a quick guess at what he sees down |
1419 | * the hall. Failing that it does it's best to pick the highest plus arrow. |
1392 | * the hall. Failing that it does it's best to pick the highest plus arrow. |
1420 | */ |
1393 | */ |
1421 | |
|
|
1422 | object * |
1394 | object * |
1423 | find_better_arrow (object *op, object *target, const char *type, int *better) |
1395 | find_better_arrow (object *op, object *target, const char *type, int *better) |
1424 | { |
1396 | { |
1425 | object *tmp = NULL, *arrow, *ntmp; |
1397 | object *tmp = NULL, *arrow, *ntmp; |
1426 | int attacknum, attacktype, betterby = 0, i; |
1398 | int attacknum, attacktype, betterby = 0, i; |
… | |
… | |
1858 | case range_misc: |
1830 | case range_misc: |
1859 | fire_misc_object (op, dir); |
1831 | fire_misc_object (op, dir); |
1860 | return; |
1832 | return; |
1861 | |
1833 | |
1862 | case range_golem: /* Control summoned monsters from scrolls */ |
1834 | case range_golem: /* Control summoned monsters from scrolls */ |
1863 | if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
|
|
1864 | { |
|
|
1865 | op->contr->ranges[range_golem] = 0; |
|
|
1866 | op->contr->shoottype = range_none; |
|
|
1867 | } |
|
|
1868 | else |
|
|
1869 | control_golem (op->contr->ranges[range_golem], dir); |
1835 | control_golem (op->contr->ranges[range_golem], dir); |
1870 | return; |
1836 | return; |
1871 | |
1837 | |
1872 | case range_skill: |
1838 | case range_skill: |
1873 | if (!op->chosen_skill) |
1839 | if (!op->chosen_skill) |
1874 | { |
1840 | { |
1875 | if (op->type == PLAYER) |
1841 | if (op->type == PLAYER) |
1876 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
1842 | new_draw_info (NDI_UNIQUE, 0, op, "You have no applicable skill to use."); |
|
|
1843 | |
1877 | return; |
1844 | return; |
1878 | } |
1845 | } |
1879 | |
1846 | |
1880 | do_skill (op, op, op->chosen_skill, dir, NULL); |
1847 | do_skill (op, op, op->chosen_skill, dir, NULL); |
1881 | return; |
1848 | return; |
… | |
… | |
1885 | default: |
1852 | default: |
1886 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
1853 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal shoot type."); |
1887 | return; |
1854 | return; |
1888 | } |
1855 | } |
1889 | } |
1856 | } |
1890 | |
|
|
1891 | |
|
|
1892 | |
1857 | |
1893 | /* find_key |
1858 | /* find_key |
1894 | * We try to find a key for the door as passed. If we find a key |
1859 | * We try to find a key for the door as passed. If we find a key |
1895 | * and successfully use it, we return the key, otherwise NULL |
1860 | * and successfully use it, we return the key, otherwise NULL |
1896 | * This function merges both normal and locked door, since the logic |
1861 | * This function merges both normal and locked door, since the logic |
… | |
… | |
1898 | * pl is the player, |
1863 | * pl is the player, |
1899 | * inv is the objects inventory to searched |
1864 | * inv is the objects inventory to searched |
1900 | * door is the door we are trying to match against. |
1865 | * door is the door we are trying to match against. |
1901 | * This function can be called recursively to search containers. |
1866 | * This function can be called recursively to search containers. |
1902 | */ |
1867 | */ |
1903 | |
|
|
1904 | object * |
1868 | object * |
1905 | find_key (object *pl, object *container, object *door) |
1869 | find_key (object *pl, object *container, object *door) |
1906 | { |
1870 | { |
1907 | object *tmp, *key; |
1871 | object *tmp, *key; |
1908 | |
1872 | |
1909 | /* Should not happen, but sanity checking is never bad */ |
1873 | /* Should not happen, but sanity checking is never bad */ |
1910 | if (container->inv == NULL) |
1874 | if (!container->inv) |
1911 | return NULL; |
1875 | return 0; |
1912 | |
1876 | |
1913 | /* First, lets try to find a key in the top level inventory */ |
1877 | /* First, lets try to find a key in the top level inventory */ |
1914 | for (tmp = container->inv; tmp != NULL; tmp = tmp->below) |
1878 | for (tmp = container->inv; tmp; tmp = tmp->below) |
1915 | { |
1879 | { |
1916 | if (door->type == DOOR && tmp->type == KEY) |
1880 | if (door->type == DOOR && tmp->type == KEY) |
1917 | break; |
1881 | break; |
1918 | /* For sanity, we should really check door type, but other stuff |
1882 | /* For sanity, we should really check door type, but other stuff |
1919 | * (like containers) can be locked with special keys |
1883 | * (like containers) can be locked with special keys |
1920 | */ |
1884 | */ |
1921 | if (tmp->slaying && tmp->type == SPECIAL_KEY && tmp->slaying == door->slaying) |
1885 | if (tmp->slaying && tmp->type == SPECIAL_KEY && tmp->slaying == door->slaying) |
1922 | break; |
1886 | break; |
1923 | } |
1887 | } |
|
|
1888 | |
1924 | /* No key found - lets search inventories now */ |
1889 | /* No key found - lets search inventories now */ |
1925 | /* If we find and use a key in an inventory, return at that time. |
1890 | /* If we find and use a key in an inventory, return at that time. |
1926 | * otherwise, if we search all the inventories and still don't find |
1891 | * otherwise, if we search all the inventories and still don't find |
1927 | * a key, return |
1892 | * a key, return |
1928 | */ |
1893 | */ |
1929 | if (!tmp) |
1894 | if (!tmp) |
1930 | { |
1895 | { |
1931 | for (tmp = container->inv; tmp != NULL; tmp = tmp->below) |
1896 | for (tmp = container->inv; tmp; tmp = tmp->below) |
1932 | { |
1897 | { |
1933 | /* No reason to search empty containers */ |
1898 | /* No reason to search empty containers */ |
1934 | if (tmp->type == CONTAINER && tmp->inv) |
1899 | if (tmp->type == CONTAINER && tmp->inv) |
1935 | { |
1900 | { |
1936 | if ((key = find_key (pl, tmp, door)) != NULL) |
1901 | if ((key = find_key (pl, tmp, door))) |
1937 | return key; |
1902 | return key; |
1938 | } |
1903 | } |
1939 | } |
1904 | } |
|
|
1905 | |
1940 | if (!tmp) |
1906 | if (!tmp) |
1941 | return NULL; |
1907 | return NULL; |
1942 | } |
1908 | } |
|
|
1909 | |
1943 | /* We get down here if we have found a key. Now if its in a container, |
1910 | /* We get down here if we have found a key. Now if its in a container, |
1944 | * see if we actually want to use it |
1911 | * see if we actually want to use it |
1945 | */ |
1912 | */ |
1946 | if (pl != container) |
1913 | if (pl != container) |
1947 | { |
1914 | { |
… | |
… | |
1968 | new_draw_info_format (NDI_UNIQUE | NDI_BROWN, 0, pl, |
1935 | new_draw_info_format (NDI_UNIQUE | NDI_BROWN, 0, pl, |
1969 | "The %s in your %s vibrates as you approach the door", query_name (tmp), query_name (container)); |
1936 | "The %s in your %s vibrates as you approach the door", query_name (tmp), query_name (container)); |
1970 | return NULL; |
1937 | return NULL; |
1971 | } |
1938 | } |
1972 | } |
1939 | } |
|
|
1940 | |
1973 | return tmp; |
1941 | return tmp; |
1974 | } |
1942 | } |
1975 | |
1943 | |
1976 | /* moved door processing out of move_player_attack. |
1944 | /* moved door processing out of move_player_attack. |
1977 | * returns 1 if player has opened the door with a key |
1945 | * returns 1 if player has opened the door with a key |
… | |
… | |
1995 | play_sound_map (op->map, op->x, op->y, SOUND_OPEN_DOOR); |
1963 | play_sound_map (op->map, op->x, op->y, SOUND_OPEN_DOOR); |
1996 | if (action_makes_visible (op)) |
1964 | if (action_makes_visible (op)) |
1997 | make_visible (op); |
1965 | make_visible (op); |
1998 | if (door->inv && (door->inv->type == RUNE || door->inv->type == TRAP)) |
1966 | if (door->inv && (door->inv->type == RUNE || door->inv->type == TRAP)) |
1999 | spring_trap (door->inv, op); |
1967 | spring_trap (door->inv, op); |
|
|
1968 | |
2000 | if (door->type == DOOR) |
1969 | if (door->type == DOOR) |
2001 | { |
|
|
2002 | hit_player (door, 9998, op, AT_PHYSICAL, 1); /* Break through the door */ |
1970 | hit_player (door, 9998, op, AT_PHYSICAL, 1); /* Break through the door */ |
2003 | } |
|
|
2004 | else if (door->type == LOCKED_DOOR) |
1971 | else if (door->type == LOCKED_DOOR) |
2005 | { |
1972 | { |
2006 | new_draw_info_format (NDI_UNIQUE, NDI_BROWN, op, "You open the door with the %s", query_short_name (key)); |
1973 | new_draw_info_format (NDI_UNIQUE, NDI_BROWN, op, "You open the door with the %s", query_short_name (key)); |
2007 | remove_door2 (door); /* remove door without violence ;-) */ |
1974 | remove_door2 (door); /* remove door without violence ;-) */ |
2008 | } |
1975 | } |
|
|
1976 | |
2009 | /* Do this after we print the message */ |
1977 | /* Do this after we print the message */ |
2010 | decrease_ob (key); /* Use up one of the keys */ |
1978 | decrease_ob (key); /* Use up one of the keys */ |
2011 | /* Need to update the weight the container the key was in */ |
1979 | /* Need to update the weight the container the key was in */ |
2012 | if (container != op) |
1980 | if (container != op) |
2013 | esrv_update_item (UPD_WEIGHT, op, container); |
1981 | esrv_update_item (UPD_WEIGHT, op, container); |
|
|
1982 | |
2014 | return 1; /* Nothing more to do below */ |
1983 | return 1; /* Nothing more to do below */ |
2015 | } |
1984 | } |
2016 | else if (door->type == LOCKED_DOOR) |
1985 | else if (door->type == LOCKED_DOOR) |
2017 | { |
1986 | { |
2018 | /* Might as well return now - no other way to open this */ |
1987 | /* Might as well return now - no other way to open this */ |
2019 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, door->msg); |
1988 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, door->msg); |
2020 | return 1; |
1989 | return 1; |
2021 | } |
1990 | } |
|
|
1991 | |
2022 | return 0; |
1992 | return 0; |
2023 | } |
1993 | } |
2024 | |
1994 | |
2025 | /* This function is just part of a breakup from move_player. |
1995 | /* This function is just part of a breakup from move_player. |
2026 | * It should keep the code cleaner. |
1996 | * It should keep the code cleaner. |
… | |
… | |
2232 | return 0; |
2202 | return 0; |
2233 | } |
2203 | } |
2234 | |
2204 | |
2235 | /* peterm: added following line */ |
2205 | /* peterm: added following line */ |
2236 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2206 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2237 | dir = absdir (dir + RANDOM () % 3 + RANDOM () % 3 - 2); |
2207 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2238 | |
2208 | |
2239 | op->facing = dir; |
2209 | op->facing = dir; |
2240 | |
2210 | |
2241 | if (op->hide) |
2211 | if (op->hide) |
2242 | do_hidden_move (op); |
2212 | do_hidden_move (op); |
… | |
… | |
2275 | * Returns true if there are more actions we can do. |
2245 | * Returns true if there are more actions we can do. |
2276 | */ |
2246 | */ |
2277 | int |
2247 | int |
2278 | handle_newcs_player (object *op) |
2248 | handle_newcs_player (object *op) |
2279 | { |
2249 | { |
2280 | if (op->contr->hidden) |
|
|
2281 | { |
|
|
2282 | op->invisible = 1000; |
|
|
2283 | /* the socket code flashes the player visible/invisible |
|
|
2284 | * depending on the value of invisible, so we need to |
|
|
2285 | * alternate it here for it to work correctly. |
|
|
2286 | */ |
|
|
2287 | if (pticks & 2) |
|
|
2288 | op->invisible--; |
|
|
2289 | } |
|
|
2290 | else if (op->invisible && !(QUERY_FLAG (op, FLAG_MAKE_INVIS))) |
|
|
2291 | { |
|
|
2292 | op->invisible--; |
|
|
2293 | if (!op->invisible) |
|
|
2294 | { |
|
|
2295 | make_visible (op); |
|
|
2296 | new_draw_info (NDI_UNIQUE, 0, op, "Your invisibility spell runs out."); |
|
|
2297 | } |
|
|
2298 | } |
|
|
2299 | |
|
|
2300 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2250 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2301 | { |
2251 | { |
2302 | flee_player (op); |
2252 | flee_player (op); |
2303 | /* If player is still scared, that is his action for this tick */ |
2253 | /* If player is still scared, that is his action for this tick */ |
2304 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2254 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2305 | { |
2255 | { |
2306 | op->speed_left--; |
2256 | op->speed_left--; |
2307 | return 0; |
2257 | return 0; |
2308 | } |
2258 | } |
2309 | } |
2259 | } |
2310 | |
|
|
2311 | /* I've been seeing crashes where the golem has been destroyed, but |
|
|
2312 | * the player object still points to the defunct golem. The code that |
|
|
2313 | * destroys the golem looks correct, and it doesn't always happen, so |
|
|
2314 | * put this in a a workaround to clean up the golem pointer. |
|
|
2315 | */ |
|
|
2316 | if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED)) |
|
|
2317 | op->contr->ranges[range_golem] = 0; |
|
|
2318 | |
2260 | |
2319 | /* call this here - we also will call this in do_ericserver, but |
2261 | /* call this here - we also will call this in do_ericserver, but |
2320 | * the players time has been increased when doericserver has been |
2262 | * the players time has been increased when doericserver has been |
2321 | * called, so we recheck it here. |
2263 | * called, so we recheck it here. |
2322 | */ |
2264 | */ |
… | |
… | |
2383 | * from. |
2325 | * from. |
2384 | */ |
2326 | */ |
2385 | void |
2327 | void |
2386 | remove_unpaid_objects (object *op, object *env) |
2328 | remove_unpaid_objects (object *op, object *env) |
2387 | { |
2329 | { |
2388 | object *next; |
|
|
2389 | |
|
|
2390 | while (op) |
2330 | while (op) |
2391 | { |
2331 | { |
2392 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2332 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2393 | |
2333 | |
2394 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2334 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
… | |
… | |
2460 | int rate_grace = 2000; |
2400 | int rate_grace = 2000; |
2461 | const int max_hp = 1; |
2401 | const int max_hp = 1; |
2462 | const int max_sp = 1; |
2402 | const int max_sp = 1; |
2463 | const int max_grace = 1; |
2403 | const int max_grace = 1; |
2464 | |
2404 | |
|
|
2405 | if (op->contr->hidden) |
|
|
2406 | { |
|
|
2407 | op->invisible = 1000; |
|
|
2408 | /* the socket code flashes the player visible/invisible |
|
|
2409 | * depending on the value of invisible, so we need to |
|
|
2410 | * alternate it here for it to work correctly. |
|
|
2411 | */ |
|
|
2412 | if (pticks & 2) |
|
|
2413 | op->invisible--; |
|
|
2414 | } |
|
|
2415 | else if (op->invisible && !(QUERY_FLAG (op, FLAG_MAKE_INVIS))) |
|
|
2416 | { |
|
|
2417 | if (!op->invisible--) |
|
|
2418 | { |
|
|
2419 | make_visible (op); |
|
|
2420 | new_draw_info (NDI_UNIQUE, 0, op, "Your invisibility spell runs out."); |
|
|
2421 | } |
|
|
2422 | } |
|
|
2423 | |
2465 | if (op->contr->outputs_sync) |
2424 | if (op->contr->outputs_sync) |
2466 | { |
|
|
2467 | for (i = 0; i < NUM_OUTPUT_BUFS; i++) |
2425 | for (i = 0; i < NUM_OUTPUT_BUFS; i++) |
2468 | if (op->contr->outputs[i].buf && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2426 | if (op->contr->outputs[i].buf && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2469 | flush_output_element (op, &op->contr->outputs[i]); |
2427 | flush_output_element (op, &op->contr->outputs[i]); |
2470 | } |
|
|
2471 | |
2428 | |
2472 | if (op->contr->ns->state == ST_PLAYING) |
2429 | if (op->contr->ns->state == ST_PLAYING) |
2473 | { |
2430 | { |
2474 | /* these next three if clauses make it possible to SLOW DOWN |
2431 | /* these next three if clauses make it possible to SLOW DOWN |
2475 | hp/grace/spellpoint regeneration. */ |
2432 | hp/grace/spellpoint regeneration. */ |
… | |
… | |
2496 | gen_grace = op->stats.maxgrace; |
2453 | gen_grace = op->stats.maxgrace; |
2497 | rate_grace -= rate_grace / 2 * op->contr->gen_grace; |
2454 | rate_grace -= rate_grace / 2 * op->contr->gen_grace; |
2498 | } |
2455 | } |
2499 | |
2456 | |
2500 | /* Regenerate Spell Points */ |
2457 | /* Regenerate Spell Points */ |
2501 | if (op->contr->ranges[range_golem] == NULL && --op->last_sp < 0) |
2458 | if (!op->contr->ranges[range_golem] && --op->last_sp < 0) |
2502 | { |
2459 | { |
2503 | gen_sp = gen_sp * 10 / (op->contr->gen_sp_armour < 10 ? 10 : op->contr->gen_sp_armour); |
2460 | gen_sp = gen_sp * 10 / (op->contr->gen_sp_armour < 10 ? 10 : op->contr->gen_sp_armour); |
2504 | if (op->stats.sp < op->stats.maxsp) |
2461 | if (op->stats.sp < op->stats.maxsp) |
2505 | { |
2462 | { |
2506 | op->stats.sp++; |
2463 | op->stats.sp++; |
… | |
… | |
2724 | tmp->name = buf; |
2681 | tmp->name = buf; |
2725 | sprintf (buf, " This finger has been cut off %s\n" |
2682 | sprintf (buf, " This finger has been cut off %s\n" |
2726 | " the %s, when he was defeated at\n level %d by %s.\n", |
2683 | " the %s, when he was defeated at\n level %d by %s.\n", |
2727 | &op->name, op->contr->title, (int) (op->level), op->contr->killer); |
2684 | &op->name, op->contr->title, (int) (op->level), op->contr->killer); |
2728 | tmp->msg = buf; |
2685 | tmp->msg = buf; |
2729 | tmp->value = 0, tmp->material = 0, tmp->type = 0; |
2686 | tmp->value = 0, tmp->type = 0; |
2730 | tmp->materialname = NULL; |
2687 | tmp->materialname = "organics"; |
2731 | tmp->insert_at (op, tmp); |
2688 | tmp->insert_at (op, tmp); |
2732 | } |
2689 | } |
2733 | |
2690 | |
2734 | /* teleport defeated player to new destination */ |
2691 | /* teleport defeated player to new destination */ |
2735 | transfer_ob (op, x, y, 0, NULL); |
2692 | transfer_ob (op, x, y, 0, NULL); |
… | |
… | |
2931 | op->stats.hp = op->stats.maxhp; |
2888 | op->stats.hp = op->stats.maxhp; |
2932 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
2889 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
2933 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
2890 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
2934 | |
2891 | |
2935 | /* |
2892 | /* |
2936 | * Check to see if the player is in a shop. IF so, then check to see if |
|
|
2937 | * the player has any unpaid items. If so, remove them and put them back |
2893 | * Check to see if the player has any unpaid items. If so, remove them |
2938 | * in the map. |
2894 | * and put them back in the map. |
2939 | */ |
2895 | */ |
2940 | |
|
|
2941 | if (is_in_shop (op)) |
|
|
2942 | remove_unpaid_objects (op->inv, op); |
2896 | remove_unpaid_objects (op->inv, op); |
2943 | |
2897 | |
2944 | /****************************************/ |
2898 | /****************************************/ |
2945 | /* */ |
2899 | /* */ |
2946 | /* Move player to his current respawn- */ |
2900 | /* Move player to his current respawn- */ |
2947 | /* position (usually last savebed) */ |
2901 | /* position (usually last savebed) */ |
… | |
… | |
2987 | void |
2941 | void |
2988 | loot_object (object *op) |
2942 | loot_object (object *op) |
2989 | { /* Grab and destroy some treasure */ |
2943 | { /* Grab and destroy some treasure */ |
2990 | object *tmp, *tmp2, *next; |
2944 | object *tmp, *tmp2, *next; |
2991 | |
2945 | |
2992 | if (op->container) |
2946 | op->close_container (); /* close open sack first */ |
2993 | esrv_apply_container (op, op->container); /* close open sack first */ |
|
|
2994 | |
2947 | |
2995 | for (tmp = op->inv; tmp; tmp = next) |
2948 | for (tmp = op->inv; tmp; tmp = next) |
2996 | { |
2949 | { |
2997 | next = tmp->below; |
2950 | next = tmp->below; |
2998 | |
2951 | |
2999 | if (tmp->invisible) |
2952 | if (tmp->invisible) |
3000 | continue; |
2953 | continue; |
3001 | |
2954 | |
3002 | tmp->remove (); |
2955 | tmp->remove (); |
3003 | tmp->x = op->x, tmp->y = op->y; |
2956 | tmp->x = op->x, tmp->y = op->y; |
|
|
2957 | |
3004 | if (tmp->type == CONTAINER) |
2958 | if (tmp->type == CONTAINER) |
3005 | { /* empty container to ground */ |
2959 | loot_object (tmp); /* empty container to ground */ |
3006 | loot_object (tmp); |
2960 | |
3007 | } |
|
|
3008 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) |
2961 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) |
3009 | { |
2962 | { |
3010 | if (tmp->nrof > 1) |
2963 | if (tmp->nrof > 1) |
3011 | { |
2964 | { |
3012 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
2965 | tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); |
3013 | tmp2->destroy (); |
2966 | tmp2->destroy (); |
… | |
… | |
3024 | /* |
2977 | /* |
3025 | * fix_weight(): Check recursively the weight of all players, and fix |
2978 | * fix_weight(): Check recursively the weight of all players, and fix |
3026 | * what needs to be fixed. Refresh windows and fix speed if anything |
2979 | * what needs to be fixed. Refresh windows and fix speed if anything |
3027 | * was changed. |
2980 | * was changed. |
3028 | */ |
2981 | */ |
3029 | |
|
|
3030 | void |
2982 | void |
3031 | fix_weight (void) |
2983 | fix_weight (void) |
3032 | { |
2984 | { |
3033 | for_all_players (pl) |
2985 | for_all_players (pl) |
3034 | { |
2986 | { |
… | |
… | |
3094 | if (op->type == PLAYER) |
3046 | if (op->type == PLAYER) |
3095 | { |
3047 | { |
3096 | op->contr->tmp_invis = 0; |
3048 | op->contr->tmp_invis = 0; |
3097 | op->contr->invis_race = 0; |
3049 | op->contr->invis_race = 0; |
3098 | } |
3050 | } |
|
|
3051 | |
3099 | update_object (op, UP_OBJ_FACE); |
3052 | update_object (op, UP_OBJ_CHANGE); |
3100 | } |
3053 | } |
3101 | |
3054 | |
3102 | int |
3055 | int |
3103 | is_true_undead (object *op) |
3056 | is_true_undead (object *op) |
3104 | { |
3057 | { |
3105 | object *tmp = NULL; |
|
|
3106 | |
|
|
3107 | if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) |
3058 | if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) |
3108 | return 1; |
3059 | return 1; |
3109 | |
3060 | |
3110 | return 0; |
3061 | return 0; |
3111 | } |
3062 | } |
… | |
… | |
3399 | char buf[MAX_BUF]; /* tmp. string buffer */ |
3350 | char buf[MAX_BUF]; /* tmp. string buffer */ |
3400 | int i = 0, j = 0; |
3351 | int i = 0, j = 0; |
3401 | |
3352 | |
3402 | /* get the appropriate treasurelist */ |
3353 | /* get the appropriate treasurelist */ |
3403 | if (atnr == ATNR_FIRE) |
3354 | if (atnr == ATNR_FIRE) |
3404 | trlist = find_treasurelist ("dragon_ability_fire"); |
3355 | trlist = treasurelist::find ("dragon_ability_fire"); |
3405 | else if (atnr == ATNR_COLD) |
3356 | else if (atnr == ATNR_COLD) |
3406 | trlist = find_treasurelist ("dragon_ability_cold"); |
3357 | trlist = treasurelist::find ("dragon_ability_cold"); |
3407 | else if (atnr == ATNR_ELECTRICITY) |
3358 | else if (atnr == ATNR_ELECTRICITY) |
3408 | trlist = find_treasurelist ("dragon_ability_elec"); |
3359 | trlist = treasurelist::find ("dragon_ability_elec"); |
3409 | else if (atnr == ATNR_POISON) |
3360 | else if (atnr == ATNR_POISON) |
3410 | trlist = find_treasurelist ("dragon_ability_poison"); |
3361 | trlist = treasurelist::find ("dragon_ability_poison"); |
3411 | |
3362 | |
3412 | if (trlist == NULL || who->type != PLAYER) |
3363 | if (trlist == NULL || who->type != PLAYER) |
3413 | return; |
3364 | return; |
3414 | |
3365 | |
3415 | for (i = 0, tr = trlist->items; tr != NULL && i < level - 1; tr = tr->next, i++); |
3366 | for (i = 0, tr = trlist->items; tr != NULL && i < level - 1; tr = tr->next, i++); |
… | |
… | |
3547 | * not readied. |
3498 | * not readied. |
3548 | */ |
3499 | */ |
3549 | void |
3500 | void |
3550 | player_unready_range_ob (player *pl, object *ob) |
3501 | player_unready_range_ob (player *pl, object *ob) |
3551 | { |
3502 | { |
3552 | rangetype i; |
|
|
3553 | |
|
|
3554 | for (i = (rangetype) 0; i < range_size; i = (rangetype) ((int) i + 1)) |
3503 | for (rangetype i = (rangetype) 0; i < range_size; i = (rangetype) ((int) i + 1)) |
3555 | { |
|
|
3556 | if (pl->ranges[i] == ob) |
3504 | if (pl->ranges[i] == ob) |
3557 | { |
3505 | { |
3558 | pl->ranges[i] = NULL; |
3506 | pl->ranges[i] = 0; |
3559 | if (pl->shoottype == i) |
3507 | if (pl->shoottype == i) |
3560 | { |
|
|
3561 | pl->shoottype = range_none; |
3508 | pl->shoottype = range_none; |
3562 | } |
|
|
3563 | } |
3509 | } |
3564 | } |
|
|
3565 | } |
3510 | } |
|
|
3511 | |
|
|
3512 | sint8 |
|
|
3513 | player::visibility_at (maptile *map, int x, int y) const |
|
|
3514 | { |
|
|
3515 | if (!ns) |
|
|
3516 | return 0; |
|
|
3517 | |
|
|
3518 | int dx, dy; |
|
|
3519 | if (!adjacent_map (map, ns->current_map, &dx, &dy)) |
|
|
3520 | return 0; |
|
|
3521 | |
|
|
3522 | x += dx - ns->current_x + ns->mapx / 2; |
|
|
3523 | y += dy - ns->current_y + ns->mapy / 2; |
|
|
3524 | |
|
|
3525 | if (!IN_RANGE_EXC (x, 0, ns->mapx) || !IN_RANGE_EXC (y, 0, ns->mapy)) |
|
|
3526 | return 0; |
|
|
3527 | |
|
|
3528 | return 100 - blocked_los [x][y]; |
|
|
3529 | } |