Page 1 of 1

How to change dimensions of an enemy?

Posted: Tue Jun 20, 2017 10:22 pm
by Alopex
Let me clarify: I want to modify the image 4SPR0333 of my Keen 4 mod (the "smaller" version of the Wormouth, when it walks hiding itself) with a replacement that have bigger dimensions than the original sprite.

Image

How can I do that?

Re: How to change dimensions of an enemy?

Posted: Tue Jun 20, 2017 10:48 pm
by Fleexy
You can change the height of the bitmap to whatever you like. The width of the sprite must be a multiple of 8 because of how the EGA format works, therefore the bitmap's width must be a multiple of 24. The first third is the image, the center is the mask, and the right third is the clipping rectangle.

This is where things get tricky. The ?SPRITES.TXT file (4SPRITES.TXT for Keen 4) keeps some information about each sprite. The number before the colon is the sprite ID. The set of 4 numbers is the hitbox's size/location: left, top, right, bottom. I'm not sure whether this takes precedence over the gray-and-red box in the bitmap; a more experienced ModKeen user will have to answer that. The set of two numbers is the offset: X and Y. This is necessary to keep the sprite in the same position when it changes size throughout its behavior. The Keen shooting frames, for instance, have an offset so that Keen's body stays in the same place even though his image gets wider. Similarly, things that change height throughout their life will need to have their Y offsets engineered so they don't glitch up and down. The Y part is also important to make sure the bottom of the hitbox aligns with the ground when the sprite spawns. Finally, the last number is how smooth the sprite needs to move; it can be 1, 2, or 4. Higher values make for smoother movement, but also require more memory.

All this can take some trial-and-error.

Re: How to change dimensions of an enemy?

Posted: Wed Jun 21, 2017 6:04 am
by Nisaba
like Fleexy mentioned it before, it's really a matter of trail-n-error. for a deeper understanding of how things work, please make sure too read the following section of the tutorial with care:
http://www.shikadi.net/keenwiki/Keen_Ga ... )#Hitboxes

Re: How to change dimensions of an enemy?

Posted: Wed Jun 21, 2017 10:41 am
by Alopex
OK, this thing is just funny:

I took a copy of sprite 4SPR0316 (the Underwater Mine in Keen 4)

Image


and I put it in BMP folder with the bitmap name 4SPR0333 (the "small" Wormouth),

Image

in order to replace the sprite of the Wormouth with the Underwater Mine. I also changed the appropriate line in the 4SPRITES.TXT of the Wormouth with the hitboxes attributes of the Underwater Mine. This is happening now: in some levels, the Underwater Mine (replacement of the "smaller" version of the Wormouth, when it walks hiding itself) works just fine, but in most levels it is stuck and literally sunk into the ground without moving.

Image

Image

Image


Why the new Wormouth sprite sometimes works properly and sometims not?

Do you have any tips?

Re: How to change dimensions of an enemy?

Posted: Wed Jun 21, 2017 5:34 pm
by Nisaba
ok, the hitboxes (ingame) of the Wormouth look something like this:

Image

depending on which sprite you have replaced, you want to make sure, to change the Y-coordinate of the second set of brackets (in your 4sprites.txt file). this value determines how far up or down the sprite is placed. so as your modded enemy is stuck in the ground (or in the air), you'll want to edit the Y value to bring the hitbox even with the ground.

if you could, please do also post your altered set of coordinates (plus the original values).

Re: How to change dimensions of an enemy?

Posted: Sat Jun 24, 2017 9:54 am
by Alopex
Nisaba wrote: Wed Jun 21, 2017 5:34 pm ok, the hitboxes (ingame) of the Wormouth look something like this:

Image

depending on which sprite you have replaced, you want to make sure, to change the Y-coordinate of the second set of brackets (in your 4sprites.txt file). this value determines how far up or down the sprite is placed. so as your modded enemy is stuck in the ground (or in the air), you'll want to edit the Y value to bring the hitbox even with the ground.

if you could, please do also post your altered set of coordinates (plus the original values).
The original values of the Wormouth (the hidden version) are: 333: [0, -3, 7, 4], [0, 3], 4.

Image

I replaced these coordinates with the Underwater Mine ones: 316: [3, 3, 20, 20], [0, 0], 4.

Image

I'd like to create a Keen's enemy bigger than it, but with the same behaviour.