X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fdamage.qc;h=cd7ac7bfa468a1e8422ddb7c131bc9784a0e6436;hb=4dd4d777cd18675c212af922d4d19ad2a40dbb9c;hp=7033447342187528d258a549bbadcfb9af149176;hpb=48a9eb74e54b8e703797522a2591c65d19596915;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/damage.qc b/qcsrc/client/damage.qc index 703344734..cd7ac7bfa 100644 --- a/qcsrc/client/damage.qc +++ b/qcsrc/client/damage.qc @@ -9,7 +9,7 @@ void DamageEffect_Think() if(time >= self.cnt || !self.owner || !self.owner.modelindex || !self.owner.drawmask) { // time is up or the player got gibbed / disconnected - self.owner.total_damages -= 1; + self.owner.total_damages = max(0, self.owner.total_damages - 1); remove(self); return; } @@ -17,12 +17,16 @@ void DamageEffect_Think() { // if the player was dead but is now alive, it means he respawned // if so, clear his damage effects, or damages from his dead body will be copied back - self.owner.total_damages -= 1; + self.owner.total_damages = max(0, self.owner.total_damages - 1); remove(self); return; } self.state = self.owner.csqcmodel_isdead; +#ifdef COMPAT_XON050_ENGINE if(self.owner.isplayermodel && (self.owner.entnum == player_localentnum || self.owner.entnum == spectatee_status) && !autocvar_chase_active) +#else + if(self.owner.isplayermodel && (self.owner.entnum == player_localentnum) && !autocvar_chase_active) +#endif return; // if we aren't using a third person camera, hide our own effects // now generate the particles @@ -35,11 +39,11 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum) { // particle effects for players and objects damaged by weapons (eg: flames coming out of victims shot with rockets) - float life, nearestbone; - string specstr, effectnum; + float life, nearestbone = 0; + string specstr, effectname; entity e; - if(autocvar_cl_gentle || autocvar_cl_gentle_damage) + if(!autocvar_cl_damageeffect || autocvar_cl_gentle || autocvar_cl_gentle_damage) return; if(!self || !self.modelindex || !self.drawmask) return; @@ -57,15 +61,16 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum) continue; // player model bone blacklist // now choose the bone closest to impact origin - if(vlen(hitorg - gettaginfo(self, tagnum)) <= vlen(hitorg - gettaginfo(self, nearestbone))) + if(nearestbone == 0 || vlen(hitorg - gettaginfo(self, tagnum)) <= vlen(hitorg - gettaginfo(self, nearestbone))) nearestbone = tagnum; } gettaginfo(self, nearestbone); // set gettaginfo_name // return if we reached our damage effect limit or damages are disabled + // TODO: When the limit is reached, it would be better if the oldest damage was removed instead of not adding a new one if(nearestbone) { - if(autocvar_cl_damageeffect < 1 || self.total_damages >= autocvar_cl_damageeffect_bones) + if(self.total_damages >= autocvar_cl_damageeffect_bones) return; // allow multiple damages on skeletal models } else @@ -79,7 +84,7 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum) type = DEATH_WEAPONOF(type); e = get_weaponinfo(type); - effectnum = strcat("damage_", e.netname); + effectname = strcat("damage_", e.netname); // if damage was dealt with a bullet weapon, our effect is blood // since blood is species dependent, include the species tag @@ -87,8 +92,8 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum) { if(self.isplayermodel) { - effectnum = strcat(effectnum, "_", specstr); - effectnum = substring(effectnum, 0, strlen(effectnum) - 1); // remove the _ symbol at the end of the species tag + effectname = strcat(effectname, "_", specstr); + effectname = substring(effectname, 0, strlen(effectname) - 1); // remove the _ symbol at the end of the species tag } else return; // objects don't bleed @@ -100,7 +105,7 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum) e.classname = "damage"; e.owner = self; e.cnt = time + life; - e.team = particleeffectnum(effectnum); + e.team = particleeffectnum(effectname); e.think = DamageEffect_Think; e.nextthink = time; self.total_damages += 1; @@ -108,7 +113,7 @@ void DamageEffect(vector hitorg, float dmg, float type, float specnum) void Ent_DamageInfo(float isNew) { - float dmg, rad, edge, thisdmg, forcemul, species; + float dmg, rad, edge, thisdmg, forcemul, species, hitplayer = FALSE; vector force, thisforce; entity oldself; @@ -141,6 +146,10 @@ void Ent_DamageInfo(float isNew) for(self = findradius(w_org, rad + MAX_DAMAGEEXTRARADIUS); self; self = self.chain) { + // attached ents suck + if(self.tag_entity) + continue; + vector nearest = NearestPointOnBox(self, w_org); if(rad) { @@ -173,7 +182,7 @@ void Ent_DamageInfo(float isNew) if(vlen(thisforce)) { self.move_velocity = self.move_velocity + damage_explosion_calcpush(self.damageforcescale * thisforce, self.move_velocity, autocvar_g_balance_damagepush_speedfactor); - self.move_flags &~= FL_ONGROUND; + self.move_flags &= ~FL_ONGROUND; } if(w_issilent) @@ -183,6 +192,9 @@ void Ent_DamageInfo(float isNew) self.event_damage(thisdmg, w_deathtype, w_org, thisforce); DamageEffect(w_org, thisdmg, w_deathtype, species); + + if(self.isplayermodel) + hitplayer = TRUE; // this impact damaged a player } self = oldself; @@ -199,43 +211,43 @@ void Ent_DamageInfo(float isNew) switch(w_deathtype) { - case DEATH_VHCRUSH: + case DEATH_VH_CRUSH: break; // spiderbot - case DEATH_SBMINIGUN: + case DEATH_VH_SPID_MINIGUN: string _snd; _snd = strcat("weapons/ric", ftos(1 + rint(random() * 2)), ".waw"); - sound(self, CH_SHOTS, _snd, VOL_BASE, ATTN_NORM); + sound(self, CH_SHOTS, _snd, VOL_BASE, ATTEN_NORM); pointparticles(particleeffectnum("spiderbot_minigun_impact"), self.origin, w_backoff * 1000, 1); break; - case DEATH_SBROCKET: - sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM); + case DEATH_VH_SPID_ROCKET: + sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM); pointparticles(particleeffectnum("spiderbot_rocket_explode"), self.origin, w_backoff * 1000, 1); break; - case DEATH_SBBLOWUP: - sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN); + case DEATH_VH_SPID_DEATH: + sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_MIN); pointparticles(particleeffectnum("explosion_big"), self.origin, w_backoff * 1000, 1); break; - - case DEATH_WAKIGUN: - sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM); + + case DEATH_VH_WAKI_GUN: + sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTEN_NORM); pointparticles(particleeffectnum("wakizashi_gun_impact"), self.origin, w_backoff * 1000, 1); break; - case DEATH_WAKIROCKET: - sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM); + case DEATH_VH_WAKI_ROCKET: + sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM); pointparticles(particleeffectnum("wakizashi_rocket_explode"), self.origin, w_backoff * 1000, 1); break; - case DEATH_WAKIBLOWUP: - sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN); + case DEATH_VH_WAKI_DEATH: + sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_MIN); pointparticles(particleeffectnum("explosion_big"), self.origin, w_backoff * 1000, 1); break; - case DEATH_RAPTOR_CANNON: - sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM); + case DEATH_VH_RAPT_CANNON: + sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTEN_NORM); pointparticles(particleeffectnum("raptor_cannon_impact"), self.origin, w_backoff * 1000, 1); break; - case DEATH_RAPTOR_BOMB_SPLIT: + case DEATH_VH_RAPT_FRAGMENT: float i; vector ang, vel; for(i = 1; i < 4; ++i) @@ -244,17 +256,21 @@ void Ent_DamageInfo(float isNew) ang = vectoangles(vel); RaptorCBShellfragToss(w_org, vel, ang + '0 0 1' * (120 * i)); } - sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM); + sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM); pointparticles(particleeffectnum("raptor_bomb_spread"), self.origin, w_backoff * 1000, 1); break; - case DEATH_RAPTOR_BOMB: - sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM); + case DEATH_VH_RAPT_BOMB: + sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM); pointparticles(particleeffectnum("raptor_bomb_impact"), self.origin, w_backoff * 1000, 1); break; - case DEATH_RAPTOR_DEATH: - sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_MIN); + case DEATH_VH_RAPT_DEATH: + sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTEN_MIN); pointparticles(particleeffectnum("explosion_big"), self.origin, w_backoff * 1000, 1); break; + case DEATH_VH_BUMB_GUN: + sound(self, CH_SHOTS, "weapons/fireball_impact2.wav", VOL_BASE, ATTEN_NORM); + pointparticles(particleeffectnum("bigplasma_impact"), self.origin, w_backoff * 1000, 1); + break; } } @@ -273,38 +289,38 @@ void Ent_DamageInfo(float isNew) switch(w_deathtype) { case DEATH_TURRET_EWHEEL: - sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_MIN); + sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTEN_MIN); pointparticles(particleeffectnum("laser_impact"), self.origin, w_backoff * 1000, 1); break; case DEATH_TURRET_FLAC: pointparticles(particleeffectnum("hagar_explode"), w_org, '0 0 0', 1); _snd = strcat("weapons/hagexp", ftos(1 + rint(random() * 2)), ".waw"); - sound(self, CH_SHOTS, _snd, VOL_BASE, ATTN_NORM); + sound(self, CH_SHOTS, _snd, VOL_BASE, ATTEN_NORM); break; case DEATH_TURRET_MLRS: case DEATH_TURRET_HK: - case DEATH_TURRET_WALKER_ROCKET: + case DEATH_TURRET_WALK_ROCKET: case DEATH_TURRET_HELLION: - sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN); + sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_MIN); pointparticles(particleeffectnum("rocket_explode"), self.origin, w_backoff * 1000, 1); break; case DEATH_TURRET_MACHINEGUN: - case DEATH_TURRET_WALKER_GUN: + case DEATH_TURRET_WALK_GUN: _snd = strcat("weapons/ric", ftos(1 + rint(random() * 2)), ".waw"); - sound(self, CH_SHOTS, _snd, VOL_BASE, ATTN_NORM); + sound(self, CH_SHOTS, _snd, VOL_BASE, ATTEN_NORM); pointparticles(particleeffectnum("machinegun_impact"), self.origin, w_backoff * 1000, 1); break; case DEATH_TURRET_PLASMA: - sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTN_MIN); + sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_MIN); pointparticles(particleeffectnum("electro_impact"), self.origin, w_backoff * 1000, 1); break; - case DEATH_TURRET_WALKER_MEELE: - sound(self, CH_SHOTS, "weapons/ric1.wav", VOL_BASE, ATTN_MIN); + case DEATH_TURRET_WALK_MEELE: + sound(self, CH_SHOTS, "weapons/ric1.wav", VOL_BASE, ATTEN_MIN); pointparticles(particleeffectnum("TE_SPARK"), self.origin, w_backoff * 1000, 1); break; @@ -320,6 +336,7 @@ void Ent_DamageInfo(float isNew) // TODO spawn particle effects and sounds based on w_deathtype if(!DEATH_ISSPECIAL(w_deathtype)) + if not(hitplayer && !rad) // don't show ground impacts for hitscan weapons if a player was hit { float hitwep;