]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/csqcmodel_hooks.qc
Group effects in a folder
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / csqcmodel_hooks.qc
index dde4461821ee9feef7e501d25961931082a79028..70e2c99fea001e291aca7f71427e0176a055198b 100644 (file)
@@ -1,26 +1,26 @@
-#if defined(CSQC)
-       #include "gibs.qh"
-       #include "miscfunctions.qh"
-       #include "player_skeleton.qh"
-       #include "sortlist.qh"
+#include "csqcmodel_hooks.qh"
+#include "_all.qh"
 
-       #include "../client/weapons/projectile.qh"
+#include "gibs.qh"
+#include "player_skeleton.qh"
 
-       #include "../common/animdecide.qh"
-       #include "../common/csqcmodel_settings.qh"
+#include "weapons/projectile.qh"
 
-       #include "../csqcmodellib/cl_model.qh"
-       #include "../csqcmodellib/cl_player.qh"
-       #include "../csqcmodellib/interpolate.qh"
+#include "../common/animdecide.qh"
+#include "../common/csqcmodel_settings.qh"
+#include "../common/effects/effects.qh"
+#include "../common/teams.qh"
+#include "../common/triggers/trigger/viewloc.qh"
 
-       #include "../warpzonelib/mathlib.qh"
+#include "mutators/events.qh"
+
+#include "../csqcmodellib/cl_model.qh"
+#include "../csqcmodellib/cl_player.qh"
+#include "../csqcmodellib/interpolate.qh"
 
-       .float death_time;
-       .int modelflags;
-#elif defined(MENUQC)
-#elif defined(SVQC)
-#endif
 
+.float death_time;
+.int modelflags;
 
 void CSQCModel_Hook_PreDraw(bool isplayer);
 
@@ -31,7 +31,7 @@ void CSQCModel_Hook_PreDraw(bool isplayer);
 .int lodmodelindex1;
 .int lodmodelindex2;
 void CSQCPlayer_LOD_Apply(void)
-{
+{SELFPARAM();
        // LOD model loading
        if(self.lodmodelindex0 != self.modelindex)
        {
@@ -120,14 +120,14 @@ int forceplayermodels_goodmodelindex;
 .vector old_glowmod;
 
 void CSQCPlayer_ModelAppearance_PreUpdate(void)
-{
+{SELFPARAM();
        self.model = self.forceplayermodels_savemodel;
        self.modelindex = self.forceplayermodels_savemodelindex;
        self.skin = self.forceplayermodels_saveskin;
        self.colormap = self.forceplayermodels_savecolormap;
 }
 void CSQCPlayer_ModelAppearance_PostUpdate(void)
-{
+{SELFPARAM();
        self.forceplayermodels_savemodel = self.model;
        self.forceplayermodels_savemodelindex = self.modelindex;
        self.forceplayermodels_saveskin = self.skin;
@@ -138,11 +138,11 @@ void CSQCPlayer_ModelAppearance_PostUpdate(void)
                self.forceplayermodels_isgoodmodel = fexists(self.forceplayermodels_savemodel);
                self.forceplayermodels_isgoodmodel_mdl = self.forceplayermodels_savemodel;
                if(!self.forceplayermodels_isgoodmodel)
-                       printf("Warning: missing model %s has been used\n", self.forceplayermodels_savemodel);
+                       LOG_INFOF("Warning: missing model %s has been used\n", self.forceplayermodels_savemodel);
        }
 }
 void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
-{
+{SELFPARAM();
        // FORCEMODEL
        // which one is ALWAYS good?
        if (!forceplayermodels_goodmodel)
@@ -325,7 +325,7 @@ void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
 
 #define IS_DEAD_FRAME(f) ((f) == 0 || (f) == 1)
 void CSQCPlayer_FallbackFrame_PreUpdate(void)
-{
+{SELFPARAM();
        self.frame = self.csqcmodel_saveframe;
        self.frame2 = self.csqcmodel_saveframe2;
 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
@@ -334,7 +334,7 @@ void CSQCPlayer_FallbackFrame_PreUpdate(void)
 #endif
 }
 void CSQCPlayer_FallbackFrame_PostUpdate(bool isnew)
-{
+{SELFPARAM();
        self.csqcmodel_saveframe = self.frame;
        self.csqcmodel_saveframe2 = self.frame2;
 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
@@ -360,11 +360,11 @@ void CSQCPlayer_FallbackFrame_PostUpdate(bool isnew)
        self.csqcmodel_isdead = IS_DEAD_FRAME(self.frame);
 }
 void CSQCPlayer_AnimDecide_PostUpdate(bool isnew)
-{
+{SELFPARAM();
        self.csqcmodel_isdead = !!(self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
 }
 int CSQCPlayer_FallbackFrame(int f)
-{
+{SELFPARAM();
        if(frameduration(self.modelindex, f) > 0)
                return f; // goooooood
        if(frameduration(self.modelindex, 1) <= 0)
@@ -380,11 +380,11 @@ int CSQCPlayer_FallbackFrame(int f)
                case 29: return 4; // anim_duckwalkbackright -> anim_duckwalk
                case 30: return 4; // anim_duckwalkbackleft -> anim_duckwalk
        }
-       printf("Frame %d missing in model %s, and we have no fallback - FAIL!\n", f, self.model);
+       LOG_INFOF("Frame %d missing in model %s, and we have no fallback - FAIL!\n", f, self.model);
        return f;
 }
 void CSQCPlayer_FallbackFrame_Apply(void)
-{
+{SELFPARAM();
        self.frame = CSQCPlayer_FallbackFrame(self.frame);
        self.frame2 = CSQCPlayer_FallbackFrame(self.frame2);
 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
@@ -398,10 +398,18 @@ void CSQCPlayer_FallbackFrame_Apply(void)
 .int tag_entity_lastmodelindex;
 .int tag_index;
 void CSQCModel_AutoTagIndex_Apply(void)
-{
+{SELFPARAM();
        if(self.tag_entity && wasfreed(self.tag_entity))
                self.tag_entity = world;
 
+       if(self.viewloc && wasfreed(self.viewloc))
+               self.viewloc = world;
+
+       if(self.viewloc.entnum != self.tag_networkviewloc)
+               self.viewloc = findfloat(world, entnum, self.tag_networkviewloc);
+
+       MUTATOR_CALLHOOK(TagIndex_Update, self);
+
        if(self.tag_networkentity)
        {
                // we are ATTACHED!
@@ -415,10 +423,7 @@ void CSQCModel_AutoTagIndex_Apply(void)
                // recursive predraw call to fix issues with forcemodels and LOD if bone indexes mismatch
                if(self.tag_entity.classname == "csqcmodel")
                {
-                       entity oldself = self;
-                       self = self.tag_entity;
-                       CSQCModel_Hook_PreDraw((self.entnum >= 1 && self.entnum <= maxclients));
-                       self = oldself;
+                       WITH(entity, self, self.tag_entity, CSQCModel_Hook_PreDraw((self.entnum >= 1 && self.entnum <= maxclients)));
                }
 
                if(self.tag_entity.modelindex != self.tag_entity_lastmodelindex)
@@ -431,9 +436,9 @@ void CSQCModel_AutoTagIndex_Apply(void)
                        if(self.tag_entity)
                        {
                                // the best part is: IT EXISTS
-                               if(substring(self.model, 0, 17) == "models/weapons/v_")
+                               if(substring(self.model, 0, 14) == "models/weapons")
                                {
-                                       if(substring(self.tag_entity.model, 0, 17) == "models/weapons/h_")
+                                       if(substring(self.tag_entity.model, 0, 14) == "models/weapons")
                                        {
                                                self.tag_index = gettagindex(self.tag_entity, "weapon");
                                                if(!self.tag_index)
@@ -443,7 +448,7 @@ void CSQCModel_AutoTagIndex_Apply(void)
                                                        // we need to prevent this from 'appening
                                                        self.tag_entity = world;
                                                        self.drawmask = 0;
-                                                       dprint("h_ model lacks weapon attachment, but v_ model is attached to it\n");
+                                                       LOG_TRACE("h_ model lacks weapon attachment, but v_ model is attached to it\n");
                                                }
                                        }
                                        else if(self.tag_entity.isplayermodel)
@@ -453,12 +458,14 @@ void CSQCModel_AutoTagIndex_Apply(void)
                                        }
                                }
 
-                               if(substring(self.tag_entity.model, 0, 17) == "models/weapons/v_")
+                               if(substring(self.tag_entity.model, 0, 14) == "models/weapons")
                                {
                                        self.tag_index = gettagindex(self.tag_entity, "shot");
                                        if(!self.tag_index)
                                                self.tag_index = gettagindex(self.tag_entity, "tag_shot");
                                }
+
+                               MUTATOR_CALLHOOK(TagIndex_Apply, self);
                        }
                        else
                        {
@@ -489,13 +496,13 @@ const int MF_TRACER3 = 128; // purple trail
 .int csqcmodel_effects;
 .int csqcmodel_modelflags;
 void CSQCModel_Effects_PreUpdate(void)
-{
+{SELFPARAM();
        self.effects = self.csqcmodel_effects;
        self.modelflags = self.csqcmodel_modelflags;
 }
 void Reset_ArcBeam(void);
 void CSQCModel_Effects_PostUpdate(void)
-{
+{SELFPARAM();
        if (self == csqcplayer) {
                if (self.csqcmodel_teleported) {
                        Reset_ArcBeam();
@@ -510,7 +517,7 @@ void CSQCModel_Effects_PostUpdate(void)
 }
 .int snd_looping;
 void CSQCModel_Effects_Apply(void)
-{
+{SELFPARAM();
        int eff = self.csqcmodel_effects & ~CSQCMODEL_EF_RESPAWNGHOST;
 
        self.renderflags &= ~(RF_DEPTHHACK | RF_ADDITIVE | RF_FULLBRIGHT | EF_NOSHADOW | RF_USEAXIS);
@@ -518,7 +525,7 @@ void CSQCModel_Effects_Apply(void)
        self.traileffect = 0;
 
        if(eff & EF_BRIGHTFIELD)
-               self.traileffect = particleeffectnum("TR_NEXUIZPLASMA");
+               self.traileffect = particleeffectnum(EFFECT_TR_NEXUIZPLASMA);
        // ignoring EF_MUZZLEFLASH
        if(eff & EF_BRIGHTLIGHT)
                adddynamiclight(self.origin, 400, '3 3 3');
@@ -536,9 +543,9 @@ void CSQCModel_Effects_Apply(void)
        if(eff & EF_FULLBRIGHT)
                self.renderflags |= RF_FULLBRIGHT;
        if(eff & EF_FLAME)
-               pointparticles(particleeffectnum("EF_FLAME"), self.origin, '0 0 0', bound(0, frametime, 0.1));
+               pointparticles(particleeffectnum(EFFECT_EF_FLAME), self.origin, '0 0 0', bound(0, frametime, 0.1));
        if(eff & EF_STARDUST)
-               pointparticles(particleeffectnum("EF_STARDUST"), self.origin, '0 0 0', bound(0, frametime, 0.1));
+               pointparticles(particleeffectnum(EFFECT_EF_STARDUST), self.origin, '0 0 0', bound(0, frametime, 0.1));
        if(eff & EF_NOSHADOW)
                self.renderflags |= RF_NOSHADOW;
        if(eff & EF_NODEPTHTEST)
@@ -552,24 +559,24 @@ 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("TR_ROCKET");
+               self.traileffect = particleeffectnum(EFFECT_TR_ROCKET);
        if(self.csqcmodel_modelflags & MF_GRENADE)
-               self.traileffect = particleeffectnum("TR_GRENADE");
+               self.traileffect = particleeffectnum(EFFECT_TR_GRENADE);
        if(self.csqcmodel_modelflags & MF_GIB)
-               self.traileffect = particleeffectnum("TR_BLOOD");
+               self.traileffect = 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("TR_WIZSPIKE");
+               self.traileffect = particleeffectnum(EFFECT_TR_WIZSPIKE);
        if(self.csqcmodel_modelflags & MF_ZOMGIB)
-               self.traileffect = particleeffectnum("TR_SLIGHTBLOOD");
+               self.traileffect = particleeffectnum(EFFECT_TR_SLIGHTBLOOD);
        if(self.csqcmodel_modelflags & MF_TRACER2)
-               self.traileffect = particleeffectnum("TR_KNIGHTSPIKE");
+               self.traileffect = particleeffectnum(EFFECT_TR_KNIGHTSPIKE);
        if(self.csqcmodel_modelflags & MF_TRACER3)
-               self.traileffect = particleeffectnum("TR_VORESPIKE");
+               self.traileffect = particleeffectnum(EFFECT_TR_VORESPIKE);
 
        if(self.drawmask)
                Projectile_DrawTrail(self.origin);
@@ -615,7 +622,7 @@ void CSQCPlayer_Precache()
 .int anim_saveframe2time;
 .int anim_prev_pmove_flags;
 void CSQCModel_Hook_PreDraw(bool isplayer)
-{
+{SELFPARAM();
        if(self.csqcmodel_predraw_run == framecount)
                return;
        self.csqcmodel_predraw_run = framecount;
@@ -632,6 +639,7 @@ void CSQCModel_Hook_PreDraw(bool isplayer)
        {
                CSQCPlayer_ModelAppearance_Apply(self.entnum == player_localnum + 1);
                CSQCPlayer_LOD_Apply();
+
                if(!isplayer)
                {
                        skeleton_loadinfo(self);
@@ -657,10 +665,10 @@ void CSQCModel_Hook_PreDraw(bool isplayer)
                        bool onground = 0;
                        if(self == csqcplayer)
                        {
-                               if(self.pmove_flags & PMF_ONGROUND)
+                               if(self.flags & FL_ONGROUND)
                                        onground = 1;
-                               self.anim_prev_pmove_flags = self.pmove_flags;
-                               if(self.pmove_flags & PMF_DUCKED)
+                               self.anim_prev_pmove_flags = self.flags;
+                               if(self.flags & FL_DUCKED)
                                        animdecide_setstate(self, self.anim_state | ANIMSTATE_DUCK, false);
                                else if(self.anim_state & ANIMSTATE_DUCK)
                                        animdecide_setstate(self, self.anim_state - ANIMSTATE_DUCK, false);
@@ -713,7 +721,7 @@ void CSQCModel_Hook_PreDraw(bool isplayer)
 }
 
 void CSQCModel_Hook_PreUpdate(bool isnew, bool isplayer, bool islocalplayer)
-{
+{SELFPARAM();
        // interpolate v_angle
        self.iflags |= IFLAG_V_ANGLE_X;
        // revert to values from server
@@ -727,9 +735,9 @@ void CSQCModel_Hook_PreUpdate(bool isnew, bool isplayer, bool islocalplayer)
 }
 
 void CSQCModel_Hook_PostUpdate(bool isnew, bool isplayer, bool islocalplayer)
-{
+{SELFPARAM();
        // is it a player model? (shared state)
-       self.isplayermodel = (substring(self.model, 0, 14) == "models/player/" || substring(self.model, 0, 17) == "models/ok_player/");
+       self.isplayermodel = (substring(self.model, 0, 14) == "models/player/" || substring(self.model, 0, 17) == "models/ok_player/" || (substring(self.model, 0, 16) == "models/monsters/" && (self.entnum >= 1 && self.entnum <= maxclients)));
 
        // save values set by server
        if(self.isplayermodel)