Is there a soundninja script out there? Mine doesn't work, though the ninja appears (in my testing, my ninja is not scripthidden). In my testing I've tried both a stock sound, and the actual sound I want (which I know works, as I have another way to play it), and my sound is turned up plenty loud enough.
Here is the script I'm using.
// ga_play_sound replacement, summons the "sound ninja" creature to play sounds since
// playsound goes at end of action queue, so an npc may not play immediately
// for more see http://nwn2.wikia.com/wiki/PlaySound
#include "ginc_param_const"
void main(string sSound, string sTarget, float fDelay)
{
object oTarget = GetTarget(sTarget, TARGET_OWNER);
location lTarget = GetLocation(oTarget);
object oSoundNinja;
oSoundNinja = CreateObject(OBJECT_TYPE_CREATURE, "sh_sound_ninja", lTarget);
if(GetIsObjectValid(oSoundNinja))
{
SendMessageToPC(GetFirstPC(), "Debug: sound ninja valid, playing sound");
AssignCommand(oSoundNinja, DelayCommand(fDelay,PlaySound(sSound)));
}
float fDestroyDelay = fDelay + 120.0; //high value for testing.
DelayCommand(fDestroyDelay, DestroyObject(oSoundNinja));
}
Soundninja script / PlaySound question
Débuté par
kamal_
, févr. 05 2013 02:14
#1
Posté 05 février 2013 - 02:14
#2
Posté 05 février 2013 - 03:29
- played around with this for a few minutes:
Sounds like it needs a delayed wrapper function for the PlaySound() line. heck i'll just post what i got here
Sounds like it needs a delayed wrapper function for the PlaySound() line. heck i'll just post what i got here
// 'kam_sound_ninja'
#include "ginc_param_const"
void kL_PlayNinja(string sSound, object oSoundNinja, float fDelay)
{
DelayCommand(fDelay, AssignCommand(oSoundNinja, PlaySound(sSound)));
fDelay += 10.f;
DelayCommand(fDelay, DestroyObject(oSoundNinja));
}
// void main(string sSound, string sTarget, float fDelay)
void main()
{
string sSound = "as_hr_x2ghost10";
string sTarget = "c_mindflayer";
float fDelay = 0.f;
object oTarget = GetTarget(sTarget, TARGET_OWNER);
location lTarget = GetLocation(oTarget);
object oSoundNinja = CreateObject(OBJECT_TYPE_CREATURE, "kl_flayer_ninja", lTarget);
if (GetIsObjectValid(oSoundNinja))
{
SendMessageToPC(GetFirstPC(), "Debug: sound ninja valid, playing sound");
DelayCommand(0.1f, kL_PlayNinja(sSound, oSoundNinja, fDelay));
}
}
#3
Posté 05 février 2013 - 04:08
The way I handle it, I just paint down a one-shot sound in the area that's set to be non-positional, so that it plays the same no matter where the PC is. Then the script just has to trigger the sound.
I think the real problem you have is that the PlaySound function actually plays something quiet, like with only a 10m max radius. Since most players have the camera 10m from their PC, with the object in question a few meters in front of the PC, it's just difficult to hear.
Maybe you could copy the sound object to a particular location?
I think the real problem you have is that the PlaySound function actually plays something quiet, like with only a 10m max radius. Since most players have the camera 10m from their PC, with the object in question a few meters in front of the PC, it's just difficult to hear.
Maybe you could copy the sound object to a particular location?
#4
Posté 05 février 2013 - 04:57
it's distinctly there with a delayed wrapper ... wasn't till that went in.
Not sure if i really like sound_ninjas though; i guess it's portable .....
Not sure if i really like sound_ninjas though; i guess it's portable .....
#5
Posté 05 février 2013 - 06:21
Here's a working script, along with some commented notes
/*
credit to kevL at http://social.biowar...800566#15801095
ga_play_sound replacement, summons the "sound ninja" creature to play sounds since playsound goes at end of action queue, so an npc may not play immediately for more see http://nwn2.wikia.com/wiki/PlaySound
Note that the sound ninja does not need to have any scripts on it at all, but "Disable AI while hidden" must not be checked.
Also note the string sSound is not the tag of a sound object, but the filename of the actual wav sound file to play
*/
#include "ginc_param_const"
void kL_PlayNinja(string sSound, object oSoundNinja, float fDelay)
{
DelayCommand(fDelay, AssignCommand(oSoundNinja, PlaySound(sSound)));
fDelay += 10.f;
DelayCommand(fDelay, DestroyObject(oSoundNinja));
}
void main(string sSound, string sTarget, float fDelay)
{
object oTarget = GetTarget(sTarget, TARGET_OWNER);
location lTarget = GetLocation(oTarget);
object oSoundNinja = CreateObject(OBJECT_TYPE_CREATURE, "sh_sound_ninja", lTarget);
if (GetIsObjectValid(oSoundNinja))
{
DelayCommand(0.1f, kL_PlayNinja(sSound, oSoundNinja, fDelay));
}
}
/*
credit to kevL at http://social.biowar...800566#15801095
ga_play_sound replacement, summons the "sound ninja" creature to play sounds since playsound goes at end of action queue, so an npc may not play immediately for more see http://nwn2.wikia.com/wiki/PlaySound
Note that the sound ninja does not need to have any scripts on it at all, but "Disable AI while hidden" must not be checked.
Also note the string sSound is not the tag of a sound object, but the filename of the actual wav sound file to play
*/
#include "ginc_param_const"
void kL_PlayNinja(string sSound, object oSoundNinja, float fDelay)
{
DelayCommand(fDelay, AssignCommand(oSoundNinja, PlaySound(sSound)));
fDelay += 10.f;
DelayCommand(fDelay, DestroyObject(oSoundNinja));
}
void main(string sSound, string sTarget, float fDelay)
{
object oTarget = GetTarget(sTarget, TARGET_OWNER);
location lTarget = GetLocation(oTarget);
object oSoundNinja = CreateObject(OBJECT_TYPE_CREATURE, "sh_sound_ninja", lTarget);
if (GetIsObjectValid(oSoundNinja))
{
DelayCommand(0.1f, kL_PlayNinja(sSound, oSoundNinja, fDelay));
}
}
#6
Posté 05 février 2013 - 06:26
I discovered one reason my sounds were not playing was because I was passing the tag of the sound object I wanted, not the name of the wav file. kevL's hardcoded example was using the name of the wav, so it played. All of which is my bad for not being sufficiently caffeinated this morning when reading the wiki for playsound.
Modifié par kamal_, 05 février 2013 - 06:29 .
#7
Posté 06 février 2013 - 04:13
BTW, kamal_, how are you handling sounds for your ambient musicians?
#8
Posté 06 février 2013 - 01:33
I have "bard song" triggers. They're standard onenter/onexit triggers for playing/stopping a sound object, except they look for the musician's tags instead of the pc. Since the musicians dont wander around all day, only go home at night and go back to their spot in the morning, this works. The triggers aren't too large, to prevent the scripts from running constantly as npcs walk around. The sound objects for these triggers are songs.Lugaid of the Red Stripes wrote...
BTW, kamal_, how are you handling sounds for your ambient musicians?
//OnEnter
void main()
{
object oEnterer = GetEnteringObject();
object oSndPlayer = GetObjectByTag(GetLocalString(OBJECT_SELF,"sound_player"));
//sound only plays while npc is in trigger
if (GetTag(oEnterer)!= GetTag(oSndPlayer)) return;
object oTarget = GetObjectByTag(GetLocalString(OBJECT_SELF,"sound_tag"));
SoundObjectPlay(oTarget);
}
//OnExit
void main()
{
object oExiter = GetExitingObject();
object oSndPlayer = GetObjectByTag(GetLocalString(OBJECT_SELF,"sound_player"));
//sound only plays while npc is in trigger
if (GetTag(oExiter)!= GetTag(oSndPlayer)) return;
object oTarget = GetObjectByTag(GetLocalString(OBJECT_SELF,"sound_tag"));
SoundObjectStop(oTarget);
}
#9
Posté 06 février 2013 - 01:54
Ok, so you just use a random list of the canned sounds from the game? Before, when I tried it, I had set the frequency variation high enough that it almost sounded like chord changes, but even then the sounds got repetitive very quickly.
In tDU I placed single-shot sound objects, and then had the ambient script do a GetNearestObjectByTag and start the objects each heartbeat.
In tDU I placed single-shot sound objects, and then had the ambient script do a GetNearestObjectByTag and start the objects each heartbeat.
#10
Posté 06 février 2013 - 02:29
I'm using freely downloadable music that I've converted into the format nwn2 uses, so the bards play appropriate songs. I'm not using any stock sound or music for the environment in Crimmor.Lugaid of the Red Stripes wrote...
Ok, so you just use a random list of the canned sounds from the game? Before, when I tried it, I had set the frequency variation high enough that it almost sounded like chord changes, but even then the sounds got repetitive very quickly.
In tDU I placed single-shot sound objects, and then had the ambient script do a GetNearestObjectByTag and start the objects each heartbeat.
Another 30 minutes or so and I'll have some ingame video uploaded showing the custom sound and bard music, as well as my commoner ai and the results of Apep's dynamic clothing equipping.
Modifié par kamal_, 06 février 2013 - 02:54 .
#11
Posté 06 février 2013 - 03:37
Here you go, a demo video showing bards playing music, commoners running their ai, etc as my test character wanders around.
www.youtube.com/watch
jamendo.com is great for custom music since all their music is creative commons licensed. last.fm has a free download section for music as well.
www.youtube.com/watch
jamendo.com is great for custom music since all their music is creative commons licensed. last.fm has a free download section for music as well.





Retour en haut






