]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/csqcmodel_hooks.qc
Merge remote-tracking branch 'origin/master' into terencehill/hud_code_restructure
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / csqcmodel_hooks.qc
index 7a642e3bde8f3064b36cb3bb5a574187a2a40fd5..109b83d166f11a8efe597f1173c76c5cda1aef59 100644 (file)
@@ -218,7 +218,7 @@ void CSQCPlayer_ForceModel_Apply(float islocalplayer)
                entity tm;
 
                for(tm = teams.sort_next; tm; tm = tm.sort_next)
-                       if(tm.team != COLOR_SPECTATOR)
+                       if(tm.team != NUM_SPECTATOR)
                                ++teams_count;
 
                if(autocvar_cl_forcemyplayercolors)
@@ -313,6 +313,10 @@ void CSQCPlayer_FallbackFrame_PostUpdate(float isnew)
        }
        self.csqcmodel_isdead = IS_DEAD_FRAME(self.frame);
 }
+void CSQCPlayer_AnimDecide_PostUpdate(float isnew)
+{
+       self.csqcmodel_isdead = !!(self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
+}
 float CSQCPlayer_FallbackFrame(float f)
 {
        if(frameduration(self.modelindex, f) > 0)
@@ -398,11 +402,8 @@ void CSQCModel_AutoTagIndex_Apply(void)
                                        }
                                        else if(self.tag_entity.isplayermodel)
                                        {
-                                               self.tag_index = gettagindex(self.tag_entity, "weapon");
-                                               if(!self.tag_index)
-                                                       self.tag_index = gettagindex(self.tag_entity, "tag_weapon");
-                                               if(!self.tag_index)
-                                                       self.tag_index = gettagindex(self.tag_entity, "bip01 r hand");
+                                               skeleton_loadinfo(self.tag_entity);
+                                               self.tag_index = self.tag_entity.bone_weapon;
                                        }
                                }
 
@@ -455,6 +456,7 @@ void CSQCModel_Effects_PostUpdate(void)
        if(self.csqcmodel_teleported)
                Projectile_ResetTrail(self.origin);
 }
+.float snd_looping;
 void CSQCModel_Effects_Apply(void)
 {
        float eff = self.csqcmodel_effects;
@@ -526,6 +528,28 @@ void CSQCModel_Effects_Apply(void)
        if(self.csqcmodel_effects & CSQCMODEL_EF_RESPAWNGHOST)
                self.renderflags |= RF_ADDITIVE;
                // also special in CSQCPlayer_GlowMod_Apply
+
+       if(self.csqcmodel_modelflags & MF_ROCKET)
+       {
+               if(!self.snd_looping)
+               {
+                       sound(self, CH_TRIGGER_SINGLE, "misc/jetpack_fly.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
+                       self.snd_looping = CH_TRIGGER_SINGLE;
+               }
+       }
+       else
+       {
+               if(self.snd_looping)
+               {
+                       sound(self, self.snd_looping, "misc/null.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
+                       self.snd_looping = 0;
+               }
+       }
+}
+
+void CSQCPlayer_Precache()
+{
+       precache_sound("misc/jetpack_fly.wav");
 }
 
 // FEATURE: auto glowmod
@@ -588,7 +612,8 @@ void CSQCModel_Hook_PreDraw(float isplayer)
                else
                {
                        // we know that frame3 and frame4 fields, used by InterpolateAnimation, are left alone - but that is all we know!
-                       float doblend = autocvar__animblend;
+                       skeleton_loadinfo(self);
+                       float doblend = (self.bone_upperbody >= 0);
                        float onground = 0;
                        if(self == csqcplayer)
                        {
@@ -602,14 +627,13 @@ void CSQCModel_Hook_PreDraw(float isplayer)
                        }
                        else
                        {
-                               traceline(self.origin + '0 0 1' * self.maxs_z, self.origin + '0 0 1' * (self.mins_z - 4), MOVE_NOMONSTERS, self);
+                               tracebox(self.origin + '0 0 1', self.mins, self.maxs, self.origin - '0 0 4', MOVE_NORMAL, self);
                                if(trace_startsolid || trace_fraction < 1)
                                        onground = 1;
                        }
-                       animdecide_init(self); // FIXME only do this on model change
+                       animdecide_init(self);
                        animdecide_setimplicitstate(self, onground);
                        animdecide_setframes(self, doblend, anim_frame, anim_frame1time, anim_frame2, anim_frame2time);
-                       print(sprintf("frames: %d %d\n", self.anim_frame, self.anim_frame2));
                        float sf = 0;
                        if(self.anim_saveframe != self.anim_frame || self.anim_saveframe1time != self.anim_frame1time)
                                sf |= CSQCMODEL_PROPERTY_FRAME;
@@ -617,7 +641,7 @@ void CSQCModel_Hook_PreDraw(float isplayer)
                                sf |= CSQCMODEL_PROPERTY_FRAME2;
                        self.anim_saveframe = self.anim_frame;
                        self.anim_saveframe1time = self.anim_frame1time;
-                       self.anim_saveframe = self.anim_frame2;
+                       self.anim_saveframe2 = self.anim_frame2;
                        self.anim_saveframe2time = self.anim_frame2time;
                        if(sf)
                        {
@@ -632,13 +656,13 @@ void CSQCModel_Hook_PreDraw(float isplayer)
                        CSQCModel_InterpolateAnimation_2To4_Do();
                        if(doblend)
                        {
-                               skeleton_from_frames(self);
+                               skeleton_from_frames(self, self.csqcmodel_isdead);
                        }
                        else
                        {
                                free_skeleton_from_frames(self);
-                               // just in case, clear these
-                               self.lerpfrac3 = 0;
+                               // just in case, clear these (we're animating in frame and frame3)
+                               self.lerpfrac = 0;
                                self.lerpfrac4 = 0;
                        }
                }
@@ -651,6 +675,8 @@ void CSQCModel_Hook_PreDraw(float isplayer)
 
 void CSQCModel_Hook_PreUpdate(float isnew, float isplayer, float islocalplayer)
 {
+       // interpolate v_angle
+       self.iflags |= IFLAG_V_ANGLE_X;
        // revert to values from server
        CSQCModel_Effects_PreUpdate();
        if(self.isplayermodel)
@@ -670,7 +696,9 @@ void CSQCModel_Hook_PostUpdate(float isnew, float isplayer, float islocalplayer)
        if(self.isplayermodel)
        {
                CSQCPlayer_ForceModel_PostUpdate();
-               if(!isplayer)
+               if(isplayer)
+                       CSQCPlayer_AnimDecide_PostUpdate(isnew);
+               else
                        CSQCPlayer_FallbackFrame_PostUpdate(isnew);
        }
        CSQCModel_Effects_PostUpdate();