Aller au contenu

Photo

How to play sounds in cutscenes (gestalt scripts)


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
Hreterus

Hreterus
  • Members
  • 55 messages
#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! 


#2
Tarot Redhand

Tarot Redhand
  • Members
  • 2 694 messages

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



#3
Hreterus

Hreterus
  • Members
  • 55 messages

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?



#4
Tarot Redhand

Tarot Redhand
  • Members
  • 2 694 messages

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



#5
Hreterus

Hreterus
  • Members
  • 55 messages

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. :) 

 

Thanks for the help, much appreciated!