SameOldBard Posted April 10, 2024 Posted April 10, 2024 Last noob question of the day, I promise. How can I figure out the level of a perk an Actor has through code? Thanks, SameOldBard
LarannKiar Posted April 11, 2024 Posted April 11, 2024 (edited) Function GetPerkRank() is not exposed to Papyrus but you can utilize it through ConditionForms. Create 4 ConditionForms in SF1Edit, each one should have only one condition item at Condition #0. Condition data ---> Type: Equal to; Comparison Value: X; Function: GetPerkRank; Perk: YourPerk; Run on: Subject. X = the PerkRank you want the ConditionForm to look for. So, by creating 4 ConditionForms with Comparison values 1, 2, 3, 4, only one ConditionForm would return True. And the one that returns True tells the PerkRank of theTargetReference. In Papyrus: ConditionForm HasPerkRank1 = (Game.GetFormFromFile(0x123, "YourMod.esp") as ConditionForm) ConditionForm HasPerkRank2 = (Game.GetFormFromFile(0x456, "YourMod.esp") as ConditionForm) If HasPerkRank1.IsTrue(theTargetReference, theTargetReference) Debug.MessageBox("theTargetReference has Rank 1 of the perk defined in the ConditionForm data") ElseIf HasPerkRank2.IsTrue(theTargetReference, theTargetReference) Debug.MessageBox("theTargetReference has Rank 2 of the perk defined in the ConditionForm data") EndIf 0x123 and 0x456 ---> replace these with the FormIDs of the ConditionForms "YourMod.esp" ---> replace with the name of the where this ConditionForm lives theTargetReference ---> replace with the Actor Reference you want the ConditionForm function GetPerkRank to be called on Edited April 11, 2024 by LarannKiar
SameOldBard Posted April 11, 2024 Author Posted April 11, 2024 24 minutes ago, LarannKiar said: Function GetPerkRank() is not exposed to Papyrus but you can utilize it through ConditionForms. Create 4 ConditionForms in SF1Edit, each one should have only one condition item at Condition #0. Condition data ---> Type: Equal to; Comparison Value: X; Function: GetPerkRank; Perk: YourPerk; Run on: Subject. X = the PerkRank you want the ConditionForm to look for. So, by creating 4 ConditionForms with Comparison values 1, 2, 3, 4, only one ConditionForm would return True. And the one that returns True tells the PerkRank of theTargetReference. In Papyrus: ConditionForm HasPerkRank1 = (Game.GetFormFromFile(0x123, "YourMod.esp") as ConditionForm) ConditionForm HasPerkRank2 = (Game.GetFormFromFile(0x456, "YourMod.esp") as ConditionForm) If HasPerkRank1.IsTrue(theTargetReference, theTargetReference) Debug.MessageBox("theTargetReference has Rank 1 of the perk defined in the ConditionForm data") ElseIf HasPerkRank2.IsTrue(theTargetReference, theTargetReference) Debug.MessageBox("theTargetReference has Rank 2 of the perk defined in the ConditionForm data") EndIf 0x123 and 0x456 ---> replace these with the FormIDs of the ConditionForms "YourMod.esp" ---> replace with the name of the where this ConditionForm lives theTargetReference ---> replace with the Actor Reference you want the ConditionForm function GetPerkRank to be called on Woo. Thanks. That certainly will do.
Recommended Posts