Jump to content

Writing .Net Plugin, Grabbing a Perk Object Not Working


Recommended Posts

EDIT: meh321 was able to help me solve it, thankfully. It's a little embarrassing how simple this was, but if anyone finds this on Google someday, the syntax should be "TESForm.LookupFormFromFile(0xAA01,"testPlugin.esp")", which I was thinking was only for pulling it out of external configuration files. Whoops.

 

Not sure if this forum is CK only, hopefully not, I can't seem to find any help/resources elsewhere. So, here's the rundown:

 

I'm using the DotNet Script Framework for Skyrim, version 14. I am using the DotNet Framework version 4.8.

 

I have an ESP, containing a perk, "My Test Perk", with a single rank, located at form ID 0500AA01. This perk is located without issue in the game itself, and can be added to the player via the console, and is functioning as intended.

 

I have a variable "thePlayer", of data type PlayerCharacter, which is being set to PlayerCharacter.Instance.

 

I have another variable, "testMe", intended to contain my perk, defined as such:

var testMe = TESForm.LookupFormById(0xAA01) as BGSPerk;

I have registered to the OnSpendMagicCost event. Inside the event, I attempt to add the perk to the player as such:

thePlayer.AddPerk(testMe,1);

However, when the OnSpendMagicCost event fires in-game, I crash, because the perk is a null object. I am able to manipulate thePlayer without issue inside of the same event, so I don't believe there's any issue there.

 

 

So, what's going on here? Am I missing something simple and just declaring the perk incorrectly?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...