Jump to content

Add a perk to an Actor with a Papyrus script


ConcreteTraveler

Recommended Posts

For a new mod project, I need to add some perks to NPCs.

I tried in various ways but none works.

 

I have created a Quest

Quest Aliases : points to a unic actor.

 

1st Method_________________________________________________________________________

Scripts :

 

Actor Property myActor Auto

Perk Property myPerk Auto

 

Event OnInit() ; This event will run once, when the script is initialized

RegisterForSingleUpdate(2)

GotoState ("polling")

EndEvent

 

State polling

Event OnUpdate()

myActor.AddPerk(myPerk)

 

If myActor.HasPerk(myPerk)

Debug.TraceAndBox("Perk added")

Else

Debug.TraceAndBox("Error Perk not added")

EndIf

 

UnregisterForUpdate()

GotoState ("active") ; Switch to a state that doesn't use OnUpdate()

EndEvent

EndState

 

State active

; Do nothing in here

EndState

 

 

2nd Method____________________________________________________________________________

Scripts :

Propertys :

the ReferenceAlias of my actor.

the Perk I want to add to my actor.

________________________________________________________________________

Script code :

 

Scriptname FPstart extends Quest

 

ReferenceAlias Property myRefActor Auto

Perk Property myPerk Auto

 

Event OnInit() ; This event will run once, when the script is initialized

RegisterForSingleUpdate(2)

GotoState ("polling")

EndEvent

 

State polling

Event OnUpdate()

myRefActor.GetActorReference().AddPerk(myPerk)

 

If myRefActor.GetActorReference().HasPerk(myPerk)

Debug.TraceAndBox("Perk added")

Else

Debug.TraceAndBox("Error perk not added")

EndIf

 

UnregisterForUpdate()

GotoState ("active") ; Switch to a state that doesn't use OnUpdate()

EndEvent

EndState

 

State active

; Do nothing in here

EndState

__________________________________________________________________________________

 

It everytime goes to the Error debug, as well as if I am in the same cell thant the actor, as if I am not.

Edited by ConcreteTraveler
Link to comment
Share on other sites

Ah yes, I have not see it was noticed at the Actor::AddPerk() CreationKit wiki in the Notes section.

I've take a look at your link, is talking about ActorBase objects with Spell::RemoteCast() function, its author saids "It's not very efficient or pretty :-) but it's the best I could do".

Unfortunately what he does is not compatible with the project I'm making.

 

Hoping together for a soon SKSE or creation kit update which allow the Actor::AddPerk() function to NPSs.

Edited by ConcreteTraveler
Link to comment
Share on other sites

  • 1 year later...

I am really not the best at papyrus, but I think you can replace GetActorReference with GetReference, though I may be wrong.

 

 

I was interested in this, this was the best I could find, since .addperk only seems to apply to the player, and not an objectreference.

 

http://www.gameskyrim.com/addperk-npc-t259951.html

 

Good luck

 

 

Does anyone know if an SKSE function was ever developed or did anyone figure out a good method to add a perk via a script?

 

As far as I STILL know, as far as scripting, you can still only call on a perk to the player and not on any outside asset. There is still a way to do it, but then the perk for the NPC becomes constant, and not a toggle. This allows you to apply the perk to the NPC, but it is ALWAYS on, you can never turn it off.

 

You need to make your perk an ability, and then apply that ability through the MagicEffect in the creation kit. Any perk can be applied this way, though with NPC's the ME ( MagicEffect) must be a constant and can never be a function call.

 

As far as I know.

 

If I am wrong maybe someone can point you in the right direction. I hope this helps.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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