Mods / Expanded Ai Tasks Code Library and Loader Mod

Category: #Creatures #Utility
Author: Grifthegnome
Side: Both
Created: Mar 28th at 12:30 AM
Last modified: May 1st at 3:04 AM
Downloads: 493
Follow Unfollow 2

This is a mod that makes the custom Ai Tasks used by Outlaw Mod available to the community.

This mod pack contains both the ExpandedAiTasks.dll and the ExpandedAiTasksLoader Mod.

If you are intrested in using this .dll for your mod, please read the include readme for implementation and compatibility details.


This contains all the currently available aiTasks written for Outlaw Mod. I use this in Outlaw Mod to make archer enemies that can lead their targets and engage the player at ranges greater than any current Ai in the vanilla game. As I add and test new aiTasks in Outlaw Mod, I will release them here so that anyone can use them.

At the moment, this libary contains the following functionality:

Shoot Projectile 

  • Create AI that can shoot any any projectile in the game at a target, with support for leading targets, arcing shots properly over distance, accuracy fall off from range, time to zero new target, damage falloff over range, friendly fire prevention, and much, much more.

Pursue, Engage, and Withdraw

  • Create Ai that can pursue and engage targets. They will chase opponents at one speed, but then slow down to actually fight them. When they don't have a path to target, they will withdraw to a safe distance and wait for the opportunity to attack.
  • You will find their responsiveness to hostiles is way more responsive than the base game and they can also switch targets rapidly mid-combat when they take damage.
  • You can also have your AI make decisions as a pack and only attack targets they think they can overpower as a group. This allows you to make Ai that are only agressive when they have a numerical advantage.

Stay Near Herd/Squad

  • You can make the your Ai travel the world in groups or evenn attempt to maintain group cohesion during combat.
  • This system appoints a squad leader that acts as the anchor for a group of Ai.
  • Members of the group will always return to the squad leader if they wander too far. Even if they get seperated by hundreds of blocks.
  • When the squad leader is killed a new one is appointed from the surviving group members.
  • When two underpowered squads with compatible members meet, they will merge into one squad to become a more effective fighting force.

Morale System

  • You can make Ai that considers both group and individual morale when deciding when to run from a fight. This gives you a powerful interface for player vs Ai and Ai vs Ai encounters.
  • The Ai will know whether their group is winning or losing the current fight.
  • They consider things like group health, friendly and enemy losses, whether they are outnumbered or have a numerical advantage, and whether there are items or objects that frighten them present on the battlefield.
  • This allows you to easily implement features such as making animals afriad of torches.
  • You can make hero character who inspires their squad members in battle, making them less likely to run.
  • You could make a vampire enemy who is afraid of garlic and crosses. 
  • You could also make an Ai that is more confident in battle when the player is holding a carrot in their hands, for some reason. The power is yours!

Guard Target

  • Create Ai that guard another creature. 
  • This guard task handles attacks from other AI and players as well as players getting too close to the guard target.
  • Because this task delegates its resolution to the Pursue, Engage, and Withdraw, Enhanced Melee, and Shoot Projectile tasks, you have a lot of power over how your Ai responds to a threat on its guard target.

Eat Dead Creatures

  • You can make Ai that is attracted to dead creatures in the environment and then eats or harvests them down to a skeleton.
  • You can make it so that the longer the creature has been dead, the farther the Ai can smell it from.
  • You can even make horrible monsters that will eat their own dead squad members.

Enhanced Melee

  • Enhanced Melee is currenly similar to the base-melee attack ai task, but it does have some useful features.
  • It prevents creatures from attacking their squad members if they happen to take friendly-fire damage.

ExpandedAiTasksLoader Mod

  • This is a simple mod, configured for people who aren't big on coding, that registers and loads the aiTasks so that you can use them in your ai files.
  • Note that if you rely on this mod to load the aiTasks for you, players who play your mod will also need the loader mod.


If you have any questions about what this mod is, what it does, or how to get it working with your mod. Drop a comment here and I'll help as best I can.

If you want to see these ai tasks in action check out Outlaw Mod here:

Version For Game version Downloads Release date Changelog Download
v1.0.3 165 May 1st at 3:04 AM Show
v1.0.2 87 Apr 30th at 7:54 PM Show
v1.0.1 100 Apr 27th at 3:02 AM Show
v1.0.0 141 Mar 28th at 12:32 AM Show

4 Comments (oldest first | newest first)

💬 YourCreator, Jun 8th at 12:27 PM

Pls add quests system (it can be very simple, like walk&do&gimme loot). 

💬 Grifthegnome, Apr 30th at 8:00 PM

Expanded Ai Tasks 1.0.2 is now live.

It contains a bug fix for a crash in the morale system caused by invalid item stacks.

💬 Grifthegnome, Apr 27th at 3:04 AM

A new verion of Expanded Ai Tasks Code Library and Loader is now available!

This version includes all the new Custom Ai Tasks added for the 1.1.1 version of outlaw mod. 

💬 Grifthegnome, Apr 4th at 8:32 PM

The next version of ExpandedAITasks will be released along side Outlaw Mod 1.1.1. This will include several new Ai Tasks Including: PursueAndEngageEntity, EatDeadEntities, and StayCloseToHerd.

As a quick note: I realized that the README file for 1.0.0 of Expanded Ai Tasks is the Outlaw Mod Readme and Not the ExpandedAiTasks Readme, Sorry!

This is the intended readme for anyone intrested, the read me will be corrected in the next version of the mod:

Hi! Welcome to the Expanded Ai Tasks Loader Mod Readme and thanks for downloading.

This mod acts as a shared loader for the ExpandedAiTasks.dll that accompanies it.
The .dll adds aiTasks that I use to develop my mods that the base game doesn't support natively.

Getting Started:


1. Just put the zip file in your mods folder, like any other mod.
2. You're good to go!


If you're planning on integrating tasks from ExpandedAiTasks.dll into your mod there are two ways of doing it:
1. Using this Loader Mod.
2. Doing your own .dll integration.

There are pros and cons to both approaches:
The Loader Mod Method:
In this method, you let this mod do the heavy lifting for you. You simply reference the AiTasks it registers.
1. If you use this loader mod, you don't have to write any code, your mod can just reference the AiTasks in your .json files and it will work.
2. You don't have to worry about compatibility with any other mod that also uses the loader mod, since all the AiTasks are registered in the same place.
1. Your mod won't work properly if players don't have the ExpandedAiTasksLoader mod installed. You'll have to point people to this mod and tell them to download it so
they will have the AiTasks registered when you reference them. (i.e. Your mod won't be a standalone mod).

Doing your own .dll integration:
In this method, You include the ExpandedAiTasks.dll in your project and register it's AiTasks in your Core ModSystem.
1. You have total control over what is and is not registered from the .dll.
2. Your mod is totally self-contained and people won't need to download the loader for your mod to work.
1. You are entirely responsible for compatibility between your mod and other mods that use these AiTasks.
That is to say, if two different mods register the same AiTask, they will crash the engine. So you have to make sure you don't double register.


Integrating ExpandedAiTasks.dll into your mod

1. Add ExpandedAiTasks.dll as a reference to your project.
2. In your Core ModSystem .cs file include 'using ExpandedAiTasks;'
3. In your Core ModSystem class, on server and client start up:
a. Register the AiTasks you want to use.
b. Be sure to enclose each AiTask registration in a statement that checks whether or not this task has already been registered by another system.
c. Be sure to register your AiTask under the same key as is used by the loader mod. That way if the player has the loader mod present in their folder,
your mod will defer to its registration while still maintaining a self-contained and independent registration of the tasks.


if (!AiTaskRegistry.TaskTypes.ContainsKey("shootatentity") )
AiTaskRegistry.Register("shootatentity", typeof(AiTaskShootProjectileAtEntity));

4. At this point, you should now be able to reference this AiTask in your .json files.
5. When packaging your mod, do not forget to include ExpandedAiTasks.dll in your zip file (Not to be confused with ExpandedAiTasksLoader.dll)


AI Tasks Documentation:

AiTaskShootProjectileAtEntity ( registered as "shootatentity"" )

This AiTask tells an Ai to shoot a specified projectile at a target with the specified settings.

json Settings

int durationMs: The duration of the ranged attack in milliseconds.
int releaseAtMs: The time at which the projectile is fired in milliseconds.
float minDist: The minimum distance at which the attack can occur (measured in blocks).
float maxDist: The maximum distance at which the attack can occur (measured in blocks).
float minRangeDistOffTarget: The projectile's maximum distance off target at minimum range (measured in blocks).
float maxRangeDistOffTarget: The projectile's maximum distance off target at maximum range (measured in blocks).
float maxVelocity: The absolute maximum velocity of the projectile.
float newTargetDistOffTarget: The projectile's maximum distance off target when the shooter has just acquired a new target (measured in blocks).
float newTargetZeroingTime: The time (in seconds) over which a shooter zeros his aim and newTargetDistOffTarget lerps to a value of 0.0.
float damage: How much damage the attack deals when the projectile hits its target.
float damageFalloffPercent: The percent of the damage value that is retained at damageFalloffEndDist.
float damageFalloffStartDist: The distance at which damage begins to falloff (measured in blocks).
float damageFalloffEndDist: The distance at which damage is fully reduced by damageFalloffPercent and will not falloff further (measured in blocks).
string projectileItem: The code of the projectile that this attack will fire.
bool projectileRemainsInWorld: Determines whether or not the projectile will remain in the world after impacting a surface.
float projectileBreakOnImpactChance: The percentage chance that a projectile will break when impacting a surface is projectileRemainInWorld is true.

Use Example from OutlawMod, yeoman-archer.json
code: "shootatentity",
entityCodes: ["player", "drifter-*", "wolf-male", "wolf-female", "hyena-male", "hyena-female", "locust-*", "bear-*", "looter"],
priority: 3.75,
priorityForCancel: 9,
mincooldown: 1000,
maxcooldown: 1500,
maxDist: 32,
minRangeDistOffTarget: 0.25,
maxRangeDistOffTarget: 0.75,
maxVelocity: 1.25,
newTargetDistOffTarget: 0.75,
newTargetZeroingTime: 5.0,
damage: 3.0,
damageFalloffPercent: 0.66,
damageFalloffStartDist: 18,
damageFalloffEndDist: 28,
projectileItem: "arrow-copper",
projectileRemainsInWorld: true,
projectileBreakOnImpactChance: 0.90,
durationMs: 2000,
releaseAtMs: 1000,
seekingRange: 15,
animationSpeed: 1.0,
animation: "bowattack"


(edit comment delete)