From bccf30480a88e23fbf37666e063738da20ae9760 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 2 Nov 2024 12:01:14 +1000 Subject: [PATCH] Use a modified copy of the nade orb effect for electro orbs --- qcsrc/common/weapons/weapon/electro.qc | 73 ++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 594c39289..a77f2a159 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -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 @@ -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); } -- 2.39.2