Prev: 33997 Up: Map Next: 34200
34150: Check Weapon Hit
Checks whether the weapon of the player is touching an entity. The weapon touches an entity if it is in the same room and within 11 pixels of it on both axes. When it touches, the weapon is flagged by setting its byte at offset 2 to 1.
Input
IX The entity to check
Output
E 1 if the weapon touches the entity, otherwise 0
CheckWeaponHit 34150 LD A,(60057) Fetch the room of the weapon from 60057.
34153 LD E,0 Set the result in E to 0 (not touching).
34155 CP (IX+1) Compare the room of the weapon with the room of the entity.
34158 RET NZ Return if they are in different rooms.
34159 LD A,(60056) Fetch the sprite ID of the weapon from PlayerWeapon.
34162 AND A Return if there is no weapon.
34163 RET Z
34164 LD A,(60059) Fetch the X position of the weapon from 60059.
34167 SUB (IX+3) Subtract the X position of the entity.
34170 JP P,CheckWeaponHit_Test_X Jump to CheckWeaponHit_Test_X if the difference is positive.
34173 NEG Make the difference positive.
CheckWeaponHit_Test_X 34175 CP 12 Return if the weapon is too far away on the X axis.
34177 RET NC
34178 LD A,(60060) Fetch the Y position of the weapon from 60060.
34181 SUB (IX+4) Subtract the Y position of the entity.
34184 JP P,CheckWeaponHit_Test_Y Jump to CheckWeaponHit_Test_Y if the difference is positive.
34187 NEG Make the difference positive.
CheckWeaponHit_Test_Y 34189 CP 12 Return if the weapon is too far away on the Y axis.
34191 RET NC
34192 LD A,1 Flag that the weapon has hit an entity.
34194 LD (60058),A
34197 LD E,1 Set the result in E to 1 (touching).
34199 RET Return.
Prev: 33997 Up: Map Next: 34200