Prev: 40562 Up: Map Next: 40710
40627: Handler: Sleeping Hippo And Warthog
Handles a hippo (sprite IDs 164-167) or a warthog (sprite IDs 172-175) which is asleep. If BringActorCloser has moved the animal to another room then it wakes up as a hippo or a warthog chosen at random (see WakeAnimal).
If the player touches the animal (see TestActorHurtingPlayer), unless the start-of-turn delay is running or the player is not alive, then the animal wakes up, turns around, stands still for a short while (the counter in *IX+2) and makes a noise.
Input
IX Actor record
If the animal has been moved to another room then wake it up.
HandlerSleepingHippoWarthog 40627 LD C,(IX+1) Fetch the room of the animal into C.
40630 PUSH BC Stash the room on the stack.
40631 CALL BringActorCloser Move the animal into the row above or below the player if it is two or more rows away.
40634 POP BC Restore the old room of the animal from the stack.
40635 LD A,(IX+1) Fetch the new room of the animal.
40638 CP C Compare with the old room.
40639 CALL NZ,WakeAnimal Wake the animal up if it has moved to a different room.
Do nothing else unless the animal is in the same room as the player.
40642 LD A,(38659) Fetch the room of the player from 38659.
40645 CP (IX+1) Compare with the room of the animal.
40648 RET NZ Return if the animal is in a different room to the player.
40649 CALL StoreEntity Remember the previous position of the animal.
40652 LD A,32 Write 32 to Actor_Width (the width of the animal).
40654 LD (38573),A
40657 LD A,(IX+0) Fetch the sprite ID of the animal.
40660 RRCA Rotate the direction bit (bit 1) into bit 0.
40661 AND %00000001 Keep only bit 0.
40663 LD D,A Set the direction the animal is facing in D.
40664 LD BC,3868 Set how far above and to the right of the animal the player can be in BC to 3868.
40667 LD A,(38581) Fetch the start-of-turn delay from GameDelayTimer.
40670 AND A Set the flags.
40671 JR NZ,HandlerSleepingHippoWarthog_NoHurt Jump to HandlerSleepingHippoWarthog_NoHurt if the start-of-turn delay is running.
40673 LD A,(38658) Fetch the sprite ID of the player from ImmortalData.
40676 SUB 16 Subtract 16 (the first Sabreman sprite ID).
40678 CP 32 Jump to HandlerSleepingHippoWarthog_NoHurt if the player is not alive.
40680 JR NC,HandlerSleepingHippoWarthog_NoHurt
40682 CALL TestActorHurtingPlayer Test whether the animal is touching the player.
HandlerSleepingHippoWarthog_Touch 40685 JP NC,DisplayActor Jump to DisplayActor to display the animal if the player is not touching it.
The player is touching the animal so it wakes up and turns around.
40688 RES 2,(IX+0) Reset bit 2 of the sprite ID to wake the animal up.
40692 CALL TurnRhinoAround Turn the animal around.
40695 LD (IX+2),15 Set the pause counter of the animal to 15 so that it stands still.
40699 CALL DisplayActor Display the animal.
40702 JP PlayWarbleSound Jump to PlayWarbleSound to play the warble sound.
Test whether the player is touching the animal, without hurting the player.
HandlerSleepingHippoWarthog_NoHurt 40705 CALL TestPlayerTouchingActor_Reach Test whether the player is touching the animal.
40708 JR HandlerSleepingHippoWarthog_Touch Jump to HandlerSleepingHippoWarthog_Touch.
Prev: 40562 Up: Map Next: 40710