SoundDef: implement `pointparticle` key, so that particle calls can happen within sound defs (lowering networking footprint further)

This commit is contained in:
Marco Cawthorne 2023-08-07 12:53:47 -07:00
parent 83202a6174
commit 0bf9374016
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
2 changed files with 12 additions and 0 deletions

View File

@ -61,6 +61,7 @@ typedef struct
string samples; /**< Separated list of samples. */
string name; /**< Name of the soundDef. */
string distshader; /**< soundDef to play where this soundDef is not audible. */
float pointparticle;
} snd_t;
/** A sound sample of a sentences.txt word sequence. */

View File

@ -172,6 +172,9 @@ Sound_ParseField(int i, int a)
case "distshader":
g_sounds[i].distshader = argv(1);
break;
case "pointparticle":
g_sounds[i].pointparticle = particleeffectnum(argv(1));
break;
case "alerts":
dprint("\tSound set to alert enemy AI\n");
g_sounds[i].flags |= SNDFL_ALERTS;
@ -550,6 +553,14 @@ Sound_Play(entity target, int chan, string shader)
}
#endif
#ifdef CLIENT
if (g_sounds[sample].pointparticle)
pointparticles(g_sounds[sample].pointparticle, target.origin, [0,0,0], 1);
#else
if (g_sounds[sample].pointparticle)
print(sprintf("SoundDef %S is attempting to spawn a particle on the server side.\n", shader));
#endif
sound(
target,
chan,