Patch:Treasure Eater

From KeenWiki
(Redirected from Patch:Smirky)
Jump to: navigation, search

Treasure Eaters are red smiling enemies found in Keen 4. Also known as Smirky or Gnosticenes Ancients. While harmless to Keen they are known to steal items and keygems, eventually making the level they are in unwinnable unless killed.

The main feature of Treasure Eater is their ability to detect and steal items. Aside from this they also have the usual sprite properties and patches.


Sprite Type

Treasure Eaters are interesting in that they have several sprite types, not only their own,(Type 26, unique) but also one for when they are stunned (type 33, used also by stunned Mimrocks) And two properties for the goods they steal. (Type 1, the stolen goods are reduced to 'misc sprites')

Sprite types also relate to what the Treasure Eater searches for. (See sprite behavior section below.)

Patch: Keen 4
#Treasure Eater sprite types
%patch $11A42 $1A
#Treasure Eater
%patch $11CEA $21
#Shot Treasure Eater
%patch $11CAB $01
#Treasure Eater stolen items
%patch $11DA4 $01
#Treasure Eater stolen tiles


Sprite Actions

Treasure Eaters have one of the most complex sets of actions in the game. There are no less than 20 actions. The first two are the Treasure Eater looking around for treasure, the next eight are the teleportation smoke of the Treasure Eater leaving and arriving. The next four are the Treasure Eater jumping to grab treasure, followed by a shot and stunned Treasure Eater and finally four actions used by items stolen by the Treasure Eater (They vanish in a clod of sparkles.)

The teleport smoke is an 8 action sequence usually ending in a Treasure Eater. The first four frames of the sequence make the Treasure Eater appear to vanish. On the fourth frame a target check behavior is run and if a target is found the Treasure Eater's location is changed to match the target. The remaining four frames of the sequence the execute which make the Treasure Eater appear to reappear at the target location as a falling Treasure Eater. If no target is found the Treasure Eater is removed from the level. (It's action is not changed it is simply ceased.)

When jumping the Treasure Eater has two kinds, small horizontal jumps and large vertical ones. When jumping horizontally it will keep bouncing until there is no more items in its path. When jumping vertically it will look when it lands for more items.

If the stolen item is made to not vanish this can have interesting results. (If it becomes more Treasure Eater then the level will quickly be stripped of items, if they become deadly sprites the Treasure Eater acts as an enemy producer.) However unlike most cases, this should not crash the game as there is no way for an unlimited number of sprites to be produced in this way.

Actions:
$31E2W #Treasure Eater look 1
$3200W #Treasure Eater look 2
$321EW #Treasure Eater teleporting smoke 1
$323CW #Treasure Eater teleporting smoke 2
$325AW #Treasure Eater teleporting smoke 3
$3278W #Treasure Eater teleporting smoke 4
$3296W #Treasure Eater teleporting smoke 5
$32B4W #Treasure Eater teleporting smoke 6
$32D2W #Treasure Eater teleporting smoke 7
$32F0W #Treasure Eater teleporting smoke 8
$330EW #Treasure Eater jumping to steal stuff 1
$332CW #Treasure Eater jumping to steal stuff 2
$334AW #Treasure Eater jumping to steal stuff 3
$3368W #Treasure Eater jumping to steal stuff 4
$3386W #Shot Treasure Eater
$33A4W #Stunned Treasure Eater
$33C2W #Items stolen by Treasure Eater vanish 1
$33E0W #Items stolen by Treasure Eater vanish 2
$33FEW #Items stolen by Treasure Eater vanish 3
$341CW #Items stolen by Treasure Eater vanish 4

Patch: Keen 4
#Treasure Eater start
%patch $11A8B $31E2W
#Treasure Eater look
#Look around
%patch $3206E $3200W
#Treasure Eater look
%patch $3208C $0000W
#Wait to teleport
#Teleport away
%patch $11B95 $321EW
#No items nearby (Teleport away)
%patch $11C24 $321EW
#Treasure Eater has fallen far away from items (Teleport away)
%patch $11C75 $3296W
#Treasure Eater appear (Teleport smoke 4)
#Teleporting
%patch $320AA $323CW
#Treasure Eater teleporting smoke 2
%patch $320C8 $325AW
#Treasure Eater teleporting smoke 3
%patch $320E6 $3278W
#Treasure Eater teleporting smoke 4
%patch $32104 $3296W
#Treasure Eater teleporting smoke 5 (W]hen appearing start at this action)
%patch $32122 $32B4W
#Treasure Eater teleporting smoke 6
%patch $32140 $32D2W
#Treasure Eater teleporting smoke 7
%patch $3215E $32F0W
#Treasure Eater teleporting smoke 8
%patch $3217C $330EW
#Treasure Eater jumping to steal stuff (If disappearing, produce nothing)
#Jumping
%patch $11AA7 $330EW
#Treasure Eater jumping to steal stuff (Sees items)
%patch $3219A $332CW
#Treasure Eater jumping to steal stuff 1
%patch $321B8 $334AW
#Treasure Eater jumping to steal stuff 2
%patch $321D6 $3368W
#Treasure Eater jumping to steal stuff 3
%patch $321F4 $330EW
#Treasure Eater jumping to steal stuff (Small jumps, lands, keep jumping)
%patch $11E14 $31E2W
#Treasure Eater look 1 (Big jumps, look for more items)
#Shot
%patch $11CF6 $3386W
#Treasure Eater when shot
%patch $32212 $33A4W
#Stunned Treasure Eater in air (Wait to land)
%patch $32230 $0000W
#Treasure Eater stunned (Do nothing)
#Stolen items
%patch $11CB3 $33C2W
#Item sprites stolen by Treasure Eater
%patch $11DC7 $33C2W
#Item tiles stolen by Treasure Eater
%patch $3224E $33E0W
#Items stolen by Treasure Eater 1
%patch $3226C $33FEW
#Items stolen by Treasure Eater 2
%patch $3228A $341CW
#Items stolen by Treasure Eater 3
%patch $322A8 $0000W
#Items stolen by Treasure Eater 4 (Disappear)


Sprite Behavior

The Treasure Eater's behavior is interesting in that it is rather complex and involves teleportation, the only sprite in Keen to do this. As such a separate subsection here is dedicated to explaining how the Treasure Eater acts and to a limited extent, how this can be patched.

There are surprisingly few behaviors for such a complex sprite; the Treasure Eater uses the 'Berkeloid flame' behavior when it is jumping and the shot sprite behavior when shot, but its only other two behaviors are its item searching behavior and teleportation behavior. (Jumping is a tile collision behavior.)

Notice the Treasure Eater only looks for items on the fourth frame of its looking loop, so it doesn't teleport away instantly. The actual grabbing of items is a sprite collision and is treated below. The teleporting Treasure Eater only uses its teleporting behavior on its fourth frame; this is what makes it teleport from one place to another.

Behaviors:
$09DC16C9RL #Shot sprite
$09DC16E5RL #Berkeloid flame
$11A20079RL #Look if there are items above you, if so, move up to get them
$11A2022ARL #Look for items, teleport to them as a Treasure Eater

Patch: Keen 4
#Look for items
%patch $32062 $00000000L
#Nothing
%patch $32080 $11A20079RL
#Look for items
#Teleporting away
%patch $3209E $00000000L
#Nothing
%patch $320BC $00000000L
#Nothing
%patch $320DA $00000000L
#Nothing
%patch $320F8 $11A2022ARL
#Treasure Eater teleport
%patch $32116 $00000000L
#Nothing
%patch $32134 $00000000L
#Nothing
%patch $32152 $00000000L
#Nothing
%patch $32170 $00000000L
#Nothing
#Jump
%patch $3218E $09DC16E5RL
#Berkeloid flame
%patch $321AC $09DC16E5RL
#Berkeloid flame
%patch $321CA $09DC16E5RL
#Berkeloid flame
%patch $321E8 $09DC16E5RL
#Berkeloid flame
#Stunned
%patch $32206 $09DC16C9RL
#Shot sprite (Hit)
%patch $32224 $09DC16C9RL
#Shot sprite (Landed)
#Stolen stuff
%patch $32242 $00000000L
#Nothing
%patch $32260 $00000000L
#Nothing
%patch $3227E $00000000L
#Nothing
%patch $3229C $00000000L
#Nothing


Don't teleport

This patch stops the Treasure Eaters from teleporting away in a puff of smoke. This frees up both code space and sprite animations. This will result in the Treasure Eater being stuck in certain places, notably the tops of some slopes, because the only way it can move is by jumping.

Patch: Keen 4
#Treasure Eater doesn't teleport
%patch $11B90 $EB %patch $11C13 $EB


Searching and Stealing

Treasure eaters will hop back and forth, jumping to reach any items above themselves. They will turn when they bump into walls and will teleport when they can do nothing else.

Treasure eaters will only take another hop if they see four consecutive tiles to their immediate right or left that are top blocking. If they cannot make another hop twice, then they will teleport to the next item. They will search for item sprites, and if they have all been collected, then they will disappear. They always select the first item that they see in the sprite list, (which is generally the top-left most item remaining).

Treasure Eaters do not seem to look for item tiles; they will jump up to get them if they detect them above, but they will not teleport to them. (That is they DO look for item tiles, but only AFTER teleporting.)

It is thus possible to predict the path of all Treasure Eaters in a level. They will start where they are placed, 'eating' all target sprites in their area, then teleport to the top leftmost target sprite. With careful placement of target sprites it is possible to lead Treasure Eater through a level.


Target Sprites

By default Treasure Eater target sprite type 4, or items. This is everything from gems to rayguns to candy. It is possible to change the sprite type and even get Treasure Eater to go after multiple sprite types, though this can be complex. It may help to check the sprite type page as well as Patch:Jump conditions

Patch: Treasure eater target sprite type
#Treasure eater target sprite type:
%patch $11C62 $04 $75
#When teleporting to targets
%patch $11AB4 $04 $75
#When looking for targets above to jump at


Treasure Eater can't steal item tiles

This patch stops the Treasure Eater from stealing item tiles (But not item sprites.) This will often leave a Treasure Eater jumping up and down after items it can never get, but may be useful. For more fine control see the tile collision section below where individual tile can be tweaked as unobtainable.

Note that there are several patches depending on how restricted you want the Treasure eater to be.

Patch: Treasure Eater can't steal item tiles
#Treasure Eater can't steal item tiles or drops
%patch $11D69 $EB $6A
#Treasure Eater can't steal drops
%patch $11D6D $90 $90
#Treasure Eater can't steal item tiles
%patch $11D73 $EB


Treasure Eater doesn't vanish if there are no targets

By default the Treasure Eater ceases to exist if there are no target sprites in the level for it to move to. This patch stops that from happening; instead they simply reappear where they originally stood.

Patch: Treasure Eaters don't vanish if there are no targets
#Treasure Eaters don't vanish if there are no targets
%patch $11C8D $90 $90 $90 $90 $90


Speed and Jump Height

Treasure Eater speed is set entirely based on tile collision, that is their animation has nothing to do with their motion by default. In contrast their jumping behavior is very complex.

Patch: Animation motion
#Looking around
%patch $3205E $0000W $0000W %patch $3207C $0000W $0000W
#Teleporting smoke
%patch $3209A $0000W $0000W %patch $320B8 $0000W $0000W %patch $320D6 $0000W $0000W %patch $320F4 $0000W $0000W %patch $32112 $0000W $0000W %patch $32130 $0000W $0000W %patch $3214E $0000W $0000W %patch $3216C $0000W $0000W
#Jumping
%patch $3218A $0000W $0000W %patch $321A8 $0000W $0000W %patch $321C6 $0000W $0000W %patch $321E4 $0000W $0000W
#Shot
%patch $32202 $0000W $0000W
#Shot
%patch $32220 $0000W $0000W
#Stunned
#Stolen candy spark
%patch $3223E $0000W $0008W %patch $3225C $0000W $0008W %patch $3227A $0000W $0008W %patch $32298 $0000W $0008W


Jumping

Treasure Eaters have two kinds of jump, a small l\r jump to move and a larger vertical jump to snatch any targets that are above it. Treasure Eaters will perform a large jump whenever they detect a target sprite type above themselves. (See above.) Otherwise they will make small jumps left or right. When a Treasure Eater is making a small jump and hits a wall, it performs a 'wall jump' and changes direction. The horizontal speed of a jump controls both its left and right speed.

There are three 'misc' speeds; the first makes a Treasure Eater 'hover' or cling to a ceiling for a short time when it jumps and hits a roof. This lets it keep moving sideways at pace when in a short tunnel, otherwise it might get stuck being unable to jump along. The second value resets the Treasure Eater's speed after it has teleported, so it can sit and look without moving.

Patch: Treasure eater jumps
#When to jump
%patch $11AB4 $04 $75
#Target sprite type
%patch $11AD3 $73
#Big jump to target if it is less than...
%patch $11AD6 $0300W
#...3 tiles above
#Jump sizes: Big jump
%patch $11B5F $0000W
#H speed (Straight up)
%patch $11B64 $FFD0W
#V height
#Jump sizes: Small jump
%patch $11BE7 $0014W
#H speed
%patch $11BF1 $FFE8W
#V height
#Jump sizes: Hit wall jump
%patch $11C38 $0014W
#H speed
%patch $11C42 $FFE8W
#V height
#Misc
%patch $11AE5 $FFD0W
#'Hover' when hitting ceilings
%patch $11E45 $0014W
#V speed after teleporting


What tile types Treasure Eater jumps for

There are three limits to what tile properties will be stolen by the Treasure Eater. The first is a specific tile type, that of drops. The next two are the upper and lower bounds of item tiles (See Patch:Jump conditions.) By default tiles with properties between $15 and $1C are stolen. This includes all items, stunners and the extra life.

This range should not include tile property 0, which causes the Treasure Eater to constantly jump up and down, making their behavior moot.

Note that there is a mirror patch in the tile collision section that gives limits for what tiles the Treasure Eater can steal. These should match the limits here to avoid the Treasure eater jumping fruitlessly for tiles it can never get, or not jumping for tiles it can steal.

Patch: Keen 4
#What tile properties are stolen by Treasure Eater
%patch $11B4D $04 $74
#$04 AND...
%patch $11B53 $15 $72
#...$15 to...
%patch $11B59 $1C $77
#...$1C


Stop Treasure eater jumping

This patch removes the Treasure Eater's ability to jump up and get items. There are two steps involved, one to stop it jumping up after point sprites, the other to stop it going after item tiles. Note that the Treasure Eater will still be able to steal items they contact, but they will not actively hunt those they cannot.

Patch: Stop Treasure eater jumping
#Stop Treasure Eater jumping
%patch $11AB5 $90 $90
#Don't jump after sprites
%patch $11B5A $EB
#Don't jump after tiles


Sprite Collision

The Treasure Eater collision is complex, while there is only one unique collision, it involves not only Keen's shots but also items, which are stolen.


Collision values

The Treasure Eater uses the same collision for all of its actions except when shot and the stolen item sparks. This is logical enough.

Patch: Keen 4 collision values
#Looking around
%patch $32066 $11A20279RL
#Treasure Eater
%patch $32084 $11A20279RL
#Treasure Eater
#Teleporting away and back
%patch $320A2 $11A20279RL
#Treasure Eater
%patch $320C0 $11A20279RL
#Treasure Eater
%patch $320DE $11A20279RL
#Treasure Eater
%patch $320FC $11A20279RL
#Treasure Eater
%patch $3211A $11A20279RL
#Treasure Eater
%patch $32138 $11A20279RL
#Treasure Eater
%patch $32156 $11A20279RL
#Treasure Eater
%patch $32174 $11A20279RL
#Treasure Eater
#Jumping to steal stuff
%patch $32192 $11A20279RL
#Treasure Eater
%patch $321B0 $11A20279RL
#Treasure Eater
%patch $321CE $11A20279RL
#Treasure Eater
%patch $321EC $11A20279RL
#Treasure Eater
#Stunned
%patch $3220A $00000000L
#No collision (In air)
%patch $32228 $00000000L
#No collision (On ground)
#Stolen candy spark
%patch $32246 $00000000L
#No collision
%patch $32264 $00000000L
#No collision
%patch $32282 $00000000L
#No collision
%patch $322A0 $00000000L
#No collision


Collision code

This is the complete collision code for the Treasure Eater. The first line deals with looking for item type sprites (Type 4); the second line deals with making the item a got item spark and the third line with playing the 'stolen item' sound. (Same as the Treasure Eater teleport sound.) It can be seen that the blue values control these parameters. The brown $75 is a jump condition.

The fourth line checks for Keen's shot (Type 3), the fifth line changes some unknown Treasure Eater parameters and the sixth line changes the Treasure Eater's sprite type and action to stunned Treasure Eater.

Patch: Treasure Eater collision
%patch $11C99 $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D $04 $75 $26 
#Check for items (Type 4)
$C7 $05 $0001W $C7 $45 $20 $0003W $B8 $33C2W $50 $57 $9A
#If found change item's type, fore and actin
$09DC0A12RL $83 $C4 $04 $B8 $001DW $50 $9A $187409F1RL $83
#Play sound of item got
$C4 $02 $5F $5E $5D $CB $83 $3D $03 $75 $32 $C7 $44 $3E $0000W
#Check for Keen's shot (Type 3)
$C7 $44 $40 $0000W $C7 $44 $42 $0000W $8B $04 $89 $44 $44 $C7
#Unknown Treasure Eater changes
$04 $0021W $57 $9A $0D8F0D43RL $83 $C4 $02 $B8 $3386W $50
#Change Treasure Eater type and action
$56 $9A $09DC120ARL $83 $C4 $04 $83 $6C $18 $10 $5F $5E $5D $CB


Kill Keen, don't steal items

This patch makes the Treasure Eater dangerous to Keen, at the cost of removing its ability to steal item sprites (But not item tiles.) This can lead to it trying to get items it can never grab and also creates two types of item in the level, ones that can be stolen and ones that can't.

Patch: Keen 4
#Treasure eaters kill Keen, shootable (Don't get item sprites)
%patch $11C99 $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D $02 $75 $09
#Check for Keen, kill
$9A $0B8013E9RL $5F $5E $5D $CB $83 $3D $03 $75 $32 $C7 $44 $3E $0000W
#Check for Keen's shot (Type 3)
$C7 $44 $40 $0000W $C7 $44 $42 $0000W $8B $04 $89 $44 $44 $C7
#Unknown Treasure Eater changes
$04 $0021W $57 $9A $0D8F0D43RL $83 $C4 $02 $B8 $3386W $50
#Change Treasure Eater type and action
$56 $9A $09DC120ARL $83 $C4 $04 $83 $6C $18 $10 $5F $5E $5D $CB


Don't stop Keen's shot

This patch will make it so that when the Treasure Eater is shot, Keen's shot will simply continue on right through it. (Allowing it to hit another sprite.) Notice it does this by removing the $9A call in line six of the above patch. It is not compatible with the infinite shootability patch.

Patch: Keen 4
#Don't stop bullet
%patch $11CED $90 $90 $90 $90 $90


Treasure Eater can be shot multiple times

This code allows Keen to shoot the Treasure Eater as many times as he wants, each time it will produce a stunned Treasure Eater This code can be combined with any of the above codes except if the 'don't stop bullet' code is disabled. (They are incompatible, the bullet will be stopped when the below code is included.)

A side effect is that the shot will vanish instead of smashing. Notice that this code replaces the three byte string $8B $76 $06 in the above patches with $90 $90 $90.

It is possible to change what is spawned by changing the 'stunned Treasure Eater' action value in the code above. Be careful when using this patch; the player can use it to spawn infinite sprites and crash the game. There must be some way to stop this happening. (If the spawned sprites vanish by themselves, destroy each other or are dangerous enough to Kill Keen this should work.)

Patch: Keen 4 infinite shootability
#Treasure Eater
%patch $11C9E $90 $90 $90


Animations

As expected the Treasure Eater's animations are complex simply due to their sheer number of them. Of more interest are the animation speeds which can be used to alter the Treasure Eater's behavior considerably. The two speeds in its 'looking' phase determine how long it will sit before teleporting away to candy, those in the teleport smoke section determine hoe fast it appears or vanishes and those for the stolen items determine how long it is before the stolen item animation vanishes.

Patch: Keen 4
#Cache
%patch $306F0 $0152W
#Treasure Eater Cache start
%patch $3073A $0163W
#Treasure Eater cache end
#Treasure Eater looks around
%patch $32052 $0152W $0152W %patch $3205C $0014W
#Animation speed
%patch $32070 $0153W $0153W %patch $3207A $0014W
#Animation speed
#Teleporting smoke
%patch $3208E $015EW $015EW %patch $32098 $0014W
#Animation speed
%patch $320AC $015FW $015FW %patch $320B6 $0014W
#Animation speed
%patch $320CA $0160W $0160W %patch $320D4 $0014W
#Animation speed
%patch $320E8 $0161W $0161W %patch $320F2 $0014W
#Animation speed
%patch $32106 $0161W $0161W %patch $32110 $0014W
#Animation speed
%patch $32124 $0160W $0160W %patch $3212E $0014W
#Animation speed
%patch $32142 $015FW $015FW %patch $3214C $0014W
#Animation speed
%patch $32160 $015EW $015EW %patch $3216A $0014W
#Animation speed
#Treasure Eater jumping
%patch $3217E $0157W $0154W %patch $32188 $0006W
#Animation speed
%patch $3219C $0158W $0155W %patch $321A6 $0006W
#Animation speed
%patch $321BA $0159W $0156W %patch $321C4 $0006W
#Animation speed
%patch $321D8 $0158W $0155W %patch $321E2 $0006W
#Animation speed
#Stunned Treasure Eater in air
%patch $321F6 $0157W $0157W %patch $32200 $0000W
#Wait to hit ground
#Stunned Treasure Eater
%patch $32214 $0163W $0163W %patch $3221E $0000W
#Do nothing
#Candy stolen by Treasure Eater
%patch $32232 $015AW $015AW %patch $3223C $000AW
#Animation speed
%patch $32250 $015BW $015BW %patch $3225A $000AW
#Animation speed
%patch $3226E $015CW $015CW %patch $32278 $000AW
#Animation speed
%patch $3228C $015DW $015DW %patch $32296 $000AW
#Wait before vanishing


Sounds

There are two sounds the Treasure Eater produces; the first is when teleporting away and the second is when teleporting back (and thus stealing an item.) Both sounds are a bit 'patchy' not being played predictably.

Patch: Keen 4
#Sounds
%patch $11C16 $1E
#Treasure Eater teleport away sound
%patch $11CC0 $1D
#Treasure Eater teleport back sound
#Don't make sounds:
%patch $11C15 $EB $0A
#Treasure Eater teleport away sound
%patch $11CBF $EB $0A
#Treasure Eater teleport back sound


Sprite positioning and landing on the ground

There are two positions that matter, the first is the initial spawn height of the Treasure Eater, it is 1.5 tiles above the ground and works as expected. (More negative is higher.) but the second position is 0.5 tiles up and is 'reversed' (More positive is higher.) If the Treasure Eater's sprite's height is changed these two must be changed also, especially if the Treasure Eater is made taller, otherwise it will fall through the floor. In this case both values must be changed, but in opposite directions. The second position deals with how far off the ground the Treasure Eater appears when teleporting.

Patch: Keen 4
#Spawning height
%patch $11A5E $FE80W
#Spawn height
%patch $11C69 $0080W
#Teleport height


Clipping and foreground

Interestingly the only clipping patchable for the Treasure Eater is the sparks left behind by stolen items, it has no clipping and will freely pass through solid tiles. (This applies to stolen item tiles, items themselves already have no clipping.)

The Treasure Eater and the items it steals (Both tile and sprite) have the value 3 for foreground, allowing them to appear in front of all tiles. This can be interesting when it steals hidden items.

Patch: Keen 4
#Treasure Eater stolen item tiles spark clipping
%patch $11DAE $0000W

Patch: Keen 4
#Treasure Eater foreground values
%patch $11A4C $0003W
#Treasure Eater
%patch $11CB0 $0003W
#Treasure Eater stolen items spark
%patch $11DA9 $0003W
#Treasure Eater stolen tiles spark


Sprite-tile interaction

By default the Smirk uses the standard 'sit' interaction when looking for candy and teleporting. (Also used by stolen item sparks.) It does however have its own special interaction for when it jumps to steal items. This is what defines its jump heights (See above.) Without this interaction it will not move at all. When shot it uses the standard 'shot sprite' interaction.

Patch: Keen 4
#Look
%patch $3206A $09DC176ERL
#Sit
%patch $32088 $09DC176ERL
#Sit
#Teleporting
%patch $320A6 $09DC176ERL
#Sit
%patch $320C4 $09DC176ERL
#Sit
%patch $320E2 $09DC176ERL
#Sit
%patch $32100 $09DC176ERL
#Sit
%patch $3211E $09DC176ERL
#Sit
%patch $3213C $09DC176ERL
#Sit
%patch $3215A $09DC176ERL
#Sit
%patch $32178 $09DC176ERL
#Sit
#Jumping
%patch $32196 $11A203DERL
#Jumping Treasure Eater
%patch $321B4 $11A203DERL
#Jumping Treasure Eater
%patch $321D2 $11A203DERL
#Jumping Treasure Eater
%patch $321F0 $11A203DERL
#Jumping Treasure Eater
#Shot
%patch $3220E $09DC1913RL
#Shot sprite
%patch $3222C $09DC1913RL
#Shot sprite
#Stolen item sparks
%patch $3224A $09DC176ERL
#Sit
%patch $32268 $09DC176ERL
#Sit
%patch $32286 $09DC176ERL
#Sit
%patch $322A4 $09DC176ERL
#Sit


What tile types are stolen

There are three limits to what tile properties will be stolen by the Treasure Eater. The first is a specific tile type, that of drops. The next two are the upper and lower bounds of item tiles (See Patch:Jump conditions.) By default tiles with properties between $15 and $1C are stolen. This includes all items, stunners and the extra life.

This range should not include tile property 0, which causes the Treasure Eater to constantly absorb tiles (Even the ones it stands on!) creating dozens of sprites, which can cause the level to crash.

An exactly related patch is found in the speed and jump height section, which gives values for what tile types are jumped at by the Treasure Eater; these should match the limits set here.

Patch: Keen 4
#What tile properties are stolen by Treasure Eater
%patch $11D6C $04 $74
#$04 AND...
%patch $11D72 $15 $73
#...$15 to...
%patch $11D78 $1C $77
#...$1C


Action type

The Treasure Eater and its associated actions use nearly all of the possible action types. The looking and teleporting use type 0 as expected. The jumping actions use type 3, as do most jumping sprites, and the shot Treasure Eater type 2. Finally stolen items use type 1, though there is no need for them to do this. (They do not move and thus do not need the smooth movement of type 1.)

Patch: Keen 4
#Look around
%patch $32056 $0000W %patch $32074 $0000W %patch $32092 $0000W %patch $320B0 $0000W %patch $320CE $0000W %patch $320EC $0000W %patch $3210A $0000W %patch $32128 $0000W %patch $32146 $0000W %patch $32164 $0000W %patch $32182 $0003W %patch $321A0 $0003W %patch $321BE $0003W %patch $321DC $0003W %patch $321FA $0002W %patch $32218 $0002W %patch $32236 $0001W %patch $32254 $0001W %patch $32272 $0001W %patch $32290 $0001W


Deprotect and stick to ground

The Treasure Eater has no need for either stick to ground or deprotection and so has values of 0 for both these parameters in all its actions.

Patch: Keen 4
#Look
%patch $32058 $0000W $0000W %patch $32076 $0000W $0000W
#Teleport
%patch $32094 $0000W $0000W %patch $320B2 $0000W $0000W %patch $320D0 $0000W $0000W %patch $320EE $0000W $0000W %patch $3210C $0000W $0000W %patch $3212A $0000W $0000W %patch $32148 $0000W $0000W %patch $32166 $0000W $0000W
#Jump
%patch $32184 $0000W $0000W %patch $321A2 $0000W $0000W %patch $321C0 $0000W $0000W %patch $321DE $0000W $0000W
#Shot
%patch $321FC $0000W $0000W %patch $3221A $0000W $0000W
#Stolen item sparks
%patch $32238 $0000W $0000W %patch $32256 $0000W $0000W %patch $32274 $0000W $0000W %patch $32292 $0000W $0000W


Probability and randomness

Treasure Eater have a built in 'randomizer' that makes their teleporting slightly unpredictable; if this value is zero then the Treasure Eater will always go to the most desirable item (Read: nearby) when teleporting. By default it has only a 50% chance of doing so. (And a 25% chance of going after the 2nd most desirable, 12.5% chance of the 3rd most and so on.) Setting this too high will use up game memory and stop the Treasure Eater from ever appearing.

Patch: Keen 4
#How predictable is Treasure Eater are when teleporting:
%patch $11A69 $80


Sprite spawn code

In the initiation code notice the Treasure Eater cache being set ($C7 $06 $6B $CB $0001W.)

In the spawning code the last blue highlighted value is the sprite action the sprite uses as it proceeds to act in-level. $C7 $02 $xxxxW sets the sprite activity, $C7 $07 $xxxxW sets the sprite type, $C7 $20 $xxxxW sets the foreground value. Finally $D3 $E0 $05 $xxxx is how far down (Or more usually up) the sprite is spawned from where it is placed. This is necessary for sprites that walk on the ground as they can only be placed in the level at multiples of 16 pixels high while their actual height can be anything.

The Treasure Eater always starts the level moving down. (Odd, it has no reason to.) $C7 $47 $10 $xxxxW is the vertical direction the sprite starts moving in, either $0001W (Facing down), $FFFFW (Facing up) or $0000W (Neither, never used.) There is however randomness in what horizontal direction the Treasure Eater spawns with. A 50:50 probability check is made which causes the Treasure Eater to spawn either facing left ($FFFFW) or right ($0001W; $C7 $47 $0E $xxxxW is the horizontal direction.)

Patch: Keen 4
#Location of initiation code
%patch $EEA7 $02BCW
#Smirky (At $EBAC)
#Smirky Initiation code
%patch $EBAC $FF $76 $FC $57 $9A $11A2000ERL $83 $C4 $04 $C7 $06 $5B $CB $0001W $E9 $023CW
#Smirky Spawning code
%patch $11A2E $55 $8B $EC $33 $C0 $50 $9A $06BD1E11RL $83 $C4 $02 $8B $1E $D8 $A7 $C7 $07 $001AW $C7 $47 $02 $0001W $C7 $47 $20 $0003W $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $05 $FE80W $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 $8B $1E $D8 $A7 $C7 $47 $10 $0001W $B8 $31E2W $50 $53 $9A $09DC118CRL $83 $C4 $04 $5D $CB