Jump to content

Npc Spawn 3.1.2

   (5 reviews)
Message added by KpucTaJl,

⚠️ IMPORTANT: Major Update!
Before installing, carefully read the update instructions included inside the archive.
The archive contains two separate guides: one for users who use BetterNpc, and one for those who do not.

⚠️ If you are using BetterNpc — do not update NpcSpawn separately.
Start the update with BetterNpc and follow its instruction — it already includes the NpcSpawn update steps.

1 Screenshot

  • 297.1k
  • 47.9k
  • 2.23 MB

depends on

About Npc Spawn

This plugin does not have its own functionality. This plugin is only used as an API for other plugins.

 

Supported Plugins

 

Commands

/preset
Opens the NPC preset configuration GUI. Allows you to create, edit, and manage NPC presets through a graphical interface

/SpawnPreset <presetName>
Spawns an NPC near the player using the specified preset.
Where <presetName> is the name of an existing NPC preset.

/CheckInfo
Displays current parameter values of the NPC you are looking at. Useful for inspection and debugging.

 

API

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ScientistNPC SpawnNpc(Vector3 position, JObject configJson)

Spawn an NPC using a JSON configuration block

Parameters:

  • position — world position where the NPC will be spawned
  • configJson — NPC configuration block (JObject)

Returns:
Spawned ScientistNPC instance.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ScientistNPC SpawnPreset(Vector3 position, string preset)

Spawn an NPC using a preset from the NpcSpawn presets folder

Parameters:

  • position — world position where the NPC will be spawned
  • preset — preset name from the NpcSpawn presets folder

Returns:
Spawned ScientistNPC instance.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void CreatePreset(string preset, JObject configJson)

Create a new NPC preset file in the plugin folder.

Parameters:

  • preset — preset name
  • configJson — NPC configuration block

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void AddTargetRaid(CustomScientistNpc npc, HashSet<BuildingBlock> foundations)

Assign a building as a raid target for the NPC.
You must provide all foundations of the building that should be raided.

Parameters:

  • npc — target NPC
  • foundations — set of building foundations to raid

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void SetParent(CustomScientistNpc npc, Transform parent, Vector3 localPos, float updateTime = 1f)

Attach the NPC to a moving Transform.
The NPC home position will be recalculated in local coordinates relative to the parent Transform at a fixed interval.

Parameters:

  • npc — NPC instance
  • parent — moving Transform used as reference
  • localPos — local offset relative to parent
  • updateTime — position update interval in seconds (default: 1f)

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void SetHomePosition(CustomScientistNpc npc, Vector3 pos)

Set a new home position for the NPC.

Parameters:

  • npc — NPC instance
  • pos — new world position

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void SetCurrentWeapon(CustomScientistNpc npc, Item weapon)

Force the NPC to equip a specific weapon from its inventory.

Parameters:

  • npc — NPC instance
  • weapon — weapon item from NPC inventory

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void SetCustomNavMesh(CustomScientistNpc npc, Transform transform, string navMeshName)

Apply a custom navigation mesh to the NPC.

Parameters:

  • npc — NPC instance
  • transform — root Transform used for navmesh coordinate calculations
  • navMeshName — navmesh name from the NpcSpawn navmesh folder

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

BaseEntity GetCurrentTarget(CustomScientistNpc npc)

Get the current combat target of the NPC.

Parameters:

  • npc — NPC instance

Returns:
Current target entity or null.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void AddStates(CustomScientistNpc npc, HashSet<string> states)

Add additional AI states to an already spawned NPC.

Parameters:

  • npc — NPC instance
  • states — set of state names to add. Example: "RoamState", "ChaseState", "CombatState"

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void DestroyTraps(CustomScientistNpc npc)

Remove all traps and mines owned by the NPC.

Parameters:

  • npc — NPC instance

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

bool IsStationaryPreset(string preset)

Check whether a preset defines a stationary NPC.

Parameters:

  • preset — preset name

Returns:
true if the preset is stationary; otherwise false.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

int GetAreaMask(string preset)

Get the AreaMask value defined in a preset.

Parameters:

  • preset — preset name

Returns:
AreaMask integer value.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

string GetPresetName(CustomScientistNpc npc)

Get the preset name used by an already spawned NPC.

Parameters:

  • npc — NPC instance

Returns:
Preset name.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void RegisterPresetUsage(string preset, string plugin, string category)

Register that a preset is used by a specific plugin and category in the NpcSpawn GUI.

Parameters:

  • preset — preset name
  • plugin — plugin name
  • category — optional category name inside your plugin (for example: monument name groups in BetterNpc)

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void UnregisterPresetUsage(string preset, string plugin, string category)

Remove preset usage registration for a plugin/category.

Parameters:

  • preset — preset name
  • plugin — plugin name
  • category — category name

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void ClearPresetUsage(string plugin)

Clear all preset usage registrations for a plugin.

Not required on plugin unload or reload — handled automatically.

Parameters:

  • plugin — plugin name

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Parameter List

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
string Prefab ["assets/rust.ai/agents/npcplayer/humannpc/scientist/scientistnpc_heavy.prefab"]
Path to the NPC prefab to spawn. Only prefabs of the ScientistNPC class are supported
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
string Names ["Scientist"]
In-game names assigned to NPCs. Separate multiple names with commas (e.g. Name1,Name2)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
int Gender [0]
0 = Random, 1 = Female, 2 = Male
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
int SkinTone [0]
0 = Random, 1 = Very Light, 2 = Light, 3 = Dark, 4 = Very Dark
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
uint Underwear [0]
Underwear worn by NPCs
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashSet<NpcWear> WearItems
Clothing and armor worn by NPCs
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashSet<NpcBelt> BeltItems
Weapons and items equipped in NPCs belt
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
string Kit [""]
Kit name
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool DestroyTrapsOnDeath [false]
If enabled, all traps placed by NPCs will be destroyed when the NPC dies
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float Health [100f]
Total health points of the NPC
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool InstantDeathIfHitHead [false]
If enabled, NPCs die instantly from any headshot, regardless of their health
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float RoamRange [10f]
Maximum distance NPCs can patrol from their spawn point. Values below 2 mean no movement
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float ChaseRange [80f]
Maximum distance NPCs can pursue their target from their spawn point
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float SenseRange [40f]
Maximum distance at which NPCs can detect targets
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float ListenRange [20f]
NPCs hear gunshots at full range, footsteps at 1/3, and crouched movement at 1/9
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float DamageRange [80f]
Maximum distance at which players can damage NPCs. Use -1 for unlimited range
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float ShortRange [10f]
Distance at which NPCs increase firearm spray duration when targets get closer
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float AttackLengthMaxShortRangeScale [2f]
Multiplier for spray length increase when targets are within the short range
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float AttackRangeMultiplier [1f]
Multiplier applied to the default Facepunch attack range of NPC weapons
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool CheckVisionCone [false]
If enabled, NPCs will only detect targets within their forward vision cone
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float VisionCone [286f]
Defines the NPCs field of view in degrees (20–340)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool HostileTargetsOnly [false]
If enabled, NPCs only attack players marked hostile after firing or carrying weapons near safe zones
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool DisplaySashTargetsOnly [false]
If enabled, NPCs will only attack players who have previously picked up a weapon after respawning
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool IgnoreSafeZonePlayers [true]
If enabled, NPCs will ignore players inside safe zones
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool IgnoreSleepingPlayers [true]
If enabled, NPCs will ignore players who are sleeping
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool IgnoreWoundedPlayers [true]
If enabled, NPCs will ignore players who are wounded and downed
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
int NpcAttackMode [2]
0 = Do not attack, 1 = Attack all, 2 = Detailed targeting
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float NpcSenseRange [40f]
Maximum distance at which this NPC can sense other NPCs
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float NpcDamageScale [1f]
Damage modifier against NPCs. Multiplied by the global Scale Damage value
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
string NpcWhitelist ["FrankensteinPet,14922524"]
Allowed NPCs to attack. Use ShortPrefabName, SkinID, class name, NPC name. Separated by commas
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
string NpcBlacklist ["11162132011012"]
Blocked NPCs to attack. Use ShortPrefabName, SkinID, class name, NPC name. Separated by commas
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
int AnimalAttackMode [0]
0 = Do not attack, 1 = Attack all, 2 = Detailed targeting
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float AnimalSenseRange [20f]
Maximum distance at which this NPC can sense animals
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float AnimalDamageScale [1f]
Damage modifier against animals. Multiplied by the global Scale Damage value
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
string AnimalWhitelist [""]
Allowed animals to attack. Use ShortPrefabName, SkinID, class name. Separated by commas
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
string AnimalBlacklist ["11491311214163"]
Blocked animals to attack. Use ShortPrefabName, SkinID, class name. Separated by commas
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float DamageScale [0.75f]
Global damage multiplier applied to all NPC attacks
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool CanTurretTarget [true]
If enabled, turrets are allowed to target NPCs
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float DamageScaleFromTurret [0.5f]
Damage multiplier applied when NPCs receive damage from turrets
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float DamageScaleToTurret [1f]
Damage modifier against turrets. Multiplied by the global Scale Damage value
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float AimConeScale [2f]
The spread of NPC shots. Default Facepunch value is 2. Negative values are not allowed
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool DisableRadio [false]
If enabled, disables the default radio chatter sounds made by scientist NPCs
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool CanRunAwayWater [true]
If enabled, NPCs that enter deep water will return to their spawn point
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool CanSleep [true]
If enabled, NPCs can enter sleep mode to reduce performance cost when no players are nearby
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float SleepDistance [100f]
Distance at which NPCs will enter sleep mode if no players are within range
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float Speed [5f]
Movement speed of NPCs. Default Facepunch value is 5
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
int AreaMask [1]
int AgentTypeID [-1372625422]
Navigation Grid Type
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float BaseOffSet [0f]
Vertical offset from the navmesh. Positive = above, negative = below, 0 = default height
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
string HomePosition [""]
Base position of the NPC used as its home and reference point for movement
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float MemoryDuration [10f]
How long NPCs remember a target after losing sight of it
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashSet<string> States [HashSet<string> { "RoamState", "ChaseState", "CombatState" }]
List of AI states the NPC can use
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
string LootPreset ["Default-Npc-KpucTaJl"]
Name of LootManager preset applied on NPC. Leave empty for no preset
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
string CratePrefab [""]
Prefab path of the crate to spawn at NPC death location. Leave empty for none
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool IsRemoveCorpse [true]
If enabled, NPC corpses are removed instantly on death
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool GroupAlertEnabled [false]
If enabled, NPCs share attacker info with nearby NPCs of matching presets
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float GroupAlertRadius [40f]
Radius in which NPCs can alert nearby groups about the attacking player
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
string GroupAlertReceivers [""]
NPC presets to alert. Use All or preset names (Preset1,Preset2). Own preset added automatically
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float HeadDamageScale [1f]
Damage multiplier for head hits
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float BodyDamageScale [1f]
Damage multiplier for body hits
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
float LegDamageScale [1f]
Damage multiplier for leg hits
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  • Like 18
  • Love 11

User Feedback

2.2m

Downloads

Total number of downloads.

10.3k

Customers

Total customers served.

148.8k

Files Sold

Total number of files sold.

3.2m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.