PDA

View Full Version : cod1-1.4: "script_origin" can't playsound()?



lobolmart
3rd April 2016, 20:32
hello,

TL;DR: the common method (way of playing a sound at a location) PlaySoundAtLocation() which uses a "script_origin" entity isn't working for me, for some odd reason.
i do see usage of that in the old AWE for COD1 and also in the main pk3's (e.g. _utils::PlaySoundAtLocation()), so i must be doing something wrong here.

setup (creating a test mod):
- i copy the default "mp/gametypes/tdm.gsc" (from the bundled pk3) into a new mod folder called "test"
- i add the following two lines of code in tdm.gsc::spawnPlayer():


self iprintlnbold("spawned");
self thread test();

- the contents of test() are pretty simple:


test()
{
self endon("death");
self endon("disconnect");
self endon("spectate");

self iprintlnbold("enter thread");
wait 1.0;
self playsound("whizby");
wait 1.0;

while (1) {
org = spawn("script_origin", origin);
org playsound("whizby"); // <----------- no working
wait 1.0;
org delete();
}
}




testcase:
- i start the sever with "CoDMP.exe +set fs_game test"
- then i enter in the console:


set g_gametype "tdm"
map mp_carentan


entering a team:
- "spawned" is printed
- "enter thread" is printed
- a "whizby" sound is played only once (i.e. only the "self playsound(...)" one)

any ideas why the script entity isn't playing sound?

notes:
- my goals is pretty much to play a non-client, non-looping, sound at a specific location
- i've also tried with "script_model' and the model spawns but...no sound.
- i've tried with many different sound aliases including some bundled ones that AWE seems to use like "generic_pain_*", to no avail.

cheers

IzNoGoD
3rd April 2016, 21:35
show soundalias file.

lobolmart
3rd April 2016, 23:15
"whizby" is one of the bundled sound aliases.

defined in cod1's pak1.pk3/soundaliases/iw_sound.csv



name,sequence,file,vol_min,vol_max,pitch_min,pitch _max,dist_min,dist_max,channel,type,probability,lo op,masterslave,loadspec,subtitle
---snip---

#Bullet Whizbys,,,,,,,,,,,,,,
whizby,1,whizbys/whizby02.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,2,whizbys/whizby03.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,3,whizbys/whizby04.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,4,whizbys/whizby05.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,5,whizbys/whizby06.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,6,whizbys/whizby07.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,7,whizbys/whizby08.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,8,whizbys/whizby09.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,9,whizbys/whizby10.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,10,whizbys/whizby11.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,11,whizbys/whizby12.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,12,whizbys/whizby13.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,13,whizbys/whizby14.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,14,whizbys/whizby15.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,15,whizbys/whizby01.wav,0.85,1,0.8,1.1,100,700,auto,,,,,!airf ield
whizby,16,null.wav,0.85,1,0.8,1.1,100,700,auto,,5, ,,!airfield

whizby,1,whizbys/whizby02.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,2,whizbys/whizby03.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,3,whizbys/whizby04.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,4,whizbys/whizby05.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,5,whizbys/whizby06.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,6,whizbys/whizby07.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,7,whizbys/whizby08.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,8,whizbys/whizby09.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,9,whizbys/whizby10.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,10,whizbys/whizby11.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,11,whizbys/whizby12.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,12,whizbys/whizby13.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,13,whizbys/whizby14.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,14,whizbys/whizby15.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,15,whizbys/whizby01.wav,0.45,0.65,0.8,1.1,100,700,auto,,,,,ai rfield
whizby,16,null.wav,0.45,0.65,0.8,1.1,100,700,auto, ,16,,,airfield

kung foo man
3rd April 2016, 23:34
org = spawn("script_origin", origin);

This looks kinda problematic, does it actually convert to self.origin? Maybe just try (0,0,0) as origin or explicitly use self.origin... maybe also iprintln(self.origin), just to be sure the origin is from the spawned player.

lobolmart
3rd April 2016, 23:36
org = spawn("script_origin", origin);

This looks kinda problematic, does it actually convert to self.origin? Maybe just try (0,0,0) as origin or explicitly use self.origin... maybe also iprintln(self.origin), just to be sure the origin is from the spawned player.

my bad, that's just a copy/paste typo. doesn't work with self.origin either, as i have tested it many times already.

edit: to be clearer, it doesn't work no matter how the origin of the entity is set (via the spawn() constructor or explicitly with org.origin = self.origin)
the origin of self and the entity does match according to debug prints.

lobolmart
4th April 2016, 09:49
download link for the simple test mod: 1065

unzip it into the root folder of COD1 and start with "CoDMP.exe +set fs_game test +set g_gametype tdm +map mp_carentan"
the mod only changes the vanilla tdm.gsc; here is the diff:



diff --git a/tdm_old.gsc b/tdm.gsc
index f8b7911..cfe9e15 100644
--- a/tdm_old.gsc
+++ b/tdm.gsc
@@ -642,11 +642,34 @@ Callback_PlayerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDi
self thread respawn();
}

+test()
+{
+ self endon("death");
+ self endon("disconnect");
+ self endon("spectate");
+
+ self iprintln("*** enter thread");
+ wait 1.0;
+ self playsound("whizby");
+ wait 1.0;
+
+ while (1) {
+ org = spawn("script_origin", self.origin);
+ self iprintln("***", self.origin, org.origin);
+ org playsound("whizby");
+ wait 1.0;
+ org delete();
+ }
+}
+
spawnPlayer()
{
self notify("spawned");
self notify("end_respawn");

+ self iprintln("*** spawned");
+ self thread test();
+
resettimeout();

self.sessionteam = self.pers["team"];



i'm starting to think that either there is some sort of a flag that disables sounds for spawned entities or that the sound aliases for spawned entities demand something special (yet i've tried pretty much all sound alias flags already).

note: i also have cod:uo-1.51 and there even the first self playsound("whizby"); doesn't work.

IzNoGoD
4th April 2016, 10:37
Try upping the maxdist in your soundalias file.
As far as i can see, you're trying to play the sound for the player only? in that case, self playlocalsound(sound). This is also a nice test for your sound file. Soundalias should be copied from the quickmessages ones, as those work for sure.

lobolmart
4th April 2016, 11:39
Try upping the maxdist in your soundalias file.

from the notes in the bundled sound alias files:



,dist_min,"within this distance in inches, the sound is always full volume (default = 120)"
,dist_max,"outside this distance in inches, the sound is not started. If left blank or set to 0, the sound will play from any distance. This does not affect sound volume falloff."


^ the sounds that i try seem to match the above criteria.



As far as i can see, you're trying to play the sound for the player only? in that case, self playlocalsound(sound). This is also a nice test for your sound file.


i want to be able to create an entity at a arbitrary location on the map and make this entity play a sound which all nearby multiplayer clients can hear.
self playsound(sound); and self playlocalsound(sound); work.
it only doesn't work when the "script_origin" entity is trying to play the sound via org playsound(sound);.


Soundalias should be copied from the quickmessages ones, as those work for sure.

just tried with the bundled "american_yes_sir" from the quick messages (responses @ dialog_mp.cvs) and it doesn't work.
dist_max of that sound is 4800.

IzNoGoD
4th April 2016, 11:57
try waiting a bit after spawning and before playing the sound maybe

lobolmart
4th April 2016, 12:24
try waiting a bit after spawning and before playing the sound maybe

just tried adding more time before the loop and between the org playsound(sound); calls. same results.

IzNoGoD
4th April 2016, 12:25
try spawning a script_model instead?

lobolmart
4th April 2016, 13:13
try spawning a script_model instead?

from the first post:



- i've also tried with "script_model' and the model spawns but...no sound.

Ni3ls
4th April 2016, 13:25
Check a louder sound that works for sure, like the Bomb thicking sound of S&D

lobolmart
4th April 2016, 14:31
Check a louder sound that works for sure, like the Bomb thicking sound of S&D

tried the bomb tick sound and a number of other multiplayer sounds, but none of them play via the spawned entity.

Ni3ls
4th April 2016, 14:38
Are you sure the model is spawned? Can you set the model to something that is recognizable? Maybe you spawn the model inside the ground and then you will hear nothing

lobolmart
4th April 2016, 14:45
Are you sure the model is spawned? Can you set the model to something that is recognizable? Maybe you spawn the model inside the ground and then you will hear nothing

yes, if trying out "script_model" with setModel() instead of "script_origin", the entity model is visible (a benzine barrel) and it properly despawns on org delete().
but no sound.

Ni3ls
4th April 2016, 15:23
Is it above the ground?

lobolmart
4th April 2016, 15:32
Is it above the ground?

yes, it is.

IzNoGoD
4th April 2016, 16:33
i guess you tried org playsound("american_yes_sir"); already?

lobolmart
4th April 2016, 17:18
i guess you tried org playsound("american_yes_sir"); already?

yeah, i've tried everything that was proposed here and all sorts of random scenarios that i can think of, including many different sounds and sound alias settings.
has anyone even gotten the COD1 spawn() entities to playsound() in multiplayer?

i *do* see that in mods, yet the whole thing seems a bit suspicious.

kung foo man
5th April 2016, 01:54
Sounds retarded, but this remembers me on an old bug which I had. I figured a script_origin first started to work after settings the angles.

Try:



org = spawn("script_origin", origin);
org.angles = (0,0,0); // add this
org playsound("whizby"); // <----------- no working


I used it back then for this: https://github.com/kungfooman/cod2_std/blob/master/utils.gsc#L131

lobolmart
5th April 2016, 08:39
Sounds retarded, but this remembers me on an old bug which I had. I figured a script_origin first started to work after settings the angles.

Try:



org = spawn("script_origin", origin);
org.angles = (0,0,0); // add this
org playsound("whizby"); // <----------- no working


I used it back then for this: https://github.com/kungfooman/cod2_std/blob/master/utils.gsc#L131

i saw the use of .angles for "script_origin" somewhere when googling for this issue and i have tried it already.
also changing the sound to "bomb_tick" or the "american_yes_sir" instead of "whizby", while testing angles doesn't work.

maybe a script entity only plays sounds if it's linked to a client entity. will try again later.

lobolmart
5th April 2016, 11:31
maybe a script entity only plays sounds if it's linked to a client entity. will try again later.

nope, this doesn't help either:
org linkto(self, "tag_helmet", (0, 0, 0), (0, 0, 0));

IzNoGoD
5th April 2016, 11:51
why not just playsound on the client? You're playing the sound on his origin anyway...

lobolmart
5th April 2016, 12:00
why not just playsound on the client? You're playing the sound on his origin anyway...



i want to be able to create an entity at a arbitrary location on the map and make this entity play a sound which all nearby multiplayer clients can hear.


i.e. like the bomb in S&D.

i can hack a way to play the sound on all nearby clients, but it's going to be always at full volume and this is an ugly hack as it doesn't make much sense in the context of 3d space.

lobolmart
5th April 2016, 13:20
while messing about with the mg42's included in mp_carentan i was able to play a sound through them and then after more trial and error i was able to spawn() a script_model that plays a sound.
will report back, to complete this thread.

EDIT:
alright, so after days of testing my conclusion is that i can't get "script_origin" to play a sound in COD1-1.4 - i.e. this doesn't work:



org = spawn("script_origin", somePosition);
wait someTime1;
org playSound(someSound); // even if the playSound() is in a separate thread long time after the spawn()...
wait someTime2;
...


i've tried everything including different sounds, sounds aliases, wait timings, setting explicit .angles, .origin and so on.
maybe there is a way, but who knows.

"script_model" on the other hand does work as expected and there is no need to setModel(), set .angles, etc. something in the lines of this in your spawnPlayer() in tdm.gsc should do it:


org = spawn("script_model", somePosition);
wait someTime1;
org playSound(someSound); // make sure that someTime1 is enough!
wait someTime2;


the downside of course, is that "script_model" is a heavier struct than "script_origin".

i still can't figure out exactly why it didn't work in my while() loop, but i think it has to do with timings and concurrency. if i maintain a single "script_model" per spawned player and only update the origin of said model on demand, it can playSound() every time at a specific location, which is pretty much what i was looking for.

thanks for the replies and suggestions.