Jump to content

Adding perks via potions/spells


Recommended Posts

Umm... from OnRead, you are calling not your 'AddPerk' - you are calling AddPerk on the player Actor. Incorrectly too, cause it expects a Perk type parameter.

 

Just move the contents of your AddPerk function into OnRead... unless you plan to invoke it from other places. In which case:

 

Event OnRead()

AddNextAlchemyPerk()

EndEvent

 

Function AddNextAlchemyPerk()

...

 

It would be ok to use 'AddPerk' function name, since neither ObjectReference not Form classes define it, but it helps to avoid confusing it with AddPerk being called on the player, and gives better idea about what function does.

Link to comment
Share on other sites

You can't declare a Function's name as an already existing Papyrus function = AddPerk()

* Plus, you have 'Typos'

* Also, Don't use in succession the function 'Game.GetPlayer()', this function is very espensive and can cause lags.

Use it once to declare and store it.

 

Perk property Experimenter30AlchemyRedone auto
Perk property Experimenter50AlchemyRedone auto
Perk property Experimenter70AlchemyRedone auto
Perk property Experimenter90AlchemyRedone auto
 
Bool Property Exp30 = False Auto Hidden
Bool Property Exp50 = False Auto Hidden
Bool Property Exp70 = False Auto Hidden
Bool Property Exp90 = False Auto Hidden
 
Actor ActorPlayer
 
Event OnRead()
    ActorPlayer = Game.GetPlayer()
    if Exp30 = False
        ActorPlayer.AddPerk(Experimenter30AlchemyRedone)
        Exp30 = True
    elseif Exp50 = False
        ActorPlayer.AddPerk(Experimenter50AlchemyRedone)
        Exp50 = True
    elseif Exp70 = False
        ActorPlayer.AddPerk(Experimenter70AlchemyRedone)
        Exp70 = True
    elseif Exp90 = False
        ActorPlayer.AddPerk(Experimenter90AlchemyRedone)
        Exp90 = True
   endif
EndEvent
Link to comment
Share on other sites

Okay. So I had an idea, and tried something new:

Scriptname AlchemyRedoneAddPerkExp extends ObjectReference
 
Perk property Alchemist00AlchemyRedone auto
Perk property Experimenter30AlchemyRedone auto
Perk property Experimenter50AlchemyRedone auto
Perk property Experimenter70AlchemyRedone auto
Perk property Experimenter90AlchemyRedone auto
 
Event OnRead()
    Game.GetPlayer().AddPerk()
EndEvent
 
FunctionAddPerk()
    if Game.GetPlayer().HasPerk(Alchemist00AlchemyRedone)
       Game.GetPlayer().AddPerk(Experimenter30AlchemyRedone)
    elseif Game.GetPlayer().HasPerk(Experimenter30AlchemyRedone)
        Game.GetPlayer().AddPerk(Experimenter50AlchemyRedone)
     elseif Game.GetPlayer().HasPerk(Experimenter50AlchemyRedone)
        Game.GetPlayer().AddPerk(Experimenter70AlchemyRedone)
    elseif Game.GetPlayer().HasPerk(Experimenter70AlchemyRedone)
        Game.GetPlayer().AddPerk(Experimenter90AlchemyRedone)
   endif
EndFunction

I finally figured out how to view the compiler log (man, the CK is seriously unintuitive), and it gave me this:

 

AlchemyRedoneAddPerkExp.psc(13,15): no viable alternative at input '('
No output generated for AlchemyRedoneAddPerkExp, compilation failed.
I can see it's pointing to lines 13 and 15, but beyond that, I'm lost.
Edited by WalkerInShadows
Link to comment
Share on other sites

Did you read my prior post?

Scriptname AlchemyRedoneAddPerkExp extends ObjectReference

Perk property Alchemist00AlchemyRedone auto
Perk property Experimenter30AlchemyRedone auto
Perk property Experimenter50AlchemyRedone auto
Perk property Experimenter70AlchemyRedone auto
Perk property Experimenter90AlchemyRedone auto

Event OnRead()
Game.GetPlayer().AddPerk() <<<< This will call 'AddPerk' on the Player object, NOT 'AddPerk' that you define below.
EndEvent

FunctionAddPerk() <<<< You need a space between Function and AddPerk. The error you get means problem in line 13, position 15. This is line 13. The problem is you got open parenthesis following something compiler does not recognize as function.
if Game.GetPlayer().HasPerk(Alchemist00AlchemyRedone) <<<<< Game.GetPlayer is effin' expensive, AVOID using it.
Game.GetPlayer().AddPerk(Experimenter30AlchemyRedone)
elseif Game.GetPlayer().HasPerk(Experimenter30AlchemyRedone)
Game.GetPlayer().AddPerk(Experimenter50AlchemyRedone)
elseif Game.GetPlayer().HasPerk(Experimenter50AlchemyRedone)
Game.GetPlayer().AddPerk(Experimenter70AlchemyRedone)
elseif Game.GetPlayer().HasPerk(Experimenter70AlchemyRedone)
Game.GetPlayer().AddPerk(Experimenter90AlchemyRedone)
endif
EndFunction


You also completely messed up your function logic.
What you had before:
If player had no perk, it would give 'Experimenter30'. If player already had that, it would give 'Experimenter50' and so on.
What you have now (assuming player has already been assigned Alchemist00 perk elsewhere) - it would every time succeed in 1st if, repeatedly re-adding 'Experimenter30' and never going to higher perks.

What you should have instead:

Scriptname AlchemyRedoneAddPerkExp extends ObjectReference

Actor property PlayerRef auto <<<<< Instead of abusing Game.GetPlayer(), define a property.
Perk property Alchemist00AlchemyRedone auto
Perk property Experimenter30AlchemyRedone auto
Perk property Experimenter50AlchemyRedone auto
Perk property Experimenter70AlchemyRedone auto
Perk property Experimenter90AlchemyRedone auto

Event OnRead()
AddNextAlchemyPerk() <<<< This will call the function that is defined locally. And you should avoid defining custom functions with same name as native functions.
EndEvent


Function AddNextAlchemyPerk()
if !PlayerRef.HasPerk(Experimenter30AlchemyRedone)
PlayerRef.AddPerk(Experimenter30AlchemyRedone)
elseif !PlayerRef.HasPerk(Experimenter50AlchemyRedone)
PlayerRef.AddPerk(Experimenter50AlchemyRedone)
elseif !PlayerRef.HasPerk(Experimenter70AlchemyRedone)
PlayerRef.AddPerk(Experimenter70AlchemyRedone)
elseif !PlayerRef.HasPerk(Experimenter90AlchemyRedone)
PlayerRef.AddPerk(Experimenter90AlchemyRedone)
endif
EndFunction


Then, in your .esp script properties, make sure to fill the PlayrRef property like this:

TfL12pm.jpg

 

Link to comment
Share on other sites

Sorry.. for some reason, those two posts didn't show up. Like I said, I have zero expertience with Papyrus - all I know is what I've picked up from reading the wiki. I was using Game.GetPlayer because (surprise!) that's the example the wiki uses.

 

Nice to know I had it (mostly) right the first time. :laugh: And thanks for the help.

Edited by WalkerInShadows
Link to comment
Share on other sites

I was looking this script over, and I realized that it would add ALL the perks at the same time. I want to add an Alchemy check to add them at specific times. I know the command (PlayerRef.GetActorValue(Alchemy)), but I'm not sure how to implement it. The wiki isn't very clear on this point - I assume it's a separate function to check for the value... but then how do I apply it to this line:

 

if !PlayerRef.HasPerk(MedAlchemyAlchemyRedone) && PlayerRef.GetActorValue(Alchemy)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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