Patch:Shikadi Master

From KeenWiki
Jump to: navigation, search

This page covers patches relating to the Shikadi Masters in Keen 5. They can teleport themselves to any place they wish, and also shoot deadly blasts of energy (called "electrospheres") along the ground. It should be noted that the electrospheres can be stopped by shooting them. Shikadi Masters only appear guarding the Quantum Explosion Dynamo. They can only be found on normal and hard difficulties.

Sprite Type

Shikadi Master use sprite type 19 which is used only by the Shikadi Master and doesn't affect anything else.

Patch: Keen 5
#Shikadi Master sprite type
%patch $12A9B $13

Sprite Actions

The Shikadi Master's actions can be quite difficult to understand. They are spawned standing, a four frame loop that is not exited until the Shikadi Master either shoots or teleports, both of which occur randomly. The Shikadi Master will also shoot if Keen shoots him.

The shooting sequence is two frames long and ends with the Shikadi Master returning to standing. An electrosphere is produced during the sequence which falls to the ground. The electrosphere has a four frame animation loop which is stays in until it hits flat ground. On hitting flat ground shots become two groundsparks.

Teleporting is a four frame sequence; in the first frame the Shikadi Master does nothing, in the second he decides whether to teleport and if so teleports, in the third he reappears and falls towards the ground and in the fourth he returns to standing. However if the Shikadi Master's fall is interrupted he will also return to standing.

At the start of teleporting two ground spark sprites are also created, moving in opposite directions away from the Shikadi Master's position. If the Shikadi Master decides not to teleport then all that will happen is the groundsparks will be produced. This happens if Keen is too close to bother teleporting.

Ground sparks have a four frame loop that they continue in until they hit a wall or go offscreen, when they vanish.

$2AF4W #Shikadi Master stand 1
$2B12W #Shikadi Master stand 2
$2B30W #Shikadi Master stand 3
$2B4EW #Shikadi Master stand 4
$2B6CW #Shikadi Master shoot
$2B8AW #Shikadi Master shoot (Make shot)
$2BA8W #Shikadi Master teleport 1
$2BC6W #Shikadi Master teleport 2 (make groundsparks, vanish)
$2BE4W #Shikadi Master teleport 3 (reappear, fall)
$2C02W #Shikadi Master teleport 4
$2C20W #Shikadi Master's shot 1
$2C3EW #Shikadi Master's shot 2
$2C5CW #Shikadi Master's shot 3
$2C7AW #Shikadi Master's shot 4
$2C98W #Shikadi Master sparks 1
$2CB6W #Shikadi Master sparks 2
$2CD4W #Shikadi Master sparks 3
$2CF2W #Shikadi Master sparks 4

Patch: Keen 5
#When spawned
%patch $12AB8 $2AF4W
#Standing loop
%patch $32E50 $2B12W %patch $32E6E $2B30W %patch $32E8C $2B4EW %patch $32EAA $2AF4W
#Randomly while standing:
%patch $12AE7 $2BA8W
#Shikadi Master teleport
%patch $12B13 $2B6CW
#Shikadi Master shoot
#When Master is shot by Keen
%patch $12BA8 $2B6CW
#Shooting sequence
%patch $32EC8 $2B8AW %patch $32EE6 $2AF4W
#What Master shoots
%patch $12B36 $2C20W
#Shikadi Master's shot loop
%patch $32F7C $2C3EW %patch $32F9A $2C5CW %patch $32FB8 $2C7AW %patch $32FD6 $2C20W
#Shikadi Master's shots hit ground
%patch $12E2E $2C98W
#Shot makes right sparks
%patch $12E5C $2C98W
#Shot makes left sparks
#Shikadi Master returns to standing if he decides not to teleport
%patch $12C5D $2AF4W
#When teleporting create...
%patch $12BFF $2C98W
#Master sparks (Right)
%patch $12C2D $2C98W
#Master sparks (Left)
#Teleport sequence
%patch $32F04 $2BC6W %patch $32F22 $2BE4W %patch $32F40 $2C02W %patch $32F5E $2AF4W
#Ground sparks loop
%patch $32FF4 $2CB6W %patch $33012 $2CD4W %patch $33030 $2CF2W %patch $3304E $2C98W

Sprite Behavior

There are no less than four behaviors relating to the Shikadi Master. Interestingly the Shikadi Master's standing behavior is only used by its last standing action. This is what makes him randomly teleport or shoot at Keen. Its shooting behavior is used by its first shooting frame, this is what makes him produce a shot in Keen's direction.

The teleporting Shikadi Master uses its teleport behavior only in its second teleport frame. This produces groundsparks. In its next frame it uses a generic 'fall to the ground' behavior allowing it to fall and land.

The Shikadi Master's shots have their own unique behavior that lets them fall and bounce off walls. Finally the ground sparks use a generic 'fall' behavior that lets them fall off of flat ground or move down slopes.

$11C40E86RL #Shikadi Master stand (Randomly go to walk or shoot)
$11C40EDARL #Shikadi Master shoot (Make shot)
$11C40F86RL #Shikadi Master teleport (Make groundsparks)
$090B172CRL #Shikadi Master's shot

Patch: Keen 5
%patch $32E44 $00000000L
%patch $32E62 $00000000L
%patch $32E80 $00000000L
%patch $32E9E $11C40E86RL
#Shikadi Master stand
%patch $32EBC $11C40EDARL
#Shikadi Master shoot
%patch $32EDA $00000000L
%patch $32EF8 $00000000L
%patch $32F16 $11C40F86RL
#Shikadi Master teleport
%patch $32F34 $090B1710RL
%patch $32F52 $00000000L
#Shikadi Master's shot
%patch $32F70 $090B172CRL
#Shikadi Master's shot
%patch $32F8E $090B172CRL
#Shikadi Master's shot
%patch $32FAC $090B172CRL
#Shikadi Master's shot
%patch $32FCA $090B172CRL
#Shikadi Master's shot
%patch $32FE8 $090B1710RL
%patch $33006 $090B1710RL
%patch $33024 $090B1710RL
%patch $33042 $090B1710RL

Shooting patches

These patches alter the way the Shikadi Master shoots.

Number of shots Shikadi Master produces

This patch changes the number of shots the Shikadi Master produces when shooting. By default this is one shot. Recall there are two situations when the Shikadi Master shoots, randomly and when Keen shoots him.

Patch: Number of shots Master shoots
#Shots when shooting randomly
%patch $12AF6 $0001W
#Shots when shot by Keen
%patch $12BA5 $0001W

Shikadi Master doesn't shoot

This patch stops the Shikadi Master randomly shooting, he will only shoot if Keen shoots him first. However even this can be disabled by changing the Shikadi Master's sprite collision (see below) to 'kill and block shots'

Patch: Keen 5
#Master doesn't shoot randomly (Only when Keen shoots him)
%patch $12AE2 $90 $90

Complete shooting code

This is the complete behavior code for the Shikadi Master shooting. This is what causes a shot to be produced. On the first line the Master's direction is checked. If it is shooting right then the Master's shot will have to be moved right a bit relative to the Master. This amount (16 pixels or 1 tile) is on line 2, as is the action of the sprite produced.

On line 3 is the vertical position of the shot (4 pixels down from thee Master's head.) Finally on the fifth line is the sound the Shikadi Master makes when shooting.

It should be noted that this code does not relate to seeking Keen in any way or the number of shots produced. That is handled elsewhere.

Patch: Keen 5
#Complete Shikadi Master shoot behavior code
%patch $12B1A $55 $8B $EC $56 $57 $8B $76 $06 $83 $7C $0E $01 $75 $0A $8B $44 $0A $05 $0100W $8B $F8 $EB $03 $8B $7C $0A $B8 $2C20W $50 $8B $44 $0C $05 $0080W $50 $57 $9A $0F920003RL $83 $C4 $06 $3D $FFFFW $74 $20 $8B $44 $0E $BA $0030W $F7 $EA $8B $1E $40 $9E $89 $47 $16 $C7 $47 $18 $FFF0W $B8 $0026W $50 $9A $196E09EFRL $83 $C4 $02 $5F $5E $5D $CB

Complete standing code

This is the complete code for the Shikadi Master standing. On the first and second lines a random check is made; if this is greater than $40 then all the remaining code is skipped (Nothing happens.) Otherwise a check of the Master's second misc variable is made. If this is not zero then the Master's action is changed to teleporting and the variable is set to 0. (So it won't teleport continuously.)

Otherwise on line four the variable is set to 1 (Allowing teleporting again) and Keen's location checked. On line 5 the Master turns to face Keen based on this and its action changes to that of shooting.

The net effect of these interactions is to make the Master need to shoot before it can teleport. Though the timing of shooting and teleporting are random there is a 1-1 pattern of shooting and teleporting.

Patch: Keen 5
#Complete Shikadi Master standing code
%patch $12AC6 $55 $8B $EC $83 $EC $02 $56 $8B $76 $06 $9A $1DFB0036RL $89 $46 $FE $83 $7E $FE $40 $7D $37 $83 $7C $3E $00 $74 $0F $C7 $44 $1C $2BA8W $C7 $44 $3E $0000W $5E $8B $E5 $5D $CB $C7 $44 $3E $0001W $8B $1E $3E $9E $8B $47 $0A $3B $44 $0A $76 $07 $C7 $44 $0E $0001W $EB $05 $C7 $44 $0E $FFFFW $C7 $44 $1C $2B6CW $5E $8B $E5 $5D $CB

Seeking Keen

The Shikadi Master will turn towards Keen when shooting. There are two situations when the Shikadi Master will shoot, randomly and when Keen shoots it.

Patch: Keen seeking
#Turn towards Keen when randomly shooting:
%patch $12B07 $0001W %patch $12B0E $FFFFW
#Turn towards Keen when shot:
%patch $12B98 $0001W %patch $12B9D $FFFFW

Shikadi Master's shots seek Keen vertically not horizontally

By default the Shikadi Master's shots are shot in Keen's horizontal direction. This is accomplished by checking his horizontal location then adjusting the shot's horizontal directions. This can be adjusted to check Keen's vertical location and adjust the shot's vertical speeds. (Or just half the patch can be used, which is... interesting.)

Again there are two situations in which the Shikadi Master shoots, both set up slightly differently. As with the above section, you can swap the seeking values so that the Shikadi Master shoots in the opposite vertical direction to Keen.

Patch: Shikadi Master's shots seek Keen vertically not horizontally
#Randomly shooting
%patch $12AFE $0C
#Check vertical 1
%patch $12B01 $0C
#Check vertical 2
%patch $12B06 $10 $0001W
#Right is now up
%patch $12B0D $10 $FFFFW
#Left is now down
#When shot by Keen
%patch $12B91 $0C
#Check vertical 1
%patch $12B94 $0C
#Check vertical 2
%patch $12BA1 $10
#Change horizontal to vertical
%patch $12B98 $0001W
%patch $12B9D $FFFFW

Speed and Jump Height

Shikadi Master speeds are complex. Animation motion is never used. Instead speeds are set when things are created. Notably the groundsparks created when the Shikadi Master teleports or when his shots hit the ground are given their speeds on creation. (And both are different situations allowing for two speeds of ground spark.) The Shikadi Master's shots are also given both horizontal and vertical speeds though as yet it is not known how these are set.

Patch: speed and jump height
#Teleport groundsparks' speed:
%patch $12BFC $0030W
%patch $12C2A $FFD0W
#Shots hit groundsparks' speed:
%patch $12E2B $0030W
%patch $12E59 $FFD0W

Patch: Animation motion
#Shikadi Master stand
%patch $32E40 $0000W $0000W %patch $32E5E $0000W $0000W %patch $32E7C $0000W $0000W %patch $32E9A $0000W $0000W
#Shikadi Master Shoot
%patch $32EB8 $0000W $0000W %patch $32ED6 $0000W $0000W
#Shikadi Master Teleporting
%patch $32EF4 $0000W $0000W %patch $32F12 $0000W $0000W %patch $32F30 $0000W $0000W %patch $32F4E $0000W $0000W
#Shikadi Master's shot
%patch $32F6C $0000W $0000W %patch $32F8A $0000W $0000W %patch $32FA8 $0000W $0000W %patch $32FC6 $0000W $0000W
%patch $32FE4 $0000W $0000W %patch $33002 $0000W $0000W %patch $33020 $0000W $0000W %patch $3303E $0000W $0000W

Sprite Collision

The Shikadi Master is invulnerable and deadly. His shots have their own collision.

Collision values

The Shikadi Master uses its own special collision. Lethal to Keen he will shoot at him if shot. However when shooting or teleporting he uses a generic 'kill Keen and block his shots' collision used by many sprites. This is to avoid Keen being able to trap him in a loop of trying to shoot or interrupting his teleporting. The Shikadi Master's shots can be destroyed by Keen's shots and are lethal to Keen.

$11C40F32RL #Shikadi Master
$11C41173RL #Shikadi Master's shots

Patch: Keen 5 collision values
%patch $32E48 $11C40F32RL
#Shikadi Master
%patch $32E66 $11C40F32RL
#Shikadi Master
%patch $32E84 $11C40F32RL
#Shikadi Master
%patch $32EA2 $11C40F32RL
#Shikadi Master
%patch $32EC0 $11C40D61RL
#Kill and block shots
%patch $32EDE $11C40D61RL
#Kill and block shots
%patch $32EFC $11C40D61RL
#Kill and block shots
%patch $32F1A $11C40D61RL
#Kill and block shots
%patch $32F38 $00000000L
%patch $32F56 $11C40D61RL
#Kill and block shots
#Master's shot
%patch $32F74 $11C41173RL
#Shikadi Master's shots
%patch $32F92 $11C41173RL
#Shikadi Master's shots
%patch $32FB0 $11C41173RL
#Shikadi Master's shots
%patch $32FCE $11C41173RL
#Shikadi Master's shots
#Master's sparks
%patch $32FEC $11C41173RL
#Shikadi Master's shots
%patch $3300A $11C41173RL
#Shikadi Master's shots
%patch $33028 $11C41173RL
#Shikadi Master's shots
%patch $33046 $11C41173RL
#Shikadi Master's shots


The Shikadi Master's animations are quite straightforward. Four animations are used when standing and two when shooting (One for each direction.) Two animations are used when teleporting, the first for only one frame the second for the next three frames. The animation speed at the start of teleporting and shooting define how long these take before that start. the animation speeds at their end determine how long the Shikadi Master will wait before returning to standing again.

The Shikadi Master's shot and groudnsparks take up another four animations each.

Patch: Keen 5
%patch $31A2E $0130W
#Master cache start
%patch $31A82 $013FW
#Cache end
#Shikadi Master stand
%patch $32E34 $0130W $0130W %patch $32E3E $0008W
#Animation speed
%patch $32E52 $0131W $0131W %patch $32E5C $0008W
#Animation speed
%patch $32E70 $0132W $0132W %patch $32E7A $0008W
#Animation speed
%patch $32E8E $0133W $0133W %patch $32E98 $0008W
#Animation speed
#Shikadi Master shooting
%patch $32EAC $0137W $0136W %patch $32EB6 $001EW
#Pause before shooting
%patch $32ECA $0137W $0136W %patch $32ED4 $0008W
#Shoot time
#Shikadi Master teleport
%patch $32EE8 $0134W $0134W %patch $32EF2 $0014W
#Animation speed
%patch $32F06 $0135W $0135W %patch $32F10 $0014W
#Animation speed
%patch $32F24 $0135W $0135W %patch $32F2E $0000W
#Wait to teleport
%patch $32F42 $0135W $0135W %patch $32F4C $003CW
#Pause before returning to standing
#Shikadi Master's shot
%patch $32F60 $013FW $013CW %patch $32F6A $0008W
#Animation speed
%patch $32F7E $013EW $013DW %patch $32F88 $0008W
#Animation speed
%patch $32F9C $013DW $013EW %patch $32FA6 $0008W
#Animation speed
%patch $32FBA $013CW $013FW %patch $32FC4 $0008W
#Animation speed
%patch $32FD8 $0138W $0138W %patch $32FE2 $0006W
#Animation speed
%patch $32FF6 $0139W $0139W %patch $33000 $0006W
#Animation speed
%patch $33014 $013AW $013AW %patch $3301E $0006W
#Animation speed
%patch $33032 $013BW $013BW %patch $3303C $0006W
#Animation speed


There are three sounds associated with the Shikadi Master. The first is that produced when the Shikadi Master produces an electrosphere. The second is produced when the Shikadi Master produces groundsparks while teleporting. (Thus even if he decides not to teleport, just produce the sparks, he will make this sound.) The third is produced when the electrosphere hits the ground and becomes groundsparks. It is the same as the Shikadi Master's shooting sound by default; but does not have to be so.

Patch: Sounds
#Shikadi Master shoot sound
%patch $12B63 $26
#Shikadi Master teleport sound
%patch $12C3A $27
#Shikadi Master's shot hit ground sound
%patch $12E1D $26

Patch: Don't play sounds
#Don't play Shikadi Master shoot sound
%patch $12B62 $EB $0A
#Don't play Shikadi Master teleport sound
%patch $12C39 $EB $0A
#Don't play Shikadi Master's shot hit ground sound
%patch $12E1C $EB $0A

Sprite positioning

The Shikadi Master spawns one and a half tiles above where he is placed in the level. This is vital for allowing him to stand on flat ground.

The Master's shot also spawns at a specific location relative to it. This is always 8 pixels down from its top and when it is shooting right 16 pixels (1 tile) right of its left side.

Patch: Keen 5
#Spawn height
%patch $12AB2 $FE80W
#1 1/2 tile up
#Master's shot position
%patch $12B2C $0100W
#Horizontal when shooting right
%patch $12B3D $0080W

Sprite-tile interaction

The Shikadi Master has a number of tile interactions. When simply standing it uses a generic draw sprite' interaction. This is also used when shooting and teleporting. It doesn't interact with tiles at all, leaving the master's clipping to stop it falling through floors and such.

When teleporting the Master's falling frame (after reappearing) uses a second generic collision that causes it to stop moving horizontally when it hits walls, and stop falling and move to its next action when it hits a floor.

Both the Shikadi Master's shots and the groundsparks have their own unique interactions. The Shikadi Master's shot's interaction lets them to fall, bounce off of walls and become groundsparks when they land on flat surfaces. The groundsparks' interactions lets them turn when they reach platform edges, fall through the air and eventually vanish.

Patch: Keen 5
#Shikadi Master Stand
%patch $32E4C $090B17B5RL %patch $32E6A $090B17B5RL %patch $32E88 $090B17B5RL %patch $32EA6 $090B17B5RL
#Shikadi Master Shoot
%patch $32EC4 $090B17B5RL %patch $32EE2 $090B17B5RL
#Shikadi Master Teleport
%patch $32F00 $090B17B5RL %patch $32F1E $090B17B5RL %patch $32F3C $0F9200A8RL
#Fall until hitting ground
%patch $32F5A $090B17B5RL
#Shikadi Master's Shot
%patch $32F78 $11C411B0RL
#Shikadi Master's shot
%patch $32F96 $11C411B0RL
#Shikadi Master's shot
%patch $32FB4 $11C411B0RL
#Shikadi Master's shot
%patch $32FD2 $11C411B0RL
#Shikadi Master's shot
%patch $32FF0 $11C41248RL
#Shikadi Master's sparks
%patch $3300E $11C41248RL
#Shikadi Master's sparks
%patch $3302C $11C41248RL
#Shikadi Master's sparks
%patch $3304A $11C41248RL
#Shikadi Master's sparks

Action type

The Shikadi Master himself uses action type 0 for all of his actions, since he does not need to move at all. The exception is his falling action when teleporting, where he sues type 2, as do most falling sprites. The Shikadi Master's shots and groundsparks use type 3, as they must move smoothly and fall.

Patch: Keen 5
#Shikadi Master Stand
%patch $32E38 $0000W %patch $32E56 $0000W %patch $32E74 $0000W %patch $32E92 $0000W
#Shikadi Master Shoot
%patch $32EB0 $0000W %patch $32ECE $0000W
#Shikadi Master Teleport
%patch $32EEC $0000W %patch $32F0A $0000W %patch $32F28 $0002W %patch $32F46 $0000W
#Shikadi Master's Shot
%patch $32F64 $0003W %patch $32F82 $0003W %patch $32FA0 $0003W %patch $32FBE $0003W
%patch $32FDC $0003W %patch $32FFA $0003W %patch $33018 $0003W %patch $33036 $0003W

Deprotect and stick to ground

Neither the Shikadi Master or his related sprites use either of these two variables, with the exception of the first two teleporting frames of the Shikadi Master. These use the deprotect animation variable; which is set to 1.

Patch: Keen 5
#Shikadi Master Stand
%patch $32E3A $0000W $0000W %patch $32E58 $0000W $0000W %patch $32E76 $0000W $0000W %patch $32E94 $0000W $0000W
#Shikadi Master Shoot
%patch $32EB2 $0000W $0000W %patch $32ED0 $0000W $0000W
#Shikadi Master Teleport
%patch $32EEE $0000W $0001W %patch $32F0C $0000W $0001W %patch $32F2A $0000W $0000W %patch $32F48 $0000W $0000W
#Shikadi Master's Shot
%patch $32F66 $0000W $0000W %patch $32F84 $0000W $0000W %patch $32FA2 $0000W $0000W %patch $32FC0 $0000W $0000W
%patch $32FDE $0000W $0000W %patch $32FFC $0000W $0000W %patch $3301A $0000W $0000W %patch $33038 $0000W $0000W

Sprite spawn code

There are three types of Master, one for each difficulty level. (Though in the game there is only one Master by default, appearing on normal and hard difficulties only.) The cache is set in $C7 $06 $C281W $0001W.

The Master's spawn code is remarkably simple; 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 activityand $C7 $07 $xxxxW sets the sprite type. Nothing else is set.

Patch: Keen 5
#Location of initiation code
%patch $F574 $5CDW
#Easy Shikadi Master (At $F31D)
%patch $F576 $5C3W
#Normal Shikadi Master (At $F313)
%patch $F578 $5B9W
#Hard Shikadi Master (At $F309)
#Shikadi Master Initiation code
%patch $F309 $83 $3E $6F6CW $03 $7D $03 $E9 $0094W $83 $3E $6F6CW $02 $7D $03 $E9 $008AW $57 $56 $9A $11C40E47RL $83 $C4 $04 $C7 $06 $C281W $0001W $EB $78
#Shikadi Master Spawn code
%patch $12A87 $55 $8B $EC $33 $C0 $50 $9A $06B91DCDRL $83 $C4 $02 $8B $1E $40 $9E $C7 $07 $0013W $C7 $47 $02 $0001W $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $05 $80 $FE $89 $47 $0C $B8 $2AF4W $50 $53 $9A $090B11C4RL $83 $C4 $04 $5D $CB