From KeenWiki
Jump to navigation Jump to search

This page covers patches relating to the Arachnuts in Keen 4. The Arachnuts appear in several levels and are notable in that they cannot be permanently stunned, eventually recovering from being shot.

Sprite Type

Arachnuts use sprite type 10 which is used only by them and doesn't affect anything else.

Keen 4

#Arachnut sprite type
%patch $10522 $0A

Sprite Actions

Arachnuts have three states, walking, stunned and recovering. Arachnuts are spawned running and will do nothing else until shot, whereupon they will be stunned. Stunned Arachnuts will, after some time recover, and after that return to running. Notice that the Arachnut cannot be permanently stunned.

$2378W #Arachnut walk 1
$2396W #Arachnut walk 2
$23B4W #Arachnut walk 3
$23D2W #Arachnut walk 4
$23F0W #Arachnut stunned
$240EW #Arachnut recovering 1
$242CW #Arachnut recovering 2
$244AW #Arachnut recovering 3
$2468W #Arachnut recovering 4

Keen 4

#Place Arachnut in level
%patch $1056B [$2378W] #Walk

#Walking Arachnut
%patch $31204 [$2396W] #Walk
%patch $31222 [$23B4W] #Walk
%patch $31240 [$23D2W] #Walk
%patch $3125E [$2378W] #Walk

#When shot
%patch $105A9 [$23F0W] #When shot, stun
%patch $105D5 [$23F0W] #When shot while stunned, stun again

%patch $3127C [$240EW] #Recover

%patch $3129A [$242CW] #Arachnut unstunning 1
%patch $312B8 [$244AW] #Arachnut unstunning 2
%patch $312D6 [$2468W] #Arachnut unstunning 3
%patch $312F4 [$2378W] #Walk

Sprite Behavior

The Arachnut has only one behavior of note, the one that makes it slightly random. Like the Inchworm it will head towards Keen, but it does so randomly, and only one of its actions uses it, meaning it takes a long time to change direction, allowing Keen to evade it.

$0FA80AF9RL #Randomly change direction towards Keen

Keen 4 Arachnut behaviors

%patch $311F8 {$00000000L}  #Nothing
%patch $31216 {$00000000L}  #Nothing
%patch $31234 {$00000000L}  #Nothing
%patch $31252 {$0FA80AF9RL} #Arachnut search

%patch $31270 {$00000000L}  #Nothing

%patch $3128E {$00000000L}  #Nothing
%patch $312AC {$00000000L}  #Nothing
%patch $312CA {$00000000L}  #Nothing
%patch $312E8 {$00000000L}  #Nothing

Movement code

The Arachnut movement code checks for Keen's horizontal position and then changes the Arachnut's direction to head towards Keen. It is quite simple, but the fact that only one frame uses this behavior means the Arachnut takes time to respond and can 'overshoot' Keen, making it seem more erratic.

Keen seeking

#Arachnut movement code
%patch $10579 $55 $8B $EC $56 $8B $76 $06 $8B $44 $0A $8B $1E $A7D6W  $3B $47
              $0A {$76 $08} $C7 $44 $0E [$FFFFW]  $5E $5D $CB $C7 $44 $0E [$0001W]
              $5E $5D $CB

Seeking Keen

By default the Arachnuts will move towards Keen all the time. It is possible to make them ignore Keen, they then just move back and forth. (Exactly the same as if they were given no behavior at all.) It is also possible to make them slightly more random by making them randomly turn right (Or left if $0001W is changed to $FFFFW) The probability given here is $80, or 50/50.

Keen seeking

#Walk towards Keen
%patch $1058F [$0001W]
%patch $10597 [$FFFFW]

Ignore Keen

#Arachnuts ignore Keen
%patch $1058A $5E $5D $CB

Ignore Keen, be randomish

#Arachnut randomly turn right
%patch $10583 $8B $76 $06 $9A $1D02002ARL $3D [$80] $00 $7D $03 $5E $5D $CB
              $C7 $44 $0E $0001W  $5E $5D $CB

Speed and Jump Height

The Arachnut's speed is determined entirely by its animation. By default the Arachnut moves a total of 128 per frame. Changing how fast the Arachnut animates (See animation section below) will change how fast it moves. The Arachnut moves only left and right. The stunned and recovering Arachnut do not move.

Keen 4

%patch $311F4 [$0080W $0000W] #Speed 1
%patch $31212 [$0080W $0000W] #Speed 2
%patch $31230 [$0080W $0000W] #Speed 3
%patch $3124E [$0080W $0000W] #Speed 4

%patch $3126C [$0000W $0000W] #Speed 

%patch $3128A [$0000W $0000W] #Speed 1
%patch $312A8 [$0000W $0000W] #Speed 2
%patch $312C6 [$0000W $0000W] #Speed 3
%patch $312E4 [$0000W $0000W] #Speed 4

Sprite Collision

The Arachnut collision is complex. There are two basic collisions, that of the Arachnut and that of the stunned Arachnut. They are the same, excepting that the stunned Arachnut is not dangerous to Keen. The stunned Arachnut is interesting in that it is set up so that eventually it will 'unstun' and come after Keen again.

Collision values

The Arachnut uses the 'dangerous' collision when walking. Everything else uses the 'safe' collision.

Keen 4

%patch $311FC $0FA80B1CRL #Arachnut
%patch $3121A $0FA80B1CRL #Arachnut
%patch $31238 $0FA80B1CRL #Arachnut
%patch $31256 $0FA80B1CRL #Arachnut

%patch $31274 $0FA80B48RL #Stunned Arachnut

%patch $31292 $0FA80B48RL #Stunned Arachnut
%patch $312B0 $0FA80B48RL #Stunned Arachnut
%patch $312CE $0FA80B48RL #Stunned Arachnut
%patch $312EC $0FA80B48RL #Stunned Arachnut

Arachnut stuns permanently

This patch adjusts the stunned Arachnut action so that instead of recovering that Arachnut stays permanently stunned, complete with stun stars. This makes it much more like every other enemy. Be aware that this patch contains, and is thus incompatible with, a number of patches elsewhere on this page involving the stunned Arachnut. (For example its animations, action type and behavior.)

This patch frees up the recovering Arachnut's actions for use elsewhere.

Keen 4

#Arachnut stuns permanently
%patch $31260 $01ADW $01ADW $0002W $0000W $0001W $0000W $0000W $0000W
              $09DC16C9RL   $00000000L    $09DC1913RL   $23F0W

Stunner doesn't affect Arachnut

This patch makes the stunner shot fly through the Arachnut.

Keen 4

#Stunner shot passes through Arachnut
%patch $105B0 $90 $90 $90 $90 $90


The Arachnut's animation is quite straightforward, it uses four images for walking left and right and a fifth frame for when it is stunned. Alternating stunned-walking images are used as the Arachnut recovers. This means the Arachnut is very image-efficient.

Notice that the animation speed for the stunned Arachnut determines how long it will be stunned for, and those of the recovering Arachnut determine both how long it will take to recover and how fast it animates while recovering.

Keen 4

%patch $306FC $A9 $01 #Arachnut Cache start
%patch $30746 $AD $01 #Arachnut cache end

%patch $311E8 $01A9W $01ACW
%patch $311F2 $0006W        #Animation speed
%patch $31206 $01AAW $01ABW
%patch $31210 $0006W        #Animation speed
%patch $31224 $01ABW $01AAW
%patch $3122E $0006W        #Animation speed
%patch $31242 $01ACW $01A9W
%patch $3124C $0006W        #Animation speed

#Arachnut stunned
%patch $31260 $01ADW $01ADW
%patch $3126A $00F0W        #Animation speed

#Arachnut unstunning
%patch $3127E $01A9W $01A9W
%patch $31288 $0014W        #Animation speed
%patch $3129C $01ADW $01ADW
%patch $312A6 $0014W        #Animation speed
%patch $312BA $01A9W $01A9W
%patch $312C4 $0014W        #Animation speed
%patch $312D8 $01ADW $01ADW
%patch $312E2 $0014W        #Animation speed

Sprite positioning

Arachnuts are spawned 1 tile, 7 pixels up from their placed position, so that they can walk smoothly on the ground.

Keen 4

#Spawn height:
%patch $1053E $FE8FW #1 tile, 7 pixels up

Clipping and foreground

The Arachnut has a foreground variable of 0, meaning it appears behind all sprites and foreground tiles.

Keen 4

#Arachnut foreground variable
%patch $1052C [$0000W]

Sprite-tile interaction

The Arachnut uses general tile collisions; when walking it uses the 'turn around at walls or edges' collision and when stunned or recovering it uses the 'sit' collision.

Keen 4

%patch $31200 $09DC1795RL #Walking
%patch $3121E $09DC1795RL #Walking
%patch $3123C $09DC1795RL #Walking
%patch $3125A $09DC1795RL #Walking

%patch $31278 $09DC176ERL #Stunned

%patch $31296 $09DC176ERL #Unstunning
%patch $312B4 $09DC176ERL #Unstunning
%patch $312D2 $09DC176ERL #Unstunning
%patch $312F0 $09DC176ERL #Unstunning

Action type

The Arachnut uses type 0 for all of its actions. This means that its motion is technically jerky, but it animates fast enough that this is not really noticeable.

Keen 4

#Arachnut moving
%patch $311EC [$0000W]
%patch $3120A [$0000W]
%patch $31228 [$0000W]
%patch $31246 [$0000W]

#Arachnut stunned
%patch $31264 [$0000W]

#Arachnut unstunning
%patch $31282 [$0000W]
%patch $312A0 [$0000W]
%patch $312BE [$0000W]
%patch $312DC [$0000W]

Deprotect and stick to ground

The Arachnut needs to move up and down slopes, so uses the stick-to-ground parameter in all of its actions. (Even when stunned.)

Keen 4

#Arachnut moving
%patch $311EE [$0000W $0001W]
%patch $3120C [$0000W $0001W]
%patch $3122A [$0000W $0001W]
%patch $31248 [$0000W $0001W]

#Arachnut stunned
%patch $31266 [$0000W $0001W]

#Arachnut unstunning
%patch $31284 [$0000W $0001W]
%patch $312A2 [$0000W $0001W]
%patch $312C0 [$0000W $0001W]
%patch $312DE [$0000W $0001W]

Probability and randomness

The Arachnut's initial direction is randomly decided with a 50:50 chance. This has little effect as the Arachnut chases Keen.

Keen 4

#Probability of initially moving right
%patch $10549 $80

Sprite spawn code

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

Keen 4

#Location of initiation code
%patch $EEAB [$02FAW] #Easy Arachnut (At $EBEA)
%patch $EF15 [$02F0W] #Medium Arachnut (At $EBE0)
%patch $EF17 [$02E6W] #Hard Arachnut (At $EBD6)

#Arachnut Initiation code
%patch $EBD6 $83 $3E [$7A6CW]  {$03 $7D} $03 $E9 $021DW  $83 $3E [$7A6CW]  {$02 $7D}
             $03 $E9 $0213W  $FF $76 $FC $57 $9A {$0FA80A8ERL}     $83 $C4 $04
             $C7 $06 $CB67W  $0001W  $E9 $01FEW