[ZScript] Monster targets non-player Actor (+ Goals)

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!)
Post Reply
Nintolerance
Posts: 3
Joined: Mon Jul 21, 2025 7:31 pm
Preferred Pronouns: They/Them

[ZScript] Monster targets non-player Actor (+ Goals)

Post by Nintolerance »

Long time listener, first time caller.

The next step in my first ZDoom project involves making specific enemies target and attack (or "attack") specific actors.

For one monster with a fire extinguisher, I want them to target & attack "fire" actors. (Currently they'll extinguish a fire if they shoot one by accident, but they don't target & chase fires.)

For another monster that resurrects monsters, I want them to target and "chase" corpses. (Currently they'll resurrect a monster if they stumble into one while chasing the player, but they don't go out of their way.)

The wiki has pointed me towards "thing_hate" and "hate targets," but I can't decipher anything workable from those pages. I don't even know if it's ZScript, and not some other language. So I've come here to beg for help.

At a glance, if I could figure out how to implement it, thing_hate does what I want. "Hate actors wih given TID and attack players when shot." So then I'd assign a TID (somehow) to fire actors and tell the Extinguisher Monster to "hate fires."

Likewise, "hate corpses" is probably too tricky but I can just have corpses spawn an invisible "corpse locator" actor for the Repair Bot to "hate," and have the corpse locator vanish. Right?

EDIT: I've tried searching the forums for "hate" but I haven't found anything relevant, so I gambled on starting a thread.

EDIT EDIT: While I'm here, I guess it'd also be nice to have a way to make monsters not blunder into fires. 😅
Last edited by Nintolerance on Tue Jul 29, 2025 9:50 am, edited 1 time in total.
Nintolerance
Posts: 3
Joined: Mon Jul 21, 2025 7:31 pm
Preferred Pronouns: They/Them

Re: [ZScript] Hate, a.k.a. Monster targets non-player Actor

Post by Nintolerance »

UPDATE.

Found some fragments of useful information looking through other threads, specifically here:

viewtopic.php?p=981410#p981410

But then that advice (ignore thing_hate, just change monster target directly) is completely contradicted a couple of posts below...

viewtopic.php?p=981433#p981433


...and I'm still no closer to understanding how you'd implement either of those solutions.
Nintolerance
Posts: 3
Joined: Mon Jul 21, 2025 7:31 pm
Preferred Pronouns: They/Them

Re: [ZScript] Hate, a.k.a. Monster targets non-player Actor

Post by Nintolerance »

UPDATE 2:

Some helpful folks on the HDest discord server gave me some advice.

The first piece of advice was using the functions A_CheckProximity or CheckProximity. It seems that the flag CPXF_SETTARGET would do almost exactly what I want: cause a monster to change target to a specific instance of an actor if it's within a radius of said instance when the function is checked.

A second user suggested using the "goal" pointer. I haven't been able to find any documentation on the use of a "goal" pointer, just forum threads mentioning that it exists and a "CHASEGOAL" flag mentioned in passing on the ZDoom wiki.

Seems like using ZScript to directly change a "goal" pointer is the modern ZScript equivalent of using the Thing_SetGoal special(?) in ACS, described (on the wiki) as useful to make monsters patrol between defined points on the map.
Post Reply

Return to “Scripting”