Jump to content

NPC's Breaking Mod

Pending 2.7.4



I'm frequently getting the following error in my console.

 

Failed to create agent because it is not close enough to the NavMesh.

 

It has to do with the NPC's after doing some research.  If I execute "ai.killscientists" in the console in game, the issue clears up and all NPC's get wiped out Murderers and Scientists.  Is there a way to help NPC's avoid this issue?

 

This Error, when it occurs, also is causing subsequent NPC's that spawn to lose logic and behavior.  New NPC's that spawn when this error is occuring and the error is spamming the console/log, do not move, shoot, or respond to a players presence.  While the NPC's that spawned before the error starts happening, continue to behave as normal.

 

Edited by Jackelmyer
more detail

Share this comment


Link to comment

hi, I don't spawn the npc if it's not on the NavMesh, unless it's a stationary npc in which case I disable the NavMesh for that npc. so it isn't this plugin

I've had this happen with 0 plugins too. I think it's a map issue where it's trying to spawn an npc into a rock.

but if you see other plugins where npcs spawn into rocks or clip into them then that would cause it too. mine walk through walls at times but that's not going to cause that issue. they're already spawned at that point.

Edited by nivex

Share this comment


Link to comment

Yeah this is the only mod I have that brings in NPC's.  hrrrm.  It's definitely coming as an issue with Raidable Bases spawned NPC's.  I disable the mod, restart the server, connect, several times, no issues.  Crud.  Is their a better way to generate a procedural map to help avoid something like this?

 

Share this comment


Link to comment

as I said I've had it happen with 0 plugins 😛

I don't spawn anything off the navmesh, either.

I don't know what causes it in the map, otherwise I'd have given a solution =/

Edited by nivex

Share this comment


Link to comment

nah, that's not what I meant. navmesh is where the npcs are able to walk. players walk on the ground and other areas, and npcs walk on the navmesh which is on the ground, too.

I get the position from the navmesh, and then spawn that npc directly onto it. your error is from some other npc that isn't on the navmesh. such as an npc inside of a rock. those are not my npcs.

Edited by nivex

Share this comment


Link to comment

Yeah i don't think it's from something else.  I say that because the error spams my logs/console right after I get a console message that a base was successfully pasted.  Something comes in to spawn NPC's right after the base is pasted and the error starts firing.  I also don't have another NPC mod and when I unload Raidable Bases. the issue goes away.  I'm disabling NPC's for now with Raidable Bases to see how much better it gets.  

Edited by Jackelmyer

Share this comment


Link to comment

Just DMed you files.

What I noticed...  That smaller bases, Easy, Med, Hard, that spawn on beaches, seemed to have the potential for NPC's to spawn in deeper water. and the issue to occur more frequently.  Though I have Kill Under Water NPC's (or whatever that is) enabled, it miiight be a thing?

Testing so far:  

Easy, Medium, Hard Profiles, NPC's disabled.  Issue stopped occurring. 

Removed Raidable Bases.  Issue stopped occurring.

Current Test:  Disabled Bases spawning on beach.   Issue still occurring.  So much for that idea.

Was testing the water thing while I wrote this.  Yeah.  I'm at a loss.  I can get the Raid Bases to work.  But NPC's?  No go.

Seed:  jack1234

world size: 3500

Command Line for my server:  -batchmode +app.port ##### +app.listenip ###### +app.publicip ####### +server.ip ###### +server.port ###### +server.queryport ###### +rcon.ip ####### +rcon.port ##### +rcon.password ###### +maxplayers 60 +datadir ###### +server.identity ###### +hostname "Jacks PVE/NPC/Raidable(building)" +server.seed jack1234 +server.worldsize 3500 -nonetworkthread

Edited by Jackelmyer

Share this comment


Link to comment

ok, not a plugin bug as I had thought. that's good, because this was a really confusing issue and I knew I was doing it correctly. this is a Unity bug where it says the agent isn't on the navmesh when it actually is. this particular bug has been an issue in Unity since 2012... (Rust uses the Unity engine)

the workaround is simple enough

https://forum.unity.com/threads/failed-to-create-agent-because-it-is-not-close-enough-to-the-navmesh.125593/

 

Share this comment


Link to comment

Sorry, scrolling through the thread.  Is this a work around I can do?  A lot of detail in there and it all looks more like Unity Code work.

Share this comment


Link to comment

nah, I will figure it out and send you the result in DM

yes, Rust uses UnityEngine so my code would use the Unity code.

much like a game that uses UnrealEngine would have to use Unreal code.

 

Share this comment


Link to comment

which map size/seed?

type server.seed in the console

jack1234 wouldn't be valid and so it's probably set to 0

Edited by nivex

Share this comment


Link to comment

I checked around beaches and deeper water to see if the NavMesh sampled a position correctly and it does. The position is on the ground / ocean floor, as opposed to being on the waters surface which would cause this issue

so far not seeing any bugs in the plugin but I updated a few things just in case there are any. it's possible that the areaMask is not working on some maps so I've changed it from -1 to 25 which is specific for heavy scientists since those are the npcs that I use. the areaMask is what the NavMesh would use when sampling a position.

think of it like trying to hang a picture on the wall. you need a good spot on the wall (NavMesh) to hang the picture (npc) first. so you look at the area (areaMask) on the wall and determine where (position) you want to hang it

Edited by nivex

Share this comment


Link to comment

open the .cs and change NavMesh.AllAreas to 25 on line 9738 and tell me if that fixes the issue

most suggestions from that Unity site caused some real issues for me so hope this simple solution works for you

Share this comment


Link to comment

Sorry, I forgot that seed gets converted from the command line.

 

I'll give that a try and get you the proper seed.  Just woke up.  It'll be a few. 😁

Share this comment


Link to comment

So I'm changing...

 

if (NavMesh.SamplePosition(target, out _navHit, radius, NavMesh.AllAreas))

to 

if (NavMesh.SamplePosition(target, out _navHit, radius, 25))

 

That alone didn't fix it.  Still getting the error.

 

I just did a full wipe and the following I believe is the seed you're looking for.

Generating procedural map of size 3500 with seed 1550274600

Trying it all again now after doing the wipe.

Edited by Jackelmyer
clarification

Share this comment


Link to comment

So still an issue.  Kinda notice scientists spawned seemed to have less of a problem.  I did find a way to print out the position of NPC's that spown, X, Y, and Z of the Vector.  Nothing seemed strange there either.  Still poking at it.

Share this comment


Link to comment

I've been writing this out as I update/change and test.  Bare with me here.  I do have some questions at the end after "SOoooo...".  X-D  But so that you can see what I went through and tested, here you go.

Spawning only Scientists seems to have at least improved the issue.  Disabling all Murderers from spawning (Raid Tier 3 Profiles Expert and Nightmare are already setup like this) by setting the amounts of murderers to 0, amount and min amount.  2 Server restarts and 35-60 base spawns.  No issue.

The only thing I can think I did that could have impacted murderers was use the Kits plugin and created the murderer_kit_1 kit so I could edit it.  Thinking the murder_kit_1 was just non-existent as I couldn't find where to build a murder_kit_1 in Raidable Bases anywhere..

Which...  I removed.  Removed the kit I created with the Kits plugin called murder_kit_1 and now everything seems to work.   2 Server restarts, 30+ base spawns and all is good.  Murder NPC's were often stuck as nakedish as far as gear worn, which may be a good indicator that this is an issue.  Oof.  That was a pain. lol.

 

I think it may be good to add to the NPC documentation something like "Warning:  Do not add kits with any plugin using the kit names listed above.  Example:  Do not add murder_kit_1 with the Kits plugin or any other plugin".

 

My final thought on this is, I wonder if there's a way to wrap the NPC Creation overall in an exception handler, capturing the entity of the NPC, and attempt to remove the entity if an exception is thrown.  Just to keep NPC's flowing in the event of any kind of error.  I'm fluent in C# but have zero understanding of Unity or Rust's implementation of Unity code so I'm not 100% sure where to poke at to assist with this.  Or a ta minimum , if possible, wrap the whole NPC creation process in an exception handler and spit out any kind of error details available or even just a "Error Creatiing NPC" with the Puts() method.  Just to narrow down issues if someone's having them.

 

SOOooo.  I could use some help figuring out how to change the gear and load out for NPC's.  

 

What are the kits?  murder_kit_1, murder_kit_2, etc.  Can I create new kits?  Does it matter if I create kits?  If Murderer (items) and Scientist (items) determine what the NPC will wear, I don't understand what this is used for.  

 

It looks like "Murderer (Items)" and "Scientist (Items)" define what the NPC's wear and wield as far as armor, clothing, and weapons.  With random skins applied.  Is there a way to make that varied?  Like some murderers wear metal face mask, some wear coffee can?  Does armor apply to the NPC's protection?  Do weapons given determine base damage?  I.E. any damage modifiers are applied to the base damage of a weapon?

"Spawn Alternate Default Scientist Loot", I assume these are alternate loot tables for what the scientists could drop?   

Lastly, I'm assuming the Drop On Death Loot Table works just like the Loot Tables for bases.  

Example:

"Scientist Items Dropped On Death": [
      {
        "shortname": "ammo.rifle",
        "name": null,
        "amount": 30,
        "skin": 0,
        "amountMin": 6,
        "probability": 1.0,
        "stacksize": -1
      },

      {
        "shortname": "ammo.shotgun",
        "name": null,
        "amount": 50,
        "skin": 0,
        "amountMin": 6,
        "probability": 0.50,
        "stacksize": -1
      }
    ]

 

 

Some Notes:  All code changes were reverted to go back to what I downloaded from this site once I figured out the kit was the problem. 

Something that you probably do in test but proved the NPC's were being positioned correctly was a C# change I made.  The following:

 

In the SpawnNpc method, after the brain object is defined, I added a Puts() call spitting out the exact position of the NPC being created.  Before where I thought an error would occur and where I thought the actual coords were being finalized.

                HumanoidBrain brain;
                Puts("NPC Position: x = " + position.x.ToString() + ", y = " + position.y.ToString() + ", z = " + position.z.ToString());

 

Provided an output of:  

You've successfully pasted the structure

[RaidableBases] raideasy9 @ O5 : 72 items

[RaidableBases] NPC Position: x = 328.7178, y = 15.21388, z = 867.2875

[RaidableBases] NPC Position: x = 342.7837, y = 14.7575, z = 896.2714

[RaidableBases] NPC Position: x = 313.864, y = 16.93336, z = 885.471

[RaidableBases] NPC Position: x = 313.5033, y = 15.98435, z = 904.3372

Edited by Jackelmyer
detailed clarifications

Share this comment


Link to comment

I'm glad you found the issue. which Kits plugin are you using? I bet the IsAPI is broken, and would explain why the npc is naked. If it's not from k1lly0u or Mevent then this is probably the fix in the Kits.cs:

        [HookMethod("isKit")]
        public bool isKit(string kitName)
        {
            return kitsList.Exists(p => p.Name == kitName);
        }

can you send the oxide log so I can see where to trap the exception at? it's probably thrown in UpdateItems

murder_kit_1, murder_kit_2, etc are placeholders that shouldn't exist, and by default Murderer (Items) and Scientist (Items) would be equipped instead. using a kit with that same name (or not at all) shouldn't cause any issues unless Kits plugin is broken or using some item that doesn't work. can you tell me exactly what items you put in that kit?

Spawn Alternate Default Scientist Loot is what loot they'd drop in the base game. so when you kill an npc in the open world they contain a few pieces of loot. this is for that (LootSpawnSlots)

Drop On Death Loot Table does work that way yes. if you wanted it to drop a kit then you would use the NPCKits plugin on this site for that (and make sure its enabled in this plugin)

Damage Multipliers in the profiles modify damage from npcs, but that applies to all weapons in that profile instead of per weapon. generally you should adjust the accuracy settings to determine how difficult the npc should be. I imagine armor adds to the npcs protection but the game handles that

CreateLoadout method uses Murderer (Items) and Scientist (Items). you can put any number of items in those lists to have them randomly picked from

ya I drew the npc positions in the game to make sure they were positioned correctly. when you mentioned water I thought maybe the game tried to put them on the waters surface but it put them on the ground correctly as expected

Edited by nivex

Share this comment


Link to comment

The kit's plugin is the following.  version 4.4.0, form UMod by killy0u

Rust Kits 4.4.0

 

as far as the log files, I've looked in the files "oxide.compiler_<date>.log" and oxide_<date>.txt.  As well sa the log files within the logs/RaidableBases folder.  Nothing shows the NavMesh error or any errors after spawning an NPC.  Good times. 🙃

Regarding the Kit used and it's configuration, Not 100% sure.  >.<  It was a bow, a machete, hide armor I believe, and 100 arrows.  Was trying to make a primitive type kit for Easy Bases.  The really weird thing is I copied my whole oxide folder when I DMed you and didn't have Kits in it.  Now I'm wondering if that was for another issue when I DMed you my oxide folder.  hrrrrm.

 

so the CreateLoadout, if I had weapons of a Wooden Bow and a Machete, the NPC will randomly get one of these?  Same for the armor then yeah?  That's AWESOME if so!  Thank you!

 

Share this comment


Link to comment

yea k1lly0u plugin should not have any issue. maybe one of the items is the issue then.

if you could reproduce the issue and tell me what items you are using then I can maybe create a workaround to prevent it from using that specific item and exchange it with something else

I'm already exchanging bow.hunting with bow.compound. as bow.hunting does not work for npc. maybe thats it? maybe neither work on npcs now? LOL

ya you can put whatever items in there. I like adding grenades or c4 and enabling Play Catch With Explosives option =p

Share this comment


Link to comment

Did you create a kit with his plugin using the murder_kit_1 kit name?  Might be murderers_kit_1.   It was whatever was in the RaifableBases json config.  I remember copying that name specifically because I was trying to edit and load the kit in a custom way 

 

I'll try to reproduce the issues in a moment.

Share this comment


Link to comment

1.1m

Downloads

Total number of downloads.

5.7k

Customers

Total customers served.

82.1k

Files Sold

Total number of files sold.

1.6m

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.