Prev: 50143 Up: Map Next: 50518
50243: Script Routine: (45) Task-three entity action
Clear the upstairs event bit, then resume the task-three script.
Input
IX Address of complex state data for an entity
ScriptRoutine_TaskThreeClearUpstairs 50243 LD A,(29363) Load A with the game event flags (GameEventFlags).
50246 RES 4,A Clear bit 4 of the flag byte in A.
50248 LD (29363),A Set the game event flags (GameEventFlags).
50251 JR ScriptRoutine_TaskThreeSeekBerk_IncRoomAndHeater Jump to ScriptRoutine_TaskThreeSeekBerk_IncRoomAndHeater to continue this routine.
This entry point is used by the routine at ScriptRoutine_TaskThreeSeekBerk.
Descend toward Berk: at room 2 arm Slimy (ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10); else fall when bit 3 is set, or run the descend script.
ScriptRoutine_TaskThreeSeekBerk_MoveRoomDown 50253 LD A,(IX+4) Load A with the current entity's room index.
50256 CP 2 Is the current entity's room index equal to 2? If so, jump to ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10.
50258 JP Z,ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10
50261 LD A,(IX+9) Load A with the current entity's direction / state.
50264 BIT 3,A Is bit 3 of the current entity's direction / state set? If so, jump to ScriptRoutine_TaskThreeSeekBerk_TestCameraThenFall.
50266 JR NZ,ScriptRoutine_TaskThreeSeekBerk_TestCameraThenFall
50268 LD HL,49978 Point HL at task-three table entry 49978.
50271 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
Probe with Clamp_CameraPosition, then fall one room toward Berk and refresh the heater.
ScriptRoutine_TaskThreeSeekBerk_TestCameraThenFall 50274 CALL Clamp_CameraPosition Call Clamp_CameraPosition to clamp the camera position.
50277 JR NC,ScriptRoutine_TaskThreeSeekBerk_MaybeArmSlimyFromFall Jump to ScriptRoutine_TaskThreeSeekBerk_MaybeArmSlimyFromFall if the result did not underflow.
50279 DEC (IX+5) Move this entity one character up.
50282 DEC (IX+6)
50285 DEC (IX+4) Move this entity back one room.
50288 CALL Update_Heater Call Update_Heater to update Heater.
50291 JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
Blocked fall: treat direction 31 as a door hit (TaskThree_DoorHitThenNextScript), otherwise arm Slimy at ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10.
ScriptRoutine_TaskThreeSeekBerk_MaybeArmSlimyFromFall 50294 CP 31 Is the current entity's direction / state equal to 31? If so, jump to TaskThree_DoorHitThenNextScript.
50296 JP Z,TaskThree_DoorHitThenNextScript
50299 JP ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10 Jump to ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10 to continue this routine.
This entry point is used by the routine at ScriptRoutine_TaskThreeSeekBerk.
Same-room chase: compare Berk's X band (BerkXCoordinateCopy/BerkXExtentCopy) and walk right, left, or stop.
ScriptRoutine_TaskThreeSeekBerk_CompareBerkXEdges 50302 LD A,(29443) Load A with Berk's X-coordinate copy (BerkXCoordinateCopy).
50305 LD C,A Keep Berk's X coordinate in C.
50306 LD A,(IX+8) Load A with the current entity's x-extent.
50309 CP C Is this entity's x-extent left of Berk's X-coordinate copy (BerkXCoordinateCopy)? If so, jump to ScriptRoutine_TaskThreeSeekBerk_BuildRightWindow.
50310 JR C,ScriptRoutine_TaskThreeSeekBerk_BuildRightWindow
50312 LD A,(29444) Load A with Berk's X-extent copy (BerkXExtentCopy).
50315 CP (IX+7) Is Berk's X-extent copy left of this entity's x (IX+7)? If so, jump to ScriptRoutine_TaskThreeSeekBerk_BuildLeftWindow.
50318 JR C,ScriptRoutine_TaskThreeSeekBerk_BuildLeftWindow
50320 JP TaskThree_DoorHitThenNextScript Jump to TaskThree_DoorHitThenNextScript to finish this handler.
This entry point is used by the routine at ScriptRoutine_TaskThreeSeekBerk.
Build the right-side Berk window into 49894 and run the peek script when he sits in that band.
ScriptRoutine_TaskThreeSeekBerk_BuildRightWindow 50323 LD A,(29445) Load A with Berk's room-index copy (BerkRoomIndexCopy).
50326 CP (IX+4) Is Berk in the same room as this entity (IX+4)? If not, jump to ScriptRoutine_TaskThreeSeekBerk_WalkRight.
50329 JR NZ,ScriptRoutine_TaskThreeSeekBerk_WalkRight
50331 OR A Is A zero? If so, jump to ScriptRoutine_TaskThreeSeekBerk_WalkRight.
50332 JR Z,ScriptRoutine_TaskThreeSeekBerk_WalkRight
50334 LD A,(IX+8) Load A with the current entity's x-extent.
50337 ADD A,3 Add 3 to A (adjust a task phase/index).
50339 LD C,A Keep the index in C.
50340 ADD A,4 Add 4 to A (step a coordinate/index).
50342 LD B,A Keep a copy of A in B.
50343 LD (49894),BC Store BC in the task-three word (49894).
50347 LD A,(29443) Load A with Berk's X-coordinate copy (BerkXCoordinateCopy).
50350 CP B Is Berk's X-coordinate copy (BerkXCoordinateCopy) at or beyond this entity's x-extent? If so, jump to ScriptRoutine_TaskThreeSeekBerk_WalkRight.
50351 JR NC,ScriptRoutine_TaskThreeSeekBerk_WalkRight
50353 CP C Is Berk's X-coordinate copy (BerkXCoordinateCopy) left of this entity's x-extent? If so, jump to ScriptRoutine_TaskThreeSeekBerk_WalkRight.
50354 JR C,ScriptRoutine_TaskThreeSeekBerk_WalkRight
50356 LD HL,50014 Point HL at task-three table entry 50014.
50359 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
Walk right toward Berk until the right edge (182), then arm Slimy or keep stepping.
ScriptRoutine_TaskThreeSeekBerk_WalkRight 50362 LD A,(IX+8) Load A with the current entity's x-extent.
50365 CP 182 Is the current entity's x-extent less than 182? If not, jump to ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange06.
50367 JR NC,ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange06
50369 BIT 0,(IX+9) Is bit 0 of the current entity's direction / state set? If so, jump to ScriptRoutine_TaskThreeSeekBerk_TestBelowThenIncX.
50373 JR NZ,ScriptRoutine_TaskThreeSeekBerk_TestBelowThenIncX
50375 LD HL,49948 Point HL at task-three table entry 49948.
50378 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
If the way below is clear (Test_EntityBelow), step right and refresh the heater.
ScriptRoutine_TaskThreeSeekBerk_TestBelowThenIncX 50381 CALL Test_EntityBelow Call Test_EntityBelow to test whether an entity is below.
50384 JR NC,ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange06 Jump to ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange06 if the result did not underflow.
50386 INC (IX+7) Move this entity one character right.
50389 INC (IX+8)
50392 CALL Update_Heater Call Update_Heater to update Heater.
50395 JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
This entry point is used by the routine at ScriptRoutine_TaskThreeSeekBerk.
Build the left-side Berk window into 49894 and run the peek script when he sits in that band.
ScriptRoutine_TaskThreeSeekBerk_BuildLeftWindow 50398 LD A,(29445) Load A with Berk's room-index copy (BerkRoomIndexCopy).
50401 CP (IX+4) Is Berk in the same room as this entity (IX+4)? If not, jump to ScriptRoutine_TaskThreeSeekBerk_WalkLeft.
50404 JR NZ,ScriptRoutine_TaskThreeSeekBerk_WalkLeft
50406 OR A Is A zero? If so, jump to ScriptRoutine_TaskThreeSeekBerk_WalkLeft.
50407 JR Z,ScriptRoutine_TaskThreeSeekBerk_WalkLeft
50409 LD A,(IX+7) Load A with the current entity's x-coordinate.
50412 SUB 3 Subtract 3 from A.
50414 LD C,A Keep the delta in C.
50415 SUB 3 Subtract 3 from A.
50417 LD B,A Keep a copy of A in B.
50418 LD (49894),BC Store BC in the task-three word (49894).
50422 LD A,(29444) Load A with Berk's X-extent copy (BerkXExtentCopy).
50425 CP B Is Berk's X-extent copy (BerkXExtentCopy) left of the entity's x (IX+7)? If so, jump to ScriptRoutine_TaskThreeSeekBerk_WalkLeft.
50426 JR C,ScriptRoutine_TaskThreeSeekBerk_WalkLeft
50428 CP C Is Berk's X-extent copy (BerkXExtentCopy) at or beyond the entity's x (IX+7)? If so, jump to ScriptRoutine_TaskThreeSeekBerk_WalkLeft.
50429 JR NC,ScriptRoutine_TaskThreeSeekBerk_WalkLeft
50431 LD HL,49988 Point HL at task-three table entry 49988.
50434 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
Walk left toward Berk until the left edge (73), then arm Slimy or keep stepping.
ScriptRoutine_TaskThreeSeekBerk_WalkLeft 50437 LD A,(IX+7) Load A with the current entity's x-coordinate.
50440 CP 73 Is the current entity's x-coordinate less than 73? If so, jump to ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange06.
50442 JR C,ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange06
50444 BIT 1,(IX+9) Is bit 1 of the current entity's direction / state set? If so, jump to ScriptRoutine_TaskThreeSeekBerk_TestRightThenDecX.
50448 JR NZ,ScriptRoutine_TaskThreeSeekBerk_TestRightThenDecX
50450 LD HL,49958 Point HL at task-three table entry 49958.
50453 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
If the way on the right is clear (Test_EntityOnRight), step left and refresh the heater.
ScriptRoutine_TaskThreeSeekBerk_TestRightThenDecX 50456 CALL Test_EntityOnRight Call Test_EntityOnRight to test whether an entity is on the right.
50459 JR NC,ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange06 Jump to ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange06 if the result did not underflow.
50461 DEC (IX+7) Move this entity one character left.
50464 DEC (IX+8)
50467 CALL Update_Heater Call Update_Heater to update Heater.
50470 JP AdvanceScriptInstruction Jump to AdvanceScriptInstruction to run the next script instruction.
Edge / stuck path: arm Slimy with range 6 via Update_Slimy_Creature, then pick a seek or descend script.
ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange06 50473 CP 31 Is the current entity's x-coordinate equal to 31? If so, jump to TaskThree_DoorHitThenNextScript.
50475 JP Z,TaskThree_DoorHitThenNextScript
50478 LD A,6 Load A with 6.
50480 CALL Update_Slimy_Creature Call Update_Slimy_Creature to update Slimy Creature.
50483 OR A Is A zero? If so, jump to ScriptRoutine_TaskThreeSeekBerk_RunSeekScript.
50484 JR Z,ScriptRoutine_TaskThreeSeekBerk_RunSeekScript
50486 LD HL,49978 Point HL at task-three table entry 49978.
50489 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
Run the climb/seek script at table entry 49968.
ScriptRoutine_TaskThreeSeekBerk_RunSeekScript 50492 LD HL,49968 Point HL at task-three table entry 49968.
50495 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
This entry point is used by the routine at ScriptRoutine_TaskThreeSeekBerk.
Arm Slimy with range 16 via Update_Slimy_Creature, then pick an approach or walk-left script.
ScriptRoutine_TaskThreeSeekBerk_ArmSlimyRange10 50498 LD A,16 Load A with 16.
50500 CALL Update_Slimy_Creature Call Update_Slimy_Creature to update the slimy creature.
50503 OR A Is the random result in A zero? If so, jump to ScriptRoutine_TaskThreeSeekBerk_RunApproachScript.
50504 JR Z,ScriptRoutine_TaskThreeSeekBerk_RunApproachScript
50506 LD HL,49958 Point HL at task-three table entry 49958.
50509 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
Run the walk-right approach script at table entry 49948.
ScriptRoutine_TaskThreeSeekBerk_RunApproachScript 50512 LD HL,49948 Point HL at task-three table entry 49948.
50515 JP ScriptInstruction Jump to ScriptInstruction to execute the script instruction at HL.
Prev: 50143 Up: Map Next: 50518