[b]Automate micromanagement for pawns when they are drafted, while considering friendly fire avoidance, cover, lines of sight, enemy weapons, and more.[/b]
Heavily inspired by [url=https://steamcommunity.com/sharedfiles/filedetails/?id=1467764609]Search and Destroy[/url] and [url=https://steamcommunity.com/sharedfiles/filedetails/?id=1134165362]Avoid Friendly Fire[/url]
[hr]
Detailed Description
Adds a toggleable gizmo to your pawns when they are drafted. When ON, the pawn will:
[b]If ranged weapon equipped:[/b]
[list]
[*] 1. If mod option "Respect Allowed area" is on, move to allowed area.
[*] 2. If closest hostile is further away than the pawn's weapon range, move towards the closest hostile.
[*] 3A. If a hostile IS within weapon range, the pawn performs a search. The search assigns a score to potentially good positions. The score is based on several things:
[b]• Estimated damage taken from all hostiles:[/b]
- For ranged hostiles, this takes their shooting skill and weapon stats into account, as well as the position's cover, to compute DPS taken (this is totally accurate to what in-game says).
- For melee hostiles, this similarly computes their effective DPS, their distance to the position, and their movement speed, and combines it into a value that is interpreted as DPS taken. This is further multiplied by "Hostile Melee Respect," which can be changed in mod options.
[b]• Estimated effort to get to that position[/b] from where the pawn currently is. This takes the pawn's movement speed into account. This is further multiplied by "Walking distance penalty weight," which can be changed in mod options.
[*] 3B. After a list of positions with scores is generated, final checks are run to find an acceptable one:
• Closest enemy distance is between 2 cells and the pawn's weapon range.
• It's not in the friendly-fire zone.
• It can actually be moved to (not a chair, chunk, etc.) and no other pawn is already pathing there.
• The pawn can actually shoot a hostile from there, without risking friendly fire to other pawns, animals, or mechanoids you own. THIS is where MOST checks fail in practice!
[*] 3C. If no acceptable position is found in the search, the decision on what to do next depends on WHY it didn't find anything. If no hostile was found, it's probably behind a wall, so we just move closer to it. If an angle to shoot a hostile from was found, but there was friendlies in the way, regroup with the others.
[*] 4. If the best position found IS the current position, the pawn will choose a target to shoot. It checks every hostile in range to find the one it has the highest accuracy against, while also not risking friendly fire. If no target is acceptable, the pawn regroups.
[/list]
[b]If melee weapon equipped:[/b]
[list]
[*] 1. If mod option "Respect Allowed area" is on, move to allowed area.
[*] 2. The pawn checks every hostile, starting with the closest. It will move to attack the first one it can reach without going outside its allowed area or entering a friendly-fire zone.
[*] 3. If no acceptable target is found, the pawn regroups with other drafted AI-pawns.
[/list]
[hr]
Player Controls & Options
[b]Pawn-Specific Options Gizmo:[/b]
Adds an additional gizmo for changing a pawn's default behaviour:
[list]
[*] [b]I avoid FF from others[/b]: The pawn will avoid friendly fire zones. Could be useful to turn off for melee pawns who need to charge through a firing line.
[*] [b]Others avoid risking FF on me[/b]: If turned off, other AI-controlled pawns will accept this target potentially being hit by missed shots(friendly fire).
[*] [b]I reposition to minimize damage from enemies[/b]: Default on, but could perhaps be useful to turn off for Minigun wielders that are supposed to hold their ground even if very exposed to enemies
[/list]
[b]Mod Options:[/b]
[list]
[*] [b]Adds a gizmo to most things to tag it as a forced "fake" hostile[/b]. Useful for destroying insect eggs or hives after a big fight.
[*] [b]Ignore fleeing hostiles[/b]. With 3 modes: Never | Ignore when active threats (default) | Always ignore
[*] [b]Enable Friendly Fire avoidance systems[/b]. On by default, if turned off, all friendly fire options will be hidden, and all functionality relating to friendly fire avoidance disabled.
[*] [b]Ignore forced targets while other threats exist[/b]. Off by default
[*] [b]Respect Allowed area[/b]: If on, the AI uses the same "Allowed area" for the pawn as when it's undrafted. Useful for defending a base. (Off by default)
[*] [b]Extinguish fires on burning friends[/b]. With 3 modes: Off | Drafted only(default) | All
[*] [b]Melee pawns behave like bodyguards[/b]: Melee pawns will focus on defense rather than offense. They will try to stay back and out of the way of ranged pawns until enemies get too close
[*] [b]Allow shooting near melee-attacked friends[/b]: If a pawn gets targeted by a nearby hostile using melee-attacks, allow AI-controlled pawns to take risky shots to help. Will show an "Allow FF" text on a pawn when this is activated. (Off by default)
[*] [b]Update interval[/b]: The AI's "reaction time" in ticks (60 = 1 second). Lower is better but more performance intensive.
[*] [b]Number of cells to search[/b]: The budget used in the detailed search (step 3A). Higher is better, but more performance intensive.
[*] [b]Walking distance penalty weight[/b]: How much to prefer staying close to the current position.
[*] [b]Hostile Melee Respect[/b]: Higher values will make ranged pawns stay further away from melee hostiles.
[*] [b]Draw FF-zone[/b]: Visualizes the friendly fire zone for selected pawns.
[*] [b]Draw Search-zone[/b]: Visualizes the area the AI searched for a better spot for selected pawns. [b]Warning: Big performance impact[/b]
[/list]
[hr]
Troubleshooting & FAQ
[b]Q: My pawn isn't shooting at an enemy! Is the AI broken?[/b]
A: Almost certainly not! The AI is extremely cautious and is likely holding fire for a very good reason. The most common reasons are:
[list]
[*] [b]Friendly Fire:[/b] This is the #1 reason. Another friendly pawn or animal is in the potential line of fire. The AI will try to reposition instead of taking a risky shot, but sometimes no angle is found and the pawn will just not shoot. Use the [b]Pawn-Specific Options Gizmo[/b] to change it.
[*] [b]Target is Fleeing:[/b] By default, the AI will ignore fleeing targets to focus on active threats. You can change this in the [b]Mod Options[/b], or select the fleeing enemy and mark them as a "Forced target".
[/list]
[hr]
How to Debug
If you believe you've found a bug or the AI is behaving strangely, you can use these built-in tools to help diagnose the problem.
[list]
[*] [b]Draw Search-zone:[/b] Enable this in the [b]Mod Options[/b]. When you select a pawn, it will draw a colored overlay on all the cells the AI "thought about" when deciding where to move. This can be useful to quickly visualize the situation from the pawns POV.
[*] [b]Pawn Action Log:[/b] This is the most powerful tool. First, enable [b]Developer Mode[/b] in the vanilla game options. A new debug gizmo, "Drafted AI DEBUG: Print PawnLog," will appear on your drafted pawns. Clicking it will print the pawn's last 10 AI decisions to the debug log, explaining why it chose to move, shoot, or wait.
[/list]
If the bug is for a specific pawn, in a specific situation. Clicking "Print PawnLog", copying it from the debug log and paste it to something like [url=https://steamcommunity.com/linkfilter/?u=https%3A%2F%2Fjustpaste.it%2F]https://justpaste.it/[/url] could be of great help to me.
Faster help:
[url=https://steamcommunity.com/linkfilter/?u=https%3A%2F%2Fdiscord.gg%2F9gFq4MqY][img]https://i.imgur.com/KkVmVck.png[/img][/url][discord.gg]
[hr]
Known Limitations
[list]
[*] The AI is optimized for open spaces. In very tight indoor corridors, manual control is often superior.
[/list]
[hr]
If you enjoy this mod, buy me a coffee!
[url=https://steamcommunity.com/linkfilter/?u=https%3A%2F%2Fko-fi.com%2FD1D0140FRD]Support me on Ko-fi[/url][ko-fi.com]