Patch:Skypest

From KeenWiki
Jump to navigation Jump to search

Skypests are small, flying, seemingly invulnerable enemies from Keen 4. They are notable for the difficulty involved in killing them, especially in killing them.


Sprite Type

Slugs use sprite type 12 which is used only by the Skypest and doesn't affect anything else. When squished its type becomes type 1 (Misc), as extra insurance against affecting anything else.

Keen 4

#Skypest sprite types
%patch $105FB $0B #Skypest default
%patch $1076B $01 #Squished Skypest


Sprite Actions

The Skypest has four cycles, a two-frame flaying cycle, a one-frame squashed cycle, a one-frame landing cycle and a long preening cycle (Where it lands on the ground and licks itself.)

What is interesting is the Skypest's collision. It is affected not by sprite type, but by what the sprite is doing. There are three Keen actions that can affect the Skypest.

Actions:
$2486W #Skypest flying
$24A4W #Skypest flying
$24C2W #Skypest squished
$24E0W #Skypest preening
$24FEW #Skypest preening
$251CW #Skypest preening
$253AW #Skypest preening
$2558W #Skypest preening
$2576W #Skypest preening
$2594W #Skypest preening
$25B2W #Skypest preening
$25D0W #Skypest preening
$25EEW #Skypest preening
$260CW #Skypest preening
$262AW #Skypest preening
$2648W #Skypest preening
$2666W #Skypest preening
$2684W #Skypest preening
$26A2W #Skypest preening
$26C0W #Skypest preening

Keen 4

#Place Skypest in level
%patch $10656 [$2486W] #Skypest flying

#Skypest land
%patch $107BA [$24E0W] #Skypest preening

#Keen actions that can squash Skypest
%patch $1073E [$110CW] #Keen presses 'pogo' on a Skypest and kills it
%patch $10745 [$112AW] #Keen pogos low squishes Skypest
%patch $1074C [$1148W] #Keen pogos high squishes Skypest

#Skypest squished
%patch $10751 [$24C2W] #Skypest squashed by Keen
%patch $3134E [$24C2W] #Skypest when squished (Stay squished)

#Skypest flying
%patch $31312 [$24A4W] #Skypest flying
%patch $31330 [$2486W] #Skypest flying

#Skypest preening
%patch $3136C [$24FEW] #Skypest preening 1
%patch $3138A [$251CW] #Skypest preening 2
%patch $313A8 [$253AW] #Skypest preening 3
%patch $313C6 [$2558W] #Skypest preening 4
%patch $313E4 [$2576W] #Skypest preening 5
%patch $31402 [$2594W] #Skypest preening 6
%patch $31420 [$25B2W] #Skypest preening 7
%patch $3143E [$25D0W] #Skypest preening 8
%patch $3145C [$25EEW] #Skypest preening 9
%patch $3137A [$260CW] #Skypest preening 10
%patch $31398 [$262AW] #Skypest preening 11
%patch $313B6 [$2648W] #Skypest preening 13
%patch $313D4 [$2666W] #Skypest preening 14
%patch $314F2 [$2684W] #Skypest preening 15
%patch $31510 [$26A2W] #Skypest preening 16
%patch $3152E [$26C0W] #Skypest preening 17
%patch $3154C [$2486W] #Skypest flying


Sprite Behavior

The Skypest has three behaviors, the first is nothing at all, the second is flying, which randomly changes its direction so it buzzes about randomly. The third simply launches it off the ground so it doesn't get stuck being grounded.

These are used as you would expect, the flying behavior is sued by the flying Skypest and the launching off ground used at the very end of the preening cycle (When the Skypest must turn from landed to flying.) Everything else uses the 'nothing' behavior.

Behaviors:
$00000000L  #Nothing
$0FA80BE7RL #Skypest flying
$0FA80CF1RL #Skypest fly off ground

Keen 4

#Flying
#Flying
%patch $31306 $0FA80BE7RL #Skypest flying
%patch $31324 $0FA80BE7RL #Skypest flying

#Landed
%patch $31360 $00000000L  #Nothing
%patch $3137E $00000000L  #Nothing
%patch $3139C $00000000L  #Nothing
%patch $313BA $00000000L  #Nothing
%patch $313D8 $00000000L  #Nothing
%patch $313F6 $00000000L  #Nothing
%patch $31414 $00000000L  #Nothing
%patch $31432 $00000000L  #Nothing
%patch $31450 $00000000L  #Nothing
%patch $3146E $00000000L  #Nothing
%patch $3148C $00000000L  #Nothing
%patch $314AA $00000000L  #Nothing
%patch $314C8 $00000000L  #Nothing
%patch $314E6 $00000000L  #Nothing
%patch $31504 $00000000L  #Nothing
%patch $31522 $00000000L  #Nothing
%patch $31540 $0FA80CF1RL #Skypest fly off ground

#Squished
%patch $31342 $00000000L  #Nothing


Skypest launch behavior

This is the complete (and rather simple) code for the Skypest launching itself off the ground. In essence its vertical direction becomes -1 (up) and its vertical speed $FFF0W (Upwards direction.) Note that this patch contains speed and direction patches and is thus incompatible with those patches. Hopefully it is easy to see where those patches fit into this, larger, patch.

Skypest launch behavior

#Skypest launch behavior
%patch $10771 $55 $8B $EC $56 $8B $76 $06 $C7 $44 $10 [$FFFFW]  $C7 $44 $18 [$FFF0W]
                  $C7 $06 $21 $C9 $70 $FF $5E $5D $CB


Skypest fly behavior

This is the complete behavior code for the Skypest flying. On the first line the Random Number Generator is called and if it produces a number less than the $A54C variable (Which is usually 2 or 3) then it will randomly flip horizontal directions. After this its vertical direction is checked, if moving up ($FF) then another RNG call is made and if larger than $A54C the Skypest's vertical direction is set to 1 (Down) This serves to make it randomly head downward slightly more than up, causing it to eventually land.

On the fourth line another vertical direction check is made, if moving down ($01) an RNG call is made, compared to $A54C and if less, the vertical direction is flipped. After this the Skypest moves horizontally and vertically through the air with speeds of $0014W.

Skypest flying behavior

#Skypest flying behavior
%patch $10667 $55 $8B $EC $56 $8B $76 $06 $9A $1D02002ARL     $3B $06 [$A54CW]
              {$73} $08 $8B $44 $0E $F7 $D8 $89 $44 $0E $83 $7C {$10} [$FF] {$75} $10
              $9A $1D02002ARL     $3B $06 [$A54CW]  {$73} $05 $C7 $44 $10 [$0001W]
              $83 $7C {$10} [$01] {$75} $17 $9A $1D02002ARL     $8B $16 [$A54CW]  $D1
              $E2 $3B $C2 {$73} $08 $8B $44 $10 $F7 $D8 $89 $44 $10 $B8 [$0014W] 
              $50 $FF $74 $0E $56 $9A $09DC13FERL     $83 $C4 $06 $B8 [$0014W] 
              $50 $FF $74 $10 $56 $9A $09DC1517RL     $83 $C4 $06 $5E $5D $CB


Skypest chase Keen more

This patch makes the Skypest chase Keen horizontally, while also making it slightly less likely to land. The blue value controls how 'closely' the Skypest's horizontal direction tracks Keen, a value of $10 should be the maximum needed, higher values tend to make its flying slower and more jerky. This patch makes use of the Inchorm's moving code, needing it to function.

Skypest chase Keen - a little

#Skypest chase Keen - a little
%patch $1068C $3D [$0010W]  $7D $06 $E9 $08E3W


Skypest slides along ground instead of landing

This patches changes the Skypest's tile collision so that instead of landing on the ground it slides along it as if it were ice (It will eventually launch off the ground again.) Do note that this is tile related and not a traditional behavior.

Skypest don't land but slide along ground

#Skypest don't land but slide along ground
%patch $10797 $2E


Skypest bounce off ground instead of landing

This patches changes the Skypest's tile collision so that instead of landing on the ground it bounces off of it as if it were a wall or ceiling. There are two highlighted values; the first is the upwards bounce speed and the second the upwards direction (-1 vertically. Changing the bounce speed (it must always be negative.) will make the Skypest react to the ground ore or less energetically. Do note that this is tile related and not a traditional behavior.

Skypest bounce off ground instead of landing

#Skypest bounce off ground instead of landing
%patch $107B4 $C7 $44 $18 [$FFF8W] $C7 $44 $10 [$FFFFW] $EB $07


Sprite Collision

While the Skypest is invulnerable in the air (Though Keen's shots will make it reverse direction.) it can be killed when it has landed if Keen squishes it by pogoing on top of it or jumping on it.


Collision values

Keen 4 collision values

#Flying
%patch $3130A $0FA80C57RL #Flying Skypest
%patch $31328 $0FA80C57RL #Flying Skypest

#Squished
%patch $31346 $00000000L #No collision

#Preening
%patch $31364 $0FA80CB0RL #Grounded Skypest
%patch $31382 $0FA80CB0RL #Grounded Skypest
%patch $313A0 $0FA80CB0RL #Grounded Skypest
%patch $313BE $0FA80CB0RL #Grounded Skypest
%patch $313DC $0FA80CB0RL #Grounded Skypest
%patch $313FA $0FA80CB0RL #Grounded Skypest
%patch $31418 $0FA80CB0RL #Grounded Skypest
%patch $31436 $0FA80CB0RL #Grounded Skypest
%patch $31454 $0FA80CB0RL #Grounded Skypest
%patch $31472 $0FA80CB0RL #Grounded Skypest
%patch $31490 $0FA80CB0RL #Grounded Skypest
%patch $314AE $0FA80CB0RL #Grounded Skypest
%patch $314CC $0FA80CB0RL #Grounded Skypest
%patch $314EA $0FA80CB0RL #Grounded Skypest
%patch $31508 $0FA80CB0RL #Grounded Skypest
%patch $31526 $0FA80CB0RL #Grounded Skypest
%patch $31544 $0FA80CB0RL #Grounded Skypest


Collision codes

Flying Skypest

This is the flying Skypest's collision code. On the first line it checks for Keen, and if it finds him, kills him. On the second line it checks for keen's shot, if found what it does next is controlled by what direction it is moving in. (In essence it reverses flying direction when shot.)

As an example, at the end of line 3 the Skypest checks its horizontal direction, if it is not right ($01) then it will change its speed to rightwards, value $0014W. On line 4 it checks its horizontal speed again, and if it is not left, changes it to left, value -$0014W ($FFECW). It may help to check out Galaxy Sprite Parameters to make more sense of this.

Keen 4

#Flying Skypest collision code
%patch $106D7 $55 $8B $EC $56 $57 $8B $7E $06 $8B $76 $08 $83 $3C [$02] {$75} $05
              $9A $0B8013E9RL     $83 $3C [$03] {$75} $3B $83 $7C {$0E} [$01] {$75} $07
              $C7 $45 {$16} [$0014W]  $EB $25 $83 $7C {$0E} [$FF] {$75} $07 $C7 $45 {$16}
              [$FFECW]  $EB $18 $83 $7C {$10} [$01] {$75} $07 $C7 $45 {$18} [$0014W]  $EB
              $0B $83 $7C {$10} [$FF] {$75} $05 $C7 $45 {$18} [$FFECW]  $56 $9A $0D8F0D43RL
                      $83 $C4 $02 $5F $5E $5D $CB


Landed Skypest

This is the complete collision code for the landed Skypest. Unlike all other sprites it reacts to the player's current action rather than a colliding sprite type. Three actions are checked for and any of them will execute the colision code, hcanging the Skypest's action and playing the squished sound.

The first two jumps skip further checks, the third skips the collision code (See Patch:Jump conditions.) The first three blue values are the triggering actions, the next is the squished Skypest action and the fifth is the squish sound value.

Keen 4

#Landed Skypest collision code
%patch $10730 $55 $8B $EC $56 $57 $8B $7E $06 $8B $76 $08 $81 $7C $1C [$110CW]
              {$74 $0E} $81 $7C $1C [$112AW]  {$74 $07} $81 $7C $1C [$1148W]  {$75 $1D}
              $B8 [$24C2W]  $50 $57 $9A $09DC120ARL     $83 $C4 $04 $B8 [$0016W]
              $50 $9A $187409F1RL     $83 $C4 $02 $C7 $05 [$0001W]  $5F $5E $5D
              $CB


Skypest stunnable

This patch allows the player to shoot the skypest when it is in the air. (It can still be squished when on the ground. Note that it uses the skip GRAPH patch, so is incompatible with other patches that use it.

Skypest stunnable

#New collision for Skypest, stunnable
%patch $3D1D $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D {$02 $75} $09 #Check for Keen (Type 2)
             $9A $0B8013E9RL     $5F $5E $5D $CB $83 $3D {$03 $75} $1F $B8     #If Keen, kill him; check for shot (Type 3)
             [$24C2W]  $50 $57 $56 $9A $09DC1695RL     $83 $C4 $06 $C7 $44 $18     #If shot, become $24C2W
             [$FFE8W]  $8B $44 $0E $D1 $E0 $D1 $E0 $D1 $E0 $89 $44 $16 $5F $5E $5D #Jump into the air $FFE8
             $CB

#Skypests use new collision
%patch $3130A $037D054DRL #Flying Skypest
%patch $31328 $037D054DRL #Flying Skypest

#Stunned Skypests act properly
%patch $31332 $01C8W $01C8W $0002W $0000W $0000W $0000W $0000W $0000W
              $09DC16C9RL   $00000000L    $09DC1913RL   $0000W


Skypest harmless to Keen

This short patch removes Keen's interaction in the flying Skypest so that it cannot harm him. Shooting it however will still have the same effect. This patch is incompatible with other patches that alter the flying Skypest collision.

Keen 4

#Skypest harmless to Keen
%patch $106E5 $EB


Speed

The Skypest moves relatively slowly, what matters most when it is flying is its direction. The Skypest will change direction when it hits solid tiles and will move down when hitting ceilings. It will also move up when flying off the ground, so it doesn't land too soon.

The Skypest owes none of its speed to its animation motion. The section of direction patches are included here for completeness, but there is little that can be done with them on their own.

Skypest speeds

#Flying speeds
%patch $106B5 [$0014W] #Speed l/r
%patch $106C5 [$0014W] #Speed u/d

#When hitting floors\ceilings
%patch $10780 [$FFF0W] #Speed up of Pest when it flies off ground
%patch $1079B [$0008W] #Speed down of Pest when hits ceiling

Skypest animation motion

#Flying
%patch $31302 $0000W $0000W #Speed 1
%patch $31320 $0000W $0000W #Speed 2

#Squished
%patch $3133E $0000W $0000W #Speed 

#Preening
%patch $3135C $0000W $0000W #Speed 1
%patch $3137A $0000W $0000W #Speed 2
%patch $31398 $0000W $0000W #Speed 3
%patch $313B6 $0000W $0000W #Speed 4
%patch $313D4 $0000W $0000W #Speed 5
%patch $313E2 $0000W $0000W #Speed 6
%patch $31410 $0000W $0000W #Speed 7
%patch $3142E $0000W $0000W #Speed 8
%patch $3144C $0000W $0000W #Speed 9
%patch $3146A $0000W $0000W #Speed 10
%patch $31488 $0000W $0000W #Speed 11
%patch $314A6 $0000W $0000W #Speed 12
%patch $314C4 $0000W $0000W #Speed 13
%patch $314E2 $0000W $0000W #Speed 14
%patch $31500 $0000W $0000W #Speed 15
%patch $3151E $0000W $0000W #Speed 16
%patch $3153C $0000W $0000W #Speed 1

Skypest directions

#When hitting ceilings
%patch $107A0 [$0001W] #Move vertically down

#When hitting right walls
%patch $107CF [$0000W] #Stop moving vertically
%patch $107D4 [$FFFFW] #Move horizontally left

#When hitting left walls
%patch $107DF [$0000W] #Stop moving vertically
%patch $107E4 [$0001W] #Move horizontally right

#Randomly change direction to down\right when flying
%patch $10695 [$0001W]


Animations

The Skypest's animations are quite simple; the Skypest uses the same sprite for facing left and facing right. Two animations are used for flying, one for the squashed Skypest and the remainder for the preening actions. Notice that many animations are used more than once in the preening sequence.

Keen 4

#Sprite cache
%patch $306FE [$01BBW] #Skypest Cache start
%patch $30748 [$01C8W] #Skypest cache end

#Skypest flying
%patch $312F6 $01BBW $01BDW
%patch $31300 $0005W        #Animation speed
%patch $31314 $01BCW $01BEW
%patch $3131E $0005W        #Animation speed

#Skypest squished
%patch $31332 $01C8W $01C8W
%patch $3133C $0000W        #Animation speed

#Skypest preening
%patch $31350 $01C7W $01C7W
%patch $3135A $0064W        #Pause before eye-lick
%patch $3136E $01BFW $01BFW
%patch $31378 $000AW        #Animation speed
%patch $3138C $01C0W $01C0W
%patch $31396 $000AW        #Animation speed
%patch $313AA $01C1W $01C1W
%patch $313B4 $000AW        #Animation speed
%patch $313C8 $01C2W $01C2W
%patch $313D2 $000AW        #Animation speed
%patch $313E6 $01C1W $01C1W
%patch $313F0 $000AW        #Animation speed
%patch $31404 $01C0W $01C0W
%patch $3140E $000AW        #Animation speed
%patch $31422 $01BFW $01BFW
%patch $3142C $000AW        #Animation speed
%patch $31440 $01C7W $01C7W
%patch $3144A $003CW        #Pause after first eye-lick
%patch $3145E $01C3W $01C3W
%patch $31468 $000AW        #Animation speed
%patch $3147C $01C4W $01C4W
%patch $31486 $000AW        #Animation speed
%patch $3149A $01C5W $01C5W
%patch $314A4 $000AW        #Animation speed
%patch $314B8 $01C6W $01C6W
%patch $314C2 $000AW        #Animation speed
%patch $314D6 $01C5W $01C5W
%patch $314E0 $000AW        #Animation speed
%patch $314F4 $01C4W $01C4W
%patch $314FE $000AW        #Animation speed
%patch $31512 $01C3W $01C3W
%patch $3151C $000AW        #Animation speed
%patch $31530 $01C7W $01C7W
%patch $3153A $0064W        #Pause before lifting off


Sounds

The Skypest makes a noise when it is squished. This sound can be blocked.

Keen 4

#Skypest squished sound
%patch $1075E $16

#Don't play Skypest squished sound
%patch $1075D $EB $0A


Sprite positioning

The Skypest's spawn position differs from the usual format. It is placed horizontally and vertically in pixels.

Keen 4

#Spawn positioning
%patch $10613 $08 #Horizontal
%patch $1060B $08 #Vertical


Sprite-tile interaction

The Skypest has two tile collisions, only one of which is unique to it. This is the one used by the flying Skypest, which allows it to bump off walls and ceilings and to land. The squished and landed Skypest uses the 'sit' tile collision used by many other sprites.

Note that patches that stop the Skypest from landing (Which are modifcations of the tile interaction) are covered under the behavior section.


Collision values

These are the values of the collisions used by each frame of the Skypest.

Keen 4

#Flying
%patch $3130E $0FA80D0BRL #Flying
%patch $3132C $0FA80D0BRL #Flying

#Squished
%patch $3134A $09DC176ERL #Squished

#Landed
%patch $31368 $09DC176ERL #Preening
%patch $31386 $09DC176ERL #Preening
%patch $313A4 $09DC176ERL #Preening
%patch $313C2 $09DC176ERL #Preening
%patch $313E0 $09DC176ERL #Preening
%patch $313FE $09DC176ERL #Preening
%patch $3141C $09DC176ERL #Preening
%patch $3143A $09DC176ERL #Preening
%patch $31458 $09DC176ERL #Preening
%patch $31476 $09DC176ERL #Preening
%patch $31494 $09DC176ERL #Preening
%patch $314B2 $09DC176ERL #Preening
%patch $314D0 $09DC176ERL #Preening
%patch $314EE $09DC176ERL #Preening
%patch $3150C $09DC176ERL #Preening
%patch $3152A $09DC176ERL #Preening
%patch $31548 $09DC176ERL #Preening


Collision code

This is the complete collision code for the collision unique to the Skypest, that is, the one used when it flies. it helps to know Patch:Jump conditions and Patch:Galaxy Sprite Parameters before looking at this patch.

In the first line the Skypest checks if it is touching a ceiling (Flat bottom of a tile, marked in brown.) If it is, its vertical speed is set to $8 (Downwards) and its vertical direction to 1. (Both of these marked in blue.)

In the second line it checks if it is sitting on a tile that can be stood on and if so then checks to make sure the tile is not part of a wall. (It does this by checking to see if the left and right sides are not blocking, these three checks are marked in brown.) This meas it only lands on flat floor, not inside walls. It lands by moving down 1/2 a tile ($0080W, marked in blue.) and changing its action to $24E0W (Also marked in blue.)

If it is touching neither floor nor ceiling the Skypest checks on line 4 to see if it is touching a right wall. If so its vertical direction is set to 0 and its horizontal direction to -1 (Left.)

On line 5 the Skypest checks for left walls, the code is similar, except its horizontal direction is set to 1 (right.)

On lines 6-8 the Skypest sprite is drawn, this is best not altered. Note that this patch contains speed and direction patches and is thus incompatible with those patches. Hopefully it is easy to see where those patches fit into this, larger, patch.

Keen 4

#Skypest flying tile collision
%patch $1078B $55 $8B $EC $56 $8B $76 $06 $83 {$7C $3A $00 $74} $0A $C7 $44 $18 [$0008W] #Move down off ceilings
                  $C7 $44 $10 [$0001W]  $83 {$7C $36 $00 $74} $1E $83 {$7C $38 $00 $75}    #Land...
              $18 $83 {$7C $3C $00 $75} $12 $81 $44 $0C $0080W  $B8 $24E0W  $50 $56    #But only on flat ground
              $9A $09DC120ARL     $83 $C4 $04 $83 {$7C $3C $00 $74} $0A $C7 $44 $16    #Hit right wall
              [$0000W]  $C7 $44 $0E [$FFFFW]  $83 {$7C $38 $00 $74} $0A $C7 $44 $16 [$0000W] #Hit left wall
                  $C7 $44 $0E [$0001W]  $FF $74 $20 $33 $C0 $50 $FF $74 $1E $FF $74    #Draw sprite
              $0C $FF $74 $0A $8B $C6 $05 $46 $00 $50 $9A $16541641RL     $83 $C4
              $0C $5E $5D $CB


Action type

The Skypest's flying action are type 3 to allow smooth movement. It's squished action is type 2, though this doesn't really matter, and its preening actions are type 0, since it doesn't move at all.

Keen 4

#Flying
%patch $312FA [$0003W] #Skypest flying 1
%patch $31318 [$0003W] #Skypest flying 2

#Squished
%patch $31336 [$0002W] #Skypest squished [Stun move]

#Landed
%patch $31354 [$0000W] #Skypest preening 1
%patch $31372 [$0000W] #Skypest preening 2
%patch $31390 [$0000W] #Skypest preening 3
%patch $313AE [$0000W] #Skypest preening 4
%patch $313CC [$0000W] #Skypest preening 5
%patch $313EA [$0000W] #Skypest preening 6
%patch $31408 [$0000W] #Skypest preening 7
%patch $31426 [$0000W] #Skypest preening 8
%patch $31444 [$0000W] #Skypest preening 9
%patch $31362 [$0000W] #Skypest preening 10
%patch $31380 [$0000W] #Skypest preening 11
%patch $3139E [$0000W] #Skypest preening 12
%patch $313BC [$0000W] #Skypest preening 13
%patch $314DA [$0000W] #Skypest preening 14
%patch $314F8 [$0000W] #Skypest preening 15
%patch $31516 [$0000W] #Skypest preening 16
%patch $31534 [$0000W] #Skypest preening 17


Deprotect and stick to ground

The Skypest has no need for the stick to ground variable, even when landed. It's flying frames however use the deprotect animation variable, a rather rare occurrence in Keen.

Keen 4

#Flying
%patch $312FC [$0001W $0000W] #Flying 1
%patch $3131A [$0001W $0000W] #Flying 2

#Squished
%patch $31338 [$0000W $0000W] #Squished

#Landed
%patch $31356 [$0000W $0000W] #Preening 1
%patch $31374 [$0000W $0000W] #Preening 2
%patch $31392 [$0000W $0000W] #Preening 3
%patch $313B0 [$0000W $0000W] #Preening 4
%patch $313CE [$0000W $0000W] #Preening 5
%patch $313EC [$0000W $0000W] #Preening 6
%patch $3140A [$0000W $0000W] #Preening 7
%patch $31428 [$0000W $0000W] #Preening 8
%patch $31446 [$0000W $0000W] #Preening 9
%patch $31464 [$0000W $0000W] #Preening 10
%patch $31482 [$0000W $0000W] #Preening 11
%patch $314A0 [$0000W $0000W] #Preening 12
%patch $314BE [$0000W $0000W] #Preening 13
%patch $314DC [$0000W $0000W] #Preening 14
%patch $314FA [$0000W $0000W] #Preening 15
%patch $31518 [$0000W $0000W] #Preening 16
%patch $31536 [$0000W $0000W] #Preening 17


Probability and randomness

The Skypest can be spawned moving in one of four directions, a combination of up\down and left\right. Both of these are choesen randomly and independently when the sprite is spawned. Both of these have a 50/50 chance of being chosen.

Keen 4

#Skypest initial directions
%patch $1061F $80 #r/l
%patch $1063D $80 #u/d

Sprite spawn code

There are three difficulties of Skypest, one each for easy, medium and hard difficulty. In the initiation code notice the Skypest cache being set at $C7 $06 $CB69W $0001W

In the spawn section the very last variable set in Galaxy is the sprite action the Skypest uses when it spawns. $C7 $02 $xxxxW sets the sprite activity, $C7 $07 $xxxxW sets the sprite type, and $C7 $20 $xxxxW sets the foreground value.

$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.) $C7 $47 $10 $xxxxW is the vertical direction and works similarly. The Skypest has two probability checks; one horizontal, one vertical, to determine which way it starts off flying. This is 50:50 (Though it needn't be.); the code responsible for this is $9A $1D02002ARL $3D $0080W This means the Skypest will randomly start in one of four diagonal directions when spawned.

Keen 4

#Location of initiation code
%patch $EE93 [$0174W] #Easy Skypest (At $EA64)
%patch $EEDD [$016AW] #Medium Skypest (At $EA5A)
%patch $EEDF [$0160W] #Hard Skypest (At $EA50)

#Skypest Initiation code
%patch $EA50 $83 $3E [$7A6CW]  {$03 $7D} $03 $E9 $03A3W  $83 $3E [$7A6CW]  {$02 $7D}
             $03 $E9 $0399W  $FF $76 $FC $57 $9A {$0FA80B67RL}     $83 $C4 $04
             $C7 $06 $CB69W  $0001W  $E9 $0384W

#Skypest spawning code
%patch $105E7 $55 $8B $EC $33 $C0 $50 $9A $06BD1E11RL     $83 $C4 $02 $8B $1E
              $D8 $A7 $C7 $07 [$000BW]  $C7 $47 $02 [$0001W]  $C7 $47 $20 [$0000W]
              $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $89
              $47 $0C $9A $1D02002ARL     $3D [$0080W]  {$7D} $0B $8B $1E $D8 $A7
              $C7 $47 $0E [$0001W]  $EB $09 $8B $1E $D8 $A7 $C7 $47 $0E [$FFFFW]
              $9A $1D02002ARL     $3D [$0080W]  {$7D} $0B $8B $1E $D8 $A7 $C7 $47
              $10 [$0001W]  $EB $09 $8B $1E $D8 $A7 $C7 $47 $10 [$FFFFW]  $B8 [$2486W]
                  $50 $FF $36 $D8 $A7 $9A $09DC118CRL     $83 $C4 $04 $5D $CB