Patch:Shockshund

From KeenWiki
Jump to navigation Jump to search

This page covers patches relating to the Shockshunds in Keen 5. They are three legged energy-dogs used as guards by the Shikadi, found aboard the Omegamatic in Keen 5. They are loyal and fierce, if small (only a foot tall) and can jump surprisingly large distances. They are capable of shooting "energy barks" at intruders and are lethal to touch.


Sprite Type

Shockshund use sprite type 21 which is used only by the Shockshund and doesn't affect anything else. Their energy shots should also ahve their own sprite type, but this cannot yet be patched.

Keen 5

#Shockshund sprite type
%patch $1326B $15


Sprite Actions

Shockshund actions are quite complex. Shocksund are spawned walking, a four frame loop that they will remain in until they do one of several things. Shocksund randomly jump, sit or bark (if Keen is near) when walking. They will also ump when they reach the edge of a platform.

Sitting is a two frame sequence that ends with the Shocksund returning to walking after a specific amount of time not related to the sitting actions. Jumping is a single frame that 'looks as if it should lead to the Shocksund returning to walking frame 2 quite quickly, instead it becomes walking frame 1 only when it hits solid ground.

The barking sequence is two actions long and ends with the Shocksund returning to walking. The Shocksund's shot has a two action loop that it stays in until it hits walls, Keen's shot or Keen, whereupon it smashes and vanishes.

Actions:
$2E96W #Shocksund sit 1
$2EB4W #Shocksund sit 2
$2ED2W #Shocksund bark 1
$2EF0W #Shocksund bark 2
$2F0EW #Shocksund walk 1
$2F2CW #Shocksund walk 2
$2F4AW #Shocksund walk 3
$2F68W #Shocksund walk 4
$2F86W #Shocksund jump
$2FA4W #Shocksund's shot 1
$2FC2W #Shocksund's shot 2
$2FE0W #Shocksund's shot smash 1
$2FFEW #Shocksund's shot smash 2
$301CW #Shocksund stunned

Keen 5

#When spawned
%patch $13296 [$2F0EW]

#Walking loop
%patch $3326A [$2F2CW]
%patch $33288 [$2F4AW]
%patch $332A6 [$2F68W]
%patch $332C4 [$2F0EW]

#When walking
%patch $132D6 [$2E96W] #Shocksund sit (Randomly when walking)
%patch $1331B [$2ED2W] #Shocksund bark (Randomly when Keen is near)
%patch $132EF [$2F86W] #Shocksund jump (Randomly on flat ground)

#At the edge of platforms
%patch $13474 [$2F86W]

#Sitting loop
%patch $331F2 [$2EB4W]
%patch $33210 [$2E96W]

#After sitting
%patch $1332F [$2F0EW]

#Jumping
%patch $332E2 [$2F2CW]

#After jumping
%patch $13525 [$2F0EW]

#While barking
%patch $3322E [$2EF0W]
%patch $3324C [$2F0EW]

#What is made when barking
%patch $13350 [$2FA4W]

#Shocksund's shot loop
%patch $33300 [$2FC2W]
%patch $3331E [$2FA4W]

#Shocksund's shot hits
%patch $13591 [$2FE0W] #Keen
%patch $135B0 [$2FE0W] #Keen's shots
%patch $135EC [$2FE0W] #Walls

#Shocksund's shot smash sequence
%patch $3333C [$2FFEW]
%patch $3335A [$0000W]

#When shot
%patch $133B7 [$301CW]

#While stunned
%patch $33378 [$0000W]


Sprite Behavior

The Shocksund has three unique behaviors, sitting, walking and shooting. Each of these is only used in the last frame of its sequence. This is because they cause random stuff to happen.

When stunned or jumping the Shocksund uses a generic 'fall to the ground' behavior used by many such sprites. Similarly its shots use the 'enemy projectile' behavior used by many enemy's shots.

Behaviors:
$11C416E0RL #Shock sit (Good boy Shocksund!)
$11C416F4RL #Shock bark
$11C41664RL #Shock walk

Keen 5

#Sit
%patch $331E6 $00000000L  #Nothing
%patch $33204 $11C416E0RL #Shock sit

#Bark
%patch $33222 $00000000L  #Nothing
%patch $33240 $11C416F4RL #Shock bark

#Walk
%patch $3325E $00000000L  #Nothing
%patch $3327C $00000000L  #Nothing
%patch $3329A $00000000L  #Nothing
%patch $332B8 $11C41664RL #Shock walk

#Jumps
%patch $332D6 $090B1710RL #Fall

#Barks
%patch $332F4 $090B1748RL #Enemy shot
%patch $33312 $090B1748RL #Enemy shot

#Barks smash
%patch $33330 $00000000L  #Nothing
%patch $3334E $00000000L  #Nothing

#Stunned
%patch $3336C $090B1710RL #Fall


Shocksund never sits

This patch prevents the Shocksund from randomly sitting while walking about.

Keen 5

#Shocksund never sits
%patch $132C3 $EB $1B

Keen 5

#Shocksund never barks
%patch $13308 $5E $5D $CB


Shocksund never barks

This patch prevents the Shocksund from randomly barking at Keen while walking about and while Keen is in barking range.

Keen 5

#Shocksund never barks
%patch $13308 $5E $5D $CB


Shocksund shoot behavior code

This is the complete behavior code for the Shocksund barking. This is what causes a shot to be produced. On the first line the Shocksund's direction is checked. If it is shooting right then the Shocksund's shot will have to be moved right a bit relative to the Shocksund. This amount (7 pixels) is on line 2, as is the action of the sprite produced.

On line 3 is the vertical position of the shot (4 pixels down from thee Shocksund's head.) Finally on the fifth line is the sound the Shocksund makes when barking.

Keen 5

#Shocksund bark behavior code
%patch $13334 $55 $8B $EC $56 $57 $8B $76 $06 $83 $7C {$0E} [$01] {$75} $0A $8B $44
              $0A $05 [$0070W]  $8B $F8 $EB $03 $8B $7C $0A $B8 [$2FA4W]  $50 $8B
              $44 $0C $05 [$0040W]  $50 $57 $9A $0F920003RL     $83 $C4 $06 $3D
              $FFFFW  {$74} $21 $8B $44 $0E $BA $003CW  $F7 $EA $8B $1E $40 $9E
              $89 $47 $16 $8B $44 $0E $89 $47 $0E $B8 [$002AW]  $50 $9A $196E09EFRL
                      $83 $C4 $02 $5F $5E $5D $CB


Speed and Jump Height

The Shocksund has not one, but two jumps, each of which is totally unrelated. The first is the jump that happens randomly when the Shocksund is walking. The second is the one that always occurs when a Shocksund reaches the end of a platform. Both can be left or right, but are always the same height no matter what direction the Shocksund is moving.

The Shocksund's walking speed is defined in its animation motion. (Interestingly its jumping frame moves too.) The Shocksund's shot's speed is defined in its code and cannot yet be patched.

Shocksund jump speeds

#Flat ground jumps
%patch $132FA [$0028W] #Right speed
%patch $13301 [$FFD8W] #Left speed
%patch $13306 [$FFD8W] #Upwards speed

#Platform edge jumps
%patch $13489 [$0028W] #Right speed
%patch $13490 [$FFD8W] #Left speed
%patch $13495 [$FFD8W] #Upwards speed

Animation motion

#Shocksund sit
%patch $331E2 [$0000W $0000W]
%patch $33200 [$0000W $0000W]

#Bark
%patch $3321E [$0000W $0000W]
%patch $3323C [$0000W $0000W]

#Walk
%patch $3325A [$0080W $0000W]
%patch $33278 [$0080W $0000W]
%patch $33296 [$0080W $0000W]
%patch $332B4 [$0080W $0000W]

#Jump
%patch $332D2 [$0080W $0000W]

#Shot
%patch $332F0 [$0000W $0000W]
%patch $3330E [$0000W $0000W]

#Shot smash
%patch $3332C [$0000W $0000W]
%patch $3334A [$0000W $0000W]

#Stunned shock
%patch $33368 [$0000W $0000W]


Sprite Collision and strength

Both the Shocksund and its shot have their own special collisions.


Collision values

The Shockshund uses its own special collision. It will be killed if hit by Keen's shots, and kill Keen if he touches it. The stunned Shockshund are harmless (No collision). The Shocksund takes two shots to destroy and it is possible to patch how long it flashes white for the first time it is shot.

The Shocksund's shot has its own collision, smashing when it hits Keen's shots or Keen, allowing him to destroy it.

Keen 5 collision values

#Sit
%patch $331EA $11C4174DRL #Shocksund
%patch $33208 $11C4174DRL #Shocksund

#Bark
%patch $33226 $11C4174DRL #Shocksund
%patch $33244 $11C4174DRL #Shocksund

#Walk
%patch $33262 $11C4174DRL #Shocksund
%patch $33280 $11C4174DRL #Shocksund
%patch $3329E $11C4174DRL #Shocksund
%patch $332BC $11C4174DRL #Shocksund

#Jump
%patch $332DA $11C4174DRL #Shocksund

#Shot
%patch $332F8 $11C4193BRL #Shocksund's shot
%patch $33316 $11C4193BRL #Shocksund's shot

#Stunned
%patch $33370 $00000000L  #Nothing

#Shot smash
%patch $33334 $00000000L  #Nothing
%patch $33352 $00000000L  #Nothing

Keen 5 strength

#Shocksund strength
%patch $1328A [$0002W]

#Length of time Shocksund flashes white when shot:
%patch $133CB [$0002W]


Collision code

Shocksund

This is the complete collision for the Shocksund. The first section reacts to Keen's sprite type. This runs the 'kill the player' code if Keen is found. On the end of line 2 the Shocksund responds to Keen's shot type. There are two things that may happen depending on if the Shocksund is out of health. The first is its stunning, this sets its horizontal and vertical speeds to 0 and runs the 'stun sprite' code, destroying Keen's shot.

If the Shocksund still has health a 'flash length' of 2 is set, the sprite's type is temporarily set to 1 and the 'hurt sprite' code is run, again destroying Keen's shot and removing 1 health from the sprite.

Keen 5

#Shocksund's collision
%patch $1338D $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 [$301CW]  $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


Shocksund's shot

This is the complete collision for the Shocksund's shot. The first section reacts to Keen's sprite type. This runs the 'kill the player' code if Keen is found and transforms the shot into a smashed shot on line 2. On line 3 the shot responds to Keen's shot type, converting Keen's shot into Keen's smashed shot and then also converting the Shocksund's shot into a smashed shot in the same way as happens when it hits Keen.

Keen 5

#Shocksund's shot collision
%patch $1357B $55 $8B $EC $56 $57 $8B $7E $06 $8B $76 $08 $83 $3C [$02] {$75} $16
              $9A $0AAF1517RL     $B8 [$2FE0W]  $50 $57 $9A $090B1242RL     $83
              $C4 $04 $5F $5E $5D $CB
                                      $83 $3C [$03] {$75} $16 $56 $9A $0CCB10B3RL
                  $83 $C4 $02 $B8 [$2FE0W]  $50 $57 $9A $090B1242RL     $83 $C4
              $04 $5F $5E $5D $CB


Misc

Shocksund doesn't flash when shot

This patch stops the Shocksund from flashing white when shot but not stunned.

Keen 5

#Shocksund doesn't flash when shot
%patch $133C8 $EB $03


Shocksund's shots stun Keen

This patch alters the Shocksund's shot so that instead of killing Keen it stuns him. This patch uses the EGAGRAPH check skip and thus may be incompatible with other patches that use it. (It is buffered however so shouldn't interfere with small skip patches.)

The stun time in this patch is $004C, this can be easily altered. Keen returns to a recovery frame after stunning. To eliminate this replace the brown value with $0888W Keen will stun even with God mode enabled. Keen will not stun when in the air, instead he will be 'knocked' and his jump\fall disrupted.

As a side effect the sprite action for what shot becomes when it collides with Keen becomes invalid and overwritten. (The shot will now become the same thing when it hits Keen OR his shot.)

Keen 5

#Disable EGAGRAPH check in Keen 5 (Frees 389 bytes at $3CF0)
%patch $3CDF $90 $90

#Shocksund's shot's collision transforms Keen
%patch $1358B $56 $9A $037D05AFRL     $83 $C4 $02 $EB $19

#New transform, stun Keen
%patch $3D7F $55 $8B $EC $56 $8B $76 $06 $B8 [$014DW]  $50 $56
             $9A $090B1242RL     $83 $C4 $04 $5E $5D $CB

#Stunned Keen action (Read book type) =$014DW
%patch $3048D $008EW $008EW $0000W $0000W $0001W [$004CW] $0000W $0000W
              $00000000L    $0AAF1597RL   $0AAF1AC6RL   {$0AFEW}


Animations

The Shocksund's animations are extensive, if simple to understand. Two frames are used for sitting and four for barking. Eight are used for walking (For for each direction) and another two for jumping (ditto). The shot and its smashing sequence have two animations each (total four) and the stunned Shocksund uses the last animation.

Keen 5

#Cache
%patch $31A32 [$0151W] #Shocksund cache start
%patch $31A86 [$0165W] #Cache end

#Shocksund sit
%patch $331D6 $0151W $0151W
%patch $331E0 $0008W        #Animation speed
%patch $331F4 $0152W $0152W
%patch $331FE $0008W        #Animation speed

#Shocksund bark
%patch $33212 $015FW $015DW 
%patch $3321C $0008W        #Animation speed
%patch $33230 $0160W $015EW
%patch $3323A $0008W        #Animation speed

#Shocksund walk
%patch $3324E $0157W $0153W
%patch $33258 $0008W        #Animation speed
%patch $3326C $0158W $0154W
%patch $33276 $0008W        #Animation speed
%patch $3328A $0159W $0155W
%patch $33294 $0008W        #Animation speed
%patch $332A8 $015AW $0156W
%patch $332B2 $0008W        #Animation speed

#Shocksund jump
%patch $332C6 $015BW $015CW
%patch $332D0 $0008W        #Animation speed

#Shocksund's shot
%patch $332E4 $0162W $0162W
%patch $332EE $0008W        #Animation speed
%patch $33302 $0163W $0163W
%patch $3330C $0008W        #Animation speed

#Shocksund's shot smash
%patch $33320 $0164W $0164W 
%patch $3332A $000AW        #Animation speed
%patch $3333E $0165W $0165W
%patch $33348 $000AW        #Animation speed

#Shocksund stunned
%patch $3335C $0161W $0161W
%patch $33366 $0000W        #Animation speed


Sprite positioning

The Shocksund spawns 8 pixels or half a tile up from where it is placed. This is not too vital, if its sprite height changes it will simply be spawned jumping instead of walking.

The Shocksund's shot is also spawned four pixels down from its head. When shooting right it also spawns 7 pixels right. (This stops the right facing Shocksund shooting from its left edge or tail.)

Keen 5

#Spawn height
%patch $13282 $FF80W #8 pixels up

#Shocksund shot spawn position
%patch $13346 $0070W #Horizontal when shooting right
%patch $13357 $0040W #Vertical


Sounds

The Shocksund makes a sound when it barks. This can be blocked.

Keen 5

#Sounds
%patch $135E0 $2D     #Shocksund bark sound

#Don't make sounds:
%patch $135DF $EB $0A #Don't play Shocksund bark sound


Sprite-tile interaction

The Shocksund has three unique tile interactions. The first is used when it is on flat ground, this makes it jump at platform edges and is used even when it is not moving. The second is when it is jumping, which allows it to return to walking when it hits solid tiles. The third is its shot's, which allow the shots to smash when they hit solid tiles. The stunned Shocksund uses a generic 'stunned sprite' tile interaction.

Keen 5

#Sit
%patch $331EE $11C4179FRL #Shocksund
%patch $3320C $11C4179FRL #Shocksund

#Bark
%patch $3322A $11C4179FRL #Shocksund
%patch $33248 $11C4179FRL #Shocksund

#Walk
%patch $33266 $11C4179FRL #Shocksund
%patch $33284 $11C4179FRL #Shocksund
%patch $332A2 $11C4179FRL #Shocksund
%patch $332C0 $11C4179FRL #Shocksund

#Jump
%patch $332DE $11C418CBRL #Shocksund jump

#Shots
%patch $332FC $11C41980RL #Shocksund's shot
%patch $3331A $11C41980RL #Shocksund's shot

#Shot smash
%patch $33338 $090B17B5RL #Solid
%patch $33356 $090B17B5RL #Solid

#Stunned
%patch $33374 $090B195ARL #Stunned


Action type

Most of the Shocksund's actions are type 0, meaning its movements can be a bit jerky. Its shot uses type 3 to move smoothly but react instantly to tiles and Keen. Jumping and stunned Shocksund use type 2, which freezes their action until something happens (In these cases hitting the ground.)

Keen 5

#Stand
%patch $331DA [$0000W]
%patch $331F8 [$0000W]

#Bark
%patch $33216 [$0000W]
%patch $33234 [$0000W]

#Walk
%patch $33252 [$0000W]
%patch $33270 [$0000W]
%patch $3328E [$0000W]
%patch $332AC [$0000W]

#Jump
%patch $332CA [$0002W]

#Shot
%patch $332E8 [$0003W]
%patch $33306 [$0003W]

#Shot smash
%patch $33324 [$0000W]
%patch $33342 [$0000W]

#Stunned
%patch $33360 [$0002W]


Deprotect and stick to ground

When walking, sitting or barking the Shocksund uses its stick to ground value, as it may be required to move down hills. All other actions do not use this value at all.

Keen 5

#Stand
%patch $331DC [$0000W $0001W]
%patch $331FA [$0000W $0001W]

#Bark
%patch $33218 [$0000W $0001W]
%patch $33236 [$0000W $0001W]

#Walk
%patch $33254 [$0000W $0001W]
%patch $33272 [$0000W $0001W]
%patch $33290 [$0000W $0001W]
%patch $332AE [$0000W $0001W]

#Jump
%patch $332CC [$0000W $0000W]

#Shots
%patch $332EA [$0000W $0000W]
%patch $33308 [$0000W $0000W]

#Shots smash
%patch $33326 [$0000W $0000W]
%patch $33344 [$0000W $0000W]

#Stunned
%patch $33362 [$0000W $0000W]


Probability and randomness

The Shocksund's bark and jump frequencies can be patched. If this is still too infrequent, patching the walking sprite behavior to be used more often (See section above) will double, triple or quadruple the bark frequency. (As well as the jump and sit frequencies.)

Keen 5

#Bark frequency
%patch $1330E $80

#Jump frequency
%patch $132C9 $10


Sprite spawn code

Only partial spawning code for the Shocksund is available. Notice that there are three types, one for each difficulty level. The cache is set in $C7 $06 $C285W $0001W.

The last blue highlighted value is the sprite action the sprite uses as it proceeds to act in-level. $C7 $47 $02 $0001W sets the Shocksund's activity, $C7 $07 $0015W sets the Shocksund's type. The Shocksund's strength. is set in $C7 $47 $40 $0002W set its Finally $D3 $E0 $05 $FF80W 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.

Keen 5

#Location of initiation code
%patch $F590 [$60DW]  #Easy Shockshund (At $F35D)
%patch $F592 [$606W]  #Normal Shockshund (At $F356)
%patch $F594 [$5FFW]  #Hard Shockshund (At $F34F)

#Shockshund initiation code
%patch $F34F $83 $3E [$6F6CW]  {$03 $7C} $51 $83 $3E [$6F6CW]  {$02 $7C} $4A $57 $56
             $9A {$11C41617RL}     $83 $C4 $04 $C7 $06 $C285W  $0001W  $EB $38

#Shockshund spawn code
%patch $13257 $55 $8B $EC $33 $C0 $50 $9A $06B91DCDRL     $83 $C4 $02 $8B $1E
              $40 $9E $C7 $07 [$0015W]  $C7 $47 $02 [$0001W]  $8B $46 $06 $B1 $08
              $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $05 [$FF80W]  $89 $47 $0C
              $C7 $47 $40 [$0002W]  $B8 [$0001W]  $89 $47 $10 $89 $47 $0E $B8 [$2F0EW]
                  $50 $53 $9A $090B11C4RL     $83 $C4 $04 $5D $CB