OnBradleyApcHunt
OnBradleyApcHunt is called from BradleyAPC.UpdateMovement_Hunt every time the APC picks its next hunt movement step. Returning a non-null value skips the game's hunt logic for that update.
object OnBradleyApcHunt(BradleyAPC bradleyAPC)Parameters
| Parameter | Type | Description |
|---|---|---|
bradleyAPC | BradleyAPC | The Bradley APC entity that is currently resolving its hunt movement. Use it to read position, health, current targets and owner data before deciding whether to suppress the attack. |
Return value
Return null to let the game's hunt logic run normally. Return any non-null value (for example true) to skip the APC's hunt movement for that update; the original method is void, so the value itself is discarded.
How it works
The hook fires inside BradleyAPC.UpdateMovement_Hunt, which the APC runs while it is in the hunt state and has an active target list. The game calls the hook before it reads the first target from targetList and moves the APC toward it, so the hook runs frequently while the APC is chasing a player.
The single argument is the Bradley entity. Read bradleyAPC.transform.position to know where the APC is, bradleyAPC.health / MaxHealth() to judge its state, and bradleyAPC.targetList if you need the current targets (check for null and empty first). Because the parameter is typed BradleyAPC, Oxide only calls your method when the argument really is a Bradley APC, so no other entity type reaches it.
Returning a non-null value makes the method return early: the APC does not evaluate patrolPath and does not run its normal target selection or movement this update. Returning null lets the vanilla hunt run unchanged. This is a per-update veto, not a permanent disable; the hunt resumes on the next update where you return null. Keep the method cheap because it is called on every hunt tick.
Example plugin: Pause Bradley hunts during a maintenance window
using System.Collections.Generic;
using System;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Bradley Hunt Pause", "RustPluginGenerator", "1.0.0")]
[Description("Lets admins pause the Bradley APC hunt behavior with a command.")]
public class BradleyHuntPause : RustPlugin
{
private const string PermUse = "bradleyhuntpause.use";
private PluginConfig config;
private bool paused;
private class PluginConfig
{
[JsonProperty("Start paused")]
public bool StartPaused { get; set; } = false;
}
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>
{
["Paused"] = "Bradley hunting is now paused.",
["Resumed"] = "Bradley hunting is now resumed.",
["NoPerm"] = "You do not have permission to use this command."
}, 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(PermUse, this);
paused = config.StartPaused;
}
private void OnServerInitialized()
{
if (paused) Puts("Bradley hunting starts paused (config).");
}
private void Unload()
{
paused = false;
}
[ChatCommand("bradleyhunt.pause")]
private void CmdPause(BasePlayer player, string command, string[] args)
{
if (player == null) return;
if (!player.IsAdmin && !permission.UserHasPermission(player.UserIDString, PermUse))
{
player.ChatMessage(Msg("NoPerm", player.UserIDString));
return;
}
paused = !paused;
player.ChatMessage(Msg(paused ? "Paused" : "Resumed", player.UserIDString));
}
private object OnBradleyApcHunt(BradleyAPC bradleyAPC)
{
if (bradleyAPC == null) return null;
return paused ? (object) true : null;
}
}
}The plugin adds an admin command bradleyhunt.pause toggling a shared pause state and a config option to pause automatically at startup. While paused, OnBradleyApcHunt returns true, so the APC never enters its hunt movement: it keeps its current position instead of chasing players. The toggle is printed to the caller, and Unload clears the flag so a reload does not leave the APC frozen. Because the hook only reads a boolean, overhead on each hunt tick is negligible.
Common use cases
Freeze Bradley during events
Toggle a flag to stop the APC from chasing players while an admin runs a custom event or builds near the launch site, then re-enable it afterward.
Zone-based aggression
Return a value when the APC is outside a configured area so it stops hunting once it leaves the zone, letting you keep the Bradley confined to a custom arena.
Low-health retreat
Inspect
bradleyAPC.healthand suppress the hunt when the APC is badly damaged, giving players a short window to finish it or letting admins script a retreat.
Pitfalls
Calling it every hunt tick
The hook runs repeatedly while the APC has targets. Do not do expensive work such as iterating all players or running raycasts inside it; cache decisions and read them here.
Returning false instead of null
Any non-null return, including
false, skips the hunt movement. When you want normal behavior, returnnullexplicitly.Assuming the APC stops entirely
This only skips the hunt branch. Other APC behavior such as patrolling and turret firing is driven by separate hooks, so a veto here does not disable the Bradley completely.
Build a plugin with OnBradleyApcHunt
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 OnBradleyApcHunt
Generate