Author Topic: zep on/off and using sounds  (Read 485 times)

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
zep on/off and using sounds
« on: October 02, 2011, 01:36:53 am »


               Hi all,

I have a question about using sounds for a placeable object that has an animation. The object has zep on/off in the onused slot and I'd like to have a sound play when the animation is activated. The script mentions stuff about sounds and variables, but I don't really understand it. Is it saying that if the placeable doesn't have a sound already attached to it, that we can have one play if we put it as a variable on the object?
If so, would the variable be CEP_L_SOUND1 for the name, the tag of the sound as the Value and the type would be String?

Any help is greatly appreciated. '<img'>
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
zep on/off and using sounds
« Reply #1 on: October 12, 2011, 10:58:23 pm »


               Uh oh. Looks like this post got lost.

There are 2 string varaibles stored on some of the CEP objects if they have a sound associated with the activate and deactiveate animations. And yes you can play whatever sound you want. It doesn't have to be the one already stored on the object. And of course you could also use the zep_onoff script for non-CEP objects that have animations and put the sound variables on them as well.

So if you store a string variable on the object (in the toolset), CEP_L_SOUND1 | string | as_an_catmeow1 , when you activate the object the "as_an_catmeow1"  sound will play.
If you store the string variable,  CEP_L_SOUND2 | string | as_an_catmeow2 , when you deactivate the object this sound would play.

These are one time sounds though since it is using the PlaySound function. If you want a sound to keep playing/looping when you activate an item you will need to place a sound object and then turn the sound on when the object is activated using the SoundObjectPlay function and off when deactivated using the SoundObjectStop function. You could easily alter the zep_onoff script to use this method as well. But this time the string variable
CEP_L_SOUND1 would be the TAG of the object that is being activated/deactivated and you wouldn't need to put in anything for CEP_L_SOUND2. That script would look like so:

void main()
{
    string sSound1 = GetLocalString(OBJECT_SELF, "CEP_L_SOUND1");
    object oSound1 = GetObjectByTag(sSound1);
    if (GetLocalInt(OBJECT_SELF,"CEP_L_AMION") == 0)
    {
        object oSelf = OBJECT_SELF;
        SoundObjectPlay(oSound1);
        DelayCommand(0.1, PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE));
        SetLocalInt(OBJECT_SELF,"CEP_L_AMION",1);
    }
    else
    {
        object oSelf = OBJECT_SELF;
        SoundObjectStop(oSound1);
        //If problems stopping the sound uncomment the line below. Know bug.
        //DelayCommand(0.1, SoundObjectStop(oSound1));
        DelayCommand(0.1, PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE));
        SetLocalInt(OBJECT_SELF,"CEP_L_AMION",0);
    }
}


Hope that made sense.
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
zep on/off and using sounds
« Reply #2 on: October 13, 2011, 12:27:54 am »


               I think that's just the template. So you would add sounds by adding a local string variable to the object which would be the resref of the sound you want to play.
I guess GoG already answered this. Sorry.
               
               

               


                     Modifié par ffbj, 12 octobre 2011 - 11:31 .
                     
                  


            

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
zep on/off and using sounds
« Reply #3 on: October 14, 2011, 07:35:49 am »


               Thank you both, sweeties *hugs* '<img'>