Jump to content

Adding Perks via script


Recommended Posts

The setup:

When you pick up a book a perk gets added. Depending on your character the perk level changes.

 

The issue:

I never get above Perk Level 2. Has anyone experience with adding perks?

Or is the script at fault?

 

The script:

Scriptname SBAddPerkScience extends ObjectReference

Perk Property Science01 Auto
Perk Property Science02 Auto
Perk Property Science03 Auto
Perk Property Science04 Auto
Actor Property PlayerRef Auto
Message Property NewSkill Auto




    Event OnActivate(ObjectReference refAction)
        ObjectReference refPlayer = Game.GetPlayer()


If PlayerRef.Hasperk(Science01)
PlayerRef.AddPerk(Science02)
NewSkill.show()

Elseif PlayerRef.Hasperk(Science02)
PlayerRef.AddPerk(Science03)
NewSkill.show()

Elseif PlayerRef.Hasperk(Science03)
PlayerRef.AddPerk(Science04)
NewSkill.show()

Elseif PlayerRef.Hasperk(Science04)
Game.RewardPlayerXP(400, True)

Else
PlayerRef.AddPerk(Science01)
Endif



EndEvent

 

Link to comment
Share on other sites

Solved

I had to make it reverse

Scriptname SBAddPerkScience extends ObjectReference

Perk Property Science01 Auto
Perk Property Science02 Auto
Perk Property Science03 Auto
Perk Property Science04 Auto
Actor Property PlayerRef Auto
Message Property NewSkill Auto




    Event OnActivate(ObjectReference refAction)
        ObjectReference refPlayer = Game.GetPlayer()

If PlayerRef.Hasperk(Science04)
Game.RewardPlayerXP(400, True)

Elseif PlayerRef.Hasperk(Science03)
PlayerRef.AddPerk(Science04)
NewSkill.show()

Elseif PlayerRef.Hasperk(Science02)
PlayerRef.AddPerk(Science03)
NewSkill.show()

Elseif PlayerRef.Hasperk(Science01)
PlayerRef.AddPerk(Science02)
NewSkill.show()



Else
PlayerRef.AddPerk(Science01)
NewSkill.show()

Endif



EndEvent

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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