JadeMoontail Posted June 3 Share Posted June 3 I have this plan for an item you can equip and its supposed to give the player a sample of pink paste once every five hours but I cant for the life of me figure out how to get the script to work and add to the item, I want to use this type of script for a few other items, some lore friendly some just funny. So if anyone wants to help out jot down an easily adaptable script and how to install it correctly and I am golden Link to comment Share on other sites More sharing options...
worm82075 Posted June 3 Share Posted June 3 Most everything in the game that is added to the player is done by a script attached to a quest rather than an object. Have you tried to find something in the vanilla game that functions similarly to adapt to your purpose? If not, that is where i would start and at least you will have something to do while you wait a little longer for an actual scripter to reply. Link to comment Share on other sites More sharing options...
LarannKiar Posted June 3 Share Posted June 3 Here's a quick script you can try. There are other ways to do it but this is probably the simplest. Create a Quest and add a Quest Alias (Reference Alias) to it. Quest Alias data ( alias name: Player ; Fill Type: Unique Actor which should point to the Player ; check the Optional flag ). Click OK, save the plugin. Reopen the Quest and the Quest Alias then add a new script to it. Scriptname TestScript extends ReferenceAlias ; --------------------------------------------- Script Properties --------------------------------------------- Formlist Property Items Auto Const ; add the items you want the script to add FoodPaste to the Player on equipping to this FormList; don't forget the fill out the script properties in the Creation Kit Form Property FoodPaste Auto Const ; FoodPaste that'll be added to the Player's inventory (recommended to be a Potion) ; --------------------------------------------- Script Variables --------------------------------------------- Float CoolingOffTime = 5.0 Bool IsCoolingOff = False ; --------------------------------------------- Events --------------------------------------------- Event OnAliasInit() ; alias initialized, should be ready to call script functions on it Utility.Wait(0.2) ; wait for 0.2 real-time seconds; does not count while a game pausing menu is open Actor PlayerRef = Game.GetPlayer() ; if the reference filled into the Quest Alias (ReferenceAlias) this script is attached to is not the Player If GetReference() != PlayerRef ; then fill the Player into the alias (just as a failsafe) ForceRefTo(PlayerRef) EndIf EndEvent Event OnItemEquipped(Form akBaseObject, ObjectReference akReference) ; event sent when the reference filled into this ReferenceAlias equips something If akBaseObject && Items.Find(akBaseObject) >= 0 ; the item that was equipped (akBaseObject) can be found in the Items FormList ( >= 0 because the first element is at 0; if not found, Find() would return -1 ) If IsCoolingOff == False ; prevent FoodPaste from getting added to the Player if they equip an item from the list Items within 5 game hours again IsCoolingOff = True Game.GetPlayer().AddItem(FoodPaste) StartTimerGameTime(CoolingOffTime, 555) ; start a timer that's measured in game time; timer time will be CoolingOffTime which is 5.0; 555 is an arbitrary number for the TimerID EndIf EndIf EndEvent Event OnTimerGameTime(int aiTimerID) ; event sent when a game time timer expires If aiTimerID == 555 ; event sent by the timer whose TimerID is 555 IsCoolingOff = False ; reset the cooling off variable so that the Player can get FoodPaste again EndIf EndEvent 1 Link to comment Share on other sites More sharing options...
JadeMoontail Posted June 6 Author Share Posted June 6 Should this work if I change the items it adds for different upgrades in a work bench? Link to comment Share on other sites More sharing options...
JadeMoontail Posted June 6 Author Share Posted June 6 On 6/3/2024 at 10:42 AM, LarannKiar said: Here's a quick script you can try. There are other ways to do it but this is probably the simplest. Create a Quest and add a Quest Alias (Reference Alias) to it. Quest Alias data ( alias name: Player ; Fill Type: Unique Actor which should point to the Player ; check the Optional flag ). Click OK, save the plugin. Reopen the Quest and the Quest Alias then add a new script to it. Reveal hidden contents Scriptname TestScript extends ReferenceAlias ; --------------------------------------------- Script Properties --------------------------------------------- Formlist Property Items Auto Const ; add the items you want the script to add FoodPaste to the Player on equipping to this FormList; don't forget the fill out the script properties in the Creation Kit Form Property FoodPaste Auto Const ; FoodPaste that'll be added to the Player's inventory (recommended to be a Potion) ; --------------------------------------------- Script Variables --------------------------------------------- Float CoolingOffTime = 5.0 Bool IsCoolingOff = False ; --------------------------------------------- Events --------------------------------------------- Event OnAliasInit() ; alias initialized, should be ready to call script functions on it Utility.Wait(0.2) ; wait for 0.2 real-time seconds; does not count while a game pausing menu is open Actor PlayerRef = Game.GetPlayer() ; if the reference filled into the Quest Alias (ReferenceAlias) this script is attached to is not the Player If GetReference() != PlayerRef ; then fill the Player into the alias (just as a failsafe) ForceRefTo(PlayerRef) EndIf EndEvent Event OnItemEquipped(Form akBaseObject, ObjectReference akReference) ; event sent when the reference filled into this ReferenceAlias equips something If akBaseObject && Items.Find(akBaseObject) >= 0 ; the item that was equipped (akBaseObject) can be found in the Items FormList ( >= 0 because the first element is at 0; if not found, Find() would return -1 ) If IsCoolingOff == False ; prevent FoodPaste from getting added to the Player if they equip an item from the list Items within 5 game hours again IsCoolingOff = True Game.GetPlayer().AddItem(FoodPaste) StartTimerGameTime(CoolingOffTime, 555) ; start a timer that's measured in game time; timer time will be CoolingOffTime which is 5.0; 555 is an arbitrary number for the TimerID EndIf EndIf EndEvent Event OnTimerGameTime(int aiTimerID) ; event sent when a game time timer expires If aiTimerID == 555 ; event sent by the timer whose TimerID is 555 IsCoolingOff = False ; reset the cooling off variable so that the Player can get FoodPaste again EndIf EndEvent How do I add this to an item the player wears? I cant seem to figure that out, I want to start off as a ring before I make the actual item as a test Link to comment Share on other sites More sharing options...
LarannKiar Posted June 6 Share Posted June 6 3 hours ago, JadeMoontail said: How do I add this to an item the player wears? I cant seem to figure that out, I want to start off as a ring before I make the actual item as a test This script can't be attached to item base forms like Armors or Weapons. It's a ReferenceAlias script so it works on any actor held in the RefAlias and any item the FormList "Items" contains. Make sure the Player is filled into the Quest Alias and fill out the script properties in the editor. Drag and drop the item base forms to the FormList. If you'd like to have a script attached to the items themselves, you'll need to make a script that extends ObjectReference instead. 8 hours ago, JadeMoontail said: Should this work if I change the items it adds for different upgrades in a work bench? Yes. The FormList "Items" contains the items' base forms and not the item instances themselves. Modifying them doesn't affect the script. Link to comment Share on other sites More sharing options...
JadeMoontail Posted June 9 Author Share Posted June 9 On 6/6/2024 at 2:21 AM, LarannKiar said: This script can't be attached to item base forms like Armors or Weapons. It's a ReferenceAlias script so it works on any actor held in the RefAlias and any item the FormList "Items" contains. Make sure the Player is filled into the Quest Alias and fill out the script properties in the editor. Drag and drop the item base forms to the FormList. If you'd like to have a script attached to the items themselves, you'll need to make a script that extends ObjectReference instead. Yes. The FormList "Items" contains the items' base forms and not the item instances themselves. Modifying them doesn't affect the script. So I replace akBaseObject with the item I want it to use? Link to comment Share on other sites More sharing options...
JadeMoontail Posted June 22 Author Share Posted June 22 On 6/3/2024 at 10:42 AM, LarannKiar said: Here's a quick script you can try. There are other ways to do it but this is probably the simplest. Create a Quest and add a Quest Alias (Reference Alias) to it. Quest Alias data ( alias name: Player ; Fill Type: Unique Actor which should point to the Player ; check the Optional flag ). Click OK, save the plugin. Reopen the Quest and the Quest Alias then add a new script to it. Reveal hidden contents Scriptname TestScript extends ReferenceAlias ; --------------------------------------------- Script Properties --------------------------------------------- Formlist Property Items Auto Const ; add the items you want the script to add FoodPaste to the Player on equipping to this FormList; don't forget the fill out the script properties in the Creation Kit Form Property FoodPaste Auto Const ; FoodPaste that'll be added to the Player's inventory (recommended to be a Potion) ; --------------------------------------------- Script Variables --------------------------------------------- Float CoolingOffTime = 5.0 Bool IsCoolingOff = False ; --------------------------------------------- Events --------------------------------------------- Event OnAliasInit() ; alias initialized, should be ready to call script functions on it Utility.Wait(0.2) ; wait for 0.2 real-time seconds; does not count while a game pausing menu is open Actor PlayerRef = Game.GetPlayer() ; if the reference filled into the Quest Alias (ReferenceAlias) this script is attached to is not the Player If GetReference() != PlayerRef ; then fill the Player into the alias (just as a failsafe) ForceRefTo(PlayerRef) EndIf EndEvent Event OnItemEquipped(Form akBaseObject, ObjectReference akReference) ; event sent when the reference filled into this ReferenceAlias equips something If akBaseObject && Items.Find(akBaseObject) >= 0 ; the item that was equipped (akBaseObject) can be found in the Items FormList ( >= 0 because the first element is at 0; if not found, Find() would return -1 ) If IsCoolingOff == False ; prevent FoodPaste from getting added to the Player if they equip an item from the list Items within 5 game hours again IsCoolingOff = True Game.GetPlayer().AddItem(FoodPaste) StartTimerGameTime(CoolingOffTime, 555) ; start a timer that's measured in game time; timer time will be CoolingOffTime which is 5.0; 555 is an arbitrary number for the TimerID EndIf EndIf EndEvent Event OnTimerGameTime(int aiTimerID) ; event sent when a game time timer expires If aiTimerID == 555 ; event sent by the timer whose TimerID is 555 IsCoolingOff = False ; reset the cooling off variable so that the Player can get FoodPaste again EndIf EndEvent How could this be altered to make it work for any NPC? Would like to make like a "Scavver Ring" that they pic up random scrap material over time Link to comment Share on other sites More sharing options...
LarannKiar Posted June 22 Share Posted June 22 10 hours ago, JadeMoontail said: How could this be altered to make it work for any NPC? Would like to make like a "Scavver Ring" that they pic up random scrap material over time You'll need another script to dynamically change the Actor Reference the ReferenceAlias holds ( with ForceRefTo() ) or alternatively alter the script I wrote for ReferenceCollectionAliases. Link to comment Share on other sites More sharing options...
JadeMoontail Posted June 23 Author Share Posted June 23 (edited) 11 hours ago, LarannKiar said: You'll need another script to dynamically change the Actor Reference the ReferenceAlias holds ( with ForceRefTo() ) or alternatively alter the script I wrote for ReferenceCollectionAliases. Having trouble getting scripts to compile at all. mind if I shared the work in progress mod files so you can check what I am doing and help me get it working and explain what I am doing wrong. Will list your username in the description when I upload the mod for your help Edited June 23 by JadeMoontail Link to comment Share on other sites More sharing options...
Recommended Posts