Skip to content

Commit

Permalink
Merge pull request #66 from kbatbouta/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
kbatbouta authored Feb 23, 2023
2 parents 14310fc + f3368c4 commit fcb16ba
Show file tree
Hide file tree
Showing 86 changed files with 5,108 additions and 1,772 deletions.
Binary file added 1.4/Assemblies/0PrepatcherAPI.dll
Binary file not shown.
Binary file modified 1.4/Assemblies/CombatAI.dll
Binary file not shown.
101 changes: 101 additions & 0 deletions 1.4/Defs/DutyDefs/Duties_Misc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<DutyDef>
<defName>CombatAI_AssaultPoint</defName>
<alwaysShowWeapon>true</alwaysShowWeapon>
<thinkNode Class="ThinkNode_Priority">
<!-- Todo here - if outside of duty radius, go to within duty radius-->
<!-- Currently this is handled by a hack in JobGiver_AIFightBase-->
<subNodes>
<li Class="JobGiver_TakeCombatEnhancingDrug">
<onlyIfInDanger>true</onlyIfInDanger>
</li>
<li Class="JobGiver_AIDefendPoint">
<targetAcquireRadius>65</targetAcquireRadius>
<targetKeepRadius>72</targetKeepRadius>
</li>
<li Class="ThinkNode_ForbidOutsideFlagRadius">
<maxDistToSquadFlag>16</maxDistToSquadFlag>
<subNodes>
<li Class="ThinkNode_Subtree">
<treeDef>SatisfyBasicNeedsAndWork</treeDef>
</li>
</subNodes>
</li>
<li Class="JobGiver_WanderNearDutyLocation">
<wanderRadius>8</wanderRadius>
<locomotionUrgencyOutsideRadius>Sprint</locomotionUrgencyOutsideRadius>
</li>
<li Class="JobGiver_AITrashBuildingsDistant">
<attackAllInert>true</attackAllInert>
</li>
<li Class="JobGiver_AITrashColonyClose" />
<li Class="JobGiver_AITrashBuildingsDistant" />
</subNodes>
</thinkNode>
</DutyDef>

<DutyDef>
<defName>CombatAI_AssaultPawn</defName>
<alwaysShowWeapon>true</alwaysShowWeapon>
<thinkNode Class="ThinkNode_Priority">
<!-- Todo here - if outside of duty radius, go to within duty radius-->
<!-- Currently this is handled by a hack in JobGiver_AIFightBase-->
<subNodes>
<li Class="JobGiver_TakeCombatEnhancingDrug">
<onlyIfInDanger>true</onlyIfInDanger>
</li>
<li Class="JobGiver_AIDefendPoint">
<targetAcquireRadius>65</targetAcquireRadius>
<targetKeepRadius>72</targetKeepRadius>
</li>
<li Class="ThinkNode_ForbidOutsideFlagRadius">
<maxDistToSquadFlag>16</maxDistToSquadFlag>
<subNodes>
<li Class="ThinkNode_Subtree">
<treeDef>SatisfyBasicNeedsAndWork</treeDef>
</li>
</subNodes>
</li>
<li Class="JobGiver_WanderNearDutyLocation">
<wanderRadius>8</wanderRadius>
<locomotionUrgencyOutsideRadius>Sprint</locomotionUrgencyOutsideRadius>
</li>
<li Class="JobGiver_AITrashBuildingsDistant">
<attackAllInert>true</attackAllInert>
</li>
<li Class="JobGiver_AITrashColonyClose" />
<li Class="JobGiver_AITrashBuildingsDistant" />
</subNodes>
</thinkNode>
</DutyDef>

<DutyDef>
<defName>CombatAI_Escort</defName>
<alwaysShowWeapon>true</alwaysShowWeapon>
<thinkNode Class="ThinkNode_Priority">
<subNodes>
<li Class="JobGiver_TakeCombatEnhancingDrug">
<onlyIfInDanger>true</onlyIfInDanger>
</li>
<li Class="JobGiver_AIDefendEscortee">
<targetAcquireRadius>65</targetAcquireRadius>
<targetKeepRadius>72</targetKeepRadius>
</li>
<li Class="JobGiver_AIFollowEscortee"/>
<li Class="ThinkNode_Subtree">
<treeDef>SatisfyVeryUrgentNeeds</treeDef>
</li>
<li Class="JobGiver_WanderNearDutyLocation">
<wanderRadius>8</wanderRadius>
</li>
<li Class="JobGiver_AITrashBuildingsDistant">
<attackAllInert>true</attackAllInert>
</li>
<li Class="JobGiver_AITrashColonyClose" />
<li Class="JobGiver_AITrashBuildingsDistant" />
</subNodes>
</thinkNode>
</DutyDef>

</Defs>
76 changes: 76 additions & 0 deletions 1.4/Defs/HyperText/HyperText_DebugTutorial.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>
<CombatAI.Gui.HyperTextDef>
<defName>CombatAI_DevJobTutorial1</defName>
<content>
<!-- isma logo -->
<img path='Isma/logo' height='350' />
<gap height='10' />
<p fontSize='Medium' textAnchor='UpperLeft'>Thank you for participating in [color=green]CAI-5000[/color] open test</p>
<gap height='10' />
<p fontSize='Smaller'>In this tutorial you will learn how create bug reports for [color=green]CAI-5000[/color]</p>
<gap height='5' />
<p fontSize='Tiny'>[color='yellow']NOTE:[/color] This is a test build thus it's significantly slower and will consume a lot more memory</p>
</content>
</CombatAI.Gui.HyperTextDef>

<CombatAI.Gui.HyperTextDef>
<defName>CombatAI_DevJobTutorial2</defName>
<content>
<p fontSize='Medium'>Job Logs and Troubleshooting Pawns</p>
<gap height="5" />
<p fontSize="Smaller">The [color='green']job log[/color] is used to troubleshoot pawns doing something they [color=red]shouldn't[/color] be doing.</p>
<gap height="5" />
<p>You can access a pawn's job log by:</p>
<gap height="5" fontSize="Smaller" />
<p fontSize="Smaller">1. Select the problematic pawn</p>
<p fontSize="Smaller">2. Click on the [color='yellow']"DEV: View job logs"[/color] gizmo button. The button is showen in screenshot (1). The window in screenshot (2) should appear</p>
<gap height="5" fontSize="Smaller" />
<p fontSize="Tiny">[color=yellow]WARNING:[/color]If you select a different pawn while the window is open the window will automatically switch to viewing their job log.</p>
<img path="Isma/Tutorials/JobLog/gizmo_screenshot" height="180" />
<p fontSize="tiny" textAnchor="MiddleCenter">Screenshot (1): The job log gizmo button</p>
<gap height="10" />
<img path="Isma/Tutorials/JobLog/window_screenshot" height="180" />
<p fontSize="tiny" textAnchor="MiddleCenter">Screenshot (2): The job log window</p>
<gap height="10" />
<p fontSize="Tiny">[color=yellow]WARNING:[/color]If you select a different pawn while the window is open the window will automatically switch to viewing their job log.</p>
</content>
</CombatAI.Gui.HyperTextDef>

<CombatAI.Gui.HyperTextDef>
<defName>CombatAI_DevJobTutorial3</defName>
<content>
<p fontSize='Medium'>Creating an initial report</p>
<gap height="5" />
<p fontSize="Smaller">1. [color=yellow]Unpause[/color] the game after opening the job log window for a second or 2 incase the job log is empty.</p>
<p fontSize="Smaller">2. Click on the [color=green]Copy short report to clipboard[/color] button in the top right corner. The green button shown in screenshot (3)</p>
<p fontSize="Smaller">3. Join the RocketMan discord server https://discord.gg/ftCjYB7jDe and post the report in the [color=yellow]#combat-ai-feedback channel[/color]</p>
<img path="Isma/Tutorials/JobLog/clipboard_screenshot" height="180" />
<p fontSize="tiny" textAnchor="MiddleCenter">Screenshot (3): Copy short report to clipboard in the top right corner of the job log window.</p>
</content>
</CombatAI.Gui.HyperTextDef>

<CombatAI.Gui.HyperTextDef>
<defName>CombatAI_DevJobTutorial4</defName>
<content>
<p fontSize='Medium'>Investigating AI choices</p>
<p fontSize="Smaller">Sometimes you might want to investigate AI choices like a pawn choosing a really bad cover position, pawn standing still or pawn dancing around in loops.</p>
<gap height="5" />
<p fontSize="Smaller">In the job log window, when you select a job, it'll show you information about the job. Example showen in screenshot (4)</p>
<img path="Isma/Tutorials/JobLog/position_screenshot" height="180" />
<p fontSize="tiny" textAnchor="MiddleCenter">Screenshot (4): The section showing your current selection information.</p>
<gap height="5" />
<p fontSize='Medium'>Investigating cover position</p>
<p fontSize="Smaller">You go about investigating what job made the pawn go to a specific location by:</p>
<gap height="5" />
<p fontSize="Smaller">1. Select a random job at the top of the job log.</p>
<p fontSize="Smaller">2.1. In the information section clicking on the [color=green]"origin:"[/color] section will hightlight the cell at which the pawn made the decision.</p>
<p fontSize="Smaller">2.2. In the information section clicking on the [color=green]"destination:"[/color] section will hightlight the target cell the pawn choose to go to. Note that if the value shown is (-1000,-1000,-1000) then that mean the selected job didn't include moving to another cell.</p>
<p fontSize="Smaller">3. Repeat steps 1 and 2 until you land on a job that matches your obesrvations.</p>
<gap height="5" />
<p fontSize="Smaller">Some tips:</p>
<p fontSize="Smaller">1. Jobs that involve movement start typically with the prefix "Goto" so any job with Goto in the name is a good place to start searching.</p>
<p fontSize="Smaller">2. If a pawn is not moving selecting jobs starting with "Wait" prefix will most likely lead to the problematic job.</p>
</content>
</CombatAI.Gui.HyperTextDef>
</Defs>
37 changes: 37 additions & 0 deletions 1.4/Defs/Jobs/Jobs_Misc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>
<JobDef>
<defName>CombatAI_Goto_Retreat</defName>
<driverClass>JobDriver_Goto</driverClass>
<reportString>retreating.</reportString>
<allowOpportunisticPrefix>false</allowOpportunisticPrefix>
<carryThingAfterJob>true</carryThingAfterJob>
<dropThingBeforeJob>false</dropThingBeforeJob>
<casualInterruptible>false</casualInterruptible>
<neverFleeFromEnemies>true</neverFleeFromEnemies>
</JobDef>

<JobDef>
<defName>CombatAI_Goto_Duck</defName>
<driverClass>JobDriver_Goto</driverClass>
<reportString>moving.</reportString>
<allowOpportunisticPrefix>false</allowOpportunisticPrefix>
<carryThingAfterJob>true</carryThingAfterJob>
<dropThingBeforeJob>false</dropThingBeforeJob>
<checkOverrideOnDamage>Never</checkOverrideOnDamage>
<casualInterruptible>false</casualInterruptible>
<neverFleeFromEnemies>true</neverFleeFromEnemies>
</JobDef>

<JobDef>
<defName>CombatAI_Goto_Cover</defName>
<driverClass>JobDriver_Goto</driverClass>
<reportString>moving.</reportString>
<allowOpportunisticPrefix>true</allowOpportunisticPrefix>
<carryThingAfterJob>true</carryThingAfterJob>
<dropThingBeforeJob>false</dropThingBeforeJob>
<checkOverrideOnDamage>Never</checkOverrideOnDamage>
<casualInterruptible>false</casualInterruptible>
<neverFleeFromEnemies>true</neverFleeFromEnemies>
</JobDef>
</Defs>
5 changes: 4 additions & 1 deletion 1.4/Languages/English/Keyed/Translations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<CombatAI.Quick.Welcome.Description>This quick-setup page will help you quickly setup CAI-5000's different features!</CombatAI.Quick.Welcome.Description>
<CombatAI.Quick.QuickSetup>Quick Setup Options</CombatAI.Quick.QuickSetup>
<CombatAI.Quick.Difficulty>Please select a difficulty level</CombatAI.Quick.Difficulty>
<CombatAI.Quick.Difficulty.Selected>{0} difficulty level applied!</CombatAI.Quick.Difficulty.Selected>
<CombatAI.Quick.Difficulty.Selected.Warning>WARNING: {0} difficulty level might cause performance issues!</CombatAI.Quick.Difficulty.Selected.Warning>
<CombatAI.PlaceWorker.WallMounted>Needs to be mounted to a wall or a solid structure.</CombatAI.PlaceWorker.WallMounted>
<CombatAI.Preparing>Preparing Combat AI</CombatAI.Preparing>
<CombatAI.Animator.Controller>Hold</CombatAI.Animator.Controller>
Expand All @@ -23,11 +25,12 @@
<CombatAI.Settings.Basic.Presets.Easy>Easy/Perf</CombatAI.Settings.Basic.Presets.Easy>
<CombatAI.Settings.Basic.Presets.Normal>Normal</CombatAI.Settings.Basic.Presets.Normal>
<CombatAI.Settings.Basic.Presets.Hard>Hard</CombatAI.Settings.Basic.Presets.Hard>
<CombatAI.Settings.Basic.Temperature>Make the AI aware of cell temperature</CombatAI.Settings.Basic.Temperature>
<CombatAI.Settings.Basic.Presets.Deathwish>Deathwish</CombatAI.Settings.Basic.Presets.Deathwish>
<CombatAI.Settings.Basic.Presets.Applied>Applied preset:</CombatAI.Settings.Basic.Presets.Applied>
<CombatAI.Settings.Basic.Presets.Description>Performance presets will determine the complexity of AI calculations and their interval. More complex calculations means harder AI but lower performance. Default is normal.</CombatAI.Settings.Basic.Presets.Description>
<CombatAI.Settings.Basic.Sprinting>Enable sprinting</CombatAI.Settings.Basic.Sprinting>
<CombatAI.Settings.Basic.Sprinting.Description>If this is disabled: Pathetic F F...\n if not: Chad :thumbsup</CombatAI.Settings.Basic.Sprinting.Description>
<CombatAI.Settings.Basic.Sprinting.Description>Allows the AI to use sprinting when dashing for cover. Turn this off if you don't like kitting simulators.</CombatAI.Settings.Basic.Sprinting.Description>
<CombatAI.Settings.Basic.Groups>Enable tactical groups</CombatAI.Settings.Basic.Groups>
<CombatAI.Settings.Basic.Groups.Description>Raiders will be divided into tactical groups (2-10) each with their own objective. Not all pawns will be assigned to groups, some will remain on the default assault duty.</CombatAI.Settings.Basic.Groups.Description>
<CombatAI.Settings.Basic.SappingMul>Cost multiplier for pathing through walls (default is 1.0)</CombatAI.Settings.Basic.SappingMul>
Expand Down
38 changes: 38 additions & 0 deletions 1.4/Patches/Duties_Misc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8" ?>
<Patch>
<!-- <Operation Class="PatchOperationReplace">
<xpath>Defs/DutyDef/thinkNode/subNodes/li[@Class="JobGiver_TakeCombatEnhancingDrug"]</xpath>
<value>
<li Class="CombatAI.ThinkNode_ConditionalSight">
<visibilityToEnemies>1</visibilityToEnemies>
<subNodes>
<li Class="JobGiver_TakeCombatEnhancingDrug">
<onlyIfInDanger>true</onlyIfInDanger>
</li>
</subNodes>
</li>
</value>
</Operation>
<Operation Class="PatchOperationInsert">
<xpath>Defs/DutyDef/thinkNode/subNodes/li[@Class="JobGiver_AIGotoNearestHostile"]</xpath>
<value>
<li Class="CombatAI.ThinkNode_ConditionalHumanlike">
<subNodes>
<li Class="CombatAI.ThinkNode_ConditionalRaider">
<subNodes>
<li Class="CombatAI.ThinkNode_Timed">
<interval>240</interval>
<subNodes>
<li Class="JobGiver_PickUpOpportunisticWeapon" />
</subNodes>
</li>
</subNodes>
</li>
</subNodes>
</li>
</value>
</Operation> -->


</Patch>
21 changes: 21 additions & 0 deletions 1.4/Patches/ThinkTree_Humanlike.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<Patch>
<!-- <Operation Class="PatchOperationReplace">
<xpath>Defs/ThinkTreeDef[defName="Humanlike"]/thinkRoot/subNodes/li[@Class="ThinkNode_ConditionalNPCCanSelfTendNow"]</xpath>
<value>
<li Class="ThinkNode_ConditionalNPCCanSelfTendNow">
<subNodes>
<li Class="CombatAI.JobGiver_DuckOrRetreat" />
<li Class="CombatAI.ThinkNode_ConditionalBeingTargeted">
<invert>true</invert>
<subNodes>
<li Class="JobGiver_SelfTend" />
</subNodes>
</li>
</subNodes>
</li>
</value>
</Operation> -->


</Patch>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 1.4/Textures/Isma/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@
<steamWorkshopUrl>steam://url/CommunityFilePage/2009463077</steamWorkshopUrl>
<downloadUrl>https://github.com/pardeike/HarmonyRimWorld/releases/latest</downloadUrl>
</li>
</v1.4>
<li>
<packageId>zetrith.prepatcher</packageId>
<displayName>Prepatcher</displayName>
<steamWorkshopUrl>steam://url/CommunityFilePage/2934420800</steamWorkshopUrl>
<downloadUrl>https://github.com/Zetrith/Prepatcher/releases/latest</downloadUrl>
</li>
</v1.4>
</modDependenciesByVersion>
<loadAfter>
<li>Ludeon.RimWorld</li>
<li>Ludeon.RimWorld.Royalty</li>
<li>brrainz.harmony</li>
<li>zetrith.prepatcher</li>
</loadAfter>
<incompatibleWith>
<li>Victor.WallsAreSolid</li>
<li>fed1sPlay.PawnTargetFix</li>
<li>brrainz.lineofsightfix</li>
<li>majorhoff.rimthreaded</li>
Expand Down
Binary file modified About/Preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions Source/Rule56/ArmorReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public struct ArmorReport
/// </summary>
public int createdAt;
/// <summary>
/// Comp shield for the shield belt.
/// </summary>
public CompShield shield;
/// <summary>
/// Weak attributes.
/// </summary>
public MetaCombatAttribute weaknessAttributes;
Expand Down Expand Up @@ -83,5 +87,25 @@ public float GetArmor(DamageDef damage)
{
return damage != null ? damage.armorCategory == DamageArmorCategoryDefOf.Sharp ? Sharp : Blunt : 0f;
}

/// <summary>
/// Get the appropriate armor for a damage def.
/// </summary>
/// <param name="damage">Damage def</param>
/// <returns>Armor value</returns>
public float GetBodyArmor(DamageDef damage)
{
return damage != null ? damage.armorCategory == DamageArmorCategoryDefOf.Sharp ? bodySharp : bodyBlunt : 0f;
}

/// <summary>
/// Get the appropriate armor for a damage def.
/// </summary>
/// <param name="damage">Damage def</param>
/// <returns>Armor value</returns>
public float GetArmor(DamageArmorCategoryDef category)
{
return category != null ? category == DamageArmorCategoryDefOf.Sharp ? Sharp : Blunt : 0f;
}
}
}
Loading

0 comments on commit fcb16ba

Please sign in to comment.