SetJohnnyOnAddPerkEventHandler
From GECK
A function added by the JohnnyGuitar NVSE Plugin.
Description
Sets/removes the specified UDF Script as a handler that will be invoked when a specified Perk (or any Perk) is added to the player, or its Perk Rank is changed. FormLists are also accepted as filters.
When invoked, the script is passed with three arguments: the added perk, previous perk rank and new perk rank.
Syntax
SetJohnnyOnAddPerkEventHandler setORremove:1/0 handlerScript:ref flag:int perk:filter
Or:
SetOnAddPerkEventHandler setORremove:1/0 handlerScript:ref flag:int perk:filter
Example
SetJohnnyOnAddPerkEventHandler 1 OnAddPerkUDF 0 BloodyMess
Sets the OnAddPerkUDF script as a handler to be invoked when Bloody Mess perk is added to the player (or any other actor).
SetJohnnyOnAddPerkEventHandler 0 OnAddPerkUDF 0 BloodyMess
Removes the OnAddPerkUDF script as a handler of the above.
Handler Script
A skeleton handler script for this event:
scn OnAddPerkUDF ref rPerk int iOldRank int iNewRank ref rPerkOwner begin Function {rPerk, iOldRank, iNewRank} set rPerkOwner to this (code) end
Notes
- Flag argument is reserved for future use and should always be 0.
- To differentiate between player and companion perks, use GetAltPerkRank in the handler script.
- Since JIP LN version 56.24, it is possible for actors other than the player character to receive and hold perks directly. And since JohnnyGuitar version 4.0, this handler can thus fire for any actor and not just the player. Since it cannot be filtered for a specific actor that received the perk, you may want to check inside the script which actor did through GetSelf.