can a monster attack player differently than other monsters?

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
User avatar
bimshwel
Posts: 704
Joined: Tue Jul 15, 2003 5:15 pm
Location: misplaced
Contact:

can a monster attack player differently than other monsters?

Post by bimshwel »

Can a monster check what its target is and do something different accordingly?
the player character in my whatsit is the same type of thing as several of the monsters and their projectiles should not be able to hurt it, and i would like them to be conscious of that and not bother trying to attack from a distance. The most basic solution is to not have them attack from a distance at all, obviously.
Jarewill
 
 
Posts: 1759
Joined: Sun Jul 21, 2019 8:54 am

Re: can a monster attack player differently than other monst

Post by Jarewill »

So the player is the same class as the monster?
But does it still by any chance inherit from PlayerPawn?

I know in ZScript you can check if the monster's target has a class of PlayerPawn, (or inherits from it) like this:

Code: Select all

If(Invoker.target is "PlayerPawn")
I don't know if there's a way to check specifically for the player though.

Still, here is an example usage:
Spoiler:
User avatar
bimshwel
Posts: 704
Joined: Tue Jul 15, 2003 5:15 pm
Location: misplaced
Contact:

Re: can a monster attack player differently than other monst

Post by bimshwel »

ah that should work, I think, thank you! I always get held up on "if/then" sorts of things. I did not know it was possible to have the player be the same class as a monster; in this case they would just be said to be the same things.
Jarewill
 
 
Posts: 1759
Joined: Sun Jul 21, 2019 8:54 am

Re: can a monster attack player differently than other monst

Post by Jarewill »

bimshwel wrote:I did not know it was possible to have the player be the same class as a monster;
Neither did I, that's why I was confused actually.
Post Reply

Return to “Scripting”