From KeenWiki
Jump to: navigation, search

Gargs are dangerous, green enemies found in Keen 1. This page lists patches relating to Garg sprites. It is divided into sections relating to the various sprite properties the patches involve. Being fluent with various sprite patch pages will help when working with these patches.

Sprite Type

Gargs use sprite type 3 which means they kill Keen on contact.

Patch: Keen 1
#Garg sprite type:
%patch $184E $03

Sprite Behavior

There are three behaviors associated with the Garg, the walking behavior (Walk back and forth, also charge and jump.) and the searching behavior (Look for Keen, if he's on the Garg's level, charge in Keen's direction.) the third behavior is the Garg collision. Gargs are spawned looking for Keen. The difference between walking and charging is simply speed, which is set during searching.

$1B51W #Garg look for Keen, charge
$1AA8W #Garg walk
$1BCEW #Garg collision

Patch: When spawned
%patch $1871 $1B51W

Patch: In level
%patch $1AD0 $1B51W 
#Look for Keen after charging into walls, randomly during walking
%patch $1BCA $1AA8W
#Walk or charge after looking for Keen.
%patch $1876 $1BCEW
#Garg collision

Searching behavior code

This is the complete code for the Garg's searching behavior. First the Garg's speed is set to 0. On the first two lines the Garg's animations are set; start animation $3C, plus $03 other frames at an animation speed of $05. The third line calls gravity and tile collision with $E8 $10B3W and $E8 $10F3W respectively. Replacing the first with $90 $90 $90 will cause Gargs to float while searching; replacing the second will cause them to 'ghost' through tiles.

The third line also contains the Garg's search time, $50 ticks. Until this time is up all the remaining code is skipped. On line 4 the Garg takes its height and subtracts Keen's height. If a difference of $0800W (Which is equivalent to 8 pixels.) is found then the Garg will charge. If Keen is shorter than the Garg then the $C2 on the line must be changed to $EA Two checks are made on line 5. If both are passed the Garg's speed is set to $DC (Right or left.), if not, it is set to $3C (Again, right or left.) This makes the Garg either chase or walk after Keen. (Also note this means gargs will walk in Keen's direction even if he is not right in front of them.)

Two unknown checks are made in the last two lines and the Garg's behavior set to 'walk\charge'.

Patch: Garg searching code
#Garg searching code
%patch $1B51 $55 $8B $EC $C7 $06 $40 $82 $0000W $A1 $5135W $B1 $05 $D3 $E8 $25 $0003W $05 $003CW $A3 $8248W $A1 $824AW $03 $06 $14 $5B $A3 $824AW $E8 $10B3W $E8 $10F3W $83 $3E $824AW $50 $7C $4B $A1 $822AW $8B $16 $8228W $81 $C2 $0800W $15 $0000W $3B $06 $E4 $6E $75 $0E $3B $16 $E2 $6E $75 $08 $C7 $06 $8240W $00DCW $EB $06 $C7 $06 $8240W $003CW $A1 $8226W $8B $16 $8224W $3B $06 $E0 $6E $7C $10 $7F $06 $3B $16 $DE $6E $76 $08 $A1 $8240W $F7 $D8 $A3 $8240W $C7 $06 $8252W $1AA8W $5D $C3

Searching and charging behavior

These patches relate to the Gargs searching and charging behavior, whether they search and what they do after searching.

Gargs still charge when Keen\Garg height changes

The Garg\Keen height check is how the Gargs determine if Keen is level with them and thus able to be charged at. If either the Garg or Keen's height changes, they will be unable to charge normally. These patches is used to address the imbalance. There are two patches, only ONE is needed. Here $xx is the difference in height between Keen's sprite and the Garg's sprite in pixels.

Patch: Make sure that the Garg still charges when Keen/Garg height changes
#If Keen is shorter or the Garg is taller:
%patch $1B8B $xx
#If the Garg is shorter or Keen is taller:
%patch $1B8B $xx %patch $1B89 $EA

Don't charge

Patch: Keen 1
#Gargs don't charge.
%patch $1B9B $90 $90 $90 $90 $90 $90 $90 $90

Charge in random direction

This patch calls the game randomizer at $C0CE instead of using Keen's location to determine direction.

Patch: Keen 1
#Garg charges in random direction instead of toward Keen
%patch $1BA9 $E8 $22 $A5 %patch $1BB0 $38 $06 $14 $5B

Always charge after searching

With this patch Gargs will always charge towards Keen after looking for him, whether Keen is level with them or not. This makes them much more vicious.

Patch: Keen 1
#Gargs anywhere will charge toward Keen after looking around
%patch $1B93 $90 $90 $90 $90 $90 $90

Stand still until Keen is seen

With these two patches, the Gargs will not move at all until Keen is level with them, after which they will charge, either towards or away from him depending on patch. This is useful for making a 'sleeping' enemy that wakes when Keen is near. The two patches are obviously not compatible.

Patch: Keen 1
#Gargs don't move until they see Keen, then they charge
%patch $1BA6 $00

Patch: Keen 1
#Gargs stand still until they see Keen, then they run away
%patch $1BA3 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90 $90

Always search

With this patch Gargs spend all their time searching and thus will tend to attack Keen as soon as they see him.

Patch: Keen 1
#Gargs always look around
%patch $1AC9 $5C

Searching Gargs keep moving

With this patch the Garg's speed is not set to 0 when searching, this means they slip and slide when searching This is useful since patching the searching speed only one direction is possible by default.

Patch: Keen 1
#Garg slides as if on ice when searching
%patch $1B54 $EB $04

Garg search time

This patch controls how long the Garg will spend searching. By default this is $50 game ticks. The maximum value is $7F. For the minimum value see the section below.

Patch: Keen 1
#Garg search time
%patch $1B7E $50

Instant search

This patch makes the Garg search instant, so that Gargs often seem to chase Keen spontaneously. It helps also to patch the searching sprite into a walking one, since the very brief search time left can still look like a flicker.

Patch: Keen 1
#Garg search is instant
%patch $1B7F $90 $90

Speed and Jump Height

The default speed of Gargs is +-60 when walking and +-220 when charging. When spawned Gargs will stand still (looking for Keen) by default. They will charge towards Keen after searching for him and finding him otherwise they will walk in a random direction.

There is only one speed for walking\charging that can be in two directions. Gargs will jump at a platform edge ONLY if moving at a certain speed, by default this is the charging speed, so this should be changed to match the charging speed if it is altered. It is possible also to alter the jump condition so that Gargs always jump or jump when walking only. The jump height is the negative of the charging speed, but this is coincidence.

Patch: In level
%patch $1B58 $0000W     
#When looking for Keen (Stand still)
%patch $1BA7 $003CW
#Right\left speed after searching for Keen and NOT finding him
%patch $1B9F $00DCW
#Right\left speed after searching for Keen and finding him
%patch $1B1E $003CW
#If hits left wall (Move right)
%patch $1B39 $FFC4W
#If hits right wall (Move left)
%patch $1B37 $00DCW $75
#Garg-jump speed, should match charging speed
%patch $1B4C $FF24W
#Jump height
%patch $1BFF $FFB0
#Jump height when shot

Sprite Collision

Gargs interact with both Keen's and Tank's shots. This produces a shot Garg. (See behavior section.) The shot Garg also resets its collision and behavior, the new collision, used for most dead sprites ignores all other sprites, the new behavior likewise is just 'fall and animate'

Basic collision patch

Patch: Keen 1
#Basic collision patches
%patch $1876 $1BCEW
#Garg collision
%patch $1BDA $3D $0A
#Garg killed by Keen's shot
%patch $1BDF $3D $0B
#Garg killed by Robot's shot
%patch $1BF5 $489DW
#Dead Garg behavior
%patch $1BFA $3360W
#Dead Garg collision
%patch $1BFF $FFB0W
#Jump height when shot

Complete collision code

This is the complete collision patch. Contained in it is all of the Garg's collision code. The first two blue values are the sprite types the Garg responds to, each followed by a jump condition in brown. The next blue value stops the sprite animating, the fourth is the number of frames to use in the stunned animation and the fifth is the sprite animation to use. The sixth and seventh are the shot Garg's behavior and sprite collision. The eighth is the shot Garg's jump height and the ninth and last is the sound played when the Yorp is shot. The last brown value calls the sound playing code. (See sounds section below.)

To customize the collision it may pay to see Patch:Vorticons Sprite Parameters and maybe Patch:Shot sprites.

Patch: Keen 1
#Garg collision (Use code at $1BCE)
%patch $1876 $1BCEW
#Default Garg collision
%patch $1BCE $55 $8B $EC $56 $57 $8B $76 $04 $8B $7E $06 $83 $3D $0A $74 $05 $83 $3D $0B $75 $27 $C7 $44 $2A $0000W $C7 $44 $2C $0002W $C7 $44 $28 $0044W $C7 $44 $32 $489DW $C7 $44 $34 $3360W $C7 $44 $22 $FFB0W $B8 $0023W $50 $E8 $A2EBW $44 $44 $5F $5E $5D $C3

Indestructible shockable Garg

This patch makes the Garg death more complex. The Garg is indestructible, but it still shows the shot animation every time it is shot (It is shot without dying so to speak.) The second line resets the collision behavior (See first section.) If the second line is changed to another collision aside from the Garg one, the second time the Garg is shot it will use that collision. (For example, changing it to the Yorp collision means the Garg will have two health, the first showing a shocked Garg, the second spawning a dead Yorp.)

Most of the other patches in the basic section can be used with this to change the sound made, etc.

Patch: Keen 1
#Garg is invincible, but shows 'shocked' animation each time its shot
%patch $1BF2 $90 $90 $90 $90 $90 %patch $1BFA $1BCEW


Patch: When spawned
%patch $187B $003CW 

Patch: In level
%patch $1B65 $003CW 
#Looking for Keen
%patch $1B62 $03
#And next 3 frames
%patch $1B5E $05
#Animation speed
%patch $1AE3 $0040W
#Walking right
%patch $1AEB $0042W
#Walking left
%patch $1AF5 $01
#And next frame
%patch $1AF1 $04
#Animation speed
%patch $1BF0 $003AW
%patch $1BEB $02
#Frames used


These are the sounds the sprite uses.

Patch: Keen 1
%patch $1C02 $23 
#Garg death
#Don't make sounds:
%patch $1C05 $90 $90 $90 $90
#Garg death


These patches don't fit into the above sections easily.

Shot Garg stuns like a Yorp

This patch makes it so that shot Gargs recover after being stunned; like the Yorps when they are stomped, after a time they will recover, search for Keen and act as if nothing had happened. While stunned using this patch they animate their shot sprites. Stunned Gargs are still deadly.

The first part of this patch changes what the Garg becomes when it is shot, using its new stunned behavior.

The section part is optional, if included then stunned Gargs can be shot again, 'restunning' and restting their 'stun timer'. If it is removed Gargs will not respond to further shots; though they will still block Keen's shots.

The third part of the patch is more complex. The first line contains three variables, the first is the animation speed, the second the number of animation frames minus 1 (That is, 2 by default.) and the third is the start animation frame for the stunned Garg. (Here the first shot frame.) The second line has a blue variable that is the Garg's stunned time, when this much time has passed, the Garg will return to normal. The two brown variables on the third line are the recovered Garg's collision and behavior, making the Garg shootable when it recovers and also changing it's behavior to look for Keen (instead of staying stunned.) The two brown $E8 $xxxxWs on the fourth line are gravity and tile check, replacing the first with $90 $90 $90 makes the stunned Garg not fall and hit the ground, replacing the second makes it ghost through tiles.

The third part of the patch makes sure that neither Yorps nor Gargs pause when offscreen when stunned. Each line in it checks for the stunned behavior, and if it is found, changes the sprite to either searching Yorp or searching Garg. (Gargs also have their collision reset so they can be shot again.)

This patch may be incompatible with patches that use the $0AA2 offset, though it is designed to work with the Keen ammo limit patch. (With unique sound and without.) Check your patchfile if conflicts occur.

Patch: Keen 1
#Stunned Garg is deadly static stunned-Yorp-like sprite
%patch $1BF5 $0B10W
#Shot Garg becomes stunned Garg
#Include this to make stunned Gargs 'restunnable'
%patch $1BF7 $EB $03
#Stun behavior
%patch $0B10 $55 $8B $EC $A1 $35 $51 $B1 $04 $D3 $E8 $25 $0001W $05 $0044W
#Garg animation
$A3 $48 $82 $A1 $4A $82 $03 $06 $14 $5B $A3 $4A $82 $3D $0320W
#Garg stun time
$7C $0C $C7 $06 $54 $82 $1BCEW $C7 $06 $52 $82 $1B51W $C7 $06
#Return to Garg search behavior and collision
$40 $82 $0000W $E8 $20E3W $E8 $2123W $5D $C3
#Stunned Gargs don't freeze when offscreen
%patch $4D98 $E9 $BDB1W %patch $0B4C $81 $3E $52 $82 $1A2CW $75 $08 $C7 $06 $52 $82 $19D3W $EB $14
#Stunned Yorps
$81 $3E $52 $82 $0B10W $75 $12 $C7 $06 $54 $82 $1BCEW $C7 $06
#Stunned Gargs
$52 $82 $1B51W $C7 $06 $4A $82 $0000W $E9 $4233W