Is there a way to just easily one-off play a sound?
I never could figure out what the PlaySounds wanted me to pass as a parameter and they never work.
Sure I created a sound object and set it to play or not for my previous works but that seems bulky and ridiculous
when I just want a single line of code to play a reasonably loud 1 shot sound.
PlaySound ... or does it?
Débuté par
Eguintir Eligard
, août 01 2013 04:02
#1
Posté 01 août 2013 - 04:02
#2
Posté 01 août 2013 - 04:20
#3
Posté 01 août 2013 - 04:29
not really... playing a sound from a placeable thats about to die. Not sure what the string value should be etc, and no actions would be queued anyway
#4
Posté 01 août 2013 - 04:47
This is my code btw
It seems to work fine in conversation and I basically copied their script except for my death part
if (iSonicDmg >= 1) // die if sonic damage dealt
{
DBT("...1 or more sonic damage dealt, destroying...");
AssignCommand(OBJECT_SELF, PlaySound("as_na_rockfalg1", TRUE) );
DelayCommand(1.0f, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDie, OBJECT_SELF) );
}
It seems to work fine in conversation and I basically copied their script except for my death part
#6
Posté 01 août 2013 - 10:51
I thought PlaySound only worked on creatures. Hence the occasional need for a 'sound ninja'.
If the sound is occuring while the player isn't doing something else (like moving or being in combat), you can ClearAllActions() on the PC and assign the PlaySound to them. That way you're guaranteed to hear it (in a single player game, at least)
PlaySound is added to a creature's action queue, which means it can be overridden by more aggressive actions, or potentially delayed until you've finished your current action. If you assign PlaySound to a player on the move, for instance, it won't play until the player reaches their destination and stops.
If the sound is occuring while the player isn't doing something else (like moving or being in combat), you can ClearAllActions() on the PC and assign the PlaySound to them. That way you're guaranteed to hear it (in a single player game, at least)
PlaySound is added to a creature's action queue, which means it can be overridden by more aggressive actions, or potentially delayed until you've finished your current action. If you assign PlaySound to a player on the move, for instance, it won't play until the player reaches their destination and stops.
#7
Posté 02 août 2013 - 12:49
So would you say my method of throwing down a sound object that plays once only and sending a line of code to play it is no less bulky than these other methods?
#8
Posté 02 août 2013 - 01:30
If it was for a sound you expected to hear multiple times at various places, then something more complex might be warranted. A sound that plays only once, and only at a specific location, might as well be a sound object.
Another option would be to create a custom VFX that incorporates dust, flying stone debris, and an appropriate sound, then just play the effect when destroying the placeable.
Another option would be to create a custom VFX that incorporates dust, flying stone debris, and an appropriate sound, then just play the effect when destroying the placeable.
#9
Posté 02 août 2013 - 03:21
I have taken to creating SEFs containing nothing but the sound I want to play, and spawning them as temporary effects in the location, because of inconsistent results with PlaySound.
#10
Posté 03 août 2013 - 11:33
make the PC play the sound? strange i know - but a much shorter trip - and even in 3d sound it wouldnt be obvious.
Tchos' idea is work intensive but not bulky to code for.
Edit: sorry Dann you already said this :innocent:
Tchos' idea is work intensive but not bulky to code for.
Edit: sorry Dann you already said this :innocent:
Modifié par Morbane, 03 août 2013 - 11:36 .
#11
Posté 04 août 2013 - 12:19
Would this help?
credit to kevL:
kamalpoe.blogspot.com/2013/02/summoning-sound-ninja-playsound-fix.html
credit to kevL:
kamalpoe.blogspot.com/2013/02/summoning-sound-ninja-playsound-fix.html
#12
Posté 04 août 2013 - 01:43
i guess (it's been a while) you'd need a creature-resref "sh_sound_ninja.Utc" ready to go, w/ ScriptHidden checked and Disable AI unchecked
?
?
#13
Posté 04 août 2013 - 10:47
It shouldn't need to be running it's AI. In fact, you'd be better off stripping the ninja blueprint of all it's usual scripts so that it's unlikely to ever have anything in it's action queue. Much like a faction pig.
#14
Posté 10 août 2013 - 10:33
Hi E.E.
I have also had issues playing sounds using PlaySound, however, I found there is one quite important thing to note:-
The object playing the sound must remain "alive" for a small amount of time to allow the sound to start properly without it being terminated.
So, it is possible to have placeables play a sound and I have this occur using code like PlaySound(sSound, TRUE); in many scripts. However, if this same script tries to fire as the object is being destroyed, then the sound does not play, and it is better to have another object that remains alive to play the sound instead.
When is this script of yours trying to play the sound?
Lance.
EDIT: I just noticed that you say that your script is for a placeable about to "die", so this is your problem then. I have written some "Hardness" checking scripts for placeables that intercept the damage taken to determine how much damage and if the placeable should be destroyed or not. By taking control of the moment of destruction, I can play the sound prior to the placable being destroyed. You could do a similar thing if you like, or I can send you my scripts for you to look at and take what you need.
I have also had issues playing sounds using PlaySound, however, I found there is one quite important thing to note:-
The object playing the sound must remain "alive" for a small amount of time to allow the sound to start properly without it being terminated.
So, it is possible to have placeables play a sound and I have this occur using code like PlaySound(sSound, TRUE); in many scripts. However, if this same script tries to fire as the object is being destroyed, then the sound does not play, and it is better to have another object that remains alive to play the sound instead.
When is this script of yours trying to play the sound?
Lance.
EDIT: I just noticed that you say that your script is for a placeable about to "die", so this is your problem then. I have written some "Hardness" checking scripts for placeables that intercept the damage taken to determine how much damage and if the placeable should be destroyed or not. By taking control of the moment of destruction, I can play the sound prior to the placable being destroyed. You could do a similar thing if you like, or I can send you my scripts for you to look at and take what you need.
Modifié par Lance Botelle, 10 août 2013 - 10:38 .





Retour en haut






