Author Topic: Rest and play sound?  (Read 491 times)

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Rest and play sound?
« on: March 20, 2014, 09:27:20 pm »


               

Can't get this to work. The sound ALWAYS plays after the rest sequence.



void main()
{
    object oPC = GetLastPCRested();

 if (GetLastRestEventType()==REST_EVENTTYPE_REST_STARTED)
        {

            if (GetLocalInt(GetFirstPC(), "canrest") == 0)
            {

            FloatingTextStringOnCreature("You can't rest here . . .", oPC, FALSE);
            AssignCommand(oPC, ClearAllActions());
            return;
            }
       AssignCommand(oPC, PlaySound("Camping"));
       DelayCommand(0.5, FadeToBlack(oPC,FADE_SPEED_SLOW));

 }
        else if (GetLastRestEventType()==REST_EVENTTYPE_REST_CANCELLED)
        {
         // No longer used but left in for the community
         // WMFinishPlayerRest(oPC,TRUE); // removes sleep effect, etc
         FadeFromBlack(oPC,FADE_SPEED_SLOW);
        }
        else if (GetLastRestEventType()==REST_EVENTTYPE_REST_FINISHED)
        {
         // No longer used but left in for the community
         //   WMFinishPlayerRest(oPC); // removes sleep effect, etc
         FadeFromBlack(oPC,FADE_SPEED_SLOW);
        }
    }

How can I get sound to play DURING the sequence?


 


For testing purposes, just change "Camping" to some other wav related mono sound that comes with NWN.


 


FP!



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Rest and play sound?
« Reply #1 on: March 20, 2014, 09:37:09 pm »


               

In my experience you can not get sound to play on a creature with a full action queue.


 


You have a couple options that i am aware of:


  • clear the PCs action queue, then apply the sound. You will need to reestablish the rest afterwards.

  • create an invisible placeable to play the sound on. when done, destroy the placeable.


               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Rest and play sound?
« Reply #2 on: March 20, 2014, 10:10:30 pm »


               

Ah, thanks Henesua. Too much trouble for what it's worth.


 


FP!