Skip to content

Commit

Permalink
Hopefully fixed size scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
pheonix99 committed Nov 3, 2021
1 parent 56d7247 commit ecea25e
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 10 deletions.
81 changes: 81 additions & 0 deletions LevelableAivu/AivuSizeFix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using HarmonyLib;
using Kingmaker.Designers.Mechanics.Buffs;
using Kingmaker.EntitySystem;
using Kingmaker.Enums;
using Kingmaker.UnitLogic.Buffs;
using Kingmaker.UnitLogic.Parts;
using Kingmaker.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LevelableAivu
{
[HarmonyPatch(typeof(UnitPartSizeModifier), "UpdateSize")]

static class AivuSizeFix
{
[HarmonyPriority(Priority.Normal)]
static bool Prefix(UnitPartSizeModifier __instance)
{

var variableSize = __instance.Owner.Facts.m_Facts.SelectMany(x => x.Components).Select(x => x.SourceBlueprintComponent).OfType<VariableBaseSize>();
if (variableSize.Count() == 0)
{

return true;
}
else
{

Size ogSize = __instance.Owner.OriginalSize + variableSize.Select(x => x.Shift).Sum();
Size finalSize = ogSize;
EntityFact entityFact = __instance.m_SizeChangeFacts.LastItem<EntityFact>();
if (entityFact != null)
{
foreach (EntityFactComponent entityFactComponent in entityFact.Components)
{
Polymorph polymorph = entityFactComponent.SourceBlueprintComponent as Polymorph;
ChangeUnitSize changeUnitSize = entityFactComponent.SourceBlueprintComponent as ChangeUnitSize;
if (polymorph != null)
{
Size? polySize = polymorph.GetUnitSize(entityFactComponent);
if (polySize != null)
finalSize = polySize.Value;

}
else if (changeUnitSize != null)
{
if (changeUnitSize.IsTypeDelta)
{
finalSize = ogSize + changeUnitSize.SizeDelta;
//Main.Log($"Size Adjust: Size set to :{finalSize}");
}
else if (changeUnitSize.IsTypeValue)
{
finalSize = changeUnitSize.Size;
//Main.Log($"Size Set: Size set to :{finalSize}");
}
}
}
}
else
{
__instance.Owner.Remove<UnitPartSizeModifier>();
}
Main.Log($"Final Size Setto :{finalSize}");
__instance.Owner.State.Size = finalSize;
return false;
}


}
}

static class AfterTheFactAivuSizeFix
{

}
}
75 changes: 66 additions & 9 deletions LevelableAivu/CreateHavocDragonClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void RemoveUnneededElements()

static void BuildHavocDragonClasses()
{

BlueprintUnit AivuUnitLoaded = Resources.GetBlueprint<BlueprintUnit>("32a037e97c3d5c54b85da8f639616c57");
AivuUsesMythixXPNew = Helpers.CreateBlueprint<BlueprintFeature>("AivuUsesMythicXP", x =>
{

Expand Down Expand Up @@ -134,12 +134,32 @@ static void BuildHavocDragonClasses()
AivuSizeUpToMedium.SetDescription("Aivu Is Now Medium Size");
AivuSizeUpToMedium.HideInCharacterSheetAndLevelUp = false;
AivuSizeUpToMedium.HideInUI = false;


ChangeUnitSize mediumMechanic = AivuSizeUpToMedium.Components.OfType<ChangeUnitSize>().FirstOrDefault();
if (mediumMechanic != null)
{


mediumMechanic.SizeDelta = 0;
AivuSizeUpToMedium.AddComponent(new VariableBaseSize()
{
Shift = 1
});

Main.LogPatch("Patched Size", AivuSizeUpToMedium);

}
else
{
Main.Log("Medium Mechanic not found");
}


BlueprintFeature AivuSizeUpToMediumDummy = Helpers.CreateBlueprint<BlueprintFeature>("AivuSmallToMedium", x =>
{
x.SetName("Aivu Size Up Dummy");
x.SetDescription("If you see this, respec");

});
BlueprintFeature AivuSizeUpToLargeDummy = Helpers.CreateBlueprint<BlueprintFeature>("AivuMediumToLarge", x =>
{
Expand Down Expand Up @@ -222,7 +242,7 @@ static void BuildHavocDragonClasses()
x.m_Feature = AivuUsesMythixXPNew.ToReference<BlueprintFeatureReference>();
}));



});

Expand Down Expand Up @@ -350,11 +370,33 @@ void AddToClasslLevelEntry(BlueprintProgression progression, int level, Blueprin
AivuSizeUpToLarge.SetDescription("Aivu Is Now Large Size");
AivuSizeUpToLarge.HideInCharacterSheetAndLevelUp = false;
AivuSizeUpToLarge.HideInUI = false;
ChangeUnitSize largeMechanic = AivuSizeUpToLarge.Components.OfType<ChangeUnitSize>().FirstOrDefault();




if (largeMechanic != null)
{

largeMechanic.SizeDelta = 0;
AivuSizeUpToLarge.AddComponent(new VariableBaseSize()
{
Shift = 1,

});

Main.LogPatch("Patched Size", AivuSizeUpToLarge);

}
else
{
Main.Log("LargeMechanic not found");
}
BlueprintFeature HeroicAura = Resources.GetBlueprint<BlueprintFeature>("bb0be011191b77f418d2225399109f0c");








#endregion

Expand All @@ -381,15 +423,30 @@ void AddToClasslLevelEntry(BlueprintProgression progression, int level, Blueprin



//int mediumLev = 2;
//int largeLev = 3;
int mediumLev = 16;
int largeLev = 26;



AddToClasslLevelEntry(HavocDragonProgressionAdded, 1, DragonType);

AddToClasslLevelEntry(HavocDragonProgressionAdded, 16, AivuSizeUpToMedium);
AddToClasslLevelEntry(HavocDragonProgressionAdded, mediumLev, AivuSizeUpToMedium);
if (largeLev < 21)
{
AddToClasslLevelEntry(HavocDragonProgressionAdded, largeLev, AivuSizeUpToLarge);
}
else
{
AddToClasslLevelEntry(HavocDragonT2ProgressionAdded, largeLev - 20, AivuSizeUpToLarge);
}


//AddToClasslLevelEntry(HavocDragonProgressionAdded, 16, AivuSizeUpToMedium);
AddToClasslLevelEntry(HavocDragonProgressionAdded, 17, AivuDragonfear);
AddToClasslLevelEntry(HavocDragonProgressionAdded, 18, AzataDragonDR1);
AddToClasslLevelEntry(HavocDragonT2ProgressionAdded, 6, AivuSizeUpToLarge);
//AddToClasslLevelEntry(HavocDragonT2ProgressionAdded, 6, AivuSizeUpToLarge);
AddToClasslLevelEntry(HavocDragonT2ProgressionAdded, 7, HeroicAura);
AddToClasslLevelEntry(HavocDragonT2ProgressionAdded, 8, AzataDragonDR2);

Expand Down
2 changes: 1 addition & 1 deletion LevelableAivu/Info.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Id": "LevelableAivu",
"DisplayName": "Levelable Aivu",
"Author": "pheonix99",
"Version": "1.0.2",
"Version": "1.0.3",
"ManagerVersion": "0.21.3",
"Requirements": [],
"AssemblyName": "LevelableAivu.dll",
Expand Down
2 changes: 2 additions & 0 deletions LevelableAivu/LevelableAivu.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AivuSizeFix.cs" />
<Compile Include="Attributes.cs" />
<Compile Include="VariableBaseSizeGetter.cs" />
<Compile Include="FinishingTouches.cs" />
<Compile Include="Config\Blueprints.cs" />
<Compile Include="Config\ICollapsableGroup.cs" />
Expand Down
24 changes: 24 additions & 0 deletions LevelableAivu/VariableBaseSizeGetter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Kingmaker.Blueprints;
using Kingmaker.Designers.Mechanics.Buffs;
using Kingmaker.EntitySystem.Entities;
using Kingmaker.UnitLogic;
using Kingmaker.UnitLogic.Mechanics.Properties;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LevelableAivu
{

class VariableBaseSize : UnitFactComponentDelegate
{
public override void OnActivate()
{

}

public int Shift;
}
}

0 comments on commit ecea25e

Please sign in to comment.