From fc48474030451e0510e76b3035b037b16278ba0c Mon Sep 17 00:00:00 2001 From: Shpoike Date: Fri, 4 Sep 2020 12:28:48 +0100 Subject: [PATCH] Give csqc access to the lightstyle+particle+makestatic+ambientsound builtins instead of depending on the server for them. --- Quake/pr_cmds.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 4 deletions(-) diff --git a/Quake/pr_cmds.c b/Quake/pr_cmds.c index 5fa301e2..86b97019 100644 --- a/Quake/pr_cmds.c +++ b/Quake/pr_cmds.c @@ -1865,6 +1865,19 @@ static void PF_cl_sound (void) S_StartSound(entnum, channel, S_PrecacheSound(sample), entity->v.origin, volume, attenuation); } +static void PF_cl_ambientsound (void) +{ + const char *samp; + float *pos; + float vol, attenuation; + + pos = G_VECTOR (OFS_PARM0); + samp = G_STRING(OFS_PARM1); + vol = G_FLOAT(OFS_PARM2); + attenuation = G_FLOAT(OFS_PARM3); + + S_StaticSound (S_PrecacheSound(samp), pos, vol, attenuation); +} static void PF_cl_precache_sound (void) { @@ -2009,6 +2022,81 @@ static void PF_cl_setmodel (void) } } +static void PF_cl_lightstyle (void) +{ + int style = G_FLOAT(OFS_PARM0); + const char *val = G_STRING(OFS_PARM1); + CL_UpdateLightstyle(style, val); +} +static void PF_cl_makestatic (void) +{ + edict_t *ent = G_EDICT(OFS_PARM0); + entity_t *stat; + int i; + + i = cl.num_statics; + if (i >= cl.max_static_entities) + { + int ec = 64; + entity_t **newstatics = realloc(cl.static_entities, sizeof(*newstatics) * (cl.max_static_entities+ec)); + entity_t *newents = Hunk_Alloc(sizeof(*newents) * ec); + if (!newstatics || !newents) + Host_Error ("Too many static entities"); + cl.static_entities = newstatics; + while (ec--) + cl.static_entities[cl.max_static_entities++] = newents++; + } + + stat = cl.static_entities[i]; + cl.num_statics++; + + SV_BuildEntityState(ent, &stat->baseline); + +// copy it to the current state + + stat->netstate = stat->baseline; + stat->eflags = stat->netstate.eflags; //spike -- annoying and probably not used anyway, but w/e + + stat->trailstate = NULL; + stat->emitstate = NULL; + stat->model = cl.model_precache[stat->baseline.modelindex]; + stat->lerpflags |= LERP_RESETANIM; //johnfitz -- lerping + stat->frame = stat->baseline.frame; + + stat->skinnum = stat->baseline.skin; + stat->effects = stat->baseline.effects; + stat->alpha = stat->baseline.alpha; //johnfitz -- alpha + + VectorCopy (ent->baseline.origin, stat->origin); + VectorCopy (ent->baseline.angles, stat->angles); + if (stat->model) + R_AddEfrags (stat); + +// throw the entity away now + ED_Free (ent); +} +static void PF_cl_particle (void) +{ + float *org = G_VECTOR(OFS_PARM0); + float *dir = G_VECTOR(OFS_PARM1); + float color = G_FLOAT(OFS_PARM2); + float count = G_FLOAT(OFS_PARM3); + + if (count == 255) + { + if (!PScript_RunParticleEffectTypeString(org, dir, 1, "te_explosion")) + count = 0; + else + count = 1024; + } + else + { + if (!PScript_RunParticleEffect(org, dir, color, count)) + count = 0; + } + R_RunParticleEffect (org, dir, color, count); +} + #define PF_NoCSQC PF_Fixme #define PF_CSQCToDo PF_Fixme builtin_t pr_csqcbuiltins[] = @@ -2048,7 +2136,7 @@ builtin_t pr_csqcbuiltins[] = PF_walkmove, // float(float yaw, float dist) walkmove PF_Fixme, // float(float yaw, float dist) walkmove PF_droptofloor, - PF_CSQCToDo,//PF_cl_lightstyle, + PF_cl_lightstyle, PF_rint, PF_floor, PF_ceil, @@ -2061,7 +2149,7 @@ builtin_t pr_csqcbuiltins[] = PF_cvar, PF_localcmd, PF_nextent, - PF_CSQCToDo,//PF_cl_particle, + PF_cl_particle, PF_changeyaw, PF_Fixme, PF_vectoangles, @@ -2085,7 +2173,7 @@ builtin_t pr_csqcbuiltins[] = SV_MoveToGoal, PF_precache_file, - PF_CSQCToDo,//PF_cl_makestatic, + PF_cl_makestatic, PF_NoCSQC,//PF_changelevel, PF_Fixme, @@ -2093,7 +2181,7 @@ builtin_t pr_csqcbuiltins[] = PF_cvar_set, PF_NoCSQC,//PF_centerprint, - PF_CSQCToDo,//PF_ambientsound, + PF_cl_ambientsound, PF_cl_precache_model, PF_cl_precache_sound,