Patch:Orange shot

From KeenWiki
Jump to navigation Jump to search

The 'orange shot' can refer to one of two things; the first is the Enemy Shooter in Keen 3; this is an invisible metasprite that produces orange shots at regular intervals. This has its own page as most of the patches relating to it relate directly to the shots it produces.

The second, and the one covered on this page, is the Enemy shot in Keen 2 that is produced by both Guard Robots and Vorticon Elites. This is independent of them and so patches affecting it will affect both the sprites that produce it. Shots will be destroyed if they travel offscreen, hit solid tiles or hit enemies. If they are patched to not do this they can quickly overwhelm the game's ability to track them all, resulting in a crash.


Sprite Type

Orange shots use sprite type 11 which means they kill both Keen and some enemies.

Keen 2

#Shot sprite type:
%patch $7648 [$0B]


Sprite Behavior

The orange shot has only one behavior, to move across the screen until it hits something. This behavior is also used by Keen's shot. Its collision deals with all the things that can make it turn into a zap\zot (And those sprites which it won't affect.)

Behaviors:
$7567W Shot behavior
$775FW Shot collision

When spawned

#Shot behavior set when created
%patch $766C {$7567W}

#Shot collision
%patch $7677 {$775FW}


Shot behavior code

The orange shot's behavior is quite simple,but also shared by Keen's shot; so altering it can have unintended side-effects. On the first line it runs a tile check code, if the shot has hit any kind of solid tile it runs the rest of the code, otherwise it does nothing.

On being destroyed first sound $25 is played, then the sprite's type changes to $0C, a 'harmless' type used for zap\zots. Its behavior is set to that of the zap\zot, $7547W and its animation timer to zero. (This is to help time how long the zap\zot stays visible before vanishing.) Finally a random number is called; if it is larger than $80 (50%) then a zap sprite is used, otherwise a zot is.

Shot behavior code

#Shot behavior code
%patch $7567 $55 $8B $EC $56 $E8 $E541W  $8B $F0 $0B $C0 $74 $31 $B8 [$0025W]
             $50 $E8 $4090W  $44 $44 $C7 $06 $96C0W  [$000CW]  $C7 $06 $96F2W
             {$7547W}  $C7 $06 $96EAW  [$0000W]  $E8 $4254W  $3D [$0080W]  $7E $08
             $C7 $06 $96E8W  [$007CW]  $EB $06 $C7 $06 $96E8W  [$007CW]  $5E $5D
             $C3


Shot speeds

The default speed of shots is +-350. This never changes until they are destroyed. This is in fact set when the Robot and Elite call the shooting code, so both can have shots moving at different speeds.

Shot speeds

#Robot's shot
%patch $4619 [$015EW] #Right speed
%patch $4623 [$FEA2W] #Left speed

#Elite's shot
%patch $4201 [$015EW] #Right speed
%patch $420B [$FEA2W] #Left speed


Sprite Collision

The orange shots have their own specific collision which controls what sprites cause them to be destroyed on contact.

Collisions

#Shot collision
%patch $7677 {$775FW}


Shot collision code

This is the orange shot's complete collision code. It is basically a simple check for what sprite types don't destroy the shot on contact. These are checked for in the first two lines and are types $06, $0D and $04. In order these are the Guard Robot, zap\zot and Vorticon Elite. Two of these sprites produce shots, so cannot be shot by their own projectiles, while the third prevents shots being destroyed by other destroyed shots.

When destroyed sound $25 is played and the shot's behavior set to that of a zap\zot ($7547W) and its collision to 'nothing' ($61A2W.) Finally a random number is called; if it is larger than $80 (50%) then a zap sprite is used, otherwise a zot is.

Shot collision code

#Orange shot's collision code
%patch $775F $55 $8B $EC $56 $57 $8B $76 $04 $8B $7E $06 $83 $3D [$06] $74 $36
             $83 $3D [$0D] $74 $31 $83 $3D [$04] $74 $2C $B8 [$0025W]  $50 $E8 $3E8BW
                 $44 $44 $C7 $44 $32 {$7547W}  $C7 $44 $2A $0000W  $C7 $44 $34
             {$61A2W}  $E8 $4052W  $3D $0080W  $7E $07 $C7 $44 $28 [$007CW]  $EB
             $05 $C7 $44 $28 [$007DW]  $5F $5E $5D $C3


Animations

The shot has only one animation, though the zap\zots it produces have many.

Orange shot animation

#Orange shot animation
%patch $767C [$007BW]