Patch:Cloud

From KeenWiki
Jump to: navigation, search

This page contains patches relating to the Cloud in Keen 4, an enemy found in some levels. Other clouds are tiles and there are other utilities that can edit their properties and appearance.

The clouds sit, resembling background until Keen touches them, at which they 'awaken' and start moving, attempting to hit Keen with lightening whenever he gets too close.


Sprite Type

Clouds use sprite type 13 which is used only by the Cloud and doesn't affect anything else.

Patch: Keen 4
#Cloud sprite type
%patch $109D6 $0D


Sprite Actions

Clouds have a number of actions, not all of them are known for sure, so their labels are slightly speculative. The Cloud is spawned using its 'asleep' action. This action does not change.

If keen touches the sleeping Cloud it goes to its awake action. This action lasts a short time before going to the moving Cloud action. The moving Cloud does nothing, staying moving. When the moving Cloud hits a solid tile it turns.

The turning Cloud also does nothing (it is not currently known how a turning Cloud returns to moving.)

The Cloud will go to zapping when Keen touches it under two conditions; firstly when it is moving and secondly when it is turning. The zapping sequence is nine actions long and ends with the Cloud changing to a 'start moving' action. Lightening is produced on the fourth action and is a seven action sequence that ends with the lightening disappearing. (If the lightening is kept around then some measures must be taken to prevent it building up and crashing the game.)

The 'start moving' action turns a zapping Cloud into a moving one and will also change the Cloud's direction if it has zapped Keen while turning.

Actions:
$28A0W #Cloud asleep
$28BEW #Cloud awake and still
$28DCW #Cloud moving
$28FAW #Cloud turn
$2918W #Cloud start moving (After zapping)
$2936W #Zap Keen 1
$2954W #Zap Keen 2
$2972W #Zap Keen 3
$2990W #Zap Keen 4
$29AEW #Zap Keen 5
$29CCW #Zap Keen 6
$29EAW #Zap Keen 7
$2A08W #Zap Keen 8
$2A26W #Zap Keen 9 (Produce lightening)
$2A44W #Lightning 1
$2A62W #Lightning 2
$2A80W #Lightning 3
$2A9EW #Lightning 4
$2ABCW #Lightning 5
$2ADAW #Lightning 6

Patch: Keen 4
#Spawn Cloud
%patch $109FE $28A0W
#Sleeping Cloud does nothing
%patch $3172C $0000W
#When touched by Keen awaken
%patch $10B8A $28BEW
#Awake Cloud goes to moving
%patch $3174A $28BEW
#Moving Cloud does nothing
%patch $31768 $0000W
#Moving Cloud turns when hitting walls
%patch $10A73 $28FAW
#Turning Cloud does nothing while turning
%patch $31786 $0000W
#Start moving Cloud goes to moving
%patch $317A4 $28DCW
#Moving Cloud goes to zapping when Keen touches it
%patch $10AB2 $2936W
#Turning Cloud goes to zapping when Keen touches it
%patch $10ADC $2936W
#Cloud zapping sequence
%patch $317C2 $2954W %patch $317E0 $2972W %patch $317FE $2990W %patch $3181C $29AEW
#Make lightening here
%patch $3183A $29CCW %patch $31858 $29EAW %patch $31876 $2A08W %patch $31894 $2A26W %patch $318B2 $2918W
#Lightening sequence
%patch $10B62 $2A44W %patch $318D0 $2A62W %patch $318EE $2A80W %patch $3190C $2A9EW %patch $3192A $2ABCW %patch $31948 $2ADAW %patch $31966 $0000W


Sprite Behavior

The Cloud's behaviors are quite simple, but it has several of them which can complicate things. The first is the cloud awakening; it involves the cloud sitting before becoming a moving cloud. The second is the moving cloud, it turns the cloud into a zapping cloud if Keen is too close. The third is the lightening creation behavior, it spawns a lightening sprite and sets its properties. There is also a 'general' behavior that only seems to be used by clouds. It appears to code nothing but sitting.

The sleeping and waking clouds use no behaviors. The moving cloud uses a 'React to Keen' behavior that lets it zap Keen if he is too close and also controls its speed. When the cloud turns or after it has zapped Keen it uses a behavior that lets it start moving again. Finally, one (And only one!) of the zapping Keen cloud actions uses the 'make lightening' behavior to spawn a bolt. (Lightening itself has no behavior either.)

Behaviors:
$09DC1701RL #Sit?
$1080020CRL #Cloud react to Keen
$10800278RL #Cloud turn
$1080032ARL #Lightening made

Patch: Keen 4
#Sleeping cloud
%patch $31720 $00000000L
#Awakening cloud
%patch $3173E $00000000L
#Awake and still (No behavior)
%patch $3177A $10800278RL
#Cloud turning
%patch $31798 $09DC1701RL
#Cloud start moving after zapping
#Moving cloud
%patch $3175C $1080020CRL
#Cloud moving (React to Keen)
#Zap Keen
%patch $317B6 $00000000L %patch $317D4 $00000000L %patch $317F2 $00000000L %patch $31810 $1080032ARL
#Lightening made
%patch $3182E $00000000L %patch $3184C $00000000L %patch $3186A $00000000L %patch $31888 $00000000L %patch $318A6 $00000000L
#Lightening
%patch $318C4 $00000000L %patch $318E2 $00000000L %patch $31900 $00000000L %patch $3191E $00000000L %patch $3193C $00000000L %patch $3195A $00000000L


Cloud doesn't attack Keen

This patch stops the Cloud attacking Keen. Under no circumstances will the Cloud stop and throw lightening at keen, though it will turn to follow him if he is close enough. This patch frees up space between $10A78 and $10AE0 as it is not used by the cloud anymore.

Patch: Keen 4
#Cloud doesn't attack Keen
%patch $10A70 $EB $03


Cloud is still and awake all the time

This patch makes the Cloud spawn awake. It will attack Keen if he touches it but will not move. The first part makes the Cloud attack Keen instead of waking up. In the second section the first line makes the Cloud return to its attacking action, the second line stops it moving after attacking and the third changes the napping Cloud's animations to be awake.

Patch: Keen 4
#Cloud collision
%patch $10B7D $55 $8B $EC $56 $8B $76 $08 $83 $3C $02 $75 $0F $B8 $2936W $50 $FF $76 $06 $9A $09DC120ARL $83 $C4 $04 $5E $5D $CB
#Don't move
%patch $318B2 $28A0W %patch $10A80 $0000W %patch $31710 $01F3W $01F3W


Speed and Jump Height

Clouds have no animation motion, the speed is set when the cloud moves, and also when it starts moving after blasting Keen.

Patch: Cloud speed
%patch $10A36 $000AW 
#Speed when moving
%patch $10A80 $000AW
#After trying to zap Keen

Patch: Animation motion
#Cloud asleep
%patch $3171C $0000W $0000W
#Cloud awakens
%patch $3173A $0000W $0000W
#Moving
%patch $31758 $0000W $0000W
#Turning
%patch $31776 $0000W $0000W
#Turn
%patch $31794 $0000W $0000W
#Start moving after zapping
#Cloud zaps
%patch $317B2 $0000W $0000W %patch $317D0 $0000W $0000W %patch $317EE $0000W $0000W %patch $3180C $0000W $0000W %patch $3182A $0000W $0000W %patch $31848 $0000W $0000W %patch $31866 $0000W $0000W %patch $31884 $0000W $0000W %patch $318A2 $0000W $0000W
#Lightening
%patch $318C0 $0000W $0000W %patch $318DE $0000W $0000W %patch $318FC $0000W $0000W %patch $3191A $0000W $0000W %patch $31938 $0000W $0000W %patch $31956 $0000W $0000W)


Sprite Collision

Collision values

The Cloud uses its own special collision, when 'sleeping' it reacts to Keen to awaken. Otherwise it has no collision. (Reacting to Keen while moving is done in its behavior, not its collision. This means it can easily be made shootable.) The lightening uses the general 'deadly to Keen' collision.

Patch: Keen 4 collision values
#Sleeping
%patch $31724 $1080037DRL
#Look for Keen
#Awakening
%patch $31742 $00000000L
#No collision
#Moving
%patch $31760 $00000000L
#No collision
#Turning
%patch $3177E $00000000L
#No collision (Turning)
%patch $3179C $00000000L
#No collision (After zapping Keen)
#Zapping Keen
%patch $317BA $00000000L
#No collision
%patch $317D8 $00000000L
#No collision
%patch $317F6 $00000000L
#No collision
%patch $31814 $00000000L
#No collision
%patch $31832 $00000000L
#No collision
%patch $31850 $00000000L
#No collision
%patch $3186E $00000000L
#No collision
%patch $3188C $00000000L
#No collision
%patch $318AA $00000000L
#No collision
#Lightening
%patch $318C8 $09DC1752RL
#Deadly to Keen
%patch $318E6 $09DC1752RL
#Deadly to Keen
%patch $31904 $09DC1752RL
#Deadly to Keen
%patch $31922 $09DC1752RL
#Deadly to Keen
%patch $31940 $09DC1752RL
#Deadly to Keen
%patch $3195E $09DC1752RL
#Deadly to Keen


Collision code

The sleeping cloud collision is quite simple; it looks for Keen's sprite type (2) and if found it changes the cloud's action to 'waking up' (Via the 'change action' subroutine.) The blue variable is the sprite type checked for, the first brown byte is the jump condition, and the second brown variable is the change sprite call.


Patch: Keen 4
#Cloud collision
%patch $10B7D $55 $8B $EC $56 $8B $76 $08 $83 $3C $02 $75 $0F $B8 $28BEW $50 $FF $76 $06 $9A $09DC120ARL $83 $C4 $04 $5E $5D $CB


Animations

Clouds use their animations and animation speeds very inventively. The first thing to note is the animation speed of the sleeping cloud controls how quickly it reacts to Keen when Keen touches it. The animation speed of the waking cloud controls how long it sits before starting to move. The moving cloud's animation speed also controls, to some extent, how fast it reacts to Keen, as does the turning and 'start moving' actions' speeds.

The 'zapping Keen' series use the same two animations over and over and their animation speeds control how long the whole sequence lasts (As well as how quickly the lightening is produced.) The animation speed of the lightening controls how long it sticks around, since it vanishes after it is done.

Patch: Keen 4
#Cache
%patch $30708 $01F2W
#Cloud Cache start
%patch $30752 $01F6W
#Cloud cache end
#Cloud asleep
%patch $31710 $01F2W $01F2W %patch $3171A $0014W
#Pause before waking when touched
#Cloud awake, pauses
%patch $3172E $01F3W $01F3W %patch $31738 $0064W
#How long cloud sits before moving
#Cloud moving
%patch $3174C $01F3W $01F3W %patch $31756 $0014W
#Animation speed
#Cloud turning
%patch $3176A $01F3W $01F3W
#Turning
%patch $31774 $0014W
#Animation speed
%patch $31788 $01F3W $01F3W
#Start moving after zapping Keen
%patch $31792 $003CW
#Animation speed
#Cloud start zapping Keen
%patch $317A6 $01F4W $01F4W %patch $317B0 $000AW
#Animation speed
%patch $317C4 $01F3W $01F3W %patch $317CE $000AW
#Animation speed
%patch $317E2 $01F4W $01F4W %patch $317EC $000AW
#Animation speed
%patch $31800 $01F3W $01F3W %patch $3180A $000AW
#Animation speed
%patch $3181E $01F4W $01F4W %patch $31828 $000AW
#Animation speed
%patch $3183C $01F3W $01F3W %patch $31846 $000AW
#Animation speed
%patch $3185A $01F4W $01F4W %patch $31864 $000AW
#Animation speed
%patch $31878 $01F3W $01F3W %patch $31882 $000AW
#Animation speed
#Zap Keen
%patch $31896 $01F4W $01F4W %patch $318A0 $0030W
#Pause while lightening strikes
#Lightning
%patch $318B4 $01F5W $01F5W %patch $318BE $0008W
#Animation speed
%patch $318D2 $01F6W $01F6W %patch $318DC $0008W
#Animation speed
%patch $318F0 $01F5W $01F5W %patch $318FA $0008W
#Animation speed
%patch $3190E $01F6W $01F6W %patch $31918 $0008W
#Animation speed
%patch $3192C $01F5W $01F5W %patch $31936 $0008W
#Animation speed
%patch $3194A $01F6W $01F6W %patch $31954 $0008W
#Animation speed


Clipping and foreground

The lightening has its clipping set to 0 when it is created. The cloud also has its foreground value set to 2 when spawned. Nothing else is currently patchable.

Patch: Keen 4
#Clipping
%patch $10B4D $0000W
#Cloud Lightening
#Foreground
%patch $109E0 $0002W
#Cloud


Sprite-tile interaction

The cloud has its own special collision, which makes it change direction whenever it hits a wall. This is used by the cloud when it is waking, turning and moving.

The sleeping cloud, zapping cloud and lightening use the 'sit' collision, which lets them sit, staying out of solid ground.

Patch: Keen 4
#Sleeping cloud
%patch $31728 $09DC176ERL
#Sit
#Awakening cloud
%patch $31746 $108002E1RL
#Cloud collision
#Moving cloud
%patch $31764 $108002E1RL
#Cloud collision
#Turning cloud
%patch $31782 $108002E1RL
#Cloud collision
%patch $317A0 $108002E1RL
#Cloud collision
#Zapping Keen
%patch $317BE $09DC176ERL
#Sit
%patch $317DC $09DC176ERL
#Sit
%patch $317FA $09DC176ERL
#Sit
%patch $31818 $09DC176ERL
#Sit
%patch $31836 $09DC176ERL
#Sit
%patch $31854 $09DC176ERL
#Sit
%patch $31872 $09DC176ERL
#Sit
%patch $31890 $09DC176ERL
#Sit
%patch $318AE $09DC176ERL
#Sit
#Lightening
%patch $318CC $09DC176ERL
#Sit
%patch $318EA $09DC176ERL
#Sit
%patch $31908 $09DC176ERL
#Sit
%patch $31926 $09DC176ERL
#Sit
%patch $31944 $09DC176ERL
#Sit
%patch $31962 $09DC176ERL
#Sit


Sounds

The cloud only makes a noise when it produces lightening.

Patch: Keen 4
#Lightning sound
%patch $10B6F $27
#Don't play Lightning sound:
%patch $10B6E $EB $0A


Positioning and Lightening location

When lightening is produced, it is positioned 1 tile down and 1 tile across from the top left of the cloud sprite by default.

Patch: Keen 4
#Lightning spawn location
%patch $10B5C $0100W
#1 tile down
%patch $10B53 $0100W
#1 Tile across


Action type

The Cloud use a number of values for their action parameters. Type 3 is used by the cloud when it starts moving after zapping Keen; this means it uses the start moving behavior only once and that it waits a bit before starting to move. The Sleeping, moving and turning clouds use type 2, these allow them to be very responsive to Keen. (It stops them using animation movement, but they don't use this anyway.)

Finally the other clouds use type 0, letting them methodically tick through their animations as dictated by their animation speeds.

Patch: Keen 4
#Asleep
%patch $31714 $0002W
#Awakening
%patch $31732 $0000W
#Moving
%patch $31750 $0002W
#Turning
%patch $3176E $0002W
#Turning
%patch $3178C $0003W
#Start moving after zapping
#Zapping Keen
%patch $317AA $0000W %patch $317C8 $0000W %patch $317E6 $0000W %patch $31804 $0000W %patch $31822 $0000W %patch $31840 $0000W %patch $3185E $0000W %patch $3187C $0000W %patch $3189A $0000W
#Lightening
%patch $318B8 $0000W %patch $318D6 $0000W %patch $318F4 $0000W %patch $31912 $0000W %patch $31930 $0000W %patch $3194E $0000W


Deprotect and stick to ground

The Cloud has values of 0 for both of these parameters. It does not need to walk on the ground.

Patch: Keen 4
#Clouds
%patch $31716 $0000W $0000W
#Asleep
%patch $31734 $0000W $0000W
#Awaken
%patch $31752 $0000W $0000W
#Move
%patch $31770 $0000W $0000W
#Turn
%patch $3178E $0000W $0000W
#Start moving after zappping
%patch $317AC $0000W $0000W
#Shocking Keen 1
%patch $317CA $0000W $0000W
#Shocking Keen 2
%patch $317E8 $0000W $0000W
#Shocking Keen 3
%patch $31806 $0000W $0000W
#Shocking Keen 4
%patch $31824 $0000W $0000W
#Shocking Keen 5
%patch $31842 $0000W $0000W
#Shocking Keen 6
%patch $31860 $0000W $0000W
#Shocking Keen 7
%patch $3187E $0000W $0000W
#Shocking Keen 8
%patch $3189C $0000W $0000W
#Shocking Keen 9
#Lightening
%patch $318BA $0000W $0000W %patch $318D8 $0000W $0000W %patch $318F6 $0000W $0000W %patch $31914 $0000W $0000W %patch $31932 $0000W $0000W %patch $31950 $0000W $0000W


Sprite spawn code

In the initiation code notice the Cloud cache being set ($C7 $06 $61 $CB $0001W.)

In the spawning code the last blue highlighted value is the sprite action the sprite uses as it proceeds to act in-level. $C7 $02 $xxxxW sets the sprite activity, $C7 $07 $xxxxW sets the sprite type, $C7 $20 $xxxxW sets the foreground value.

Patch: Keen 4
#Location of initiation code
%patch $EE95 $0189W
#Cloud (At $EA79)
#Cloud Initiation code
%patch $EA79 $FF $76 $FC $57 $9A $108001C2RL $83 $C4 $04 $C7 $06 $73 $CB $0001W $E9 $036FW
#Cloud Spawning code
%patch $109C2 $55 $8B $EC $33 $C0 $50 $9A $06BD1E11RL $83 $C4 $02 $8B $1E $D8 $A7 $C7 $07 $000DW $C7 $47 $02 $0002W $C7 $47 $20 $0002W $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $89 $47 $0C $B8 $0001W $89 $47 $0E $89 $47 $10 $B8 $28A0W $50 $53 $9A $09DC118CRL $83 $C4 $04 $5D $CB


Misc patches

These are some random patches. They may cause some problems in complex patch files.


Clouds keep moving before zapping

This patch makes clouds move right after they find Keen *before* zapping. This means they often miss him, but as part of a more complex patch they might be used to say, make Keen chase them before they release a point item.

Patch: Keen 4
#Clouds will move all the way to the right before zapping if Keen is careful
%patch $10AC6 $00 $01


Lightening always at level top

This patch makes the cloud lightening always appear at the top of the level, no matter how high up the Cloud is. (The horizontal position depends on the cloud's location though.) This can be useful for using the cloud as some sort of 'switch' to affect other things far from it.

Patch: Keen 4
#No matter where clouds are, the lightening they make is at the level top
%patch $10B5B $01 $00