Patch:Squasher

From KeenWiki
Jump to navigation Jump to search

Squashers are yellow, rotund creatures that are found in many levels in Tuberia in Keen Dreams, notably Squash Swamp. They will ignore Keen until about five tiles away, when they will jump and try to squash him.

Squashers are prime targets for the dropping enemy bug which can crash the game if it is abused. This is remarkably easy to do as they will readily jump down cliffs or off the side of the level.


Sprite Type

Squashers use type 19 which has no impact on any other sprites save for making them transform into Wilted Flowers properly. It also affects how Keen reacts to it.

Keen Dreams

#Squasher sprite type
%patch $8E52 [$13]


Sprite Actions

The Squasher has a simple set of actions. It is spawned in the first frame of its walking cycle and continues walking until too close to Keen. It attacks Keen at close range by jumping towards him. After the jump it goes to falling, the only action lethal to Keen. When the falling Squasher hits a floor it goes to its landing action that then goes back to the walking cycle.

Due to the Squasher's sprite type it it harmless to Keen except for one action, falling. Only that action is deadly by default.

Actions:
$20C8W #Squasher walk 1
$20E6W #Squasher walk 2
$2104W #Squasher jump
$2122W #Squasher fall
$2140W #Squasher land

Keen Dreams

#Place Squasher in level
%patch $8E74 [$20C8W]

#Walking cycle
%patch $25B54 [$20E6W]
%patch $25B72 [$20C8W]

#When attacking Keen
%patch $8EFF [$2104W]

#Jumping goes to falling
%patch $7899 [$2122W]

#Return to walking after landing
%patch $25BCC [$20C8W]

#Land on ground
%patch $8F1E [$2140W]

#Actions that are deadly to Keen
%patch $7899 [$2122W]


Deadly action range

As noted above only one action is deadly to Keen by default. It is possible to use jump conditions to make the Squasher harmless. Sadly it is much harder to expand the range of actions that are lethal.

Keen Dreams

#Actions that are deadly to Keen
%patch $7899 [$2122W]  {$75}


Sprite Behavior

The Squasher has two unique behaviors. The first is used when it walks; this allows it to chase and attack Keen. The second is used when jumping, falling and landing. It is a generic behavior that makes the Squasher fall.

Behaviors:
$08680805RL #Squasher walk
$07C501A4RL #Fall

Keen Dreams

#Squasher walking
%patch $25B48 $08680805RL
%patch $25B66 $08680805RL

#Jump
%patch $25B84 $07C501A4RL

#Fall
%patch $25BA2 $07C501A4RL

#Land
%patch $25BC0 $07C501A4RL


Walking behavior code

This is the complete behavior code for the Squasher walking. The second and third line contain the vertical limits for when the Squasher will try and jump at Keen. (It will do so if Keen is between 8 pixels and 3 tiles higher than the Squasher.) At the end of line 4 the Squasher's horizontal direction is checked. If it is not -1 ($FF) then it goes to line 6, else it proceeds to line 5.

Lines 6 and 5 contain the horizontal attack ranges for right and left Squashers respectively. If both checks are passed then the Squasher will jump; otherwise it's horizontal direction will be set to 1 no matter which way it is facing. Left facing Squashers will attack when Keen is between -6 and +0.5 tiles right of them while right facing Squashers will attack between +6 and +0.5 tiles. ($80 or 8 pixels is half a tile.)

When jumping Squashers get a vertical speed boost of $FFCE and their action changes to $2014W.

Keen Dreams

#Squasher walk code
%patch $8E85 $55 $8B $EC $56 $57 $8B $76 $06 $8B $44 $0C $8B $1E $34 $70 $2B
             $47 $0C $99 $33 $C2 $2B $C2 $3D [$0300W]  {$7E} $14 $9A $16C40026RL
                 $3D [$0008W]  {$7D} $56 $8B $44 $0E $F7 $D8 $89 $44 $0E $EB $4C
             $8B $1E $34 $70 $8B $47 $0A $2B $44 $0A $8B $F8 $83 $7C {$0E} [$FF]
             {$75} $13 $81 $FF [$FA00W]  {$7C} $34 $81 $FF [$0080W]  {$7E} $19 $C7 $44
             $0E [$0001W]  $EB $27 $81 $FF [$0600W]  {$7F} $21 $83 $FF [$80] {$7D} $07
             $C7 $44 $0E [$0001W]  $EB $15 $C7 $44 $18 $FFCEW  $8B $C7 $BB $3C
             $00 $99 $F7 $FB $89 $44 $16 $C7 $44 $1E $2104W  $5F $5E $5D $CB


Speed and Jump Height

The Squasher's animation motion sets its walking speed, this is the only real speed it has. Its jump height is set elsewhere in its code.

Sprite speeds

#Walking
%patch $25B44 [$0080W $0000W]
%patch $25B62 [$0080W $0000W]

#Jump
%patch $25B80 [$0000W $0000W]

#Fall
%patch $25B9E [$0000W $0000W]

#Land
%patch $25BBC [$0000W $0000W]


Sprite collision

Like nearly all sprites in Keen Dreams the Squasher does not have a sprite collision. Instead Keen and his shots react to them and their sprite types.

Keen Dreams

#Squasher walking
%patch $25B4C $00000000L
%patch $25B6A $00000000L

#Jump
%patch $25B88 $00000000L

#Fall
%patch $25BA6 $00000000L

#Land
%patch $25BC4 $00000000L


Animations

Squasher have three animation cycles, walk, jump and land. Note that landing uses the same animations as falling and that its aniamtion speed is how long it stays landed for before returning to walking.

Keen Dreams

#Cache
%patch $23E8A $0141W #Squasher cache start
%patch $23EB6 $0148W #Squasher cache end

#Squasher walk
%patch $25B38 $0145W $0141W
%patch $25B42 $000AW        #Animation speed
%patch $25B56 $0146W $0142W
%patch $25B60 $000AW        #Animation speed

#Squasher jump
%patch $25B74 $0147W $0143W
%patch $25B7E $0014W        #Animation speed
%patch $25B92 $0148W $0144W
%patch $25B9C $0000W        #Animation speed

#Squasher land
%patch $25BB0 $0148W $0144W
%patch $25BBA $000AW        #Animation speed


Sprite-tile interaction

The Squasher uses two generic and one special tile interactions. The first, used when walking causes it to turn at platform edges and walls and also go up and down hills. The second, used when landing doesn't do anything but show the sprite. The third is used by the jumping and falling actions and looks for a floor to land on.

Keen Dreams

#Squasher walking
%patch $25B50 $07C50299RL
%patch $25B6E $07C50299RL

#Jump
%patch $25B8C $08680885RL

#Fall
%patch $25BAA $08680885RL

#Land
%patch $25BC8 $07C501DDRL


Falling interaction code

This is the complete tile interaction code for the Squasher as it falls. On the first line ceilings are checked for, if found the Squasher's vertical speed is set to 0. On the second line floors are checked for, if found the Squasher changes action to its landed action.

Keen Dreams

#Squasher fall tile interaction code
%patch $8F05 $55 $8B $EC $56 $8B $76 $06 $83 $7C {$3A} [$00] {$74} $05 $C7 $44 $18
             [$0000W]  $83 $7C {$36} [$00] {$74} $0D $B8 [$2140W]  $50 $56 $9A $07C50255RL
                     $83 $C4 $04 $33 $C0 $50 $50 $FF $74 $20 $FF $74 $0C $FF
             $74 $0A $8B $C6 $05 $46 $00 $50 $9A $0E450DC5RL     $83 $C4 $0C
             $5E $5D $CB


Sprite positioning

The Squasher spawns 15 pixels higher then where it is placed in-level. This ensures that the Squasher is level with the ground. If its height changes it will 'float' downward until touching a floor.

Keen Dreams

#Spawn height:
%patch $8E64 [$FF00W] #15 pixels up


Action type

The Squasher's walking (and landing) actions are quite basic and thus type 0. When fallin it needs to move smoothly and react fast, so that action is type 2. When jumping it needs to do all that plus animate so it is type 3.

Sprite action types

#Walking
%patch $25B3C [$0000W]
%patch $25B5A [$0000W]

#Jumping
%patch $25B78 [$0003W]

#Falling
%patch $25B96 [$0002W]

#Landing
%patch $25BB4 [$0000W]


Deprotect and stick to ground

The Squasher needs to stick to the ground while walking and thus uses a value of 1 for this variable in both its walking actions.

Sprite deprotect, stick

#Walking
%patch $25B3E [$0000W $0001W]
%patch $25B5C [$0000W $0001W]

#Jumping
%patch $25B7A [$0000W $0000W]

#Falling
%patch $25B98 [$0000W $0000W]

#Landing
%patch $25BB6 [$0000W $0000W]


Sprite spawn code

In the initiation code notice the Squasher cache being set ($C7 $06 $70CEW $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 and $C7 $07 $xxxxW sets the sprite type. Finally $D3 $E0 $05 $xxxx is how far down (Or more usually up) the sprite is spawned from where it is placed. This is necessary for sprites that walk on the ground as they can only be placed in the level at multiples of 16 pixels high while their actual height can be anything.

The Squasher always starts the level moving down and right. $C7 $47 $10 $xxxxW is the vertical direction the sprite starts moving in, either $0001W (Facing down), $FFFFW (Facing up) or $0000W (Neither, never used.) $C7 $47 $0E $xxxxW is the horizontal direction.

Keen Dreams

#Location of initiation code
%patch $4A4D [$0462W] #Squasher (At $4932)

#Squasher initiation code
%patch $4932 $FF $36 $7052W  $FF $36 $7050W  $9A {$086807BFRL}     $83 $C4 $04
             $8B $1E $3E $70 $C7 $47 $02 $0000W  $C7 $06 $70CEW  $0001W  $EB
             $79

#Squasher spawn code
%patch $8E3F $55 $8B $EC $33 $C0 $50 $9A $044D01C9RL     $44 $44 $8B $1E $3E
             $70 $C7 $07 [$0013W]  $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B
             $46 $08 $D3 $E0 $05 [$FF00W]  $89 $47 $0C $C7 $47 $0E [$0001W]  $C7
             $47 $10 [$0001W]  $B8 [$20C8W]  $50 $FF $36 $3E $70 $9A $044D1212RL
                 $83 $C4 $04 $5D $CB