Play a sound every 24 in-game hours, no matter location?

Post » Tue Nov 20, 2012 11:00 am

the title. I want to set it so that after the main quest, Every 24 hours in game a loud noise will sound, and while not required, I would like it to shake the screen to. Now, the bell will toll every 24 hours at first. after 3 days, this turns to twelve hours. Do this for 3 days, then start the quest. Presently, I only ahve a base script going to initiate the Bell. It is not working.

Scriptname SDWBBellScript extends ObjectReferenceObjectReference Property SDWTheBell  AutoQuest Property NewProperty  AutoSound Property SDWTheBellSound  AutoFunction SleepFunction()RegisterForSleep()EndFunctionEvent OnSleepStop(bool abInterupted)if (NewProperty.GetStage() >= 260)Utility.WaitGameTime(24.5)  int InstanceID = SDWTheBellSound.Play(Game.GetPlayer())   Utility.Wait(5.0)  EndifEndEvent


It compiles with no issues. It just does not do the bell noise like I want it to.

Any ideas?

PLEASE NOTE: The new property is the end quest of the main SKYRIM storyline.
User avatar
Adam Porter
 
Posts: 3532
Joined: Sat Jun 02, 2007 10:47 am

Post » Tue Nov 20, 2012 3:02 pm

Can't you just add a condition to the sound descriptor, with these conditions:

GetQuestCompleted MQ306

and do the same for the timing?
User avatar
Courtney Foren
 
Posts: 3418
Joined: Sun Mar 11, 2007 6:49 am

Post » Tue Nov 20, 2012 9:01 pm

Check out the Vampire control Quest, it does something similar to this with the Change noise. It uses a marker, and moves it to the player, and uses that as the sound-sorce. It might help you solve the problem.
User avatar
Katie Pollard
 
Posts: 3460
Joined: Thu Nov 09, 2006 11:23 pm

Post » Tue Nov 20, 2012 2:54 pm

Can't you just add a condition to the sound descriptor, with these conditions:

GetQuestCompleted MQ306

and do the same for the timing?


Hadn't really thought of that. But that doesn't make it play everywhere.


Check out the Vampire control Quest, it does something similar to this with the Change noise. It uses a marker, and moves it to the player, and uses that as the sound-sorce. It might help you solve the problem.

This on the other hand, very well might. I'll edit this post as to if it works or not.

Quick question: Vampire control quest? I've looked, but cant find it. :/
User avatar
kevin ball
 
Posts: 3399
Joined: Fri Jun 08, 2007 10:02 pm

Post » Tue Nov 20, 2012 12:34 pm

It is on "PlayerVampireQuest".

This is the code I am thinking of :
Effects for hiding the changeGame.DisablePlayerControls()VampireChangeFX.play(Target)VampireTransformIncreaseISMD.applyCrossFade(2.0)ObjectReference myXmarker = Target.PlaceAtMe(XmarkerMAGVampireTransform01.Play(myXmarker) ;MAGVampireTransform01 is a sound file, so I assume this makes the Xmarker play it as the sourcemyXmarker.Disable() utility.wait(2.0)imageSpaceModifier.removeCrossFade()VampireChangeFX.stop(Target)
User avatar
Richard
 
Posts: 3371
Joined: Sat Oct 13, 2007 2:50 pm

Post » Tue Nov 20, 2012 3:56 pm

Aaaah. I see. Ill give it a go.

EDIT: I can't get it to work. No matter how I write it, I just cant find a setup that compiles properly. I just don't know how to write it out. -_- Even that reference you gave me isn't very helpful.
User avatar
neen
 
Posts: 3517
Joined: Sun Nov 26, 2006 1:19 pm

Post » Tue Nov 20, 2012 7:19 pm

If you post your code, I'll take a look later tonight if I get a chance. Not sure if I'll be able to make it work, but... :)
User avatar
Lily Evans
 
Posts: 3401
Joined: Thu Aug 31, 2006 11:10 am

Post » Tue Nov 20, 2012 7:18 pm

I no longer have a code. I deleted all of the text, leaving just the properties. Also, the script is presently on an actor, if that helps.
User avatar
Anne marie
 
Posts: 3454
Joined: Tue Jul 11, 2006 1:05 pm

Post » Tue Nov 20, 2012 8:30 pm

Hmm, OK. I will have an experiment shortly, and see what I can come up with. It might work better if the Script was on a Quest, I think, but then I almost never use Actors, so... :)
User avatar
Dalley hussain
 
Posts: 3480
Joined: Sun Jun 18, 2006 2:45 am

Post » Tue Nov 20, 2012 11:55 am

Right, I've had a look and more-or-less got it working. The Script below should be copy-and-paste as a Quest Script, and it will mostly work.

The Issues :-
- You'll need to make your own Bell Sound, right now it's using "ice explosion"
- Sometimes the sound does not play correctly, I *think* this is a Skyrim issue, but I don't know much about sound files, so...
- I can't seem to get the 12 hour version working quite right. I've managed to get it to play maybe 3 times... Not sure what's up, but it might give you a starting place.

Scriptname ZTestQuestScript extends QuestGlobalVariable Property GameHour AutoGlobalVariable Property GameDay AutoActor Property PlayerRef AutoFloat BellHourFloat BellDayFloat PlayBellObjectReference MyXMarkerSound Property FXExplosionIce AutoStatic Property XMarker AutoFloat DaysRangFloat TwelveHourFloat TwelveRingFloat AllowBellRingingEvent OnInit()RegisterForSingleUpdate(1)EndEventEvent OnUpdate()RegisterForSingleUpdate(1);Put some conditions here, I.E. "If Quest Stage = 10"AllowBellRinging = 1;Put Negative Condition Here, I.E., "ElseIf QuestStage &--#62; 10";AllowBellRinging = 0;EndIfIf ( AllowBellRinging == 1 )  ;MAIN BELL RINGING PART  ;If the BellDay is 'zero', then the Player has just started using the Mod.  ;Ring the Bell, and set Bell day to the current Day  ;Set Bell Hour to the current Hour.  If ( BellDay == 0 )   BellDay = GameDay.GetValue()   BellHour = GameHour.GetValue()   myXmarker = PlayerRef.PlaceAtMe(Xmarker)   FXExplosionIce.Play(myXmarker)   myXmarker.Disable()   DaysRang = ( DaysRang + 1 )   TwelveRing = 0  ;Check if the Current Day is the same as Bell Day.  ;If it is, we don't ring the Bell  ;If it is a different day, then we need to check the time of day (GameHour)  ElseIf ( BellDay != GameDay.GetValue() )   ;If The GameHour is more than the BellHour we recorded earlier, it is later in the day   ;So we should ring the Bell   If ( BellHour &--#60;= GameHour.GetValue() )	BellDay = GameDay.GetValue()	BellHour = GameHour.GetValue()	;Tell the Game to ring the Bell in a minute	PlayBell = 1	;Update the number of times the Bell has rang	DaysRang = ( DaysRang + 1 )	PlayerRef.SetAV("Health", DaysRang)   EndIf  EndIf  If ( DaysRang &--#62;= 3 ) && ( DaysRang &--#60; 6 )   If ( TwelveHour == 0 )	TwelveHour = ( BellHour + 12 )   EndIf   If ( TwelveHour &--#62;= 24 )	TwelveHour = ( TwelveHour - 24 )   EndIf   PlayerRef.SetAV("Magicka", TwelveHour)   If ( TwelveHour &--#60;= GameHour.GetValue() )	If ( TwelveRing == 0 )	 PlayBell = 1	 TwelveRing = 1	EndIf   EndIf  EndIf  If ( DaysRang &--#62;= 6 )   ;Update Quest Here, and stop Bell Ringing Script   AllowBellRinging = 0  EndIf  ;If we told the game to ring the Bell, it will do it now  If ( PlayBell == 1 )   PlayBell = 0   ;Makes an Xmarker   ;Moves it to the Player   myXmarker = PlayerRef.PlaceAtMe(Xmarker)   ;Plays our sound file   FXExplosionIce.Play(myXmarker)   myXmarker.Disable()  EndIfEndIfEndEvent
User avatar
~Sylvia~
 
Posts: 3474
Joined: Thu Dec 28, 2006 5:19 am

Post » Tue Nov 20, 2012 12:51 pm

Ive never written a code quite THAT big before. O.o Still ,I'll look into it. Thanks.

EDIT: ok ,in the code I have noticed some things that are

&--#60;=

in there. What are they supposed to be?
User avatar
James Potter
 
Posts: 3418
Joined: Sat Jul 07, 2007 11:40 am

Post » Tue Nov 20, 2012 9:44 pm

What are they supposed to be?

That's a small flaw in the forums when you copy+paste. It's probably meant to be a < or > or similar

- Hypno
User avatar
Lyd
 
Posts: 3335
Joined: Sat Aug 26, 2006 2:56 pm

Post » Tue Nov 20, 2012 10:45 am

Ah, ok.
User avatar
Tha King o Geekz
 
Posts: 3556
Joined: Mon May 07, 2007 9:14 pm

Post » Tue Nov 20, 2012 10:01 pm

Two quick things:

There is no reason at all to poll every second the entire time the game is running for this. You're causing the game to do way too much work.

Use http://www.creationkit.com/RegisterForSingleUpdateGameTime_-_Form instead.

So if you want to ring a bell every 24 hours:

Function StartBell()  ; Call this function in a quest stage fragment on the quest stage you want the bell to start  RegisterForSingleUpdateGameTime(24)EndFunctionEvent OnUpdateGameTime()  ; Ring your bell here  ; If you want your bell to stop ringing, just don't call this function  ; If you want to use a different time, pass in a different time  ; This is at the END of the event so we don't risk piling events up, bloating saves, and breaking the user's game  RegisterForSingleUpdateGameTime(24)EndEventFunction StopBell()  ; Call this function in a stage fragment when you want the bell to stop  UnregisterForUpdateGameTime()EndFunction

That way you're only running the script when it needs, which is certainly not every second.
User avatar
Nice one
 
Posts: 3473
Joined: Thu Jun 21, 2007 5:30 am


Return to V - Skyrim