Patch:Enemy shooter (Keen 3)

From KeenWiki
Jump to navigation Jump to search

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.

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

When spawned

#Guns
%patch $402E {$4D34W} #Horizontal gun
%patch $4061 {$4D9BW} #Vertical gun

#Shots
%patch $4D8C {$4CF2W} #Horizontal shot
%patch $4DF3 {$4CF2W} #Vertical shot

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.

Keen 3

#Complete horizontal gun behavior
%patch $4D34 $55 $8B $EC $56 $57 $8B $7E $04 $8B $45 $0A $03 $06 $40 $5D $89
             $45 $0A $81 $7D $0A [$0190W]  $7D $02 $EB $48 $81 $6D $0A [$0190W]
             $B8 [$0026W]  $50 $E8 $7C0EW  $59 $E8 $125EW  $8B $F0 $C7 $44 $28
             [$0067W]  $C7 $44 $20 [$0190W]  $8B $45 $02 $8B $15 $89 $54 $04 $89
             $44 $06 $8B $45 $06 $8B $55 $04 $81 $C2 $00 [$03] $15 [$0000W]  $89
             $54 $08 $89 $44 $0A $C7 $44 $32 {$4CF2W}  $C7 $44 $34 {$6A00W}  $C7
             $04 [$0010W]  $5F $5E $5D $C3


Vertical gun behavior

This is the complete code for the vertical 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.

Keen 3

#Complete vertical gun behavior
%patch $4D9B $55 $8B $EC $56 $57 $8B $7E $04 $8B $45 $0A $03 $06 $40 $5D $89
             $45 $0A $81 $7D $0A [$0190W]  $7D $02 $EB $48 $81 $6D $0A [$0190W]
             $B8 [$0026W]  $50 $E8 $7BA7W  $59 $E8 $11F7W  $8B $F0 $C7 $44 $28
             [$0068W]  $C7 $44 $20 [$0190W]  $8B $45 $02 $8B $15 $81 $C2 $00 [$04]
             $15 [$0000W]  $89 $54 $04 $89 $44 $06 $8B $45 $06 $8B $55 $04 $89
             $54 $08 $89 $44 $0A $C7 $44 $32 {$4CF2W}  $C7 $44 $34 {$6A00W}  $C7
             $04 [$0010W]  $5F $5E $5D $C3


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.

Enemy shot code

#Enemy shot code
%patch $4CF2 $55 $8B $EC $56 $E8 $15FEW  $8B $F0 $0B $F6 $74 $32 $B8 [$0025W]     #Play sound
             $50 $E8 $7C63W  $59 $C7 $06 $10 $99 [$0012W]  $C7 $06 $42 $99 {$7E05W} #Set sprite type and behavior
                 $C7 $06 $3A $99 [$0000W]  $E8 $7E28W  $3D [$0080W]  $7E $08 $C7     #Set anim counter= 0, random check
             $06 $38 $99 [$0069W]  $EB $06 $C7 $06 $38 $99 [$006AW]  $EB $00 $5E     #Set animation
             $5D $C3


Shot speeds

The default speed of shots is 400. This never changes until they are destroyed. It is possible to change the shot's direction (Whether they move horizontally or vertically.)

Starting speeds

%patch $4D69 [$0190W] #Horizontal shot speed
%patch $4DD0 [$0190W] #Vertical shot speed


Sprite Collision

The shooters cannot be affected by any other sprite. The shots themselves use the 'dead sprite' collision, which means they ignore other sprites as well. All the effects they have are due to other sprites reacting to them.

Collisions

%patch $4D91 {$6A00W} #Horizontal shot
%patch $4DF8 {$6A00W} #Vertical shot


Animations

When spawned

%patch $4D64 [$0067W] #Horizontal shot
%patch $4DCB [$0068W] #Vertical shot


Sounds

These are the sounds the sprites use. The shooters make a noise every time they fire and they fire even when offscreen, which means that any level containing them is very noisy. Shots also make a noise when they hit tiles.

Keen 1

%patch $4D55 $26 #Horizontal shooter shoots
%patch $4DBC $26 #Vertical shooter shoots
%patch $4D00 $25 #Shots hit tiles

#Don't make sounds:
%patch $4D54 $EB $06 #Horizontal shooter shoots
%patch $4DBB $EB $06 #Vertical shooter shoots
%patch $4CFF $EB $06 #Shots hit tiles


Shot positioning

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.

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.

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.

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.

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