Patch:Gik

From KeenWiki
Jump to: navigation, search

This page covers patches relating to the Giks in Keen 6. Giks are small, yellow, beetle-like enemies that Keen can ride on top of. They will jump to attack him.


Sprite Type

Giks use sprite type 24. This is used by no other sprite and does not affect any other sprite type.

Patch: Keen 6
#Gik sprite type
%patch $1112E $11


Sprite Actions

Giks are quite straightforward. Giks are spawned walking, a three frame loop they will continue in until Keen is in-range, at which point they will jump to attack him. They will then go to landing\sliding, which they will do at the top of their jump or when they hit a block. When sliding Giks will loop 2 frames until they stop moving, either by hitting a wall or 'running out of steam.' Recovering Giks return to walking.

$2604W  #Gik walking
$2622W  #Gik walking
$2640W  #Gik walking
$265EW  #Gik jumping
$267CW  #Gik slide 1
$269AW  #Gik slide 2
$26B8W  #Gik recover

Patch: Keen 6
#When spawned
%patch $11174 $2604W
#While walking
%patch $33350 $2622W %patch $3336E $2640W %patch $3338C $2604W
#When Keen is near
%patch $111EF $265EW
#While jumping
%patch $333AA $267CW
#When at top of jump
%patch $111D5 $267CW
#Slide loop
%patch $333C8 $269AW %patch $333E6 $267CW
#Gik recover
%patch $11247 $26B8W
#When sliding and hits a wall
%patch $11293 $26B8W
#When finished sliding
#When recovering
%patch $33404 $2604W


Sprite Behavior

The Gik has two unique behaviors as well as using a shared 'move through the air' behavior also used by other sprites. When walking the Gik uses its 'chase Keen' behavior; this dictates under what circumstances the Gik can jump at Keen. When jumping it uses the generic fall behavior and while sliding on the ground uses its own sliding behavior which dictates when it stops sliding. When recovering it has no behavior.

Replacing the walking behavior with $00000000L will stop the Gik ever attacking Keen.

Behaviors:
$08F41765RL #Move through the air
$10CC04C2RL #Gik walk
$10CC0541RL #Gik slide

Patch: Keen 6
#Walking
%patch $33344 $10CC04C2RL %patch $33362 $10CC04C2RL %patch $33380 $10CC04C2RL
#Jumping
%patch $3339E $08F41765RL
#Sliding
%patch $333BC $10CC0541RL %patch $333DA $10CC0541RL
#Recovering
%patch $333F8 $00000000L


Walking behavior code

This is the complete code for the Gik's walking behavior. On the first line an unknown check is made, this seems to randomize the Gik's behavior so that it does not do anything sometimes, making it easier to get past.

On the second and third lines the Gik's vertical position is checked. The first check is whether Keen is below the Gik, the second is whether Keen is less than 4 tiles above the Gik. (See Patch:Jump conditions.) At the end of line 3 the Gik checks where Keen is horizontally and changes its direction to chase him.

On lines 4-6 there are four separate horizontal position checks. The first two are the Gik's 'attack range'; if Keen is closer than this the Gik can attack. The next two checks are the Gik's 'riding range'; if Keen is closer than this he is assumed to be riding the Gik and the Gik will not jump.

In the middle of line 6 is a check to see which way the Gik is facing; this determines its horizontal jump speed. On line 7 the vertical speed is set as well as the Gik's jumping action. On the last line the jump sound is played.

Patch: Keen 6
#Gik walk behavior
%patch $11182 $55 $8B $EC $56 $57 $8B $76 $06 $83 $7C $36 $09 $74 $6D $8B $1E $64 $A9 $8B $47 $0A $2B $44 $0A $8B $F8 $8B $47 $28 $3B $44 $28 $77 $59 $8B $44 $28 $2B $47 $28 $3D $0400W $77 $4E $0B $FF $7D $07 $C7 $44 $0E $FFFFW $EB $05 $C7 $44 $0E $0001W $81 $FF $F900W $7C $38 $81 $FF $0700W $7F $32 $81 $FF $FF00W $7E $06 $81 $FF $0100W $7C $26 $0B $FF $7D $07 $C7 $44 $16 $FFD8W $EB $05 $C7 $44 $16 $0028W $C7 $44 $18 $FFE4W $C7 $44 $1C $265EW $B8 $0024W $50 $9A $183B09F1RL $83 $C4 $02 $5F $5E $5D $CB


Seeking Keen and jump-attack range

The Gik will attack Keen when +-$70 pixels from him. This is 7 tiles. The Gik will not attack Keen however if he is riding on it. This is a second distance range that must be smaller than the attack distance; by default it is +-$10 pixels or 1 tile.

The Gik 'seeks' Keen by jumping towards him, if the seeking values are reversed it will always jump away from him.

Patch: Keen 6
#Gik attack distance
%patch $111C8 $0700W
#Right: 7
%patch $111C2 $F900W
#Left: -7
#Keen-is-riding distance
%patch $111D4 $0100W
#Right: 1
%patch $111CE $FF00W
#Left: -1
#Gik jump toward Keen
%patch $111B6 $0001W
#Right
%patch $111BD $FFFFW
#Left


Speed and Jump Height

The Gik's walking speed is defined by its animation motion; and its jump speed in its code.

Patch: Animation motion
#Walking
%patch $33340 $0080W $0000W %patch $3335E $0080W $0000W %patch $3337C $0080W $0000W
#Jumping
%patch $3339A $0000W $0000W
#Sliding
%patch $333B8 $0000W $0000W %patch $333D6 $0000W $0000W
#Recovering
%patch $333F4 $0000W $0000W

Patch: Gik jump variables
#Jump variables
%patch $111DE $FFD8W
#Left speed
%patch $111E5 $0028W
#Right speed
%patch $111EA $FFE4W
#Height


Sprite Collision

The Gik has several collision values depending on what it is doing. Most are quite simple, code-wise.


Collision values

The Gik has two collisions of its own. The first is used when it is walking, it allows Keen to ride on it. The second is used when jumping, and it pushes Keen, but does not kill him. When sliding upside-down the Gik uses a generic 'kill Keen' collision which makes it deadly. In all cases the Gik is indestructible.

Patch: Keen 6 collision values
#Walking
%patch $33348 $0EFC002DRL
#Rideable Gik
%patch $33366 $0EFC002DRL
#Rideable Gik
%patch $33384 $0EFC002DRL
#Rideable Gik
#Jumping
%patch $333A2 $0EFC0006RL
#Push Keen
#Sliding
%patch $333C0 $08F417EERL
#Kill Keen
%patch $333DE $08F417EERL
#Kill Keen
#Recovering
%patch $333FC $08F417EERL
#Kill Keen


Gik harmless

This patch makes the Gik harmless to Keen though he can still ride on it. This is done by making its sprite type the same as the [Patch:Platform (Keen 5)|moving Platform]], changing its attacking collision to 'nothing and changing its walking collision to 'push Keen'

Patch: Keen 6
#Gik sprite type
%patch $1112E $06
#Gik harmless to Keen
%patch $333C0 $00000000L %patch $333DE $00000000L %patch $333FC $00000000L %patch $33348 $0EFC0006RL %patch $33366 $0EFC0006RL %patch $33384 $0EFC0006RL


Animations

The Gik's animations are quite basic. Of interest is the animation speed when walking, which affects the walking speed, and when recovering, which affects how long it takes the Gik to right itself after it has finished sliding.

Patch: Keen 6 Animations
#Cache
%patch $32438 $0183W
#Gik cache start
%patch $32488 $018EW
#Gik cache end
#Walking
%patch $33334 $0186W $0183W %patch $3333E $000AW
#Animation speed
%patch $33352 $0187W $0184W %patch $3335C $000AW
#Animation speed
%patch $33370 $0188W $0185W %patch $3337A $000AW
#Animation speed
#Jumping
%patch $3338E $0189W $018AW %patch $33398 $0000W
#Wait to hit ground
#Sliding
%patch $333AC $018DW $018BW %patch $333B6 $0006W
#Animation speed
%patch $333CA $018EW $018CW %patch $333D4 $0006W
#Animation speed
#Recovering
%patch $333E8 $018DW $018BW %patch $333F2 $0014W
#Recovery time


Sprite Activity

The Gik doesn't need to be active when it leaves the screen so has a variable of 1. This means that if Keen walks away from it it will quickly 'freeze' until he returns.

Patch: Keen 6
#Gik activity variable
%patch $11133 $0001W


Sounds

The Gik makes a sound when it jumps. This can be blocked.

Patch: Keen 4
#Gik jump sound:
%patch $111F2 $24
#Don't play Gik jump sound:
%patch $111F1 $EB $0A


Clipping and foreground

The Gik uses a value of 0 for its foreground variable, making it appear behind foreground tiles, needed when it jumps agaisnt wals and ceilings.

Patch: Gik foreground variable
#Gik foreground variable
%patch $11138 $0000W


Probability and randomness

There is only one random event Gik do and that is when they are spawned. There is a 50:50 chance of them moving either right or left.

Patch: Keen 6
#Chance of spawning moving right
%patch $11152 $80


Sprite spawn code

In the initiation code notice the Gik cache being set ($C7 $06 $CD25W $0001W.) Also notice the three difficulties of Gik that are possible.

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

The Gik always starts the level moving down. It has a 50:50 chance of spawning moving left or right, decided in the code $9A $1CF30034RL $3D $0080W. $C7 $47 $10 $xxxxW is the vertical direction the sprite starts moving in, either $0001W (Facing down), $FFFFW (Facing up) or $0000W (Neither, seldom used.) $C7 $47 $0E $xxxxW is the horizontal direction.

Patch: Keen 6
#Location of initiation code
%patch $E9B4 $02D7W
#Easy Gik (At $E6F7)
%patch $E9B6 $02CDW
#Medium Gik (At $E6ED)
%patch $E9B8 $02C3W
#Hard Gik (At $E6E3)
#Gik initiation code
%patch $E6E3 $83 $3E $A8 $75 $03 $7D $03 $E9 $01DAW $83 $3E $A8 $75 $02 $7D $03 $E9 $01D0W $57 $56 $9A $10CC045ARL $83 $C4 $04 $C7 $06 $CD25W $0001W $E9 $01BDW
#Gik spawn code
%patch $1111A $55 $8B $EC $33 $C0 $50 $9A $069A1E25RL $83 $C4 $02 $8B $1E $66 $A9 $C7 $07 $0011W $C7 $47 $02 $0001W $C7 $47 $20 $0000W $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $89 $47 $0C $9A $1CF30034RL $3D $0080W $7D $0B $8B $1E $66 $A9 $C7 $47 $0E $0001W $EB $09 $8B $1E $66 $A9 $C7 $47 $0E $FFFFW $8B $1E $66 $A9 $C7 $47 $10 $0001W $B8 $2604W $50 $53 $9A $08F41219RL $83 $C4 $04 $5D $CB