Robbie922004 Posted June 13, 2015 Posted June 13, 2015 Currently fiddling with a perk overhaul for personal use. I want to make it compatible with some old characters, so I'm trying to bang out a respec script, but I'm having some trouble. Is it possible to add all the perks I want to remove to a Formlist rather than checking and removing them all in the script itself? My attempts are hilariously bad and not worth posting because I can't really find any example scripts to follow. The plan is to have the script remove all the vanilla perks from the player and then refund the perk points. The refunding is simple enough, but I'm really struggling with the actual removal of the perks. I really want to get this done with a Formlist somehow but I'm flying completely blind and would love some help if anybody is willing to offer it. Thanks!
GrimyBunyip Posted June 13, 2015 Posted June 13, 2015 removeperk works on actors. if you want to edit formlists, use addform, revert and removeaddedform: http://www.creationkit.com/FormList_Script
Robbie922004 Posted June 13, 2015 Author Posted June 13, 2015 (edited) removeperk works on actors. if you want to edit formlists, use addform, revert and removeaddedform: http://www.creationkit.com/FormList_ScriptI'm not trying to edit form lists. I'm trying to put all of the perks I need to be removed into a formlist, and then call that form list and remove all those perks from the player when the script fires. It would be easier than manually using RemovePerk for each perk I'm trying to remove because the plan is for it to be a full respec, which would require removing hundreds of perks. Edited June 13, 2015 by Robbie922004
GrimyBunyip Posted June 13, 2015 Posted June 13, 2015 Oh. Well you could run a loop through a formlist, but that would be extremely slow, so I can't advise that. Manually writing code to remove them one by one would in fact run faster. There is the issue of there being a cap on the number of properties a single script can hold, but I would circumvent this by breaking the perk removal process into multiple scripts. It would probably run faster broken into separate threads because of multithreading too.
Robbie922004 Posted June 13, 2015 Author Posted June 13, 2015 Oh. Well you could run a loop through a formlist, but that would be extremely slow, so I can't advise that. Manually writing code to remove them one by one would in fact run faster. There is the issue of there being a cap on the number of properties a single script can hold, but I would circumvent this by breaking the perk removal process into multiple scripts. It would probably run faster broken into separate threads because of multithreading too.Welp, looks like that's what I'm doing if it will be faster. Thanks for the help.
sLoPpYdOtBiGhOlE Posted June 13, 2015 Posted June 13, 2015 For speed array would be quicker then a formlist. But in all honesty if your just removing a short list of 20 ~ 30 perks at the click of a button or just on occasion, then the speed would be trivial in relation to any method.Myself I'd take compact code over the whole bloated If / ElseIf/ Else /Endif for 10 or more perk entries.Aother reason I prefer the loop against any array or formlist is it's easier to add or remove perks (or whatever) in future if needed without editing your script.Beats having to edit your script each time adding/removing If / ElseIf every time you want to edit a perk entry. Here's a couple of trivial functions one for a list, one for an array, not tested. Function PerksRemoveList(FormList ListOfPerksToRemove) Actor PR = Game.GetPlayer() Int i = ListOfPerksToRemove.GetSize() While i i -= 1 If (ListOfPerksToRemove.GetAt(i) As Perk) && PR.HasPerk(ListOfPerksToRemove.GetAt(i) As Perk) PR.RemovePerk(ListOfPerksToRemove.GetAt(i) As Perk) EndIf EndWhile EndFunction Function PerksRemoveArray(Perk[] ArrayOfPerksToRemove) Actor PR = Game.GetPlayer() Int i = ArrayOfPerksToRemove.Length While i i -= 1 If ArrayOfPerksToRemove[i] && PR.HasPerk(ArrayOfPerksToRemove[i]) PR.RemovePerk(ArrayOfPerksToRemove[i]) EndIf EndWhile EndFunction
Recommended Posts