Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Moderator:GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
DER works well, overall, with only one minor bug I'm aware of. I would like to fix it, but it's a matter of engine details I know little about, so I don't even know where to start. (Full disclosure: DER is a fork of AI Director, and this is an inherited bug that Josh771 wasn't able to fix.)
The bug is that a small percentage of dynamically spawned enemies can be clipped into a wall. In the attached pk3 file, I wrote a comment block at the start of the Zscript file that explains it in detail.
It's easy to reproduce the bug, with these steps:
Spoiler: Steps to Reproduce
1. Download the attached der_DEBUG.pk3 file. Functionally, it's the same as normal DER_v2 except the default CVars are insane, only survivable with invincibility.
(1a. If you've used DER before, you probably need to clear out the normal CVars in the gzdoom.ini file so that the Debug ones can take their place. I suggest opening the .ini (GZDoom must not be running) and deleting the block of "der_*" items. It's much easier than manually setting them in the console.)
2. Load Doom 2 with this mod. Start a new game on Hurt Me Plenty difficulty.
3. In the console, "buddha" to survive the onslaught.
4. Go into the inner room of Map01. There are 4 Zombiemen on the raised platforms.
Important: Don't activate the switch that lowers the platforms. They need to stay up.
5. Roam around the room and let swarms of reinforcements spawn. (A new group should appear every 6 seconds.) You'll see that some are clipped into the walls of the platforms and stuck in-place.
6. Optional: After seeing the problem, activate the switch to lower the platforms. The stuck enemies can now move freely.
I realize this thread is a long shot, but I figured I might as well ask.
--------------------
edit: Good thing I asked for help! Now that it's fixed in DER_v3, I deleted the debug pk3 here. If you want to reproduce this problem in the current version, simply comment out the use of CheckMove.
Also, here's the comment block and debug settings mentioned in my original post:
server int der_min_seconds = 6;
server int der_max_seconds = 6;
server float der_min_distance = 0.0;
server float der_max_distance = 300.0;
server int der_min_groups = 1;
server int der_max_groups = 1;
server int der_min_pergroup = 10;
server int der_max_pergroup = 10;
/* The only visible bug has been reinforcements clipping into a vertical wall
when their spawn point is on top of a raised surface, but within SpawnOneAt
they are moved far enough to settle on a lower surface.
That's when they get clipped into a wall.
The problem occurs regardless of the extra nudge (which I kept because my
testing clearly demonstrated it enables more spawns to share a point).
For context, this happens seldomly enough in the course of real gameplay
that I consider it a minor problem. But I would like to fix it, because
it can detract from immersion: the clipped enemy keeps walking in place,
with part of its sprite hidden in the wall. In every case I've seen,
it can be attacked and killed (and usually can shoot back).
I tried removing the last SetOrigin call, so that they spawn in mid-air,
but they just fell straight down and clipped anyways.
Given how dynamic DER is (can run on any map, leveraging any spawn point)
it seems that the only solution would be to do further operations
after the SetOrigin calls and move the spawn if it would be clipped.
*/
Last edited by fcas3t on Thu Apr 08, 2021 4:20 pm, edited 1 time in total.
This adds a check to see if the spawned monster is able to move from its current position. It appears to work for me, monsters no longer spawn inside platform walls now. I'm not sure if there is a reliable way to "unstuck" them especially if you want your script to work on every map, so it's probably best to simply destroy them in this case.
Thanks for figuring this out! I really appreciate you applying your expertise to this problem.
Adding CheckMove has completely fixed it in my own testing today. So I've released a new version of DER.
And, yes, I agree that it's best to destroy any clipped monster. The code already has a robust retry mechanism in place, so this is just another case of that. Full credit to Josh771 for creating this robustness in AID, which DER inherited.
(I found it funny that an actor can CheckMove its own position, so I took a quick look at the relevant GZ engine code. There's a slew of tests, one of which must detect the clipping. Very cool that there was a Zscript API for this.)