Monster Factions and Immediate Monster Infighting

Projects that alter game functions but do not include new maps belong here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
User avatar
scroton
Posts: 148
Joined: Sat Apr 27, 2013 10:53 am

Monster Factions and Immediate Monster Infighting

Post by scroton »

Factions for doom:

https://drive.google.com/file/d/0BxbbtK ... sp=sharing

Version which starts infighting between all monsters with different class names as soon as map opens, should work with all mods:

https://drive.google.com/file/d/0BxbbtK ... sp=sharing

Monsters in a faction will select targets to attack monsters in different factions. They will not attack monsters in their own factions or attack monsters that are not in a faction (unless they would otherwise infight normally, eg an imp hits a baron with an impball and they are both in faction 2 or one isn't in any faction; you could prevent this from happening if you didn't want it to with other decorate like +NOINFIGHTING, which won't interfere with the way this works.) The faction_look script can also include players in it's search for targets, though you can also just intersperse it with calls to A_Look to achieve the same effect.

Pastebins for main acs file in both version, if you want to take a look without downloading:
http://pastebin.com/bs8LwPAG
http://pastebin.com/xXLM636b

===How to use in your own projects===

Set faction by running "faction_tid_start" script from decorate, so for instance

ACS_NamedExecuteWithResult("faction_tid_start", 1)

The only argument sent to the script is the faction number.

Factions start at 1, go up to 50 right now or 50 total faction. Have to add more factions in acs, just increase 50 in
#libdefine NUM_FACTIONS 50
which is line 7, to whatever you want.

To have them look for memebers of enemy factions, use "faction_look" script from decorate, so for instance

ACS_NamedExecuteWithResult("faction_look", 0, 0, 0, 128)

Here are the arguments passed to the script:

First arg is combination of enemy faction and the following flags, with player flags first.

--enemy faction is sole to check when looking for targets. Set at 0 to check all enemy factions.

--player flags
0 won't target players
1 process players like other targets
2 prioritize player targets

--target processsing flags
0 pick first valid target
1 pick closest target
2 pick random target from valid targets

So to have the monster target monsters only in faction 5, process players like other targets, and to pick random targets from valid targets, have "512" as the argument passed to the script.

--max distance to look for target, in int. Will be ignored if 0 or less.

--min distance for player, in order to target; it won't pick any targets unless a player is at least this close, in int. Will be ignored if 0 or less.

Both distances are in int, not fixed, since I figured fixed precision isn't necessary and int will be easier for people to read.

commonFuncs made by ijon tichy, updated by marrub.
large radius radius give by Beed28
http://forum.zdoom.org/viewtopic.php?p=845858#p845858
All other code made by scroton, feel free to use for anything.
Last edited by scroton on Tue May 31, 2016 7:37 am, edited 3 times in total.
User avatar
scroton
Posts: 148
Joined: Sat Apr 27, 2013 10:53 am

Re: Monster Factions and Immediate Monster Infighting

Post by scroton »

Updated this.

Changes are:

Instead of having to actually enter arrays in manually to increase number of factions, all you need to do is increase 50 in
#libdefine NUM_FACTIONS 50
which is line 7 in acs, to whatever you want.

Also since I realized I was only using 2 functions from commonFuncs.h I copied them from commonFuncs.h into the main acs file to make it easier on people that aren't used to compiling acs. The functions are the two very first functions and are marked, so if you use commonFuncs.h it will be very easy to remove them before compiling.

The monster infighting verision will also now cause monsters to continually search for new targets even after their first one is dead.

Also deleted a bit of extraneous code, but nothing that will be noticed in-game.

Also updated OP with both versions main acs file, in case you want to take a look but don't want to download.
Miguel371xd
Posts: 136
Joined: Mon Dec 28, 2015 7:04 pm

Re: Monster Factions and Immediate Monster Infighting

Post by Miguel371xd »

I tried this with different mods that add new enemies and there are times when they do not kill each other for example an zombie man not attacking a pinky demon , I tried this with aeons of death and scalliano shuffle addon
User avatar
scroton
Posts: 148
Joined: Sat Apr 27, 2013 10:53 am

Re: Monster Factions and Immediate Monster Infighting

Post by scroton »

If you are using the the regular version, the only things that get factions are zombiemen, shotgunguys, and imps. They're there for demonstration purposes to use in your own work.

For the infighting version, the checksight checks sometimes don't return true, which is something that can't really be fixed in acs.

EDIT: It may also be that there are more classes than 50 active in the map at a time, which would mean that some monsters aren't getting a faction. Try increasing the faction amount in acs and compiling, just increase 50 in
#libdefine NUM_FACTIONS 50
which is line 7, to whatever you want.
Miguel371xd
Posts: 136
Joined: Mon Dec 28, 2015 7:04 pm

Re: Monster Factions and Immediate Monster Infighting

Post by Miguel371xd »

Thanks, but I do not understand much of "acs" I'm noob in this :?
User avatar
scroton
Posts: 148
Joined: Sat Apr 27, 2013 10:53 am

Re: Monster Factions and Immediate Monster Infighting

Post by scroton »

Miguel371xd
Posts: 136
Joined: Mon Dec 28, 2015 7:04 pm

Re: Monster Factions and Immediate Monster Infighting

Post by Miguel371xd »

oh....thx :o sorry for bothering
User avatar
scroton
Posts: 148
Joined: Sat Apr 27, 2013 10:53 am

Re: Monster Factions and Immediate Monster Infighting

Post by scroton »

NP!
Miguel371xd
Posts: 136
Joined: Mon Dec 28, 2015 7:04 pm

Re: Monster Factions and Immediate Monster Infighting

Post by Miguel371xd »

sorry for bothering again but it is normal that the enemies of the same class to kill each other? I just saw now this with aeons of death
User avatar
scroton
Posts: 148
Joined: Sat Apr 27, 2013 10:53 am

Re: Monster Factions and Immediate Monster Infighting

Post by scroton »

If they can harm each other, then then will infight. For instance zombiemen.

They may also be different classes but look the same.
Miguel371xd
Posts: 136
Joined: Mon Dec 28, 2015 7:04 pm

Re: Monster Factions and Immediate Monster Infighting

Post by Miguel371xd »

Thank you! but it is normal two of the same class soar among them with no reason? (sorry my english)
User avatar
scroton
Posts: 148
Joined: Sat Apr 27, 2013 10:53 am

Re: Monster Factions and Immediate Monster Infighting

Post by scroton »

Are they the same exact actor? Or do they just look the same with different class names?
try going into the console and typing "faction_debug_msg 1"
and then check the console to see what class names are targetting which class names
Miguel371xd
Posts: 136
Joined: Mon Dec 28, 2015 7:04 pm

Re: Monster Factions and Immediate Monster Infighting

Post by Miguel371xd »

and then I put "faction_debug_msg 1" without any mod and it's all good... and I realized something for example an imp when just killed a Zombieman the imp and not seek more enemies and this happens with all
User avatar
TheRailgunner
Posts: 1556
Joined: Mon Jul 08, 2013 10:08 pm

Re: Monster Factions and Immediate Monster Infighting

Post by TheRailgunner »

Is there a way to activate this on a small scale (a group of monsters in a room) when a monster accidentally hurts another of a different class? The idea is that if, say, a zombieman shoots one imp in a group of imps, the entire group would retaliate, and then turn their attention to the player (if more than one zombie is involved, this sort of set up would lead to both groups fighting until only a single group remains, since the imps' counterattacks towards the first zombie would cause the zombies around him to retaliate in turn). This seems like the closest thing to what I want to accomplish, but I don't want, say, all imps on a map to become hostile to all zombies, or for imps and zombies to hate each other from the moment the player enters the map - the goal is localized group infighting.
User avatar
scroton
Posts: 148
Joined: Sat Apr 27, 2013 10:53 am

Re: Monster Factions and Immediate Monster Infighting

Post by scroton »

Miguel371xd wrote:and then I put "faction_debug_msg 1" without any mod and it's all good... and I realized something for example an imp when just killed a Zombieman the imp and not seek more enemies and this happens with all
All of them will just go back to whatever spawn state they have defined, if they don't see the player they will just stay there.
The immediate infighting version doesn't change any monsters in decorate.
TheRailgunner wrote:Is there a way to activate this on a small scale (a group of monsters in a room) when a monster accidentally hurts another of a different class? The idea is that if, say, a zombieman shoots one imp in a group of imps, the entire group would retaliate, and then turn their attention to the player (if more than one zombie is involved, this sort of set up would lead to both groups fighting until only a single group remains, since the imps' counterattacks towards the first zombie would cause the zombies around him to retaliate in turn). This seems like the closest thing to what I want to accomplish, but I don't want, say, all imps on a map to become hostile to all zombies, or for imps and zombies to hate each other from the moment the player enters the map - the goal is localized group infighting.
There are a couple of ways to do this.

The thing you want to do is create decorate or acs that causes monsters of the same type to enter a state where they call the "faction_look" script. Monsters will pick a target from an enemy faction only when that script is called, and will only ever target enemy monsters they can see. If they can't see an enemy monster, they won't pick a target, and not picking a target won't override their current target.

Give the zombieman a particular damagetype and have a painstate for the imp that has an a_radiusgive that gives an item that has the "faction_look" script in the pickup state. Or use an explosion/painstate instead of a_radiusgive to do the same thing.

Or have monsters call a looping script upon spawn that checks what their target is, and if it's another monster, gives them a dummy item that has a_radiusgive in the pickup state that radiusgives items that call the script in their pickup state.

In either case you'd want to put in limits, especially in the painstate one, to prevent monsters from getting locked into the first few tics of a state. The acs version is probably the easiest to do this with; once it detects the monster target have it delay for a minute or more before checking anything again.

EDIT: Realized you'd need a way to specify an enemy faction to check only, so added it in to the OP.
Last edited by scroton on Mon May 30, 2016 10:09 pm, edited 1 time in total.
Post Reply

Return to “Gameplay Mods”