]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/csqcmodel_hooks.qc
Merge branch 'master' into Juhu/battle-royale
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / csqcmodel_hooks.qc
index 5f421f8d28fbfb9e6928ba1fb514eefc6728cb26..4ce5c74a392ea94a0e4053b3156680fcf73c0765 100644 (file)
 .int lodmodelindex0;
 .int lodmodelindex1;
 .int lodmodelindex2;
-void CSQCPlayer_LOD_Apply(entity this, bool isplayer)
+.float loddistance1;
+.float loddistance2;
+void CSQCModel_LOD_Apply(entity this, bool isplayer)
 {
        int detailreduction = ((isplayer) ? autocvar_cl_playerdetailreduction : autocvar_cl_modeldetailreduction);
 
        // LOD model loading
-       if(this.lodmodelindex0 != this.modelindex)
+       if(this.lodmodelindex0 != this.modelindex && this.lodmodelindex1 != this.modelindex && this.lodmodelindex2 != this.modelindex)
        {
                string modelname = this.model;
                string s;
@@ -48,7 +50,7 @@ void CSQCPlayer_LOD_Apply(entity this, bool isplayer)
                        precache_model(s);
                        _setmodel(this, s);
                        if(this.modelindex)
-                               this.lodmodelindex1 = this.modelindex;
+                               this.lodmodelindex2 = this.lodmodelindex1 = this.modelindex;
                }
 
                s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
@@ -77,11 +79,13 @@ void CSQCPlayer_LOD_Apply(entity this, bool isplayer)
        else
        {
                float distance = vlen(((isplayer) ? this.origin : NearestPointOnBox(this, view_origin)) - view_origin); // TODO: perhaps it should just use NearestPointOnBox all the time, player hitbox can potentially be huge
+               float dist1 = (this.loddistance1 > 0) ? this.loddistance1 : autocvar_cl_loddistance1;
+               float dist2 = (this.loddistance2 > 0) ? this.loddistance2 : autocvar_cl_loddistance2;
                float f = (distance * current_viewzoom + 100.0) * detailreduction;
                f *= 1.0 / bound(0.01, view_quality, 1);
-               if(f > autocvar_cl_loddistance2)
+               if(f > dist2)
                        this.modelindex = this.lodmodelindex2;
-               else if(f > autocvar_cl_loddistance1)
+               else if(f > dist1)
                        this.modelindex = this.lodmodelindex1;
                else
                        this.modelindex = this.lodmodelindex0;
@@ -203,6 +207,8 @@ void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
 
        if(teamplay)
                isfriend = (cm == 1024 + 17 * myteam);
+       else if(ISGAMETYPE(BR))
+           isfriend = br_isSameSquad(this.entnum);
        else
                isfriend = islocalplayer;
 
@@ -248,14 +254,19 @@ void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
                if ((team_count == 2) && (myteam != NUM_SPECTATOR) && (fpc == 2 || fpc == 4 || fpc == 5))
                        forceplayercolors_enabled = true;
        }
+       else if (ISGAMETYPE(BR))
+       {
+               if (br_inSquad() && (fpc == 2 || fpc == 5))
+                       forceplayercolors_enabled = true;
+       }
        else
        {
-               if ((!(ISGAMETYPE(BR) && STAT(SQUADCOLORS)) && fpc == 1) || fpc == 2)
+               if (fpc == 1 || fpc == 2)
                        forceplayercolors_enabled = true;
        }
 
        // forceplayercolors too
-       if(teamplay)
+       if(teamplay || ISGAMETYPE(BR))
        {
                // own team's color is never forced
                int forcecolor_friend = 0, forcecolor_enemy = 0;
@@ -267,7 +278,7 @@ void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
                if(forceplayercolors_enabled)
                        forcecolor_enemy = 1024 + autocvar__cl_color;
 
-               if(forcecolor_enemy && !forcecolor_friend)
+               if(!ISGAMETYPE(BR) && forcecolor_enemy && !forcecolor_friend)
                {
                        // only enemy color is forced?
                        // verify it is not equal to the friend color
@@ -275,7 +286,7 @@ void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
                                forcecolor_enemy = 0;
                }
 
-               if(forcecolor_friend && !forcecolor_enemy)
+               if(!ISGAMETYPE(BR) && forcecolor_friend && !forcecolor_enemy)
                {
                        // only friend color is forced?
                        // verify it is not equal to the enemy color
@@ -288,7 +299,7 @@ void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
                                        forcecolor_friend = 0;
                }
 
-               if(cm == 1024 + 17 * myteam)
+               if((!ISGAMETYPE(BR) && (cm == 1024 + 17 * myteam)) || (ISGAMETYPE(BR) && br_isSameSquad(this.entnum)))
                {
                        if(forcecolor_friend)
                                this.colormap = forcecolor_friend;
@@ -567,6 +578,11 @@ void CSQCModel_Effects_Apply(entity this)
                boxparticles(particleeffectnum(EFFECT_EF_FLAME), this, this.absmin, this.absmax, this.velocity, this.velocity, bound(0, frametime, 0.1), 0);
                //pointparticles(EFFECT_EF_FLAME, this.origin, '0 0 0', bound(0, frametime, 0.1));
        }
+       if(eff & EF_SHOCK)
+       {
+               boxparticles(particleeffectnum(EFFECT_ARC_LIGHTNING), this, this.absmin, this.absmax, '0 0 0', '0 0 0', bound(0, frametime, 0.1), 0);
+               //pointparticles(EFFECT_ARC_LIGHTNING, this.origin, '0 0 0', bound(0, frametime, 0.1));
+       }
        if(eff & EF_STARDUST)
        {
                boxparticles(particleeffectnum(EFFECT_EF_STARDUST), this, this.absmin, this.absmax, this.velocity, this.velocity, bound(0, frametime, 0.1), 0);
@@ -669,7 +685,7 @@ void CSQCModel_Hook_PreDraw(entity this, bool isplayer)
        if((this.isplayermodel & ISPLAYER_MODEL) && this.drawmask) // this checks if it's a player MODEL!
        {
                CSQCPlayer_ModelAppearance_Apply(this, (this.isplayermodel & ISPLAYER_LOCAL));
-               CSQCPlayer_LOD_Apply(this, true);
+               CSQCModel_LOD_Apply(this, true);
 
                if(!isplayer)
                {
@@ -748,7 +764,7 @@ void CSQCModel_Hook_PreDraw(entity this, bool isplayer)
                }
        }
        else
-               CSQCPlayer_LOD_Apply(this, false);
+               CSQCModel_LOD_Apply(this, false);
 
        CSQCModel_AutoTagIndex_Apply(this);