Prev: C3D7 Up: Map Next: C443
C3DF: Script Routine: (2B) Task-three entity action
Steer the task-three creature toward Berk while pursuit flags allow it.
Input
IX Address of complex state data for an entity
ScriptRoutine_TaskThreeSeekBerk C3DF BIT 0,(IX+$03) Is the current entity script-locked (bit 00 of IX+03)? If not, jump to ScriptRoutine_TaskThreeSeekBerk_ClearActiveAndSeekBerk.
C3E3 JR Z,ScriptRoutine_TaskThreeSeekBerk_ClearActiveAndSeekBerk
C3E5 LD A,($C2E4) Load A with the task-three byte (TaskThree_Workspace).
C3E8 OR A Is the task-three byte (TaskThree_Workspace) zero? If so, jump to ScriptRoutine_TaskThreeSeekBerk_ClearActiveAndSeekBerk.
C3E9 JR Z,ScriptRoutine_TaskThreeSeekBerk_ClearActiveAndSeekBerk
C3EB DEC A Step task-three byte back by one.
C3EC LD ($C2E4),A Set the task-three byte (TaskThree_Workspace).
C3EF LD A,(IX+$09) Load A with the current entity's direction / state.
C3F2 BIT 0,A Is bit 00 of the current entity's direction / state set? If so, jump to ScriptRoutine_TaskThreeSeekBerk_BuildRightWindow.
C3F4 JP NZ,ScriptRoutine_TaskThreeSeekBerk_BuildRightWindow
C3F7 BIT 1,A Is bit 01 of the current entity's direction / state set? If so, jump to ScriptRoutine_TaskThreeSeekBerk_BuildLeftWindow.
C3F9 JP NZ,ScriptRoutine_TaskThreeSeekBerk_BuildLeftWindow
C3FC BIT 2,A Is bit 02 of the current entity's direction / state set? If so, jump to ScriptRoutine_TaskThreeSeekBerk_MoveRoomUp.
C3FE JR NZ,ScriptRoutine_TaskThreeSeekBerk_MoveRoomUp
C400 BIT 3,A Is bit 03 of the current entity's direction / state set? If so, jump to ScriptRoutine_TaskThreeSeekBerk_MoveRoomDown.
C402 JR NZ,ScriptRoutine_TaskThreeSeekBerk_MoveRoomDown
Clear the seek latch and chase Berk by room: same room compares X; else move up or down toward him.
ScriptRoutine_TaskThreeSeekBerk_ClearActiveAndSeekBerk C404 RES 0,(IX+$03) Reset bit 00 of the current entity's flags byte 3.
C408 LD A,($7305) Load A with Berk's room-index copy (BerkRoomIndexCopy).
C40B CP (IX+$04) Is Berk in the same room as this entity (IX+04)? If so, jump to ScriptRoutine_TaskThreeSeekBerk_CompareBerkXEdges.
C40E JR Z,ScriptRoutine_TaskThreeSeekBerk_CompareBerkXEdges
C410 JR C,ScriptRoutine_TaskThreeSeekBerk_MoveRoomDown Jump to ScriptRoutine_TaskThreeSeekBerk_MoveRoomDown if the result underflowed.
Climb toward Berk: at room 04 arm Slimy (ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10); else rise when bit 02 is set, or run the climb script.
ScriptRoutine_TaskThreeSeekBerk_MoveRoomUp C412 LD A,(IX+$04) Load A with the current entity's room index.
C415 CP $04 Is the current entity's room index equal to 04? If so, jump to ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10.
C417 JP Z,ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10
C41A LD A,(IX+$09) Load A with the current entity's direction / state.
C41D BIT 2,A Is bit 02 of the current entity's direction / state set? If so, jump to ScriptRoutine_TaskThreeSeekBerk_TestOverlapThenRise.
C41F JR NZ,ScriptRoutine_TaskThreeSeekBerk_TestOverlapThenRise
C421 LD HL,$C330 Point HL at task-three table entry C330.
C424 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
Probe the path above with Test_EntityOverlap_AtDepth before rising into the next room.
ScriptRoutine_TaskThreeSeekBerk_TestOverlapThenRise C427 CALL Test_EntityOverlap_AtDepth Call Test_EntityOverlap_AtDepth to test collectible / room collision.
C42A JR NC,ScriptRoutine_TaskThreeSeekBerk_MaybeArmSlimyFromRise Jump to ScriptRoutine_TaskThreeSeekBerk_MaybeArmSlimyFromRise if the result did not underflow.
This entry point is used by the routine at ScriptRoutine_TaskThreeClearUpstairs.
Step down a room toward Berk, refresh the heater at Update_Heater, and continue the script.
ScriptRoutine_TaskThreeSeekBerk_IncRoomAndHeater C42C INC (IX+$05) Move this entity one character down.
C42F INC (IX+$06)
C432 INC (IX+$04) Advance this entity into the next room.
C435 CALL Update_Heater Call Update_Heater to update Heater.
C438 JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
Blocked rise: treat direction 1F as a door hit (TaskThree_DoorHitThenNextScript), otherwise arm Slimy at ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10.
ScriptRoutine_TaskThreeSeekBerk_MaybeArmSlimyFromRise C43B CP $1F Is the current entity's direction / state equal to 1F? If so, jump to TaskThree_DoorHitThenNextScript.
C43D JP Z,TaskThree_DoorHitThenNextScript
C440 JP ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10 Jump to ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10 to continue this routine.
Prev: C3D7 Up: Map Next: C443