Prev: CC31 Up: Map Next: CCAB
CC37: Guards follow suspicious character
This routine decides whether the given vischar should pursue the hero.
The commandant can see through the hero's disguise if he's wearing the guard's uniform, but other guards do not. Bribed characters will ignore the hero. When outdoors, line of sight checking is used to determine if the hero will be pursued. If the red_flag is in effect the hero will be pursued, otherwise he will just be hassled.
Input
Used by the routine at automatics.
I:IY Pointer to visible character.
guards_follow_suspicious_character CC37 PUSH IY Copy vischar pointer into HL
CC39 POP HL
CC3A LD A,(HL) Fetch the character index
Wearing the uniform stops anyone but the commandant from pursuing the hero.
CC3B AND A Is it character_0_COMMANDANT?
CC3C JR Z,gfsc_chk_bribe Jump if so (the commandant sees through the disguise)
CC3E LD A,($8015) Read the bottom byte of the hero's sprite set pointer
CC41 LD DE,$CEA6 Point DE at the guard sprite set
CC44 CP E Return if they match
CC45 RET Z
If this (hostile) character saw the bribe being used then ignore the hero.
gfsc_chk_bribe CC46 INC L Advance HL to point at vischar.flags
CC47 LD A,(HL) Fetch vischar.flags
CC48 CP $04 Is it vischar_PURSUIT_SAW_BRIBE?
CC4A RET Z Return if the bribe was seen
Do line of sight checking when outdoors.
CC4B DEC L Rewind HL to point at vischar.character
CC4C LD A,L Point HL at vischar.mi.pos
CC4D ADD A,$0F
CC4F LD L,A
CC50 LD DE,$81B2 Point DE at tinypos_stash_x
CC53 LD A,($68A0) If the global current room index is room_0_OUTDOORS...
CC56 AND A
CC57 JP NZ,gfsc_chk_flag
CC5A CALL pos_to_tinypos Scale down vischar's map position (HL) and assign the result to tinypos_stash (DE). DE is updated to point after tinypos_stash on return
CC5D LD HL,$81B8 Point HL at hero_map_position.x
CC60 LD DE,$81B2 Point DE at tinypos_stash_x
CC63 LD A,(IY+$0E) Get this vischar's direction
Check for TL/BR directions.
CC66 RRA Shift out the bottom direction bit into carry
CC67 LD C,A Save (rotated direction byte) in C
CC68 JR C,gfsc_chk_seen_x Jump if not TL or BR
Handle TL/BR directions.
Does the hero approximately match our Y coordinate?
gfsc_chk_seen_y CC6A INC HL Advance HL to hero_map_position.y
CC6B INC DE Advance DE to tinypos_stash_y
CC6C LD A,(DE) Fetch tinypos_stash_y
CC6D DEC A Return if (tinypos_stash_y - 1) >= hero_map_position.y
CC6E CP (HL)
CC6F RET NC
CC70 ADD A,$02 Return if (tinypos_stash_y + 1) < hero_map_position.y
CC72 CP (HL)
CC73 RET C
Are we facing the hero?
CC74 DEC HL Rewind to hero_map_position_x
CC75 DEC DE Rewind to tinypos_stash_x
CC76 LD A,(DE) Set carry if tinypos_stash_x < hero_map_position_x
CC77 CP (HL)
CC78 BIT 0,C Check bit 1 of direction byte (direction_BOTTOM_*?)
CC7A JR NZ,guards_follow_suspicious_character_0 Jump if set?
CC7C CCF Otherwise invert the carry flag
guards_follow_suspicious_character_0 CC7D RET C Return if set
CC7E JR gfsc_chk_flag (else)
Handle TR/BL directions.
Does the hero approximately match our X coordinate?
gfsc_chk_seen_x CC80 LD A,(DE) Fetch tinypos_stash_x
CC81 DEC A Return if (tinypos_stash_x - 1) >= hero_map_position_x
CC82 CP (HL)
CC83 RET NC
CC84 ADD A,$02 Return if (tinypos_stash_x + 1) < hero_map_position_x
CC86 CP (HL)
CC87 RET C
Are we facing the hero?
CC88 INC HL Advance to hero_map_position_y
CC89 INC DE Advance to tinypos_stash_y
CC8A LD A,(DE) Set carry if tinypos_stash_y < hero_map_position_y
CC8B CP (HL)
CC8C BIT 0,C Check bit 1 of direction byte (direction_BOTTOM_*?)
CC8E JR NZ,guards_follow_suspicious_character_1 Jump if set?
CC90 CCF Otherwise invert the carry flag
guards_follow_suspicious_character_1 CC91 RET C Return if set
gfsc_chk_flag CC92 LD A,($A138) Is red_flag set?
CC95 AND A
CC96 JR NZ,gfsc_bell Jump if so
Hostiles *not* in guard towers hassle the hero.
CC98 LD A,(IY+$13) Fetch vischar.mi.pos.height
CC9B CP $20 Return if it's 32 or greater
CC9D RET NC
CC9E LD (IY+$01),$02 Set vischar's flags to vischar_PURSUIT_HASSLE
CCA2 RET Return
gfsc_bell CCA3 XOR A Make the bell ring perpetually
CCA4 LD ($A130),A
CCA7 CALL hostiles_pursue Call hostiles_pursue
CCAA RET Return
Prev: CC31 Up: Map Next: CCAB