Patch:Wormouth

From KeenWiki
Jump to navigation Jump to search

This page covers patches relating to the Wormouths in Keen 4. The Wormouth appear in several levels and are notable in that they are mostly unobtrusive, staying low to the ground and indestructible until keen is close, whereupon they attack.


Sprite Type

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

Keen 4

#Wormouth sprite type
%patch $1081A $0C


Sprite Actions

The Wormouth has a number of behaviors that are quite straightforward. Wormouth are place in-level moving back and forth. This is a single action loop that is only stopped when it randomly looks for Keen. Looking for Keen is an 8 action sequence that ends with the Wormouth returning to moving. (If it 'sees' Keen it will abort the looking sequence and head towards him.)

When close enough to Keen the Wormouth will perform the attack sequence; a five action sequence that ends with the Wormouth returning to moving. (If Keen is still close they will attack again.) The Wormouth can be shot and stunned. The stunned Wormouth does nothing.

Actions:
$26DEW #Wormouth moving
$26FCW #Wormouth looking around 1
$271AW #Wormouth looking around 2
$2738W #Wormouth looking around 3
$2756W #Wormouth looking around 4
$2774W #Wormouth looking around 5
$2792W #Wormouth looking around 6
$27B0W #Wormouth looking around 7
$27CEW #Wormouth looking around 8
$27ECW #Wormouth biting 1
$280AW #Wormouth biting 2
$2828W #Wormouth biting 3
$2846W #Wormouth biting 4
$2864W #Wormouth biting 5
$2882W #Wormouth stunned

Keen 4

#Wormouth placed in-level
%patch $10863 [$26DEW]

#Moving loop
%patch $3156A [$26DEW]

#Randomyl look while moving
%patch $1090D [$26FCW]

#Look for Keen sequence
%patch $31588 [$271AW]
%patch $315A6 [$2738W]
%patch $315C4 [$2756W]
%patch $315E2 [$2774W]
%patch $31600 [$2792W]
%patch $3161E [$27B0W]
%patch $3163C [$27CEW]
%patch $3165A [$26DEW]

#Stop looking if Keen is seen
%patch $108CF [$26DEW] #See Keen on left
%patch $1088C [$26DEW] #See Keen on right

#Attack if Keen is near
%patch $10955 [$27ECW]

#While attack sequence
%patch $31678 [$280AW]
%patch $31696 [$2828W]
%patch $316B4 [$2846W]
%patch $316D2 [$2864W]
%patch $316F0 [$26DEW]

#When shot
%patch $1096A [$2882W]

#While stunned
%patch $3170E [$0000W]


Sprite Behavior

The Wormouth's behaviors are interesting. Mostly they relate to seeking Keen. While moving the Wormouth will constantly look to bite Keen. When looking for Keen it oddly looks left first, then right, (but not both at once.) After looking it uses a 'head towards Keen' behavior. Finally when shot it uses a standard 'shot sprite' behavior used by many sprites.

Behaviors:
$09DC16C9RL #Shot sprite
$10800071RL #Wormouth look right
$108000B4RL #Wormouth look left
$10800091RL #Head toward Keen
$108000D4RL #Wormouth check to bite

Keen 4

#Moving
%patch $3155E $108000D4RL #Wormouth check to bite

#Look around
%patch $3157C $00000000L  #Nothing
%patch $3159A $00000000L  #Nothing
%patch $315B8 $108000B4RL #Wormouth look left
%patch $315D6 $00000000L  #Nothing
%patch $315F4 $00000000L  #Nothing
%patch $31612 $00000000L  #Nothing
%patch $31630 $10800071RL #Wormouth look right
%patch $3164E $10800091RL #Head toward Keen

#Biting
%patch $3166C $00000000L  #Nothing
%patch $3168A $00000000L  #Nothing
%patch $316A8 $00000000L  #Nothing
%patch $316C6 $00000000L  #Nothing
%patch $316E4 $00000000L  #Nothing

#Stunned
%patch $31702 $09DC16C9RL #Shot sprite


Wormouth doesn't look around

This patch stops the Wormouth from looking around and thus makes it much less able to track Keen.

Keen 4

#Wormouth doesn't look for Keen
%patch $108F4 $EB $1F


Seeking Keen

The Wormouth has several checks before it bites the player. The first two checks determine whether the Wormouth is close enough to Keen to attempt to bite him. This is +-3 tiles.

Once the Wormouth passes this test, it does a more specific test to see if Keen is vertically level with it and to make sure Keen is not behind it. (There is no point being close enough to bite Keen if it is behind him and facing the wrong way.)

Keen seeking

#Look
%patch $10887 $0001W #Look right, see Keen, go right
%patch $108CA $FFFFW #Look left, see Keen, go right
%patch $108A7 $0001W #Look miss Keen, go right
%patch $108AF $FFFFW #Look miss Keen, go left

#Look (Related to bite!)
%patch $108F6 $00 $FD #Look range, tiles, left (-3)
%patch $108FC $00 $03 #Look range, tiles, right (3)

#Bite range
%patch $10918 $00 $FF #Bite range, tiles, up    (-1)
%patch $1091F $00 $01 #Bite range, tiles, down  (+1)
%patch $1092B $80 $00 #Bite right range, tiles, right (+1)
%patch $10931 $80 $01 #Bite right range, tiles, right (+1.5)
%patch $1093D $80     #Bite left range, tiles, right  (0.5)
%patch $10942 $00 $FE #Bite left range, tiles, left  (-2)


Speed and Jump Height

The Wormouth has only one animation speed, its movement while small and moving. Otherwise it has no speed at all.

Animation motion

#Small Wormouth
%patch $3155A [$0010W $0000W]

#Looking around
%patch $31578 [$0000W $0000W]
%patch $31596 [$0000W $0000W]
%patch $315B4 [$0000W $0000W]
%patch $315D2 [$0000W $0000W]
%patch $315F0 [$0000W $0000W]
%patch $3160E [$0000W $0000W]
%patch $3162C [$0000W $0000W]
%patch $3164A [$0000W $0000W]

#Attack sequence
%patch $31668 [$0000W $0000W]
%patch $31686 [$0000W $0000W]
%patch $316A4 [$0000W $0000W]
%patch $316C2 [$0000W $0000W]
%patch $316E0 [$0000W $0000W]

#Stunned
%patch $316FE [$0000W $0000W]


Sprite Collision

The Wormouth collision is simple, but handled in an interesting manner.


Collision values

The Wormouth uses no collision when moving about, making it indestructible and harmless. It uses one collision when looking around; but this isn't one that let's Keen kill it. It's stunnable collision is used when it is biting, meaning Keen can only kill it when it is attacking.

Keen 4 collision values

#Moving
%patch $31562 $00000000L #No collision

#Looking around
%patch $31580 $1080015DRL #Wormouth looking around 1
%patch $3159E $1080015DRL #Wormouth looking around 2
%patch $315BC $1080015DRL #Wormouth looking around 3
%patch $315DA $1080015DRL #Wormouth looking around 4
%patch $315F8 $1080015DRL #Wormouth looking around 5
%patch $31616 $1080015DRL #Wormouth looking around 6
%patch $31634 $1080015DRL #Wormouth looking around 7
%patch $31652 $00000000L  #No collision -Going to move

#Biting
%patch $31670 $1080017CRL #Wormouth biting 1
%patch $3168E $1080017CRL #Wormouth biting 2
%patch $316AC $1080017CRL #Wormouth biting 3
%patch $316CA $1080017CRL #Wormouth biting 4
%patch $316E8 $1080017CRL #Wormouth biting 5

#Stunned
%patch $31706 $00000000L #No collision


Animations

There is little to say about the Wormouth animations; they are quite straightforward.

Keen 4

#Cache
%patch $30700 [$01C9W] #Wormouth Cache start
%patch $3074A [$01D4W] #Wormouth cache end

#Wormouth moving
%patch $3154E $01C9W $01C9W
%patch $31558 $0004W        #Reaction speed

#Looking around
%patch $3156C $01CCW $01CCW
%patch $31576 $0014W        #Animation speed
%patch $3158A $01CDW $01CDW
%patch $31594 $0008W        #Animation speed
%patch $315A8 $01CCW $01CCW
%patch $315B2 $0014W        #Animation speed
%patch $315C6 $01C9W $01C9W
%patch $315D0 $0008W        #Animation speed
%patch $315E4 $01CAW $01CAW
%patch $315EE $0014W        #Animation speed
%patch $31602 $01CBW $01CBW
%patch $3160C $0008W        #Animation speed
%patch $31620 $01CAW $01CAW
%patch $3162A $0014W        #Animation speed
%patch $3163E $01C9W $01C9W
%patch $31648 $0008W        #Animation speed

#Biting
%patch $3165C $01D1W $01CEW
%patch $31666 $0008W        #Animation speed
%patch $3167A $01D2W $01CFW
%patch $31684 $0008W        #Animation speed
%patch $31698 $01D3W $01D0W
%patch $316A2 $0010W        #Animation speed
%patch $316B6 $01D2W $01CFW
%patch $316C0 $0008W        #Animation speed
%patch $316D4 $01D1W $01CEW
%patch $316DE $0008W        #Animation speed
%patch $316F2 $01D4W $01D4W
%patch $316FC $000AW        #Animation speed

#Wormouth stunned
%patch $316F2 $01D4W $01D4W
%patch $316FC $000AW


Sprite positioning and landing on the ground

The Wormouth spawns 7 pixels up from where it is placed, so it can move on the ground. This is vitally important.

Keen 4

#Spawn height:
%patch $10836 $8F $00 #7 pixels up

Sounds

The Wormouth makes a noise when attacking. This sound can be blocked.

Keen 4

#Wormouth bites sound
%patch $10947 $05

#Don't play Wormouth bites sound
%patch $10946 $EB $0A


Clipping and foreground

The Wormouth's foreground variable is set to 0, meaning it appears behind most sprites and fore tiles. This is required since it must appear to be embedded in the ground.

Keen 4

#Wormouth Foreground variable
%patch $10824 [$0000W] #Wormouth


Sprite-tile interaction

The moving Wormouth uses the 'turn at edges and walls' code used by many sprites. The stunned Wormouth uses a default 'shot sprite' code and the remaining actions use a general 'draw sprite' interaction that ignores tiles entirely. (Since they are not moving actions.).

Keen 4

#Small and moving
%patch $31566 $09DC1795RL

#Looking around
%patch $31584 $09DC176ERL
%patch $315A2 $09DC176ERL
%patch $315C0 $09DC176ERL
%patch $315DE $09DC176ERL
%patch $315FC $09DC176ERL
%patch $3161A $09DC176ERL
%patch $31638 $09DC176ERL
%patch $31656 $09DC176ERL

#Biting
%patch $31674 $09DC176ERL
%patch $31692 $09DC176ERL
%patch $316B0 $09DC176ERL
%patch $316CE $09DC176ERL
%patch $316EC $09DC176ERL

#Stunned
%patch $3170A $09DC1913RL


Action type

The Stunned Wormouth uses type 2, like most stunned sprites. The moving Wormouth is type 1 as it needs to react quickly. Other actions are type 0.

Keen 4

#Small and moving
%patch $31552 {$0001W}

#Looking around
%patch $31570 {$0000W}
%patch $3158E {$0000W}
%patch $315AC {$0000W}
%patch $315CA {$0000W}
%patch $315E8 {$0000W}
%patch $31606 {$0000W}
%patch $31624 {$0000W}
%patch $31642 {$0000W}

#Biting
%patch $31660 {$0000W}
%patch $3167E {$0000W}
%patch $3169C {$0000W}
%patch $316BA {$0000W}
%patch $316D8 {$0000W}

#Wormouth stunned
%patch $316F6S {$0002W}


Deprotect and stick to ground

The Wormouth has a stick-to-ground value of 1 whenever it is moving. All other actions set it to 0.

Keen 4

%patch $31554 [$0001W $0001W] #Crawling

%patch $31572 [$0000W $0000W] #Looking about 1
%patch $31590 [$0000W $0000W] #Looking about 2
%patch $315AE [$0000W $0000W] #Looking about 3
%patch $315CC [$0000W $0000W] #Looking about 4
%patch $315EA [$0000W $0000W] #Looking about 5
%patch $31608 [$0000W $0000W] #Looking about 6
%patch $31626 [$0000W $0000W] #Looking about 7
%patch $31644 [$0000W $0000W] #Looking about 8

%patch $31662 [$0000W $0000W] #Chomping 1
%patch $31680 [$0000W $0000W] #Chomping 2
%patch $3169E [$0000W $0000W] #Chomping 3
%patch $316BC [$0000W $0000W] #Chomping 4
%patch $316DA [$0000W $0000W] #Chomping 5

%patch $316F8 [$0000W $0000W] #Stunned


Probability and randomness

Wormouth can be spawned moving right or left, there is a 50:50 chance of this. They also look for Keen randomly, but there is a much lower chance of this.

Keen 4

#Spawned moving right or left
%patch $10841 $80

#Look around frequency
%patch $10906 $06


Sprite spawn code

There are three different difficulties of Wormouth in the game. In the initiation code notice the Wormouth cache being set ($C7 $06 $CB6BW $0001W.)

Keen 4

#Location of initiation code
%patch $EE91 [$014BW] #Easy Wormouth (At $EA3B)
%patch $EEE9 [$0141W] #Medium Wormouth (At $EA31)
%patch $EEEB [$0137W] #Hard Wormouth (At $EA27)

#Wormouth Initiation code
%patch $EA27 $83 $3E [$7A6CW]  {$03 $7D} $03 $E9 $03CCW  $83 $3E [$7A6CW]  {$02}
             {$7D} $03 $E9 $03C2W  $FF $76 $FC $57 $9A {$10800006RL}     $83 $C4
             $04 $C7 $06 $CB6BW  $0001W  $E9 $03ADW