X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Feffects%2Fqc%2Fdamageeffects.qc;h=c532e6a29a7cc9392f62d5695cff3087e71c2896;hb=7069dc3f41678554d089db582ccf16da1f8874a5;hp=b72f38e0882ceac7c1d11215c95baf26b098700b;hpb=4ee2807b2d8f808928ef14b3e814945b3edb4350;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/effects/qc/damageeffects.qc b/qcsrc/common/effects/qc/damageeffects.qc index b72f38e08..c532e6a29 100644 --- a/qcsrc/common/effects/qc/damageeffects.qc +++ b/qcsrc/common/effects/qc/damageeffects.qc @@ -1,17 +1,4 @@ -#ifndef DAMAGEEFFECTS_H -#define DAMAGEEFFECTS_H - -#ifdef CSQC -#include -#include -#include -#include -#include -#endif - -#endif - -#ifdef IMPLEMENTATION +#include "damageeffects.qh" REGISTER_NET_LINKED(ENT_CLIENT_DAMAGEINFO) @@ -19,11 +6,10 @@ REGISTER_NET_LINKED(ENT_CLIENT_DAMAGEINFO) bool Damage_DamageInfo_SendEntity(entity this, entity to, int sf) { + vector org = vec3(floor(this.origin.x), floor(this.origin.y), floor(this.origin.z)); WriteHeader(MSG_ENTITY, ENT_CLIENT_DAMAGEINFO); WriteShort(MSG_ENTITY, this.projectiledeathtype); - WriteCoord(MSG_ENTITY, floor(this.origin.x)); - WriteCoord(MSG_ENTITY, floor(this.origin.y)); - WriteCoord(MSG_ENTITY, floor(this.origin.z)); + WriteVector(MSG_ENTITY, org); WriteByte(MSG_ENTITY, bound(1, this.dmg, 255)); WriteByte(MSG_ENTITY, bound(0, this.dmg_radius, 255)); WriteByte(MSG_ENTITY, bound(1, this.dmg_edge, 255)); @@ -67,7 +53,8 @@ void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad .float cnt; .int state; -.bool isplayermodel; + +.bool silent; void DamageEffect_Think(entity this) { @@ -93,12 +80,11 @@ void DamageEffect_Think(entity this) return; } this.state = this.owner.csqcmodel_isdead; - if(this.owner.isplayermodel && (this.owner.entnum == player_localentnum) && !autocvar_chase_active) + if((this.owner.isplayermodel & ISPLAYER_LOCAL) && !autocvar_chase_active) return; // if we aren't using a third person camera, hide our own effects // now generate the particles - vector org; - org = gettaginfo(this, 0); // origin at attached location + vector org = gettaginfo(this, 0); // origin at attached location __pointparticles(this.team, org, '0 0 0', 1); } @@ -123,8 +109,8 @@ void DamageEffect(entity this, vector hitorg, float thedamage, int type, int spe int nearestbone = 0; float life; - string specstr, effectname; - entity e; + string effectname; + entity e, wep; if(!autocvar_cl_damageeffect || autocvar_cl_gentle || autocvar_cl_gentle_damage) return; @@ -164,15 +150,15 @@ void DamageEffect(entity this, vector hitorg, float thedamage, int type, int spe life = bound(autocvar_cl_damageeffect_lifetime_min, thedamage * autocvar_cl_damageeffect_lifetime, autocvar_cl_damageeffect_lifetime_max); - effectname = DEATH_WEAPONOF(type).netname; - - if(substring(effectname, strlen(effectname) - 5, 5) == "BLOOD") + wep = DEATH_WEAPONOF(type); + effectname = strcat("damage_", wep.netname); + if((wep.spawnflags & WEP_FLAG_BLEED)) { - if(this.isplayermodel) + // if this weapon induces bleeding, use the effect name with the proper species prefix (blood type) + if((this.isplayermodel & ISPLAYER_MODEL)) { - specstr = species_prefix(specnum); - specstr = substring(specstr, 0, strlen(specstr) - 1); - effectname = strreplace("BLOOD", specstr, effectname); + string specstr = species_prefix(specnum); + effectname = strcat(specstr, effectname); } else { return; } // objects don't bleed } @@ -190,7 +176,6 @@ void DamageEffect(entity this, vector hitorg, float thedamage, int type, int spe NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew) { - const float ATTEN_LOW = 0.2; float thedamage, rad, edge, thisdmg; bool hitplayer = false; int species, forcemul; @@ -200,9 +185,7 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool 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 = ReadVector(); thedamage = ReadByte(); rad = ReadByte(); @@ -255,7 +238,7 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew) if(it.damageforcescale) if(vdist(thisforce, !=, 0)) { - it.velocity = it.velocity + damage_explosion_calcpush(it.damageforcescale * thisforce, it.velocity, autocvar_g_balance_damagepush_speedfactor); + it.velocity = it.velocity + damage_explosion_calcpush(it.damageforcescale * thisforce, it.velocity, damagepush_speedfactor); UNSET_ONGROUND(it); } @@ -267,7 +250,7 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew) DamageEffect(it, w_org, thisdmg, w_deathtype, species); - if(it.isplayermodel) + if((it.isplayermodel & ISPLAYER_MODEL)) hitplayer = true; // this impact damaged a player }); @@ -401,6 +384,8 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew) } } + MUTATOR_CALLHOOK(DamageInfo, this, w_deathtype, w_org); + // TODO spawn particle effects and sounds based on w_deathtype if(!DEATH_ISSPECIAL(w_deathtype)) if(!hitplayer || rad) // don't show ground impacts for hitscan weapons if a player was hit @@ -409,7 +394,7 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew) w_random = prandom(); traceline(w_org - normalize(force) * 16, w_org + normalize(force) * 16, MOVE_NOMONSTERS, NULL); - if(trace_fraction < 1 && hitwep != WEP_VORTEX && hitwep != WEP_VAPORIZER) + if(trace_fraction < 1 && !(hitwep.spawnflags & WEP_TYPE_HITSCAN)) w_backoff = trace_plane_normal; else w_backoff = -1 * normalize(force); @@ -424,5 +409,3 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew) } #endif - -#endif