Modify monsters patroling behaviour

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!)
unbagolo
Posts: 1
Joined: Wed May 22, 2024 1:41 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: Intel (Legacy GZDoom)

Modify monsters patroling behaviour

Post by unbagolo »

Good morning all, it's the first time i ask something, but i can't find a way/answer i search quite a lot, but without luck(i use zscript).

MY GOAL:
Now(gzDoom) if a monster is patroling through patrolpoints look for player without considering the field of view, it can see me even if i'm behind it.
I would love to change this behaviour making it searching for player in its field of view.

I think there are some solutions, but i don't know which will work and which is the best:
SOLUTION 1:
Create a feature of gzdoom modifing the p_enemy.cpp, in the patroling handler from P_LookForPlayers to P_CheckSight , could be the simpliest(i don't know how to compile, but not really a problem) but i would have to bound the wad with my custom gzdoom feature.
SOLUTION 2:
I saw that in the p_enemy.cpp the p_LookForPlayers are called with parameters flags4 & MF4_LOOKALLAROUND (P_LookForPlayers (self, self->flags4 & MF4_LOOKALLAROUND, NULL)) i tried to set those parameters(MF4_LOOKALLAROUND to false) without luck, but maybe i'm missing something, i tried modifying the revenant class like this:
Default
{
-LOOKALLAROUND;
}

override void BeginPlay()
{
bLOOKALLAROUND = false;
}
SOLUTION 3:
Add a flag(boolean) that tell me that is patroling(because in the super.tick) and a variable Actor "nextPatrolPoint" that store the next patrolPoint, Override the Tick class implementing the behaviour i want; i did almost all, but it doesn't work, i think that set the target it's not enough and looks like that i can't call Thing_setGoal from zscript(even if would be redundant, but at leat just to understand if works)
SOLUTION 4:
Make a custom patroling handler(opening the Pandora's box cause it needs a lot of regression tests)

In all solutions something missing me, can an expert tell me what is the best way to go and give me some hints.
Really really thanks and sorry for the long question!

Return to “Scripting”