That's actually reasonably straight forward to do directly in the actor's ZScript. I do it with a lot of my custom enemies and decorations. A frame in the spawn state sequence sets a random scale value. IMO, it's best not to make very different values possible because then you could end up with a very small, and a very big one standing right next to each other - and that just looks weird and makes if very obvious what you have done. This also means that it isn't usually necessary to alter the hitbox size - just make it somewhere in the middle of the randomisation extremes.
example of scaling from one of my actors:
Code: Select all
PRIS A 0 A_SetScale (frandom(0.95,1.1));
There are also several other things to consider (here are just a few that I have come across):
It's a good idea to give the enemies an idle state sequence. If the enemy loses their target (e.g. when a player dies), they go back to their spawn state sequence and re-scale themselves. There are a few ways to fix this but the easiest (IMO) is to give them an idle state sequence. If an enemy has an idle sequence, they go to that, rather than the spawn sequence when they lose their target. So, no more rescaling - and you can get the enemy to do things in their idle state too - like wander around instead of just stopping on the spot.
If an enemy has been set to be dormant in a map, it won't scale itself until it becomes activated. If the player sees that, they can see the change in size. e.g. I had some enemies that were initially like decorations in tanks in a science lab. They were set to be dormant. That meant that they were too big anyway (they needed to be scaled down to look right), but the tanks break and the monsters get released in full view of the player. So, I had to place them as active, rather than dormant, and then freeze them after a couple of tics in an open script when the map starts and before the player could see them.
Also, if you are doing something like having the player teleport invisibly from one location to another identical location (to fake a continuous corridor or whatever) and there are some decorations that are set to randomly scale (e.g. natural scenery like trees would be a suitable candidate here) then the decorations on either side of the teleport setup need to be given the same scale. Otherwise, you can see the size change when you teleport, and this breaks the illusion.
That all probably sounds like a lot of hassle, but in reality, most of the time, those issues simply don't get encountered. So, it just needs to be addressed in the very few occasions when it's a problem, and addressing it is actually pretty easy.
And, as ever, there are alternatives to the above too, if someone wanted to do it a different way. This is just something that I set up years ago and saw no need to change. Or, it doesn't need to be done at all.