Jump to content

Need help with a sound script.


Recommended Posts

Hi all, hope someone here can help, I've been banging my head against a wall over this.. I've tried by best, but my head is hurting.

 

Is there a way to have a sound play from an NPC without sound markers or triggers?

 

Quite literally, I need to make the sound come from the walking and talking NPC.. randomly and wherever in the world he happens to be.

 

Let me clarify a little..

 

What I need is for my NPC to play music at the end of a piece of dialogue (he's basically a walking jukebox). I need the sound to come from him and to be triggered via dialogue options.

 

Being me, I know there are simply ways without much scripting involved; using quest stages and scenes. But although this method works, it is not ideal because the music can be paused or interrupted. I know I can set scenes otherwise, but I believe a script that fires sound irrespective of combat or conversation would be better.

 

Any help or suggestions here would be truly appreciated.

 

 

Thanks in advance

Link to comment
Share on other sites

To answer your original question of playing a sound WITHOUT sound markers or triggers, the answer is no. The Sound property requires a Sound marker to set as the Sound property. Thus as an example NPCTalk01SoundProperty must have a NPCTalk01Sound sound marker before you can use NPCTalk01SoundProperty.Play(akSpeaker).

 

If you are running this in dialogue, what you could do is have your Quest script contain the function with the Sound property.

 

Below is a fragment to explain what you need to add in the Quest script:

 

 

Sound Property AJDSampleNPCSound01  Auto  

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Inputs: Choice to tell the sound to play (allows for moddability), and NPC for the speaker
;
;This function is designed to play a sound from a NPC upon Function call
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Function PlayNPCSound(Int Choice, Actor NPC)
	;Choice logic
	;1 = AJDSampleNPCSound01
	if (Choice == 1)
		AJDSampleNPCSound01.Play(NPC)
	EndIf	
EndFunction

 

 

 

In your Dialogue fragment block, you will want something like this:

 

 

 

;First sound
(GetOwningQuest() as AJDSampleNPCQuestDialogueScript).PlayNPCSound(1, akSpeaker)

 

 

 

Hope this helps you working around annoying DialogueFragment issues for the method you want to play the sound.

Link to comment
Share on other sites

Thanks everyone for your responses. :blush:

Mm, perhaps there's a workaround here.. well here's my crazy thought anyway..

If sound markers are absolutely required to make play() function work, then I wonder if It's possible to attach a sound marker to an NPC?

Or if there's a way to copy its properties on to an object that can be mobile and follow my npc using the placeatme method?

As stated in my original question, I know that I can use the scene method or could perhaps create a spell with zero visible effect (gonna look into that one) .. but in the interests of continually pushing myself, I really want to get my head around the script method if I can.

Scripts don't come naturally to me.

 

P.s. This is all for this chap..

 

 

 

https://www.youtube.com/watch?v=f9eAuNT6_Js

Edited by skinnytecboy
Link to comment
Share on other sites

Well think of it this way, you NEED to create a sound marker no matter what, which means you need a sound descriptor

Step by step

 

Create the audio file

Create a sound descriptor that points at the audio file in your data/sound folder

Create a sound marker that points at the Sound descriptor, we will name is 0_Mysound1

Create a script on the dialogue option you wish to have start the audio file (This is easy just type "Utility.wait(0.1)" without the quotes into the script end or beginning and hit compile)

Close the dialogue box

Re-open the dialogue box (This 'creates' the script or w/e just do it lol)

Highlight the script on the right and hit the propertys tab

Add a property and for type pick SOUND

For name pick whatever but for this example I will use "Sound1"

Select sound one and hit the "Edit Value" box and select 0_mysound1, it will be conveniently at the top

Now back out to the end papyrus fragment

Add the line "Sound1.play(akspeaker)" , without the quotes

Hit compile

Test

 

 

Also if you havent watched my videos on scripting for dummies find them in youtube.com/ddproductions83

 

Also I have almost finished the 2 quest scripts for Doone in Discworld lol, will be sending them off for your edit at some point int he future :P

Link to comment
Share on other sites

no, no placing of the sound marker is needed, it will play that sound from him via script not the markers world location

It just needs to exist in the sound descriptor and sound marker tabs in order to be called upon via the script and the game will basically turn the akspeaker IE the robot, into the sound marker for the duraton, for lack of a better way to explain it

Link to comment
Share on other sites

You do not need to place your SoundMarker in the cell. With the SoundMarker in the properties tab (although I have run into issues with the property not adding itself to the fragment, which is why I posted a Quest script method), it will automatically go to your speaking NPC when you call to play it from the speaking NPC.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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