Making custom patrol routes in Zscript

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!)
Ershantik
Posts: 14
Joined: Sat Dec 23, 2023 4:04 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 7

Making custom patrol routes in Zscript

Post by Ershantik »

I've been working on a way to dynamically set custom patrol routes for friendly monsters. I use Zscript to directly set the monster's goal pointer to the first patrol point in a route, and each patrol point's goal to the next point in the route. I read on another post that patrol points will automatically transfer their goal pointer when a monster reaches it, but that isn't happening. Once a monster reaches the first point, it seems to clear their goal pointer, and they just go back to wandering aimlessly.

I came up with a workaround using custom classes as patrol points that use A_CheckProximity. It works, but it feels kind of sloppy. Is there a better way I can do this?
No ACS. Zscript only, please.
Ershantik
Posts: 14
Joined: Sat Dec 23, 2023 4:04 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 7

Re: Making custom patrol routes in Zscript

Post by Ershantik »

UPDATE: I did some more testing, and I found out the patrol points need to have the TID of another patrol point passed to them as args[0] to work properly. Functions like UniqueTID don't seem to work in Zscript, so I used a for loop with actor iterators to generate TIDs for the patrol points, and the whole system seems to work.

I would still like to know if there's a more efficient way to do this, if anyone has any advice.
7Soul
Posts: 44
Joined: Sat Mar 13, 2021 6:47 pm

Re: Making custom patrol routes in Zscript

Post by 7Soul »

Ershantik wrote: Wed Mar 12, 2025 6:42 am I did some more testing, and I found out the patrol points need to have the TID of another patrol point passed to them as args[0]
When you have an object's info window opened, there's a link on the bottom-left that sends you to the wiki page for that class, very helpful to learn how each class works

The ZScript version of UniqueTID is LevelLocals.FindUniqueTid(1) (I found it by searching UniqueTID on GZDoom's source code)

Return to “Scripting”