Author Topic: How to play sounds in cutscenes (gestalt scripts)  (Read 290 times)

Legacy_Hreterus

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
How to play sounds in cutscenes (gestalt scripts)
« on: September 26, 2014, 04:39:41 pm »


               
#include "in_g_cutscene"

void main()

{

 

    object oPC = GetLocalObject( GetObjectByTag("tr_thefall"),"cutsceneviewer" );

    object oNPC = GetObjectByTag("mynpc");

 

 

    float fFace = GetFacing(oPC);

 

 

    GestaltStartCutscene(oPC,"cthefall",TRUE,TRUE,TRUE,TRUE,2);

    //------------------------------------------------------------------------

 

    GestaltActionPlaySound(0.0,oPC,"bf_med_bone","");

    GestaltActionAnimate(0.0,oPC,ANIMATION_LOOPING_DEAD_BACK,12.0,1.0);

 

    GestaltCameraMove(0.0,

                      fFace + 180.0,5.0,0.0,

                      fFace + 180.0,5.0,180.0,

                      10.0,30.0,oPC);

 

    //------------------------------------------------------------------------

    GestaltStopCutscene(12.0,oPC);

}

 

I'm trying to make a cutscene with the gestalt scripts. Everything seems to work, with the exception of the GestaltActionPlaySound() command. The script instructions say that the 3rd argument is the name of a sound.

 

I tried using the name of one of the sounds you get in the Sound object making wizard, but it doesn't play. Am I supposed to be using a sound object? If so, how would I do that? 

 

Thanks in advance! 


               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
How to play sounds in cutscenes (gestalt scripts)
« Reply #1 on: September 26, 2014, 06:48:09 pm »


               

A sound object has three different "names" - the name, the tag and the blueprint resref (found under the advanced tab). Have you tried each of them in turn? Also the name is a string. You are enclosing it in quotation marks (i.e. "fred_sound"), aren't you?


 


TR



               
               

               
            

Legacy_Hreterus

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
How to play sounds in cutscenes (gestalt scripts)
« Reply #2 on: September 26, 2014, 07:23:42 pm »


               

I hadn't tried the resref name, but it doesn't seem to be working either. 


 


I did however find a script which did it in the following way:


 


object oSound = GetObjectByTag("sound_tag");


 


DelayCommand(2.0,SoundObjectPlay(oSound));


 


This does work, but it requires a sound object to be placed in the area, which permissibly has to be destroyed after usage. 


Is this the way it's usually done, or should the GestaltPlaySound() work approximately the way I tried to use it?



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
How to play sounds in cutscenes (gestalt scripts)
« Reply #3 on: September 29, 2014, 08:36:30 pm »


               

So I went and had a look at what I did in this situation when I made "Hrothgar's Resting Place". Having looked at my code it turns out that I may have run into the same problem. Before I show you my solution (by showing the whole of the very short cutscene code, I have one last question. The sound you want played does exist? The reason I ask is because, just on rare occasions, NwN "forgets" a sound. I'm not sure why but it may be something to do with custom content.


 


OK here is the code snippet I promised.



GestaltStartCutscene(oPC, "giveinscene", TRUE, TRUE, TRUE, TRUE, 2);

AssignCommand(oPC, SpeakString("(Seeker) Scabbard! Scabbard! Scabbard!"));

if((GetGender(oPC)) == GENDER_MALE)
     DelayCommand(1.0f, AssignCommand(oPC, PlaySound("as_pl_x2screamm5")));
else
     DelayCommand(1.0f, AssignCommand(oPC, PlaySound("as_pl_x2screamf3")));

GestaltActionAnimate(1.01f, oPC, ANIMATION_LOOPING_TALK_FORCEFUL, 3.5f);
DelayCommand(2.0f, AssignCommand(oPC, SpeakString("(" + sName + ") Enough already! I'll find you a scabbard!")));

GestaltStopCutscene(5.0, oPC);

The commands that you want are between the if and else statements. What it does is wait a second and then it tells the PC to play the scream sound. It does not need a sound object to be placed in the area.


 


TR



               
               

               
            

Legacy_Hreterus

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
How to play sounds in cutscenes (gestalt scripts)
« Reply #4 on: October 03, 2014, 04:18:38 pm »


               

Hey! 


 


I just now checked on this thread again.


 


I had figured out how to use sound objects, but your solution is more elegant. It works with the sound I posted above, so apparently it does exist. '<img'> 


 


Thanks for the help, much appreciated!