]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/nades/net.qc
Merge branch 'master' into terencehill/player_sorting
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / nades / net.qc
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;