Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #93

Merged
merged 44 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
440ffea
ThingComp_PostDraw for pawns in fogged area won't be called.
kbatbouta Feb 28, 2023
c3a38fc
lots of changes geared towards performance
kbatbouta Mar 1, 2023
433c51c
Better caching for damage and armor reports
kbatbouta Mar 1, 2023
1c2845a
Update CombatAI.dll
kbatbouta Mar 1, 2023
058b3b1
Fixed a bug with fire and sapping
kbatbouta Mar 2, 2023
32fe3d7
Added confidence metrics
kbatbouta Mar 2, 2023
abc77bc
add moved bias when allies are providing covering fire
kbatbouta Mar 2, 2023
da29e56
Fixes
kbatbouta Mar 2, 2023
b55430d
fixes to fog of war
kbatbouta Mar 2, 2023
72a4656
improved fog of war fix
kbatbouta Mar 2, 2023
6430585
improved the squad system
kbatbouta Mar 2, 2023
e0fe720
..
kbatbouta Mar 2, 2023
a081252
Improved escorting
kbatbouta Mar 3, 2023
26d7683
Update to squads
kbatbouta Mar 3, 2023
d4ae211
Further improvements to squads
kbatbouta Mar 3, 2023
cc07571
reverted squad changes
kbatbouta Mar 3, 2023
b2fe829
Implemented group pathing
kbatbouta Mar 3, 2023
eeb232f
Initial changes
kbatbouta Mar 8, 2023
bd6db80
..
kbatbouta Mar 8, 2023
bd44839
Added support for mech tunneler
kbatbouta Mar 8, 2023
6edbd85
Fixed an issue with prisoners trying to dig
kbatbouta Mar 9, 2023
c53fd8a
Increased sightradius capacity mul
kbatbouta Mar 10, 2023
e24338d
Muzzle flash reveals fog of war
kbatbouta Mar 14, 2023
2bd1b43
Merge pull request #84 from kbatbouta/development-maintenance
kbatbouta Mar 14, 2023
0b3e0d0
Settings upgrade and FoW fixes
kbatbouta Mar 15, 2023
62ca8bf
fixes
kbatbouta Mar 15, 2023
3922e39
Improvements to the update rate
kbatbouta Mar 15, 2023
a5efe87
Small update
kbatbouta Mar 22, 2023
426206e
fog of war improvements
kbatbouta Mar 22, 2023
3128cc0
Add tech level faction settings.
kbatbouta Mar 23, 2023
a501638
Added faction personalities
kbatbouta Mar 23, 2023
bdc2741
Added ranged sapping, mech sapping and general bug fixes.
kbatbouta Mar 25, 2023
d092eb8
Performance improvements while in combat.
kbatbouta Mar 25, 2023
210908d
Small fixes
kbatbouta Mar 26, 2023
20fc494
Fix threading issues
m00nl1ght-dev May 19, 2023
b73ff25
Update AsyncActions.cs
kbatbouta May 19, 2023
aaaee10
Merge pull request #87 from m00nl1ght-dev/threading-fixes
kbatbouta May 19, 2023
4fba3f0
Fixed an issue with vehicle framework
kbatbouta Oct 1, 2023
668de5d
Implemented new race settings
kbatbouta Oct 28, 2023
c14aa56
Introduced support for zombieLand
kbatbouta Dec 15, 2023
ed7b8fd
Fixed a small settings bug
kbatbouta Dec 15, 2023
1bbe6e7
Debug dll
kbatbouta Dec 17, 2023
c29a988
Major CAI cleanup
kbatbouta Dec 24, 2023
a890980
Merge pull request #92 from kbatbouta/development-settings-upgrade
kbatbouta Dec 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified 1.4/Assemblies/CombatAI.dll
Binary file not shown.
49 changes: 41 additions & 8 deletions 1.4/Defs/DutyDefs/Duties_Misc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@
<li Class="JobGiver_TakeCombatEnhancingDrug">
<onlyIfInDanger>true</onlyIfInDanger>
</li>
<li Class="CombatAI.ThinkNode_ConditionalReacted">
<ticks>900</ticks>
<subNodes>
<li Class="JobGiver_AIFightEnemies">
<targetAcquireRadius>35</targetAcquireRadius>
<targetKeepRadius>42</targetKeepRadius>
</li>
</subNodes>
</li>
<li Class="JobGiver_AIDefendPoint">
<targetAcquireRadius>65</targetAcquireRadius>
<targetKeepRadius>72</targetKeepRadius>
</li>
</li>
<li Class="ThinkNode_ForbidOutsideFlagRadius">
<maxDistToSquadFlag>16</maxDistToSquadFlag>
<subNodes>
Expand All @@ -23,7 +32,7 @@
</subNodes>
</li>
<li Class="JobGiver_WanderNearDutyLocation">
<wanderRadius>32</wanderRadius>
<wanderRadius>12</wanderRadius>
<locomotionUrgencyOutsideRadius>Sprint</locomotionUrgencyOutsideRadius>
</li>
<li Class="JobGiver_AITrashBuildingsDistant">
Expand All @@ -45,9 +54,21 @@
<li Class="JobGiver_TakeCombatEnhancingDrug">
<onlyIfInDanger>true</onlyIfInDanger>
</li>
<li Class="ThinkNode_Subtree" MayRequire="Ludeon.RimWorld.Biotech">
<treeDef>Abilities_Aggressive</treeDef>
</li>
<li Class="CombatAI.ThinkNode_ConditionalReacted">
<ticks>900</ticks>
<subNodes>
<li Class="JobGiver_AIFightEnemies">
<targetAcquireRadius>35</targetAcquireRadius>
<targetKeepRadius>42</targetKeepRadius>
</li>
</subNodes>
</li>
<li Class="JobGiver_AIDefendPoint">
<targetAcquireRadius>65</targetAcquireRadius>
<targetKeepRadius>72</targetKeepRadius>
<targetAcquireRadius>32</targetAcquireRadius>
<targetKeepRadius>28</targetKeepRadius>
</li>
<li Class="ThinkNode_ForbidOutsideFlagRadius">
<maxDistToSquadFlag>16</maxDistToSquadFlag>
Expand All @@ -59,6 +80,7 @@
</li>
<li Class="JobGiver_WanderNearDutyLocation">
<wanderRadius>8</wanderRadius>
<expiryInterval>30</expiryInterval>
<locomotionUrgencyOutsideRadius>Sprint</locomotionUrgencyOutsideRadius>
</li>
<li Class="JobGiver_AITrashBuildingsDistant">
Expand All @@ -78,17 +100,28 @@
<li Class="JobGiver_TakeCombatEnhancingDrug">
<onlyIfInDanger>true</onlyIfInDanger>
</li>
<li Class="CombatAI.ThinkNode_ConditionalReacted">
<ticks>900</ticks>
<subNodes>
<li Class="JobGiver_AIFightEnemies">
<targetAcquireRadius>35</targetAcquireRadius>
<targetKeepRadius>42</targetKeepRadius>
</li>
</subNodes>
</li>
<li Class="JobGiver_AIDefendEscortee">
<targetAcquireRadius>65</targetAcquireRadius>
<targetAcquireRadius>35</targetAcquireRadius>
<targetKeepRadius>72</targetKeepRadius>
</li>
<li Class="JobGiver_AIFollowEscortee"/>
</li>
<li Class="CombatAI.JobGiver_CAIFollowEscortee"/>
<li Class="ThinkNode_Subtree">
<treeDef>SatisfyVeryUrgentNeeds</treeDef>
</li>
<li Class="JobGiver_WanderNearDutyLocation">
<wanderRadius>8</wanderRadius>
</li>
<expiryInterval>60</expiryInterval>
<locomotionUrgencyOutsideRadius>Jog</locomotionUrgencyOutsideRadius>
</li>
<li Class="JobGiver_AITrashBuildingsDistant">
<attackAllInert>true</attackAllInert>
</li>
Expand Down
2 changes: 1 addition & 1 deletion 1.4/Defs/Jobs/Jobs_Misc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<defName>CombatAI_Goto_Cover</defName>
<driverClass>JobDriver_Goto</driverClass>
<reportString>moving.</reportString>
<allowOpportunisticPrefix>true</allowOpportunisticPrefix>
<allowOpportunisticPrefix>false</allowOpportunisticPrefix>
<carryThingAfterJob>true</carryThingAfterJob>
<dropThingBeforeJob>false</dropThingBeforeJob>
<checkOverrideOnDamage>Never</checkOverrideOnDamage>
Expand Down
17 changes: 17 additions & 0 deletions 1.4/Languages/English/Keyed/Translations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<CombatAI.Hide>Hide</CombatAI.Hide>
<CombatAI.Expand>Hide</CombatAI.Expand>
<CombatAI.Quick.Welcome>Welcome to CAI-5000</CombatAI.Quick.Welcome>
<CombatAI.DefKindSettings.Title>AI Race Settings</CombatAI.DefKindSettings.Title>
<CombatAI.DefKindSettings.Description>Here you can configure different AI settings for each race.</CombatAI.DefKindSettings.Description>
<CombatAI.DefKindSettings.Selected>Selected</CombatAI.DefKindSettings.Selected>
<CombatAI.Gizmos.AttackMove>Move-Attack</CombatAI.Gizmos.AttackMove>
<CombatAI.Gizmos.AttackMove.Warning>Warning: Melee pawns cannot use move-attack. Melee pawns skipped.</CombatAI.Gizmos.AttackMove.Warning>
<CombatAI.Gizmos.AttackMove.Cancel>Cancel Move-Attack</CombatAI.Gizmos.AttackMove.Cancel>
Expand All @@ -21,6 +24,7 @@
<CombatAI.Animator.Controller>Hold</CombatAI.Animator.Controller>
<CombatAI.Animator.Controller.Description>Hold at the current angle.</CombatAI.Animator.Controller.Description>
<CombatAI.Settings.Basic>Basic Settings</CombatAI.Settings.Basic>
<CombatAI.Settings.Basic.RandomizedPersonality>Enable variation in faction tactics depending on the faction leader and the current time of year</CombatAI.Settings.Basic.RandomizedPersonality>
<CombatAI.Settings.Basic.Presets>Performance/Difficulty presets</CombatAI.Settings.Basic.Presets>
<CombatAI.Settings.Basic.Presets.Easy>Easy/Perf</CombatAI.Settings.Basic.Presets.Easy>
<CombatAI.Settings.Basic.Presets.Normal>Normal</CombatAI.Settings.Basic.Presets.Normal>
Expand All @@ -37,6 +41,8 @@
<CombatAI.Settings.Basic.SappingMul.Description>Cost multiplier for pathing through walls. Higher values means raiders are less likely to path through walls.</CombatAI.Settings.Basic.SappingMul.Description>
<CombatAI.Settings.Basic.FogOfWar>[BETA] Fog of war</CombatAI.Settings.Basic.FogOfWar>
<CombatAI.Settings.Basic.FogOfWar.Enable>Enable fog of war</CombatAI.Settings.Basic.FogOfWar.Enable>
<CombatAI.Settings.Basic.FogOfWar.OldShader>Use the old legacy shader</CombatAI.Settings.Basic.FogOfWar.OldShader>
<CombatAI.Settings.Basic.FogOfWar.OldShader.Restart>The new shader settings will be applied after restart!</CombatAI.Settings.Basic.FogOfWar.OldShader.Restart>
<CombatAI.Settings.Basic.FogOfWar.Allies>Allies reveal fog of war</CombatAI.Settings.Basic.FogOfWar.Allies>
<CombatAI.Settings.Basic.FogOfWar.Animals>Colony animals reveal fog of war</CombatAI.Settings.Basic.FogOfWar.Animals>
<CombatAI.Settings.Basic.FogOfWar.Animals.SmartOnly>Only smart animals reveal fog of war</CombatAI.Settings.Basic.FogOfWar.Animals.SmartOnly>
Expand Down Expand Up @@ -64,6 +70,8 @@
<CombatAI.Settings.Debugging>Debugging</CombatAI.Settings.Debugging>
<CombatAI.Settings.Debugging.Enable>Enable Debugging</CombatAI.Settings.Debugging.Enable>
<CombatAI.Settings.Advance>Advance Settings</CombatAI.Settings.Advance>
<CombatAI.Settings.Advance.SquadPathWidth>Avoidance path width. Avoidance path width determine flanking aggressiveness.</CombatAI.Settings.Advance.SquadPathWidth>
<CombatAI.Settings.Advance.SquadPathWidth.Description>Path width {0} cells (default: 1)</CombatAI.Settings.Advance.SquadPathWidth.Description>
<CombatAI.Settings.Advance.Warning>WARNING: This is only for advanced users! Don't enable this if you don't know what you're doing!</CombatAI.Settings.Advance.Warning>
<CombatAI.Settings.Advance.Enable>I'm an advanced user!</CombatAI.Settings.Advance.Enable>
<CombatAI.Settings.Advance.Sight.Performance>Performance</CombatAI.Settings.Advance.Sight.Performance>
Expand All @@ -77,4 +85,13 @@
<CombatAI.Settings.Advance.Sight.Performance.Readouts.Interval>Ticks between bucket updates {0} Ticks</CombatAI.Settings.Advance.Sight.Performance.Readouts.Interval>
<CombatAI.Settings.Advance.Sight.Performance.Readouts.CarryLimit>{0} Things maximum can obstuct line of sight</CombatAI.Settings.Advance.Sight.Performance.Readouts.CarryLimit>
<CombatAI.Settings.Advance.Sight.Performance.Readouts.CarryLimit.Description>The maximum number of things along line of sight. This includes trees, buildings, etc. Higher values means more accurate sight model but higher performance impact.</CombatAI.Settings.Advance.Sight.Performance.Readouts.CarryLimit.Description>
<CombatAI.Settings.FactionTech>Faction Tech Level Settings</CombatAI.Settings.FactionTech>
<CombatAI.Settings.FactionTech.Desciption>Here you can configure factions with different tech levels.</CombatAI.Settings.FactionTech.Desciption>
<CombatAI.Settings.FactionTech.Tech>Tech {0}</CombatAI.Settings.FactionTech.Tech>
<CombatAI.Settings.FactionTech.Duck>Duck {0}x. Higher values means more likely to duck for cover</CombatAI.Settings.FactionTech.Duck>
<CombatAI.Settings.FactionTech.Retreat>Retreat {0}x. Higher values means more likely to retreat</CombatAI.Settings.FactionTech.Retreat>
<CombatAI.Settings.FactionTech.Cover>Cover {0}x. Higher values means more aggressive cover</CombatAI.Settings.FactionTech.Cover>
<CombatAI.Settings.FactionTech.Pathing>Pathing {0}x. Higher values means more aggressive pathing</CombatAI.Settings.FactionTech.Pathing>
<CombatAI.Settings.FactionTech.Sapping>Sapping {0}x. Higher values means less aggressive sapping</CombatAI.Settings.FactionTech.Sapping>
<CombatAI.Settings.FactionTech.Group>Charge {0}x. Higher values means groups are more likely to charge</CombatAI.Settings.FactionTech.Group>
</LanguageData>
1 change: 1 addition & 0 deletions About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<li>Ludeon.RimWorld.Royalty</li>
<li>brrainz.harmony</li>
<li>zetrith.prepatcher</li>
<li>owlchemist.simplefx.vapor</li>
<li>CETeam.CombatExtended</li>
</loadAfter>
<loadBefore>
Expand Down
10 changes: 9 additions & 1 deletion Source/Rule56/ArmorUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static ArmorReport GetArmorReport(this Pawn pawn, Listing_Collapsible col
{
return default(ArmorReport);
}
if (collapsible != null || !reports.TryGetValue(pawn.thingIDNumber, out ArmorReport report) || GenTicks.TicksGame - report.createdAt > 900)
if (collapsible != null || !reports.TryGetValue(pawn.thingIDNumber, out ArmorReport report) || GenTicks.TicksGame - report.createdAt > 7200)
{
reports[pawn.thingIDNumber] = report = CreateReport(pawn, collapsible);
}
Expand Down Expand Up @@ -179,5 +179,13 @@ public float Coverage(ApparelProperties apparel)
return coverage;
}
}

public static void Invalidate(Thing thing)
{
if (reports.ContainsKey(thing.thingIDNumber))
{
reports.Remove(thing.thingIDNumber);
}
}
}
}
32 changes: 26 additions & 6 deletions Source/Rule56/AsyncActions.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Verse;
namespace CombatAI
{
public class AsyncActions
{

private static readonly List<AsyncActions> running = new List<AsyncActions>();

private readonly int hashOffset;

public readonly object locker_Main = new object();
public readonly object locker_offMain = new object();
private readonly int mainLoopTickInterval;

private readonly List<Action> queuedMainThreadActions = new List<Action>();
private readonly List<Action> queuedOffThreadActions = new List<Action>();
private readonly Thread thread;
private bool mainThreadActionQueueEmpty;
private readonly List<Action> queuedMainThreadActions = new List<Action>();
private readonly List<Action> queuedOffThreadActions = new List<Action>();
private readonly AutoResetEvent waitHandle = new AutoResetEvent(false);
private readonly Thread thread;
private bool mainThreadActionQueueEmpty;

public AsyncActions(int mainLoopTickInterval = 5)
{
Expand All @@ -34,6 +37,7 @@ public bool Alive
public void Start()
{
thread.Start();
running.Add(this);
}

public void ExecuteMainThreadActions()
Expand All @@ -44,6 +48,7 @@ public void ExecuteMainThreadActions()
public void Kill()
{
Alive = false;
running.Remove(this);
try
{
lock (locker_Main)
Expand All @@ -55,12 +60,22 @@ public void Kill()
queuedOffThreadActions.Clear();
}
thread.Abort();
thread.Join(100);
waitHandle.Close();
}
catch (Exception)
{
}
}

public static void KillAll()
{
foreach (AsyncActions asyncActions in running.ToList())
{
asyncActions.Kill();
}
}

public void EnqueueOffThreadAction(Action action)
{
lock (locker_offMain)
Expand All @@ -72,6 +87,7 @@ public void EnqueueOffThreadAction(Action action)
else
{
queuedOffThreadActions.Add(action);
waitHandle.Set();
}
}
}
Expand Down Expand Up @@ -151,14 +167,18 @@ private void OffMainThreadActionLoop()
{
action();
}
catch (ThreadAbortException)
{
throw;
}
catch (Exception er)
{
Log.Error(er.ToString());
}
}
else
{
Thread.Sleep(1);
waitHandle.WaitOne();
}
}
}
Expand Down
Loading
Loading