Danikov Posted December 31, 2017 Share Posted December 31, 2017 Hello. I would like to create a single script that will be used by several items in the form of 'Magic Effect' but I don't much experience scripting in Lua/Papyrus and also there aren't many examples out there similar to what I am trying to do, so am having quite some trouble getting anywhere. What I am trying to do is to get and store the ID value of the object into a variable( I am also not quite sure of how variables are defined here) that has just been consumed, and run a series of checks( using if and else ) that compare the ID value of the consumed object with the ID values that are defined in this series of checks, and if the ID value matches, the player receives different items that also will be defined. What I am asking for is if anyone can write down things like what functions do I need achieve that? How do I store the ID value into a variable(and again, what kind of variable)? Do I need to load the items before requesting them to be added, if so, how? Thank you very much. Link to comment Share on other sites More sharing options...
JonathanOstrus Posted December 31, 2017 Share Posted December 31, 2017 (edited) I think you might be going about this the wrong way. There's no (simple at least) way to detect what is giving a magic effect to something. Many things can trigger a magic effect, eating a food, a drink, equipping an armor or weapon, etc. All of them can start an effect and there's no way to detect within the effect how it came to be. If you just want to give a specific item whenever this specific magic effect is started that's simple enough. You make a script with properties for the item to give (and optionally how many). Then just make different effects for different items. Then assign the effect to whatever base trigger chem/food/etc you want. One such script would be something like this Scriptname SimpleAddItemOnEffectStart extends ActiveMagicEffect Form Property ItemToAdd Auto {What item to give the effect target} int Property iCount = 1 Auto {How many of the item to give target} bool Property SilentAdd = false Auto {Give silently or show the message that x items were added (if player)} Event OnEffectStart(Actor akTarget, Actor akCaster) akTarget.AddItem(ItemToAdd, iCount, SilentAdd) EndEvent Doing it this way you don't need to know how the effect was triggered to do what could be a messy if tree check, and it will give the effect target whatever item the script is set for. Edited December 31, 2017 by BigAndFlabby Link to comment Share on other sites More sharing options...
Danikov Posted December 31, 2017 Author Share Posted December 31, 2017 Thank you very much for this input, I have been searching for a few couple of good hours through the Nexus forums and also TESA forums to no avail.I have stumbled upon this template already but I had a different approach in mind, again to no good, oh well. Really, thank you for dedicating a few moments read and give an answer to this, I could have kept searching how it could be done for another good while. Link to comment Share on other sites More sharing options...
Recommended Posts