Patch:Robo Red

From KeenWiki
Jump to: navigation, search

This page covers patches relating to the Robo Reds in Keen 5. Robo Red is an indestructible and rather large enemy found in a few pen areas in Keen 5, especially on harder difficulties.


Sprite Type

Robo Reds use sprite type 13 which is used only by the Robo Red and doesn't affect anything else. When an Robo Red shoots, its shots are also given a sprite type, though this cannot yet be patched.

Patch: Keen 5
#Robo Red's sprite type
%patch $125B0 $0C


Sprite Actions

Robo Reds have several sets of actions. They are spawned moving and will remain doing so. The Red can be disturbed by Keen landing near it, or shooting it.

Red will pause before shooting, then enter a two-action cycle of making a shot then pausing. it will do this until it has created the required number of shots, after which it will resume moving.

Red's shots have two actions as they move. They will smash when they hit walls or Keen. Smashed shots have two actions and vanish quickly.

Actions:
$2734W #Robo Red move
$2752W #Robo Red pause before shooting
$2770W #Robo Red prepare to shoot
$278EW #Robo Red shoot (Make shot)
$27ACW #Robo Red's shot 1
$27CAW #Robo Red's shot 2
$27E8W #Robo Red shot smash 1
$2806W #Robo Red shot smash 2

Patch: Keen 5
#When spawned
%patch $125EB $2734W
#While moving
%patch $32A90 $2734W
#Keep moving
#When disturbed
%patch $12648 $2752W
#Robo Red pause before shoot (Keen lands near Red)
%patch $12683 $2752W
#Robo Red pause before shoot (Shot by Keen)
#Shooting
%patch $32AAE $2770W
#Robo Red pause before shooting
%patch $32ACC $278EW
#Robo Red shoot (Pause between shots)
%patch $32AEA $2770W
#Robo Red shoot (Make shot, keep shooting)
#After shooting
%patch $126B1 $2734W
#Robo Red move
#What Red creates when shooting
%patch $126C7 $27ACW
#Robo Red shot
#Red's shots while moving
%patch $32B08 $27CAW
#Robo Red's shot 1
%patch $32B26 $27ACW
#Robo Red's shot2
#Red's shots destroyed
%patch $12738 $27E8W
#Robo Red shot smash (When hits Keen)
%patch $12775 $27E8W
#Robo Red shot smash (When hits walls)
#Red's smashed shots
%patch $32B44 $2806W
#Robo Red shot smash 1
%patch $32B62 $0000W
#Robo Red shot smash 2(Vanish)


Sprite Behavior

The Robo Red has two behaviors, one to move back and forth and respond to Keen disturbing it, and one to produce a shot when shooting. The shots themselves use a generic 'enemy shot' behavior.

Behaviors:
$090B1748RL #Enemy shot
$11C409BCRL #Robo Red move
$11C40A61RL #Robo Red make shot

Patch: Keen 5
%patch $32A84 $11C409BCRL 
#Robo Red move
#Shoot
%patch $32AA2 $00000000L
#Nothing (Pause before starting)
%patch $32AC0 $00000000L
#Nothing (Pause between shots)
%patch $32ADE $11C40A61RL
#Robo Red shoot (Shoot)
#Shots
%patch $32AFC $090B1748RL
#Enemy shot
%patch $32B1A $090B1748RL
#Enemy shot
#Shots smashed
%patch $32B38 $00000000L
#Nothing
%patch $32B56 $00000000L
#Nothing


Seeking Keen

Robo Red will turn to face Keen when Keen disturbs or shoots it. Changing this will make it always shoot away from Keen.

Patch: Keen seeking
#When sees Keen, turns to face him to shoot:
%patch $1263E $0001W %patch $12637 $FFFFW
#When shot by Keen, turn towards him:
%patch $12673 $0001W %patch $12678 $FFFFW


When Robo Red responds to Keen disturbing it

By default the Robo Red will only shoot at Keen if Keen it below its head and above its 'feet'. This ensures that it does not shoot at nothing when Keen is not level with it. In the default patch below the 'above' check is the first line, the 'below' check the second line.

The patches following it change the conditions, often by removing one. The patches can be combined by, for example, replacing a line of $90s with the condition from another patch. Notice that these new patches overwrite the default checks, so the patch making the Red shoot only when Keen disturbs it while left of it will make it shoot even if he is far above or below it. (Though it is possible to combine it with the default patch to stop it shooting Keen when he is both right and below the Red.)

Patch: Keen seeking
#Robo Red default (Shoot Keen if he is below its head, above its feet.)
%patch $1260E $8B $47 $28 $3B $44 $24 $76 %patch $12616 $8B $47 $24 $3B $44 $28 $73
#Red shoots even when Keen is higher than his head
%patch $1260E $90 $90 $90 $90 $90 $90 $90 $90 %patch $12616 $8B $47 $24 $3B $44 $28 $73
#Red shoots even when Keen is lower than his feet
%patch $1260E $8B $47 $28 $3B $44 $24 $76 %patch $12616 $90 $90 $90 $90 $90 $90 $90 $90
#Red only shoots when Keen is right of him
%patch $1260E $8B $47 $0A $3B $44 $0A $76 %patch $12616 $90 $90 $90 $90 $90 $90 $90 $90
#Red only shoots when Keen is left of him
%patch $1260E $8B $47 $0A $3B $44 $0A $73 %patch $12616 $90 $90 $90 $90 $90 $90 $90 $90


Red shoots randomly

Robo Red shoots randomly when Keen is close enough to disturb it; this patch simplifies things so that Red will shoot randomly no matter where Keen is or what he's doing. Also included here is the probability Red will shoot (See below section.) for convvenience. (A lower value for this means Red shoots less often. The maximum value is $00FFW.)

Patch: Red shoots randomly no matter where Keen is
#Red shoots randomly no matter where Keen is
%patch $12603 $EB $19 %patch $12624 $0010W


Shooting patches

These patches relate to how Robo Red shoots, but not the properties of his shots. Note that there are two times when Red will shoot, when Keen lands near him and when Keen shoots him.


Robo Red doesn't shoot

This (slightly unstable) patch stops Robo Red from shooting, but causes him to glide towards Keen when disturbed. A more stable patch can be made using sprite actions (above).

Patch: Keen 5
#Red doesn't shoot, but glides in the shooting direction forever when agitated
%patch $126A8 $10


Number of shots per shooting event

The Robo Red will shoot a number of shots each time it shoots. This patch controls that number.

Patch: Keen 5
#Number of shots
%patch $12643 $000AW
#When Keen lands near Red (10)
%patch $12680 $000AW
#When shot by Keen (10)


Shot up\down pattern

Robo Red's shots can be produced moving up or down in a regular pattern, by default this is one shot up and one shot down. This patch controls that pattern. This value should divide evenly into the total number of shots Red will shoot, but can be larger. (2x larger, 3x...) Failing to do this will result in somewhat random shot directions over time.

Patch: Keen 5
#Shot up\down pattern
%patch $126F1 $0001W
#1 up, 1 down


Red leaves a trail of shots

This (slightly unstable) patch makes Robo Red leave a trail of non-moving shots behind it when it shoots, slowly moving forward towards Keen. These shots make great 'mines', but can cause problems if too many are spawned in one level.

Patch: Keen 5
#Robo Red leaves a trail of still shots behind it when it shoots
%patch $126DB $00 $00


Speed

The Robo Red's movement is controlled in bulk by its animation motion. Notable is that Robo Red can be made to move off an edge in certain conditions and get stuck in the air. Red's shots are given their speeds when they are created, both kinds of shot move forward the same amount, but one moves upwards, the other downwards. The Red also has a backwards movement to compensate for dashing forwards as it shoots. This makes the Red 'jiggle' when shooting at Keen.

Patch: Animation motion
#Robo Red move
%patch $32A80 $0040W $0000W
#Moving speed
#Shoot
%patch $32A9E $0000W $0000W
#Pause before shooting
%patch $32ABC $0040W $0000W
#Move forward this much when shooting
%patch $32ADA $0000W $0000W
#Make bullets
#Shots
%patch $32AF8 $0000W $0000W %patch $32B16 $0000W $0000W
#Shot smash
%patch $32B34 $0000W $0000W %patch $32B52 $0000W $0000W

Patch: Other speeds
#Move back after shooting
%patch $12718 $FFC0W
#Facing right
%patch $1271D $0040W
#Facing left
#Red's shot speeds
%patch $126E3 $003CW
#Horizontal
%patch $126F8 $0008W
#Up vertical
%patch $12703 $FFF8W
#Down vertical


Red can't be lured off ledges

This patch stops the Red luring bug by stopping it from moving when shooting. As a side effect however it does not 'jiggle' when shooting, which can make it seem slightly less energetic.

Patch: Red can't be lured off ledges
#Red can't be lured off ledges
%patch $32ABC $0000W %patch $12711 $5F $5E $5D $CB


Red's shots only move horizontally

This patch removes the up and down vertical pattern of Red's shots and makes them move horizontally only. It is incompatible with the vertical shot speed patches above.

Patch: Red's shots only move horizontally
#Red's shots only move horizontally
%patch $126EE $C7 $47 $18 $0000W $EB $10


Sprite Collision

The Robo Red has two of its own collisions in different circumstances. They are quite interesting.


Collision values

The Robo Red uses its own dedicated collision when moving. This responds to Keen's shots by making it face Keen and shoot. It is also lethal to Keen. While shooting it uses a second collision that kills Keen and blocks his shots, but doesn't make it start shooting. Finally its shots use a generic 'dangerous sprite' collision.

The 'kill and block shots' collision is used by several other sprites and so is not uniquely the Robo Red's.

Patch: Keen 5 collision values
#Moving
%patch $32A88 $11C40A0DRL
#Robo Red moving
#Shooting
%patch $32AA6 $11C40D61RL
#Kill and block shots (Pause before shooting)
%patch $32AC4 $11C40D61RL
#Kill and block shots (Pause between shots)
%patch $32AE2 $11C40D61RL
#Kill and block shots (Shoot)
#Red's shot
%patch $32B00 $11C40AE6RL
#Robo Red's shot
%patch $32B1E $11C40AE6RL
#Robo Red's shot
#Red's shot smashed
%patch $32B3C $00000000L
#Nothing
%patch $32B5A $00000000L
#Nothing


Collision code

This is the default Robo Red collision code. It responds to Keen and his shots. The first paragraph is the response to Keen's shots, the second Keen.

On the first line is the sprite type check for Keen's shots. Following that on line 2 is Keen's shots being destroyed. (To make the shot pass through Red replace $57 $9A $0CCB10B3RL $83 $C4 $02 with $90 $90 $90 $90 $90 $90 $90 $90 $90.) Line 3 is Keen seeking; Keen's location is checked and Red turns to face him. (See above sections.) On line 4 the number of shots Red willl shoot is set (10 by default) and Red's shooting action is called. The fifth line closes the code.

In paragraph 2 Keen's type is checked for and if found the 'kill Keen' code is run.

Patch: Keen 5 collision code
#Robo Red default collision code
%patch $1264D $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D $03 $75 $36
#Respond to Keen's shots
$57 $9A $0CCB10B3RL $83 $C4 $02 $8B $1E $3E $9E $8B $47 $0A
#Destroy shot
$3B $44 $0A $76 $05 $B8 $0001W $EB $03 $B8 $FFFFW $89 $44 $0E
#Check Keen's location
$C7 $44 $3E $000AW $B8 $2752W $50 $56 $9A $090B1242RL $83
#Shoot
$C4 $04 $5F $5E $5D $CB $83 $3D $02 $75 $05 $9A $0AAF1517RL $5F $5E $5D $CB


Robo Red is stunnable

This patch modifies the Red's collision so that he is stunnable. As a side effect Red can't respond to Keen when shot. Red uses the same frames when stunned as when he is moving.

Patch: Keen 5 collision code
#New collision: stun
%patch $1264D $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D $02 $75 $09 $9A $0B8013E9RL $5F $5E $5D $CB $83 $3D $03 $75 $18 $C7 $44 $16 $0000W $C7 $44 $06 $0001W $B8 $00F2W $50 $57 $56 $9A $090B16CDRL $83 $C4 $06 $5F $5E $5D $CB
#New action: stunned
%patch $30432 $0184W $0183W $0002W $0000W $0000W $0000W $0000W $0000W $090B1710RL $00000000L $090B195ARL $0000W


Robo Red pushes Keen instead of killing him

This patch adjusts the Robo Red's moving collision so that instead of killing Keen he pushes him. (Red will still occasionally burst into bouts of shooting.) The second part of this patch alters Red's collision when shooting so that that too is not fatal. Asa side effect of that however the player can 'halt' Red by shooting him when he is already shooting 'resetting' him back to the start of his shooting sequence.

When working with the complete collision code above this patch replaces only the last two lines and relies on the sequence $83 $C4 $04 $5F $5E $5D $CB in the first paragraph of the default collision.

Patch: Keen 5 collision code
#Robo Red pushes Keen instead of killing him
%patch $12693 $83 $3D $02 $75 $F7 $56 $57 $9A $090B0CD2RL $EB $EB
#Change other collisions to not kill Keen
%patch $32AA6 $11C40A0DRL
#Pause before shooting
%patch $32AC4 $11C40A0DRL
#Pause between shots
%patch $32AE2 $11C40A0DRL
#Shooting


Red can be pogoed on, blocks shots

This patch causes Red to be harmless to Keen yet invulnerable to Keen's shots, destroying them. However he can be destroyed by being pogoed on which will turn him into a vitalin splash. (This action can be changed to a custom action if desired. Thus pogoing could activate shooting or other such sequences.)

The collision works by responding to two sets of sprite actions. (See Patch:Jump conditions.) The checks are set up such that there is a lower and upper bound for what actions trigger what response. The first set of actions are those of Keen pogoing, the response is to change the Red's action to a vitalin splash and play the Little Ampton stunned sound.

The second set of actions cover Keen's shot's actions and the response is to run the 'change sprite into a smashed shot' code.

Patch: Keen 5 collision code
#Red harmless, blocks shots, can be pogoed on to kill
%patch $1264D $55 $8B $EC $56 $57 $8B $7E $06 $8B $76 $08 $81 $7C $1C $1008W $74 $07 $81 $7C $1C $1026W $75 $13 $C7 $45 $1C $19DCW $B8 $0021W $50 $9A $196E09EFRL $83 $C4 $02 $EB $17 $81 $7C $1C $1502W $72 $10 $81 $7C $1C $155CW $77 $09 $56 $9A $0CCB10B3RL $83 $C4 $02 $5F $5E $5D $CB


Animations

There is little to say about Robo Red's animations. Its moving animation speed also controls its movement speed, and it is possible to alter how long it pauses before shooting and how fast it shoots. Aside from that everything is quite regular.

Patch: Keen 5
#Cache
%patch $31A3C $0183W
#Robo Red cache start
%patch $31A90 $0188W
#Cache end
#Robo Red moving
%patch $32A74 $0184W $0183W %patch $32A7E $0006W
#Animation speed
#Robo Red shoot
%patch $32A92 $0184W $0183W %patch $32A9C $0028W
#Pause before shooting
%patch $32AB0 $0184W $0183W %patch $32ABA $0004W
#Pause between shots
%patch $32ACE $0184W $0183W %patch $32AD8 $0006W
#Shot time
#Robo Red's shot
%patch $32AEC $0185W $0185W %patch $32AF6 $0008W
#Animation speed
%patch $32B0A $0186W $0186W %patch $32B14 $0008W
#Animation speed
#Robo Red's shot smash
%patch $32B28 $0187W $0187W %patch $32B32 $000AW
#Animation speed
%patch $32B46 $0188W $0188W %patch $32B50 $000AW
#Animation speed


Sounds

There are two sounds associated with the Robo Red, that of it shooting and that of a shot hitting something and being destroyed. Both can be removed.

Patch: Keen 5
#Sounds
%patch $12706 $1D
#Robo Red shoot
%patch $12769 $1E
#Robo red shot destroyed

Patch: Keen 5
#Don't play sounds
%patch $12705 $EB $0A
#Don't play Robo Red shoot
%patch $12768 $EB $0A
#Don't play Robo red shot destroyed


Sprite positioning

The Robo Red spawns 4 tiles up from where it is placed in-level, perhaps the highest spawn height in the games, appropriate for its large sprite. The Red's shots also spawn at a specified location, 2 tiles down from the top of the Red's sprite and, when shooting left, 3.5 tiles right.

Patch: Keen 5
#Spawn height
%patch $125C7 $FC00W
#4 tiles up
#Shot spawn relative to Red:
%patch $126CE $0200W
#2 tiles down from sprite top
%patch $126BD $0380W
#3.5 tiles right, when shooting left only


Clipping and foreground

Add clipping\foreground by overwriting

The Robo Red and its shots have no adjustable foreground variables by default. However some can be created at the expense of other properties. For the Robo Red this is the sprite activity variable, which has a subtle effect and shouldn't be missed. For the Red's shots this is the up\down speed (They will only move left or right.) In the foreground patches below the clipping is set to 3, or 'appear in front of all sprites and fore tiles', the most noticeable foreground change. In the clipping patches clipping is set to 0, allowing Red and the shots to pass through all tiles.

Patch: Add foreground variables to Robo Red and his shots
#Robo Red has foreground variable (Sacrifice sprite active var)
%patch $125B4 $20 $0003W
#Robo Red's shots have foreground variables (Sacrifice vertical movement)
%patch $126F7 $20 $0003W %patch $12702 $20 $0003W

Patch: Add clipping variables to Robo Red and his shots
#Robo Red has clipping variable (Sacrifice sprite active var)
%patch $125B4 $06 $0003W
#Robo Red's shots have clipping variables (Sacrifice vertical movement)
%patch $126F7 $06 $0003W %patch $12702 $06 $0003W


Add clipping by linking code

A second approach is to adjust the Red's spawning code. In this case other sprite properties remain unchanged. However the Shikadi Master's spawn code cannot be overwritten (Though it can be mildly patched.) as the Red now relies on it.

Patch: Add foreground variable to Rob Red
#Give Robo Red a foreground variable
%patch $125F2 $C7 $47 $20 $0000W $E9 $04C2W


Sprite-tile interaction

The Robo Red does not have any specialized tile collisions. it uses a generic 'back and forth' collision to avoid walking off edges or into walls. When shooting it uses a 'sit' collision' that keeps it out of solid tiles, as do its destroyed shots. Its shots however have their own unique collision that allows them to produce smashed shots when they hit walls or floors.

Patch: Keen 5
#Moving
%patch $32A8C $090B17DCRL
#Move l/r and down slopes
#Shooting
%patch $32AAA $090B17B5RL
#Sit(Pause before starting)
%patch $32AC8 $090B17B5RL
#Sit(Pause between shots)
%patch $32AE6 $090B17B5RL
#Sit
#Shots
%patch $32B04 $11C40B09RL
#Robo red's shoot
%patch $32B22 $11C40B09RL
#Robo red's shoot
#Shots smashed
%patch $32B40 $090B17B5RL
#Sit
%patch $32B5E $090B17B5RL
#Sit


Red's shot's tile interaction code

This is the complete tile interaction code for Red's shot. The first two lines check to see if the shot it touching any sort of wall, floor or ceiling. If so it plays sound $001EW (Shot smash) in line 4 and changes action to the smashed shot. The code after this simply draws the shot.

Patch: Keen 5
#Robo Red's shot's tile interaction
%patch $12749 $55 $8B $EC $56 $8B $76 $06 $83 $7C $36 $00 $75 $12 $83 $7C $38 $00 $75 $0C $83 $7C $3A $00 $75 $06 $83 $7C $3C $00 $74 $19 $B8 $001EW $50 $9A $196E09EFRL $83 $C4 $02 $B8 $27E8W $50 $56 $9A $090B1242RL $83 $C4 $04 $FF $74 $20 $33 $C0 $50 $FF $74 $1E $FF $74 $0C $FF $74 $0A $8B $C6 $05 $46 $00 $50 $9A $174E163ERL $83 $C4 $0C $5E $5D $CB


Action type

The Robo Red uses type 0 for all its actions. Its shots however are type 3, with a more fluid motion.

Patch: Keen 5
#Move
%patch $32A78 $0000W
#Shoot
%patch $32A96 $0000W
#Pause before shoot
%patch $32AB4 $0000W
#Pause between shots
%patch $32AD2 $0000W
#Shoot
#Red's shots
%patch $32AF0 $0003W %patch $32B0E $0003W
#Red's shots smash
%patch $32B2C $0000W %patch $32B4A $0000W


Deprotect and stick to ground

The Robo Red is rather unique in that it uses the stick to ground parameter when moving and shooting, but also uses the deprotect animation so that its 'jiggling' when shooting looks smoother.

Patch: Keen 5
#Move
%patch $32A7A $0000W $0001W
#Shoot
%patch $32A98 $0001W $0001W
#Pause
%patch $32AB6 $0001W $0001W
#Pause between shots
%patch $32AD4 $0000W $0001W
#Shoot
#Shots
%patch $32AF2 $0000W $0000W %patch $32B10 $0000W $0000W
#Shots smash
%patch $32B2E $0000W $0000W %patch $32B4C $0000W $0000W


Probability and randomness

The Robo Red's spawn direction is random, with a 50:50 chance of facing left or right. There is also a smaller chance the Robo Red will shoot Keen if he is nearby. (See the 'Keen seeking' section for a patch to make red shoot randomly wherever Keen is.)

Patch: Keen 5
#Chance of initially moving right:
%patch $125D2 $0080W
#Probability Red will shoot when Keen is near:
%patch $12624 $0010W


Sprite spawn code

Only partial spawn code is available for the Robo Red. Notice that there are three kinds of Robo Red, one for each difficulty level. Notice also that Red's cache is set in $C7 $06 $C28FW $0001W.

The last blue highlighted value is the sprite action the sprite uses as it proceeds to act in-level. $C7 $47 $02 $xxxxW sets the sprite activity, $C7 $07 $xxxxW sets the sprite type, Finally $D3 $E0 $05 $xxxxW is how far down (Or more usually up) the Red is spawned from where it is placed. This is just to align its placement height in the level editor with its sprite height.

$C7 $47 $0E $xxxxW is the horizontal direction the sprite starts moving in, either $0001W (Facing right), $FFFFW (Facing left) or $0000W (Neither, never used.) Red uses a probability check to determine which way it faces, this is 50:50 (Though it needn't be.) and the code responsible for this is $9A $1D02002ARL $3D $0080W

Patch: Keen 5
#Location of initiation code
%patch $F4DE $26DW
#Easy RoboRed (At $EFBD)
%patch $F4E0 $263W
#Normal RoboRed (At $EFB3)
%patch $F4E2 $259W
#Hard RoboRed (At $EFA9)
#Robo Red Initiation code
%patch $EFA9 $83 $3E $6F6CW $03 $7D $03 $E9 $03F4W $83 $3E $6F6CW $02 $7D $03 $E9 $03EAW $57 $56 $9A $11C4095CRL $83 $C4 $04 $C7 $06 $C28FW $0001W $E9 $03D7W
#Robo Red spawning code
%patch $1259C $55 $8B $EC $33 $C0 $50 $9A $06B91DCDRL $83 $C4 $02 $8B $1E $40 $9E $C7 $07 $000CW $C7 $47 $02 $0001W $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $05 $FC00W $89 $47 $0C $9A $1DFB0036RL $3D $0080W $7D $0B $8B $1E $40 $9E $C7 $47 $0E $0001W $EB $09 $8B $1E $40 $9E $C7 $47 $0E $FFFFW $B8 $2734W $50 $FF $36 $40 $9E $9A $090B11C4RL $83 $C4 $04 $5D $CB