]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/nades/net.qc
Merge branch 'bones_was_here/q1bsp_hitbox' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / nades / net.qc
index e2659c7af85307fb2e30529e1318b83e35a12746..296e7d11582db1e1bdfa04e8736e321fa4607f8a 100644 (file)
@@ -1,8 +1,12 @@
-#include "nades.qh"
+#include "net.qh"
+
+#ifdef GAMEQC
 
-#ifdef IMPLEMENTATION
+#include "nades.qh"
 
 #ifdef CSQC
+#include <client/view.qh>
+
 .float ltime;
 void orb_draw(entity this)
 {
@@ -16,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);
@@ -29,8 +47,10 @@ 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);
-       e.health = 255;
+       IL_PUSH(g_drawables_2d, e);
+       SetResourceExplicit(e, RES_HEALTH, 255);
        set_movetype(e, MOVETYPE_NONE);
        e.solid = SOLID_NOT;
        e.drawmask = MASK_NORMAL;
@@ -48,13 +68,9 @@ NET_HANDLE(Nade_Orb, bool isNew)
        Net_Accept(Nade_Orb);
        int sf = ReadByte();
        if (sf & 1) {
-               this.origin_x = ReadCoord();
-               this.origin_y = ReadCoord();
-               this.origin_z = ReadCoord();
+               this.origin = ReadVector();
                setorigin(this, this.origin);
-               this.colormod_x = ReadCoord();
-               this.colormod_y = ReadCoord();
-               this.colormod_z = ReadCoord();
+               this.colormod = ReadVector();
                this.orb_lifetime = ReadByte();
                this.orb_radius = ReadShort();
                this.ltime = time + ReadByte()/10.0;
@@ -72,13 +88,9 @@ bool orb_send(entity this, entity to, int sf)
        WriteHeader(channel, Nade_Orb);
        WriteByte(channel, sf);
        if (sf & 1) {
-               WriteCoord(channel, this.origin.x);
-               WriteCoord(channel, this.origin.y);
-               WriteCoord(channel, this.origin.z);
+               WriteVector(channel, this.origin);
 
-               WriteCoord(channel, this.colormod.x);
-               WriteCoord(channel, this.colormod.y);
-               WriteCoord(channel, this.colormod.z);
+               WriteVector(channel, this.colormod);
 
                WriteByte(channel, this.orb_lifetime);
                //WriteByte(MSG_ENTITY, this.ltime - time + 1);