Patch:Yorp

From KeenWiki
Jump to: navigation, search

Yorps are harmless one-eyed enemies found in Keen 1. This page lists patches relating to Yorp 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.


Sprite Type

Yorps use sprite type 2 which means they push Keen about but don't hurt him, and if Keen lands on top of them, a stunned Yorp sprite is produced. Using any other sprite type means a Yorp cannot be stunned. There are some subtleties in the stunned behavior revealed in the behaviors section.

Patch: Keen 1
#Yorp sprite type:
%patch $188B $02


What stunned Yorp does to Keen

The following patches alter how the Yorp stun\push affects Keen. It is possible using these patches to make Keen jump when a Yorp hits him (or he stuns a Yorp), using them like trampolines. If the Yorp's behavior isn't set to stunned (See below) but say, search, then Keen can bounce on the still Yorp over and over.

Patch: Keen 1
#Keen can stomp Yorp if...
%patch $4601 $0A $7C
#Less than 10 pixels above it and
%patch $4608 $08 $76
#Less than 8 pixels either side of it (Else get pushed)
#How far right of Yorp left side Keen must be to be pushed right:
%patch $4612 $0020W $7E
#20 pixels or more
#When Keen is bumped by a Yorp he:
%patch $460E $0000W
#Jumps this high (Not at all)
%patch $4619 $00F0W
#Is pushed right this much or
%patch $4620 $FF10W
#Left this much
#When Keen stuns a Yorp he:
%patch $4634 $0000W
#Jumps this high (Not at all)


Unstompable Yorps

This patch makes Yorps unstompable, without needing to change its type. Something almost identical can be done by changing the sprite type to type 4 (Butler Robot) but this patch allows sprite type 2 to be used in sprite collisions.

Patch: Keen 1
#Can't stomp Yorps
%patch $18A5 $90


Deadly stompable Yorps

This patch makes Yorps deadly to Keen, but they're still stompable, that is, Keen can jump on them and stun them safely.

Patch: Keen 1
#Yorp kills Keen but can be stomped
%patch $460B $EB $68


Sprite Behavior

There are two behaviors associated with the Yorp, the walking\jumping behavior (Walk back and forth, randomly jump a random height.) and the searching behavior (Look for Keen then turn towards him) The stunned Yorp behavior is more associated with sprite type 2 (See above) but is pretty much a Yorp behavior by default. See also the collision section which has a similar patch.

The stunned behavior is interesting. When a Yorp is stomped it will go to the stunned behavior. This behavior is still a Yorp, but it is not stompable (Anything with that behavior will NOT be stomped, check its jump condition.) If a stunned Yorp goes offscreen then it will become a walking Yorp. It is possible to change these behaviors so that any sort of sprite becomes another type when Keen is not looking. It is even possible to make Yorps push Keen, but not stun.

Behaviors:
$194FW Walk\jump
$19D3W Look for Keen
$1A2CW Stunned
$1A68W Yorp collision

Patch: When spawned
%patch $18B4 $194FW

Patch: In level
%patch $1A22 $194FW 
#After looking for Keen
%patch $1980 $19D3W
#Do this randomly when walking
%patch $1A58 $19D3W
#After being stunned
%patch $45E5 $1A2CW
#This behavior of type-2 sprite not stompable
$75
%patch $462A $1A2CW
#What Yorp becomes when stunned
%patch $4D9C $1A2CW
#If offscreen and using this behavior then...
%patch $4DA4 $19D3W
#...become this
%patch $18D9 $1A68W
#Yorp collision


Yorp never searches for Keen

This patch stops the Yorp from searching for Keen, it just moves back and forth predictably. The one side effect of this patch is that when the Yorp is stomped it will become stuck, not being able to move left or right. This is because the searching code resets the Yorp's speed. To stop this, the second line can be removed, allowing the Yorp to search after being stunned.

Patch: Yorp never looks for Keen
#Yorp never looks for Keen
%patch $197A $EB
#Don't search randomly when walking
%patch $1A58 $194FW
#After being stunned
%patch $4D9E $EB
#Don't search if going offscreen


Yorp walking code

This is the complete code for the Yorp walking back and forth. This patch contains many other patches on this page, and is thus incompatible with them.

In the first line of the patch the game checks to see if the Yorp has no vertical speed (Is not jumping or falling.) If it does, the search and jump code is skipped.) Next a random check is performed. On the second line if this value is less than $5B the Yorp will not jump. (The blue and yellow values, see Patch:Jump conditions. Making the blue value larger will increase jump frequency.) Jumping involves setting the Yorp's vertical speed to $0080W.

On the third line, if jumping the Yorp will skip the search for Keen code, to stop it doing so in midair. This code starts with another random check. On the fourth line, if searching is going to occur the sprite behavior is changed to 'search' ($19D3W) and the horizontal speed is set to 0 (No moving while searching.)

At the end of the forth line the game check the Yorp's direction, if it is less than 0, (That is -1 or left) then the Yorp will use sprite $0034W, otherwise (If it is 0 or +1, that is right.) it will use sprite $0036W. These are both on line 5.

On line 6 the animation speed and number of frames for walking both left and right are set. They are 04 and 0001W respectively. On line 7 $E8 $1276W $E8 $12B6W are two calls to gravity and 'stand on tiles' respectively. Replacing the first $E8 call with $90 $90 $90 will stop the walking Yorp from falling, it will gradually float upwards. Replacing the second will cause it to simply fall through all tiles like a ghost. Replacing both will create a floating ghost.

The 8th line has a tile check; $0004W $74 checks to see if the Yorp is touching a right wall, and if so the speed is changed to $FFC4 on line 9 (Which is moving left.) This is followed by a check to see if the Yorp is touching a left wall ($0001W $74) and if so changes the speed to $003C, or right.

Patch: Yorp walking code
#Complete Yorp walking code
%patch $194F $55 $8B $EC $56 $83 $3E $42 $82 $00 $75 $2E $E8 $A771W $3B $06 $14 $5B $73 $10 $B8 $0080W $50 $E8 $A6F2W $44 $44 $F7 $D8 $A3
#Jump
$42 $82 $EB $15 $E8 $A758W $3B $06 $14 $5B $73 $0C $C7 $06 $52 $82 $19D3W $C7 $06 $4A $82 $0000W $83 $3E $40 $82 $00 $7E $08 $C7 $06 $48 $82 $0034W $EB $06 $C7 $06 $48 $82 $0036W $A1 $35 $51 $B1 $04 $D3 $E8 $25 $0001W $8B $16 $48 $82 $03 $D0 $89 $16 $48 $82 $E8 $1276W $E8 $12B6W $8B $F0 $A9 $0004W $74 $06 $C7 $06 $40 $82 $FFC4W $F7 $C6 $0001W $74 $06 $C7 $06 $40 $82 $003CW $5E $5D $C3


Yorp walking code without jumping

This is the Yorp's walking code, without the random jumping. The offending code is not just skipped, but removed completely.

Patch: Yorp walking code without jumping
#Yorp walking code without jumping
%patch $194F $55 $8B $EC $56 $83 $3E $42 $82 $00 $75 $15 $E8 $A771W $3B $06 $14 $5B $73 $0C $C7 $06 $52 $82 $19D3W $C7 $06 $4A $82 $0000W $83 $3E $40 $82 $00 $7E $08 $C7 $06 $48 $82 $0034W $EB $06 $C7 $06 $48 $82 $0036W $A1 $35 $51 $B1 $04 $D3 $E8 $25 $0001W $8B $16 $48 $82 $03 $D0 $89 $16 $48 $82 $E8 $128FW $E8 $12CFW $8B $F0 $A9 $0004W $74 $06 $C7 $06 $40 $82 $FFC4W $F7 $C6 $0001W $74 $06 $C7 $06 $40 $82 $003CW $5E $5D $C3


Yorp searching code

This is the complete code for the Yorp's looking for Keen. It is somewhat simpler than the walking\jumping code.

The first line sets the speed to zero, it also sets the animation speed to $05. On the second line the number of searching frames is set (3 + 1 = 4) and the first searching frame, $0030W.

The third lines contains the searching time ($00C8W = 200 or time for 40 animations or 10 animation cycles.) If this is exceeded then the rest of the code will be run.

The code on lines 4\5 checks for Keen, then makes the Yorp move in his direction left or right ($003C\$FFC4)) and changes the Yorp's behavior to 'walk' ($194FW).

Finally the sixth line has to $E8 calls to the gravity and tile collision code. Replacing the first $E8 call with $90 $90 $90 will stop the searching Yorp from falling, it will gradually float upwards. Replacing the second will cause it to simply fall through all tiles like a ghost. Replacing both will create a floating ghost.

Patch: Yorp searching code
#Complete Yorp searching code
%patch $19D3 $55 $8B $EC $C7 $06 $40 $82 $0000W $A1 $35 $51 $B1 $05 $D3 $E8 $25 $0003W $05 $0030W $A3 $48 $82 $A1 $4A $82 $03 $06 $14 $5B $A3 $4A $82 $3D $00C8W $7C $29 $A1 $26 $82 $8B $16 $24 $82 $3B $06 $E0 $6E $7F $10 $7C $06 $3B $16 $DE $6E $73 $08 $C7 $06 $40 $82 $003CW $EB $06 $C7 $06 $40 $82 $FFC4W $C7 $06 $52 $82 $194FW $E8 $1203W $E8 $1243W $5D $C3


Search time

This is how long the Yorps spend looking for Keen before moving in his direction. If made very small it will seem as if Yorps simply randomly turn towards Keen while walking.

Patch: Keen 1
#Yorp searching-for-Keen time
%patch $19F7 $00C8W


Speed and Jump Height

The default speed of Yorps is +-60. When spawned Yorps will head toward Keen by default. They will also head towards Keen after searching for him and will stand still when stomped or looking for Keen.

Patch: Starting speeds
%patch $18CD $003CW 
#If left of Keen (Move right)
%patch $18D4 $FFC4W
#If right of Keen (Move left)

Patch: In level
%patch $1A1C $FFC4W 
#If right of Keen after searching (Move left)
%patch $1A14 $003CW
#If left of Keen after searching (Move right)
%patch $19CE $003CW
#If hits left wall (Move right)
%patch $19C2 $FFC4W
#If hits right wall (Move left)
%patch $19DA $0000W
#When looking for Keen (Stand still)
%patch $1A5E $0000W
#When stomped (Stand still)
%patch $1964 $0080W
#Jump height
%patch $1A99 $FFB0
#Jump height when shot


Yorp never jumps

This patch stops the Yorp jumping entirely (Instead of setting the jump height very small.)

Patch: Yorp doesn't jump
#Yorp doesn't jump
%patch $1961 $EB


Sprite Collision

Yorps interact with both Keen's and the Tank's shots. This produces a shot Yorp. (See behavior section.) The shot Yorp 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'


Basic collision patches

This set of simple patches allows a modder to alter the basic aspects of a Yorp's collision.

Patch: Keen 1
%patch $18D9 $1A68W  
#Yorp collision
%patch $1A74 $3D $0A
#Yorp killed by Keen's shot
%patch $1A79 $3D $0B
#Yorp killed by robot's shot
%patch $1A8F $489DW
#Dead Yorp behavior
%patch $1A94 $3360W
#Dead Yorp collision
%patch $1A99 $FFB0
#Jump height when shot


Complete collision patch

This is the complete collision patch. Contained in it is all of the Yorp's collision code. The first two blue values are the sprite types the Yorp responds to, each followed by a jump condition in brown. The next blue value stops the sprite animating, the fourth is the number of frames to use in the stunned animation and the fifth is the sprite animation to use. The sixth and seventh are the shot Yorp's behavior and sprite collision. The eighth is the shot Yorp's jump height and the ninth and last is the sound played when the Yorp is shot. The last brown value calls the sound playing code. (See sounds section below.)

To customize the collision it may pay to see Patch:Vorticons Sprite Parameters and maybe Patch:Shot sprites.

Patch: Yorp collision
#Yorp collision (64 bytes long)
%patch $1A68 $55 $8B $EC $56 $57 $8B $76 $04 $8B $7E $06 $83 $3D $0A $74 $05 $83 $3D $0B $75 $27 $C7 $44 $2A $0000W $C7 $44 $2C $0002W $C7 $44 $28 $003AW $C7 $44 $32 $489DW $C7 $44 $34 $3360W $C7 $44 $22 $FFB0W $B8 $0022W $50 $E8 $A451W $44 $44 $5F $5E $5D $C3


Yorp 'shockable'

This patch makes the Yorp death more complex. The Yorp is indestructible, but it still shows the shot animation every time it is shot (It is shot without dying so to speak.) The second line resets the collision behavior (See first section.) If the second line is changed to another collision aside from the Yorp one, the second time the Yorp is shot it will use that collision. (For example, changing it to the Garg collision means the Yorp will have two health, the first showing a shocked Yorp, the second spawning a dead Garg.)

Patch: Keen 1
#Yorp is invincible, but shows 'shocked' animation each time its shot
%patch $1A8C $90 $90 $90 $90 $90 %patch $1A94 $1A68W


Animations

Patch: When spawned
%patch $18DE $0030W 
#Start

Patch: In level
%patch $19E7 $0030W 
#Looking for Keen
%patch $19E4 $03
#And next 3 frames
%patch $19E0 $05
#Animation speed
%patch $1993 $0034W
#Walking right
%patch $199B $0036W
#Walking left
%patch $19A5 $01
#And next frame
%patch $19A1 $04
#Animation speed
%patch $1A3A $0038W
#Stunned
%patch $1A37 $01
#And next frame
%patch $1A33 $04
#Animation speed
%patch $1A8A $003AW
#Shot
%patch $1A85 $02
#Frames used


Yorp spawn height

The Yorp spawns 8 pixels lower than where it is placed, because it is not quite two tiles tall. If the Yorp's sprite height is changed this should also be changed by the same amount.

Patch: Keen 1
#Yorp's spawn height
%patch $18A6 $0800W
#Eight pixels down


Sounds

These are the sounds the sprite uses. The first sound is played when the Yorp is shot and killed, the second when it is stomped and stunned. Both sounds can be blocked.

Patch: Keen 1
#Sounds:
%patch $1A9C $22
#Yorp death
%patch $463C $1F
#Yorp stunned
#Don't make sounds:
%patch $1A9B $EB $07
#Yorp death
%patch $463B $EB $07
#Yorp stunned