CanBeHomingTargeted
CanBeHomingTargeted is called when the game asks whether a helicopter can be locked onto by a homing weapon or projectile. It fires from the IsValidHomingTarget override of each helicopter type.
object CanBeHomingTargeted(BaseHelicopter helicopter)Parameters
| Parameter | Type | Description |
|---|---|---|
helicopter | BaseHelicopter | The BaseHelicopter instance whose homing validity is being queried. Cast or pattern-match to a more specific subtype (CH47Helicopter, PlayerHelicopter, PatrolHelicopter) to handle them differently. |
Return value
Return null (or any non-bool) to leave the helicopter's own result untouched. Return true or false to override it: a boxed bool is used directly as the IsValidHomingTarget() result, letting homing weapons target or ignore that helicopter.
How it works
This hook fires whenever Rust evaluates IsValidHomingTarget() on a helicopter - for example while a homing projectile or flare-guided weapon searches for a valid target. Each helicopter subtype injects the call into its own override, so the parameter you receive depends on which override ran:
BaseHelicopter.IsValidHomingTargetpasses the base instance (returnstrueby default).CH47Helicopter.IsValidHomingTargetpasses aCH47Helicopter(returnsfalseby default).PlayerHelicopter.IsValidHomingTargetpasses aPlayerHelicopter(returnsIsOn()by default).PatrolHelicopterandHeliPilotFlarehave their own overrides as well.
Use the parameter to read net.ID, OwnerID, or the subtype, so you can decide per hull. Declaring a specific subtype as the parameter narrows dispatch: a method taking CH47Helicopter is skipped for every other helicopter because Oxide only calls hooks whose arguments match the declared parameter types. Keep the hook fast - it can run on every targeting check.
Other signatures
Oxide also calls CanBeHomingTargeted from other places in the game with these parameter types. Declare the overload you need, or several:
object CanBeHomingTargeted(CH47Helicopter cH47Helicopter)object CanBeHomingTargeted(PlayerHelicopter playerHelicopter)object CanBeHomingTargeted(PatrolHelicopter patrolHelicopter)object CanBeHomingTargeted(HeliPilotFlare heliPilotFlare)
Example plugin: Make only powered player helicopters valid homing targets
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Homing Target Control", "RustPluginGenerator", "1.0.0")]
[Description("Controls whether player helicopters can be locked onto by homing weapons.")]
public class HomingTargetControl : RustPlugin
{
private const string PermBypass = "homingtargetcontrol.bypass";
private PluginConfig config;
public class PluginConfig
{
[JsonProperty("Only valid while engine is on")]
public bool RequireEngineOn { get; set; } = true;
[JsonProperty("Notify protected pilot")]
public bool NotifyPilot { get; set; } = true;
}
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);
protected override void LoadDefaultMessages()
{
lang.RegisterMessages(new Dictionary<string, string>
{
["Protected"] = "Your helicopter cannot be locked onto by homing weapons."
}, this);
}
private string Msg(string key, string userId = null, params object[] args)
=> string.Format(lang.GetMessage(key, this, userId), args);
private void Init()
{
permission.RegisterPermission(PermBypass, this);
}
private object CanBeHomingTargeted(PlayerHelicopter helicopter)
{
if (helicopter == null) return null;
var owner = BasePlayer.FindByID(helicopter.OwnerID);
if (owner != null && permission.UserHasPermission(owner.UserIDString, PermBypass))
return null;
bool valid = config.RequireEngineOn ? helicopter.IsOn() : true;
if (!valid && config.NotifyPilot && owner != null && owner.IsConnected && !owner.IsDead())
owner.ChatMessage(Msg("Protected", owner.UserIDString));
return valid;
}
}
}The plugin registers a homingtargetcontrol.bypass permission that lets admins or trusted players keep the default behavior. CanBeHomingTargeted narrows to PlayerHelicopter, so it is only called for player-owned hulls. When the pilot lacks the permission it forces the result based on config: either always valid while the engine is on, or always invalid, so guided launchers cannot lock onto it. Returning null for permitted players leaves the game's IsOn() default in place. Config exposes the mode and a short chat notice when a pilot is protected.
Common use cases
Protect donor helicopters
Return false for helicopters owned by players with a VIP permission, so missiles and flares can never lock onto their hulls.
Allow locking onto parked helicopters
Override the default IsOn() check and return true whenever a player is mounted, letting raiders target helicopters that are hovering without the engine flag set.
Block Chinook targeting entirely
Take CH47Helicopter as the parameter and always return false to guarantee the supply Chinook can never be used as a homing target.
Pitfalls
Type-specific dispatch
A hook declared with PlayerHelicopter will never be called for a PatrolHelicopter or CH47Helicopter. Add separate overloads if you need to cover multiple subtypes.
Returning an unexpected type
Only a boxed bool is used as the result. Returning an int, string, or false-looking object has no effect and the helicopter's default answer stands.
Heavy work in a hot path
The check can run repeatedly per projectile per frame. Cache permissions or owner data rather than doing lookups, and never log inside the hook.
Build a plugin with CanBeHomingTargeted
Describe what should happen and get a compiled plugin that uses this hook.
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 CanBeHomingTargeted
Generate