C#:
using Rust;
namespace Oxide.Plugins
{
[Info("RocketDamage", "CASHR#6906", "1.0.0")]
internal class RocketDamage : RustPlugin
{
private void OnEntityTakeDamage(BasePlayer entity, HitInfo info)
{
if (entity == null || info?.damageTypes == null || info.WeaponPrefab == null) return;
string weaponName = info.WeaponPrefab.name;
if (weaponName.Contains("explosive.timed") || weaponName.Contains("grenade.f1") || weaponName.Contains("explosive.satchel") || weaponName.Contains("grenade.beancan"))
info.damageTypes.ScaleAll(0.1f);
if (weaponName.Contains("rocket"))
{
float maxHp = entity.MaxHealth();
float currentHp = entity.Health();
float totalDamage = info.damageTypes.Total();
float maxAllowedDamage = maxHp * 0.7f;
if (totalDamage > maxAllowedDamage)
{
float scale = maxAllowedDamage / totalDamage;
info.damageTypes.ScaleAll(scale);
}
float afterDamage = currentHp - info.damageTypes.Total();
float minHp = maxHp * 0.3f;
if (afterDamage < minHp)
{
float allowed = currentHp - minHp;
if (allowed <= 0f)
{
info.damageTypes.ScaleAll(0f);
}
else
{
info.damageTypes.ScaleAll(allowed / info.damageTypes.Total());
}
}
}
}
}
}