Prev: 897D Up: Map Next: 89ED
8988: Handle Frankenstein
The handler for Frankenstein (sprite IDs 74 to 77). He steers towards the player. If he touches the player while the player is holding the spanner (sprite ID 8B with attribute 45) then he is hit instead and the player is given 1000 points, otherwise TakeEnergyFromPlayer_Small takes some energy. The sprite comes from the bottom two bits of the counter at CounterLow. The tail at HandlerBoss_Move is also used by the other bosses.
Input
IX The Frankenstein entity
HandlerFrankenstein 8988 CALL StoreEntity Call StoreEntity to save the position of Frankenstein.
898B CALL CheckPlayerTouch Call CheckPlayerTouch to check whether the entity is touching the player.
898E DEC E Jump to HandlerFrankenstein_Steer if Frankenstein did not touch the player.
898F JR NZ,HandlerFrankenstein_Steer
8991 LD DE,$458B DE=458B (the attribute and the sprite ID of the spanner).
8994 CALL FindInventoryItem Call FindInventoryItem to look for the spanner in the inventory.
8997 JR NZ,HandlerFrankenstein_Hurt Jump to HandlerFrankenstein_Hurt if the player is not holding it.
8999 LD BC,$1000 BC=1000 (the points to add to the score).
899C CALL AddPointsToScore Call AddPointsToScore to add the points to the score.
899F JP PopCreature Jump to PopCreature to turn the creature into a pop.
HandlerFrankenstein_Hurt 89A2 CALL TakeEnergyFromPlayer_Small Call TakeEnergyFromPlayer_Small to take energy from the player.
HandlerFrankenstein_Steer 89A5 LD DE,($EA93) Fetch the position of the player from EA93.
89A9 CALL SteerCreature Call SteerCreature to steer the creature towards its target.
89AC LD A,($5E12) Fetch the counter from CounterLow.
89AF RRA Divide the counter by four.
89B0 RRA
89B1 AND %00000011 Keep only bits 0-1.
89B3 ADD A,$74 Add 74 to get the sprite ID of Frankenstein.
89B5 LD (IX+$00),A Update the sprite ID of Frankenstein.
89B8 LD DE,$3434 DE=3434 (the area).
This entry point is used by the routines at HandlerMummy, HandlerDracula and HandlerDevil.
The shared end of the handlers of the bosses. If the player is a character then the boss moves. If not, the boss moves away from the player.
HandlerBoss_Move 89BB LD A,($EA90) Fetch the sprite ID of the player from Player.
89BE CP $31 Jump to MoveCreature if the player is a character.
89C0 JP C,MoveCreature
89C3 LD DE,($EA93) Fetch the position of the player from EA93.
89C7 CALL SteerCreature Call SteerCreature to steer the creature towards its target.
89CA LD A,(IX+$08) Fetch the X velocity.
89CD NEG Reverse the direction of the X velocity.
89CF LD (IX+$08),A Update the X velocity.
89D2 LD C,A Keep the reversed X velocity in C.
89D3 LD A,(IX+$09) Fetch the Y velocity.
89D6 NEG Reverse the direction of the Y velocity.
89D8 LD (IX+$09),A Update the Y velocity.
89DB LD DE,$3434 DE=3434 (the area).
89DE AND C Jump to MoveCreature if the AND of the two velocities is not zero.
89DF JP NZ,MoveCreature
89E2 LD (IX+$08),$01 Set the X velocity to 01.
89E6 LD (IX+$09),$01 Set the Y velocity to 01.
89EA JP MoveCreature Jump to MoveCreature to move the creature.
Prev: 897D Up: Map Next: 89ED