CopperBoltwire Posted October 21, 2019 Share Posted October 21, 2019 (edited) Okay so I got the following script to FINALLY work on my book: Scriptname GiveAPeak001CB745 extends Objectreference Perk Property BookLearnedPerk Auto Event OnRead() If !Game.GetPlayer().HasPerk(BookLearnedPerk) Game.GetPlayer().AddPerk(BookLearnedPerk) Endif EndEventWith some help googling and asking around and some trial and error it finally worked! At least the book ADDS the perk... However, I would love to go 2 steps further: * Removing the perk upon reading, IF the perk was already added. * Announcing that it added/removed the perk upon reading so the player using the book is actually informed. As is, no "feedback" weather the perk is added or not - would result in clear confusion. My scripting skills are practically non-existent. Anyone willing to jump in and be a hero? Edited October 21, 2019 by DonDidDon Link to comment Share on other sites More sharing options...
NexusComa Posted October 21, 2019 Share Posted October 21, 2019 (edited) I did this once ... give me a few to dig up the script. (lol, 10 year old script .. sorry took a bit to find)This was set up to give the player master glass blacksmith. Script is on the book set via the creation kit. Scriptname _RGD_MasterBlacksmithing extends ObjectReferenceActor Property PlayerRef AutoPerk Property _Perk Auto;Event OnInit() GoToState("Done")EndEvent;-----------------------Event OnActivate(ObjectReference akActionRef) If(akActionRef==(PlayerRef)) PlayerRef.AddPerk(_Perk) EndifEndEvent;State Done ;do nothingEndState;Guess I didn't read all that ... umm did you try RemovePerk()And for the feedback thing ... Debug.Notification("Wow you just lost that epic perk, tisk tisk ...") Edited October 21, 2019 by NexusComa Link to comment Share on other sites More sharing options...
CopperBoltwire Posted October 21, 2019 Author Share Posted October 21, 2019 I did this once ... give me a few to dig up the script. (lol, 10 year old script .. sorry took a bit to find) This was set up to give the player master glass blacksmith. Script is on the book set via the creation kit. Scriptname _RGD_MasterBlacksmithing extends ObjectReference Actor Property PlayerRef Auto Perk Property _Perk Auto ; Event OnInit() GoToState("Done") EndEvent ;----------------------- Event OnActivate(ObjectReference akActionRef) If(akActionRef==(PlayerRef)) PlayerRef.AddPerk(_Perk) Endif EndEvent ; State Done ;do nothing EndState ; Guess I didn't read all that ... umm did you try RemovePerk() And for the feedback thing ... Debug.Notification("Wow you just lost that epic perk, tisk tisk ...")As I said; I got it to work fine, once I close book and inventory, the perk is not just added but takes effect just fine. As for the Debug.Notification thing, I'll try it out and see how it goes... Would the following script work??? : Scriptname GiveAPeak001CB745 extends Objectreference Perk Property BookLearnedPerk Auto Event OnRead() If !Game.GetPlayer().HasPerk(BookLearnedPerk) Then Game.GetPlayer().AddPerk(BookLearnedPerk) Debug.Notification("Perk Added") Else Game.GetPlayer().RemovePerk(BookLearnedPerk) Debug.Notification("Perk Removed") End EndEventIf that works, then my script is done and ready for (ab)use :wink: Link to comment Share on other sites More sharing options...
CopperBoltwire Posted October 21, 2019 Author Share Posted October 21, 2019 I got the script working after some look-see in some other mods scripts: Scriptname GiveAPeak001CB745 extends ObjectreferencePerk Property BookLearnedPerk AutoEvent OnRead() If !Game.GetPlayer().HasPerk(BookLearnedPerk) Game.GetPlayer().AddPerk(BookLearnedPerk) Debug.Notification("Perk Added") Else Game.GetPlayer().RemovePerk(BookLearnedPerk) Debug.Notification("Perk Removed") EndifEndEvent It works almost exactly as planned.I mean, the perks takes effect only after you close your inventory, but that is a TINY price to pay...It could be pretty cool if i could display the notification like "Perk <PerkName> Added"But that just frosting on the cake if i could make it say that...The fact that it at least say "Perk Added" or "Perk Removed" is awesome!The fact it does NOT remove the book like how spell tomes work is a blessing!I got some Crafting perks i rather don't want active at all times... just like with my amulets... i like to keep my weapons do less then 800 points in damage, as it makes the game behave odd XDWith 5000% to Weapon blacksmithing, you can make some SERIOSLY OP weapons... 4k+... kind of gets boring fast. Thanks NexusComa!Your help was, is, are and will be greatly appreciated!Now i just need to convert my pesky necklaces into actual perks, link perks and books together and voilá!Monotenous work, but huge payof!No more a chance for an enemy to have/use my cheat items against myself!Freaking dynamic mods :P Link to comment Share on other sites More sharing options...
Ghaunadaur Posted October 21, 2019 Share Posted October 21, 2019 (edited) needs SKSEdebug.notification("Perk "+BookLearnedPerk.GetName()+" added") It would be better practice to use messages for this, but that's a bit more complicated... Edited October 21, 2019 by Ghaunadaur Link to comment Share on other sites More sharing options...
NexusComa Posted October 21, 2019 Share Posted October 21, 2019 Debug.Notification works great but you can't really say the same thing more than once in a row or it will skip it. Some don't like it as they feel it breaks the immersion.But I use it all the time. Especially when I'm testing code. Looks like you got it and you doing well coding. I can tell this isn't your 1st language ... the Then gave you away. :P Link to comment Share on other sites More sharing options...
CopperBoltwire Posted October 21, 2019 Author Share Posted October 21, 2019 Debug.Notification works great but you can't really say the same thing more than once in a row or it will skip it. Some don't like it as they feel it breaks the immersion.But I use it all the time. Especially when I'm testing code. Looks like you got it and you doing well coding. I can tell this isn't your 1st language ... the Then gave you away. :tongue:I have been messing with code for many years, don't know how to write it, i find it WAY to abstract, but from what i remember of all the code i have been working with, the classic "If, Then, Else" is often used, but for the most part, i got that from the blck building game called "Blockland" where you had the wrench where you could then "program" things into doing various things. I always found it ratehr limited, but was still fun mocking around in. But yeah, i got it from all the coding i have done in my day, i USED to know how to do Binary and Batch, but as DOS became less and less of a thing, i have forgotten most if not all of it...I still, from time to time mess with DOSBox and FreeDOS on my Raspberry Pi3... but it's more dabbling then anything... Link to comment Share on other sites More sharing options...
NexusComa Posted October 22, 2019 Share Posted October 22, 2019 "It could be pretty cool if i could display the notification like "Perk <PerkName> Added"". You do know the name of the perk ... just state it.If you look at my code you will see it is set up to be generic (as in any perk will work). This is the next step in coding for you. I always gofor a generic approach. Not that it's needed in this case but you will find that approach will serve you well when looking to expand the code. Knowing how to manipulate your code with if statements is 70% of the battle. Any success in any language is a win in any other language.If you understand how to code in one language it's just a matter of syntax after that. It's code logic that is the hard part to get down.Clearly you understand that so don't play yourself down. You know more than most right out the gun. You had a concept then made it happen.That is everything. You didn't approach it like can this be done. You knew you only needed to figure out the syntax. Wonderful!I've been programming all my life and know over 30 languages. At this point it's easy to absorb a language. That said ...Papyrus to me is one of the hardest to work with. Such a crazy language set up. If you can program in Papyrus you can program in any language ... lol ... 1/3 basic, 1/3 assembler, 1/3 crazy. The step from Papyrus to C++ is an easy one also.This is all fun and games in Skyrim with the Creation Kit and Papyrus. But in truth you couldn't buy better training for Unity. And with Unityyou can make anything happen. After messing around with the Creation Kit for a bit. You would be shocked how easy Unity is to pick up. Link to comment Share on other sites More sharing options...
Recommended Posts