TheRecusantX Posted January 6, 2020 Share Posted January 6, 2020 Hey guys, so I made a custom Perk and now I am trying to add it to my character ingame with a book. To do that I attached a script to the book. Example: ScriptName AddPerkBookScript Extends ObjectReference Perk Property Custommod AutoActor Property PlayerRef Auto Event OnRead() PlayerRef.AddPerk(Custommod)EndEvent Using this script the game does not apply the Perk to my character when reading the book. I know the Perk is not the problem because it works when I add it through the console. But what is the problem here??? Why wont my script add the Perk??? Link to comment Share on other sites More sharing options...
maxarturo Posted January 6, 2020 Share Posted January 6, 2020 If you haven't forgotten to add the "Player" in the script's property, then. Some faction will not execute when the game is in "Pause Mode" > "Book's UI", a quick workaround is to add a "Wait()" before the "AddPerk()", while the "Wait()" dose not execute also, it does however fires the instant you leave the "Pause Mode" > "Book's UI", so anything after that will also execute. I hope it helps.... Link to comment Share on other sites More sharing options...
TheRecusantX Posted January 6, 2020 Author Share Posted January 6, 2020 Thx for your reply but I found out what the problem was. I was trying to put the perkscript on a spelltome. Turns out spelltomes are not actually treated like books scriptingwise^^. I tried pretty much every script i could think of to make the spelltome work but ultimately I gave up and put the perkscript on a regular book. It works fine now. Link to comment Share on other sites More sharing options...
maxarturo Posted January 6, 2020 Share Posted January 6, 2020 (edited) With spelltomes you can use: Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) Example: ScriptName AddPerkBookScript Extends ObjectReference Perk Property Custommod Auto Actor Property PlayerRef Auto Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) if akNewContainer == PlayerRef PlayerRef.AddPerk(Custommod) EndIf EndEvent Edited January 6, 2020 by maxarturo Link to comment Share on other sites More sharing options...
TheRecusantX Posted January 6, 2020 Author Share Posted January 6, 2020 Wow! Thx I will try this when I get back home !! :D What do I insert instead of the objectreference? Link to comment Share on other sites More sharing options...
maxarturo Posted January 7, 2020 Share Posted January 7, 2020 Wow! Thx I will try this when I get back home !! :D What do I insert instead of the objectreference? I don't really understand what you mean by that....But, "OnContainerChanged()" is in the family group of "Objectreference" events.It should work just fine as it is. Link to comment Share on other sites More sharing options...
TheRecusantX Posted January 7, 2020 Author Share Posted January 7, 2020 alright, tried your script and it works perfectly ! thx so much :) Link to comment Share on other sites More sharing options...
maxarturo Posted January 8, 2020 Share Posted January 8, 2020 The only issue with this approach, if you haven't find out already, is that the "Custom Perk" will always get applied no matter if the player reads the Spelltome or not, there is also the issue that he can remove the spelltome from his inventory and then pick it up again, so everytime that the Player pick up the spelltome the "Perk" will be apply. According to what the "Custom Perk" does, it might not cause any issues but in the other hand it can, can even cause CTD. To prevent this, use the following script that ensures that the perk gets applied only once. ScriptName AddPerkBookScript Extends ObjectReference Perk Property Custommod Auto Actor Property PlayerRef Auto Auto State WaitingPickUp Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) if akNewContainer == PlayerRef PlayerRef.AddPerk(Custommod) GoToState("Taken") EndIf EndEvent EndState State Taken Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) ; EndEvent EndState Link to comment Share on other sites More sharing options...
TheRecusantX Posted January 8, 2020 Author Share Posted January 8, 2020 The custom perk basically increases summon limit for a specific custom summoning spell I made similar to the ritual stone. Do you think this kind of Perk could eff up the game if reapplied on accident ? Link to comment Share on other sites More sharing options...
maxarturo Posted January 8, 2020 Share Posted January 8, 2020 (edited) I can't be sure since i don't know what exactly you have done with your mod, and i haven't tested this. Nevertheless, the second script is the script that it should be from the beginning and ensures that no issue can be caused by double applying the perk since it will get apply ONLY ONCE no matter how many times the player drops and picks up the Spelltome, after the first pick up and first perk apply the script will go to a STATE that does nothing. I just didn't wrote it like this because it was made on the go (the first script), after revisiting your post today i had the time to rectify it. Have a happy modding. Edited January 8, 2020 by maxarturo Link to comment Share on other sites More sharing options...
Recommended Posts