Added disable_self_explosive_damage

This commit is contained in:
Resxt 2022-02-09 23:54:26 +01:00
parent 7615e4ddf6
commit e21f8ef4a2
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,7 @@
# Disable Self Explosive Damage
Prevents players from dying to their own grenades and rockets.
Note that if you shoot enough rockets (around 15/20) you can still kill yourself.
This also doesn't prevent players from killing themselves when they hold a frag grenade in their hands.
You can add `iprintlnbold(iDamage);` at the beginning of `cancelDamage()` or any other variable found in `cancelDamage()` to debug it (see attacked player, attacker, damage, weapon used, damage type etc.)

View File

@ -0,0 +1,15 @@
init()
{
level.callbackplayerdamagestub = level.callbackplayerdamage;
level.callbackplayerdamage = ::cancelDamage;
}
cancelDamage( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset )
{
if (eAttacker.name == self.name && sMeansOfDeath == "MOD_PROJECTILE_SPLASH" || eAttacker.name == self.name && sMeansOfDeath == "MOD_GRENADE_SPLASH" || eAttacker.name == self.name && sMeansOfDeath == "MOD_EXPLOSIVE")
{
iDamage = 0;
}
self [[level.callbackplayerdamagestub]]( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset );
}