Patch:Keen dying (Keen 4)
This page contains patches relating to Keen's death in Keen 4, its causes and effects as well as patches that affect dying Keen's sprite. Other pages relating to Keen's death in other games can be found at Patch:Dead Keen.
In Keen 4 Keen can die in a number of ways, the three most basic being: falling out of the level bottom, lethal sprites and lethal tiles. In all cases Keen will use the same 'death code' which is in itself split into two sections depending whether or not Keen is in the Well Of Wishes. If Keen is, he will die using the 'scuba deaths' otherwise (normally) he will us the 'normal deaths'
In each case Keen has a choice of two death actions, chosen at random. While dead keen can be 'killed' again changing his death action. This can result in humorous sequences where Keen 'bounces' across the screen, repeatedly hitting lethal objects.
This page is split into two sections; the first is Keen's death code itself, the second containing patches relating to dead Keen's sprites.
Contents
Death code
This section contains patches that alter Keen's death code, that is, the circumstances in which he becomes dead. Some patches in this section may contain and thus be incompatible with some Keen mooning patches.
Default death code
This is the code run each time Keen is killed. A number of things will be noticed. Firstly there are some conditions under which Keen cannot die. The first is the PlayLoop timer (which has several functions.) It is set to $1E when Keen successfully dies. The second checks if god mode is enabled and the third and final check is whether Keen is using a defunct exception action (Oddly there is no place in the game that sets this action so this check is pointless.)
Secondly a number of variables are set; clipping is turned off (So dead Keen doesn't get stuck.), foreground is set to 3 (So dead Keen always appears in front of tiles and doesn't look odd.) Keen's 'mooning value' is set to 0 so that if he dies after mooning he can do so again. Two other variables are set, one may be the sprite type, the other is the screen scroll variable (This stops the screen scrolling when Keen dies and is needed to prevent bugs.)
There are four possible actions Keen may die into, dead 'sprawled' dead 'clutched', swimming 'sprawled' and swimming 'clutched'. There is a check for what level Keen is in before this which determines which pair (Swimming or not swimming) Keen can choose from. (See Patch:Jump conditions.)
It can be seen that there is a 50% chance of Keen being either sprawled or clutched, this is controlled by a random check of value 80. (50\50) Setting the value to zero will make Keen only die using one action.
Finally near the end of the code sound 17 is played and Keen's speed is set to jump up slightly and move right.
This code contains a number of smaller patches listed on this page and may not be compatible with them if placed after them in the patch file.
Patch: Keen 4 |
|
Probability and randomness
Both of these patches alter the probability that Keen will die using one death frame as opposed to the other. By default this is 50:50, meaning that each time Keen dies he has an equal chance of dying in either of two possible death frames.
Patch: Keen 4 |
%patch $CC37 $80 |
Dead Keen uses only one animation (Also no scuba death)
This patch substantially reduces the size of the kill Keen code, making it far easier to copy and thus allow multiple Keen deaths. It also ensures Keen dies the same way every time, useful if something novel is to be done with dead Keen. Here Keen dies and only uses the 'normal sprawled' frame. The first patch makes keen just fall offscreen, the second makes him 'bounce' like he does by default.
Patch: Keen 4 |
|
Patch: Keen 4 |
|
Hit points (health)
This patch allows Keen to have hit points health) with two main side effects. Firstly keen will not gain extra lives from collecting lifewater drops and secondly Keen will not have a 'scuba death' in the Well Of Wishes. The drops counter is used to keep track of hit points.
The first section of the patch alters the status window to accommodate a 3-digit HP counter in place of the drops counter. (If Keen's HP are not allowed to rise above 99 then the first section of 5 lines is totally unnecessary.) The details are slightly obscure and shouldn't be altered unless the modder wants to customize the status window.
The second section sets Keen's health when a new game starts. In this patch his health is set to 100 ($0064W). The third section gives the maximum amount of lifewater drops Keen can acquire, that is, the maximum health he can get in a level by collecting drops. In this patch it is 200 ($00C8W), or twice the default health, but a modder may wish to make this 100, the same as default health. If Keen collects a drop while at maximum health, he will get no benefit from it, though the drop will be taken.
The third section is Keen's death code; the last part of this section is very similar to the default code, with highlighted variables doing identical things. However at the start of the section there is an additional check before the player dies; HP are decreased by 1, and if they are less than 1 the player is allowed to die (Otherwise nothing happens.) On dying HP is reset to full health (To avoid the player restarting the level with 0 HP.)
The first patch has no indication Keen is hurt, the second plays a 'hit sound' to alert the player.
Patch: Keen has hit points, Keen 4 |
|
Patch: Keen has hit points, Keen 4, play hurt sound |
|
Dying in WoW and scuba death
There are two possible ways for Keen to die, swimming or not. Which one is chosen depends on what level he is in. The patch below has three parts, first what is checked for in brown (The current level), second the value in blue ($11 = 17, that is, level 17) and thirdly, the jump, again in brown ($74, only jump if...) The net result is that if the current level is 17, Keen dies using the swimming frames.
To make Keen die normally in WoW, simply replace the jump with $90 $90.
Patch: Keen 4 |
|
Keen does not die differently in WoW
This patch removes the unique WoW death, meaning Keen will use the same actions dying in any level. If Keen is swimming when he dies this may well cause an uncached sprite error, so Keen's death actions will have to be carefully coded.
It is of course possible to make this patch into a 'Keen always uses scuba death' patch with a simple animation frame switch.
Patch: Keen 4 |
|
Keen has three death frames instead of two
This patch gives Keen an extra death frame; it does this in this patch by stealing from Keen's mooning sequence, but this is not mandatory. It relies on using the EGAGRAPH check skip and so is incompatible with any other patches that use this. Note that Keen's underwater death is not affected. (But not given three frames either!)
The first line of the patch alters the probability Keen will die in a certain frame. Now he has a 1/3 chance of dying in one action and 2/3 in the other. This second action will itself split in two, resulting in 1/3 + 1/3 + 1/3 for each of the three death frames.
The next part is the two new death frames. Notice one is a copy of the second death frame, but the other uses the first Keen mooning frame. (If this is changed, Keen's mooning sequence can be left alone.) The third part of the patch is the 'split' action that splits one of Keen's original death frames into two new ones.
The fourth part of the patch is the splitting behavior, it performs a random check then changes Keen's frame to either one of the new death frames. Finally the fourth part of the patch caches the first (and only the first) mooning animation when Keen spawns in a level. (This must be changed if the animations of the new death frame are changed.)
Patch: Keen 4 |
|
Being eaten wins the game
This patch makes Keen win the game when he is eaten by a Dopefish. It works by making a new level state that wins the game and then changing the level state in eaten Keen's behavior to that instead of 1.
Patch: Keen 4 |
|
Dead Keen's sprite frames
This section contains patches that relate to Keen after he has died, his death animations and how they act.
Sprite Actions
There are a surprising number of actions associated with Keen's death. One of these is the 'defunct' action originally meant to stop Keen 're-dying' when already dead. This was dropped however and although the action exists there is no way for Keen to use it. It is checked for however in keen's death code.
There are two possible 'normal' and 'scuba' death actions for a total of four actions. Keen can die into all four in his death code randomly picking one or the other normal\swim deaths depending on what level he is in.
Each of these four actions continues to animate to itself, not changing its action at all. (Though they can 're-die' and change actions that way.)
When Keen is eaten by a Dopefish he is converted to a special dead action that does not act the same way the other death actions do. (For example if it falls offscreen the level doesn't restart.) This action in theory goes to the 'invisible dead' Keen but it doesn't animate. Instead the Dopefish 're-eats' dead Keen converting him into the invisible dead action.
The invisible dead action animates to itself, ending the level when it does so.
Actions: $0CD4W #Defunct action (Not used) $0CF2W #Keen dies sprawled (Exits level if offscreen.) $0D10W #Keen dies clutched (Exits level if offscreen.) $0D2EW #Keen die swimming sprawled (Exits level if offscreen.) $0D4CW #Keen die swimming clutched (Exits level if offscreen.) $36B0W #Eaten by Dopefish Keen $36CEW #Eaten by Dopefish Keen - invisible
Patch: Keen 4 |
|
Sprite Behavior
There are two dead Keen behaviors in use. The defunct action has no behavior and it does not matter if it is given one.
All four of Keen's 'usual' dead frames use the same behavior, one that loses the level if the sprite goes offscreen. Eaten Keen has no behavior but invisible dead Keen uses a different behavior; one that loses the level when it animates. (That is, after sitting around for a period of time.)
Behaviors: $00000000L #Nothing $0B8013B9RL #Lose level if offscreen $11A20700RL #Keen dead invisible
Patch: Keen 4 |
|
Dead Keen's behavior
This behavior is used by Keen's normal and scuba dead actions. It is quite simple; when Keen starts to go offscreen in any direction the level is lost. This is done by simply changing the level state to 1 when the game detects Keen's position relative to a screen edge is 0.
On the first line code is also called to make Keen fall; $56 $9A $09DC1315RL $83 $C4 $02. If this is removed then dead Keen will not fall at all, making it harder for him to go offscreen.
Patch: Keen 4 |
|
Dead Keen doesn't fall
This patch will stop Keen from responding to gravity, that is falling offscreen when he dies. Since however the level can only be restarted when he leaves the screen, some other form of movement must be implemented. By default he will move sideways off the screen if this patch is used.
Patch: Keen 4 |
|
Eaten Keen's behavior
This behavior is used by the invisible frame of Keen after he has been eaten by a Dopefish. It is quite simple; when its animation timer runs out the level is lost. This is done by simply changing the level state to 1. This can be changed to another value so that being eaten by the Dopefish actually wins the level or even the game.
Patch: Keen 4 |
|
Speed
There are two main sets of speeds relating to dead Keen. The first is the 'bounce' Keen gets when killed. This is both upwards and rightwards to ensure that Keen will quickly move off of any hazard he is touching and not get stuck in an 'infinite death loop'
The other set of speeds involve animation motion. None of dead keen's actions use these speeds at all.
Patch: Dead Keen 'bounce' speeds |
|
Patch: Animation motion |
|
Sprite Collision
None of Keen's dead actions have any collision. They do not interact with sprites, though they may still trigger the 'Keen die' code when sprites react to them.
Patch: Keen 4 |
|
Animations
There are two animations each for Keen dying normally, or underwater. There is also a separate, invisible frame that brings up the 'Didn't make it past window'. Finally when Keen is eaten by a Dopefish there is a two frame sequence that results in an invisible dead Keen similar to the 'restart level' action.
Patch: Keen 4 |
|
Sounds
Keen makes a sound each time he dies. This is the only death related sound and it can be blocked. The Dopefish also makes a sound when eating Keen but this is not strictly Keen's sound.
Patch: Keen 4 |
|
Clipping and foreground
When Keen dies his clipping is set to 0 (So he can pass through tiles offscreen and doesn't get stuck in a block.) and foreground is set to 3 (So he appears in front of all tiles and most sprites, making him appear very prominent.) When Keen is eaten by a Dopefish his clipping is also removed; this also affects the Schoolfish when it is eaten.
Patch: Clipping |
|
Patch: Foreground |
|
Sprite-tile interaction
All of dead Keen's actions use the basic 'draw' tile collision that doesn't interact with any tiles in any way. (Though if their clipping is 1 or higher tiles will still bock them.)
Patch: Sprite-tile interaction |
|
Action type
All of dead Keen's actions are type 2 meaning they ignore their animation timer but react instantly to outside influences. The exception is invisible dead Keen which is type 0, allowing it to wait until its animation timer runs out before losing the level.
Patch: Keen 4 |
|
Deprotect and stick to ground
None of Dead Keen's actions need to stick to the ground and so neither of these variables is used by any of the actions.
Patch: Keen 4 |
|
Probability and randomness
See above in the first section of this page for patches relating to the probability of Keen dying with a certain action.