Skip to content

Commit

Permalink
RC for 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Vek17 committed Feb 23, 2023
1 parent 434aa7d commit fd80906
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 28 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Versions 0.5.9
* Updated for 2.1.0
* Moved AddOutgoingWeaponDamageBonus to post crit damage system
* Added support for more ActivatableAbilityGroups with AdditionalActivatableAbilityGroups

## Version 0.5.8
* Support for twin spell metamagic
* Fixed issue with aberrant bloodline and permanant polymorph durations
Expand Down
4 changes: 2 additions & 2 deletions TabletopTweaks-Core/Info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"Author": "Sean Petrie",
"DisplayName": "Tabletop Tweaks Core",
"EntryMethod": "TabletopTweaks.Core.Main.Load",
"GameVersion": "2.0.0",
"GameVersion": "2.1.0",
"HomePage": "https://github.com/Vek17/TabletopTweaks-Core",
"Id": "TabletopTweaks-Core",
"ManagerVersion": "0.23.0",
"Repository": "https://raw.githubusercontent.com/Vek17/TabletopTweaks-Core/master/Repository.json",
"Requirements": [],
"LoadAfter": ["MewsiferConsole.Mod"],
"Version": "0.5.8"
"Version": "0.5.9"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using HarmonyLib;
using Kingmaker.UnitLogic.ActivatableAbilities;
using Kingmaker.UnitLogic.Parts;
using System;
using TabletopTweaks.Core.NewUnitParts;

namespace TabletopTweaks.Core.MechanicsChanges {
public static class AdditionalActivatableAbilityGroups {
public enum ExtentedActivatableAbilityGroup : int {
CavalierCharge = 1000
}

private static bool IsTTTGroup(this ActivatableAbilityGroup group) {
return Enum.IsDefined(typeof(ExtentedActivatableAbilityGroup), (int)group);
}

[HarmonyPatch(typeof(UnitPartActivatableAbility), nameof(UnitPartActivatableAbility.IncreaseGroupSize), new Type[] { typeof(ActivatableAbilityGroup) })]
static class UnitPartActivatableAbility_IncreaseGroupSize_Patch {

static bool Prefix(UnitPartActivatableAbility __instance, ActivatableAbilityGroup group) {
if (group.IsTTTGroup()) {
var extensionPart = __instance.Owner.Ensure<UnitPartActivatableAbilityGroupExtension>();
extensionPart.IncreaseGroupSize((ExtentedActivatableAbilityGroup)group);
return false;
}
return true;
}
}

[HarmonyPatch(typeof(UnitPartActivatableAbility), nameof(UnitPartActivatableAbility.DecreaseGroupSize), new Type[] { typeof(ActivatableAbilityGroup) })]
static class UnitPartActivatableAbility_DecreaseGroupSize_Patch {

static bool Prefix(UnitPartActivatableAbility __instance, ActivatableAbilityGroup group) {
if (group.IsTTTGroup()) {
var extensionPart = __instance.Owner.Ensure<UnitPartActivatableAbilityGroupExtension>();
extensionPart.DecreaseGroupSize((ExtentedActivatableAbilityGroup)group);
return false;
}
return true;
}
}

[HarmonyPatch(typeof(UnitPartActivatableAbility), nameof(UnitPartActivatableAbility.GetGroupSize), new Type[] { typeof(ActivatableAbilityGroup) })]
static class UnitPartActivatableAbility_GetGroupSize_Patch {

static bool Prefix(UnitPartActivatableAbility __instance, ActivatableAbilityGroup group, ref int __result) {
if (group.IsTTTGroup()) {
var extensionPart = __instance.Owner.Ensure<UnitPartActivatableAbilityGroupExtension>();
__result = extensionPart.GetGroupSize((ExtentedActivatableAbilityGroup)group);
return false;
}
return true;
}
}

//[HarmonyPatch(typeof(UnitPartActivatableAbility), nameof(UnitPartActivatableAbility.PersistentGroupsSizeIncreases), MethodType.Getter)]
static class UnitPartActivatableAbility_PersistentGroupsSizeIncreases_Getter_Patch {

static void Postfix(UnitPartActivatableAbility __instance, ref int[] __result) {

}
}

//[HarmonyPatch(typeof(UnitPartActivatableAbility), nameof(UnitPartActivatableAbility.PersistentGroupsSizeIncreases), MethodType.Setter)]
static class UnitPartActivatableAbility_PersistentGroupsSizeIncreases_Setter_Patch {

static void Postfix(UnitPartActivatableAbility __instance) {

}
}
}
}
29 changes: 14 additions & 15 deletions TabletopTweaks-Core/NewComponents/AddOutgoingWeaponDamageBonus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Kingmaker.UnitLogic;
using System;
using TabletopTweaks.Core.Utilities;
using UnityEngine;

namespace TabletopTweaks.Core.NewComponents {
[TypeId("03f55b5c7cb0445ab32ce2c8d44704ec")]
Expand All @@ -17,22 +18,20 @@ public class AddOutgoingWeaponDamageBonus : UnitFactComponentDelegate,
IInitiatorRulebookSubscriber {

public void OnEventAboutToTrigger(RuleCalculateDamage evt) {
if (evt.DamageBundle.First == null) { return; }

var WeaponDamage = evt.DamageBundle.First;
DamageTypeDescription description = GenerateTypeDescriptiron(WeaponDamage);
DamageDescription damageDescriptor = description.GetDamageDescriptor(Helpers.CreateCopy(WeaponDamage.Dice.ModifiedValue), 0);
damageDescriptor.TemporaryContext(dd => {
dd.TypeDescription.Physical.Enhancement = description.Physical.Enhancement;
dd.TypeDescription.Physical.EnhancementTotal = description.Physical.EnhancementTotal;
dd.TypeDescription.Common.Alignment = WeaponDamage.AlignmentsMask;
dd.SourceFact = this.Fact;
if (BonusDamageMultiplier > 1) {
dd.ModifyDice(new DiceFormula(damageDescriptor.Dice.Rolls * BonusDamageMultiplier, damageDescriptor.Dice.Dice), this.Fact);
}
dd.AddModifier(new Modifier(WeaponDamage.Bonus * Math.Max(1, BonusDamageMultiplier), this.Fact, ModifierDescriptor.UntypedStackable));
});
evt.ParentRule.m_DamageBundle.m_Chunks.Insert(1, damageDescriptor.CreateDamage());
BaseDamage weaponDamage = evt.DamageBundle.WeaponDamage;
if (weaponDamage == null) {
return;
}
DiceFormula modifiedValue = weaponDamage.Dice.ModifiedValue;
int extraDice = modifiedValue.Rolls * BonusDamageMultiplier;
if (extraDice > 0) {
weaponDamage.PostCritIncrements.AddDiceModifier(extraDice, this.Fact);
}
int bonusDamage = weaponDamage.TotalBonus * BonusDamageMultiplier;
if (bonusDamage > 0) {
weaponDamage.PostCritIncrements.AddBonusModifier(bonusDamage, this.Fact);
}
}

public void OnEventDidTrigger(RuleCalculateDamage evt) {
Expand Down
2 changes: 1 addition & 1 deletion TabletopTweaks-Core/NewComponents/ArmorEnchantsToWeapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ArmorEnchantsToWeapon : WeaponEnchantmentLogic,
if (evt.Weapon == base.Owner) {
var bonus = evt.Initiator?.Body?.Armor?.MaybeArmor?.EnchantmentValue ?? 0;
if (bonus > 0) {
evt.Enhancement = bonus > evt.Enhancement ? bonus : evt.Enhancement;
Modifier modifier = new Modifier(bonus, base.Fact, ModifierDescriptor.Enhancement);
}
}
}
Expand Down
23 changes: 13 additions & 10 deletions TabletopTweaks-Core/NewComponents/SuppressBuffsEveryRound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ public class SuppressBuffsEveryRound : UnitFactComponentDelegate, ITickEachRound
public void OnNewRound() {
if (conditionsChecker.Check()) {
UnitPartBuffSuppress unitPartBuffSuppress = base.Owner.Ensure<UnitPartBuffSuppress>();
foreach (BlueprintBuff buff in m_SuppressedBuffs) {
unitPartBuffSuppress.Suppress(buff);
}
unitPartBuffSuppress.ApplyChanges();
//foreach (BlueprintBuff buff in m_SuppressedBuffs) {
// unitPartBuffSuppress.PrepareForSuppression(buff);
//}
}
}

Expand All @@ -38,22 +39,23 @@ public class SuppressBuffsEveryRound : UnitFactComponentDelegate, ITickEachRound

foreach (Buff buff in Owner.Buffs) {
if (IsSuppressed(buff)) {
unitPartBuffSuppress.Suppress(buff.Blueprint);
unitPartBuffSuppress.PrepareForSuppression(buff.Blueprint);
suppressedBuffs.Add(buff.Blueprint);
}
}


if (Descriptor != SpellDescriptor.None) {
unitPartBuffSuppress.Suppress(Descriptor);
unitPartBuffSuppress.PrepareForSuppression(Descriptor);
}
if (Schools != null && Schools.Length > 0) {
unitPartBuffSuppress.Suppress(Schools);
unitPartBuffSuppress.PrepareForSuppression(Schools);
}
foreach (BlueprintBuff buff in Buffs) {
unitPartBuffSuppress.Suppress(buff);
unitPartBuffSuppress.PrepareForSuppression(buff);
}
m_SuppressedBuffs = suppressedBuffs.Select(bp => bp.ToReference<BlueprintBuffReference>()).ToArray();
unitPartBuffSuppress.ApplyChanges();
}

public override void OnDeactivate() {
Expand All @@ -63,14 +65,15 @@ public class SuppressBuffsEveryRound : UnitFactComponentDelegate, ITickEachRound
return;
}
if (Descriptor != SpellDescriptor.None) {
unitPartBuffSuppress.Release(Descriptor);
unitPartBuffSuppress.PrepareForRelease(Descriptor);
}
if (Schools != null && Schools.Length > 0) {
unitPartBuffSuppress.Release(Schools);
unitPartBuffSuppress.PrepareForRelease(Schools);
}
foreach (BlueprintBuff buff in Buffs) {
unitPartBuffSuppress.Release(buff);
unitPartBuffSuppress.PrepareForRelease(buff);
}
unitPartBuffSuppress.ApplyChanges();
}

private static IEnumerable<SpellDescriptor> GetValues(SpellDescriptor spellDescriptor) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Kingmaker.UnitLogic;
using System.Collections.Generic;
using static TabletopTweaks.Core.MechanicsChanges.AdditionalActivatableAbilityGroups;

namespace TabletopTweaks.Core.NewUnitParts {
public class UnitPartActivatableAbilityGroupExtension : OldStyleUnitPart {

public void IncreaseGroupSize(ExtentedActivatableAbilityGroup group) {
if (m_GroupsSizeIncreases.ContainsKey(group)) {
this.m_GroupsSizeIncreases[group] += 1;
} else {
m_GroupsSizeIncreases.Add(group, 1);
}
}

public void DecreaseGroupSize(ExtentedActivatableAbilityGroup group) {
if (m_GroupsSizeIncreases.ContainsKey(group)) {
this.m_GroupsSizeIncreases[group] -= 1;
}
}

public int GetGroupSize(ExtentedActivatableAbilityGroup group) {
this.m_GroupsSizeIncreases.TryGetValue(group, out int result);
return result + 1;
}

private SortedDictionary<ExtentedActivatableAbilityGroup, int> m_GroupsSizeIncreases = new SortedDictionary<ExtentedActivatableAbilityGroup, int>();
}
}
2 changes: 2 additions & 0 deletions TabletopTweaks-Core/TabletopTweaks-Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,13 @@
<Compile Include="Bugfixes\General\PropertyFixes.cs" />
<Compile Include="Bugfixes\General\RuleCalculateCMDFix.cs" />
<Compile Include="Config\Blueprints.cs" />
<Compile Include="MechanicsChanges\AdditionalActivatableAbilityGroups.cs" />
<Compile Include="NewComponents\AddAdditionalWeaponDamageOnHit.cs" />
<Compile Include="NewComponents\AddConditionalWeaponDamageBonus.cs" />
<Compile Include="NewComponents\BuffDescriptorImmunityIgnore.cs" />
<Compile Include="NewComponents\OwlcatReplacements\AttackBonusAgainstTargetTTT.cs" />
<Compile Include="NewComponents\SpellDescriptorImmunityIgnore.cs" />
<Compile Include="NewUnitParts\UnitPartActivatableAbilityGroupExtension.cs" />
<Compile Include="NewUnitParts\UnitPartIgnoreBuffDescriptorImmunity.cs" />
<Compile Include="Utilities\VenderTools.cs" />
<EmbeddedResource Include="Config\Blueprints.json" />
Expand Down

0 comments on commit fd80906

Please sign in to comment.