OnScientistInitialized
OnScientistInitialized is called after the BradleyAPC has created and set up one of its crew scientists, at the end of BradleyAPC.InitScientist.
void OnScientistInitialized(BradleyAPC bradleyAPC, ScientistNPC scientist, UnityEngine.Vector3 spawnPos)Parameters
| Parameter | Type | Description |
|---|---|---|
bradleyAPC | BradleyAPC | The BradleyAPC that spawned the scientist; the scientist is part of its crew. Use it to identify which Bradley the NPC belongs to. |
scientist | ScientistNPC | The ScientistNPC entity that was just created and initialized, located at the spawn position. Null-check it before changing health, equipment or AI state. |
spawnPos | UnityEngine.Vector3 | The world position the scientist was spawned at, as passed by BradleyAPC.InitScientist. Useful for distance checks or for placing related entities. |
Return value
The hook runs as a plain notification at the end of BradleyAPC.InitScientist; the original method returns void and the return value is ignored. Returning null, a value or nothing has no effect on the scientist or the Bradley.
How it works
This hook fires from BradleyAPC.InitScientist, the game method that spawns a single scientist for a Bradley APC. The call happens after the NPC has been created, given its loadout and had its brain primed (the last internal step is a Brain.Think call), so the scientist is a fully formed, spawned entity by the time you receive it.
The three parameters cover everything you usually need: bradleyAPC identifies the parent vehicle, scientist is the NPC itself and spawnPos is the exact position used for the spawn. Because the call is placed on the Bradley path only, this hook does not fire for scientists created by other means (monument spawners, event plugins) - those go through different code paths.
The hook signature only provides BradleyAPC, so you cannot narrow the first parameter to a base class to catch other vehicles; every call you receive comes from a Bradley. You can still ignore parameters you do not use.
Typical work at this point is adjusting the freshly spawned crew: changing health or damage resistance, swapping the weapon in their belt, tagging them for later lookup, or emitting an effect at spawnPos. Because the hook fires once per scientist, it is safe to do small amounts of work here, but avoid spawning large numbers of entities or running expensive scans.
Example plugin: Buff Bradley crew scientists and mark them for tracking
using System;
using Newtonsoft.Json;
using UnityEngine;
using Oxide.Core;
namespace Oxide.Plugins
{
[Info("Bradley Crew Tagger", "RustPluginGenerator", "1.0.0")]
[Description("Applies configurable health and damage scaling to scientists spawned by a Bradley APC.")]
public class BradleyCrewTagger : RustPlugin
{
private const string PermAdmin = "bradleycrewtagger.admin";
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Maximum health")]
public float MaxHealth = 300f;
[JsonProperty("Damage multiplier (1 = default)")]
public float DamageMultiplier = 1.5f;
}
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();
}
if (config.MaxHealth < 10f) config.MaxHealth = 10f;
if (config.DamageMultiplier < 0.1f) config.DamageMultiplier = 0.1f;
SaveConfig();
}
protected override void SaveConfig() => Config.WriteObject(config);
private void Init()
{
permission.RegisterPermission(PermAdmin, this);
}
private void OnScientistInitialized(BradleyAPC bradleyAPC, ScientistNPC scientist, Vector3 spawnPos)
{
if (scientist == null || scientist.IsDestroyed) return;
scientist.InitializeHealth(config.MaxHealth, config.MaxHealth);
// Scale protections: higher multiplier = takes less damage.
if (scientist.baseProtection != null)
{
float scale = config.DamageMultiplier;
if (scale < 0.01f) scale = 0.01f;
scientist.baseProtection.amounts = ScaleProtection(scientist.baseProtection.amounts, scale);
}
Effect.server.Run("assets/bundled/prefabs/fx/impacts/additive/explosion.prefab", spawnPos);
if (bradleyAPC != null)
{
scientist.OwnerID = bradleyAPC.OwnerID;
}
}
private static float[] ScaleProtection(float[] amounts, float scale)
{
if (amounts == null) return amounts;
var result = new float[amounts.Length];
for (int i = 0; i < amounts.Length; i++)
{
result[i] = amounts[i] * scale;
}
return result;
}
[ChatCommand("bradleybuff")]
private void CmdBradleyBuff(BasePlayer player, string command, string[] args)
{
if (player == null) return;
if (!player.IsAdmin && !permission.UserHasPermission(player.UserIDString, PermAdmin))
{
player.ChatMessage("You do not have permission to use this command.");
return;
}
player.ChatMessage($"Bradley crew: max health {config.MaxHealth}, damage multiplier {config.DamageMultiplier}.");
}
}
}The plugin handles OnScientistInitialized and applies the configured maximum health via InitializeHealth, then multiplies the scientist's baseProtection.amounts by the configured damage multiplier so a higher multiplier makes crew members take less damage. It skips null or destroyed scientists, plays an explosion effect at the spawn position, and sets the scientist's OwnerID to the Bradley APC's OwnerID when a Bradley is provided. Config values are validated in LoadConfig, falling back to defaults if the file is invalid and clamping MaxHealth to at least 10 and DamageMultiplier to at least 0.1. Admins and users with the bradleycrewtagger.admin permission can run /bradleybuff to see the active values.
Common use cases
Buffing Bradley crew
Raise the health or damage output of scientists attached to a Bradley so the APC encounter is harder, without touching monument scientists.
Custom loadout
Give each newly spawned crew member an item through their inventory (for example extra ammo or a different weapon) right after the game has finished initializing them.
Spawn effects and markers
Play a prefab effect or create a short-lived marker at spawnPos so players can see where the Bradley crew appeared.
Pitfalls
Only Bradley scientists
The hook is called from BradleyAPC.InitScientist, so scientists spawned by monuments or other plugins never trigger it. Do not rely on it as a global NPC spawn hook.
Do not assume a player is nearby
Crew spawn as part of the Bradley lifecycle and the hook fires regardless of player proximity, so any code that assumes observers or an attacker exists will throw.
Build a plugin with OnScientistInitialized
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 OnScientistInitialized
Generate