]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/gibs.qc
Create common client header
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / gibs.qc
index 6f6316bec1d4c46e2fd474e874316b8563f0af29..e0fec0e60baed9907ed36bdf4e8e45aa75a0324c 100644 (file)
@@ -1,11 +1,24 @@
-.float silent;
+#include "gibs.qh"
+#include "_.qh"
+
+#include "movetypes.qh"
+#include "prandom.qh"
+#include "rubble.qh"
+
+#include "../common/constants.qh"
+#include "../common/util.qh"
+
+.float scale;
+.float alpha;
+.float cnt;
+.float gravity;
 
 void Gib_Delete()
 {
        remove(self);
 }
 
-string species_prefix(float specnum)
+string species_prefix(int specnum)
 {
        switch(specnum)
        {
@@ -20,7 +33,7 @@ string species_prefix(float specnum)
        }
 }
 
-void Gib_setmodel(entity gib, string mdlname, float specnum)
+void Gib_setmodel(entity gib, string mdlname, int specnum)
 {
        switch(specnum)
        {
@@ -48,7 +61,7 @@ void Gib_setmodel(entity gib, string mdlname, float specnum)
        }
 }
 
-void new_te_bloodshower (float ef, vector org, float explosionspeed, float howmany)
+void new_te_bloodshower (int ef, vector org, float explosionspeed, int howmany)
 {
        float i, pmod;
        pmod = autocvar_cl_particles_quality;
@@ -73,7 +86,7 @@ void Gib_Touch()
        }
 
        if(!self.silent)
-               sound(self, CH_PAIN, strcat("misc/gib_splat0", ftos(floor(prandom() * 4 + 1)), ".wav"), VOL_BASE, ATTN_NORM);
+               sound(self, CH_PAIN, strcat("misc/gib_splat0", ftos(floor(prandom() * 4 + 1)), ".wav"), VOL_BASE, ATTEN_NORM);
        pointparticles(particleeffectnum(strcat(species_prefix(self.cnt), "blood")), self.origin + '0 0 1', '0 0 30', 10);
 
        Gib_Delete();
@@ -109,12 +122,13 @@ void Gib_Draw()
        }
 }
 
-void TossGib (string mdlname, vector safeorg, vector org, vector vconst, vector vrand, float specnum, float destroyontouch, float issilent)
+void TossGib (string mdlname, vector safeorg, vector org, vector vconst, vector vrand, int specnum, bool destroyontouch, bool issilent)
 {
        entity gib;
 
        // TODO remove some gibs according to cl_nogibs
        gib = RubbleNew("gib");
+       gib.classname = "gib";
        gib.move_movetype = MOVETYPE_BOUNCE;
        gib.gravity = 1;
        gib.solid = SOLID_CORPSE;
@@ -137,7 +151,8 @@ void TossGib (string mdlname, vector safeorg, vector org, vector vconst, vector
                org = trace_endpos;
        }
 
-       gib.move_origin = gib.origin = org;
+       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.move_time = time;
@@ -149,21 +164,22 @@ void TossGib (string mdlname, vector safeorg, vector org, vector vconst, vector
        RubbleLimit("gib", autocvar_cl_gibs_maxcount, Gib_Delete);
 }
 
-void Ent_GibSplash(float isNew)
+void Ent_GibSplash(bool isNew)
 {
-       float amount, type, specnum;
+       int amount, type, specnum;
        vector org, vel;
        string specstr;
-       float issilent;
-       string gentle_prefix;
+       bool issilent;
+       string gentle_prefix = "morphed_";
 
-       float c, randomvalue;
+       float randomvalue;
+       int c;
 
        type = ReadByte(); // gibbage type
        amount = ReadByte() / 16.0; // gibbage amount
-       org_x = ReadShort() * 4 + 2;
-       org_y = ReadShort() * 4 + 2;
-       org_z = ReadShort() * 4 + 2;
+       org.x = ReadShort() * 4 + 2;
+       org.y = ReadShort() * 4 + 2;
+       org.z = ReadShort() * 4 + 2;
        vel = decompressShortVector(ReadShort());
 
        float cl_gentle_gibs = autocvar_cl_gentle_gibs;
@@ -174,10 +190,8 @@ void Ent_GibSplash(float isNew)
        {
                if(cl_gentle_gibs == 2)
                        gentle_prefix = "";
-               else if(cl_gentle_gibs == 3) 
+               else if(cl_gentle_gibs == 3)
                        gentle_prefix = "happy_";
-               else
-                       gentle_prefix = "morphed_";
        }
        else if(autocvar_cl_particlegibs)
        {
@@ -185,7 +199,7 @@ void Ent_GibSplash(float isNew)
                gentle_prefix = "particlegibs_";
        }
 
-       if not(cl_gentle_gibs || autocvar_cl_gentle)
+       if (!(cl_gentle_gibs || autocvar_cl_gentle))
                amount *= 1 - autocvar_cl_nogibs;
 
        if(autocvar_ekg)
@@ -194,7 +208,7 @@ void Ent_GibSplash(float isNew)
        if(amount <= 0 || !isNew)
                return;
 
-       self.origin = org; // for the sounds
+       setorigin(self, org); // for the sounds
 
        specnum = (type & 0x78) / 8; // blood/gibmodel type: using four bits (0..7, bit indexes 3,4,5)
        issilent = (type & 0x40);
@@ -205,7 +219,7 @@ void Ent_GibSplash(float isNew)
        {
                case 0x01:
                        if(!issilent)
-                               sound (self, CH_PAIN, "misc/gib.wav", VOL_BASE, ATTN_NORM);
+                               sound (self, CH_PAIN, "misc/gib.wav", VOL_BASE, ATTEN_NORM);
 
                        if(prandom() < amount)
                                TossGib ("models/gibs/eye.md3", org, org, vel, prandomvec() * 150, specnum, 0, issilent);