Enemy interacting with gem holders

Request patches for Keens 4-6.
Post Reply
Dave216
Posts: 19
Joined: Thu Apr 14, 2022 8:33 am

Enemy interacting with gem holders

Post by Dave216 »

I would like a patch that would make Lick open doors. I am aware that this one is rather difficult(or not even doable?)

If it's any easier, it can be Treasure Eater instead of Lick since he at least interacts with items like candy and gems. And I've managed to patch that he follows Keen so either one of those two would do.
nwe74
Posts: 11
Joined: Mon Jul 18, 2022 7:46 pm

Re: Enemy interacting with gem holders

Post by nwe74 »

I was able to patch the Treasure Eater to open gem doors. As you have suggested, patching the Eater for this behavior was significantly easier as its code already contains a loop for checking properties of "nearby" tiles, which I could re-use for gem sockets.

My patches:

Code: Select all

# Patches for Treasure Eater opening gem doors. It can no longer "eat"
# bonus objects/gems or teleport.

# New Treasure Eater think code (T_EaterJump). Follows Keen, makes smaller
# jumps when close to him. Note: Jump size can be easily modified
# ($B9 $0020w -> length, $BA $FFE0w -> height)
%patch $11A9C  $56 $8B $76 $06 $C7 $44 $1C $330Ew $B9 $0020w $BA $0001w
    $8B $1E $A7D6w $8B $47 $0A $2B $44 $0A $73 $06 $F7 $D8 $F7 $D9 $F7 $DA      
    $89 $54 $0E $BA $FFE0w $3D $0300w $73 $04 $D1 $F9 $D1 $FA $89 $4C $16    
    $89 $54 $18 $5E $5D $CB        

# Replacement for the initial part of the function responsible for Keen
# opening gem doors (KeenKeyThink). Required because the sprite is not
# always positioned exactly at the gem socket.
# The original function for Keen should still work.
%patch $11AD5  $55 $8B $EC $83 $EC $10 $56 $57 $8B $5E $06
    $8E $06 $A7E9w $26 $8B $07 $05 $0012w $89 $46 $FE $8E $06 $A7EBw
    $26 $8B $07 $31 $C9 $86 $E1 $89 $4E $FA $89 $46 $F8 $B8 $0001w $50 $50
    $FF $76 $0A $FF $76 $08 $50 $EA $0B800A8DRL
    
# Sprite interaction (C_Eater). Patched Eater is harmless and not stunnable.
# If this is not what you need, I can change this. 
%patch $11CA4  $83 $3D $03 $75 $09 $57 $9A $0D8F0D43RL $83 $C4 $02
    $5F $5E $5D $CB

# New code for checking for gem sockets (in EaterInTile). Calls the 
# new function starting at $11AD5.
# (Implementation detail: the function is called with 3 arguments pushed
# to the stack: 1: offset in map segment, 2. x position 3. y position).
%patch $11D63  $24 $7F $3C $07 $72 $6C $3C $0A $77 $68 $FF $76 $FE $56
    $FF $76 $FA $0E $E8 $FD5Dw $83 $C4 $06 $EB $58      

# Tile interaction (R_EaterAir). The creature could get stuck near 
# the top of slopes, the following patch should fix this.
%patch $11E2C  $83 $7C $3A $00 $74 $0A $F7 $5C $0E $90 $90

The main limitation of the current patches are that the patched Eater will open the gem door immediately if its sprite collides with the gem socket. Unlike Keen, it will open the door from a small distance and it has currently no separate animation frame for placing gem. I guess the distance could be made smaller (if needed) by using a narrower hit box for the sprite. If not, I will try to modify the patches.

(Edited due to a typo - nwe74)
Dave216
Posts: 19
Joined: Thu Apr 14, 2022 8:33 am

Re: Enemy interacting with gem holders

Post by Dave216 »

This is wonderful. This adds so much new possibilities when designing levels. Once again, thank you.
Post Reply