Patch:Icecubes

From KeenWiki
Jump to navigation Jump to search

Icecubes, also known as ice cannons is a vague term covering several sprites in Keen 1 whose purpose it to paralyze Keen by freezing him in a block of ice. This page covers patches for the 'cannon', the icecube sprites and their fragments when they hit tiles. patches covering frozen Keen are elsewhere.

Icecubes have an interesting setup, there are three main sprites. The first is the 'metasprite' that is placed in the level. It has no graphics and there can only be 16 in the level maximum. It's function is to spawn icecubes at regular intervals. This is the 'ice cannon' cannons cannot fire if offscreen. There are four types of cannon, differing in the direction they spawn icecubes. These are up, down, diagonal left and diagonal right.

The second part is the icecubes proper; created regularly they will fly in a straight line and be destroyed on hitting shots, Keen or blocks. If they are not destroyed they will quickly overwhelm the game's ability to track them all, causing a rash. Icecubes, and any other sprite with the 'freeze' property, cease existing when offscreen. There is only one kind of icecube, differing in the direction it moves.

The final part are the ice fragments. Four of these are spawned when an icecube hits a block. They exist for a short time before vanishing. If they do not, they overwhelm the game even faster than icecubes. There are four kinds of ice fragment since all four are spawned at once, though they are very similar and share a lot of code.


Sprite Type

Ice cannons have no sprite type. Icecubes use type 15, which means they freeze Keen on contact. The ice fragments use type 12 which does nothing but is set aside for their use specifically.

Keen 1

#Ice sprite types:
%patch $20D6 $0F #Icecube (Freeze Keen)
%patch $21B0 $0C #Down right fragment
%patch $21EC $0C #Up right fragment
%patch $2228 $0C #Down left fragment
%patch $2264 $0C #Up left fragment


Sprite Behavior

There are three behaviors associated with ice sprites, the cannons; which produces icecubes, the icecubes; which move until they hit something and the fragments which do the same, but vanish after a short time. The freezing property is related to the sprite type and any sprite may use it. The cannon behavior is metasprite behavior and as such cannot be used by other sprites.

By default the ice sprite's behaviors never change from the moment they are created. Icecube collision is also fragment spawning. Fragments use the 'dead sprite' collision, meaning they ignore all other sprites.

If the cube\fragment behavior is changed, they will may longer destroy themselves, quickly overloading the game. Thus when altering behavior is is wise to either slow the cannon shoot rate or to find some other way of destroying the sprites, such as making them able to kill each other or placing them where they will fall off the screen.

Behaviors:
$2151W Move then disappear after a time
$2192W Move until hitting blocks
$22A6W Cube collision
$3360W Fragment collision (Used by many sprites)

When spawned

%patch $20F3 {$2192W} #Icecube (By cannon)

%patch $21B5 {$2151W} #Down right fragment (By smashing cube)
%patch $21F1 {$2151W} #Up right fragment (By smashing cube)
%patch $222D {$2151W} #Down left fragment (By smashing cube)
%patch $2269 {$2151W} #Up left fragment (By smashing cube)

Collision

%patch $213E {$22A6W} #Icecube
%patch $21BA {$3360W} #Down right fragment
%patch $21F6 {$3360W} #Up right fragment
%patch $2232 {$3360W} #Down left fragment
%patch $226E {$3360W} #Up left fragment


Speed and direction

It is the speed of icecubes and fragments that differentiate them.These speeds are set on creation and never change. Both vertical and horizontal speed can be changed for some cubes and in practice cubes and fragments can move in any direction. As such there are four different places speed is set for both cubes and fragments. Cannons do not move and have no speed.

Icecubes move at +-200 in all directions, fragments at +-300.

Starting speeds

#Up right icecube
%patch $2110 [$FF38W] #Up speed
%patch $2115 [$00C8W] #Right speed

#Up icecube
%patch $211C [$FF38W] #Up speed

#Down icecube
%patch $2128 [$00C8W] #Down speed

#Up left icecube
%patch $2134 [$FF38W] #Up speed
%patch $2139 [$FF38W] #Left speed


#down right fragments
%patch $21D9 [$012CW] #Speed right
%patch $21DE [$012CW] #Speed down

#up right fragments
%patch $2215 [$012CW] #Speed right
%patch $221A [$FED4W] #Speed up

#Down left fragments
%patch $2251 [$FED4W] #Speed left
%patch $2256 [$012CW] #Speed down

#Up left fragments
%patch $228D [$FED4W] #Speed left
%patch $2292 [$FED4W] #Speed up


Sprite Collision

Icecubes react with both Keen and his shot. Shooting cubes won't destroy them, but it will block the shot. Touching Keen will destroy the icecube. Freezing Keen is a sprite type property and not part of the collision. Fragmenting is part of the cube's behavior and reaction to tiles.

Fragments use the 'dead sprite' collision, that is they ignore all other sprites.

Collisions
$22A6W Cube collision
$3360W Fragment collision (Used by many sprites)

Keen 1

#Collisions used:
%patch $213E {$22A6W} #Icecube
%patch $21BA {$3360W} #Down right fragment
%patch $21F6 {$3360W} #Up right fragment
%patch $2232 {$3360W} #Down left fragment
%patch $226E {$3360W} #Up left fragment

#React with:
%patch $22AD $3F $01 #Disappear when hit Keen (Cubes)


Animations

When spawned

%patch $2143 [$0070W] #Icecube
%patch $21E3 [$0071W] #down right fragment
%patch $221F [$0071W] #up right fragment
%patch $225B [$0071W] #Down left fragment
%patch $2297 [$0071W] #Up left fragment


Sounds

These are the sounds the sprites use; Cannons make a noise every time they fire and cubes make a noise every time they smash. This makes ice sprites very noisy, often drowning out other sounds..

Keen 1

%patch $209B $17 #Ice cannon fire 
%patch $229A $13 #Icecube smash

#Don't make sounds:
%patch $209E $90 $90 $90 $90 #Cannon fire
%patch $229D $90 $90 $90 $90 #Cube smash

Misc

These are patches that do not fit into any of the above sections. They may affect other sprites or have unintended side-effects.

Cannon shoot rate

This controls how often the cannons create a new cube. The lower this number, the more often this occurs. The minimum value is $01 which will create a nearly solid stream of cubes.

Keen 1

#Ice cannon shoot rate
%patch $2058 [$07]


Cannon fires offscreen

This patch makes the ice cannons keep firing even when not visible. They will only make noise when onscreen however, which leads to quieter levels. It may be desired that the following patch is used with it.

Keen 1

#Cannon fires, even offscreen, only makes shooting sound while onscreen
%patch $207A $28
%patch $2084 $1E
%patch $208F $13
%patch $2099 $09


Freeze-type sprites don't vanish when offscreen

This patch allows icecubes to continue existing even when offscreen; this means they can be more troublesome for Keen and is best used with the above patch. It also fixes the problem noted in the behavior section, where any sprite of type 15 vanishes when offscreen. This allows things like freezing Yorps.

Keen 1

#Existing freeze sprites continue existing even offscreen
%patch $3340 $83 $3E $20 $82 $09 $7C $13 $83 $3E $20 $82 $0F $74 $0C $90


Keen can ride icecubes

This patch changes the icecubes so that Keen can ride the icecubes. There are two versions; one that plays a sound when Keen touches the cubes and one that is silent. The blue variable is the sound played.

Keen 1

#Keen can ride icecubes - sound on contact
%patch $467A $57 $56 $E8 $E9BDW $59 $59 $B8 [$0002W] $EB $0D

Keen 1

#Keen can ride icecubes - no sound on contact
%patch $467A $57 $56 $E8 $E9BDW $59 $59 $5F $5E $5D $C3