Prev: 42204 Up: Map Next: 42320
42220: Move Hunter
The handler for entity types 96 to 99, which are enemies that hunt for the robot. The enemy heads for the robot, and chooses a new direction when it is blocked.
Input
IX Entity
MoveHunter 42220 CALL ToggleSprite Move on to the next sprite using ToggleSprite.
42223 CALL RemoveDistantEntity Remove the enemy if it is far away from the camera using RemoveDistantEntity.
42226 CALL GetPosition Fetch the position of the enemy.
42229 LD B,64 The enemy can take up to 64 steps in this frame.
MoveHunter_Step 42231 CALL TryMove Take a step using TryMove.
42234 JR NZ,MoveHunter_Blocked Jump if the enemy has been blocked by a cell.
42236 CALL CheckEnemyOverlap Check whether another enemy is in the way using CheckEnemyOverlap.
42239 JR C,MoveHunter_Reverse Jump if there is.
42241 LD A,E Jump if the enemy is not at the start of a cell.
42242 OR L
42243 JR NZ,MoveHunter_Store
42245 CALL FindDirectionToRobot Choose a direction towards the robot using FindDirectionToRobot...
42248 LD (IX+7),A ...and store it.
42251 LD A,B Loop back to take another step if there are steps left.
42252 AND A
42253 JR NZ,MoveHunter_Step
MoveHunter_Store 42255 CALL SetPosition Store the new position of the enemy.
42258 CALL FaceEnemy Face the enemy in the direction that it is heading using FaceEnemy.
42261 JP AddEntity Draw the enemy using AddEntity.
MoveHunter_Blocked 42264 PUSH HL Save the Y position.
42265 LD HL,(38446) Fetch the address of the cell that blocked the enemy...
42268 LD A,(HL) ...and its type.
42269 AND 15 Keep the current type of the cell.
42271 JR MoveHunter_Turn Jump to choose a direction.
This code is never run. It would have let the enemy pick up programs, like MoveThief.
MoveHunter_Unused 42273 CP 6 Jump to pick up the item if the cell is type 6...
42275 JR Z,MoveHunter_Unused_Pick
42277 CP 7 ...or type 7.
42279 JR NZ,MoveHunter_Turn
MoveHunter_Unused_Pick 42281 LD B,A Keep the type.
42282 LD A,(IX+8) Fetch the item that the enemy is carrying.
42285 AND A Jump if it is carrying one already.
42286 JR NZ,MoveHunter_Turn
42288 LD (IX+8),B Store the item that it has picked up.
42291 CALL EmptyCell Remove it from the cell using EmptyCell.
42294 POP HL Restore the Y position.
42295 JR MoveHunter_Store Carry on.
MoveHunter_Turn 42297 POP HL Restore the Y position.
42298 CALL FindDirectionToRobot Choose a direction towards the robot using FindDirectionToRobot...
42301 LD (IX+7),A ...and store it.
42304 JP AddEntity Draw the enemy using AddEntity.
The enemy is in the way of another enemy.
MoveHunter_Reverse 42307 CALL ReverseDirection Turn the enemy round using ReverseDirection.
42310 CALL FaceEnemy Face the enemy in the direction that it is heading using FaceEnemy.
42313 CALL AddEntity Draw the enemy using AddEntity.
42316 RET NC Return if it was not drawn.
42317 JP MakeBumpSound Otherwise make a sound using MakeBumpSound.
Prev: 42204 Up: Map Next: 42320