Prev: AB36 Up: Map Next: ABDE
AB74: Handler: Tribesman
Handles a tribesman (sprite IDs 38 to 3F). Bit 2 of the sprite ID is set when the tribesman is facing right.
A tribesman wanders about the room with the velocity chosen by ChooseTribesmanVelocity. If it touches the player then it hurts the player and is thrown away (see SetTribesmanVelocity). When a tribesman is close to an amulet piece which has not been collected (see TestAmuletProximity) it flashes yellow and plays a sound.
Input
IX Actor record of the tribesman
HandlerTribesman AB74 CALL BringActorCloser Bring the tribesman closer to the player if it is two or more rows away.
AB77 CALL StoreEntity Remember the previous position of the tribesman.
AB7A LD A,$10 Set the width of the tribesman in Actor_Width to 10.
AB7C LD ($96AD),A
AB7F CALL MoveActor Work out the new position of the tribesman.
AB82 LD BC,$170F Set the height of the tribesman in B to 17 and the width in C to 0F.
AB85 CALL SlideActorPastObjects Stop the tribesman passing through objects in the room.
AB88 CALL ChooseTribesmanVelocity Choose a new velocity if the tribesman did not manage to move.
AB8B LD (IX+$03),E Set the X position of the tribesman.
AB8E LD (IX+$04),D Set the Y position of the tribesman.
AB91 CALL AnimateActor Animate the tribesman.
Test whether the tribesman has touched the player.
AB94 LD A,(IX+$00) Fetch the sprite ID of the tribesman.
AB97 RRCA Rotate right twice, so bit 2 is now in bit 0.
AB98 RRCA
AB99 AND %00000001 Keep only the direction bit (bit 0).
AB9B LD D,A Stash the hit direction in D (used by TestActorHurtingPlayer).
AB9C LD BC,$0F0C Set the reach used to test whether the tribesman is touching the player in BC to 0F0C.
AB9F CALL TestActorHurtingPlayer Test whether the tribesman is hurting the player.
ABA2 JR NC,HandlerTribesman_Amulet Jump to HandlerTribesman_Amulet if the tribesman is not touching the player.
Throw the tribesman away from the player.
ABA4 LD A,($9702) Fetch the sprite ID of the player from ImmortalData.
ABA7 AND %00001000 Keep only the direction the player is facing (bit 3).
ABA9 JR Z,HandlerTribesman_ThrowLeft Jump to HandlerTribesman_ThrowLeft if the player is facing left.
ABAB LD A,$40 Set the X velocity in A to 40 (moving right).
HandlerTribesman_Throw ABAD LD BC,$AC24 Point BC at the table of tribesman velocities at TribesmanVelocities.
ABB0 CALL SetTribesmanVelocity Set the velocity of the tribesman.
ABB3 CALL PlayWarbleSound Play the warble sound.
Flash the tribesman and make a sound if an amulet piece is close.
HandlerTribesman_Amulet ABB6 CALL TestAmuletProximity Test whether an amulet piece is close.
ABB9 JP NC,UpdateActor Jump to UpdateActor to update the tribesman if no amulet piece is close.
ABBC LD C,A Stash the distance to the amulet piece in C.
ABBD LD A,($9703) Fetch the room of the player from 9703.
ABC0 CP (IX+$01) Compare with the room of the tribesman.
ABC3 JP NZ,UpdateActor Jump to UpdateActor to update the tribesman if it is in a different room to the player.
ABC6 LD A,C Fetch the distance to the amulet piece.
ABC7 CALL PlayAmuletPieceSound Play the amulet piece sound.
ABCA LD A,(IX+$05) Fetch the colour of the tribesman.
ABCD PUSH AF Stash the colour on the stack.
ABCE LD (IX+$05),$46 Set the colour of the tribesman to INK:YELLOW, PAPER:BLACK (BRIGHT) (bright yellow).
ABD2 CALL UpdateActor Update the tribesman.
ABD5 POP AF Restore the colour of the tribesman from the stack.
ABD6 LD (IX+$05),A Set the colour of the tribesman.
ABD9 RET Return.
HandlerTribesman_ThrowLeft ABDA LD A,$C0 Set the X velocity in A to C0 (moving left).
ABDC JR HandlerTribesman_Throw Jump to HandlerTribesman_Throw.
Prev: AB36 Up: Map Next: ABDE