void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo) { if (hitInfo != null && hitInfo.Initiator != null && hitInfo.Initiator.ToPlayer() != null) { BasePlayer player = hitInfo.Initiator.ToPlayer(); if (ZoneManager != null) { object canBeWounded = ZoneManager.Call("CanBeWounded", player, hitInfo); if (canBeWounded == null) { return; } } TimedExplosive explosion = null; if (hitInfo.WeaponPrefab != null && hitInfo.WeaponPrefab.ToString().Contains("explosive")) { explosion = (hitInfo.WeaponPrefab.GetEntity() as TimedExplosive); } if (entity.ShortPrefabName.ToString().Contains("player") && ( explosion == null || explosion.explosionRadius >= player.Distance(entity.GetEntity()) ) ) { float totalDamage = (float)0.0; foreach (Rust.DamageType damageType in Enum.GetValues(typeof(Rust.DamageType))) //calculate the damage the player would take { try { if (hitInfo.damageTypes.Get(damageType) > (float)0.0) { if (hitInfo.damageTypes.Get(damageType) > player.baseProtection.Get(damageType)) //damage of attack surpass player protection { totalDamage += hitInfo.damageTypes.Get(damageType) - player.baseProtection.Get(damageType); } } } catch { } } if (player.health <= totalDamage) { //if (!popupsEnabled) SendReply(player, localization["AboutToDie"]); } //else // PopupNotifications.Call("CreatePopupNotification", localization["AboutToDie"], player); } } }