-
Posts
12 -
Joined
-
Last visited
Content Type
Profiles
Warranty Claims
Downloads
Forums
Store
Services
Downloads Plus Support
DOWNLOADS EXTRA
Everything posted by tsuyoshi_ito
-
sleep transitions warp stationary NPCs standing on structures without navmesh
tsuyoshi_ito posted A Support Report in Support
Hello, First of all, thank you for developing and maintaining NpcSpawn — we use it on our PvE server through several of your and Adem's plugins. ■How we found it We noticed the issue while using Dynamic Monuments (by Adem). Its "Static NPCs" are stationary guards placed through NpcSpawn on monuments that are spawned dynamically while the server is running. Those NPCs sometimes ended up standing under the monument floor, on the terrain. The trigger was distance: if a player was near the monument when it spawned, the NPCs stayed in place; if nobody was around, they fell under the floor. We investigated and confirmed that Dynamic Monuments places the NPCs at the correct positions — the displacement happens later, inside NpcSpawn's sleep system. So the report below is about NpcSpawn itself and can be reproduced without Dynamic Monuments. ■The issue in NpcSpawn A stationary NPC (Speed = 0, or States containing only IdleState / CombatStationaryState) is spawned with its NavMeshAgent disabled: CustomScientistBrain.AddStates() calls DisableNavAgent(). The NPC then stands exactly where the SpawnNpc API placed it, even if there is no navmesh at that position. This is correct behavior. The problem is in CustomScientistNpc.UpdateSleep() (around line 3632 in 3.3.7). When the sleep state toggles, it always runs one of two movement-related calls, including for stationary NPCs: Falling asleep: SetDestination(HomePosition, 2f, NavigationSpeed.Fast). This goes through BaseNavigator.SetDestination, which re-enables the disabled NavMeshAgent (SetNavMeshEnabled(true) → PlaceOnNavMesh()). Waking up: NavAgent.enabled = true directly. Enabling a NavMeshAgent makes Unity snap it to the nearest navmesh surface. Entities spawned at runtime are not part of the baked navmesh, so for an NPC standing on such a structure the nearest navmesh is the terrain below it — the agent gets warped under the floor. This also explains why the bug looks intermittent: if a player stays within SleepDistance from the moment the NPC spawns, no sleep transition ever happens and the NPC keeps its position. For a stationary NPC both calls are unnecessary: it never moves, so there is nothing to navigate on sleep/wake transitions. ■Steps to reproduce Create a preset with Speed = 0 (or States containing only IdleState + CombatStationaryState), CanSleep = true, SleepDistance = 100. Spawn any prefab with a walkable floor at runtime and place the NPC on top of it via the SpawnNpc API, with no player within 100 m. Wait a few seconds (UpdateTick runs every 2 s), then approach as a player. The NPC is standing on the terrain under the floor. Repeat with a player standing nearby the whole time — the NPC stays in the correct position. ■The fix we applied (verified on our server) We changed only the Sleep region of CustomScientistNpc: Added an IsStationary property using exactly the same condition AddStates() uses for its local isStationary variable. In UpdateSleep(), after Brain.sleeping is updated, return early for stationary NPCs, so neither SetDestination(...) nor NavAgent.enabled = true runs. Brain.sleeping is still updated, so the sleep optimization (the early return in Think()) keeps working for stationary NPCs, and mobile NPCs keep their current behavior. After deploying this change, stationary NPCs no longer fall under runtime-spawned structures on our server. The modified Sleep region: #region Sleep // Same stationary condition as CustomScientistBrain.AddStates() — keep both in sync public bool IsStationary => Config.Speed == 0f || Config.States == null || Config.States.Count == 0 || (Config.States.Contains("IdleState") && Config.States.Contains("CombatStationaryState")) || (Config.States.Contains("IdleState") && Config.States.Count == 1) || (Config.States.Contains("CombatStationaryState") && Config.States.Count == 1); private void UpdateSleep() { if (!Config.CanSleep) return; bool sleep = Query.Server.PlayerGrid.Query(transform.position.x, transform.position.z, Config.SleepDistance, AIBrainSenses.playerQueryResults, x => x.IsPlayer() && !x.IsSleeping()) == 0; if (Brain.sleeping == sleep) return; Brain.sleeping = sleep; // Stationary NPCs must not touch the NavAgent: enabling it snaps them to the nearest // navmesh, which is the terrain under dynamically spawned monuments (no navmesh on floors) if (IsStationary) return; if (Brain.sleeping) SetDestination(HomePosition, 2f, BaseNavigator.NavigationSpeed.Fast); else if (!ActiveCustomNavMesh) NavAgent.enabled = true; } #endregion Sleep ■Patch and how to apply it The attached NpcSpawn-stationary-sleep.patch is a unified diff against NpcSpawn.cs 3.3.7. Put the patch file in the same directory as NpcSpawn.cs and apply it with either of: git apply NpcSpawn-stationary-sleep.patch (inside a git repository) patch -p1 < NpcSpawn-stationary-sleep.patch The change is small (one added property and one early return in UpdateSleep), so applying it by hand from the code block above works just as well. Would you consider including this fix (or an equivalent one) in a future release? Thank you very much! NpcSpawn-stationary-sleep.patch.txt -
Buy Limits Permissions Are Not Applied in Shop Default.json
tsuyoshi_ito posted A Support Report in Support
Thank you as always for providing such a useful plugin. I really appreciate it. I have found an issue with the settings in the following file: oxide/data/Shop/Shops/Default.json Even when I configure the "Buy Limits" for an item, the permissions defined there do not seem to be applied. Could you please make it so that the permissions set in "Buy Limits" are properly recognized and applied? At the moment, I am working around this issue by also setting the same permission under "Discount" so that the permission name is recognized. "Buy Limits (0 - no limit)": { "shop.default": 1, "shop.vip1": 3, "shop.vip2": 5, "shop.vip3": 10 }, "Discount (%)": { "shop.default": 100, "shop.vip1": 100, "shop.vip2": 100, "shop.vip3": 100 }, -
The purchase quantity is reset when the plugin is reloaded.
tsuyoshi_ito posted A Support Report in Support
Even if I specify the purchase quantity as shown below, the purchase quantity is reset when the plugin is reloaded. How can I maintain the purchase quantity even when restarting the plugin? I would like to be able to purchase only the specified quantity during the period leading up to the wipe. "Maximum number of purchases of one vehicle by one player": 2 -
Can I use LootManager to set the loot dropped by NPCs?
tsuyoshi_ito posted A Support Report in Support
Can I use LootManager to set the loot dropped by NPCs? If so, please tell me how. In my environment, the NPC drop item item was not displayed in LootManager. I have been using Dynamic Monument since before installing LootManager. -
- 158 comments
-
- #serverpanel
- #info
-
(and 32 more)
Tagged with:
- #serverpanel
- #info
- #panel
- #ui
- #server
- #serverinfo
- #welcome
- #welcomeui
- #infopanel
- #server gui
- #welcome controller
- #welcome video
- #infopanel mevent
- #welcome panel
- #welcome mevent panel
- #welcome info
- #multi-function info panel
- #server panel
- #menu by mevent
- #menu with info
- #menu gui
- #menu rust
- #rust menu
- #info hud
- #infomenu
- #information
- #best welcome plugin
- #rust welcome
- #welcomer
- #welcome menu
- #welcome ui
- #welcome gui
- #welcome plugin
- #welcome hud
-
- 158 comments
-
- #serverpanel
- #info
-
(and 32 more)
Tagged with:
- #serverpanel
- #info
- #panel
- #ui
- #server
- #serverinfo
- #welcome
- #welcomeui
- #infopanel
- #server gui
- #welcome controller
- #welcome video
- #infopanel mevent
- #welcome panel
- #welcome mevent panel
- #welcome info
- #multi-function info panel
- #server panel
- #menu by mevent
- #menu with info
- #menu gui
- #menu rust
- #rust menu
- #info hud
- #infomenu
- #information
- #best welcome plugin
- #rust welcome
- #welcomer
- #welcome menu
- #welcome ui
- #welcome gui
- #welcome plugin
- #welcome hud
-
- 158 comments
-
- #serverpanel
- #info
-
(and 32 more)
Tagged with:
- #serverpanel
- #info
- #panel
- #ui
- #server
- #serverinfo
- #welcome
- #welcomeui
- #infopanel
- #server gui
- #welcome controller
- #welcome video
- #infopanel mevent
- #welcome panel
- #welcome mevent panel
- #welcome info
- #multi-function info panel
- #server panel
- #menu by mevent
- #menu with info
- #menu gui
- #menu rust
- #rust menu
- #info hud
- #infomenu
- #information
- #best welcome plugin
- #rust welcome
- #welcomer
- #welcome menu
- #welcome ui
- #welcome gui
- #welcome plugin
- #welcome hud