Truinto / DarkCodex

Mod for Pathfinder: Wrath of the Righteous
MIT License
50 stars 19 forks source link

[Cross-mod compatibility] Allow AoOs with kinetic blades, not with whip #266

Closed NosVladimir closed 1 year ago

NosVladimir commented 1 year ago

Hi Truinto,

Thank you very much for this mod, for providing both interesting contents and coding examples for modding!

I recently made a mod featuring a kineticist duelist archetype that allows AoOs with normal kinetic blades (https://github.com/NosVladimir/KineticArchetypes/blob/main/KineticDuelist.cs), and I implemented it by removing the DisableAttacksOfOpportunity condition on AddKineticistBlade.OnActivate(). But currently if I turn on Patch_KineticistAllowOpportunityAttack in DarkCodex, it would fall back to not being able to AoO with kinetic blades. I also like your patch since it re-enables AoOs for other off-hand weapons, but I didn't figure out a way make my feature compatible with the patch so I just left it as is for now.

I thought an easy fix would be for you to extend the if statement in GetThreatHand_AttackOfOpportunity to check if character has the kinetic duelist KDKineticBlade feature, but then if anyone would like to add some other stuff to allow kinetic blade AoOs in the future they would need to ask you again. So are there any better workarounds or recommended solutions, that you could possibly think of?

Truinto commented 1 year ago

Sure, I have a solution. Give me a bit more time.

Truinto commented 1 year ago
var CreateAddMechanicsFeature = AccessTools.Method("CodexLib.Helper, CodexLib:CreateAddMechanicsFeature", new[] { Type.GetType("CodexLib.MechanicFeature, CodexLib") });
var comp = CreateAddMechanicsFeature?.Invoke(null, new object[] { 8 });

Use this code to generate a blueprint component. Check for null. If it is null, then DarkCodex is not installed. If it is non-null you need to add it to the blueprint that grants AoO with kinetic blades (can be BlueprintFeature or BlueprintBuff).

You could call the library directly, without reflection. But then you would need to add dependency.

Tell me, if you have any questions about this. Oh, and only works with the current update.

NosVladimir commented 1 year ago

Thank you!! This is very sweet and works perfectly. I've updated my mod and I'll close the issue now