-
-void Ent_DamageEffect()
-{
- float type, specnum1, specnum2, entnumber;
- vector org;
- string specstr, effectnum;
- entity e;
-
- type = ReadByte(); // damage weapon
- specnum1 = ReadByte(); // player species
- entnumber = ReadByte(); // player entnum
- org_x = ReadCoord();
- org_y = ReadCoord();
- org_z = ReadCoord();
-
- if not(autocvar_cl_damageeffect)
- return;
- if(autocvar_cl_gentle || autocvar_cl_gentle_damage)
- return;
- // if we aren't in third person mode, hide our own damage effect
- if(entnumber == player_localentnum && !autocvar_chase_active)
- return;
-
- e = get_weaponinfo(type);
-
- specnum2 = (specnum1 & 0x78) / 8; // blood type: using four bits (0..7, bit indexes 3,4,5)
- specstr = species_prefix(specnum2);
-
- 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_SNIPERRIFLE)
- if(specstr != "")
- {
- effectnum = strcat(effectnum, "_", specstr);
- effectnum = substring(effectnum, 0, strlen(effectnum) - 1); // remove the _ symbol at the end of the species name
- }
-
- entity head;
-
- // 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 the particles to the gibs as well.
- for(head = world; (head = find(head, classname, "gib")); )
- {
- if(head.team == entnumber)
- if(random() < autocvar_cl_damageeffect_gib_probability)
- pointparticles(particleeffectnum(effectnum), head.origin, '0 0 0', autocvar_cl_damageeffect);
- }
-
- // Now apply the effect to the player. This shouldn't be done on gibbed bodies, but there's no way
- // to tell between them and the respawned player, if both have damage effects at the same time.
- pointparticles(particleeffectnum(effectnum), org, '0 0 0', autocvar_cl_damageeffect);
-}