Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Monster Factions and Immediate Monster Infighting

Recommended Posts

Factions for doom:


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


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:

===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
All other code made by scroton, feel free to use for anything.

Share this post

Link to post

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.

Share this post

Link to post

Updated with added ability to specify an enemy faction to limit the search for targets to.

First arg is now enemy faction to check when looking for targets. Needs to be set to -1 or less to check all factions, because factions start at 0.

Like so:
ACS_NamedExecuteWithResult("faction_look", -1, 0, 0, 128)

Share this post

Link to post

Another minor update. Made factions (as far as args passed to scripts are concerned) start at 1 rather than 0. This is so that I can group the enemy faction setting in with the other flags, and not have to have it be negative and thus require users to input -100 for what was default behavior. I wanted to group them together to reduce the args from 4 to 3, so that if using the script via a function where a map would need to be specified, it wouldn't interfere. I might pack the two distance args together later, but since I don't need an extra arg right now I won't. OP has been updated.d

Share this post

Link to post

Those were a lot of words... I got lost about halfway through. So I'm a bit confused here; what does this do? From what I can gleam it makes monsters fight each other based on both arbitrary factions and normal circumstances at map start-up, which seems to only really apply to large-scale encounters for a player to watch/be involved in at the start of a map, as small-scale ones can be easily achieved through other scripts. Am I on the right track here?

Share this post

Link to post

The second version of the file causes immediate infighting between all monsters of different class names, it's more just a gimmick to show something you could do with the first version.

The first is meant to be used for projects. It allows mappers/modders to easily assign monsters to faction. The factions are like having teams for monsters, and depending upon in what monster state you call the faction_look script and what arguments you use it with, you could have them seek out other monsters over a player, seek out players but attack different monsters when they get within a certain range, or vice versa, or one group of monsters attack a different group of monster en masse, but only when one from the one group hits another from the other group. Etc.

Share this post

Link to post

Also forgot to add: you can specify a distance for player proximity required before they activate, meaning you can set up fights the player will encounter throughout the map rather than having most infights done before the player comes across them. The other thing is the ability to specify either each individual monster targeting monsters closest to them or a random target out of the available targets it sees allows you to set up more chaotic fights between groups with monsters from one faction all targeting different monsters from the other faction.

To use examples of how this can be used, from those that requested this ability before this project came about or commented in the zdoom thread:

You could have a faction of zombies and a faction of looters on a map, and have the zombies target the first non-zombie (looter or player) they see, but switch targets if a different non-zombie gets closer than a certain distance, at which point they start shambling after the new target, until they either catch it or another target gets within that distance. You could have the looters never target zombies, until a zombie gets within a certain distance at which point they switch to the zombie (that particular zombie, not the whole faction) that has gotten too close. You could have zombies not target looters more than a certain distance away, but when one in a group gets hit, target a member of that far away group of looters (not necessarily the specific actor that shot a member of the group.)

For a more vanilla example, you could have a group of barons and cacos that do not infight at first, but if one member of a group hits a member of the other group, the entire group with the member that was hit will turn on the other group, with monsters that were not hit targeting enemy factions members that did not hit anything themselves, the idea being that they are rushing to the aid of "their friend" who got hit by "one of those assholes over there."

If there are other scenarios that this can be used for, or used for with a slight bit of modification I'd be happy to explain how to use the scripts to accomplish that or add additional functionality to the project if needed.

The current "immediate infighting" version (the "gimmick version") is borked as of last update. I will fix this sometime this morning when I get back to my PC.

Edit: In case I wasn't clear, fighting with enemy factions happens when the "faction_look" script is called, not at map start.

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now