-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Scarlet Edge CE support, initial implementation of CE AP calc.
- Loading branch information
Showing
15 changed files
with
339 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Patch> | ||
|
||
<Operation Class="PatchOperationSequence"> | ||
<operations> | ||
|
||
<!-- === AM_Weebstick === --> | ||
|
||
<li Class="PatchOperationReplace"> | ||
<xpath>/Defs/ThingDef[defName="AM_Weebstick"]/tools</xpath> | ||
<value> | ||
<tools> | ||
<li Class="CombatExtended.ToolCE"> | ||
<label>point</label> | ||
<capacities> | ||
<li>Stab</li> | ||
</capacities> | ||
<power>25</power> | ||
<cooldownTime>1.8</cooldownTime> | ||
<chanceFactor>0.9</chanceFactor> | ||
<armorPenetrationBlunt>22</armorPenetrationBlunt> | ||
<armorPenetrationSharp>29</armorPenetrationSharp> | ||
<linkedBodyPartsGroup>Point</linkedBodyPartsGroup> | ||
</li> | ||
<li Class="CombatExtended.ToolCE"> | ||
<label>edge</label> | ||
<capacities> | ||
<li>Cut</li> | ||
</capacities> | ||
<power>28</power> | ||
<cooldownTime>2</cooldownTime> | ||
<chanceFactor>0.50</chanceFactor> | ||
<armorPenetrationBlunt>20</armorPenetrationBlunt> | ||
<armorPenetrationSharp>27</armorPenetrationSharp> | ||
<linkedBodyPartsGroup>Edge</linkedBodyPartsGroup> | ||
</li> | ||
</tools> | ||
</value> | ||
</li> | ||
|
||
<li Class="PatchOperationAdd"> | ||
<xpath>/Defs/ThingDef[defName="AM_Weebstick"]/statBases</xpath> | ||
<value> | ||
<Bulk>15</Bulk> | ||
<MeleeCounterParryBonus>1.1</MeleeCounterParryBonus> | ||
</value> | ||
</li> | ||
|
||
<li Class="PatchOperationAdd"> | ||
<xpath>Defs/ThingDef[defName="AM_Weebstick"]/equippedStatOffsets</xpath> | ||
<value> | ||
<MeleeCritChance>0.8</MeleeCritChance> | ||
<MeleeParryChance>0.9</MeleeParryChance> | ||
<MeleeDodgeChance>0.55</MeleeDodgeChance> | ||
</value> | ||
</li> | ||
|
||
</operations> | ||
</Operation> | ||
|
||
</Patch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using AM.Outcome; | ||
using CombatExtended; | ||
using RimWorld; | ||
using System.Collections.Generic; | ||
using Verse; | ||
|
||
namespace AM.CombatExtendedPatch; | ||
|
||
public sealed class CombatExtendedOutcomeWorker : IOutcomeWorker | ||
{ | ||
public IEnumerable<PossibleMeleeAttack> GetMeleeAttacksFor(ThingWithComps weapon, Pawn pawn) | ||
{ | ||
var comp = weapon?.GetComp<CompEquippable>(); | ||
if (comp == null) | ||
yield break; | ||
|
||
foreach (var verb in comp.AllVerbs) | ||
{ | ||
if (!verb.IsMeleeAttack) | ||
continue; | ||
|
||
float dmg = GetDamage(weapon, verb, pawn); | ||
float ap = GetPen(weapon, verb, pawn); | ||
|
||
yield return new PossibleMeleeAttack | ||
{ | ||
Damage = dmg, | ||
ArmorPen = ap, | ||
Pawn = pawn, | ||
DamageDef = verb.GetDamageDef(), | ||
Verb = verb, | ||
Weapon = weapon | ||
}; | ||
} | ||
} | ||
|
||
public float GetPen(ThingWithComps weapon, Verb verb, Pawn attacker) | ||
{ | ||
var tool = verb.tool as ToolCE; | ||
if (tool == null) | ||
return verb.tool.armorPenetration * GetPenetrationFactor(weapon); | ||
|
||
var isBlunt = verb.GetDamageDef()?.armorCategory?.armorRatingStat == StatDefOf.ArmorRating_Blunt; | ||
if (isBlunt) | ||
return tool.armorPenetrationBlunt * GetPenetrationFactor(weapon); | ||
return tool.armorPenetrationSharp * GetPenetrationFactor(weapon); | ||
} | ||
|
||
public float GetDamage(ThingWithComps weapon, Verb verb, Pawn attacker) | ||
=> verb.verbProps.AdjustedMeleeDamageAmount(verb.tool, attacker, weapon, verb.HediffCompSource); | ||
|
||
private float GetPenetrationFactor(Thing weapon) | ||
=> weapon?.GetStatValue(CE_StatDefOf.MeleePenetrationFactor) ?? 1f; | ||
|
||
public float GetChanceToPenAprox(Pawn pawn, BodyPartRecord bodyPart, StatDef armorType, float armorPen) | ||
{ | ||
// Get skin & hediff chance-to-pen. | ||
float armor = pawn.GetStatValue(armorType); | ||
|
||
if (pawn.apparel != null) | ||
{ | ||
// Get apparel chance-to-pen. | ||
foreach (var a in pawn.apparel.WornApparel) | ||
{ | ||
if (!a.def.apparel.CoversBodyPart(bodyPart)) | ||
continue; | ||
|
||
armor += a.GetStatValue(armorType); | ||
} | ||
} | ||
|
||
// 75% of the required pen gives 0% pen chance, increasing to 100% at 100% required pen. | ||
// Not perfect, but a reasonable approximation. | ||
float rawPct = armor <= 0f ? 1f : armorPen / armor; | ||
return OutcomeUtility.RemapClamped(0.75f, 1f, 0f, 1f, rawPct); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net472</TargetFramework> | ||
<OutputType>Library</OutputType> | ||
<LangVersion>preview</LangVersion> | ||
<NoStdLib>false</NoStdLib> | ||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> | ||
<Configurations>v1.4</Configurations> | ||
<RootNamespace>AM.CombatExtendedPatch</RootNamespace> | ||
<AssemblyName>zz.AM.CombatExtendedPatch</AssemblyName> | ||
<Nullable>disable</Nullable> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<DebugType>none</DebugType> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Lib.Harmony" Version="2.2.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ThingGenerator\AnimationMod.csproj"> | ||
<CopyLocal>False</CopyLocal> | ||
<Private>False</Private> | ||
<ExcludeAssets>all</ExcludeAssets> | ||
</ProjectReference> | ||
</ItemGroup> | ||
|
||
<!-- _____ 1.4 _____ --> | ||
<ItemGroup Condition="'$(Configuration)'=='v1.4'"> | ||
<PackageReference Include="Krafs.Rimworld.Ref"> | ||
<Version>1.4.3641</Version> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="CombatExtended"> | ||
<HintPath>CombatExtended_14.dll</HintPath> | ||
<CopyLocal>False</CopyLocal> | ||
<Private>False</Private> | ||
<ExcludeAssets>runtime</ExcludeAssets> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<!-- Output --> | ||
<PropertyGroup Condition="'$(Configuration)'=='v1.4'"> | ||
<DebugType>none</DebugType> | ||
<OutputPath>..\..\Patch_CombatExtended\1.4\Assemblies\</OutputPath> | ||
<Optimize>true</Optimize> | ||
<DefineConstants>TRACE;V14</DefineConstants> | ||
</PropertyGroup> | ||
|
||
</Project> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using JetBrains.Annotations; | ||
using Verse; | ||
|
||
namespace AM.CombatExtendedPatch; | ||
|
||
[UsedImplicitly] | ||
[HotSwapAll] | ||
public class PatchCore : Mod | ||
{ | ||
public static void Log(string msg) | ||
{ | ||
Core.Log($"[<color=#63e0ff>CE Patch</color>] {msg}"); | ||
} | ||
|
||
public PatchCore(ModContentPack content) : base(content) | ||
{ | ||
// Replace the vanilla outcome worker with the combat extended one, | ||
// which uses the combat extended armor system. | ||
OutcomeUtility.OutcomeWorker = new CombatExtendedOutcomeWorker(); | ||
|
||
Log("Loaded and applied CE patch."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
|
||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.