case DEATH_SBMINIGUN:
string _snd;
_snd = strcat("weapons/ric", ftos(1 + rint(random() * 2)), ".waw");
- sound(self, CHAN_PROJECTILE, _snd, VOL_BASE, ATTN_NORM);
+ sound(self, CH_SHOTS, _snd, VOL_BASE, ATTN_NORM);
pointparticles(particleeffectnum("spiderbot_minigun_impact"), self.origin, w_backoff * 1000, 1);
break;
case DEATH_SBROCKET:
- sound(self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
+ sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
pointparticles(particleeffectnum("spiderbot_rocket_explode"), self.origin, w_backoff * 1000, 1);
break;
case DEATH_SBBLOWUP:
- sound(self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN);
+ sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN);
pointparticles(particleeffectnum("explosion_big"), self.origin, w_backoff * 1000, 1);
break;
case DEATH_WAKIGUN:
- sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
+ sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
pointparticles(particleeffectnum("wakizashi_gun_impact"), self.origin, w_backoff * 1000, 1);
break;
case DEATH_WAKIROCKET:
- sound(self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
+ sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
pointparticles(particleeffectnum("wakizashi_rocket_explode"), self.origin, w_backoff * 1000, 1);
break;
case DEATH_WAKIBLOWUP:
- sound(self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN);
+ sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN);
pointparticles(particleeffectnum("explosion_big"), self.origin, w_backoff * 1000, 1);
break;
case DEATH_RAPTOR_CANNON:
- sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
+ sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
pointparticles(particleeffectnum("raptor_cannon_impact"), self.origin, w_backoff * 1000, 1);
break;
case DEATH_RAPTOR_BOMB_SPLIT:
- sound(self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
+ float i;
+ vector ang, vel;
+ for(i = 1; i < 4; ++i)
+ {
+ vel = normalize(w_org - (w_org + normalize(force) * 16)) + randomvec() * 128;
+ 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);
pointparticles(particleeffectnum("raptor_bomb_spread"), self.origin, w_backoff * 1000, 1);
break;
case DEATH_RAPTOR_BOMB:
- sound(self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
+ sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
pointparticles(particleeffectnum("raptor_bomb_impact"), self.origin, w_backoff * 1000, 1);
break;
case DEATH_RAPTOR_DEATH:
- sound(self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_MIN);
+ sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_MIN);
pointparticles(particleeffectnum("explosion_big"), self.origin, w_backoff * 1000, 1);
break;
}
}
+
+ if(DEATH_ISTURRET(w_deathtype))
+ {
+ string _snd;
+ traceline(w_org - normalize(force) * 16, w_org + normalize(force) * 16, MOVE_NOMONSTERS, world);
+ if(trace_plane_normal != '0 0 0')
+ w_backoff = trace_plane_normal;
+ else
+ w_backoff = -1 * normalize(w_org - (w_org + normalize(force) * 16));
+
+ setorigin(self, w_org + w_backoff * 2); // for sound() calls
+
+ switch(w_deathtype)
+ {
+ case DEATH_TURRET_EWHEEL:
+ sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_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);
+ break;
+
+ case DEATH_TURRET_MLRS:
+ case DEATH_TURRET_HK:
+ case DEATH_TURRET_WALKER_ROCKET:
+ case DEATH_TURRET_HELLION:
+ sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_MIN);
+ pointparticles(particleeffectnum("rocket_explode"), self.origin, w_backoff * 1000, 1);
+ break;
+
+ case DEATH_TURRET_MACHINEGUN:
+ case DEATH_TURRET_WALKER_GUN:
+ _snd = strcat("weapons/ric", ftos(1 + rint(random() * 2)), ".waw");
+ sound(self, CH_SHOTS, _snd, VOL_BASE, ATTN_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);
+ 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);
+ pointparticles(particleeffectnum("TE_SPARK"), self.origin, w_backoff * 1000, 1);
+ break;
+
+ case DEATH_TURRET_PHASER:
+ break;
+
+ case DEATH_TURRET_TESLA:
+ te_smallflash(self.origin);
+ break;
+
+ }
+ }
+
// TODO spawn particle effects and sounds based on w_deathtype
if(!DEATH_ISSPECIAL(w_deathtype))
{
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
(get_weaponinfo(i)).weapon_func(WR_PRECACHE);
}
+
+// damage effect
+
+.entity dmgent;
+.float dmgpartnum, dmgtime;
+.float lifetime;
+
+void Ent_DamageEffect_Think()
+{
+ self.nextthink = time;
+
+ float foundgib;
+ vector org;
+
+ if(time >= self.lifetime)
+ {
+ remove(self);
+ self = world;
+ return;
+ }
+ if(self.dmgtime > time)
+ return;
+ org = getplayerorigin(self.team);
+ if(org == GETPLAYERORIGIN_ERROR)
+ return;
+
+ // Scan the owner of all gibs in the world. If a gib owner is the same as the player we're applying
+ // the effect to, it means our player is gibbed. Therefore, apply particles to the gibs instead.
+ entity head;
+ for(head = world; (head = find(head, classname, "gib")); )
+ {
+ if(head.team == self.team)
+ {
+ if(autocvar_cl_damageeffect_gibs)
+ {
+ if(autocvar_cl_damageeffect_gibs_randomize >= random())
+ pointparticles(self.dmgpartnum, head.origin, '0 0 0', 1);
+ self.dmgtime = time + autocvar_cl_damageeffect_gibs;
+ }
+ foundgib = TRUE;
+ }
+ }
+
+ if(foundgib || !autocvar_cl_damageeffect_player)
+ return; // don't show effects on the invisible dead body if gibs exist
+ if(self.team == player_localentnum - 1 && !autocvar_chase_active)
+ return; // if we aren't in third person mode, hide own damage effect
+
+ // Now apply the effect to actual players
+ pointparticles(self.dmgpartnum, org, '0 0 0', 1);
+ self.dmgtime = time + autocvar_cl_damageeffect_player;
+}
+
+void Ent_DamageEffect()
+{
+ float dmg, type, specnum1, specnum2, entnumber, life;
+ vector org;
+ string specstr, effectnum;
+ entity e;
+
+ dmg = ReadByte(); // damage amount
+ type = ReadByte(); // damage weapon
+ specnum1 = ReadByte(); // player species
+ entnumber = ReadByte(); // player entnum
+
+ if(!autocvar_cl_damageeffect_player && !autocvar_cl_damageeffect_gibs)
+ return;
+ if(autocvar_cl_gentle || autocvar_cl_gentle_damage)
+ return;
+
+ specnum2 = (specnum1 & 0x78) / 8; // blood type: using four bits (0..7, bit indexes 3,4,5)
+ specstr = species_prefix(specnum2);
+ life = bound(0, dmg * autocvar_cl_damageeffect_lifetime, autocvar_cl_damageeffect_lifetime_max);
+
+ e = get_weaponinfo(type);
+ effectnum = strcat("weapondamage_", e.netname);
+ // If the weapon is a bullet weapon, its damage effect is blood.
+ // Since blood is species dependent, we make this effect per-species.
+ if(type == WEP_SHOTGUN || type == WEP_UZI || type == WEP_RIFLE)
+ if(specstr != "")
+ {
+ effectnum = strcat(effectnum, "_", specstr);
+ effectnum = substring(effectnum, 0, strlen(effectnum) - 1); // remove the _ symbol at the end of the species name
+ }
+
+ // if the player already has a damage effect, update it instead of spawning a new one
+ entity head;
+ for(head = world; (head = find(head, classname, "damageeffect")); )
+ {
+ if(head.team == entnumber - 1)
+ {
+ head.dmgpartnum = particleeffectnum(effectnum);
+ head.lifetime += life;
+ return;
+ }
+ }
+
+ entity e;
+ e = spawn();
+ e.classname = "damageeffect";
+ e.team = entnumber - 1;
+ e.dmgpartnum = particleeffectnum(effectnum);
+ e.lifetime = time + life;
+ e.think = Ent_DamageEffect_Think;
+ e.nextthink = time;
+}