Prev: 43777 Up: Map Next: 43892
43830: Test Actor Hurting Player
Tests whether an actor is touching the player, and if so whether the actor hurts the player. The test is only made when the player has the normal colour of 71 (see TestOrchidTouched) and is in the same room as the actor.
If the player is walking, or is attacking in the direction away from the actor, then they are hit and the direction they are hit in is written to 38660 (1 if bit 0 of D is set, or 2 otherwise). If the player is attacking towards the actor then the actor is hit and no hit direction is written.
Input
B How far above the actor the player can be
C How far to the right of the actor the player can be
D Bit 0 is set if the hit direction should be 1
IX Actor record
Output
F Carry flag set if the actor is touching the player
TestActorHurtingPlayer 43830 LD A,(38663) Fetch the colour of the player from 38663.
43833 SUB 71 Subtract 71 (the normal colour).
43835 AND A Return if the player does not have the normal colour.
43836 RET NZ
This entry point is used by the routine at HandlerGuardian.
TestActorHurtingPlayer_Room 43837 LD A,(38659) Fetch the room of the player from 38659.
43840 SUB (IX+1) Subtract the room of the actor.
43843 AND A Return if the actor is in a different room to the player.
43844 RET NZ
43845 CALL TestPlayerTouchingActor Test whether the player is touching the actor.
See Immunity.
43848 RET NC Return if the player is not touching the actor.
43849 LD A,(38658) Fetch the sprite ID of the player from ImmortalData.
43852 SUB 16 Subtract 16 (the first Sabreman sprite ID).
43854 CP 16 Jump to TestActorHurtingPlayer_Hit if the player is walking.
43856 JR C,TestActorHurtingPlayer_Hit
43858 BIT 3,A Jump to TestActorHurtingPlayer_Right if the player is attacking to the right (bit 3 of the sprite ID is set).
43860 JR NZ,TestActorHurtingPlayer_Right
The player is attacking to the left.
43862 LD A,(38661) Fetch the X position of the player from 38661.
43865 SUB (IX+3) Subtract the X position of the actor.
43868 JR NC,TestActorHurtingPlayer_Touching Jump to TestActorHurtingPlayer_Touching if the actor is to the left of the player.
Hurt the player.
TestActorHurtingPlayer_Hit 43870 BIT 0,D Test whether the hit direction should be 1 (bit 0 of D).
43872 LD A,1 Set the hit direction in A to 1.
43874 JR NZ,TestActorHurtingPlayer_Direction Jump to TestActorHurtingPlayer_Direction if bit 0 of D is set.
43876 INC A Set the hit direction in A to 2.
TestActorHurtingPlayer_Direction 43877 LD (38660),A Store the hit direction in 38660.
TestActorHurtingPlayer_Touching 43880 SCF Set the carry flag (the actor is touching the player).
43881 RET Return.
The player is attacking to the right.
TestActorHurtingPlayer_Right 43882 LD A,(38661) Fetch the X position of the player from 38661.
43885 SUB (IX+3) Subtract the X position of the actor.
43888 JR C,TestActorHurtingPlayer_Touching Jump to TestActorHurtingPlayer_Touching if the actor is to the right of the player.
43890 JR TestActorHurtingPlayer_Hit Jump to TestActorHurtingPlayer_Hit to hurt the player.
Prev: 43777 Up: Map Next: 43892