Possible to remove all perks via scripts?

Post » Wed Jun 20, 2012 7:45 am

I'm wondering if it's possible to remove all player aquired perks through scripting? I'm doing a mod that redesigns some of the perk trees, and in order to be compatable with save games I'm going to need a way for my mod to remove perks a player has earned, and ideally "refund" the perk points back to the player.

I suppose I could do checks to see if player has X perk in an oninit script. If the player does have X perk, then remove it, add +1 to some variable that checks the number of removed perks, and then output that variable to the player in a message box saying how many perk points they need to manually add (this is possible via the console right?).

But that script would be extremely intensive to do, for all 281 perks :tongue: And not to mention a very "brute force" method.

I'm correct in assuming it's impossible to add perk-spending points to the player via scripts yes?
User avatar
nath
 
Posts: 3463
Joined: Mon Jan 22, 2007 5:34 am

Post » Wed Jun 20, 2012 6:33 am

Yes on all points. And it would take a while to setup a perk cleaning script since you have to attach each perk as a reference to the script.
You would need SKSE or something similar to add to the perk points since there is no way to do this in the CK.
User avatar
Francesca
 
Posts: 3485
Joined: Thu Jun 22, 2006 5:26 pm

Post » Wed Jun 20, 2012 8:55 am

I see, how would I use something like SKSE? I've never used it before. I'm aware of the ability that it can do that, but I'm unsure how to take advantage of it.

I think the best course of action would be to upload a seperate mod file/ESP for users who wish to install on exsisting characters, in order to safely "uninstall" the default perks so when they load up the mod they can reapply (to their discretion) the new perks.
User avatar
Ross
 
Posts: 3384
Joined: Thu Aug 10, 2006 7:22 pm

Post » Wed Jun 20, 2012 8:39 pm

Yes on all points. And it would take a while to setup a perk cleaning script since you have to attach each perk as a reference to the script.
You would need SKSE or something similar to add to the perk points since there is no way to do this in the CK.
You know about auto-filling properties right? As long as the variable name for each Perk property in the script matches the editor id of the perk, filling in all the properties requires a single button click. So, if you know about regular expressions and have a list of all the perks in the game by editor id (you can get this from UESP) writing a script to remove all the perks a player has acquired is a cinch. As in, would take five minutes to do in theory, or maybe 30 minutes in practice. This is what I did with Perk Books, although with that I was adding perks, not removing them.

That's for removing them by script, unfortunately you can't give the player perk points even with SKSE yet, so that part is a no-go.
User avatar
Alba Casas
 
Posts: 3478
Joined: Tue Dec 12, 2006 2:31 pm

Post » Wed Jun 20, 2012 6:19 am

Your script to remove perks would be very simple, only a few lines, and in your case, you probably want to attach it to a quest.
In that script you declare a FormList containing all perks you wish to remove/refund, when you have that, you can simply iterate over that list and remove/refund one perk at a time.

Like WilliSea mentioned, refunding perk points can't be done, not without external help. Currently it's only possible via http://alexander.sannybuilder.com/?category=other-bethgames&altname=skyrim_script_dragon but I'd discourage to use it in favor of http://skse.silverlock.org/.
SKSE doesn't have papyrus support yet, so you'll have to wait until it does. For the same reason, I can't tell you how the workflow might be affected.
But, once it does support papyrus, it will most likely add a new RemovePerk function, named slightly different or enhance the current one to allow refunding perk points.
Either way, the original script will have to be modified to do take advantage of that.
User avatar
Mylizards Dot com
 
Posts: 3379
Joined: Fri May 04, 2007 1:59 pm

Post » Wed Jun 20, 2012 4:48 pm

Formlists are a great idea, I'll look into that.

So SKSE can't add perks to the player? I thought a mod was released that does just that?

I could always just give a little perk-calculator telling the user how many perks were removed, and then how many points to add (plus or minus bonus perk points or something), then tell them to use cheatengine to get it :tongue:
User avatar
Emily abigail Villarreal
 
Posts: 3433
Joined: Mon Aug 27, 2007 9:38 am

Post » Wed Jun 20, 2012 7:29 am

Adding or removing the perks themselves is easily done by script. As others have said, it's perk points that cannot be given or removed as yet.

As to the removal script, here's a snippent of what I wrote for my mod...
Properties and functions not shown - it's just something to get you thinking...

;Removal;;;;;;;;;;;;if GetStage() == 20debug.MessageBox("ASAP is removing perks it added.  Do not perform any action that will increase any skill levels until removal is complete.  Wait for the 'removal completed' message."); first while loop - sort through skills and initialize temporary arrays to equal skill arrays;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;     SkillNameElement = 0     While (SkillNameElement < SkillName.Length)     SelectSkill(SkillNameElement)          ; Check if perk was added and remove it          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;          TempPerksElement = 0          While (TempPerksElement < TempPerks.Length)	        if (Game.GetPlayer().HasPerk(TempPerks[TempPerksElement])) && (TempPerksAdded[TempPerksElement].IsEnabled())	            Game.GetPlayer().RemovePerk(TempPerks[TempPerksElement])	            TempPerksAdded[TempPerksElement].Disable()	         endif          TempPerksElement += 1          EndWhile      SkillNameElement += 1      endWhile        debug.MessageBox("ASAP removal has completed.  Save your game.  Exit Skyrim.  Uninstall ASAP.esp and scripts.")      SetStage(30)      UnregisterForUpdate()      ASAP.Stop()endIf

Admittedly it's crude, but it does the job. I used arrays instead of formlists, but I plan on re-thinking that...

edir: damn formatting....
User avatar
keri seymour
 
Posts: 3361
Joined: Thu Oct 19, 2006 4:09 am

Post » Wed Jun 20, 2012 1:49 pm

Thanks for the insight. Acutally, what exactly do "while" loops do?

Does it, once an event has been activated, constantly run? I.E. does it do the same role as an "OnUpdate()" event, except localized to just that loop and runs as fast as it can? Does the script continue past the while loop?
User avatar
dell
 
Posts: 3452
Joined: Sat Mar 24, 2007 2:58 am

Post » Wed Jun 20, 2012 6:58 am

Thanks for the insight. Acutally, what exactly do "while" loops do?

Does it, once an event has been activated, constantly run? I.E. does it do the same role as an "OnUpdate()" event, except localized to just that loop and runs as fast as it can? Does the script continue past the while loop?

Code inside a while loop continue as long as the loop counter is less than the limit.

x = 0
while x < 10
;do stuff <<<< runs each time x imcrements until it reaches 10
x +=1
endwhile


Yes, the entire while loop runs inside the event block.
Code after the while loop doesn't execute until the loop is completed.
Even though the OnUpdate() event may have completed.

From my example, I use a quest stage to run different loops at different times on an update.
User avatar
Richard Dixon
 
Posts: 3461
Joined: Thu Jun 07, 2007 1:29 pm


Return to V - Skyrim