Jump to content

Need help with a sound script.


Recommended Posts

Hi chaps, firstly, thanks so much for your help and wisdom with this. I really do appreciate it and I will of course credit all help provided.

 

Okay, so I've been doing a little testing with the above methods and also the scene method, and although they work (without sound marker in the cell) when the script or scene is called a 2nd time... I get CTD.

 

Just to expand a little more, my sound descriptor contains several sounds which I hoped would play randomly..

 

The problem with the script method is that I need to find a way of stopping any music already playing (sound descriptor) if the player opens up the same dialogue again that fires the script. Is there a way to do this?

 

I guess I could create lots of individual sound markers and disable them using aliases, but I'm planning upon having quite a fair amount of random music.

 

He is a walking jukebox after all.

Link to comment
Share on other sites

Actually you could have a cell with all the sound markers disabled, and upon asking him to play something a generic script fires to disable all markers except the one you wanted to play and instead move the new one to his location and onupdate 1 second move it to him, then unregister it for update with the generic script, the problem with that would be zoning to a new cell but realistically you could create a script to fix that.. it is just really beyond you atm if you had trouble with this one, not to sound bad about it lol, you could also just make them random idles in scenes

Use a scene to force a dialogue and he plays the music via the dialogue but then when you spoke to him it would turn it off

 

IDK if anyone has a easier idea on this one

Link to comment
Share on other sites

Sound.Play() has a return value of type Integer. This integer is the unique ID of the current playback, meaning you shouldn't require physical copies of the marker. Below is an example of how you could integrate this (with commented assumptions on quest structure, and one tiny potential bug concerning the global, which probably could be corrected by registering for a single update with the seconds of the current sounds you are playing calling an update event to reset the global, but I haven't tested it):

 

The Quest Script:

 

 

Scriptname SoundScriptExample extends Quest

;These are examples of properties I imagine for this situation
;The global is used to keep track and see if you are currently playing one of your sounds
;It will never reset back to 0 in its current form, so you might have to rethink that part
Int Property CurrentPlayingSoundID Auto Hidden
Global Property YouAreCurrentlyPlayingASound Auto
Sound Property YourSoundMarkerName Auto
Sound Property YourSecondSoundMarkerSoundName Auto

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;The purpose of this function is to cease the current playback and play the sound again
;In this example, I am utilizing two different markers to show choice logic
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Function CeaseCurrentPlaybackAndPlaySoundAgain(Actor SpeakingNPC, Int SoundChoice)
	;Release your current Sound playback
	StopInstance(CurrentPlayingSoundID)
	
	;Call your normal sound function
	PlaySoundFromChoice(SpeakingNPC, SoundChoice)
EndFunction

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;The purpose of this function is to play a sound based on an input, storing the play id
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Function PlaySoundFromChoice(Actor SpeakingNPC, Int SoundChoice)
	;Choice logic
	;0 = YourSoundMarkerName
	;1 = YourSecondSoundMarkerSoundName
	;Change your CurrentPlayingSoundID
	;Choice Logic
	;0 = YourSoundMarkerName
	;1 = YourSecondSoundMarkerSoundName
	If Choice == 0
		CurrentPlayingSoundID = YourSoundMarkerName.Play(SpeakingNPC)
	Else ;Choice 1
		CurrentPlayingSoundID = YourSecondSoundMarkerSoundName.Play(SpeakingNPC)
	EndIf	
	
	YouAreCurrentlyPlayingASound.SetValue(1)
EndFunction

;Garbage function for kmy initialization
Function Garbage()
	;Indeed
EndFunction

 

 

 

The Dialogue Fragments:

 

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;This portion is for your first Dialogue Fragment
;I decided to have a global keep track to see if a sound is currently playing so I could use that a dialogue condition
;There is probably a more elegant way to tackle this.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(GetOwningQuest as SoundScriptExample).PlaySoundFromChoice(akSpeaker, 0)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;This portion will be used within the version of the Dialogue with the global check
;Again, there is probably a more elegant and efficient way to integrate this
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(GetOwningQuest as SoundScriptExample).CeaseCurrentPlaybackAndPlaySoundAgain(akSpeaker, 0)

 

 

 

kmyQuest initialization:

 

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;This portion will be used within your quest stage in the kmy block
;Set the kmyQuest to SoundScriptExample, or whatever your script is named within the Quest
;It might give you an initial error, I know it does in my CK, just close the quest and reopen to see if it properly compiles
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
kmyquest.Garbage()

 

 

Edited by Arron Dominion
Link to comment
Share on other sites

As an update for the CTD issue if anyone is curious or runs into Sound Descriptor related CTD in the future, there is a limit on how big a sound file can be. Roughly 3 min 10 sec for the length. After talking to one of my programming friends, the thought is that this is most likely due to the console's memory limit, and the handling for sound on the console being carried over to the PC version.

Link to comment
Share on other sites

  • 2 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...