using System.Collections.Generic;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Reduce Rocket Damage", "YourName", "1.0.0")]
[Description("Reduces damage from rockets for players")]
public class ReduceRocketDamage : RustPlugin
{
private Dictionary<string, float> rocketDamageMultiplier = new Dictionary<string, float>();
private float playerRocketDamageMultiplier = 0.5f; // Урон от ракеты для игрока (настраиваемое значение)
private void Init()
{
LoadDefaultConfig();
}
protected override void LoadDefaultConfig()
{
Config["RocketDamageMultiplier"] = new Dictionary<string, float>()
{
["rocket_fire"] = 0.5f,
["rocket_hv"] = 0.5f,
["rocket_basic"] = 0.5f,
["rocket_smoke"] = 0.5f,
["explosive.timed"] = 0.5f,
["explosive.satchel"] = 0.5f,
["explosive.c4"] = 0.5f
};
Config["PlayerRocketDamageMultiplier"] = 0.5f;
SaveConfig();
rocketDamageMultiplier = Config.Get<Dictionary<string, float>>("RocketDamageMultiplier");
playerRocketDamageMultiplier = Config.Get<float>("PlayerRocketDamageMultiplier");
}
private void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
{
if (entity is BasePlayer && hitInfo.WeaponPrefab != null)
{
string shortPrefabName = hitInfo.WeaponPrefab.ShortPrefabName;
float damageMultiplier;
if (rocketDamageMultiplier.TryGetValue(shortPrefabName, out damageMultiplier))
{
hitInfo.damageTypes.ScaleAll(damageMultiplier);
// Применяем урон от ракеты к игроку, который выстрелил ракетой
BasePlayer attacker = hitInfo.InitiatorPlayer;
if (attacker != null)
{
float playerDamage = hitInfo.damageTypes.Total() * playerRocketDamageMultiplier;
attacker.Hurt(playerDamage, Rust.DamageType.Explosion);
}
// Отправляем сообщение в чат игрока, который выстрелил ракетой
SendChatMessage(attacker, "Не будь слабаком, бери калаш в руки!");
}
}
}
private void SendChatMessage(BasePlayer player, string message)
{
player.ChatMessage(message);
}
}
}