Prev: 34861 Up: Map Next: 35078
34914: Handle Mummy
The handler for the mummy (sprite IDs 112 to 115). If the mummy touches the player then TakeEnergyFromPlayer_Small takes some energy. Then the mummy picks a target to steer towards with SteerCreature. If the leaf (ItemEntity_Leaf, the copy of Initialisation_Leaf) is in the room then it is the target, and when the mummy reaches it the leaf is moved to room 107. Otherwise, when bit 7 of offset 6 is reset and the red key (ItemEntity_Red_Key, the copy of Initialisation_Key_Red) is in the room, the mummy goes backwards and forwards between two waypoints that are kept at offsets 11 and 12 and when bit 7 is set (or the red key is not in the room) the target is the player. The sprite comes from the bottom two bits of the counter at CounterLow, and then HandlerBoss_Move does the rest.
Input
IX The mummy entity
HandlerMummy 34914 CALL StoreEntity Call StoreEntity to save the position of the mummy.
34917 CALL CheckPlayerTouch Call CheckPlayerTouch to check whether the entity is touching the player.
34920 DEC E Call TakeEnergyFromPlayer_Small if the mummy touched the player.
34921 CALL Z,TakeEnergyFromPlayer_Small
See if the leaf (ItemEntity_Leaf) is in the room, and if so make it the target.
34924 LD HL,60128 Point HL at the leaf at ItemEntity_Leaf.
34927 LD A,(HL) Fetch the sprite ID of the entity.
34928 AND A Jump to HandlerMummy_CheckFlags if the leaf is not in use.
34929 JR Z,HandlerMummy_CheckFlags
34931 INC HL Move HL on to the room of the entity.
34932 LD A,(HL) Fetch the room of the entity.
34933 CP (IX+1) Jump to HandlerMummy_CheckFlags if the leaf is in a different room to the mummy.
34936 JR NZ,HandlerMummy_CheckFlags
34938 INC HL Move HL on to the X position of the entity.
34939 INC HL
34940 LD E,(HL) Fetch the X position of the entity.
34941 INC HL Move HL on to the Y position of the entity.
34942 LD D,(HL) Fetch the Y position of the entity.
34943 JR HandlerMummy_Target Jump to HandlerMummy_Target to steer the mummy towards its target.
If bit 7 of the flags is set then the target is the player.
HandlerMummy_CheckFlags 34945 BIT 7,(IX+6) Jump to HandlerMummy_Player if bit 7 of offset 6 is set.
34949 JR NZ,HandlerMummy_Player
See if the red key (ItemEntity_Red_Key) is in the room.
34951 LD HL,60104 Point HL at the red key at ItemEntity_Red_Key.
34954 LD A,(HL) Fetch the sprite ID of the entity.
34955 AND A Jump to HandlerMummy_SeekPlayer if the red key is not in use.
34956 JR Z,HandlerMummy_SeekPlayer
34958 INC HL Move HL on to the room of the entity.
34959 LD A,(HL) Fetch the room of the entity.
34960 CP (IX+1) Jump to HandlerMummy_SeekPlayer if the red key is in a different room to the mummy.
34963 JR NZ,HandlerMummy_SeekPlayer
Steer towards the current waypoint.
34965 LD D,(IX+12) Fetch the Y position of the waypoint.
34968 LD E,(IX+11) Fetch the X position of the waypoint.
34971 CALL SteerCreature Call SteerCreature to steer the creature towards its target.
34974 LD A,C Fetch which of the axes have been reached.
34975 CP 3 Jump to HandlerMummy_NextWaypoint if the mummy is at the waypoint.
34977 JR Z,HandlerMummy_NextWaypoint
Choose the sprite and the area that the mummy can move in.
HandlerMummy_SetSprite 34979 LD A,(24082) Fetch the counter from CounterLow.
34982 RRA Divide the counter by four.
34983 RRA
34984 AND %00000011 Keep only bits 0-1.
34986 ADD A,112 Add 112 to get the sprite ID of the mummy.
34988 LD (IX+0),A Update the sprite ID of the mummy.
34991 LD DE,14392 DE=14392 (the area).
34994 JP HandlerBoss_Move Jump to HandlerBoss_Move to move the boss.
The mummy is at a waypoint, so change to the other one.
HandlerMummy_NextWaypoint 34997 BIT 6,(IX+6) Jump to HandlerMummy_FirstWaypoint if bit 6 of offset 6 is reset.
35001 JR Z,HandlerMummy_FirstWaypoint
35003 LD (IX+11),140 Set the X position of the waypoint to 140.
35007 LD (IX+12),104 Set the Y position of the waypoint to 104.
35011 RES 6,(IX+6) Reset bit 6 of offset 6.
35015 JR HandlerMummy_SetSprite Jump to HandlerMummy_SetSprite to choose the sprite of the mummy.
HandlerMummy_FirstWaypoint 35017 LD (IX+11),104 Set the X position of the waypoint to 104.
35021 LD (IX+12),56 Set the Y position of the waypoint to 56.
35025 SET 6,(IX+6) Set bit 6 of offset 6.
35029 JR HandlerMummy_SetSprite Jump to HandlerMummy_SetSprite to choose the sprite of the mummy.
Steer towards the leaf, and when the mummy gets there move it out of the way.
HandlerMummy_Target 35031 CALL SteerCreature Call SteerCreature to steer the creature towards its target.
35034 LD A,C Fetch which of the axes have been reached.
35035 CP 3 Jump to HandlerMummy_SetSprite if the mummy has not arrived.
35037 JR NZ,HandlerMummy_SetSprite
35039 PUSH IX Stash the mummy on the stack.
35041 LD IX,60128 Point IX at the leaf at ItemEntity_Leaf.
35045 LD A,(60049) Fetch the room of the player from PlayerRoom.
35048 CP (IX+1) Jump to HandlerMummy_Moved if the leaf is in a different room to the player.
35051 JR NZ,HandlerMummy_Moved
35053 CALL DrawEntity Call DrawEntity to draw the entity.
HandlerMummy_Moved 35056 POP IX Restore the mummy from the stack.
35058 LD A,107 Write 107 to the room of the leaf, to move it out of the way.
35060 LD (60129),A
35063 JR HandlerMummy_NextWaypoint Jump to HandlerMummy_NextWaypoint to change the mummy to its other waypoint.
There is nothing else to go for, so the target is the player.
HandlerMummy_SeekPlayer 35065 SET 7,(IX+6) Set bit 7 of offset 6.
HandlerMummy_Player 35069 LD DE,(60051) Fetch the position of the player from 60051.
35073 CALL SteerCreature Call SteerCreature to steer the creature towards its target.
35076 JR HandlerMummy_SetSprite Jump to HandlerMummy_SetSprite to choose the sprite of the mummy.
Prev: 34861 Up: Map Next: 35078