GSGlobe Posted September 30, 2017 Author Share Posted September 30, 2017 (edited) Something like below, I'm having a small issue understanding it. Thanks for all the help so far, its very kind of you! Scriptname auto_store1_script extends activemagiceffect Auto_GlobalVar_Script Property GlobalVars Auto ; Reference the Quest script with global variables.Auto_GlobalVar_Script Property myScript Auto ; Reference the Quest Script Property for Store Spell Bool X = False EVENT OnSpellCast(Form akSpell) ; This can include spells, ingrediant eaten, potions or scrolls. myScript.StoreMySpell(akSpell as Spell) ; Reference my Store Spell Function X = GlobalVars.FunctionNotAllowed(myScript.GetmySpell(), FALSE) ;;-----------------------------------------------------------------------;; Would the above work or do I have to do like this;;----------------------------------------------------------------------- myScript.StoreMySpell(akSpell as Spell) ; Reference my Store Spell Function Spell mySpell = myScript.GetmySpell() ; <- Do I have to use it like this? X = GlobalVars.FunctionNotAllowed(mySpell, FALSE) Edited September 30, 2017 by GSGlobe Link to comment Share on other sites More sharing options...
JonathanOstrus Posted September 30, 2017 Share Posted September 30, 2017 You could use the syntax of X = GlobalVars.FunctionNotAllowed(myScript.GetmySpell(), FALSE) Link to comment Share on other sites More sharing options...
GSGlobe Posted September 30, 2017 Author Share Posted September 30, 2017 Yay! That worked aswell, thanks alot! I didn't know you could do that, where else than here or Wiki is a good place to read up on scripting with papyrus?I feel like I'm not taking in so much as I would like, most have come from looking at vanilla scripts and by trial and errors but this had me completely lost. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted September 30, 2017 Share Posted September 30, 2017 (edited) I am not really understand what do you want to get as result with your scripts. Imho you are on the wrong way.Have a look into the next scripts! Maybe it is useful. GSG_QuestScript Scriptname GSG_QuestScript extends Quest {sample 2017} ; former scriptname was Auto_GlobalVar_Script ; https://forums.nexusmods.com/index.php?/topic/6018743-onspellcast-event-question/ ; GSGlobe has written Spell myStoredSpell ; this is a script variable Spell PROPERTY myStoredSP auto Hidden ; this is a script property ; -- FUNCTIONs -- 2 ;-------------------------------- FUNCTION myF_Store(Spell akSpell) ;-------------------------------- myStoredSpell = akSpell ENDFUNCTION ;---------------------------- Spell FUNCTION myF_GetSpell() ;---------------------------- RETURN myStoredSpell ENDFUNCTION GSG_AliasScript Scriptname GSG_AliasScript extends ReferenceAlias {sample 2017} ; former scriptname was teststore_script ; -- EVENTs -- EVENT OnPlayerLoadGame() ; this works only for a player alias script ENDEVENT EVENT OnSpellCast(Form akSpell) ; event does not trigger within ActiveMagicEffect scripts, (yes I know it is a part of vanilla script) Debug.Notification("Someone cast a Spell") Debug.Trace("GSG_Alias: casts " +akSpell+ ", Ref = " + self.GetActorReference()) GSG_QuestScript ps = self.GetOwningQuest() as GSG_QuestScript ps.myF_Store(akSpell as Spell) ; update quest script variable, by using a function ps.myStoredSP = akSpell as Spell ; update quest script property, no function needed ENDEVENT GSG_MagicEffectScript Scriptname GSG_MagicEffectScript extends ActiveMagicEffect {sample 2017} ; former scriptname was testrelease_script Quest PROPERTY myQuest auto ; fill with your created quest ; -- EVENT -- EVENT OnEffectStart(Actor akTarget, Actor akCaster) Debug.Trace("GSG_MagicEffect: with target = " +akTarget+ ", caster = " +akCaster) spell sp = (myQuest as GSG_QuestScript).myF_GetSpell() ; use a function to get the script variable ;;; spell sp = (myQuest as GSG_QuestScript).myStoredSP ; use this construct to get a script property (without any semicolon infront) sp.Cast(Game.GetPlayer() as ObjectReference) Debug.Notification("casting a Spell") ENDEVENT ; your code: ; If playerref.getactorvalue(Health) <= 50% ; IF (Game.GetPlayer().GetActorValue("Health") < 0.5) ; ; player is of lower health < 50 percent ; ELSE ; ; player is of good health => 50 percent ; ENDIF Edited September 30, 2017 by ReDragon2013 Link to comment Share on other sites More sharing options...
ReDragon2013 Posted September 30, 2017 Share Posted September 30, 2017 (edited) Do NOT use PlayerRef as follow Scriptname SampleScript extends ObjectReference Actor PROPERTY PlayerRef auto ; this is a script property which makes this actor (a subclass of objectReference) persistent as long as your mod is activemuch better Scriptname SampleScript extends ObjectReference FUNCTION sampleFunction() ;------------------------ actor PlayerRef = Game.GetPlayer() ; use a function variable instead of script property int i = PlayerRef.GetLevel() ; just a sample ENDFUNCTION ; function has finished and persistent variable is gone Edited September 30, 2017 by ReDragon2013 Link to comment Share on other sites More sharing options...
JonathanOstrus Posted September 30, 2017 Share Posted September 30, 2017 Do NOT use PlayerRef as follow Scriptname SampleScript extends ObjectReference Actor PROPERTY PlayerRef auto ; this is a script property which makes this actor (a subclass of objectReference) persistent as long as your mod is active For argument sake why not? PlayerRef is always persistent anyway. Link to comment Share on other sites More sharing options...
GSGlobe Posted October 1, 2017 Author Share Posted October 1, 2017 (edited) I am not really understand what do you want to get as result with your scripts. Imho you are on the wrong way.Have a look into the next scripts! Maybe it is useful.ÃÂ GSG_QuestScript Scriptname GSG_QuestScript extends Quest {sample 2017}ÃÂ ÃÂ ÃÂ ; former scriptname was Auto_GlobalVar_Script ; https://forums.nexusmods.com/index.php?/topic/6018743-onspellcast-event-question/ ; GSGlobe has written ÃÂ Spell myStoredSpellÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ; this is a script variable ÃÂ Spell PROPERTY myStoredSP auto HiddenÃÂ ÃÂ ÃÂ ÃÂ ; this is a script property ; -- FUNCTIONs -- 2 ;-------------------------------- FUNCTION myF_Store(Spell akSpell) ;-------------------------------- ÃÂ ÃÂ ÃÂ myStoredSpell = akSpell ENDFUNCTION ;---------------------------- Spell FUNCTION myF_GetSpell() ;---------------------------- ÃÂ ÃÂ ÃÂ RETURN myStoredSpell ENDFUNCTION ÃÂ GSG_AliasScript Scriptname GSG_AliasScript extends ReferenceAlias {sample 2017}ÃÂ ÃÂ ÃÂ ; former scriptname was teststore_script ; -- EVENTs -- EVENT OnPlayerLoadGame() ÃÂ ÃÂ ÃÂ ; this works only for a player alias script ENDEVENT EVENT OnSpellCast(Form akSpell)ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ; event does not trigger within ActiveMagicEffect scripts, (yes I know it is a part of vanilla script) ÃÂ ÃÂ ÃÂ Debug.Notification("Someone cast a Spell") ÃÂ ÃÂ ÃÂ Debug.Trace("GSG_Alias: casts " +akSpell+ ", Ref = " + self.GetActorReference()) ÃÂ ÃÂ ÃÂ GSG_QuestScript ps = self.GetOwningQuest() as GSG_QuestScript ÃÂ ÃÂ ÃÂ ps.myF_Store(akSpell as Spell)ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ; update quest script variable, by using a function ÃÂ ÃÂ ÃÂ ps.myStoredSP = akSpell as SpellÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ; update quest script property, no function needed ENDEVENT ÃÂ GSG_MagicEffectScript Scriptname GSG_MagicEffectScript extends ActiveMagicEffect {sample 2017}ÃÂ ÃÂ ÃÂ ; former scriptname was testrelease_script ÃÂ Quest PROPERTY myQuest autoÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ; fill with your created quest ; -- EVENT -- EVENT OnEffectStart(Actor akTarget, Actor akCaster) ÃÂ ÃÂ ÃÂ Debug.Trace("GSG_MagicEffect: with target = " +akTarget+ ", caster = " +akCaster) ÃÂ ÃÂ ÃÂ spell sp = (myQuest as GSG_QuestScript).myF_GetSpell()ÃÂ ÃÂ ÃÂ ; use a function to get the script variable ;;; spell sp = (myQuest as GSG_QuestScript).myStoredSPÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ; use this construct to get a script property (without any semicolon infront) ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ sp.Cast(Game.GetPlayer() as ObjectReference) ÃÂ ÃÂ ÃÂ Debug.Notification("casting a Spell") ENDEVENT ;ÃÂ your code: ;ÃÂ ÃÂ ÃÂ If playerref.getactorvalue(Health) <= 50% ;ÃÂ ÃÂ ÃÂ IF (Game.GetPlayer().GetActorValue("Health") < 0.5) ;ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ; player is of lower health < 50 percent ;ÃÂ ÃÂ ÃÂ ELSE ;ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ; player is of good health => 50 percent ;ÃÂ ÃÂ ÃÂ ENDIFWhat I want to do is have a spell; That stores a spell, for example you cast "Store" then you cast fireball.Fireball is then saved and be called in another script using conditions IF any of the condition is met then fireball fires. And you can simply change your stored spell from fireball to firebolt simply by recasting "Store" and then firebolt. OnSpellCast works or am I understanding IT wrong? Is your scripts more efficient? Or whats the difference? Thanks alot for taking your time helping :) Edit: at this moment I have two spells and a quest. One spell stores a spell, the other spell is a constant spell which runs until a condition is met then applies a cooldown then cast a cooldown spell and dispel. Edited October 1, 2017 by GSGlobe Link to comment Share on other sites More sharing options...
GSGlobe Posted October 2, 2017 Author Share Posted October 2, 2017 (edited) Another question: I have made 5 abilities and 5x scripts set to constant linked to these abilites 5 perks linked to these 5 abilities and 5 spells that toggle each ability on and off. I'm wondering how I can make it so that WHEN 1 spell fires, 2 ability toggles on, WHEN 2 spell fires, 3 abilitiy toggles on etctill 5 spell fires then go back to activate spell 1? I've tried to make the ability 1 (Don't fire when Cooldown 1 is active) Ability 2 (Fire when Cooldown 1 is active and Cooldown 2 ISNT active) and so on, on the ability spell window, I also tried setting it up on Magic Effect Window, but I can't recall if I removed the Spell conditions on the ability beforehand or not, don't suppose that makes any difference? But if I toggle ability 1 - 2 - 3 - 4 - 5 Only first spell activates and second spell never activates unless I activate it when Cooldown 1 is active. Would be nice if the second spell activates directly after Spell 1 is fired by itself, without having to cast the toggle ability after the first spell is fired. I figured adding HasMagicEffect(CooldownX) into the scripts but I'm worried it might cause performance hit since the scripts are constant? However only active for a while. Edit: The spells dispels after each use and places a cooldown upon itself. If that makes any difference?My initial idea was to have Spell 1 - Cast spell 2 and Spell 2 Cast Spell 3, and Spell 5 cast a cooldown and Spell 1, but then we're back at the problem I'm having now that Spell 1 Won't activate because cooldown X is active. Perhaps Cooldown X needs a script to cast Spell 1 on effect finish? Im out of ideas, please?But that makes it so, one needs to have all 5 spells in order for it to reset.. I wanna keep it so, one can choose spell 1 2 3 and not need all of them. If that makes any sense Any ideas would be greatly appreciated as I'm uncapable of seeing a fix, I'm quite lost on this one!Best regards! Edited October 2, 2017 by GSGlobe Link to comment Share on other sites More sharing options...
ReDragon2013 Posted October 2, 2017 Share Posted October 2, 2017 BigAndFlabby wrote: "For argument sake why not? PlayerRef is always persistent anyway."Please read the content of the next link, it is essentiell to understand, How does papyrus persistence is working?Make sure your browser has cookies on. http://www.creationkit.com/index.php?title=Persistence_%28Papyrus%29The player is a persistent object in the Skyrim world. The position of the player determines which cell(s) has/have to be attached/detached [events: OnCellAttach(), OnCellDetach()],and later become(s) 3D ready or will be lost [events: OnCellLoad() / OnLoad(), OnUnLoad()].Within papyrus scripting it is a bit more complicated. Every additional script variable or property which is of type "Actor" or "ObjectReference" is blowing up the memory and savegame.Each script or script instance handles the PlayerRef as a separate persistent actor for example, keep it in mind. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted October 2, 2017 Share Posted October 2, 2017 (edited) @GSGlobe: At the moment I do not have enough time to give you more help. My English knowledge is not good enough to understand your aim.Just a hint, use keywords (new created by your mod) within the MagicEffect. It makes conditions much more efficently. Edited October 2, 2017 by ReDragon2013 Link to comment Share on other sites More sharing options...
Recommended Posts