# Patch:Garg

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.

Behaviors:
$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

#### 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.

## 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.

## Misc

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