![]() |
Routines |
| Prev: 8862 | Up: Map | Next: 897D |
|
The handler for Dracula (sprite IDs 7C to 7F). If Dracula touches the player then TakeEnergyFromPlayer_Small takes some energy. When the player is holding the crucifix (sprite ID 8A with attribute 46) Dracula heads away from the player, otherwise he heads towards the player when they are in the same room. If they are not, then about once every 0100 frames he goes to a random room, if the shape of that room (see GetRoomValue) is less than 03.
|
||||||||
| HandlerDracula | 8906 | CALL StoreEntity | Call StoreEntity to save the position of Dracula. | |||||
| 8909 | CALL CheckPlayerTouch | Call CheckPlayerTouch to check whether the entity is touching the player. | ||||||
| 890C | DEC E | Call TakeEnergyFromPlayer_Small if Dracula touched the player. | ||||||
| 890D | CALL Z,TakeEnergyFromPlayer_Small | |||||||
|
See if the player is holding the crucifix.
|
||||||||
| 8910 | LD DE,$468A | DE=468A (the attribute and the sprite ID of the crucifix). | ||||||
| 8913 | CALL FindInventoryItem | Call FindInventoryItem to look for the crucifix in the inventory. | ||||||
| 8916 | JR NZ,HandlerDracula_CheckRoom | Jump to HandlerDracula_CheckRoom if the player is not holding it. | ||||||
|
The player has the crucifix, so steer towards the player and then reverse the velocities to run away.
|
||||||||
| 8918 | LD DE,($EA93) | Fetch the position of the player from EA93. | ||||||
| 891C | CALL SteerCreature | Call SteerCreature to steer the creature towards its target. | ||||||
| 891F | LD A,(IX+$08) | Fetch the X velocity. | ||||||
| 8922 | NEG | Reverse the direction of the X velocity. | ||||||
| 8924 | LD (IX+$08),A | Update the X velocity. | ||||||
| 8927 | LD A,(IX+$09) | Fetch the Y velocity. | ||||||
| 892A | NEG | Reverse the direction of the Y velocity. | ||||||
| 892C | LD (IX+$09),A | Update the Y velocity. | ||||||
| 892F | JR HandlerDracula_SetSprite | Jump to HandlerDracula_SetSprite to choose the sprite of Dracula. | ||||||
|
Check whether Dracula is in the same room as the player.
|
||||||||
| HandlerDracula_CheckRoom | 8931 | LD A,($EA91) | Fetch the room of the player from PlayerRoom. | |||||
| 8934 | CP (IX+$01) | Jump to HandlerDracula_OtherRoom if Dracula is in a different room. | ||||||
| 8937 | JR NZ,HandlerDracula_OtherRoom | |||||||
| 8939 | LD DE,($EA93) | Fetch the position of the player from EA93. | ||||||
| 893D | CALL SteerCreature | Call SteerCreature to steer the creature towards its target. | ||||||
|
Choose the sprite and the area that Dracula can move in.
|
||||||||
| HandlerDracula_SetSprite | 8940 | LD A,($5E12) | Fetch the counter from CounterLow. | |||||
| 8943 | RRA | Divide the counter by four. | ||||||
| 8944 | RRA | |||||||
| 8945 | AND %00000011 | Keep only bits 0-1. | ||||||
| 8947 | ADD A,$7C | Add 7C to get the sprite ID of Dracula. | ||||||
| 8949 | LD (IX+$00),A | Update the sprite ID of Dracula. | ||||||
| 894C | LD DE,$3434 | DE=3434 (the area). | ||||||
| 894F | JP HandlerBoss_Move | Jump to HandlerBoss_Move to move the boss. | ||||||
|
Dracula is in a different room, so every so often send him to a random one.
|
||||||||
| HandlerDracula_OtherRoom | 8952 | LD (IX+$0B),$68 | Set the X position of the waypoint to 68. | |||||
| 8956 | LD (IX+$0C),$68 | Set the Y position of the waypoint to 68. | ||||||
| 895A | CALL SteerCreature | Call SteerCreature to steer the creature towards its target. | ||||||
| 895D | LD A,($5C78) | Fetch the low byte of FRAMES. | ||||||
| 8960 | AND A | Jump to HandlerDracula_SetSprite unless the low byte of FRAMES is zero, which happens once in every 0100 frames. | ||||||
| 8961 | JP NZ,HandlerDracula_SetSprite | |||||||
| 8964 | LD A,R | Fetch a random number (from the refresh register). | ||||||
| 8966 | AND %01111111 | Keep only bits 0-6. | ||||||
| 8968 | LD C,A | Keep the random room in C. | ||||||
| 8969 | CALL GetRoomValue | Call GetRoomValue to look up the value for the room. | ||||||
| 896C | CP $03 | Jump to HandlerDracula_SetSprite if the value for the room is 03 or more. | ||||||
| 896E | JP NC,HandlerDracula_SetSprite | |||||||
| 8971 | LD A,($EA91) | Fetch the room of the player from PlayerRoom. | ||||||
| 8974 | CP C | Jump to HandlerDracula_SetSprite if the random room is the room of the player. | ||||||
| 8975 | JP Z,HandlerDracula_SetSprite | |||||||
| 8978 | LD (IX+$01),C | Update the room of Dracula. | ||||||
| 897B | JR HandlerDracula_SetSprite | Jump to HandlerDracula_SetSprite to choose the sprite of Dracula. | ||||||
| Prev: 8862 | Up: Map | Next: 897D |