A minion that will target everyone but master in multiplayer

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
Jekyll Grim Payne
 
 
Posts: 1071
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

A minion that will target everyone but master in multiplayer

Post by Jekyll Grim Payne »

So, while solving a different problem I started thinking about the concept of "friendliness" in ZDoom as well as who is whose default target.

As far as I can see, apart from players we only have two sides now:

* +FRIENDLY monsters that won't harm ANY player (including multiplayer, AFAIK) and will only attack -FRIENDLY monsters
* All other actors that harm the player (even a lamp or a barrel will by default shoot a player if they're provided with A_Look and an attack function)

Is there a method to create a 'minion', i.e. a monster that will attack everyone BUT its master, i.e. all monsters AND all players except the player that spawned it? (The method of spawning is irrelevant, but I assume it'd be A_SpawnItemEx.) Or, in a broader sense: is there a way to make an actor attack everyone except ONE specific actor? (Not using TIDs)
User avatar
ramon.dexter
Posts: 1529
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: A minion that will target everyone but master in multipl

Post by ramon.dexter »

According to what's defined on the wiki about the Species actor property, looks like it could do the trick.

Code: Select all

Defines the species the monster belongs to. This determines infighting behavior, since a monster's missile do not inflict harm (except through splash damage) to other monsters belonging to the same species by default.
When used with keys, this property allows for new keys to open the same locks as the keys they are referencing with the property, without the need to redefine the locks to add the new keys. For example, setting the key's species to RedCard will allow it to open locks as if it were a red keycard.
Default is None that makes the game to look up the actor this actor inherits from and has this property set to something else.
But as I read through what you want, the species wont stop these monsters from attacking the same species, so it is just a halfway solution.
User avatar
Jekyll Grim Payne
 
 
Posts: 1071
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: A minion that will target everyone but master in multipl

Post by Jekyll Grim Payne »

I studied species property for quite some time but I don't think it can do that. I only controls who damages whom, not who attacks whom. I don't see a way to use it to create a specific kind of 'friendship'.
User avatar
TheGameratorT
Posts: 63
Joined: Sun Mar 04, 2018 4:42 am
Graphics Processor: nVidia with Vulkan support
Location: Portugal
Contact:

Re: A minion that will target everyone but master in multipl

Post by TheGameratorT »

Using Zscript and acs you could make a state that could change the specie like:

Code: Select all

TNT1 A 0 { Specie = "Master"; }
And then set the minions to not harm the same specie.

ACS would be used to jump to that state and change the specie.

If you still need help PM me on Discord. It's on my profile.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: A minion that will target everyone but master in multipl

Post by Arctangent »

Species has absolutely nothing to do with it. It all has to do with FriendPlayer, which can be modified by AAPTR_FRIENDPLAYER or directly through ZScript. It's also automatically set when a player spawns either a monster or any actor, I forget which, through something like A_SpawnItemEx. Also, if a friendly monster doesn't have a FriendPlayer, it'll automatically set it to the first valid player it can find in order of player number.

With that all said, FriendPlayer is exactly what this stuff is for - to have a player the monster can use as reference for determining whether or not to treat other players as enemies, as well as the player it should try to follow if it has no target. In co-op, this means it's only used for the latter case, but in deathmatch, it'll automatically attack other players, or players on other teams if in teamplay.

Keep in mind, though, that a monster can seemingly start ignoring other actors it considers enemies even though it does consider them enemies. A friendly monster will only naturally change its target when its current one is dead or an enemy hurts it, so one can get stuck trying to get to a target it can't reach or even catch a sight line of. Stuff like ZDoom Wars gets around this by having the monsters regularly check if they have line of sight of their target and to clear it on a random chance if they do not - at which point they'll start following their FriendPlayer around while looking for a new target.

QUICK EDIT: Looking at the ZDoom source code, FriendPlayer is specifically set through A_SpawnProjectile ( to the created actor's target, though only if it has the SPECTRAL flag - probably has to do with SPECTRAL's implementation ) and A_SpawnItemEx ( to the "originator" - aka, either the caller, or if SXF_ORIGINATOR isn't set, the caller's target if is a projectile ). If you're spawning actors through other means, you'll have to manually set FriendPlayer.
User avatar
Jekyll Grim Payne
 
 
Posts: 1071
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: A minion that will target everyone but master in multipl

Post by Jekyll Grim Payne »

Arctangent wrote:Species has absolutely nothing to do with it. It all has to do with FriendPlayer, which can be modified by AAPTR_FRIENDPLAYER or directly through ZScript. It's also automatically set when a player spawns either a monster or any actor, I forget which, through something like A_SpawnItemEx. Also, if a friendly monster doesn't have a FriendPlayer, it'll automatically set it to the first valid player it can find in order of player number.

Ah, that's it! That's what I was talking about. But forgive me if I sound dense, I'm still not sure I understand how I can use it. Let's say I'm using A_SpawnItemEx in a player weapon's Fire state; how exactly would that A_SpawnItemEx need to look in order to spawn a monster that will only consider that player its friend and every other monster and player its enemy?
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: A minion that will target everyone but master in multipl

Post by Arctangent »

It just needs to look like an A_SpawnItemEx call. The only concern is spawning a monster with a player projectile that doesn't keep the player as a target, but you really shouldn't be making projectiles like that in the first place due to that being how a projectile tracks its owner.
User avatar
TheGameratorT
Posts: 63
Joined: Sun Mar 04, 2018 4:42 am
Graphics Processor: nVidia with Vulkan support
Location: Portugal
Contact:

Re: A minion that will target everyone but master in multipl

Post by TheGameratorT »

Oh so that's why with species I was only able to do it with missiles...
Post Reply

Return to “Scripting”