ZansoHel Posted October 23, 2012 Share Posted October 23, 2012 (edited) Hey! I tried to create a script which removes one dragon soul when you "meditate" aka sit on certain chair and adds a magic effect to you. It works fine except that the message box pops up when going down on the chair (sitting) and again when standing up. I would like it to pop out only once when sitting down. Below is the script. Any suggestion how I could make that happen? Scriptname MeditateScript1 extends ObjectReference Spell Property Blessing Auto GlobalVariable Property TimeScale AutoSpell Property Shoutname AutoActor Property PlayerREF AutoKeyword Property MeditateEffect Auto Event OnActivate(ObjectReference akActionRef) if Game.GetPlayer(). hasmagiceffectwithkeyword(MeditateEffect) == 0 If Game.GetPlayer().GetAv("DragonSouls") > 0 Utility.Wait(1.5) Timescale.SetValue(5000) Utility.Wait(3.5) Debug.MessageBox("You lost Dragon Soul, but got a cool buff. Yay!") Game.GetPlayer().Modav("Dragonsouls", -1) Blessing.Cast(akActionRef, akActionRef) Timescale.SetValue(20) Endif EndIf if Game.GetPlayer(). hasmagiceffectwithkeyword(MeditateEffect) == 1 If Game.GetPlayer().GetAv("DragonSouls") > 0 Utility.Wait(2.0) Debug.MessageBox("You have already meditated today!") EndIf EndIF If Game.GetPlayer().GetAv("DragonSouls") < 1 Utility.Wait(2.0) Debug.MessageBox("You don't have any Dragon Souls!") EndIF EndEvent I would appreciate any help! :) Edited October 23, 2012 by Pusin Link to comment Share on other sites More sharing options...
acidzebra Posted October 23, 2012 Share Posted October 23, 2012 (edited) whoops - ghaunadaur you are absolutely right. Pretend I didn't say anything. :whistling: Edited October 23, 2012 by acidzebra Link to comment Share on other sites More sharing options...
Ghaunadaur Posted October 23, 2012 Share Posted October 23, 2012 An additional if-condition to check the player is not sitting or wants to sit down: if Game.GetPlayer().GetSitState() < 3 . . . endif @acidzebra I believe OnSit() will only called on an actor. Link to comment Share on other sites More sharing options...
steve40 Posted October 24, 2012 Share Posted October 24, 2012 (edited) Try this. Also, what happens if a player is not using the default timescale of 20? For example, I like to play with the timescale always set to 5. Your script resets it back to 20, tsk tsk. Scriptname MeditateScript1 extends ObjectReference Spell Property Blessing Auto GlobalVariable Property TimeScale Auto Keyword Property MeditateEffect Auto ;****************************************** AUTO STATE WAITING Event OnActivate(ObjectReference ActionRef) If ActionRef == Game.GetPlayer() GoToState("BUSY") float myTimeScale = TimeScale.GetValue() ; you need to cater for users who are not using the default timescale!!! If ActionRef.GetAv("DragonSouls") < 1 Utility.Wait(2.0) Debug.MessageBox("You don't have any Dragon Souls!") Elseif ActionRef.hasmagiceffectwithkeyword(MeditateEffect) Utility.Wait(2.0) Debug.MessageBox("You have already meditated today!") Else Utility.Wait(1.5) TimeScale.SetValue(5000) Utility.Wait(3.5) Debug.MessageBox("You lost a Dragon Soul, but got a cool buff. Yay!") ActionRef.Modav("Dragonsouls", -1) Blessing.Cast(ActionRef, ActionRef) TimeScale.SetValue(myTimeScale) ; be nice to users who may be using a non-default setting! EndIf EndIf EndEvent ENDSTATE ;****************************************** STATE BUSY Event OnActivate(ObjectReference ActionRef) GoToState("WAITING") EndEvent ENDSTATE Alternatively, incorporating Ghaunadaur's suggestion: Scriptname MeditateScript1 extends ObjectReference Spell Property Blessing Auto GlobalVariable Property TimeScale Auto Keyword Property MeditateEffect Auto ;****************************************** Event OnActivate(ObjectReference ActionRef) If ActionRef == Game.GetPlayer() && ActionRef.GetSitState() < 3 float myTimeScale = TimeScale.GetValue() ; you need to cater for users who are not using the default timescale!!! If ActionRef.GetAv("DragonSouls") < 1 Utility.Wait(2.0) Debug.MessageBox("You don't have any Dragon Souls!") Elseif ActionRef.hasmagiceffectwithkeyword(MeditateEffect) Utility.Wait(2.0) Debug.MessageBox("You have already meditated today!") Else Utility.Wait(1.5) TimeScale.SetValue(5000) Utility.Wait(3.5) Debug.MessageBox("You lost a Dragon Soul, but got a cool buff. Yay!") ActionRef.Modav("Dragonsouls", -1) Blessing.Cast(ActionRef, ActionRef) TimeScale.SetValue(myTimeScale) ; be nice to users who may be using a non-default setting! EndIf EndIf EndEvent Edited October 24, 2012 by steve40 Link to comment Share on other sites More sharing options...
ZansoHel Posted October 24, 2012 Author Share Posted October 24, 2012 Strange... the both give the same error message (some functions doesn't compile with actionRef?) c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\MeditateScript1.psc(11,54): GetSitState is not a function or does not existc:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\MeditateScript1.psc(11,68): cannot compare a none to a int (cast missing or types unrelated)c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\MeditateScript1.psc(11,68): cannot relatively compare variables to Nonec:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\MeditateScript1.psc(15,29): GetAv is not a function or does not existc:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\MeditateScript1.psc(15,50): cannot compare a none to a int (cast missing or types unrelated)c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\MeditateScript1.psc(15,50): cannot relatively compare variables to None However, the below one works if I change the actionRef to Game.GetPlayer() on the error giving functions, but the above one does nothing (the player just sits there). Scriptname MeditateScript1 extends ObjectReference Spell Property Blessing AutoGlobalVariable Property TimeScale AutoKeyword Property MeditateEffect Auto Event OnActivate(ObjectReference ActionRef) If ActionRef == Game.GetPlayer() && Game.GetPlayer().GetSitState() < 3 float myTimeScale = TimeScale.GetValue() If Game.GetPlayer().GetAv("DragonSouls") < 1 Utility.Wait(2.0) Debug.MessageBox("You don't have any Dragon Souls!") Elseif Game.GetPlayer().hasmagiceffectwithkeyword(MeditateEffect) Utility.Wait(2.0) Debug.MessageBox("You have already meditated today!") Else Utility.Wait(1.5) TimeScale.SetValue(5000) Utility.Wait(3.5) Debug.MessageBox("You lost a Dragon Soul, but got a cool buff. Yay!") Game.GetPlayer().Modav("Dragonsouls", -1) Blessing.Cast(ActionRef, ActionRef) TimeScale.SetValue(myTimeScale) EndIf EndIf EndEvent Any idea what the problem might be? Link to comment Share on other sites More sharing options...
steve40 Posted October 24, 2012 Share Posted October 24, 2012 (edited) Oops, the ActionRef needed to be cast as an Actor. Scriptname MeditateScript1 extends ObjectReference Spell Property Blessing Auto GlobalVariable Property TimeScale Auto Keyword Property MeditateEffect Auto ;****************************************** AUTO STATE WAITING Event OnActivate(ObjectReference ActionRef) If ActionRef as Actor == Game.GetPlayer() Actor ActorRef = ActionRef as Actor GoToState("BUSY") float myTimeScale = TimeScale.GetValue() ; you need to cater for users who are not using the default timescale!!! If ActorRef.GetAv("DragonSouls") < 1 Utility.Wait(2.0) Debug.MessageBox("You don't have any Dragon Souls!") Elseif ActorRef.hasmagiceffectwithkeyword(MeditateEffect) Utility.Wait(2.0) Debug.MessageBox("You have already meditated today!") Else Utility.Wait(1.5) TimeScale.SetValue(5000) Utility.Wait(3.5) Debug.MessageBox("You lost a Dragon Soul, but got a cool buff. Yay!") ActorRef.Modav("Dragonsouls", -1) Blessing.Cast(ActorRef, ActorRef) TimeScale.SetValue(myTimeScale) ; be nice to users who may be using a non-default setting! EndIf EndIf EndEvent ENDSTATE ;****************************************** STATE BUSY Event OnActivate(ObjectReference ActionRef) GoToState("WAITING") EndEvent ENDSTATE Scriptname MeditateScript1 extends ObjectReference Spell Property Blessing Auto GlobalVariable Property TimeScale Auto Keyword Property MeditateEffect Auto ;****************************************** Event OnActivate(ObjectReference ActionRef) If ActionRef as Actor == Game.GetPlayer() && (ActionRef as Actor).GetSitState() < 3 Actor ActorRef = ActionRef as Actor float myTimeScale = TimeScale.GetValue() ; you need to cater for users who are not using the default timescale!!! If ActorRef.GetAv("DragonSouls") < 1 Utility.Wait(2.0) Debug.MessageBox("You don't have any Dragon Souls!") Elseif ActorRef.hasmagiceffectwithkeyword(MeditateEffect) Utility.Wait(2.0) Debug.MessageBox("You have already meditated today!") Else Utility.Wait(1.5) TimeScale.SetValue(5000) Utility.Wait(3.5) Debug.MessageBox("You lost a Dragon Soul, but got a cool buff. Yay!") ActorRef.Modav("Dragonsouls", -1) Blessing.Cast(ActorRef, ActorRef) TimeScale.SetValue(myTimeScale) ; be nice to users who may be using a non-default setting! EndIf EndIf EndEvent Edited October 24, 2012 by steve40 Link to comment Share on other sites More sharing options...
ZansoHel Posted October 24, 2012 Author Share Posted October 24, 2012 Works perfectly! Thanks a lot for all help! :) Link to comment Share on other sites More sharing options...
Recommended Posts