]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use a modified copy of the nade orb effect for electro orbs Mario/electro_combo_qc_effect
authorMario <mario.mario@y7mail.com>
Sat, 2 Nov 2024 02:01:14 +0000 (12:01 +1000)
committerMario <mario.mario@y7mail.com>
Sat, 2 Nov 2024 02:01:14 +0000 (12:01 +1000)
qcsrc/common/weapons/weapon/electro.qc

index 594c39289ecebae8cb92468f29e5cb9e14b28aec..a77f2a1597a899afe463183a6378fd9df1e4d37c 100644 (file)
@@ -1,5 +1,75 @@
 #include "electro.qh"
 
+#ifdef GAMEQC
+
+#ifdef CSQC
+
+.float ltime;
+void electro_orb_draw(entity this)
+{
+       float dt = time - this.move_time;
+       this.move_time = time;
+       if(dt <= 0)
+               return;
+
+       this.alpha = bound(0, (this.ltime - time) * 4, 1);
+       this.scale = (WEP_CVAR(WEP_ELECTRO, combo_radius) * 0.05) * this.alpha;
+       this.angles = this.angles + dt * this.avelocity;
+}
+
+void electro_orb_setup(entity e)
+{
+       setmodel(e, MDL_PROJECTILE_ELECTRO);
+       setsize(e, '-4 -4 -4', '4 4 4');
+
+       setorigin(e, e.origin);
+
+       e.draw = electro_orb_draw;
+       IL_PUSH(g_drawables, e);
+       SetResourceExplicit(e, RES_HEALTH, 255);
+       set_movetype(e, MOVETYPE_NONE);
+       e.solid = SOLID_NOT;
+       e.avelocity = '7 0 11';
+       e.drawmask = MASK_NORMAL;
+}
+#endif
+
+REGISTER_NET_LINKED(Electro_Orb)
+
+#ifdef CSQC
+NET_HANDLE(Electro_Orb, bool isNew)
+{
+       Net_Accept(Electro_Orb);
+       int sf = ReadByte();
+       if (sf & 1) {
+               this.origin = ReadVector();
+               setorigin(this, this.origin);
+               this.ltime = time + ReadByte()/10.0;
+               // this.ltime = time + this.orb_lifetime;
+               electro_orb_setup(this);
+       }
+       return true;
+}
+#endif
+
+#ifdef SVQC
+bool electro_orb_send(entity this, entity to, int sf)
+{
+       int channel = MSG_ENTITY;
+       WriteHeader(channel, Electro_Orb);
+       WriteByte(channel, sf);
+       if (sf & 1) {
+               WriteVector(channel, this.origin);
+
+               // round time delta to a 1/10th of a second
+               WriteByte(channel, (this.ltime - time)*10.0+0.5);
+       }
+       return true;
+}
+#endif
+
+#endif
+
 #ifdef SVQC
 #include <common/effects/qc/_mod.qh>
 
@@ -86,6 +156,9 @@ void W_Electro_Orb_ExplodeOverTime(entity this)
        newproj.ltime = time + WEP_CVAR(WEP_ELECTRO, combo_duration);
        set_movetype(newproj, MOVETYPE_NONE);
 
+       Net_LinkEntity(newproj, true, 0, electro_orb_send);
+       newproj.SendFlags |= 1;
+
        // fire the first damage tick immediately
        getthink(newproj)(newproj);
 }