Friendly monsters help

Ask about mapping, UDMF, using DoomBuilder/editor of choice, etc, 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.
Post Reply
whirledtsar
Posts: 109
Joined: Mon Mar 12, 2018 10:06 pm

Friendly monsters help

Post by whirledtsar »

I'm experimenting with friendly monsters/NPC's in UDMF but have quickly run into a brick wall. When a monster is tagged or flagged as friendly, they are indeed friendly. But they won't attack back if provoked, like I'd like them to. According to Strife's peasant's decorate, the only way they react is with one punch after being hit before returning to friendliness, which is not ideal. Also THING_HATE won't work on them, so the only way I've found to make them hostile to the player is by changing their APROP_FRIENDLY status to false. This is frustrating because not only must it be executed by a script, but it isn't logically perfect (they will become friendly with non-friendly monsters). The best automatic way I've thought of is to make their pain state execute a script that checks if the player hit them, and then make them not friendly. This isn't perfect because it requires them to have a 100% pain chance. Plus, I'm having trouble actually coding that check anyways (either because I'm a newb to ACS or because it's just not possible).

1. Is there a better way to make it so friendly monsters will automatically become hostile to the player if he hits them?
2. If not, how could I write a script that checks if the actor who caused them pain was the player?
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Friendly monsters help

Post by Arctangent »

[wiki]ZScript virtual functions[/wiki] should be handy here, specifically DamageMobj. It'll allow you to check if the source parameter is a player ( probably through the is special word ) and if so, immediately remove the FRIENDLY flag, though you might want to have some "forgiveness" by only making it occur randomly anyway or by only causing it to happen if the actor takes too much damage from a player so a friendly that gets caught in a rocket or barrel blast by accident won't instantly turn.

Also, you don't need to use ACS to remove an actor's friendliness - direct flag manipulation through ZScript or [wiki]A_ChangeFlag[/wiki] in Decorate will do that just fine.
whirledtsar
Posts: 109
Joined: Mon Mar 12, 2018 10:06 pm

Re: Friendly monsters help

Post by whirledtsar »

Arctangent wrote:[wiki]ZScript virtual functions[/wiki] should be handy here, specifically DamageMobj. It'll allow you to check if the source parameter is a player ( probably through the is special word ) and if so, immediately remove the FRIENDLY flag, though you might want to have some "forgiveness" by only making it occur randomly anyway or by only causing it to happen if the actor takes too much damage from a player so a friendly that gets caught in a rocket or barrel blast by accident won't instantly turn.

Also, you don't need to use ACS to remove an actor's friendliness - direct flag manipulation through ZScript or [wiki]A_ChangeFlag[/wiki] in Decorate will do that just fine.
Thanks. I was hoping to avoid ZScript since I know nothing about it, but oh well.
Post Reply

Return to “Mapping”