Skip to content
RustPluginGenerator

OnPatrolHelicopterTakeDamage

OnPatrolHelicopterTakeDamage is called at the start of PatrolHelicopter.Hurt, before the helicopter applies any damage. Returning a non-null value aborts the original Hurt method so the damage is fully ignored.

Signature
object OnPatrolHelicopterTakeDamage(PatrolHelicopter patrolHelicopter, HitInfo info)

Parameters

Hook parameters
ParameterTypeDescription
patrolHelicopterPatrolHelicopterThe PatrolHelicopter entity receiving the damage. Use it to read or change its health, position, and flags, since this is the same instance whose Hurt method was invoked.
infoHitInfoThe HitInfo describing the hit: the initiator and InitiatorPlayer, the weapon, damage types, isHeadshot, and hit position. Change info.damageTypes to scale the damage before the helicopter applies it.

Return value

Return null (or nothing) to let the helicopter process the damage normally. Return any non-null value to stop PatrolHelicopter.Hurt immediately, so no damage, health change, or death handling occurs for that hit.

How it works

This hook fires inside PatrolHelicopter.Hurt, which the game calls whenever a patrol helicopter is about to take damage. The attack can come from any source that routes through Hurt: bullets, rockets, explosives, fire, or scripted Hurt calls. Because the hook runs before the vanilla code reads info.damageTypes.Total() and touches health, it sees the incoming hit unmodified unless a previous plugin already changed it.

Use patrolHelicopter when you need the entity itself: its current health, its position, or to apply a follow-up effect. Use info to inspect who attacked (info.InitiatorPlayer), the weapon (info.Weapon), whether it was a headshot (info.isHeadshot), and the damage list. Modifying info.damageTypes here alters what the vanilla code then applies; ScaleAll(0.5f) halves it, ScaleAll(0f) makes it a no-op hit.

The signature is fixed: PatrolHelicopter and HitInfo. This hook is separate from the general OnEntityTakeDamage, which also fires for the helicopter. Do not print to console here, since it runs on every hit.

Example plugin: Scale helicopter damage from configurable weapon types

HelicopterDamageScaler.cs
using System.Linq;
using System;
using Newtonsoft.Json;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("Helicopter Damage Scaler", "RustPluginGenerator", "1.0.0")]
    [Description("Scales bullet and explosion damage dealt to patrol helicopters using config multipliers")]
    public class HelicopterDamageScaler : RustPlugin
    {
        private class PluginConfig
        {
            [JsonProperty("Bullet damage multiplier")]
            public float BulletMultiplier = 1.0f;

            [JsonProperty("Explosion damage multiplier")]
            public float ExplosionMultiplier = 1.0f;
        }

        private PluginConfig config;

        protected override void LoadDefaultConfig() => config = new PluginConfig();

        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                config = Config.ReadObject<PluginConfig>();
                if (config == null) throw new Exception();
            }
            catch
            {
                PrintWarning("Configuration file is invalid, using defaults");
                LoadDefaultConfig();
            }
            SaveConfig();
        }

        protected override void SaveConfig() => Config.WriteObject(config);

        private object OnPatrolHelicopterTakeDamage(PatrolHelicopter patrolHelicopter, HitInfo info)
        {
            if (patrolHelicopter == null || info == null || info.damageTypes == null)
                return null;

            var majority = info.damageTypes.GetMajorityDamageType();

            if (majority == Rust.DamageType.Bullet)
            {
                info.damageTypes.ScaleAll(Math.Max(0f, config.BulletMultiplier));
            }
            else if (majority == Rust.DamageType.Explosion)
            {
                info.damageTypes.ScaleAll(Math.Max(0f, config.ExplosionMultiplier));
            }

            return null;
        }

        [ChatCommand("heli.scale")]
        private void CmdShow(BasePlayer player, string command, string[] args)
        {
            if (player == null || !player.IsAdmin) return;

            player.ChatMessage($"Helicopter damage - bullets x{config.BulletMultiplier}, explosions x{config.ExplosionMultiplier}");
        }
    }
}

The plugin reads two multipliers from config: one for explosive damage and one for bullet damage. In OnPatrolHelicopterTakeDamage it checks info.damageTypes.GetMajorityDamageType() and, when it maps to a configured category, applies ScaleAll with the matching multiplier on the damage list. Because the hook runs before the vanilla Hurt code reads the total, the scaled value is what the helicopter actually takes. A ScaleAll(0f) in config would effectively make that damage type harmless, while 1.0 leaves it untouched. The hit is never cancelled, so death handling and the vanilla health logic still run.

Common use cases

  • Make helicopters immune to specific damage

    Scale bullet or explosion damage to zero inside info.damageTypes so players cannot shoot down a protected helicopter, while other sources still apply.

  • Reward attackers in real time

    Read info.InitiatorPlayer to identify who hit the helicopter and award points or resources on each landed hit, with a cooldown to stop farming.

  • Event-tuned difficulty

    During a custom event, adjust damage via config so the helicopter dies in a predictable number of rockets, then restore defaults on cleanup.

Pitfalls

  • Returning non-null cancels the whole Hurt call

    Any non-null return stops the vanilla code before health changes, death checks, and the smoke/fire effects. Only return a value when you truly want the hit ignored.

  • Modify info, not health directly, for scaling

    Setting health inside the hook fights the vanilla code that runs afterwards. Scaling info.damageTypes is the reliable way to change how much damage lands.

  • Do not log on every hit

    The helicopter takes many hits per second during a fight. Put PrintWarning outside this hook; write to data only on rare events.

Build a plugin with OnPatrolHelicopterTakeDamage

Describe what should happen and get a compiled plugin that uses this hook.

Prompt: Make helicopters immune to specific damage using the OnPatrolHelicopterTakeDamage hook, with a config file and a permission
Generate this plugin

Edit the prompt on the next screen. 2 free plugins a month, no card.

Last updated Oct 26, 2026. Found a mistake? Email support@rustplugingenerator.com.

Build a plugin with OnPatrolHelicopterTakeDamage

Generate