Prev: 41496 Up: Map Next: 41645
41602: Find Direction To Robot
Used by the routines at MoveThief and MoveHunter.
Chooses a direction for an enemy, at random, that heads towards the robot in either the X direction or the Y direction.
Input
IX Entity
Output
A Direction (0 to 3)
FindDirectionToRobot 41602 LD A,(38423) Fetch the random number.
41605 CP 128 Jump to use the Y direction if the number is below 128.
41607 JR C,FindDirectionToRobot_Y
41609 LD A,(38546) Fetch the X cell of the camera...
41612 SUB (IX+2) ...and subtract the X cell of the entity.
41615 AND 63 Limit the difference to 0-63.
41617 CP 32 Jump if the robot is less than 32 cells ahead.
41619 JR C,FindDirectionToRobot_DirectionTwo
41621 LD A,0 Otherwise use direction zero...
41623 RET ...and return.
FindDirectionToRobot_DirectionTwo 41624 LD A,2 Use direction two...
41626 RET ...and return.
FindDirectionToRobot_Y 41627 LD A,(38548) Fetch the Y cell of the camera...
41630 SUB (IX+4) ...and subtract the Y cell of the entity.
41633 AND 63 Limit the difference to 0-63.
41635 CP 32 Jump if the robot is less than 32 cells ahead.
41637 JR C,FindDirectionToRobot_DirectionOne
41639 LD A,3 Otherwise use direction three...
41641 RET ...and return.
FindDirectionToRobot_DirectionOne 41642 LD A,1 Use direction one...
41644 RET ...and return.
Prev: 41496 Up: Map Next: 41645