Is this a known bug?

Post » Wed Jun 20, 2012 12:21 am

If you set a global int its ID changes per script block. I tested it with playing sounds. If you call out a sound to play (per the ID I set), and the sound descriptor is a loop, if you try to stop the instance from another block it has a separate internal ID (and thus the looped sound does not stop playing). This intended? What's the point of setting a global int in your script if it's uniqueness is always reset?
User avatar
Pat RiMsey
 
Posts: 3306
Joined: Fri Oct 19, 2007 1:22 am

Post » Wed Jun 20, 2012 3:02 am

Is this like the experiment RandomNoob did with the daggers? Or something else?

http://www.gamesas.com/topic/1358006-scripted-objects-in-inventory/
User avatar
Taylor Tifany
 
Posts: 3555
Joined: Sun Jun 25, 2006 7:22 am

Post » Wed Jun 20, 2012 9:54 am

Hmm that could be related. I'm not familiar with "OnInit" or how it would apply to playing a sound.
User avatar
Katharine Newton
 
Posts: 3318
Joined: Tue Jun 13, 2006 12:33 pm

Post » Wed Jun 20, 2012 1:22 am

RN's example shows a script-global int that's not holding the values you'd think it would across inventory moves.

Just wondered if yours was moving containers too.
User avatar
bimsy
 
Posts: 3541
Joined: Wed Oct 11, 2006 3:04 pm

Post » Wed Jun 20, 2012 7:01 am

No mine is just a sound property. If I start and stop the sound in the same block it works. But if I try to stop the sound in following 'else' the stopinstance changes ID inwrtly. I tested this by adding a blank msgbox in the first 'if' and in the following 'else'. The first returned an ID of 161 and the following returned 0. Even though the play and stop both used the same global int. Script is at home can't post it.
User avatar
Setal Vara
 
Posts: 3390
Joined: Thu Nov 16, 2006 1:24 pm

Post » Wed Jun 20, 2012 5:32 am

Here is the script. Everything except for my little problem of the looping Sound Descriptor called "BatsFlying". Which I've set to a global ID as "BatsFly"

The spell is a toggle (ignore the Fly function I haven't got it working yet. It compiles but does nothing basically)

Scriptname DV_BatFormTraits extends ActiveMagicEffect  import Gameimport Soundimport Formimport Debugimport Utilityimport GlobalVariableimport ActorActor Property Player AutoSpell Property DVampireBatForm AutoSpell Property DVampireBatFormToggle AutoIdle Property SwimStart AutoIdle Property swimStop AutoIdle Property JumpFall Autobool Property bIsOn Autobool Property bVal AutoEffectShader Property DVCelerityShadowForBats AutoEffectShader Property Bats_DV AutoSound Property AMBBatsSD AutoSound Property BatsFlying AutoSound Property BatsLeaving Autofloat bearingfloat elevationfloat speedfloat posxfloat posyfloat poszfloat movefloat dtimeint BatsFlyIDint BatsLeaveIDEvent OnEffectStart(Actor Target, Actor Caster)if !Caster.IsInInterior()	if !Caster.HasSpell(DVampireBatFormToggle)			Caster.AddSpell(DVampireBatFormToggle, false)			Caster.SetAlpha(0)			Wait(0.1)			DisablePlayerControls()			Wait(0.1)			SetIniFloat("fInAirFallingCharGravityMult:Havok",0)			Caster.MoveTo(Caster, 0, 0, 800)		    BatsFlyID = BatsFlying.Play(Caster)	  ;turn on the sound to play while in Bat Form			SetInstanceVolume(BatsFlyID, 2.0)			Caster.TranslateTo(Caster.GetPositionX(), Caster.GetPositionY(), Caster.GetPositionZ(), 0.0, 0.0, 0.0, 0.0)			Wait(0.1)			Caster.StopTranslation()			DVCelerityShadowForBats.Play(Caster)			Bats_DV.Play(Caster)						Caster.SetAllowFlying()			ForceThirdPerson()			Wait(0.1)			SendAnimationEvent(Caster ,"SwimStart")			EnablePlayerControls()			SetIniFloat("fInAirFallingCharGravityMult:Havok",0)			while Caster.HasSpell(DVampireBatFormToggle)				 Fly()			endwhile			;bVal = True	else			Caster.RemoveSpell(DVampireBatFormToggle)			SendAnimationEvent(Caster ,"JumpFall")			Caster.SetAlpha(1)			DVCelerityShadowForBats.Stop(Caster)			Bats_DV.Stop(Caster)			Caster.SetAllowFlying(false)		    StopInstance(BatsFlyID)				  ;turn off the flying sound when Bat Form ends			BatsLeaveID = BatsLeaving.Play(Caster)			   ;landing/exit form sound			;bVal = False	endifendif			;Toggle()	EndEventfunction Fly()		if Player.IsRunning()				posx = Player.GetPositionX()				posy = Player.GetPositionY()				posz = Player.GetPositionZ()				bearing = Player.GetAngleZ()				elevation = Player.GetAngleX()				speed = 1000				if bearing < 90						posx += (bearing)*speed						posy += (90 - bearing)*speed				elseif bearing > 90 && bearing < 180						posx +=(180 - bearing)*speed						posy +=(90 - bearing)*speed				elseif bearing > 180 && bearing < 270						posx += (180 - bearing)*speed						posy += (bearing - 270)*speed										elseif bearing > 270						posx += (bearing - 360)*speed						posy += (bearing - 270)*speed										endif				posz = Player.GetPositionZ() - (elevation*speed)				Player.TranslateTo(posx,posy,posz,Player.GetAngleX(),Player.GetAngleY(),Player.GetAngleZ(),speed,1)				if Player.IsSprinting()						move = 0				endIf				else						Player.StopTranslation()		endIfendFunctionEvent OnTranslationComplete()		move = 0		Fly()endEventFunction Toggle()	if (bVal == True)		bIsOn = True	elseif (bVal == False)		bIsOn = False	endif	EndFunctionEvent OnEffectFinish(Actor Player, Actor Caster)		 Player.StopTranslation()		 SetIniFloat("fInAirFallingCharGravityMult:Havok",1.35)		EndEvent



The StopInstance does not stop the sound and thus my looping bat sound just keeps playing ingame. Much to my annoyance.
User avatar
Eibe Novy
 
Posts: 3510
Joined: Fri Apr 27, 2007 1:32 am

Post » Wed Jun 20, 2012 12:42 pm

By the way, I recommend http://www.youtube.com/watch?v=iCEDfZgDPS8for your bats-flying music...
User avatar
Dragonz Dancer
 
Posts: 3441
Joined: Sat Jun 24, 2006 11:01 am

Post » Wed Jun 20, 2012 12:05 pm

By the way, I recommend http://www.youtube.com/watch?v=iCEDfZgDPS8for your bats-flying music...

rofl.... that is so good. I might just do that.

Oh man I think I have too. I forgot all about this song.

Well, as soon as I figure out how to stop music/sound in a different block.
User avatar
carrie roche
 
Posts: 3527
Joined: Mon Jul 17, 2006 7:18 pm

Post » Tue Jun 19, 2012 11:18 pm

Could you check the ID for a positive value in OnEffectFinish, and stop it there?

Only one part of the 'If' and 'else' part of an instance of this script will ever run.
Each instance of the script will have their own instance of the script-global.

So it's not really a global, perhaps a better name would be a script-wide-temp.
User avatar
Princess Johnson
 
Posts: 3435
Joined: Wed Feb 07, 2007 5:44 pm

Post » Wed Jun 20, 2012 8:16 am

I have not yet played with spells and spelleffects, but if your event is onEffectStart(), I suppose, you recast the spell, so it's a new effect and not the first, so it's normal that all the declaration are at default and your soundinstance is null.
User avatar
Ana
 
Posts: 3445
Joined: Sat Jul 01, 2006 4:29 am

Post » Wed Jun 20, 2012 12:39 pm

Hmm. I see. I didn't know that was going on.

Well then how would I make the sound play (and loop) only while the first part of the spell is being used? Is that even possible? I imagine it has to be. For example when you cast a channeled spell it only makes noise when the spell is being used. Could this be utilized similarly?
User avatar
jaideep singh
 
Posts: 3357
Joined: Sun Jul 08, 2007 8:45 pm

Post » Tue Jun 19, 2012 9:12 pm

I've not messed with sounds at all... Does it loop when you call Play on a sound? If not, the ID doesn't even really matter after the sound finishes playing, does it?

If it doesn't loop, then I guess you need to time your sound, then calculate how much time has passed using your while loop with http://www.creationkit.com/GetRealHoursPassed_-_Game, and call play on it again when appropriate.

If it does loop, then I think what you need is an actual global variable to store your ID, not one declared in the script. You can create global variables by clicking Global under the Miscellaneous category in the object window.

Also, are you sure you set the Player property to the player? That could be why your fly function doesn't work.
User avatar
*Chloe*
 
Posts: 3538
Joined: Fri Jul 07, 2006 4:34 am

Post » Tue Jun 19, 2012 9:21 pm

I've not messed with sounds at all... Does it loop when you call Play on a sound? If not, the ID doesn't even really matter after the sound finishes playing, does it?

If it doesn't loop, then I guess you need to time your sound, then calculate how much time has passed using your while loop with http://www.creationkit.com/GetRealHoursPassed_-_Game, and call play on it again when appropriate.

If it does loop, then I think what you need is an actual global variable to store your ID, not one declared in the script. You can create global variables by clicking Global under the Miscellaneous category in the object window.

Also, are you sure you set the Player property to the player? That could be why your fly function doesn't work.

Aaah yes a global variable. That makes sense. I will try that.

That's true. The Fly function is set to use Player instead of Caster. It probably will work once I change that :tongue:

The sound by default is designed to loop. Which is essentially what I wanted it to do. However it just wasn't stopping. But yes if I make it a global variable perhaps that would work.

I will test it and report back.
User avatar
Elizabeth Falvey
 
Posts: 3347
Joined: Fri Oct 26, 2007 1:37 am

Post » Wed Jun 20, 2012 2:10 am

Hmm. Well Global Variables aren't what I thought they would be. I'm not sure I can create a global variable for a sound. Since the Global is just a value. Or at least as I am still new to scripting I simply do not know how to utilize it.
User avatar
Cartoon
 
Posts: 3350
Joined: Mon Jun 25, 2007 4:31 pm

Post » Wed Jun 20, 2012 8:00 am

http://www.creationkit.com/Global

Just create your global variable and don't check "constant". Use setvalue() and getvalue() and affect/retrieve your soundinstance from/to your globalVAR.
User avatar
Amysaurusrex
 
Posts: 3432
Joined: Wed Aug 09, 2006 2:45 pm

Post » Wed Jun 20, 2012 1:29 am

http://www.creationkit.com/Global

Just create your global variable and don't check "constant". Use setvalue() and getvalue() and affect/retrieve your soundinstance from/to your globalVAR.

Ah ha!

Thank you my friend! I will go and do this and report back!
User avatar
jaideep singh
 
Posts: 3357
Joined: Sun Jul 08, 2007 8:45 pm

Post » Wed Jun 20, 2012 2:37 am

Alright so I'm just not getting how I can set a globalvariable to the sound to play so that I can cancel the sound outside of its instance (and also have it keep the same ID everytime the spell is cast).

I know it's rude to ask this but if someone could write it out for me so I can understand it I'd really appreciate it.

I created a GlobalVariable and added it to my script as a property.

I have both an int instanceID set to play the sound and I have the sound properties set in the script.

What I need to learn now is how to use the SetValue and GetValue so I can assign a unique id to the sound that is always used and thus hopefully end this sound nightmare I'm having with my scripted spell.

If you can help thanks :)
User avatar
Poetic Vice
 
Posts: 3440
Joined: Wed Oct 31, 2007 8:19 pm

Post » Wed Jun 20, 2012 4:45 am

It compiled, don't know if it'll work though:

;;;Sound Property BatsFlying AutoGlobalVariable property GlobalInt autoEvent OnEffectStart(Actor Target, Actor Caster)	if (GlobalInt.GetValueInt() == 0)	;default, so we hadn't assigned an ID to it yet		GlobalInt.SetValueInt(BatsFlying.Play(Caster))	else				;we had already assigned an ID to it		Sound.StopInstance(GlobalInt.GetValueInt())		GlobalInt.SetValueInt(0)	endif	;;;	EndEvent
User avatar
Tiffany Carter
 
Posts: 3454
Joined: Wed Jul 19, 2006 4:05 am

Post » Wed Jun 20, 2012 12:50 pm

Man thank you so much RandomNoob. I got my fingers crossed. Gonna test it right now.
User avatar
Joanne
 
Posts: 3357
Joined: Fri Oct 27, 2006 1:25 pm

Post » Tue Jun 19, 2012 9:41 pm

It must works. I made a test with a trigger and it works.

Scriptname aaapjmtlgsoundtest01script extends ObjectReference Sound Property AMBWaterfallSmallLP  Auto GlobalVariable Property aaapjmtlgGlobSound  Auto Event onTriggerEnter(ObjectReference triggerRef)    Int MySoundID = AMBWaterfallSmallLP.Play(triggerRef)      sound.SetInstanceVolume(MySoundID, 1.0)    aaapjmtlgGlobSound.SetValueInt(MySoundID)   EndEventEvent OnTriggerLeave(ObjectReference triggerRef)    Int MySoundID =aaapjmtlgGlobSound.GetValueInt()    sound.StopInstance(MySoundID)EndEvent
User avatar
Wayland Neace
 
Posts: 3430
Joined: Sat Aug 11, 2007 9:01 am

Post » Wed Jun 20, 2012 9:52 am

Well perhaps the clinging problem is that my Sound Descriptor is set to loop. But thats the intended effect. It's basically a sound file of many bats screaming and in the sound descriptor settings I set it to loop.

I just tried this code and the same problems occur the sound plays when the ability starts. When it ends it does not stop and when you cast the spell again the sound stacks over the one currently playing. Like an endless stacking loop. Is it possible my while loop is screwing with it?

Event OnEffectStart(Actor Target, Actor Caster)if !Caster.IsInInterior()    if !Caster.HasSpell(DVampireBatFormToggle)		    Caster.AddSpell(DVampireBatFormToggle, false)            VampireLaughID = VampireLaugh.Play(Caster)            SetInstanceVolume(VampireLaughID, 3.0)            Wait(1.5)            Caster.SetAlpha(0)            Wait(0.1)		    DisablePlayerControls()		    Wait(0.1)		    Caster.TranslateTo(Caster.GetPositionX(), Caster.GetPositionY(), Caster.GetPositionZ() + 500, 0.0, 0.0, 0.0, 1000.0)		    Wait(0.1)            SetIniFloat("fInAirFallingCharGravityMult:Havok",0)		    DVCelerityShadowForBats.Play(Caster)   	 if  (BatsFlyingSoundLoopGLBL.GetvalueInt() == 0)			    BatsFlyingSoundLoopGLBL.SetValueInt(BatsFlying.Play(Caster))	    endif		    Bats_DV.Play(Caster)                        Caster.SetAllowFlying()		    ForceThirdPerson()            Wait(0.1)            SendAnimationEvent(Caster ,"SwimStart")            EnablePlayerControls()            SetIniFloat("fInAirFallingCharGravityMult:Havok",0)            while Caster.HasSpell(DVampireBatFormToggle)			    Fly()		    endwhile            ;bVal = True    else		    Caster.RemoveSpell(DVampireBatFormToggle)            SendAnimationEvent(Caster ,"JumpFall")            Caster.SetAlpha(1)            DVCelerityShadowForBats.Stop(Caster)            Bats_DV.Stop(Caster)            Caster.SetAllowFlying(false)            StopInstance(BatsFlyingSoundLoopGLBL.GetValueInt())            BatsFlyingSoundLoopGLBL.SetValueInt(0)            BatsLeaveID = BatsLeaving.Play(Caster)            ;bVal = False    endifendif            ;Toggle()    EndEvent
User avatar
Glu Glu
 
Posts: 3352
Joined: Sun Apr 01, 2007 5:39 am

Post » Wed Jun 20, 2012 11:37 am

You need an event "OnEffectFinish" to stop the sound when the magic effect... hum... finishes :)
http://www.creationkit.com/OnEffectFinish_-_ActiveMagicEffect
User avatar
Horror- Puppe
 
Posts: 3376
Joined: Fri Apr 13, 2007 11:09 am

Post » Wed Jun 20, 2012 10:55 am

You need an event "OnEffectFinish" to stop the sound when the magic effect... hum... finishes :smile:
http://www.creationkit.com/OnEffectFinish_-_ActiveMagicEffect

Ah yes I do have of course an OnEffectFinish (I didnt post it). That's where I should put it the Stop isn't it? I will try this, thank you.
User avatar
jodie
 
Posts: 3494
Joined: Wed Jun 14, 2006 8:42 pm

Post » Wed Jun 20, 2012 6:02 am

If you use the OnEffectFinish block, you don't really even need a global variable to store the ID, do you? That would make things a lot simpler.
User avatar
Megan Stabler
 
Posts: 3420
Joined: Mon Sep 18, 2006 2:03 pm

Post » Wed Jun 20, 2012 9:00 am

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
:banana: :banana: :banana:
:run:
http://www.youtube.com/watch?v=RaxVwD-HvNU













It worked! The sound stops. I'm gonna dig up Einstein and shake his hand!

Man thank you thank you thank you. I scared the dog from cheering.
User avatar
Victor Oropeza
 
Posts: 3362
Joined: Sun Aug 12, 2007 4:23 pm

Next

Return to V - Skyrim