]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/csqcmodel_hooks.qc
Merge branch 'Mario/trailparticles' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / csqcmodel_hooks.qc
index 7e36cabec6ee48cc7ae88127f15e2b81d3785c89..488289f15e60d88da20f79688b51d27f0dbe354a 100644 (file)
@@ -1,4 +1,3 @@
-#include "csqcmodel_hooks.qh"
 #include "_all.qh"
 
 #include "gibs.qh"
@@ -8,7 +7,7 @@
 
 #include "../common/animdecide.qh"
 #include "../common/csqcmodel_settings.qh"
-#include "../common/effects.qh"
+#include "../common/effects/effects.qh"
 #include "../common/teams.qh"
 #include "../common/triggers/trigger/viewloc.qh"
 
@@ -51,7 +50,7 @@ void CSQCPlayer_LOD_Apply(void)
                if(fexists(s))
                {
                        precache_model(s);
-                       setmodel(self, s);
+                       _setmodel(self, s);
                        if(self.modelindex)
                                self.lodmodelindex1 = self.modelindex;
                }
@@ -60,12 +59,12 @@ void CSQCPlayer_LOD_Apply(void)
                if(fexists(s))
                {
                        precache_model(s);
-                       setmodel(self, s);
+                       _setmodel(self, s);
                        if(self.modelindex)
                                self.lodmodelindex2 = self.modelindex;
                }
 
-               setmodel(self, modelname); // make everything normal again
+               _setmodel(self, modelname); // make everything normal again
                setsize(self, mi, ma);
        }
 
@@ -150,7 +149,7 @@ void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
                entity e;
                e = spawn();
                precache_model(cvar_defstring("_cl_playermodel"));
-               setmodel(e, cvar_defstring("_cl_playermodel"));
+               _setmodel(e, cvar_defstring("_cl_playermodel"));
                forceplayermodels_goodmodel = e.model;
                forceplayermodels_goodmodelindex = e.modelindex;
                remove(e);
@@ -181,7 +180,7 @@ void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
                // only if this failed, find it out on our own
                entity e;
                e = spawn();
-               setmodel(e, autocvar__cl_playermodel); // this is harmless, see below
+               _setmodel(e, autocvar__cl_playermodel); // this is harmless, see below
                forceplayermodels_modelisgoodmodel = fexists(e.model);
                forceplayermodels_model = e.model;
                forceplayermodels_modelindex = e.modelindex;
@@ -193,7 +192,7 @@ void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
        {
                entity e;
                e = spawn();
-               setmodel(e, autocvar_cl_forcemyplayermodel); // this is harmless, see below
+               _setmodel(e, autocvar_cl_forcemyplayermodel); // this is harmless, see below
                forceplayermodels_myisgoodmodel = fexists(e.model);
                forceplayermodels_mymodel = e.model;
                forceplayermodels_mymodelindex = e.modelindex;
@@ -495,10 +494,12 @@ const int MF_TRACER2 =  64; // orange split trail
 const int MF_TRACER3 = 128; // purple trail
 .int csqcmodel_effects;
 .int csqcmodel_modelflags;
+.int csqcmodel_traileffect;
 void CSQCModel_Effects_PreUpdate(void)
 {SELFPARAM();
        self.effects = self.csqcmodel_effects;
        self.modelflags = self.csqcmodel_modelflags;
+       self.traileffect = self.csqcmodel_traileffect;
 }
 void Reset_ArcBeam(void);
 void CSQCModel_Effects_PostUpdate(void)
@@ -510,6 +511,7 @@ void CSQCModel_Effects_PostUpdate(void)
        }
        self.csqcmodel_effects = self.effects;
        self.csqcmodel_modelflags = self.modelflags;
+       self.csqcmodel_traileffect = self.traileffect;
        self.effects = 0;
        self.modelflags = 0;
        if(self.csqcmodel_teleported)
@@ -519,13 +521,14 @@ void CSQCModel_Effects_PostUpdate(void)
 void CSQCModel_Effects_Apply(void)
 {SELFPARAM();
        int eff = self.csqcmodel_effects & ~CSQCMODEL_EF_RESPAWNGHOST;
+       int tref = self.csqcmodel_traileffect;
 
        self.renderflags &= ~(RF_DEPTHHACK | RF_ADDITIVE | RF_FULLBRIGHT | EF_NOSHADOW | RF_USEAXIS);
        self.effects = 0;
        self.traileffect = 0;
 
        if(eff & EF_BRIGHTFIELD)
-               self.traileffect = particleeffectnum(EFFECT_TR_NEXUIZPLASMA);
+               tref = particleeffectnum(EFFECT_TR_NEXUIZPLASMA);
        // ignoring EF_MUZZLEFLASH
        if(eff & EF_BRIGHTLIGHT)
                adddynamiclight(self.origin, 400, '3 3 3');
@@ -559,24 +562,26 @@ void CSQCModel_Effects_Apply(void)
                self.renderflags |= RF_DYNAMICMODELLIGHT;
        // ignoring EF_UNUSED18, EF_UNUSED19, EF_RESTARTANIM_BIT, EF_TELEPORT_BIT, EF_LOWPRECISION
        if(self.csqcmodel_modelflags & MF_ROCKET)
-               self.traileffect = particleeffectnum(EFFECT_TR_ROCKET);
+               tref = particleeffectnum(EFFECT_TR_ROCKET);
        if(self.csqcmodel_modelflags & MF_GRENADE)
-               self.traileffect = particleeffectnum(EFFECT_TR_GRENADE);
+               tref = particleeffectnum(EFFECT_TR_GRENADE);
        if(self.csqcmodel_modelflags & MF_GIB)
-               self.traileffect = particleeffectnum(EFFECT_TR_BLOOD);
+               tref = particleeffectnum(EFFECT_TR_BLOOD);
        if(self.csqcmodel_modelflags & MF_ROTATE)
        {
                self.renderflags |= RF_USEAXIS;
                makevectors(self.angles + '0 100 0' * fmod(time, 3.6));
        }
        if(self.csqcmodel_modelflags & MF_TRACER)
-               self.traileffect = particleeffectnum(EFFECT_TR_WIZSPIKE);
+               tref = particleeffectnum(EFFECT_TR_WIZSPIKE);
        if(self.csqcmodel_modelflags & MF_ZOMGIB)
-               self.traileffect = particleeffectnum(EFFECT_TR_SLIGHTBLOOD);
+               tref = particleeffectnum(EFFECT_TR_SLIGHTBLOOD);
        if(self.csqcmodel_modelflags & MF_TRACER2)
-               self.traileffect = particleeffectnum(EFFECT_TR_KNIGHTSPIKE);
+               tref = particleeffectnum(EFFECT_TR_KNIGHTSPIKE);
        if(self.csqcmodel_modelflags & MF_TRACER3)
-               self.traileffect = particleeffectnum(EFFECT_TR_VORESPIKE);
+               tref = particleeffectnum(EFFECT_TR_VORESPIKE);
+
+       self.traileffect = tref;
 
        if(self.drawmask)
                Projectile_DrawTrail(self.origin);
@@ -591,7 +596,7 @@ void CSQCModel_Effects_Apply(void)
        {
                if(!self.snd_looping)
                {
-                       sound(self, CH_TRIGGER_SINGLE, "misc/jetpack_fly.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
+                       sound(self, CH_TRIGGER_SINGLE, SND_JETPACK_FLY, VOL_BASE, autocvar_g_jetpack_attenuation);
                        self.snd_looping = CH_TRIGGER_SINGLE;
                }
        }
@@ -599,17 +604,12 @@ void CSQCModel_Effects_Apply(void)
        {
                if(self.snd_looping)
                {
-                       sound(self, self.snd_looping, "misc/null.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
+                       sound(self, self.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
                        self.snd_looping = 0;
                }
        }
 }
 
-void CSQCPlayer_Precache()
-{
-       precache_sound("misc/jetpack_fly.wav");
-}
-
 // general functions
 .int csqcmodel_predraw_run;
 .int anim_frame;