Skip to content

Commit

Permalink
Updated to supported Mixed blood bloodrager
Browse files Browse the repository at this point in the history
  • Loading branch information
Vek17 committed Oct 30, 2021
1 parent c731e64 commit bf5b280
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Kingmaker.Blueprints.JsonSystem;
using Kingmaker.EntitySystem.Entities;
using Kingmaker.UnitLogic.Mechanics.Properties;
using System.Linq;
using UnityEngine;

namespace TabletopTweaks.NewComponents.Properties {
[TypeId("762c31d6c5284ff5964a4af007ec5325")]
class CompositeCustomPropertyGetter : PropertyValueGetter {
public override int GetBaseValue(UnitEntityData unit) {
switch (CalculationMode) {
case Mode.Sum:
return Properties.Select(property => property.Calculate(unit)).Sum();
case Mode.Highest:
return Properties.Select(property => property.Calculate(unit)).Max();
case Mode.Lowest:
return Properties.Select(property => property.Calculate(unit)).Min();
default:
return 0;
}
}

public ComplexCustomProperty[] Properties = new ComplexCustomProperty[0];
public Mode CalculationMode;

public enum Mode : int {
Sum,
Highest,
Lowest
}

public class ComplexCustomProperty {
public ComplexCustomProperty() { }

public int Calculate(UnitEntityData unit) {
return Bonus + Mathf.FloorToInt((Numerator / Denominator) * Property.GetBaseValue(unit));
}

public PropertyValueGetter Property;
public int Bonus;
public float Numerator = 1;
public float Denominator = 1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

namespace TabletopTweaks.NewComponents.Properties {
[TypeId("b310257badf44a9d97d8f8fe8b3df3f6")]
class ProgressionRankPropertyGetter : PropertyValueGetter {
class ProgressionRankGetter : PropertyValueGetter {

public override int GetBaseValue(UnitEntityData unit) {
var unitProgression = unit.Progression.GetProgression(Progression);
int value = unitProgression?.Level ?? 0;
return UseMax ? Math.Max(value, Max) : value;
return UseMax ? Math.Min(value, Max) : value;
}

public BlueprintProgressionReference Progression;
Expand Down
19 changes: 19 additions & 0 deletions TabletopTweaks/NewContent/Bloodlines/BloodragerArcaneBloodline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,30 @@ public static void AddArcaneBloodrageReworkToggles() {
var ProtectionFromArrowsBuff = Resources.GetBlueprint<BlueprintBuff>("241ee6bd8c8767343994bce5dc1a95e0");

var BloodragerArcaneProgressionProperty = Helpers.CreateBlueprint<BlueprintUnitProperty>("BloodragerArcaneProgressionProperty", bp => {
bp.AddComponent<CompositeCustomPropertyGetter>(c => {
c.CalculationMode = CompositeCustomPropertyGetter.Mode.Highest;
c.Properties = new CompositeCustomPropertyGetter.ComplexCustomProperty[] {
new CompositeCustomPropertyGetter.ComplexCustomProperty(){
Property = new ProgressionRankGetter(){
Progression = BloodragerArcaneBloodline.ToReference<BlueprintProgressionReference>(),
UseMax = true,
Max = 20
}
},
new CompositeCustomPropertyGetter.ComplexCustomProperty(){
Property = new ClassLevelGetter(){
m_Class = BloodragerClass.ToReference<BlueprintCharacterClassReference>()
}
}
};
});
/*
bp.AddComponent<ProgressionRankPropertyGetter>(c => {
c.Progression = BloodragerArcaneBloodline.ToReference<BlueprintProgressionReference>();
c.UseMax = true;
c.Max = 20;
});
*/
});

var ProtectionFromArrowsArcaneBloodragerBuff = Helpers.CreateBuff("ProtectionFromArrowsArcaneBloodrageBuff", bp => {
Expand Down
3 changes: 2 additions & 1 deletion TabletopTweaks/TabletopTweaks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,10 @@
<Compile Include="NewComponents\HasFactFeatureUnlock.cs" />
<Compile Include="NewComponents\IncreaseResourceAmountByWeaponTraining.cs" />
<Compile Include="NewComponents\NestedPseudoActivatableAbilities.cs" />
<Compile Include="NewComponents\Properties\CompositeCustomPropertyGetter.cs" />
<Compile Include="NewComponents\Properties\MadDogPetDRProperty.cs" />
<Compile Include="NewComponents\Properties\CompositePropertyGetter.cs" />
<Compile Include="NewComponents\Properties\ProgressionRankPropertyGetter.cs" />
<Compile Include="NewComponents\Properties\ProgressionRankGetter.cs" />
<Compile Include="NewComponents\PseudoActivatable.cs" />
<Compile Include="NewComponents\AbilityEffectToggleBuff.cs" />
<Compile Include="NewComponents\RecalculateOnEquipmentChange.cs" />
Expand Down
11 changes: 0 additions & 11 deletions TabletopTweaks/Utilities/BloodlineTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,18 +310,7 @@ BlueprintUnitProperty casterProperty
ValueType = ContextValueType.CasterCustomProperty,
m_CustomProperty = casterProperty.ToReference<BlueprintUnitPropertyReference>()
};
//c.CasterLevel = 10;
});
/*
bp.AddContextRankConfig(c => {
c.m_Type = Kingmaker.Enums.AbilityRankType.StatBonus;
c.m_BaseValueType = ContextRankBaseValueType.ClassLevel;
c.m_Class = new BlueprintCharacterClassReference[] { BloodragerClass.ToReference<BlueprintCharacterClassReference>() };
c.m_Progression = ContextRankProgression.AsIs;
c.m_Min = 1;
c.m_UseMin = true;
});
*/
});
}

Expand Down

0 comments on commit bf5b280

Please sign in to comment.