]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/damage.qc
Merge branch 'master' into Mario/vehicles
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / damage.qc
index 162ef6a07eb17560ebf4ffeb4d7a6c745affdaae..fb80a52a0eb22a5c85fee6cf5cf81ef8d1cd0910 100644 (file)
@@ -1,3 +1,24 @@
+#include "damage.qh"
+#include "_all.qh"
+
+#include "gibs.qh"
+#include "prandom.qh"
+
+#include "../common/vehicles/cl_vehicles.qh"
+
+#include "../common/constants.qh"
+#include "../common/deathtypes.qh"
+#include "../common/movetypes/movetypes.qh"
+#include "../common/util.qh"
+
+#include "../common/weapons/all.qh"
+
+.entity tag_entity;
+
+.float cnt;
+.int state;
+.bool isplayermodel;
+
 void DamageEffect_Think()
 {
        // if particle distribution is enabled, slow ticrate by total number of damages
@@ -31,11 +52,12 @@ void DamageEffect_Think()
        pointparticles(self.team, org, '0 0 0', 1);
 }
 
-void DamageEffect(vector hitorg, float dmg, float type, float specnum)
+void DamageEffect(vector hitorg, float thedamage, int type, int specnum)
 {
        // particle effects for players and objects damaged by weapons (eg: flames coming out of victims shot with rockets)
 
-       float life, nearestbone = 0;
+       int nearestbone = 0;
+       float life;
        string specstr, effectname;
        entity e;
 
@@ -75,7 +97,7 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum)
                        return; // allow a single damage on non-skeletal models
        }
 
-       life = bound(autocvar_cl_damageeffect_lifetime_min, dmg * autocvar_cl_damageeffect_lifetime, autocvar_cl_damageeffect_lifetime_max);
+       life = bound(autocvar_cl_damageeffect_lifetime_min, thedamage * autocvar_cl_damageeffect_lifetime, autocvar_cl_damageeffect_lifetime_max);
 
        effectname = get_weaponinfo(DEATH_WEAPONOF(type)).netname;
 
@@ -85,7 +107,7 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum)
                {
                        specstr = species_prefix(specnum);
                        specstr = substring(specstr, 0, strlen(specstr) - 1);
-                       effectname = strreplace("BLOOD", specstr, effectname); 
+                       effectname = strreplace("BLOOD", specstr, effectname);
                }
                else { return; } // objects don't bleed
        }
@@ -104,7 +126,9 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum)
 
 void Ent_DamageInfo(float isNew)
 {
-       float dmg, rad, edge, thisdmg, forcemul, species, hitplayer = FALSE;
+       float thedamage, rad, edge, thisdmg;
+       bool hitplayer = false;
+       int species, forcemul;
        vector force, thisforce;
        entity oldself;
 
@@ -114,11 +138,11 @@ void Ent_DamageInfo(float isNew)
        w_issilent = (w_deathtype & 0x8000);
        w_deathtype = (w_deathtype & 0x7FFF);
 
-       w_org_x = ReadCoord();
-       w_org_y = ReadCoord();
-       w_org_z = ReadCoord();
+       w_org.x = ReadCoord();
+       w_org.y = ReadCoord();
+       w_org.z = ReadCoord();
 
-       dmg = ReadByte();
+       thedamage = ReadByte();
        rad = ReadByte();
        edge = ReadByte();
        force = decompressShortVector(ReadShort());
@@ -149,10 +173,10 @@ void Ent_DamageInfo(float isNew)
                                continue;
                        if(thisdmg < 0)
                                thisdmg = 0;
-                       if(dmg)
+                       if(thedamage)
                        {
-                               thisdmg = dmg + (edge - dmg) * thisdmg;
-                               thisforce = forcemul * vlen(force) * (thisdmg / dmg) * normalize(self.origin - w_org);
+                               thisdmg = thedamage + (edge - thedamage) * thisdmg;
+                               thisforce = forcemul * vlen(force) * (thisdmg / thedamage) * normalize(self.origin - w_org);
                        }
                        else
                        {
@@ -165,7 +189,7 @@ void Ent_DamageInfo(float isNew)
                        if(vlen(nearest - w_org) > bound(MIN_DAMAGEEXTRARADIUS, self.damageextraradius, MAX_DAMAGEEXTRARADIUS))
                                continue;
 
-                       thisdmg = dmg;
+                       thisdmg = thedamage;
                        thisforce = forcemul * force;
                }
 
@@ -185,7 +209,7 @@ void Ent_DamageInfo(float isNew)
                DamageEffect(w_org, thisdmg, w_deathtype, species);
 
                if(self.isplayermodel)
-                       hitplayer = TRUE; // this impact damaged a player
+                       hitplayer = true; // this impact damaged a player
        }
 
        self = oldself;
@@ -329,13 +353,11 @@ void Ent_DamageInfo(float isNew)
        if(!DEATH_ISSPECIAL(w_deathtype))
        if(!hitplayer || rad) // don't show ground impacts for hitscan weapons if a player was hit
        {
-               float hitwep;
-
-               hitwep = DEATH_WEAPONOFWEAPONDEATH(w_deathtype);
+               int hitwep = DEATH_WEAPONOFWEAPONDEATH(w_deathtype);
                w_random = prandom();
 
                traceline(w_org - normalize(force) * 16, w_org + normalize(force) * 16, MOVE_NOMONSTERS, world);
-               if(trace_fraction < 1 && hitwep != WEP_VORTEX && hitwep != WEP_VAPORIZER)
+               if(trace_fraction < 1 && hitwep != WEP_VORTEX.m_id && hitwep != WEP_VAPORIZER.m_id)
                        w_backoff = trace_plane_normal;
                else
                        w_backoff = -1 * normalize(force);