Prev: 43830 Up: Map Next: 43998
43892: Handler: Tribesman
Handles a tribesman (sprite IDs 56 to 63). 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 43892 CALL BringActorCloser Bring the tribesman closer to the player if it is two or more rows away.
43895 CALL StoreEntity Remember the previous position of the tribesman.
43898 LD A,16 Set the width of the tribesman in Actor_Width to 16.
43900 LD (38573),A
43903 CALL MoveActor Work out the new position of the tribesman.
43906 LD BC,5903 Set the height of the tribesman in B to 23 and the width in C to 15.
43909 CALL SlideActorPastObjects Stop the tribesman passing through objects in the room.
43912 CALL ChooseTribesmanVelocity Choose a new velocity if the tribesman did not manage to move.
43915 LD (IX+3),E Set the X position of the tribesman.
43918 LD (IX+4),D Set the Y position of the tribesman.
43921 CALL AnimateActor Animate the tribesman.
Test whether the tribesman has touched the player.
43924 LD A,(IX+0) Fetch the sprite ID of the tribesman.
43927 RRCA Rotate right twice, so bit 2 is now in bit 0.
43928 RRCA
43929 AND %00000001 Keep only the direction bit (bit 0).
43931 LD D,A Stash the hit direction in D (used by TestActorHurtingPlayer).
43932 LD BC,3852 Set the reach used to test whether the tribesman is touching the player in BC to 3852.
43935 CALL TestActorHurtingPlayer Test whether the tribesman is hurting the player.
43938 JR NC,HandlerTribesman_Amulet Jump to HandlerTribesman_Amulet if the tribesman is not touching the player.
Throw the tribesman away from the player.
43940 LD A,(38658) Fetch the sprite ID of the player from ImmortalData.
43943 AND %00001000 Keep only the direction the player is facing (bit 3).
43945 JR Z,HandlerTribesman_ThrowLeft Jump to HandlerTribesman_ThrowLeft if the player is facing left.
43947 LD A,64 Set the X velocity in A to 64 (moving right).
HandlerTribesman_Throw 43949 LD BC,44068 Point BC at the table of tribesman velocities at TribesmanVelocities.
43952 CALL SetTribesmanVelocity Set the velocity of the tribesman.
43955 CALL PlayWarbleSound Play the warble sound.
Flash the tribesman and make a sound if an amulet piece is close.
HandlerTribesman_Amulet 43958 CALL TestAmuletProximity Test whether an amulet piece is close.
43961 JP NC,UpdateActor Jump to UpdateActor to update the tribesman if no amulet piece is close.
43964 LD C,A Stash the distance to the amulet piece in C.
43965 LD A,(38659) Fetch the room of the player from 38659.
43968 CP (IX+1) Compare with the room of the tribesman.
43971 JP NZ,UpdateActor Jump to UpdateActor to update the tribesman if it is in a different room to the player.
43974 LD A,C Fetch the distance to the amulet piece.
43975 CALL PlayAmuletPieceSound Play the amulet piece sound.
43978 LD A,(IX+5) Fetch the colour of the tribesman.
43981 PUSH AF Stash the colour on the stack.
43982 LD (IX+5),70 Set the colour of the tribesman to INK:YELLOW, PAPER:BLACK (BRIGHT) (bright yellow).
43986 CALL UpdateActor Update the tribesman.
43989 POP AF Restore the colour of the tribesman from the stack.
43990 LD (IX+5),A Set the colour of the tribesman.
43993 RET Return.
HandlerTribesman_ThrowLeft 43994 LD A,192 Set the X velocity in A to 192 (moving left).
43996 JR HandlerTribesman_Throw Jump to HandlerTribesman_Throw.
Prev: 43830 Up: Map Next: 43998