-
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.
Compatibility with attack / damage stat replacers
- Loading branch information
Showing
5 changed files
with
81 additions
and
5 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
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
55 changes: 55 additions & 0 deletions
55
ToggleableThrowingWeapons/Patch/PatchAttackStatReplacement.cs
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,55 @@ | ||
using HarmonyLib; | ||
using Kingmaker.EntitySystem.Stats; | ||
using Kingmaker.RuleSystem.Rules; | ||
using Kingmaker.UnitLogic.FactLogic; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ToggleableThrowingWeapons.Component; | ||
|
||
namespace ToggleableThrowingWeapons.Patch | ||
{ | ||
class PatchAttackStatReplacement | ||
{ | ||
[HarmonyPatch(typeof(AttackStatReplacement), "OnEventAboutToTrigger")] | ||
static class FixAttackStatReplacer | ||
{ | ||
|
||
[HarmonyPriority(Priority.Normal)] | ||
public static void Postfix(AttackStatReplacement __instance, RuleCalculateAttackBonusWithoutTarget evt) | ||
{ | ||
if (__instance.CheckWeaponTypes) | ||
{ | ||
|
||
|
||
var crossref = evt.Weapon?.Blueprint.Type.Components.OfType<ThrownCrossrefTypeComponent>().FirstOrDefault(); | ||
if (crossref != null) | ||
{ | ||
Main.TTWContext.Logger.Log($"Assessing Crossref for hackage: {crossref.m_OtherForm.NameSafe()}"); | ||
Main.TTWContext.Logger.Log($"First local weapon type is {__instance.WeaponTypes.FirstOrDefault().name}"); | ||
ModifiableValueAttributeStat modifiableValueAttributeStat = __instance.Owner.Stats.GetStat(evt.AttackBonusStat) as ModifiableValueAttributeStat; | ||
ModifiableValueAttributeStat modifiableValueAttributeStat2 = __instance.Owner.Stats.GetStat(__instance.ReplacementStat) as ModifiableValueAttributeStat; | ||
bool flag = modifiableValueAttributeStat2 != null && modifiableValueAttributeStat != null && modifiableValueAttributeStat2.Bonus >= modifiableValueAttributeStat.Bonus; | ||
|
||
if (flag) | ||
{ | ||
|
||
|
||
if (__instance.WeaponTypes.HasReference(crossref.m_OtherForm)) | ||
{ | ||
|
||
evt.AttackBonusStat = __instance.ReplacementStat; | ||
Main.TTWContext.Logger.Log($"Patching Crossref"); | ||
} | ||
} | ||
|
||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
} | ||
} |
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