Patch:Flect

From KeenWiki
Jump to: navigation, search

This page covers patches relating to the Flects in Keen 6. Flect are yellow bucktoothed enemies notable for reflecting Keen's shots back at him, causing him to be stunned. (hence their name, reFlect.) They can only be stunned when shot from above, but are harmless, simply pushing Keen around.


Sprite Type

Flect use sprite type 21. This is used by no other sprite and does not affect any other sprite type.

Patch: Keen 6
#Flect sprite type
%patch $11AF8 $15


Sprite Actions

Flects are quite simple, action-wise. They are spawned walking and will continue doing so either until they are too close to Keen, which may happen if he jumps down on top of them, when they will go to standing so as to get away from him, or when they need need to chase Keen.

Chasing Keen is achieved by changing the sprite direction and going to the turning action. After turning the Flect will return to walking (but will be moving in the opposite direction.) Flect will also turn when they hit walls or reach the end of a platform.

Standing is used to get away from Keen (to push him better.) The Flect will turn if it is too close to Keen to push him and after standing will return to walking. It will also return to walking 'early' if Keen moves far enough away from it while it is standing.

Finally the Flect can be stunned. When stunned it stays with its stunned action.

Actions:
$2BA6W  #Flect standing
$2BC4W  #Flect turning
$2BE2W  #Flect walking 1
$2C00W  #Flect walking 2
$2C1EW  #Flect walking 3
$2C3CW  #Flect walking 4
$2C5AW  #Flect stunned

Patch: Keen 6
#When spawned
%patch $11B41 $2BE2W
#Walking loop
%patch $3392E $2C00W %patch $3394C $2C1EW %patch $3396A $2C3CW %patch $33988 $2BE2W
#While walking
%patch $11B6B $2BC4W
#Turn if Keen is left of right moving Flect
%patch $11B89 $2BC4W
#Turn if Keen is right of left moving Flect
%patch $11BF3 $2BA6W
#Stand if Keen is too close to Flect
#Go to walk when standing
%patch $11B78 $2BE2W
#Far from Keen left
%patch $11B96 $2BE2W
#Far from Keen right
#After standing
%patch $338F2 $2BE2W
#After turning
%patch $33910 $2BE2W
#Turning when hitting walls
%patch $11BBD $2BC4W
#When hits right walls
%patch $11BDF $2BC4W
#When hits left walls
#When shot
%patch $11C22 $2C5AW
#While stunned
%patch $339A6 $2C5AW


Sprite Behavior

The Flect has two unique behaviors, walking and standing. The first is used when the Flect is walking. It makes the Flect turn in Keen's direction (chase him). The second is used when standing and is used mainly to prevent the Flect from spinni9ng rapidly around Keen if Keen jumps on top of it.

The stunned Flect uses a general 'move through the air' (fall) behavior.

Behaviors:
$08F41765RL #Move through the air
$10CC0E8FRL #Flect stand
$10CC0EDBRL #Flect walk, seek Keen

Patch: Keen 6
#Standing
%patch $338E6 $10CC0E8FRL
#Turning
%patch $33904 $00000000L
#Walking
%patch $33922 $10CC0EDBRL %patch $33940 $10CC0EDBRL %patch $3395E $10CC0EDBRL %patch $3397C $10CC0EDBRL
#Stunned
%patch $3399A $08F41765RL


Flect walking behavior code

The Flect's walking behavior is remarkably complicated for something with such a simple function. In essence it is simply Keen seeking which is explained in the section below. The Flect first seeks Keen by checking where the Flect is horizontally compared to Keen (This is $73, splinting left of Keen from right of Keen.) at the start of line 2.

Each turn has two direction checks of the Flect. For example before turning left the Flect checks that it is either moving right or not moving left before turning. (Otherwise left moving Flect would be constantly turning.

Finally if the Flect is too close to Keen it will go to its standing animation instead of turning. This stops it pointlessly 'spinning' around Keen if Keen jumps down on its head.

Patch: Flect walking behavior code
#Flect walking behavior code
%patch $11B9B $55 $8B $EC $56 $8B $76 $06 $8B $1E $64 $A9 $8B $47 $0A $3B $44 $0A $73 $16 $83 $7C $0E $01 $75 $10 $83 $7C $0E $FF $74 $05 $C7 $44 $1C $2BC4W $C7 $44 $0E $FFFFW $8B $1E $64 $A9 $8B $47 $0A $3B $44 $0A $76 $16 $83 $7C $0E $FF} $75 $10 $83 $7C $0E [$01 $74 $05 $C7 $44 $1C $2BC4W $C7 $44 $0E $0001W $9A $1CF30034RL $3D $0020W $7D $05 $C7 $44 $1C $2BA6W $5E $5D $CB


Seeking Keen

The Flect's Keen seeking is unexpectedly complex, as seen in the behavior code above. The Flect seeks Keen by turning towards him. The first check performed is where the Flect is horizontally compared to Keen. (This is $73, splinting left of Keen from right of Keen.)

Each turn has two direction checks of the Flect. For example before turning left the Flect checks that it is either moving right or not moving left before turning. (Otherwise left moving Flect would be constantly turning.) To reverse the seeking (make the Flect flee Keen) all $01 and $FF values must be reversed as well as the first check being changed from $73 to $76.

Finally if the Flect is too close to Keen it will go to its standing animation instead of turning. This stops it pointlessly 'spinning' around Keen if Keen jumps down on its head.

Patch: Flect walking behavior code
#Keen's position check
%patch $11BAC $73
#If right of Keen AND...
%patch $11BB1 $01 $75
#Walking right OR...
%patch $11BB1 $FF $74
#NOT walking left...
%patch $11BC2 $FFFFW
#Turn left
#Otherwise if...
%patch $11BD3 $FF $75
#Walking left OR...
%patch $11BD9 $01 $74
#NOT walking right...
%patch $11BE4 $0001W
#Turn right
#Stand if closer than 2 pixels
%patch $11BEC $0020W


Flect doesn't seek Keen

This patch stops the Flect from seeking Keen entirely; it simply removes the Flect's walking behavior so that it just walks back and forth.

Patch: Walking Flect doesn't chase Keen
#Walking Flect doesn't chase Keen
%patch $33922 $00000000L %patch $33940 $00000000L %patch $3395E $00000000L %patch $3397C $00000000L


Speed

The Flect's speed is entirely defined in its animation motion, notably its walking speed.

Patch: Keen 6 Animation motion
#Standing
%patch $338E2 $0000W $0000W
#Turning
%patch $33900 $0000W $0000W
#Walking
%patch $3391E $0080W $0000W %patch $3393C $0080W $0000W %patch $3395A $0080W $0000W %patch $33978 $0080W $0000W
#Stunned
%patch $33996 $0000W $0000W


Sprite Collision

The Flect has a complex collision that is poorly understood. It will push Keen and reflect his shots, but can be shot from above or behind and stunned.


Collision values

The Flect has only one collision, used at all times, except for the stunned Flect, which has no collision.

Patch: Keen 6 collision values
#Standing
%patch $338EA $10CC0F38RL
#Flect
#Turning
%patch $33908 $10CC0F38RL
#Flect
#Walking
%patch $33926 $10CC0F38RL
#Flect
%patch $33944 $10CC0F38RL
#Flect
%patch $33962 $10CC0F38RL
#Flect
%patch $33980 $10CC0F38RL
#Flect
#Stunned
%patch $3399E $00000000L
#Nothing


Collision code

Flect doesn't push Keen

This patch stops the Flect from pushing Keen in front of it, instead it will just pass through Keen.

Patch: Flect doesn't push Keen
#Flect doesn't push Keen
%patch $11C06 $EB


Flect kills Keen instead of pushing him

This patch stops the Flect from pushing Keen, instead the Flect will kill him.

Patch: Flect doesn't push Keen
#Flect kills Keen instead of pushing him
%patch $11C08 $9A $0AA213CARL $5F $5E $5D $CB


Stop Flect reflecting Keen's shot

This patch makes the Flect stun like any normal enemy; Keen can shoot it from the right or left and it will still stun.

Patch: Stop Flect reflecting Keen's shot
#Stop Flect reflecting Keen's shot
%patch $11C1B $EB $04


Shots pass through Flect

This patch stops the Flect from reflecting Keen's shot. Instead his shots pass straight through it. Two lines are used, on that affects either side of the Flect. The third line stops the 'bounce' sound being played.

Patch: Keen 6
%patch $11C3D $01 
#From right
%patch $11C40 $01
#From left
%patch $11C46 $EB $0A
#Don't play Flect reflect Keen's shots sound


Flect reflects shots downwards

This patch makes the Flect reflect Keen's shots downwards, into the ground. This looks very much as if the Flect were simply blocking Keen's shots.

Patch: Keen 6
%patch $11C3D $10 
#From right
%patch $11C40 $10
#From left


Flect doesn't reflect shot, but stops it, doesn't push Keen if he's standing still, and is immortal

This patch may be unstable.

Patch: Flect doesn't reflect shot, but stops it, doesn't push Keen if he's standing still, and is immortal
#Flect doesn't reflect shot, but stops it, doesn't push Keen if he's standing still, and is immortal
%patch $11C18 $02 %patch $11C05 $03


Flect stops shots, is immortal and doesn't push Keen

This patch may be unstable.

Patch: Flect stops shots, is immortal and doesn't push Keen
#Flect stops shots, is immortal and doesn't push Keen
%patch $11C05 $03


Stunned Flect recovers

This patch causes the Flect to stun only temporarily, quickly recovering. The first blue values are the stunned animation. The third is the stun time ($80 tics here.) and the fourth what the recovered Flect does (In this case turn.) The brown value is its collision, here the stunned Flect can be shot again to extend its stun time. (Replacing with $00000000L will cause it to not be shootable.)

Patch: Keen 6
#Stunned Flect recovers, no stun stars
%patch $3398A $0148W $0148W $0000W $0000W $0001W $0080W $0000W $0000W $00000000L $10CC0F38RL $10CC0F96RL $2BC4W


Animations

Flect are interesting. Their standing frame is the only one that uses two animations. Its turning and stunned frames use one animation each and its walk cycle eight. The walking animation speed affects the Flect's walking speed, and its standing\turning times affect how long these actions take, which in turn affects how long they can be shot in the back for.

Patch: Keen 6 Animations
#Cache
%patch $32442 $013DW
#Flect cache start
%patch $32492 $0148W
#Flect cache end
#Stand
%patch $338D6 $0143W $013EW %patch $338E0 $003CW
#Standing time
#Turn
%patch $338F4 $013DW $013DW
#Flect turning (Go to walk)
%patch $338FE $0008W
#Turning time
#Walking
%patch $33912 $0144W $013FW
#Flect walking 1
%patch $3391C $000AW
#Animation speed
%patch $33930 $0145W $0140W
#Flect walking 2
%patch $3393A $000AW
#Animation speed
%patch $3394E $0146W $0141W
#Flect walking 3
%patch $33958 $000AW
#Animation speed
%patch $3396C $0147W $0142W
#Flect walking 4
%patch $33976 $000AW
#Animation speed
#Stunned
%patch $3398A $0148W $0148W %patch $33994 $0000W
#Animation speed


Clipping and foreground

The Flect uses a value of 0 for its foreground variable, making it appear behind all foreground tiles.

Patch: Foreground variable
#Foreground variable
%patch $11B02 $0000W
#Flect


Sounds

The Flect makes a noise when reflecting Keen's shots from any direction.

Patch: Keen 6
#Flect reflect Keen's shots sound
%patch $11C47 $2A
#Don't play Flect reflect Keen's shots sound
%patch $11C46 $EB $0A