Trying to clarify/extend/replicate AVOIDHAZARDS flag

Mon Sep 06, 2021 9:24 am

(Posting in general cause it's kinda multi-discipline, I guess)

Sooo... I was quite interested when I saw the addition of the AVOIDHAZARDS flag in recent commits, but looking at the source, it appears to only check for crushers and not anything else. Which is understandable, given the stock behavior.

But... I was kinda crossing my fingers for a way to make monsters that would avoid regular damaging floors (regardless of actual damage to them - though I do plan on working that out, too), as that is something I am looking into doing for my own project.

I've already delved into source modification but I am speculating whether there might be a scripting solution. Otherwise, I can probably adapt the source for AVOIDHAZARDS to achieve this. But I am trying to keep such modifications to as little a degree as I can.

So... is there any particular recourse anyone might want to suggest here? Admittedly, it's looking like a lot of work for a pretty minor enhancement ūü§Ē

Re: Trying to clarify/extend/replicate AVOIDHAZARDS flag

Mon Sep 06, 2021 11:12 am

Considering this flag was meant for MBF21 compatibility, it is highly undesirable for it to perform any task other than what other source ports are doing with it to achieve this.

So to that end, if you are looking to modify the source it will need a new flag, instead, that is not related to MBF21. Modifying the source is unnecessary though - monster movement can largely be regulated with ZScript, instead, and you can move creatures off of hazardous floors and onto safe areas using that, instead. It should be pointed out that for the most part, non-player objects do not suffer damage from floor hazards due to the way the hazard check code works. If you want a creature to suffer from hurt floor damage, they will have to check what surface they are standing on, themselves, and apply the damage as appropriate.

Re: Trying to clarify/extend/replicate AVOIDHAZARDS flag

Mon Sep 06, 2021 11:50 am

Yeah, that's what I was suspecting on both counts. I've got my own base monster class, so I should be able to do it in there. I'll go digging through the ZScript side of things to see if I can figure it out. Thanks.

I'll follow up in this thread with whatever I come up with, too. Whenever that may be!

-----------------------------------
Edit:

Ok, I have a sloppy working proof of concept that took way too long to figure out.

Easy enough to get automatic sector damage on monsters in ZScript... but configuring the movement functions in ZScript looks like it would be a huge nightmare involving writing a new chase function which is not an undertaking I feel up for, so - at least pending some much easier way that I've overlooked - I put something together modding the source. Took a while of understanding P_TryMove and a P_NewChaseDir to get something that worked properly... it kept working too well and treating the boundary to a damaging floor like a solid wall, but I got there in the end.

I will be the first to say that I fully expect the following code to be put through the meat grinder by everyone else, but it probably deserves it. Anyway, physically stopping the actor from moving onto a damaging floor is a new bit in P_TryMove, governed by a new flag, awkwardly replicating how other bits in the same function work which I understand a solid 58% of:
Spoiler:


That works on its own, but the monsters just kinda awkwardly press against the boundary and slide around, which is what they'd do against ledges blocking them if it weren't for the randomization done in P_NewChaseDir.
That's where the part I'm ashamed of lives. It's just a kludgey duplicate of the "turn-around-if-too-close-to-a-ledge" check changed to look at sector damage, and I hate it.
Spoiler:


We'll see how it changes in the future though. Or gets destroyed. Time will tell.