]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move handling of the nade orb overlay to the client side, resolves the need to networ... 1035/head
authorMario <mario.mario@y7mail.com>
Tue, 21 Jun 2022 02:17:28 +0000 (12:17 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 21 Jun 2022 02:17:28 +0000 (12:17 +1000)
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/nades/nades.qh
qcsrc/common/mutators/mutator/nades/net.qc
qcsrc/common/stats.qh

index 5ea4cb49cfb9a4d4deb6802d8bf8e82d1cad3491..749b77c7f58e1db4132f0d9086bbd19cd2c7fc05 100644 (file)
@@ -41,29 +41,6 @@ entity Nade_TrailEffect(int proj, int nade_team)
 
 #ifdef CSQC
 REGISTER_MUTATOR(cl_nades, true);
-MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay)
-{
-       // TODO: make a common orb state!
-       if (STAT(HEALING_ORB) > time)
-       {
-               M_ARGV(0, vector) = NADE_TYPE_HEAL.m_color;
-               M_ARGV(1, float) = STAT(HEALING_ORB_ALPHA);
-               return true;
-       }
-       if (STAT(ENTRAP_ORB) > time)
-       {
-               M_ARGV(0, vector) = NADE_TYPE_ENTRAP.m_color;
-               M_ARGV(1, float) = STAT(ENTRAP_ORB_ALPHA);
-               return true;
-       }
-       if (STAT(VEIL_ORB) > time)
-       {
-               M_ARGV(0, vector) = NADE_TYPE_VEIL.m_color;
-               M_ARGV(1, float) = STAT(VEIL_ORB_ALPHA);
-               return true;
-       }
-       return false;
-}
 MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile)
 {
        entity proj = M_ARGV(0, entity);
@@ -604,12 +581,7 @@ void nade_entrap_touch(entity this, entity toucher)
        if ( IS_REAL_CLIENT(toucher) || (IS_VEHICLE(toucher) && toucher.owner) )
        {
                entity show_tint = (IS_VEHICLE(toucher) && toucher.owner) ? toucher.owner : toucher;
-               STAT(ENTRAP_ORB, show_tint) = time + 0.1;
-
-               float tint_alpha = 0.75;
-               if(SAME_TEAM(toucher, this.realowner))
-                       tint_alpha = 0.45;
-               STAT(ENTRAP_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
+               show_tint.nade_entrap_time = time + 0.1;
        }
 }
 
@@ -656,13 +628,6 @@ void nade_heal_touch(entity this, entity toucher)
                }
 
        }
-
-       if ( IS_REAL_CLIENT(toucher) || (IS_VEHICLE(toucher) && toucher.owner) )
-       {
-               entity show_red = (IS_VEHICLE(toucher) && toucher.owner) ? toucher.owner : toucher;
-               STAT(HEALING_ORB, show_red) = time+0.1;
-               STAT(HEALING_ORB_ALPHA, show_red) = 0.75 * (this.ltime - time) / this.orb_lifetime;
-       }
 }
 
 void nade_heal_boom(entity this)
@@ -694,14 +659,13 @@ void nade_veil_touch(entity this, entity toucher)
                if(SAME_TEAM(toucher, this.realowner))
                {
                        tint_alpha = 0.45;
-                       if(!STAT(VEIL_ORB, show_tint))
+                       if(!show_tint.nade_veil_time)
                        {
                                toucher.nade_veil_prevalpha = toucher.alpha;
                                toucher.alpha = -1;
                        }
                }
-               STAT(VEIL_ORB, show_tint) = time + 0.1;
-               STAT(VEIL_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
+               show_tint.nade_veil_time = time + 0.1;
        }
 }
 
@@ -1343,9 +1307,9 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
                        STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
                }
 
-               if(STAT(VEIL_ORB, player) && STAT(VEIL_ORB, player) <= time)
+               if(player.nade_veil_time && player.nade_veil_time <= time)
                {
-                       STAT(VEIL_ORB, player) = 0;
+                       player.nade_veil_time = 0;
                        if(player.vehicle)
                                player.vehicle.alpha = player.vehicle.nade_veil_prevalpha;
                        else
@@ -1417,7 +1381,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPhysics_UpdateStats)
        entity player = M_ARGV(0, entity);
        // these automatically reset, no need to worry
 
-       if(STAT(ENTRAP_ORB, player) > time)
+       if(player.nade_entrap_time > time)
                STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_nades_entrap_speed;
 }
 
@@ -1425,16 +1389,16 @@ MUTATOR_HOOKFUNCTION(nades, MonsterMove)
 {
     entity mon = M_ARGV(0, entity);
 
-       if (STAT(ENTRAP_ORB, mon) > time)
+       if (mon.nade_entrap_time > time)
        {
                M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed
                M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed
        }
 
-       if (STAT(VEIL_ORB, mon) && STAT(VEIL_ORB, mon) <= time)
+       if (mon.nade_veil_time && mon.nade_veil_time <= time)
        {
                mon.alpha = mon.nade_veil_prevalpha;
-               STAT(VEIL_ORB, mon) = 0;
+               mon.nade_veil_time = 0;
        }
 }
 
@@ -1567,12 +1531,6 @@ MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
        client.pokenade_type = spectatee.pokenade_type;
        STAT(NADE_BONUS, client) = STAT(NADE_BONUS, spectatee);
        STAT(NADE_BONUS_SCORE, client) = STAT(NADE_BONUS_SCORE, spectatee);
-       STAT(HEALING_ORB, client) = STAT(HEALING_ORB, spectatee);
-       STAT(HEALING_ORB_ALPHA, client) = STAT(HEALING_ORB_ALPHA, spectatee);
-       STAT(ENTRAP_ORB, client) = STAT(ENTRAP_ORB, spectatee);
-       STAT(ENTRAP_ORB_ALPHA, client) = STAT(ENTRAP_ORB_ALPHA, spectatee);
-       STAT(VEIL_ORB, client) = STAT(VEIL_ORB, spectatee);
-       STAT(VEIL_ORB_ALPHA, client) = STAT(VEIL_ORB_ALPHA, spectatee);
 }
 
 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsPrettyString)
index 460c21571683069d92f897404d3f3d7d8335e65c..a129c826aae651cd287e956a71dda72b6ab51298 100644 (file)
@@ -144,7 +144,9 @@ REPLICATE_INIT(string, cvar_cl_pokenade_type);
 .entity nade_damage_target;
 .float toss_time;
 .float nade_show_particles;
+.float nade_veil_time;
 .float nade_veil_prevalpha;
+.float nade_entrap_time;
 
 bool orb_send(entity this, entity to, int sf);
 
index 02c5df7a3fd3db6d44296d16068b41e72ed694fe..296e7d11582db1e1bdfa04e8736e321fa4607f8a 100644 (file)
@@ -5,6 +5,8 @@
 #include "nades.qh"
 
 #ifdef CSQC
+#include <client/view.qh>
+
 .float ltime;
 void orb_draw(entity this)
 {
@@ -18,6 +20,20 @@ void orb_draw(entity this)
        this.angles = this.angles + dt * this.avelocity;
 }
 
+float orb_drawtime; // global storage of last drawn orb frame, to counter overlapping orbs
+void orb_draw2d(entity this)
+{
+       if(time <= orb_drawtime)
+               return;
+
+       if(boxesoverlap(view_origin - '1 1 1', view_origin + '1 1 1', this.absmin, this.absmax))
+       {
+               orb_drawtime = time; // prevent rendering more than one of these per frame!
+               float orb_alpha = 0.65 * (this.ltime - time) / this.orb_lifetime;
+               drawfill('0 0 0', vec2(vid_conwidth, vid_conheight), this.colormod, autocvar_hud_colorflash_alpha * orb_alpha, DRAWFLAG_ADDITIVE);
+       }
+}
+
 void orb_setup(entity e)
 {
        setmodel(e, MDL_NADE_ORB);
@@ -31,7 +47,9 @@ void orb_setup(entity e)
        e.orb_radius = e.orb_radius/model_radius*0.6;
 
        e.draw = orb_draw;
+       e.draw2d = orb_draw2d;
        IL_PUSH(g_drawables, e);
+       IL_PUSH(g_drawables_2d, e);
        SetResourceExplicit(e, RES_HEALTH, 255);
        set_movetype(e, MOVETYPE_NONE);
        e.solid = SOLID_NOT;
index 128f090c4fd9ec94ff1269b3336bda705be60c8e..812f3e92d77e128a12775507d011b616bf250a40 100644 (file)
@@ -125,19 +125,13 @@ REGISTER_STAT(MONSTERS_KILLED, int)
 REGISTER_STAT(NADE_BONUS, float)
 REGISTER_STAT(NADE_BONUS_TYPE, int)
 REGISTER_STAT(NADE_BONUS_SCORE, float)
-REGISTER_STAT(HEALING_ORB, float)
-REGISTER_STAT(HEALING_ORB_ALPHA, float)
 REGISTER_STAT(PLASMA, int)
 REGISTER_STAT(FROZEN, int)
 REGISTER_STAT(REVIVE_PROGRESS, float)
 REGISTER_STAT(ROUNDLOST, int)
 REGISTER_STAT(CAPTURE_PROGRESS, float)
-REGISTER_STAT(ENTRAP_ORB, float)
-REGISTER_STAT(ENTRAP_ORB_ALPHA, float)
 REGISTER_STAT(ITEMSTIME, int, autocvar_sv_itemstime)
 REGISTER_STAT(KILL_TIME, float)
-REGISTER_STAT(VEIL_ORB, float)
-REGISTER_STAT(VEIL_ORB_ALPHA, float)
 
 #ifdef SVQC
 float autocvar_sv_showfps = 0;