Patch:Youth (Keen 2)

From KeenWiki
Jump to: navigation, search

Youths are harmless but annoying enemies found in Keen 2 as well as Keen 3. This page lists patches relating to Keen 2 Youth sprites. It is divided into sections relating to the various sprite properties the patches involve. Being fluent with various sprite patch pages will help when working with these patches.

For patches relating to Youths in Keen 3 see Patch:Youth (Keen 3). For patches relating to the stunning effect the youths have, including patches to stop them stunning under certain conditions, see Patch:Keen stunned as well as Patch:G O D Cheat.


Sprite Type

Youths use sprite type 3 which means they stun Keen on contact but are harmless to everything else.

Patch: Keen 2
#Youth sprite type:
%patch $3C57 $03


Sprite Behavior

The Youth has only two behaviors, walking\jumping, and falling\sliding. The Youth will jump randomly when walking. After jumping the Youth will fall and slide along the ground before returning to walking.

Behaviors:
$3FCCW #Walk, jump randomly, turn when hitting walls
$404CW #Youth fall or slide along ground
$4093W #Youth collision

Patch: When spawned
%patch $3C7A $3FCCW

Patch: In level
%patch $401C $404CW 
#Fall\slide after hitting walls
%patch $402F $404CW
#Fall\slide after randomly jumping
%patch $4076 $3FCCW
#Walk after fall\slide
%patch $3C7F $4093W
#Youth collision


Falling behavior

This is the complete code for the Youth's falling behavior. On the first line the Youth's direction is checked; this affects the animation used, $0037W or $0033W. After this two calls are made to gravity and tile collision. Replacing $E8 $1A04W with $90 $90 $90 causes the Youth to not fall but simply move back and forth in the air. Replacing $E8 $1A44W with $90 $90 $90 causes the Youth to 'ghost' through tiles, eventually falling out of the level.

Following are tile checks; first the Youth checks for floors at the beginning of line 3. If detected the Youth's behavior is set to 'run\jump'. At the end of the line right walls are checked for, if detected speed is set to $FF06W (Left.) The same thing is done with left walls.

Patch: Youth fall behavior
#Youth fall behavior
%patch $404C $55 $8B $EC $56 $83 $3E $96E0W $00 $7E $08 $C7 $06 $96E8W $0037W $EB $06 $C7 $06 $96E8W $0033W $E8 $1A04W $E8 $1A44W $8B $F0 $A9 $02 $00 $74 $06 $C7 $06 $96F2W $3FCCW $F7 $C6 $04 $00 $74 $06 $C7 $06 $96E0W $FF06W $F7 $C6 $01 $00 $74 $06 $C7 $06 $96E0W $00FAW $5E $5D $C3


Run\jump behavior

This is the complete code for the Youth run\jump behavior. On the first line the Youth's direction is checked; this affects the animation used, $0034W or $0030W. These have 3 other frames animating at a speed of 4 ticks. Next is the randomized jumping; a probability of $0003W is used and tested. Jumps are a maximum of $0190W high and the Youth's behavior is set to 'fall' ($404CW).

After this two calls are made to gravity and tile collision at the start of line six. Replacing $E8 $1A4BW with $90 $90 $90 causes the Youth to not fall but simply move back and forth in the air. Replacing $E8 $1A8BW with $90 $90 $90 causes the Youth to 'ghost' through tiles, eventually falling out of the level.

Next are tile checks. First the Youth checks for floors; if it doesn't find one then its behavior is set to 'fall'. This causes Youths to fall off the edges of platforms. The last two checks are for right and left walls respectively and change the Youth's speed to left and right respectively. ($FF06W and $00FAW.)

Patch: Youth run\jump behavior
#Youth run\jump behavior
%patch $3FCC $55 $8B $EC $56 $83 $3E $96E0W $00 $7E $08 $C7 $06 $96E8W $0034W $EB $06 $C7 $06 $96E8W $0030W $A1 $5111W $B1 $04 $D3 $E8 $25 $0003W $8B $16 $96E8W $03 $D0 $89 $16 $96E8W $E8 $77EAW $50 $A1 $5AF0W $BA $0003W $F7 $5AEAW $3B $D0 $73 $14 $B8 $0190W $50 $E8 $7763W $44 $44 $F7 $D8 $A3 $96E2W $C7 $06 $96F2W $404CW $E8 $1A4BW $E8 $1A8BW $8B $F0 $A9 $02 $00 $75 $06 $C7 $06 $96F2W $404CW $F7 $C6 $04 $00 $74 $06 $C7 $06 $96E0W $FF06W $F7 $C6 $01 $00 $74 $06 $C7 $06 $96E0W $00FAW $5E $5D $C3


Youths turn at platform edges

This patch causes Youths to turn at edges instead of jumping. (Jumping is possible but makes things more complicated.) The first line causes Youths to fall when they first spawn. This is required because Youths spawn in the air.

The second section replaces the jumping code with turning code. When the Youth is not touching a floor it is given a slight upward boost ($FFF2W to counteract gravity.), its timer is set to 0 (For timing its turning.) and its action to 'turn'. A check is then made of the Youth's speed and it is reversed. (If moving left, go right, if right, go left.) This is also part of the 'hit walls' code.

The third section is the turning code itself using unused space at $0AF2. This checks the Youth's speed and sets the turning animations. (Here the same as the falling animations.) There are three tile checks. The first checks for floors; if the Youth is back on a floor it returns to walking. The next two are walls; the Youth will bounce off of walls.

On line 5 a timer is checked; after 14 ticks of turning the Youth will go to falling. This happens if the Youth somehow finds itself in the air, such as if a bridge is removed from beneath it. The speeds of the Youth are $FF06W (Left.) and $00FAW (Right.) These are set in both the second and third sections.

Patch: Youths turn at platform edges
#Youths fall to ground when spawned
%patch $3C7A $404CW
#Youths turn at edges instead of jumping
%patch $4008 $E8 $1A61W $E8 $1AA1W $8B $F0 $A9 $02 $00 $75 $1B $C7 $06 $96E2W $FFF2W $C7 $06 $96EAW $0000W $C7 $06 $96F2W $0AF2W $83 $3E $96E0W $00 $7D $08 $EB $12 $F7 $C6 $04 $00 $74 $06 $C7 $06 $96E0W $FF06W $F7 $C6 $01 $00 $74 $06 $C7 $06 $96E0W $00FAW $5E $5D $C3
#Turning behavior, bounce off walls, walk on ground fall in air
%patch $0AF2 $55 $8B $EC $56 $83 $3E $96E0W $00 $7E $08 $C7 $06 $96E8W $0037W $EB $06 $C7 $06 $96E8W $0033W $E8 $4FA1W $8B $F0 $A9 $02 $00 $74 $06 $C7 $06 $96F2W $3FCCW $F7 $C6 $04 $00 $74 $06 $C7 $06 $96E0W $FF06W $F7 $C6 $01 $00 $74 $06 $C7 $06 $96E0W $00FAW $A1 $96EAW $03 $06 $5AF0W $A3 $96EAW $3D $0014W $7E $06 $C7 $06 $96F2W $404CW $5E $5D $C3


Speed and Jump Height

The default speed of Youths is +-250 when walking. They will head towards Keen when spawned by default.

Patch: Starting speeds
%patch $3CA4 $00FAW 
#If left of Keen (Move right)
%patch $3C9D $FF06W
#If right of Keen (Move left)

Patch: In level
#When walking\jumping
%patch $4047 $00FAW
#Hits left wall (Go right)
%patch $403B $FF06W
#Hits right wall (Go left)
%patch $400B $0190W
#Jump height
#When falling\sliding
%patch $408E $00FAW
#Hits left wall (Go right)
%patch $4082 $FF06W
#Hits right wall (Go left)


Jumping frequency

The probability of a Youth jumping is very roughly controlled; 0 is never, 3 the usual frequency, anything above 6 nearly constantly.

Patch: Keen 2
#Probability of Youth jumping
%patch $4001 $03


Youth never jumps

This patch prevents the Youth from jumping at all.

Patch: Keen 2
#Youth never jumps
%patch $4008 $EB


Sprite Collision

Youths interact with Keen's and Elite's shots. This produces a shot Youth. (See behavior section.) The shot Youth also resets its collision and behavior, the new collision, used for most dead sprites ignores all other sprites, the new behavior likewise is just 'fall an animate'

Patch: Youth Sprite Collision
%patch $3C7F $4093W   
#Youth collision
%patch $409F $3D $0A
#Youth killed by Keen's shot
%patch $40A4 $3D $0B
#Youth killed by Elite shot
%patch $40C8 $75FCW
#Dead Youth behavior
%patch $40C3 $61A2W
#Dead Youth collision


Animations

Patch: When spawned
%patch $3CA9 $0030W 
#Start

Patch: In level
%patch $3FDB $0034W 
#Walking right
%patch $3FE3 $0030W
#Walking left
%patch $3FED $03
#And next 3 frames
%patch $3FE9 $04
#Animation speed
%patch $405B $0037W
#Jumping right
%patch $4063 $0033W
#Jumping left
%patch $406E $02
#And next 2 frames
%patch $40BE $0038W
#When shot
%patch $40B9 $02
#Frames used


Sounds

Patch: Keen 2
#Sounds:
%patch $40A9 $27
#Youth death
#Don't make sounds:
%patch $40AC $90 $90 $90
#Youth death