# Patch:Enemy shooter (Keen 3)

Enemy shooters are invisible metasprites found in Keen 3 that produce orange shots at regular intervals. The shots are lethal to Keen. This page lists patches relating both to the shooters and their shots.

As mentioned above there are two main components to the shooters; the shooter itself which is placed in the level and the shots it produces. There are also two kinds of shooter, horizontal and vertical, which differ in the direction their shots travel.

Shots will be destroyed if they travel offscreen or hit solid tiles or enemies. If they are patched to not do this they can quickly overwhelm the game's ability to track them all, resulting in a rash.

## Sprite Type

As metasprites the shooters themselves have no sprite type and are not affected by any other sprites (Except the destruction of the Mangling Machine which destroys most sprites in a level.) Both shots use sprite type 16 which means they kill both Keen and some enemies.

 Patch: Keen 3 #Shot sprite type: %patch $4D95$10 #Horizontal %patch $4DFC$10 #Vertical

## Sprite Behavior

There are two behaviors associated with the shooters, that of the shooter itself, which is metasprite behavior and cannot be used by other sprites, and the shot's behavior, which is the same for both types of shot and doesn't change until they are destroyed. The shot's sprite collision is 'nothing' (Used by many dead sprites) meaning they do not interact with any other sprites, everything they do is technically other sprites reacting to them. (The guns have no collision set.)

Behaviors:
$4D34W Horizontal gun$4D9BW Vertical gun
$4CF2W Shot behavior$6A00W Shot collision

 Patch: When spawned #Guns %patch $402E$4D34W #Horizontal gun %patch $4061$4D9BW #Vertical gun #Shots %patch $4D8C$4CF2W #Horizontal shot %patch $4DF3$4CF2W #Vertical shot

 Patch: Collisions %patch $4D91$6A00W #Horizontal shot %patch $4DF8$6A00W #Vertical shot

### Horizontal gun behavior

This is the complete code for the horizontal gun. it is responsible for timing and producing the orange enemy shots.

On the second line of the code there are two blue values. The first is how long the guns wait once the level is started before shooting their first shot. The second is how far apart each successive shot is. By default these are equal but they do not have to be. On the third line the shooting sound is played.

The fourth line deals with the shot's animation and horizontal speed, while the sixth lines is the shot height, three pixels down from the gun's tile. (See positioning section.) The seventh line sets the shot's behavior and collision while the eighth line sets its sprite type.

### Complete shot behavior

The shot's behavior is quite simple, it checks for any sort of solid tile, and if it encounters one, it will then become a zap\zot sprite, changing its sprite type and behavior appropriately, setting its animation counter to 0 (Necessary for zap\zot display) and making a random check to see which of the two valid animations to use. It also plays the 'shot smashed' sound.

This patch alters where the shots are spawned relative to the shooter. This can be used to change the shot height if Keen's height changes or puzzles need it, or for better visual effect. It is divided into two values, the first in a 'fine-tuner', the number of pixels down\across from the shooter's top the bullet appears. The second value is much rougher and is worth 256 pixels when +-1 It is really only useful when making the shot appear a negative number of pixels below\right (That is above\left) of the sprite, when it will be changed to $FFFFW.  Patch: Shot spawning position #Horizontal shooter h-position (Default$000003 ,if zero then no shot appears) %patch $4D7F$03 %patch $4D81$00 $00 #Vertical shooter v-position (Default$000004 ,if zero then no shot appears) %patch $4DDA$04 %patch $4DDC$00 $00 ## Sprite spawn code This is the initiation and spawning code for the horizontal and vertical guns. When created the guns are given a sprite type of 5 and a behavior at$1DC7. Nothing else is assigned, the guns are invisible and don't collide. Interestingly the guns are not in fact sprites, but rather 'metasprites' which means that they are always active and far simpler. This means the guns shoot all the time, instead of just when Keen is nearby.

 Patch: Sprite spawn code #Level sprite values %patch $3BEE$000EW #Gun across %patch $3BF0$000FW #Gun down #Sprite initiation pointers %patch $3C14$3B5DW #Gun across %patch $3C16$3B66W #Gun down #Initiation codes %patch $3B5D$56 $57$E8 $049EW$59 $59$EB $54 #Goes to Gun across (Code at$3B5D + $49E + 5 =$4000) %patch $3B66$56 $57$E8 $04C8W$59 $59$EB $4B #Goes to Gun down (Code at$3B66 + $4C8 + 5 =$4033) #H gun spawn code %patch $4000$55 $8B$EC $56$E8 $2001W$8B $F0$C7 $44$08 $0005W$8B $46$04 #Sprite type = 5 $99$B1 $0C$E8 $ABAAW$89 $04$89 $54$02 $8B$46 $06$99 $B1$0C $E8$AB9CW $89$44 $04$89 $54$06 $C7$44 $22$4D34W $5E$5D $C3 #Behavior =$4D34 #V gun spawn code %patch $4033$55 $8B$EC $56$E8 $1FCEW$8B $F0$C7 $44$08 $0005W$8B $46$04 #Sprite type = 5 $99$B1 $0C$E8 $AB77W$89 $04$89 $54$02 $8B$46 $06$99 $B1$0C $E8$AB69W $89$44 $04$89 $54$06 $C7$44 $22$4D9BW $5E$5D $C3 #Behavior =$4D9B

## Misc

These are patches that do not fit into any of the above sections. They may affect other sprites or have unintended side-effects.

### Change shot's direction

These patches will make both shots move in the same direction by altering one shot's direction from horizontal to vertical or vice versa. Only ONE of the following 2 patches an be used at once. Note also that this can be used to make two shots move in the same direction, but at different speeds.

 Patch: Both shots move: %patch $4D68$22 #Vertically %patch $4DCF$20 #Horizontally

### Shot frequency

This patch changes how often a new shot is produced by the horizontal or vertical shooters. Both sprites work the same; there is a pause when the level starts before the first shot is fired then more shots are produced at regular intervals after this. By default both values are the same, but this need not be the case. (For example a long start pause can be used as 'Keen has 30 seconds to get out before the guns start shooting continuously.)

All shooters everywhere in the level will start counting as soon as the level starts.

 Patch: Shooting frequency #Horizontal shooter %patch $4D49$0190W #Pause before first shot %patch $4D52$0190W #Pause between shots #Vertical shooter %patch $4DB0$0190W #Pause before first shot %patch $4DB9$0190W #Pause between shots