CanDeployScientists
CanDeployScientists is called by BradleyAPC.CanDeployScientists to let plugins decide whether the Bradley APC may release its escort scientists at that moment.
object CanDeployScientists(BradleyAPC bradleyAPC, BaseEntity attacker, List<GameObjectRef> scientistPrefabs, List<UnityEngine.Vector3> spawnPositions)Parameters
| Parameter | Type | Description |
|---|---|---|
bradleyAPC | BradleyAPC | The Bradley APC entity that is about to release scientists. Use it to read its position, health or OwnerID to scope the decision. |
attacker | BaseEntity | The entity that triggered the deployment check, typically the player or weapon that damaged the APC. Can be null, so always null-check before reading OwnerID or casting to BasePlayer. |
scientistPrefabs | List<GameObjectRef> | List of GameObjectRef prefabs that would be spawned, one per scientist. You can inspect or clear it, though returning a value bypasses the whole spawn. |
spawnPositions | List<UnityEngine.Vector3> | List of world positions where the scientists would appear, already calculated relative to the APC. Useful for distance checks or to log where NPCs are about to drop. |
Return value
Return true to allow the APC to spawn its scientists, or false to stop the original spawn code. Returning null leaves the decision to the game and lets the original deployment logic run unchanged.
How it works
The hook fires on the server before the Bradley APC spawns a group of scientists, inside the APC's CanDeployScientists check. Oxide passes the APC itself, the attacker entity that triggered the check, the list of scientist prefabs that would be spawned, and the world positions where they would appear. Returning a boolean lets you allow or block the deployment outright. Because attacker can be null and may be a weapon or projectile rather than a player, resolve the player with attacker as BasePlayer or by inspecting OwnerID before making decisions. The spawn position list is already populated, so you can compare each entry to the APC's transform position or to nearby players to enforce a minimum distance. Internally showHealth and other follow-up logic belongs to the game; you only control whether the timer path that spawns the NPCs runs. The hook fires on every deployment attempt, so keep the body cheap: no allocations per call where avoidable and no chat spam. Typical use is limiting how often a boss fight can summon adds, blocking deployment on certain maps, or gating it by player count.
Example plugin: Limit Bradley scientist deployment to a cooldown
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Bradley Scientist Cooldown", "RustPluginGenerator", "1.0.0")]
[Description("Throttles how often the Bradley APC may deploy its escort scientists.")]
public class BradleyScientistCooldown : RustPlugin
{
private const string PermAdmin = "bradleyscientistcooldown.admin";
private PluginConfig config;
private readonly Dictionary<ulong, float> lastDeploy = new Dictionary<ulong, float>();
private class PluginConfig
{
[JsonProperty("Cooldown in seconds between scientist deployments")]
public float CooldownSeconds = 120f;
}
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 void Init()
{
permission.RegisterPermission(PermAdmin, this);
}
private object CanDeployScientists(BradleyAPC bradleyAPC, BaseEntity attacker, List<GameObjectRef> scientistPrefabs, List<Vector3> spawnPositions)
{
if (bradleyAPC == null || bradleyAPC.net == null) return null;
ulong id = bradleyAPC.net.ID.Value;
float now = UnityEngine.Time.realtimeSinceStartup;
if (lastDeploy.TryGetValue(id, out float last) && now - last < config.CooldownSeconds)
{
return false;
}
lastDeploy[id] = now;
return true;
}
[ChatCommand("bradleycooldown")]
private void CmdReset(BasePlayer player, string command, string[] args)
{
if (player == null) return;
if (!permission.UserHasPermission(player.UserIDString, PermAdmin))
{
player.ChatMessage("You do not have permission to use this command.");
return;
}
lastDeploy.Clear();
player.ChatMessage("Bradley scientist cooldowns cleared.");
}
private void Unload()
{
lastDeploy.Clear();
}
}
}The plugin records the last time each Bradley APC was allowed to deploy scientists, keyed by the APC's network ID. When CanDeployScientists fires, it checks the stored timestamp against a configurable cooldown in seconds. If the APC already deployed recently, the hook returns false and the game skips spawning the escort; otherwise it stores the current time and returns true. Admins can clear the cooldown with an in-game command so a boss fight can still spawn a fresh wave on demand. A short warning is only printed when the configuration is invalid, never inside the hook itself.
Common use cases
Prevent scientist spam in boss fights
Enforce a minimum interval between scientist waves so a single Bradley cannot endlessly fill the area with NPCs while players farm it.
Disable escort on specific maps or events
Return false unconditionally when a custom event is active, or only allow deployment during scheduled hours, using the APC position to decide.
Scale deployment with player count
Return false when no players are within a configurable radius of the APC, keeping idle NPCs from spawning on an empty part of the map.
Pitfalls
Attacker can be null or not a player
Do not assume
attackeris a BasePlayer or even exists. It is frequently a weapon, projectile or null, so guard before reading OwnerID or casting.Do not mutate the prefab or position lists lightly
Clearing
scientistPrefabsor editingspawnPositionsand returning true can produce mismatched counts or bad spawn locations. Return false to block instead.Hook fires on every deployment check
Keep the body allocation-free and avoid long-running logic or PrintWarning calls, since the APC can call this repeatedly during combat.
Build a plugin with CanDeployScientists
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 CanDeployScientists
Generate