JohN100x1 / IsekaiMod

An unbalanced gameplay mod for Pathfinder: Wrath of the Righteous
MIT License
19 stars 10 forks source link

Refactoring patch methods #130

Closed JohN100x1 closed 1 year ago

JohN100x1 commented 1 year ago

I'm going to refactor the patching methods currently in StaticReferences and put them in a new class called PatchTools.

@kjk001 I took a look in StaticReferences and came across this

public static BlueprintFeatureSelection SorcererFeatSelection = BlueprintTools.GetBlueprint<BlueprintFeatureSelection>("d6dd06f454b34014ab0903cb1ed2ade3");

However when I searched the blueprints for SorcererFeatSelection it gave me 3a60f0c0442acfb419b0c03b584e1394 for the guid while d6dd06f454b34014ab0903cb1ed2ade3 is for SorcererBonusFeat. I'm guessing this is a bug?

JohN100x1 commented 1 year ago

It looks like the buffs need to be patched manually since they are unreachable unless the patch methods get changed to explore AbilityEffectRunAction, and other components that run contexts actions that apply buffs.

kjk001 commented 1 year ago

If this is a bug depends on the context in which it is used. I might just have been lazy with the naming and actually mean the BonusFeat. I will check, but my first guess would be that I was just lazy with the name, and the second that I should actually delete the reference and use the already provided selections link for it anyway...

If you give me one or two examples the change to explore them as well should be easy enough.

kjk001 commented 1 year ago

Or Option 3, both of those selections should have been referenced might also be true.

kjk001 commented 1 year ago

@JohN100x1 after the merging to get the refactoring I get an error that c.ReplaceIfHigher = true; is unknown on ReplaceStatBaseAttribute so which extension does that attribute come from? Also in ReleaseEnergy it complains that the Get() Method for Positive and Negative Energy is unknown and you indeed seem to have removed those in patch 865841411d8f48aae2356c3304ffd765b3993e66 [8658414]

JohN100x1 commented 1 year ago

Ok I just made a commit to fix Release Energy.

I'm not sure about the error with c.ReplaceIfHigher = true;. It doesn't give me an error for that

kjk001 commented 1 year ago

there should be a dependency that is incorrect for me because some patch or extension added the ReplaceIfHigher if there is no error in it for you

JohN100x1 commented 1 year ago

maybe try cleaning the solution. It could be because I have a newer Assembly-CSharp.dll

kjk001 commented 1 year ago

it should be the assemly c-sharp.dll, but that one is provided by the game, so why should your version be newer if we are both on the latest patch?

kjk001 commented 1 year ago

if you click into the ReplaceStatBaseAttribute what does it say for the source of the class for you?

JohN100x1 commented 1 year ago

Delete the Assembly-CSharp.dll in \lib and then publicise the one from the game directory.

#region Assembly Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// C:\Users\JohN100x1\Dev\C#\IsekaiMod\lib\Assembly-CSharp.dll
// Decompiled with ICSharpCode.Decompiler 7.1.0.6543
#endregion

using Kingmaker.Blueprints;
using Kingmaker.Blueprints.JsonSystem;
using Kingmaker.EntitySystem.Stats;
using Owlcat.QA.Validation;

namespace Kingmaker.UnitLogic.FactLogic
{
    [AllowMultipleComponents]
    [TypeId("1c1315a505494aed84a6570a8111a6ec")]
    public class ReplaceStatBaseAttribute : UnitFactComponentDelegate
    {
        public StatType TargetStat;

        public StatType BaseAttributeReplacement;

        public bool ReplaceIfHigher;

        public override void OnTurnOn()
        {
            base.OnTurnOn();
            ReplaceStat();
        }

        public override void OnTurnOff()
        {
            base.OnTurnOff();
            DiscardReplaceStat();
        }

        public void ReplaceStat()
        {
            (base.Owner.Stats.GetStat(TargetStat) as IModifiableValueReplaceBaseStat)?.ReplaceBaseAttribute(BaseAttributeReplacement, ReplaceIfHigher);
        }

        public void DiscardReplaceStat()
        {
            (base.Owner.Stats.GetStat(TargetStat) as IModifiableValueReplaceBaseStat)?.RemoveBaseAttributeReplacement(BaseAttributeReplacement);
        }

        public override void ApplyValidation(ValidationContext context, int parentIndex)
        {
            base.ApplyValidation(context, parentIndex);
            if (TargetStat != StatType.AC && !TargetStat.IsSkill())
            {
                context.AddError("Stat: only AC and Skills allowed");
            }

            if (!BaseAttributeReplacement.IsAttribute())
            {
                context.AddError("Replacement: must be an Attribute");
            }
        }
    }
}
kjk001 commented 1 year ago

Based on the <Move SourceFiles="$(SolutionDir)lib/Assembly-CSharp_public.dll" DestinationFiles="$(SolutionDir)\lib\Assembly-CSharp.dll" /> this should actually be the Pathfinder Second Adventure\Wrath_Data\Managed\Assembly-CSharp_public.dll, so why does that file for me not contain that bool, did you copy your dll manually from another source?

JohN100x1 commented 1 year ago

I'm pretty sure it's from the game directory. I deleted my /lib folder and then clicked Build -> Clean Solution.

    <Reference Include="Assembly-CSharp">
      <HintPath>$(SolutionDir)lib\Assembly-CSharp.dll</HintPath>
      <Private>False</Private>
    </Reference>
kjk001 commented 1 year ago

Got it, it doesn't because that line of code is dead code, you are directly copying the Assempbly-C-Sharp.dll rather than the Assembly-C-Sharp_public.dll file from the game folder.

Now, when referencing this file from the game folder this does not work because then it keeps complaining that half the methods have an insufficient visibility, but by running the publicise task on this file while coyping it to the lib folder you then get something that has visibilities similiar to the public.dll version of it...

kjk001 commented 1 year ago

I removed the dead parts of the csproj file, so next time it should be easier to see where the file is actually coming from

JohN100x1 commented 1 year ago

That line of code isn't dead. It's supposed to rename the publicised Assembly-CSharp_public.dll into Assempbly-CSharp.dll.

图片