-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
456 additions
and
14 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
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
85 changes: 85 additions & 0 deletions
85
TomeOfTheFirebird/New Components/BloodlineMutation/AbstractBloodlineMutationComponent.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,85 @@ | ||
using BlueprintCore.Utils; | ||
using Kingmaker.Blueprints; | ||
using Kingmaker.Blueprints.Classes.Spells; | ||
using Kingmaker.UnitLogic; | ||
using Kingmaker.UnitLogic.Abilities; | ||
using Kingmaker.UnitLogic.Parts; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace TomeOfTheFirebird.New_Components.BloodlineMutation | ||
{ | ||
class AbstractBloodlineMutationComponent : UnitFactComponentDelegate | ||
{ | ||
public List<BlueprintCharacterClassReference> classes = new(); | ||
|
||
public List<BlueprintSpellbookReference> archetypeBooks = new(); | ||
|
||
private static Dictionary<SpellSchool, BlueprintFeatureReference> spellFocuses; | ||
|
||
private static BlueprintFeatureReference _spellFocus; | ||
|
||
|
||
|
||
protected bool AppliesToAbility(AbilityData ability) | ||
{ | ||
if (spellFocuses == null) | ||
{ | ||
spellFocuses = new(); | ||
spellFocuses.Add(SpellSchool.Abjuration, BlueprintTool.GetRef<BlueprintFeatureReference>("71a3f1c1ac77ae3488b9b3d6d2aac01a")); | ||
spellFocuses.Add(SpellSchool.Conjuration, BlueprintTool.GetRef<BlueprintFeatureReference>("d342cc595f499434687f9765f56d525c")); | ||
spellFocuses.Add(SpellSchool.Divination, BlueprintTool.GetRef<BlueprintFeatureReference>("955e97411611d384db2cbc00d7ed5ead")); | ||
spellFocuses.Add(SpellSchool.Enchantment, BlueprintTool.GetRef<BlueprintFeatureReference>("c5bf645f128c39b40850cde005b8538f")); | ||
spellFocuses.Add(SpellSchool.Evocation, BlueprintTool.GetRef<BlueprintFeatureReference>("c5bf645f128c39b40850cde005b8538f")); | ||
spellFocuses.Add(SpellSchool.Illusion, BlueprintTool.GetRef<BlueprintFeatureReference>("e588279a80eb7a24b813fadad4bc83b5")); | ||
spellFocuses.Add(SpellSchool.Necromancy, BlueprintTool.GetRef<BlueprintFeatureReference>("8791da25011fd1844ad61a3fea6ece54")); | ||
spellFocuses.Add(SpellSchool.Transmutation, BlueprintTool.GetRef<BlueprintFeatureReference>("49907a2e51b49d641aad3c9781a3a698")); | ||
_spellFocus = BlueprintTool.GetRef<BlueprintFeatureReference>("16fa59cc9a72a6043b566b49184f53fe"); | ||
} | ||
|
||
if (ability.Blueprint.IsSpell) | ||
{ | ||
if (classes.Any(x=>x.Equals(ability.SpellbookBlueprint.m_CharacterClass) || archetypeBooks.Any(x=>ability.m_SpellbookBlueprint))) | ||
{ | ||
var part = Owner.Ensure<UnitPartBloodlineSpellTracker>(); | ||
if (part.IsBloodlineSpell(ability.Blueprint.ToReference<BlueprintAbilityReference>())) | ||
{ | ||
return true; | ||
} | ||
|
||
var school = ability.Blueprint.School; | ||
if (school == SpellSchool.None) | ||
return false; | ||
else if (Owner.Progression.Features.HasFact(spellFocuses[school])) | ||
return true; | ||
var expandedstudypart = Owner.Get<UnitPartExpandedArsenal>(); | ||
if (expandedstudypart == null) | ||
return false; | ||
else | ||
return expandedstudypart.HasSpellSchoolEntry(school) && Owner.Progression.Features.HasFact(_spellFocus); | ||
|
||
|
||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
|
||
|
||
} | ||
else if (ability.Blueprint.Type == Kingmaker.UnitLogic.Abilities.Blueprints.AbilityType.SpellLike || ability.Blueprint.Type == Kingmaker.UnitLogic.Abilities.Blueprints.AbilityType.Supernatural) | ||
{ | ||
//For bloodline powers when I add those to this | ||
return false; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
|
47 changes: 47 additions & 0 deletions
47
TomeOfTheFirebird/New Components/BloodlineMutation/BloodHavocComponent.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,47 @@ | ||
using Kingmaker.PubSubSystem; | ||
using Kingmaker.RuleSystem; | ||
using Kingmaker.RuleSystem.Rules.Damage; | ||
using Kingmaker.UnitLogic.Mechanics; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace TomeOfTheFirebird.New_Components.BloodlineMutation | ||
{ | ||
class BloodHavocComponent : AbstractBloodlineMutationComponent, IInitiatorRulebookHandler<RuleCalculateDamage>, IRulebookHandler<RuleCalculateDamage>, ISubscriber, IInitiatorRulebookSubscriber | ||
{ | ||
public void OnEventAboutToTrigger(RuleCalculateDamage evt) | ||
{ | ||
MechanicsContext context = evt.Reason.Context; | ||
if (((context != null) ? context.SourceAbility : null) == null) | ||
{ | ||
return; | ||
} | ||
if (context.SourceAbilityContext?.Ability == null) | ||
{ | ||
return; | ||
} | ||
else if (AppliesToAbility(context.SourceAbilityContext.Ability)) | ||
{ | ||
foreach (BaseDamage baseDamage in evt.DamageBundle) | ||
{ | ||
if (!baseDamage.Precision) | ||
{ | ||
DiceFormula modifiedValue = baseDamage.Dice.ModifiedValue; | ||
int bonus = modifiedValue.Rolls; | ||
baseDamage.AddModifier(bonus, base.Fact); | ||
} | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
public void OnEventDidTrigger(RuleCalculateDamage evt) | ||
{ | ||
|
||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
TomeOfTheFirebird/New Components/BloodlineMutation/BloodlineSpellComponent.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,74 @@ | ||
using BlueprintCore.Blueprints.CustomConfigurators.Classes; | ||
using Kingmaker.Blueprints; | ||
using Kingmaker.UnitLogic; | ||
using Kingmaker.UnitLogic.FactLogic; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace TomeOfTheFirebird.New_Components.BloodlineMutation | ||
{ | ||
[AllowMultipleComponents] | ||
public class BloodlineSpellComponent : UnitFactComponentDelegate | ||
{ | ||
|
||
public BlueprintAbilityReference m_spell; | ||
public override void OnActivate() | ||
{ | ||
OnTurnOn(); | ||
} | ||
|
||
public override void OnDeactivate() | ||
{ | ||
OnTurnOff(); | ||
} | ||
|
||
public override void OnTurnOn() | ||
{ | ||
|
||
base.OnTurnOn(); | ||
var part = base.Owner.Ensure<UnitPartBloodlineSpellTracker>(); | ||
part.RegisterBloodlineSpell(Fact, m_spell); | ||
|
||
|
||
} | ||
|
||
public override void OnTurnOff() | ||
{ | ||
var part = base.Owner.Get<UnitPartBloodlineSpellTracker>(); | ||
if (part != null) | ||
part.UnregisterBloodlineSpell(Fact, m_spell); | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
public static class BloodlineSpellComponentAssistant | ||
{ | ||
public static FeatureConfigurator AddBloodlineSpellComponents(this FeatureConfigurator featureConfigurator) | ||
{ | ||
List<BlueprintAbilityReference> spells = new(); | ||
|
||
featureConfigurator.EditComponents<AddKnownSpell>(x => | ||
{ | ||
if (!spells.Contains(x.m_Spell)) | ||
{ | ||
spells.Add(x.m_Spell); | ||
} | ||
|
||
}, y => true); | ||
foreach(BlueprintAbilityReference spell in spells) | ||
{ | ||
featureConfigurator.AddComponent<BloodlineSpellComponent>(x => | ||
{ | ||
x.m_spell = spell; | ||
}); | ||
} | ||
|
||
return featureConfigurator; | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
TomeOfTheFirebird/New Components/BloodlineMutation/UnitPartBloodlineSpellTracker.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,32 @@ | ||
using Kingmaker.Blueprints; | ||
using Kingmaker.UnitLogic; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace TomeOfTheFirebird.New_Components.BloodlineMutation | ||
{ | ||
class UnitPartBloodlineSpellTracker : OldStyleUnitPart | ||
{ | ||
private Dictionary<UnitFact, BlueprintAbilityReference> mappings = new(); | ||
|
||
public void RegisterBloodlineSpell(UnitFact source, BlueprintAbilityReference spell) | ||
{ | ||
if (!mappings.ContainsKey(source)) | ||
mappings.Add(source, spell); | ||
} | ||
|
||
public bool IsBloodlineSpell(BlueprintAbilityReference spell) | ||
{ | ||
return mappings.ContainsValue(spell); | ||
} | ||
|
||
public void UnregisterBloodlineSpell(UnitFact source, BlueprintAbilityReference spell) | ||
{ | ||
|
||
mappings.Remove(source); | ||
} | ||
} | ||
} |
Oops, something went wrong.