Patch:Korath (Sprite)

From KeenWiki
Jump to navigation Jump to search

Koraths are a secret creature in Keen 5. They appear in only one level and are harmless, if pushy. In the game's secret ending they arrest the Shikadi for illegal parking.


Sprite Type

Koraths use sprite type 32 which is used only by the Koraths and doesn't affect anything else.

Keen 5

#Korath sprite type
%patch $138D5 $17


Sprite Actions

The Korath's actions are quite straightforward. Korath are spawned walking, a four frame loop that they remain in until randomly stopping to sit. Sitting is a single frame sequence that ends with the Korath returning to walking. Finally the Korath can be stunned, after which is does nothing more.

Actions:
$30D2W #Korath walking 1
$30F0W #Korath walking 2
$310EW #Korath walking 3
$312CW #Korath walking 4
$314AW #Korath sit
$3168W #Korath stunned

Keen 5

#When spawned
%patch $13910 [$30D2W]

#While walking
%patch $3342E [$30F0W]
%patch $3344C [$310EW]
%patch $3346A [$312CW]
%patch $33488 [$30D2W]

#Korath sit (Random when walking)
%patch $13951 [$314AW]

#While sitting
%patch $334A6 [$30D2W]

#Korath stunned (When shot)
%patch $13985 [$3168W]

#While stunned
%patch $334C4 [$0000W]


Korath has only three walking actions, but has two standing actions

This patch makes the Korath have just three walking actions, but two standing actions. This is more than a simple animations patch, it alters the 4th walking action so it acts like a standing action. it also spawns to sitting instead of walking. Due to the simplicity of the Korath this is easy to do.

In the first line the 'next action pointer' of the 3rd walking frame is changed to go to the 1st walking frame instead of the 4th. This immediately reduces the walking cycle to 3 frames. The second section changes the old sitting frame so that it doesn't go to walking 1, but instead the new sitting frame ('Walking 4' Notice that the new sit frame already goes back to walking 1, so we don't need to tweak it.) Finally the last line makes the Korath spawn sitting instead of walking. (This is optional.)

Korath has only three walking actions, but has two standing actions

#Make 3rd walk action go to 1st
%patch $3346A [$30D2W]

#Make 4th walking action the second sitting animation
%patch $334A6 [$312CW]

#Spawn sitting
%patch $13951 [$314AW]


Sprite Behavior

The Korath has only one behavior, walking, in which it randomly sits. This is used only when walking, as expected. When stunned it uses a generic 'stunned sprite' behavior.

Behaviors:
$11C41CE1RL #Korath walk

Keen 5

#Walking
%patch $33422 $11C41CE1RL #Korath walk
%patch $33440 $11C41CE1RL #Korath walk
%patch $3345E $11C41CE1RL #Korath walk
%patch $3347C $11C41CE1RL #Korath walk

#Sit
%patch $3349A $00000000L  #Nothing

#Stunned
%patch $334B8 $090B1710RL #Fall


Walking behavior code

This is the only unique behavior the Korath has and it is quite simple. It consists of two probability check and an action change.

On the first line of the patch is the Korath's standing check; the check that determines randomly how often the Korath will go to standing. This is quite low ($0010W) so that it does not stand too often.

On the second line the Korath changes its direction; this is for when the Korath resumes walking but it is stored here. The options are left ($FFFFW) or right ($0001W) seen on the third line. Also on the second line some unknown variable is set to 0.

On the fourth line the Korath's action is changed to that of standing.

Korath walking behavior

#Korath walking behavior
%patch $13921 $55 $8B $EC $56 $8B $76 $06 $9A $1DFB0036RL     $3D [$0010W]  $7D
              $21 $C7 $06 $BF85W  [$0000W]  $9A $1DFB0036RL     $3D [$0080W]  $7D
              $07 $C7 $44 $0E [$0001W]  $EB $05 $C7 $44 $0E [$FFFFW]  $C7 $44 $1C
              [$314AW]  $5E $5D $CB


Korath follows Keen after standing

This patch alters the Korath's behavior so that the direction in which it turns after standing is no longer random but it instead turns to face Keen. The first blue value is still its standing probability and the direction and action values are still the same. However the unknown value set to 0 has been removed to make space, (It is not known if this has any side effects.) as well as the 50/50 random value.

To make the Korath flee Keen simply swap the $0001W and $FFFFW values.

Korath follows Keen after standing behavior

#Korath follows Keen after standing
%patch $13921 $55 $8B $EC $56 $8B $76 $06 $9A $1DFB0036RL     $3D [$0010W]  $7D
              $1D $8B $44 $0A $8B $1E $3E $9E $3B $47 $0A $7D $07 $C7 $44 $0E
              [$0001W]  $EB $05 $C7 $44 $0E [$FFFFW]  $C7 $44 $1C [$314AW]  $5E $5D $CB


Speed

The only speeds relevant to the Korath are those of its walking. They are controlled by its animation motion.

Animation motion

#Korath walk
%patch $3341E [$0080W $0000W]
%patch $3343C [$0080W $0000W]
%patch $3345A [$0080W $0000W]
%patch $33478 [$0080W $0000W]

#Korath stand
%patch $33496 [$0000W $0000W]

#Korath stunned
%patch $334B4 [$0000W $0000W]


Sprite Collision

The Korath's collision is exceedingly simple. It will push Keen and can be stunned.


Collision values

The Korath has a single collision, used fore everything it does except when it is stunned.

Keen 5 collision values

#Walk
%patch $33426 $11C41D16RL #Korath
%patch $33444 $11C41D16RL #Korath
%patch $33462 $11C41D16RL #Korath
%patch $33480 $11C41D16RL #Korath

#Sit
%patch $3349E $11C41D16RL #Korath

#Stunned
%patch $334BC $00000000L  #Nothing


Collision code

This is the complete collision code for the Korath. It responds to two sprite types, Keen, and his shot. If Keen is detected, he is pushed about. If the shot is detected, it is destroyed and the Korath stunned.

Complete Korath collision code

#Complete Korath collision code
%patch $13956 $55 $8B $EC $56 $57 $8B $7E $06 $8B $76 $08 $83 $3C [$02] {$75} $19 #React to Keen
              $8B $5C $1C $8B $47 $14 $0B $47 $16 $74 $0E $57 $56 $9A
      $090B0CD2RL     $83 $C4 $04 $5F $5E $5D $CB $83 $3C [$03] {$75} $0E $B8     #Push Keen, react to Keen's shot
          [$3168W]  $50 $56 $57 $9A $090B16CDRL     $83 $C4 $06 $5F $5E $5D $CB #Be stunned


Korath are deadly

This patch makes it so the Korath does not push Keen, but kills him. Keen can still kill the Korath.

Korath are deadly, shootable

#Korath are deadly, shootable
%patch $13956 $55 $8B $EC $56 $8B $76 $08 $83 $3C [$02] {$75 $08} $9A $0AAF1517RL #Check for Keen, if yes, kill
                      $5E $5D $CB $83 $3C [$03] {$75 $10} $B8 [$3168W]  $50 $56 $FF #Check for Keen shot, if yes, stun
                  $76 $06 $9A $090B16CDRL     $83 $C4 $06 $5E $5D $CB


Animations

The Korath has three animation cycles; the first is a four frame walking cycle, the second is a single frame sitting cycle, and the third is a one frame stunned cycle.

Keen 5

#Cache:
%patch $31A50 [$0126W] #Korath cache start
%patch $31AA4 [$012FW] #Cache end

#Korath walking
%patch $33412 $0126W $012AW
%patch $3341C $0008W        #Animation speed
%patch $33430 $0127W $012BW
%patch $3343A $0008W        #Animation speed
%patch $3344E $0128W $012CW
%patch $33458 $0008W        #Animation speed
%patch $3346C $0129W $012DW
%patch $33476 $0008W        #Animation speed

#Korath sit
%patch $3348A $012EW $012EW
%patch $33494 $001EW        #How long Korath sits

#Korath stunned
%patch $334A8 $012FW $012FW
%patch $334B2 $0000W        #Animation speed


Sprite positioning

The Korath spawns 8 pixels or half a tile higher then where it is placed in level, so that it may walk on the ground. If the Korath's sprite height is changed this must be changed also.

Keen 5

#Spawn height
%patch $138EC [$FF80W] #1/2 tile up


Sprite-tile interaction

The Korath does not have its own tile interaction, but uses a general 'move l/r and down slopes' interaction that is used by many walking sprites and is used by walking and sitting Koraths. The stunned Korath however uses a generic 'stunned sprite' tile collision.

Keen 5

#Walk
%patch $3342A $090B17DCRL
%patch $33448 $090B17DCRL
%patch $33466 $090B17DCRL
%patch $33484 $090B17DCRL

#Sit
%patch $334A2 $090B17DCRL

#Stunned
%patch $334C0 $090B195ARL


Action type

The Korath uses type 0 for all its actions except being stunned. This is because it is a walking sprite with jerky motion.

Keen 5

#Walk
%patch $33416 $0000W #Doesn't fall
%patch $33434 $0000W #Doesn't fall
%patch $33452 $0000W #Doesn't fall
%patch $33470 $0000W #Doesn't fall

#Sit
%patch $3348E $0000W #Doesn't fall

#Stunned
%patch $334AC $0002W #Stunned


Deprotect and stick to ground

The Korath does not use the deprotect animation parameter (this is 0); but must climb up and down hills, so uses a value of 1 for its 'stick to ground' variable. (Except of course, when it is stunned.)

Keen 5

#Walk
%patch $33418 $0000W $0001W
%patch $33436 $0000W $0001W
%patch $33454 $0000W $0001W
%patch $33472 $0000W $0001W

#Stand
%patch $33490 $0000W $0001W

#Stunned
%patch $334AE $0000W $0000W


Probability and randomness

There are three things that are random in relation to the Korath. The first is how often the Korath will be spawned moving left as opposed to right. By default it has a 50:50 chance of either. The second thing is how often the Korath pauses to stand; this is much less often. Finally after standing the Korath moves off left or right, again this is a 50:50 split by default.

Keen 5

#Chance of initially moving right:
%patch $138F7 [$0080W]

#Probability Korath will go to standing while walking
%patch $1392E [$0010W]

#Probability Korath will resume walking right
%patch $1393E [$0080W]


Sprite spawn code

There is only one type of Korath, spawned on all difficulties. Note its cache is set at $C7 $06 $C2A3W $0001W

The spawning code is more complex. In the spawning code the last blue highlighted value is the sprite action the Ampton 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. 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.

$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. The Korath uses $9A $1DFB0036RL $3D $0080W $7D to determine the random probability that it will spawn moving left or right. By default it has a 50:50 chance of doing either.

The spawn code contains and is thus incompatible with a number of patches elsewhere on this page.

Keen 5

#Location of initiation code
%patch $F5BC [$63FW]   #Korath (At $F38F)

#Korath Initiation code
%patch $F38F $57 $56 $9A $11C41C81RL    $83 $C4 $04 $C7 $06 $C2A3W  $0001W  $EB $06

#Korath spawning code
%patch $138C1 $55 $8B $EC $33 $C0 $50 $9A $06B91DCDRL     $83 $C4 $02 $8B $1E
              $40 $9E $C7 $07 [$0017W]  $C7 $47 $02 [$0001W]  $8B $46 $06 $B1 $08
              $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $05 [$FF80W]  $89 $47 $0C
              $9A $1DFB0036RL     $3D [$0080W]  {$7D} $0B $8B $1E $40 $9E $C7 $47
              $0E [$0001W]  $EB $09 $8B $1E $40 $9E $C7 $47 $0E [$FFFFW]  $B8 [$30D2W]
                  $50 $FF $36 $40 $9E $9A $090B11C4RL     $83 $C4 $04 $5D $CB


Korath has a sprite strength

This patch alters the Korath's spawn code so that it has a strength. As a side effect of this however its initial spawning direction is no longer randomly left or right but instead is always right. This is also incompatible with the Korath's spawning action patch at the top of this page, the probability patch for initial direction and the direction patches.

The first blue value is the strength (Here, two.), the second is the Korath's initial direction and the third its starting action. (See above section for details.)

In order to actually use the strength given the Korath must use a custom collision that has a strength built in. This is the second and third parts of the patch here, which can be altered.

Keen 5

#Korath has a strength of 2 (Now always spawns moving right.)
%patch $138F1 $C7 $47 $40 [$0002W]  $C7 $47 $0E [$0001W]  $B8 [$30D2W]
              $50 $FF $36 $40 $9E $9A $090B11C4RL     $83 $C4 $04 $5D $CB

#Use new collision when walking, sitting
%patch $33426 $06B90E68RL
%patch $33444 $06B90E68RL
%patch $33462 $06B90E68RL
%patch $33480 $06B90E68RL
%patch $3349E $06B90E68RL

#New collision for Korath
%patch $79F6 $EB $5C
%patch $79F8 $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D $02 $75 $05
             $9A $0AAF1517RL     $83 $3D $03 $75 $34 $FF $4C $40 $75 $1C $C7
             $44 $16 $0000W  $C7 $44 $18 $0000W  $B8 $3168W  $50 $57 $56 $9A
             $090B16CDRL     $83 $C4 $06 $5F $5E $5D $CB $C7 $44 $42 $0002W
             $C7 $44 $04 $0001W  $57 $9A $0CCB10B3RL     $83 $C4 $02 $5F $5E
             $5D $CB