… | |
… | |
54 | |
54 | |
55 | players.insert (this); |
55 | players.insert (this); |
56 | ob->remove (); |
56 | ob->remove (); |
57 | ob->map = 0; |
57 | ob->map = 0; |
58 | ob->activate_recursive (); |
58 | ob->activate_recursive (); |
59 | CLEAR_FLAG (ob, FLAG_FRIENDLY); |
59 | ob->clr_flag (FLAG_FRIENDLY); |
60 | add_friendly_object (ob); |
60 | add_friendly_object (ob); |
61 | } |
61 | } |
62 | |
62 | |
63 | void |
63 | void |
64 | player::deactivate () |
64 | player::deactivate () |
… | |
… | |
374 | */ |
374 | */ |
375 | int |
375 | int |
376 | path_to_player (object *mon, object *pl, unsigned mindiff) |
376 | path_to_player (object *mon, object *pl, unsigned mindiff) |
377 | { |
377 | { |
378 | rv_vector rv; |
378 | rv_vector rv; |
379 | sint16 x, y; |
|
|
380 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
379 | int dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
381 | maptile *m, *lastmap; |
|
|
382 | |
380 | |
383 | get_rangevector (mon, pl, &rv, 0); |
381 | get_rangevector (mon, pl, &rv, 0); |
384 | |
382 | |
385 | if (rv.distance < mindiff) |
383 | if (rv.distance < mindiff) |
386 | return 0; |
384 | return 0; |
387 | |
385 | |
388 | x = mon->x; |
386 | mapxy pos (mon); |
389 | y = mon->y; |
|
|
390 | m = mon->map; |
|
|
391 | dir = rv.direction; |
387 | dir = rv.direction; |
392 | lastdir = firstdir = rv.direction; /* perhaps we stand next to pl, init firstdir too */ |
388 | lastdir = firstdir = rv.direction; /* perhaps we stand next to pl, init firstdir too */ |
393 | diff = ::max (abs (rv.distance_x), abs (rv.distance_y)); |
389 | diff = ::max (abs (rv.distance_x), abs (rv.distance_y)); |
394 | |
390 | |
395 | /* If we can't solve it within the search distance, return now. */ |
391 | /* If we can't solve it within the search distance, return now. */ |
396 | if (diff > max) |
392 | if (diff > max) |
397 | return 0; |
393 | return 0; |
398 | |
394 | |
399 | while (diff > 1 && max > 0) |
395 | while (diff > 1 && max > 0) |
400 | { |
396 | { |
401 | lastx = x; |
397 | mapxy lastpos = pos; |
402 | lasty = y; |
398 | pos.move (dir); |
403 | lastmap = m; |
|
|
404 | x = lastx + freearr_x[dir]; |
|
|
405 | y = lasty + freearr_y[dir]; |
|
|
406 | |
399 | |
407 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
400 | MoveType blocked; |
408 | blocked = (mflags & P_OUT_OF_MAP) ? MOVE_ALL : GET_MAP_MOVE_BLOCK (m, x, y); |
401 | bool blocksview; |
|
|
402 | |
|
|
403 | if (pos.normalise ()) |
|
|
404 | { |
|
|
405 | mapspace &ms = *pos; |
|
|
406 | |
|
|
407 | blocksview = ms.flags () & P_BLOCKSVIEW; |
|
|
408 | blocked = ms.move_block; |
|
|
409 | } |
|
|
410 | else |
|
|
411 | { |
|
|
412 | blocksview = true; |
|
|
413 | blocked = MOVE_ALL; |
|
|
414 | } |
409 | |
415 | |
410 | /* Space is blocked - try changing direction a little */ |
416 | /* Space is blocked - try changing direction a little */ |
411 | if ((mflags & P_OUT_OF_MAP) || ((OB_TYPE_MOVE_BLOCK (mon, blocked) || (mflags & P_BLOCKSVIEW)) |
417 | if ((blocksview || OB_TYPE_MOVE_BLOCK (mon, blocked)) |
412 | && (m == mon->map && blocked_link (mon, m, x, y)))) |
418 | && (blocked_link (mon, pos.m, pos.x, pos.y))) |
413 | { |
419 | { |
414 | /* recalculate direction from last good location. Possible |
420 | /* recalculate direction from last good location. Possible |
415 | * we were not traversing ideal location before. |
421 | * we were not traversing ideal location before. |
416 | */ |
422 | */ |
417 | get_rangevector_from_mapcoord (lastmap, lastx, lasty, pl, &rv, 0); |
423 | get_rangevector_from_mapcoord (lastpos.m, lastpos.x, lastpos.y, pl, &rv, 0); |
418 | if (rv.direction != dir) |
424 | if (rv.direction != dir) |
419 | { |
425 | { |
420 | /* OK - says direction should be different - lets reset the |
426 | /* OK - says direction should be different - lets reset the |
421 | * the values so it will try again. |
427 | * the values so it will try again. |
422 | */ |
428 | */ |
423 | x = lastx; |
|
|
424 | y = lasty; |
|
|
425 | m = lastmap; |
429 | pos = lastpos; |
426 | dir = firstdir = rv.direction; |
430 | dir = firstdir = rv.direction; |
427 | } |
431 | } |
428 | else |
432 | else |
429 | { |
433 | { |
430 | /* direct path is blocked - try taking a side step to |
434 | /* direct path is blocked - try taking a side step to |
… | |
… | |
437 | */ |
441 | */ |
438 | for (i = -DETOUR_AMOUNT; i <= DETOUR_AMOUNT; i++) |
442 | for (i = -DETOUR_AMOUNT; i <= DETOUR_AMOUNT; i++) |
439 | { |
443 | { |
440 | if (i == 0) |
444 | if (i == 0) |
441 | continue; /* already did this, so skip it */ |
445 | continue; /* already did this, so skip it */ |
|
|
446 | |
442 | /* Use lastdir here - otherwise, |
447 | /* Use lastdir here - otherwise, |
443 | * since the direction that the creature should move in |
448 | * since the direction that the creature should move in |
444 | * may change, you could get infinite loops. |
449 | * may change, you could get infinite loops. |
445 | * ie, player is northwest, but monster can only |
450 | * ie, player is northwest, but monster can only |
446 | * move west, so it does that. It goes some distance, |
451 | * move west, so it does that. It goes some distance, |
… | |
… | |
448 | * can't do that, but now finds it can move east, and |
453 | * can't do that, but now finds it can move east, and |
449 | * gets back to its original point. lastdir contains |
454 | * gets back to its original point. lastdir contains |
450 | * the last direction the creature has successfully |
455 | * the last direction the creature has successfully |
451 | * moved. |
456 | * moved. |
452 | */ |
457 | */ |
453 | |
|
|
454 | x = lastx + freearr_x[absdir (lastdir + i)]; |
|
|
455 | y = lasty + freearr_y[absdir (lastdir + i)]; |
|
|
456 | m = lastmap; |
458 | pos = lastpos; |
457 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
459 | pos.move (absdir (lastdir + i)); |
458 | if (mflags & P_OUT_OF_MAP) |
460 | |
|
|
461 | if (!pos.normalise ()) |
459 | continue; |
462 | continue; |
460 | blocked = GET_MAP_MOVE_BLOCK (m, x, y); |
463 | |
461 | if (OB_TYPE_MOVE_BLOCK (mon, blocked)) |
464 | mapspace &ms = *pos; |
|
|
465 | |
|
|
466 | if (ms.flags () & P_BLOCKSVIEW) |
462 | continue; |
467 | continue; |
463 | if (mflags & P_BLOCKSVIEW) |
468 | |
|
|
469 | if (OB_TYPE_MOVE_BLOCK (mon, ms.move_block)) |
464 | continue; |
470 | continue; |
465 | |
471 | |
466 | if (m == mon->map && blocked_link (mon, m, x, y)) |
472 | if (blocked_link (mon, pos.m, pos.x, pos.y)) |
467 | break; |
473 | break; |
468 | } |
474 | } |
|
|
475 | |
469 | /* go through entire loop without finding a valid |
476 | /* go through entire loop without finding a valid |
470 | * sidestep to take - thus, no valid path. |
477 | * sidestep to take - thus, no valid path. |
471 | */ |
478 | */ |
472 | if (i == (DETOUR_AMOUNT + 1)) |
479 | if (i == DETOUR_AMOUNT + 1) |
473 | return 0; |
480 | return 0; |
|
|
481 | |
474 | diff--; |
482 | diff--; |
475 | lastdir = dir; |
483 | lastdir = dir; |
476 | max--; |
484 | max--; |
477 | if (!firstdir) |
485 | if (!firstdir) |
478 | firstdir = dir + i; |
486 | firstdir = dir + i; |
… | |
… | |
482 | { |
490 | { |
483 | /* we moved towards creature, so diff is less */ |
491 | /* we moved towards creature, so diff is less */ |
484 | diff--; |
492 | diff--; |
485 | max--; |
493 | max--; |
486 | lastdir = dir; |
494 | lastdir = dir; |
|
|
495 | |
487 | if (!firstdir) |
496 | if (!firstdir) |
488 | firstdir = dir; |
497 | firstdir = dir; |
489 | } |
498 | } |
490 | |
499 | |
491 | if (diff <= 1) |
500 | if (diff <= 1) |
492 | { |
501 | { |
493 | /* Recalculate diff (distance) because we may not have actually |
502 | /* Recalculate diff (distance) because we may not have actually |
494 | * headed toward player for entire distance. |
503 | * headed toward player for entire distance. |
495 | */ |
504 | */ |
496 | get_rangevector_from_mapcoord (m, x, y, pl, &rv, 0); |
505 | get_rangevector_from_mapcoord (pos.m, pos.x, pos.y, pl, &rv, 0); |
497 | diff = ::max (abs (rv.distance_x), abs (rv.distance_y)); |
506 | diff = ::max (abs (rv.distance_x), abs (rv.distance_y)); |
498 | } |
507 | } |
499 | |
508 | |
500 | if (diff > max) |
509 | if (diff > max) |
501 | return 0; |
510 | return 0; |
… | |
… | |
519 | next = op->below; |
528 | next = op->below; |
520 | |
529 | |
521 | /* Forces get applied per default, unless they have the |
530 | /* Forces get applied per default, unless they have the |
522 | * flag "neutral" set. Sorry but I can't think of a better way |
531 | * flag "neutral" set. Sorry but I can't think of a better way |
523 | */ |
532 | */ |
524 | if (op->type == FORCE && !QUERY_FLAG (op, FLAG_NEUTRAL)) |
533 | if (op->type == FORCE && !op->flag [FLAG_NEUTRAL]) |
525 | SET_FLAG (op, FLAG_APPLIED); |
534 | op->set_flag (FLAG_APPLIED); |
526 | |
535 | |
527 | /* we never give weapons/armour if these cannot be used |
536 | /* we never give weapons/armour if these cannot be used |
528 | * by this player due to race restrictions |
537 | * by this player due to race restrictions |
529 | */ |
538 | */ |
530 | if (pl->type == PLAYER) |
539 | if (pl->type == PLAYER) |
531 | { |
540 | { |
532 | if ((!QUERY_FLAG (pl, FLAG_USE_ARMOUR) |
541 | if ((!pl->flag [FLAG_USE_ARMOUR] |
533 | && |
542 | && |
534 | (op->type == ARMOUR || op->type == BOOTS |
543 | (op->type == ARMOUR || op->type == BOOTS |
535 | || op->type == CLOAK || op->type == HELMET |
544 | || op->type == CLOAK || op->type == HELMET |
536 | || op->type == SHIELD || op->type == GLOVES |
545 | || op->type == SHIELD || op->type == GLOVES |
537 | || op->type == BRACERS || op->type == GIRDLE)) |
546 | || op->type == BRACERS || op->type == GIRDLE)) |
538 | || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
547 | || (!pl->flag [FLAG_USE_WEAPON] && op->type == WEAPON)) |
539 | { |
548 | { |
540 | op->destroy (); |
549 | op->destroy (); |
541 | continue; |
550 | continue; |
542 | } |
551 | } |
543 | } |
552 | } |
… | |
… | |
560 | if (op->nrof > 1) |
569 | if (op->nrof > 1) |
561 | op->nrof = 1; |
570 | op->nrof = 1; |
562 | } |
571 | } |
563 | |
572 | |
564 | if (op->type == SPELLBOOK && op->inv) |
573 | if (op->type == SPELLBOOK && op->inv) |
565 | CLEAR_FLAG (op->inv, FLAG_STARTEQUIP); |
574 | op->inv->clr_flag (FLAG_STARTEQUIP); |
566 | |
575 | |
567 | /* Give starting characters identified, uncursed, and undamned |
576 | /* Give starting characters identified, uncursed, and undamned |
568 | * items. Just don't identify gold or silver, or it won't be |
577 | * items. Just don't identify gold or silver, or it won't be |
569 | * merged properly. |
578 | * merged properly. |
570 | */ |
579 | */ |
571 | if (need_identify (op)) |
580 | if (op->need_identify ()) |
572 | { |
581 | { |
573 | SET_FLAG (op, FLAG_IDENTIFIED); |
582 | op->set_flag (FLAG_IDENTIFIED); |
574 | CLEAR_FLAG (op, FLAG_CURSED); |
583 | op->clr_flag (FLAG_CURSED); |
575 | CLEAR_FLAG (op, FLAG_DAMNED); |
584 | op->clr_flag (FLAG_DAMNED); |
576 | } |
585 | } |
577 | |
586 | |
578 | if (op->type == SPELL) |
587 | if (op->type == SPELL) |
579 | { |
588 | { |
580 | op->destroy (); |
589 | op->destroy (); |
581 | continue; |
590 | continue; |
582 | } |
591 | } |
583 | else if (op->type == SKILL) |
592 | else if (op->type == SKILL) |
584 | { |
593 | { |
585 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
594 | op->set_flag (FLAG_CAN_USE_SKILL); |
586 | op->stats.exp = 0; |
595 | op->stats.exp = 0; |
587 | op->level = 1; |
596 | op->level = 1; |
588 | } |
597 | } |
589 | else /* lock all 'normal items by default */ |
598 | else /* lock all 'normal items by default */ |
590 | SET_FLAG (op, FLAG_INV_LOCKED); |
599 | op->set_flag (FLAG_INV_LOCKED); |
591 | } /* for loop of objects in player inv */ |
600 | } /* for loop of objects in player inv */ |
592 | |
601 | |
593 | /* Need to set up the skill pointers */ |
602 | /* Need to set up the skill pointers */ |
594 | pl->contr->link_skills (); |
603 | pl->contr->link_skills (); |
595 | } |
604 | } |
… | |
… | |
729 | |
738 | |
730 | if (ob->msg) |
739 | if (ob->msg) |
731 | ob->msg = 0; |
740 | ob->msg = 0; |
732 | |
741 | |
733 | start_info (ob); |
742 | start_info (ob); |
734 | CLEAR_FLAG (ob, FLAG_WIZ); |
743 | ob->clr_flag (FLAG_WIZ); |
735 | give_initial_items (ob, ob->randomitems); |
744 | give_initial_items (ob, ob->randomitems); |
736 | esrv_send_inventory (ob, ob); |
745 | esrv_send_inventory (ob, ob); |
737 | ob->update_stats (); |
746 | ob->update_stats (); |
738 | |
747 | |
739 | /* This moves the player to a different start map, if there |
748 | /* This moves the player to a different start map, if there |
… | |
… | |
788 | rv_vector rv; |
797 | rv_vector rv; |
789 | |
798 | |
790 | if (op->stats.hp < 0) |
799 | if (op->stats.hp < 0) |
791 | { |
800 | { |
792 | LOG (llevDebug, "Fleeing player is dead.\n"); |
801 | LOG (llevDebug, "Fleeing player is dead.\n"); |
793 | CLEAR_FLAG (op, FLAG_SCARED); |
802 | op->clr_flag (FLAG_SCARED); |
794 | return; |
803 | return; |
795 | } |
804 | } |
796 | |
805 | |
797 | if (!op->enemy) |
806 | if (!op->enemy) |
798 | { |
807 | { |
799 | LOG (llevDebug, "Fleeing player had no enemy.\n"); |
808 | LOG (llevDebug, "Fleeing player had no enemy.\n"); |
800 | CLEAR_FLAG (op, FLAG_SCARED); |
809 | op->clr_flag (FLAG_SCARED); |
801 | return; |
810 | return; |
802 | } |
811 | } |
803 | |
812 | |
804 | if (!(random_roll (0, 4, op, PREFER_LOW)) && did_make_save (op, op->level, 0)) |
813 | if (!(random_roll (0, 4, op, PREFER_LOW)) && did_make_save (op, op->level, 0)) |
805 | { |
814 | { |
806 | op->enemy = NULL; |
815 | op->enemy = NULL; |
807 | CLEAR_FLAG (op, FLAG_SCARED); |
816 | op->clr_flag (FLAG_SCARED); |
808 | return; |
817 | return; |
809 | } |
818 | } |
810 | |
819 | |
811 | get_rangevector (op, op->enemy, &rv, 0); |
820 | get_rangevector (op, op->enemy, &rv, 0); |
812 | |
821 | |
… | |
… | |
818 | if (op->move (absdir (dir + diff * m)) || (diff == 0 && op->move (absdir (dir - diff * m)))) |
827 | if (op->move (absdir (dir + diff * m)) || (diff == 0 && op->move (absdir (dir - diff * m)))) |
819 | return; |
828 | return; |
820 | } |
829 | } |
821 | |
830 | |
822 | /* Cornered, get rid of scared */ |
831 | /* Cornered, get rid of scared */ |
823 | CLEAR_FLAG (op, FLAG_SCARED); |
832 | op->clr_flag (FLAG_SCARED); |
824 | op->enemy = NULL; |
833 | op->enemy = NULL; |
825 | } |
834 | } |
826 | |
835 | |
827 | /* check_pick sees if there is stuff to be picked up/picks up stuff. |
836 | /* check_pick sees if there is stuff to be picked up/picks up stuff. |
828 | * It returns 1 if the player should keep on moving, 0 if he should |
837 | * It returns 1 if the player should keep on moving, 0 if he should |
… | |
… | |
920 | * fighting */ |
929 | * fighting */ |
921 | if (op->contr->mode & PU_INHIBIT) |
930 | if (op->contr->mode & PU_INHIBIT) |
922 | return 1; |
931 | return 1; |
923 | |
932 | |
924 | /* prevent us from turning into auto-thieves :) */ |
933 | /* prevent us from turning into auto-thieves :) */ |
925 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
934 | if (tmp->flag [FLAG_UNPAID]) |
926 | continue; |
935 | continue; |
927 | |
936 | |
928 | /* ignore known cursed objects */ |
937 | /* ignore known cursed objects */ |
929 | if (QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) && op->contr->mode & PU_NOT_CURSED) |
938 | if (tmp->flag [FLAG_KNOWN_CURSED] && op->contr->mode & PU_NOT_CURSED) |
930 | continue; |
939 | continue; |
931 | |
940 | |
932 | /* all food and drink if desired */ |
941 | /* all food and drink if desired */ |
933 | /* question: don't pick up known-poisonous stuff? */ |
942 | /* question: don't pick up known-poisonous stuff? */ |
934 | if (op->contr->mode & PU_FOOD) |
943 | if (op->contr->mode & PU_FOOD) |
… | |
… | |
937 | CHK_PICK_PICKUP; |
946 | CHK_PICK_PICKUP; |
938 | continue; |
947 | continue; |
939 | } |
948 | } |
940 | |
949 | |
941 | if (op->contr->mode & PU_DRINK) |
950 | if (op->contr->mode & PU_DRINK) |
942 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
951 | if (tmp->type == DRINK || (tmp->type == POISON && !tmp->flag [FLAG_KNOWN_CURSED])) |
943 | { |
952 | { |
944 | CHK_PICK_PICKUP; |
953 | CHK_PICK_PICKUP; |
945 | continue; |
954 | continue; |
946 | } |
955 | } |
947 | |
956 | |
… | |
… | |
985 | continue; |
994 | continue; |
986 | } |
995 | } |
987 | |
996 | |
988 | /* pick up all magical items */ |
997 | /* pick up all magical items */ |
989 | if (op->contr->mode & PU_MAGICAL) |
998 | if (op->contr->mode & PU_MAGICAL) |
990 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) |
999 | if (tmp->flag [FLAG_KNOWN_MAGICAL] |
991 | && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1000 | && !tmp->flag [FLAG_KNOWN_CURSED]) |
992 | { |
1001 | { |
993 | CHK_PICK_PICKUP; |
1002 | CHK_PICK_PICKUP; |
994 | continue; |
1003 | continue; |
995 | } |
1004 | } |
996 | |
1005 | |
… | |
… | |
1080 | continue; |
1089 | continue; |
1081 | } |
1090 | } |
1082 | |
1091 | |
1083 | /* hoping to catch throwing daggers here */ |
1092 | /* hoping to catch throwing daggers here */ |
1084 | if (op->contr->mode & PU_MISSILEWEAPON) |
1093 | if (op->contr->mode & PU_MISSILEWEAPON) |
1085 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1094 | if (tmp->type == WEAPON && tmp->flag [FLAG_IS_THROWN]) |
1086 | { |
1095 | { |
1087 | CHK_PICK_PICKUP; |
1096 | CHK_PICK_PICKUP; |
1088 | continue; |
1097 | continue; |
1089 | } |
1098 | } |
1090 | |
1099 | |
… | |
… | |
1145 | * return 0. |
1154 | * return 0. |
1146 | */ |
1155 | */ |
1147 | static int |
1156 | static int |
1148 | action_makes_visible (object *op) |
1157 | action_makes_visible (object *op) |
1149 | { |
1158 | { |
1150 | if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) |
1159 | if (op->invisible && op->flag [FLAG_ALIVE]) |
1151 | { |
1160 | { |
1152 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
1161 | if (op->flag [FLAG_MAKE_INVIS]) |
1153 | { |
1162 | { |
1154 | // artefact invisibility is permanent, but we still make noise |
1163 | // artefact invisibility is permanent, but we still make noise |
1155 | // this is important for game-balance. |
1164 | // this is important for game-balance. |
1156 | if (op->contr) |
1165 | if (op->contr) |
1157 | op->make_noise (); |
1166 | op->make_noise (); |
… | |
… | |
1184 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1193 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1185 | if (tmp->type == ARROW && !strcmp (&tmp->race, type)) |
1194 | if (tmp->type == ARROW && !strcmp (&tmp->race, type)) |
1186 | return splay (tmp); |
1195 | return splay (tmp); |
1187 | |
1196 | |
1188 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1197 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1189 | if (tmp->type == CONTAINER && QUERY_FLAG (tmp, FLAG_APPLIED) && !strcmp (&tmp->race, type)) |
1198 | if (tmp->type == CONTAINER && tmp->flag [FLAG_APPLIED] && !strcmp (&tmp->race, type)) |
1190 | if (object *arrow = find_arrow (tmp, type)) |
1199 | if (object *arrow = find_arrow (tmp, type)) |
1191 | { |
1200 | { |
1192 | splay (tmp); |
1201 | splay (tmp); |
1193 | return arrow; |
1202 | return arrow; |
1194 | } |
1203 | } |
… | |
… | |
1211 | if (!type) |
1220 | if (!type) |
1212 | return NULL; |
1221 | return NULL; |
1213 | |
1222 | |
1214 | for (arrow = op->inv; arrow; arrow = arrow->below) |
1223 | for (arrow = op->inv; arrow; arrow = arrow->below) |
1215 | { |
1224 | { |
1216 | if (arrow->type == CONTAINER && arrow->race == type && QUERY_FLAG (arrow, FLAG_APPLIED)) |
1225 | if (arrow->type == CONTAINER && arrow->race == type && arrow->flag [FLAG_APPLIED]) |
1217 | { |
1226 | { |
1218 | i = 0; |
1227 | i = 0; |
1219 | ntmp = find_better_arrow (arrow, target, type, &i); |
1228 | ntmp = find_better_arrow (arrow, target, type, &i); |
1220 | |
1229 | |
1221 | if (i > betterby) |
1230 | if (i > betterby) |
… | |
… | |
1322 | break; |
1331 | break; |
1323 | } |
1332 | } |
1324 | |
1333 | |
1325 | if (mflags & P_IS_ALIVE) |
1334 | if (mflags & P_IS_ALIVE) |
1326 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
1335 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
1327 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
1336 | if (tmp->flag [FLAG_ALIVE]) |
1328 | break; |
1337 | break; |
1329 | } |
1338 | } |
1330 | |
1339 | |
1331 | if (!tmp) |
1340 | if (!tmp) |
1332 | return find_arrow (op, type); |
1341 | return find_arrow (op, type); |
… | |
… | |
1393 | { |
1402 | { |
1394 | if (op->type == PLAYER) |
1403 | if (op->type == PLAYER) |
1395 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1404 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1396 | /* FLAG_READY_BOW will get reset if the monsters picks up some arrows */ |
1405 | /* FLAG_READY_BOW will get reset if the monsters picks up some arrows */ |
1397 | else |
1406 | else |
1398 | CLEAR_FLAG (op, FLAG_READY_BOW); |
1407 | op->clr_flag (FLAG_READY_BOW); |
1399 | |
1408 | |
1400 | return 0; |
1409 | return 0; |
1401 | } |
1410 | } |
1402 | } |
1411 | } |
1403 | |
1412 | |
… | |
… | |
1603 | { |
1612 | { |
1604 | object *tmp; |
1613 | object *tmp; |
1605 | |
1614 | |
1606 | if (item->arch) |
1615 | if (item->arch) |
1607 | { |
1616 | { |
1608 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1617 | item->clr_flag (FLAG_ANIMATE); |
1609 | item->face = item->arch->face; |
1618 | item->face = item->arch->face; |
1610 | item->set_speed (0); |
1619 | item->set_speed (0); |
1611 | } |
1620 | } |
1612 | |
1621 | |
1613 | if (object *pl = item->visible_to ()) |
1622 | if (object *pl = item->visible_to ()) |
… | |
… | |
1741 | * |
1750 | * |
1742 | * Change the color so that the message doesn't disappear with |
1751 | * Change the color so that the message doesn't disappear with |
1743 | * all the others. |
1752 | * all the others. |
1744 | */ |
1753 | */ |
1745 | if (pl->contr->usekeys == key_inventory |
1754 | if (pl->contr->usekeys == key_inventory |
1746 | || !QUERY_FLAG (container, FLAG_APPLIED) |
1755 | || !container->flag [FLAG_APPLIED] |
1747 | || (pl->contr->usekeys == keyrings && container->race != shstr_keys)) |
1756 | || (pl->contr->usekeys == keyrings && container->race != shstr_keys)) |
1748 | { |
1757 | { |
1749 | new_draw_info_format (NDI_UNIQUE | NDI_BROWN, 0, pl, |
1758 | new_draw_info_format (NDI_UNIQUE | NDI_BROWN, 0, pl, |
1750 | "The %s in your %s vibrates as you approach the door", query_name (tmp), query_name (container)); |
1759 | "The %s in your %s vibrates as you approach the door", query_name (tmp), query_name (container)); |
1751 | return NULL; |
1760 | return NULL; |
… | |
… | |
1902 | */ |
1911 | */ |
1903 | if (op->type == PLAYER |
1912 | if (op->type == PLAYER |
1904 | && ((mon->owner && mon->owner->contr |
1913 | && ((mon->owner && mon->owner->contr |
1905 | && same_party (mon->owner->contr->party, op->contr->party)) |
1914 | && same_party (mon->owner->contr->party, op->contr->party)) |
1906 | || mon->owner == op) |
1915 | || mon->owner == op) |
1907 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
1916 | && (mon->flag [FLAG_UNAGGRESSIVE] || mon->flag [FLAG_FRIENDLY])) |
1908 | { |
1917 | { |
1909 | /* If we're braced, we don't want to switch places with it */ |
1918 | /* If we're braced, we don't want to switch places with it */ |
1910 | if (op->contr->braced) |
1919 | if (op->contr->braced) |
1911 | return false; |
1920 | return false; |
1912 | |
1921 | |
… | |
… | |
1932 | * creatures. Note that if you are braced, you can't push |
1941 | * creatures. Note that if you are braced, you can't push |
1933 | * someone, but put it inside this loop so that you won't |
1942 | * someone, but put it inside this loop so that you won't |
1934 | * attack them either. |
1943 | * attack them either. |
1935 | */ |
1944 | */ |
1936 | if ((mon->type == PLAYER || mon->enemy != op) |
1945 | if ((mon->type == PLAYER || mon->enemy != op) |
1937 | && (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) |
1946 | && (mon->type == PLAYER || mon->flag [FLAG_UNAGGRESSIVE] || mon->flag [FLAG_FRIENDLY]) |
1938 | && ((op->contr->peaceful |
1947 | && ((op->contr->peaceful |
1939 | || (mon->type == PLAYER && mon->contr->peaceful)) |
1948 | || (mon->type == PLAYER && mon->contr->peaceful)) |
1940 | && !on_battleground)) |
1949 | && !on_battleground)) |
1941 | { |
1950 | { |
1942 | if (op->speed_left > 0.f) |
1951 | if (op->speed_left > 0.f) |
… | |
… | |
1958 | } |
1967 | } |
1959 | } |
1968 | } |
1960 | /* If the object is a boulder or other rollable object, then |
1969 | /* If the object is a boulder or other rollable object, then |
1961 | * roll it if not braced. You can't roll it if you are braced. |
1970 | * roll it if not braced. You can't roll it if you are braced. |
1962 | */ |
1971 | */ |
1963 | else if (QUERY_FLAG (mon, FLAG_CAN_ROLL) && (!op->contr->braced)) |
1972 | else if (mon->flag [FLAG_CAN_ROLL] && (!op->contr->braced)) |
1964 | { |
1973 | { |
1965 | if (op->speed_left > 0.f) |
1974 | if (op->speed_left > 0.f) |
1966 | { |
1975 | { |
1967 | --op->speed_left; |
1976 | --op->speed_left; |
1968 | |
1977 | |
… | |
… | |
1977 | * Way it works is like this: First, it must have some hit points |
1986 | * Way it works is like this: First, it must have some hit points |
1978 | * and be living. Then, it must be one of the following: |
1987 | * and be living. Then, it must be one of the following: |
1979 | * 1) Not a player, 2) A player, but of a different party. Note |
1988 | * 1) Not a player, 2) A player, but of a different party. Note |
1980 | * that party_number -1 is no party, so attacks can still happen. |
1989 | * that party_number -1 is no party, so attacks can still happen. |
1981 | */ |
1990 | */ |
1982 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
1991 | else if ((mon->stats.hp >= 0) && mon->flag [FLAG_ALIVE] && |
1983 | ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) |
1992 | ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) |
1984 | { |
1993 | { |
1985 | if (op->contr->weapon_sp_left > 0.f && !op->flag [FLAG_WIZPASS]) |
1994 | if (op->contr->weapon_sp_left > 0.f && !op->flag [FLAG_WIZPASS]) |
1986 | { |
1995 | { |
1987 | --op->contr->weapon_sp_left; |
1996 | --op->contr->weapon_sp_left; |
… | |
… | |
2003 | { |
2012 | { |
2004 | if (!op->map || op->map->in_memory != MAP_ACTIVE) |
2013 | if (!op->map || op->map->in_memory != MAP_ACTIVE) |
2005 | return 0; |
2014 | return 0; |
2006 | |
2015 | |
2007 | /* Sanity check: make sure dir is valid */ |
2016 | /* Sanity check: make sure dir is valid */ |
2008 | if (dir < 0 || dir >= 9) |
2017 | if (dir < 0 || dir > 8) |
2009 | { |
2018 | { |
2010 | LOG (llevError, "move_player: invalid direction %d\n", dir); |
2019 | LOG (llevError, "move_player: invalid direction %d\n", dir); |
2011 | return 0; |
2020 | return 0; |
2012 | } |
2021 | } |
2013 | |
2022 | |
2014 | /* peterm: added following line */ |
2023 | /* peterm: added following line */ |
2015 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2024 | if (op->flag [FLAG_CONFUSED] && dir) |
2016 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2025 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2017 | |
2026 | |
2018 | op->facing = dir; |
2027 | op->facing = dir; |
2019 | |
2028 | |
2020 | if (op->flag [FLAG_HIDDEN]) |
2029 | if (op->flag [FLAG_HIDDEN]) |
… | |
… | |
2060 | * players. |
2069 | * players. |
2061 | */ |
2070 | */ |
2062 | bool |
2071 | bool |
2063 | handle_newcs_player (object *op) |
2072 | handle_newcs_player (object *op) |
2064 | { |
2073 | { |
2065 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2074 | if (op->flag [FLAG_SCARED]) |
2066 | { |
2075 | { |
2067 | if (op->speed_left > 0.f) |
2076 | if (op->speed_left > 0.f) |
2068 | { |
2077 | { |
2069 | --op->speed_left; |
2078 | --op->speed_left; |
2070 | flee_player (op); |
2079 | flee_player (op); |
… | |
… | |
2089 | } |
2098 | } |
2090 | |
2099 | |
2091 | static int |
2100 | static int |
2092 | save_life (object *op) |
2101 | save_life (object *op) |
2093 | { |
2102 | { |
2094 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2103 | if (!op->flag [FLAG_LIFESAVE]) |
2095 | return 0; |
2104 | return 0; |
2096 | |
2105 | |
2097 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
2106 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
2098 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2107 | if (tmp->flag [FLAG_APPLIED] && tmp->flag [FLAG_LIFESAVE]) |
2099 | { |
2108 | { |
2100 | op->play_sound (sound_find ("ob_evaporate")); |
2109 | op->play_sound (sound_find ("ob_evaporate")); |
2101 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2110 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2102 | |
2111 | |
2103 | tmp->destroy (); |
2112 | tmp->destroy (); |
2104 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2113 | op->clr_flag (FLAG_LIFESAVE); |
2105 | |
2114 | |
2106 | if (op->stats.hp < 0) |
2115 | if (op->stats.hp < 0) |
2107 | op->stats.hp = op->stats.maxhp; |
2116 | op->stats.hp = op->stats.maxhp; |
2108 | |
2117 | |
2109 | if (op->stats.food < 0) |
2118 | if (op->stats.food < 0) |
… | |
… | |
2112 | op->update_stats (); |
2121 | op->update_stats (); |
2113 | return 1; |
2122 | return 1; |
2114 | } |
2123 | } |
2115 | |
2124 | |
2116 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2125 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2117 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2126 | op->clr_flag (FLAG_LIFESAVE); |
2118 | enter_player_savebed (op); /* bring him home. */ |
2127 | enter_player_savebed (op); /* bring him home. */ |
2119 | return 0; |
2128 | return 0; |
2120 | } |
2129 | } |
2121 | |
2130 | |
2122 | /* This goes throws the inventory and removes unpaid objects, and puts them |
2131 | /* This goes throws the inventory and removes unpaid objects, and puts them |
… | |
… | |
2129 | { |
2138 | { |
2130 | while (op) |
2139 | while (op) |
2131 | { |
2140 | { |
2132 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2141 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2133 | |
2142 | |
2134 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2143 | if (op->flag [FLAG_UNPAID]) |
2135 | op->insert_at (env); |
2144 | op->insert_at (env); |
2136 | else if (op->inv) |
2145 | else if (op->inv) |
2137 | drop_unpaid_items (op->inv, env); |
2146 | drop_unpaid_items (op->inv, env); |
2138 | |
2147 | |
2139 | op = next; |
2148 | op = next; |
… | |
… | |
2169 | * alternate it here for it to work correctly. |
2178 | * alternate it here for it to work correctly. |
2170 | */ |
2179 | */ |
2171 | if (pticks & 2) |
2180 | if (pticks & 2) |
2172 | op->invisible--; |
2181 | op->invisible--; |
2173 | } |
2182 | } |
2174 | else if (op->invisible && !(QUERY_FLAG (op, FLAG_MAKE_INVIS))) |
2183 | else if (op->invisible && !(op->flag [FLAG_MAKE_INVIS])) |
2175 | { |
2184 | { |
2176 | if (!op->invisible--) |
2185 | if (!op->invisible--) |
2177 | { |
2186 | { |
2178 | make_visible (op); |
2187 | make_visible (op); |
2179 | new_draw_info (NDI_UNIQUE, 0, op, "Your invisibility spell runs out."); |
2188 | new_draw_info (NDI_UNIQUE, 0, op, "Your invisibility spell runs out."); |
… | |
… | |
2246 | if (op->stats.sp < op->stats.maxsp) |
2255 | if (op->stats.sp < op->stats.maxsp) |
2247 | { |
2256 | { |
2248 | op->stats.sp++; |
2257 | op->stats.sp++; |
2249 | |
2258 | |
2250 | /* dms do not consume food */ |
2259 | /* dms do not consume food */ |
2251 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2260 | if (!op->flag [FLAG_WIZ]) |
2252 | { |
2261 | { |
2253 | op->stats.food--; |
2262 | op->stats.food--; |
2254 | |
2263 | |
2255 | if (op->contr->digestion < 0) |
2264 | if (op->contr->digestion < 0) |
2256 | op->stats.food += op->contr->digestion; |
2265 | op->stats.food += op->contr->digestion; |
… | |
… | |
2290 | if (op->stats.hp < op->stats.maxhp) |
2299 | if (op->stats.hp < op->stats.maxhp) |
2291 | { |
2300 | { |
2292 | op->stats.hp++; |
2301 | op->stats.hp++; |
2293 | |
2302 | |
2294 | /* dms do not consume food */ |
2303 | /* dms do not consume food */ |
2295 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2304 | if (!op->flag [FLAG_WIZ]) |
2296 | { |
2305 | { |
2297 | op->stats.food--; |
2306 | op->stats.food--; |
2298 | |
2307 | |
2299 | if (op->contr->digestion < 0) |
2308 | if (op->contr->digestion < 0) |
2300 | op->stats.food += op->contr->digestion; |
2309 | op->stats.food += op->contr->digestion; |
… | |
… | |
2327 | penalty = max (0, -op->contr->digestion); |
2336 | penalty = max (0, -op->contr->digestion); |
2328 | |
2337 | |
2329 | op->last_eat = 25 * (1 + bonus) / (max (0, op->contr->gen_hp) + penalty + 1); |
2338 | op->last_eat = 25 * (1 + bonus) / (max (0, op->contr->gen_hp) + penalty + 1); |
2330 | |
2339 | |
2331 | /* dms do not consume food */ |
2340 | /* dms do not consume food */ |
2332 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2341 | if (!op->flag [FLAG_WIZ]) |
2333 | op->stats.food--; |
2342 | op->stats.food--; |
2334 | } |
2343 | } |
2335 | |
2344 | |
2336 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2345 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2337 | { |
2346 | { |
2338 | object *flesh = 0; |
2347 | object *flesh = 0; |
2339 | |
2348 | |
2340 | for_inv_removable (op, tmp) |
2349 | for_inv_removable (op, tmp) |
2341 | { |
2350 | { |
2342 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
2351 | if (tmp->flag [FLAG_UNPAID]) |
2343 | continue; |
2352 | continue; |
2344 | |
2353 | |
2345 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2354 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2346 | { |
2355 | { |
2347 | op->statusmsg ("You blindly grab for a bite of food. " |
2356 | op->statusmsg ("You blindly grab for a bite of food. " |
… | |
… | |
2382 | op->contr->killer->destroy (); |
2391 | op->contr->killer->destroy (); |
2383 | } |
2392 | } |
2384 | } |
2393 | } |
2385 | |
2394 | |
2386 | /* killer should be set here already */ |
2395 | /* killer should be set here already */ |
2387 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2396 | if (op->stats.hp < 0 && !op->flag [FLAG_WIZ]) |
2388 | kill_player (op); |
2397 | kill_player (op); |
2389 | } |
2398 | } |
2390 | } |
2399 | } |
2391 | |
2400 | |
2392 | /* If the player should die (lack of hp, food, etc), we call this. |
2401 | /* If the player should die (lack of hp, food, etc), we call this. |
… | |
… | |
2587 | * difference. |
2596 | * difference. |
2588 | */ |
2597 | */ |
2589 | if (this_stat >= -50) |
2598 | if (this_stat >= -50) |
2590 | { |
2599 | { |
2591 | change_attr_value (&(dep->stats), i, -1); |
2600 | change_attr_value (&(dep->stats), i, -1); |
2592 | SET_FLAG (dep, FLAG_APPLIED); |
2601 | dep->set_flag (FLAG_APPLIED); |
2593 | new_draw_info (NDI_UNIQUE, 0, op, lose_msg[i]); |
2602 | new_draw_info (NDI_UNIQUE, 0, op, lose_msg[i]); |
2594 | op->update_stats (); |
2603 | op->update_stats (); |
2595 | lost_a_stat = 1; |
2604 | lost_a_stat = 1; |
2596 | } |
2605 | } |
2597 | } |
2606 | } |
… | |
… | |
2668 | |
2677 | |
2669 | force = get_archetype (FORCE_NAME); |
2678 | force = get_archetype (FORCE_NAME); |
2670 | /* 50 ticks should be enough time for the spell to abate */ |
2679 | /* 50 ticks should be enough time for the spell to abate */ |
2671 | force->speed = 0.1f; |
2680 | force->speed = 0.1f; |
2672 | force->speed_left = -5.f; |
2681 | force->speed_left = -5.f; |
2673 | SET_FLAG (force, FLAG_APPLIED); |
2682 | force->set_flag (FLAG_APPLIED); |
2674 | for (at = 0; at < NROFATTACKS; at++) |
2683 | for (at = 0; at < NROFATTACKS; at++) |
2675 | if (will_kill_again & (1 << at)) |
2684 | if (will_kill_again & (1 << at)) |
2676 | force->resist[at] = 100; |
2685 | force->resist[at] = 100; |
2677 | |
2686 | |
2678 | insert_ob_in_ob (force, op); |
2687 | insert_ob_in_ob (force, op); |
… | |
… | |
2700 | tmp->x = op->x, tmp->y = op->y; |
2709 | tmp->x = op->x, tmp->y = op->y; |
2701 | |
2710 | |
2702 | if (tmp->type == CONTAINER) |
2711 | if (tmp->type == CONTAINER) |
2703 | loot_object (tmp); /* empty container to ground */ |
2712 | loot_object (tmp); /* empty container to ground */ |
2704 | |
2713 | |
2705 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) |
2714 | if (!tmp->flag [FLAG_UNIQUE] && (tmp->flag [FLAG_STARTEQUIP] || tmp->flag [FLAG_NO_DROP] || !(rndm (3)))) |
2706 | { |
2715 | { |
2707 | if (tmp->nrof > 1) |
2716 | if (tmp->nrof > 1) |
2708 | { |
2717 | { |
2709 | tmp->decrease (rndm (1, tmp->nrof - 1)); |
2718 | tmp->decrease (rndm (1, tmp->nrof - 1)); |
2710 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2719 | insert_ob_in_map (tmp, op->map, NULL, 0); |
… | |
… | |
2800 | } |
2809 | } |
2801 | |
2810 | |
2802 | int |
2811 | int |
2803 | is_true_undead (object *op) |
2812 | is_true_undead (object *op) |
2804 | { |
2813 | { |
2805 | if (QUERY_FLAG (op->arch, FLAG_UNDEAD)) |
2814 | if (op->arch->flag [FLAG_UNDEAD]) |
2806 | return 1; |
2815 | return 1; |
2807 | |
2816 | |
2808 | return 0; |
2817 | return 0; |
2809 | } |
2818 | } |
2810 | |
2819 | |
… | |
… | |
2908 | |
2917 | |
2909 | if (who->type == PLAYER) |
2918 | if (who->type == PLAYER) |
2910 | player = 1; |
2919 | player = 1; |
2911 | |
2920 | |
2912 | else |
2921 | else |
2913 | friendly = QUERY_FLAG (who, FLAG_FRIENDLY); |
2922 | friendly = who->flag [FLAG_FRIENDLY]; |
2914 | |
2923 | |
2915 | /* search adjacent squares */ |
2924 | /* search adjacent squares */ |
2916 | for (i = 1; i < 9; i++) |
2925 | for (i = 1; i < 9; i++) |
2917 | { |
2926 | { |
2918 | x = who->x + freearr_x[i]; |
2927 | x = who->x + freearr_x[i]; |
… | |
… | |
2927 | if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) |
2936 | if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) |
2928 | continue; |
2937 | continue; |
2929 | |
2938 | |
2930 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
2939 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
2931 | { |
2940 | { |
2932 | if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) |
2941 | if ((player ||friendly) &&tmp->flag [FLAG_MONSTER] && !tmp->flag [FLAG_UNAGGRESSIVE]) |
2933 | return 1; |
2942 | return 1; |
2934 | else if (tmp->type == PLAYER) |
2943 | else if (tmp->type == PLAYER) |
2935 | { |
2944 | { |
2936 | /*don't let a hidden DM prevent you from hiding */ |
2945 | /*don't let a hidden DM prevent you from hiding */ |
2937 | if (!QUERY_FLAG (tmp, FLAG_WIZ) || tmp->contr->hidden == 0) |
2946 | if (!tmp->flag [FLAG_WIZ] || tmp->contr->hidden == 0) |
2938 | return 1; |
2947 | return 1; |
2939 | } |
2948 | } |
2940 | } |
2949 | } |
2941 | } |
2950 | } |
2942 | return 0; |
2951 | return 0; |
… | |
… | |
3011 | * and the exit-coordinates sp/hp must both be > 0. |
3020 | * and the exit-coordinates sp/hp must both be > 0. |
3012 | * => The intention here is to prevent abuse of the battleground- |
3021 | * => The intention here is to prevent abuse of the battleground- |
3013 | * feature (like pickable or hidden battleground tiles). */ |
3022 | * feature (like pickable or hidden battleground tiles). */ |
3014 | for (object *tmp = op->below; tmp; tmp = tmp->below) |
3023 | for (object *tmp = op->below; tmp; tmp = tmp->below) |
3015 | { |
3024 | { |
3016 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
3025 | if (tmp->flag [FLAG_IS_FLOOR]) |
3017 | { |
3026 | { |
3018 | if (QUERY_FLAG (tmp, FLAG_NO_PICK) |
3027 | if (tmp->flag [FLAG_NO_PICK] |
3019 | && tmp->type == BATTLEGROUND |
3028 | && tmp->type == BATTLEGROUND |
3020 | && tmp->name == shstr_battleground |
3029 | && tmp->name == shstr_battleground |
3021 | && EXIT_X (tmp) && EXIT_Y (tmp)) |
3030 | && EXIT_X (tmp) && EXIT_Y (tmp)) |
3022 | { |
3031 | { |
3023 | /* before we assign the exit, check if this is a teambattle */ |
3032 | /* before we assign the exit, check if this is a teambattle */ |
… | |
… | |
3181 | strcat (buf, "."); |
3190 | strcat (buf, "."); |
3182 | new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, who, buf); |
3191 | new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, who, buf); |
3183 | } |
3192 | } |
3184 | |
3193 | |
3185 | /* evtl. adding flags: */ |
3194 | /* evtl. adding flags: */ |
3186 | if (QUERY_FLAG (item, FLAG_XRAYS)) |
3195 | if (item->flag [FLAG_XRAYS]) |
3187 | SET_FLAG (skin, FLAG_XRAYS); |
3196 | skin->set_flag (FLAG_XRAYS); |
3188 | if (QUERY_FLAG (item, FLAG_STEALTH)) |
3197 | if (item->flag [FLAG_STEALTH]) |
3189 | SET_FLAG (skin, FLAG_STEALTH); |
3198 | skin->set_flag (FLAG_STEALTH); |
3190 | if (QUERY_FLAG (item, FLAG_SEE_IN_DARK)) |
3199 | if (item->flag [FLAG_SEE_IN_DARK]) |
3191 | SET_FLAG (skin, FLAG_SEE_IN_DARK); |
3200 | skin->set_flag (FLAG_SEE_IN_DARK); |
3192 | |
3201 | |
3193 | /* print message if there is one */ |
3202 | /* print message if there is one */ |
3194 | if (item->msg != NULL) |
3203 | if (item->msg != NULL) |
3195 | new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, who, item->msg); |
3204 | new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, who, item->msg); |
3196 | } |
3205 | } |
… | |
… | |
3238 | { |
3247 | { |
3239 | play_sound (sound_find ("generic_failure")); |
3248 | play_sound (sound_find ("generic_failure")); |
3240 | statusmsg (msg, color); |
3249 | statusmsg (msg, color); |
3241 | } |
3250 | } |
3242 | |
3251 | |
|
|
3252 | void |
|
|
3253 | object::failmsgf (const char *format, ...) |
|
|
3254 | { |
|
|
3255 | if (!contr) |
|
|
3256 | return; |
|
|
3257 | |
|
|
3258 | va_list ap; |
|
|
3259 | va_start (ap, format); |
|
|
3260 | contr->failmsg (vformat (format, ap)); |
|
|
3261 | va_end (ap); |
|
|
3262 | } |
|
|
3263 | |
|
|
3264 | void |
|
|
3265 | player::failmsgf (const char *format, ...) |
|
|
3266 | { |
|
|
3267 | va_list ap; |
|
|
3268 | va_start (ap, format); |
|
|
3269 | failmsg (vformat (format, ap)); |
|
|
3270 | va_end (ap); |
|
|
3271 | } |
|
|
3272 | |