GSGlobe Posted September 25, 2017 Share Posted September 25, 2017 Hi there! I have a question. Is it possible to have a spell as this;EVENT OnEffectStart(Actor akTarget, Actor akCaster)GotoState("Spell")EndEvent State SpellEVENT OnSpellCast(Form akSpell) spToCast = akSpell As Spell ;;;;<- store spell in variableEndEventEndstate Store the casted spell in a variable and then call this variable in another scripted spell? On another scripted spell effect script;If playerref.getactorvalue(Health) <= 50%;;Use spToCast Variable to cast? Is something like this possible? I would greatly apperciate any help regarding this.Thanks alot! Link to comment Share on other sites More sharing options...
foamyesque Posted September 25, 2017 Share Posted September 25, 2017 (edited) It'd be possible, but I'm not sure of the point of the OnSpellCast catch. As you have it structured an effect will go on the actor that listens for them casting a spell, and if they do stores it, and then if their health drops below 50% (you can't use % signs, though; Papyrus will interpret that as a modulo division with no divisor and complain at you) casts it. But that spell could be anything, including nothing; I don't think that'd be what you're going for? The OnSpellCast event will not catch whatever spell started the effect, so you are aware. It can only fire, in your structure, after the effect has started, which is necessarily after the casting event has already occurred. If there's some specific spell you want to cast when the player's health drops below some percentage, you'd be better off feeding it into the script as a property. Edited September 25, 2017 by foamyesque Link to comment Share on other sites More sharing options...
GSGlobe Posted September 26, 2017 Author Share Posted September 26, 2017 Hi there, thank you for your comment!The reason why I want to store a spell (Event OnSpellCast) is that I may want to change the spell later on. My idea is simple really.First Spell:Store a spell using OnSpellCast eventSecond Spell: With different conditions, using the stored spell. If cast stored spellElseIfcast stored spellElseIfcast stored spellElseDo something else. I tried this:Store Spell ME script"myQuestScript property myScript auto" Event OnSpellCast(Form akSpell)myScript.StoreMySpell(akSpell)EndEvent This is what myQuestScript would have to store spells to a variable and return the spell for later on: myQuestScript extends quest Spell myStoredSpell Function StoreMySpell(Spell akSpell)akSpell = myStoredSpellendfunction Spell Function GetMySpell()return myStoredSpellendfunction Release Spell ME Script: If PlayerRef.getavpercentage(Health) <= 0.5Spell mySpell = myScript.GetmySpell()If mySpell ;because don't cast it if it's 'None'PlayerRef.Cast(mySpell)endifendif But I'm getting a error here: myScript.StoreMySpell(akSpell) D:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source\temp\teststore_script.psc(6,9): type mismatch on parameter 1 (did you forget a cast?) And Here: PlayerRef.Cast(Myspell) ;; cast is not a function or does not exist or something similar on my release script Any ideas? Thanks for the help so far and I truely appreciate any help given! Link to comment Share on other sites More sharing options...
foamyesque Posted September 26, 2017 Share Posted September 26, 2017 You need to explicitly cast the akSpell from a Form type to a Spell type in order to clear the first compilation error: "myScript.StoreMySpell(akSpell as Spell)" should work.Cast() is not a function of an ObjectReference (or Actor), but of a Spell, which is what's causing the second error. You want "mySpell.Cast(PlayerRef)" instead. Link to comment Share on other sites More sharing options...
GSGlobe Posted September 27, 2017 Author Share Posted September 27, 2017 Thank you very much for this information, couldn't find anything related to it or didn't understand how to use it properly, I'm a novice!Would you know what the difference here is?----------------------------Spell Spell1OnSpellCast Spell1 = akSpell as Spell <- Here is without () ----------------------------------------- OnSpellCastmyScript.StoreMySpell(akSpell as Spell) <- Here akSpell as Spell is inside ()-------------------------If I wanted to use myScript.StoreMySpell(akSpell as Spell) variable in the same script aswell, would I have to use Spell myScript.StoremySpell above the event and then call that like this;--- script magic ---- actorbase blabla = noneSpell myScript.StoremySpell Event OnSpellCast (Form akSpell)myScript.StoreMySpell(akSpell as Spell)blabla = (Quest Property).Function(None, myScript.StoremySpell) if this makes any sense to you? Thanks for taking your time! Link to comment Share on other sites More sharing options...
GSGlobe Posted September 27, 2017 Author Share Posted September 27, 2017 (edited) Store Spell Script & Release Spell Script & Quest Script Scriptname teststore_script extends activemagiceffectÃÂ ÃÂ ÃÂ auto_globalvar_script property myScript autoÃÂ Event OnSpellCast(Form akSpell)ÃÂ debug.notification("stored your spell")myscript.StoreMySpell(akSpell as Spell)ÃÂ EndEvent----------------------------------------------------------------------------Release Spell Magic Effect Script----------------------------------------------------------------------------Scriptname testrelease_script extends activemagiceffectÃÂ Actor Property PlayerRef AutoAuto_GlobalVar_Script Property myScript AutoÃÂ ÃÂ EVENT OnEffectStart(Actor akTarget, Actor akCaster)ÃÂ ÃÂ Spell mySpell = myScript.GetmySpell()myspell.cast(playerref)Debug.Notification("Spell mySpell cast")ÃÂ ÃÂ EndEvent-------------------------------------------------------------------------------------Quest Script-------------------------------------------------------------------------------------Scriptname Auto_GlobalVar_Script extends QuestÃÂ ÃÂ ÃÂ spell property test_release_spell autospell property test_store_spell autoSpell myStoredSpellÃÂ ; ------------------------------------- Function to Store and Retrieve Spell ---------------------------------------ÃÂ Function StoreMySpell(Spell akSpell)akSpell = myStoredSpellendfunctionÃÂ Spell Function GetMySpell()return myStoredSpellendfunction ÃÂ The above doesn't work, any ideas? It compiles but When I try IT ingame, storing a spell. The release spell doesnt cast the stored spell, nothing happens. Theyre both set to fire and forget script & selfÃÂ Edited September 27, 2017 by GSGlobe Link to comment Share on other sites More sharing options...
GSGlobe Posted September 28, 2017 Author Share Posted September 28, 2017 (edited) Upon further testing and checking all scripts, no propeties were unset and the spell return as none so it doesnt store. Edit: im out of ideas, anyone know what steps I can take or can see where the fault is or general improvements? Edited September 28, 2017 by GSGlobe Link to comment Share on other sites More sharing options...
JonathanOstrus Posted September 29, 2017 Share Posted September 29, 2017 (edited) Upon further testing and checking all scripts, no propeties were unset and the spell return as none so it doesnt store. Edit: im out of ideas, anyone know what steps I can take or can see where the fault is or general improvements? You have a problem with your store function. Your code Spell myStoredSpell Function StoreMySpell(Spell akSpell) akSpell = myStoredSpell endfunction It doesn't store the spell into your local variable. It's trying to put your local variable into the passed spell variable. So try this Spell myStoredSpell Function StoreMySpell(Spell akSpell) myStoredSpell = akSpell ; the variables have swapped place endfunctionSince you never properly set the local spell variable, when you retrieve it you in fact get a valid response of "None" since it was never set. Edited September 29, 2017 by BigAndFlabby Link to comment Share on other sites More sharing options...
GSGlobe Posted September 30, 2017 Author Share Posted September 30, 2017 Thanks alot, that did wonders :) Its working great now! Now for a last question: Is IT possible to also use the stored spell locally from the store spell script? Event OnSpellCast(form akSpell) Myscript.mystoredspell(akSpell as Spell) ;something like Actor = questproperty.questfunction(none,mystoredspell) ? Do I have to store a New variable? Spell mySpell ? Link to comment Share on other sites More sharing options...
JonathanOstrus Posted September 30, 2017 Share Posted September 30, 2017 It would be so much easier to answer that if you posted actual code usage. But I think what you're asking the answer is yes. You can use the local script variable like this: Spell mySavedSpell SomeSampleQuestScript Property SomeQuest Auto Function StoreTheSpell(Spell akSpell) mySavedSpell = akSpell EndFunction Spell Function GetStoredSpell() return mySavedSpell EndFunction Function DoSomethingWithSpell() SomeQuest.SomeQuestFunction(mySavedSpell) EndFunction If you're trying to do something from inside the OnSpellCast event you could just use akSpell as Spell. Otherwise you would need to call asking for the stored spell and need an appropriate function on the script that stores it like the GetStoredSpell() above. Then you would do it something like this ; not a valid code snippet. it would need to be run inside a function SomeQuest.SomeQuestFunction(SomeValue, SpellScript.GetStoredSpell()) Link to comment Share on other sites More sharing options...
Recommended Posts