]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/effects/qc/gibs.qc
Merge branch 'master' into terencehill/lms_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / effects / qc / gibs.qc
index 20b050c3a4a633ea225e8e7a2e0f523ce17991f1..64a847e270644c0b4c3260114b91c550d703a511 100644 (file)
@@ -1,6 +1,5 @@
 #include "gibs.qh"
 
-#ifdef IMPLEMENTATION
 REGISTER_NET_TEMP(net_gibsplash)
 
 #ifdef SVQC
@@ -17,7 +16,7 @@ bool Violence_GibSplash_SendEntity(entity this, entity to, int sf)
        WriteShort(channel, floor(this.origin.x / 4)); // not using a coord here, as gibs don't need this accuracy
        WriteShort(channel, floor(this.origin.y / 4)); // not using a coord here, as gibs don't need this accuracy
        WriteShort(channel, floor(this.origin.z / 4)); // not using a coord here, as gibs don't need this accuracy
-       WriteShort(channel, this.oldorigin.x); // acrually compressed velocity
+       WriteShort(channel, this.oldorigin.x); // actually compressed velocity
        return true;
 }
 
@@ -26,7 +25,7 @@ void Violence_GibSplash_At(vector org, vector dir, float type, float amount, ent
        if(g_cts) // no gibs in CTS
                return;
 
-       entity e = new(gibsplash);
+       entity e = new_pure(gibsplash);
        e.cnt = amount;
        e.state = type; // should stay smaller than 15
        if(!sound_allowed(MSG_BROADCAST, gibowner) || !sound_allowed(MSG_BROADCAST, attacker))
@@ -40,13 +39,15 @@ void Violence_GibSplash_At(vector org, vector dir, float type, float amount, ent
        else
                e.team = etof(gibowner);
 
-       setorigin(e, org);
+       // origin is just data to be sent
+       //setorigin(e, org);
+       e.origin = org;
        e.velocity = dir;
 
        e.oldorigin_x = compressShortVector(e.velocity);
 
        FOREACH_CLIENT(IS_REAL_CLIENT(it), Violence_GibSplash_SendEntity(e, it, 0));
-       remove(e);
+       delete(e);
 }
 
 void Violence_GibSplash(entity source, float type, float amount, entity attacker)
@@ -70,7 +71,7 @@ void Violence_GibSplash(entity source, float type, float amount, entity attacker
 
 void Gib_Delete(entity this)
 {
-       remove(this);
+       delete(this);
 }
 
 string species_prefix(int specnum);
@@ -111,27 +112,27 @@ void new_te_bloodshower (int ef, vector org, float explosionspeed, int howmany)
                __pointparticles(ef, org, randomvec() * explosionspeed, howmany / 50);
 }
 
-void SUB_RemoveOnNoImpact(entity this)
+void SUB_RemoveOnNoImpact(entity this, entity toucher)
 {
        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
-               Gib_Delete(self);
+               Gib_Delete(this);
 }
 
-void Gib_Touch(entity this)
+void Gib_Touch(entity this, entity toucher)
 {
        // TODO maybe bounce of walls, make more gibs, etc.
 
        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
        {
-               Gib_Delete(self);
+               Gib_Delete(this);
                return;
        }
 
-       if(!self.silent)
-               sound(self, CH_PAIN, SND_GIB_SPLAT_RANDOM(), VOL_BASE, ATTEN_NORM);
-       __pointparticles(_particleeffectnum(strcat(species_prefix(self.cnt), "blood")), self.origin + '0 0 1', '0 0 30', 10);
+       if(!this.silent)
+               sound(this, CH_PAIN, SND_GIB_SPLAT_RANDOM(), VOL_BASE, ATTEN_NORM);
+       __pointparticles(_particleeffectnum(strcat(species_prefix(this.cnt), "blood")), this.origin + '0 0 1', '0 0 30', 10);
 
-       Gib_Delete(self);
+       Gib_Delete(this);
 }
 
 void Gib_Draw(entity this)
@@ -169,17 +170,20 @@ void TossGib (string mdlname, vector safeorg, vector org, vector vconst, vector
        entity gib;
 
        // TODO remove some gibs according to cl_nogibs
-       gib = RubbleNew("gib");
-       gib.move_movetype = MOVETYPE_BOUNCE;
+       gib = ListNewChildRubble(CasingsNGibs, new(gib));
+       set_movetype(gib, MOVETYPE_BOUNCE);
        gib.gravity = 1;
        gib.solid = SOLID_CORPSE;
        gib.cnt = specnum;
        gib.silent = issilent;
+       gib.colormap = 4; // red
+       gib.colormap |= BIT(10); // RENDER_COLORMAPPED
        Gib_setmodel(gib, mdlname, specnum);
 
        setsize (gib, '-8 -8 -8', '8 8 8');
 
        gib.draw = Gib_Draw;
+       IL_PUSH(g_drawables, gib);
        if(destroyontouch)
                settouch(gib, Gib_Touch);
        else
@@ -192,17 +196,16 @@ void TossGib (string mdlname, vector safeorg, vector org, vector vconst, vector
                org = trace_endpos;
        }
 
-       gib.move_origin = org;
        setorigin(gib, org);
-       gib.move_velocity = vconst * autocvar_cl_gibs_velocity_scale + vrand * autocvar_cl_gibs_velocity_random + '0 0 1' * autocvar_cl_gibs_velocity_up;
-       gib.move_avelocity = prandomvec() * vlen(gib.move_velocity) * autocvar_cl_gibs_avelocity_scale;
+       gib.velocity = vconst * autocvar_cl_gibs_velocity_scale + vrand * autocvar_cl_gibs_velocity_random + '0 0 1' * autocvar_cl_gibs_velocity_up;
+       gib.avelocity = prandomvec() * vlen(gib.velocity) * autocvar_cl_gibs_avelocity_scale;
        gib.move_time = time;
        gib.damageforcescale = autocvar_cl_gibs_damageforcescale;
 
        gib.nextthink = time + autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15);
        gib.drawmask = MASK_NORMAL;
 
-       RubbleLimit("gib", autocvar_cl_gibs_maxcount, Gib_Delete);
+       LimitedChildrenRubble(CasingsNGibs, "gib", autocvar_cl_gibs_maxcount, Gib_Delete, NULL);
 }
 
 NET_HANDLE(net_gibsplash, bool isNew)
@@ -311,8 +314,6 @@ NET_HANDLE(net_gibsplash, bool isNew)
                        // no gibs in gentle mode, sorry
                        break;
        }
-       remove(this);
+       delete(this);
 }
 #endif
-
-#endif