Patch:Cloud
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.
Contents |
Sprite Type
Clouds use sprite type 13 which is used only by the Cloud and doesn't affect anything else.
| Patch: Keen 4 |
|
Sprite Actions
Clouds have a number of actions, not all of them are known for sure, so their labels are slightly speculative. The first is the cloud hiding. The next two or three are used when the clouds moves back and forth. There are a whole string of action used as the cloud prepares to strike Keen, and another string used for the lightening itself, which is a separate sprite that then vanishes.
If the lightening is kept around (This can be done by changing its last entry, $0000W to anything else.) then be aware that they can build up in the level and eventually crash the game. There should be something to limit how many appear.
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
The cloud is placed in-level 'sleeping', by default it then does nothing, not animating until Keen touches it. It then 'awakes', sitting for a time before moving off.
| Patch: Keen 4 |
|
The moving cloud will turn whenever it hits a solid tile, and also after blasting Keen with lightening.
| Patch: Keen 4 |
|
When Keen gets too close to the cloud it begins a series of actions that lead to it blasting him with a lightening sprite. It then uses a 'start moving again' action. The lightening sprite is separate from the cloud and quickly vanishes.
| Patch: Keen 4 |
|
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 |
|
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 |
|
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 |
| Patch: Animation motion |
|
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 |
|
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 [[Patch:Jump conditions|jump condition], and the second brown variable is the change sprite call.
| Patch: Keen 4 |
|
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 |
|
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 |
|
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 |
|
Sounds
The cloud only makes a noise when it produces lightening.
| Patch: Keen 4 |
|
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 |
|
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 |
|
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 |
|
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 clipping, $C7 $07 $xxxxW sets the sprite type, $C7 $20 $xxxxW sets the foreground value.
| Patch: Keen 4 |
|
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 |
|
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 |
|