AzureRye Posted February 7 Share Posted February 7 (edited) I want to create a mod and in that mod, there's a script I wanna try to implement but I don't understand how to do it as I'm still a newbie when it comes to scripting. I tried to find it online but with no help or maybe a clear understanding of it. Any help would be great as I'm okay with making houses in the CK, but scripting is not my specialty. What I want to try and make is: The player finds an item and when they interact with the item in their inventory, that item will disappear from their inventory and it can increase their attributes to a couple of values. I.E. There is a soul gem asset in the inventory, when the player clicks on it, it disappears and it will permanently increase their health by a value of 10, or maybe increase their carry weight by about 15. If that makes any sense. I don't know if this would be possible on Skyrim's original scripts or if I would need one of those fancy papyrus scripts to download on the Nexus. Thanks. Edited February 7 by AzureRye Link to comment Share on other sites More sharing options...
xkkmEl Posted February 7 Share Posted February 7 It is doable, though you may get a pesky "This item cannot be equipped" message in the upper left corner of the screen. The key is to put a ReferenceAlias script on the player to catch the OnObjectEquipped event. It will fire when the player clicks on it in inventory even if the object is not equippable, and your script can take it from there. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 7 Share Posted February 7 (edited) Alternatively, if the object is a custom one, you can put a script directly on the base object that uses the OnEquipped event. A basic example that could be modified for your needs: Spoiler ScriptName myMod_myObjectScript Extends ObjectReference String Property AVtoAdjust = "Health" Auto {Actor value to be adjusted by this script - script default: Health} Float Property AdjustAmmount = 10.0 Auto {Amount to change the actor value by - positives increase, negatives decrease - script default: 10.0 } Event OnEquipped(Actor akActor) If akActor == Game.GetPlayer() ; only proceed if the player equipped akActor.ModActorValue(AVtoAdjust,AdjustAmmount) ; adjust the designated AV by the designated amount akActor.RemoveItem(Self) ; remove from the player inventory without a destination container EndIf EndEvent This has not been tested for compilation or proper function. Adjustments may be needed for your specific purposes. This will prompt the "This item cannot be equipped" message should the item not be a piece of armor or a weapon. However, the script will still process anything in the OnEquipped event. Edited February 7 by IsharaMeradin Link to comment Share on other sites More sharing options...
scorrp10 Posted February 7 Share Posted February 7 You can implement your item as a potion. Just attach a script to imparted effect. Link to comment Share on other sites More sharing options...
AzureRye Posted February 7 Author Share Posted February 7 25 minutes ago, IsharaMeradin said: Alternatively, if the object is a custom one, you can put a script directly on the base object that uses the OnEquipped event. A basic example that could be modified for your needs: Hide contents ScriptName myMod_myObjectScript Extends ObjectReference String Property AVtoAdjust = "Health" Auto {Actor value to be adjusted by this script - script default: Health} Float Property AdjustAmmount = 10.0 Auto {Amount to change the actor value by - positives increase, negatives decrease - script default: 10.0 } Event OnEquipped(Actor akActor) If akActor == Game.GetPlayer() ; only proceed if the player equipped akActor.ModActorValue("AVtoAdjust",AdjustAmmount) ; adjust the designated AV by the designated amount akActor.RemoveItem(Self) ; remove from the player inventory without a destination container EndIf EndEvent This has not been tested for compilation or proper function. Adjustments may be needed for your specific purposes. This will prompt the "This item cannot be equipped" message should the item not be a piece of armor or a weapon. However, the script will still process anything in the OnEquipped event. Wow. Okay, I'll test this out later and see if it works. Scripting does look complex but I'll see what happens lol. I was thinking of something other than a soul gem like say a container asset, i.e a satchel, would I need to do anything different to the script you listed or it's just the same? Thanks. Link to comment Share on other sites More sharing options...
AzureRye Posted February 7 Author Share Posted February 7 2 minutes ago, scorrp10 said: You can implement your item as a potion. Just attach a script to imparted effect. I see, well this is something I'll also look into along with IsharaMeradin's idea lol. Thanks. Link to comment Share on other sites More sharing options...
AzureRye Posted February 7 Author Share Posted February 7 1 hour ago, scorrp10 said: You can implement your item as a potion. Just attach a script to imparted effect. I'm curious about how to achieve this and how to put a script on a potion. Again, scripting is something I never tackle often in The CK. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 7 Share Posted February 7 (edited) For a consumable it would be a magic effect applied to the potion, poison, food, drink, or ingredient. The magic effect would have a script attached which would be very similar to the one I already posted. Spoiler ScriptName myMod_myMagicEffectScript Extends ActiveMagicEffect String Property AVtoAdjust = "Health" Auto {Actor value to be adjusted by this script - script default: Health} Float Property AdjustAmmount = 10.0 Auto {Amount to change the actor value by - positives increase, negatives decrease - script default: 10.0 } Event OnEffectStart(Actor akTarget, Actor akCaster) If akTarget == Game.GetPlayer() ; only proceed if the player consumed the item akTarget.ModActorValue(AVtoAdjust,AdjustAmmount) ; adjust the designated AV by the designated amount ;nature of a consumable means that the item automatically disapears without having to do anything else. EndIf EndEvent To answer your other question, you can attach my previous example to any object that the player can pick up. And any such object can utilize whatever mesh you wish to use. In a couple of my mods, I have used the alchemy satchel mesh and one mod I used a satchel mesh that was cut from an existing set of stock armor. You would create a new misc object and assign the NIF file that you want to use. You may need to duplicate the NIF file and make adjustments to it so that the player could drop it and not have the item bounce all over the place or remain stuck in mid-air. Edited February 7 by IsharaMeradin Link to comment Share on other sites More sharing options...
AzureRye Posted February 7 Author Share Posted February 7 2 hours ago, IsharaMeradin said: For a consumable it would be a magic effect applied to the potion, poison, food, drink, or ingredient. The magic effect would have a script attached which would be very similar to the one I already posted. Reveal hidden contents ScriptName myMod_myMagicEffectScript Extends ActiveMagicEffect String Property AVtoAdjust = "Health" Auto {Actor value to be adjusted by this script - script default: Health} Float Property AdjustAmmount = 10.0 Auto {Amount to change the actor value by - positives increase, negatives decrease - script default: 10.0 } Event OnEffectStart(Actor akTarget, Actor akCaster) If akTarget == Game.GetPlayer() ; only proceed if the player consumed the item akTarget.ModActorValue("AVtoAdjust",AdjustAmmount) ; adjust the designated AV by the designated amount ;nature of a consumable means that the item automatically disapears without having to do anything else. EndIf EndEvent To answer your other question, you can attach my previous example to any object that the player can pick up. And any such object can utilize whatever mesh you wish to use. In a couple of my mods, I have used the alchemy satchel mesh and one mod I used a satchel mesh that was cut from an existing set of stock armor. You would create a new misc object and assign the NIF file that you want to use. You may need to duplicate the NIF file and make adjustments to it so that the player could drop it and not have the item bounce all over the place or remain stuck in mid-air. I followed the script you gave me seems to work fine as I got no errors, but I can't seem to get it working. I use the item and it does disappear, but my carrying weight is still at 300 and doesn't increase. I don't know if it's related to the script or maybe some other properties. I have an image of everything from the magic effect, the potion, and even the script below. https://i.imgur.com/fF1jmEI.jpeg Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 7 Share Posted February 7 You used the variation of the script with the OnEquipped event. That will not work with consumables. You will need to use the variation I posted with the OnEffectStart event. Link to comment Share on other sites More sharing options...
Recommended Posts