Jump to content

Npc not spawning inside raidables

Closed 2.4.7

Thortazo
Thortazo

Posted

Hi, my problem is that i have activated npc spawns inside raidablebases but they spawn outside and static (despite the npcs that are configured around the raidablases walls).

Here's the config:

 

 "NPC Levels": {
    "Level 2 - Final Death": false
  },
  "NPCs": {
    "Damage Multipliers": {
      "Explosive Damage Multiplier": 1.0,
      "Gun Damage Multiplier": 1.0,
      "Melee Damage Multiplier": 1.0
    },
    "Spawn Inside Bases": {
      "Spawn On Floors": true,
      "Spawn On Beds": true,
      "Spawn On Rugs": true,
      "Spawn On Rugs With Skin Only": 1,
      "Spawn Murderers Outside": false,
      "Spawn Scientists Outside": false,
      "Minimum Inside (-1 = ignore)": 5,
      "Maximum Inside (-1 = ignore)": 10
    },

Thanks for advantage.

nivex

Posted

ok thanks ill take a look

Thortazo

Posted (edited)

Ok, i think i figured out, what was the cause.

I'm using Devil Islands custom map and it came with a plugin called:
FOffNavmeshSpam.
Tried to disable the plugin and manually spawn scientist npc inside buildings, because i could not do that either and it worked.

As i can see the plugin avoid spamming messages ov invalid navmesh position, i think maybe the custom map is not well polished.

I will try with procedural map to see if the issue is solved.

Is there any chance to deactivate that plugin while inside of raidablebases? maybe a fragment of code i can use to add the exception on raidablebases ?

Thx for advantage.

using UnityEngine;
using UnityEngine.AI;

namespace Oxide.Plugins
{
    [Info("FOffNavmeshSpam", "bmgjet", "1.0.0")]
    [Description("Stops the navmesh spamming for bots")]
    public class FOffNavmeshSpam : RustPlugin
    {
        void OnEntitySpawned(BaseNetworkable entity)
        {
            BaseNavigator baseNavigator = entity.GetComponent<BaseNavigator>();
            if (baseNavigator != null)
            {
                Vector3 pos;
                if (!baseNavigator.GetNearestNavmeshPosition(entity.transform.position + (Vector3.one * 2f), out pos, (baseNavigator.IsSwimming() ? 30f : 6f)))
                {
                    baseNavigator.topologyPreference = (TerrainTopology.Enum)TerrainTopology.EVERYTHING;
                    BasePlayer bp = null;
                    bp = entity as BasePlayer;
                    if (bp != null){ClipGround(bp, baseNavigator);}
                }
            }
        }
        private void ClipGround(BasePlayer bp, BaseNavigator baseNavigator)
        {
            NavMeshHit hit;
            if (NavMesh.SamplePosition(bp.transform.position, out hit, 30, (int)baseNavigator.topologyPreference))
            {
                bp.gameObject.layer = 17;
                baseNavigator.Warp(hit.position);
                bp.SendNetworkUpdateImmediate();
            }
            NextTick(() =>
            {
                Vector3 pos;
                if (!baseNavigator.GetNearestNavmeshPosition(bp.transform.position + (Vector3.one * 2f), out pos, (baseNavigator.IsSwimming() ? 30f : 6f)))
                {
                    Puts("No Navmesh found @ " + pos.ToString() + " bot will be stationary to stop spam.");
                    baseNavigator.CanUseNavMesh = false;
                }
            });
        }
    }
}

 

Edited by Thortazo
nivex

Posted

using Oxide.Core.Plugins;
using System;
using UnityEngine;
using UnityEngine.AI;

namespace Oxide.Plugins
{
    [Info("FOffNavmeshSpam", "bmgjet", "1.0.0")]
    [Description("Stops the navmesh spamming for bots")]
    public class FOffNavmeshSpam : RustPlugin
    {
        [PluginReference] Plugin RaidableBases;

        void OnEntitySpawned(BaseNetworkable entity)
        {
            BaseNavigator baseNavigator = entity.GetComponent<BaseNavigator>();
            if (baseNavigator != null)
            {
                Vector3 pos;
                if (!baseNavigator.GetNearestNavmeshPosition(entity.transform.position + (Vector3.one * 2f), out pos, (baseNavigator.IsSwimming() ? 30f : 6f)))
                {
                    baseNavigator.topologyPreference = (TerrainTopology.Enum)TerrainTopology.EVERYTHING;
                    BasePlayer bp = null;
                    bp = entity as BasePlayer;
                    if (bp != null) { ClipGround(bp, baseNavigator); }
                }
            }
        }
        private void ClipGround(BasePlayer bp, BaseNavigator baseNavigator)
        {
            if (Convert.ToBoolean(RaidableBases?.Call("EventTerritory", bp.transform.position)))
            {
                return;
            }
            NavMeshHit hit;
            if (NavMesh.SamplePosition(bp.transform.position, out hit, 30, (int)baseNavigator.topologyPreference))
            {
                bp.gameObject.layer = 17;
                baseNavigator.Warp(hit.position);
                bp.SendNetworkUpdateImmediate();
            }
            NextTick(() =>
            {
                if (bp == null || bp.IsDestroyed)
                {
                    return;
                }
                Vector3 pos;
                if (!baseNavigator.GetNearestNavmeshPosition(bp.transform.position + (Vector3.one * 2f), out pos, (baseNavigator.IsSwimming() ? 30f : 6f)))
                {
                    Puts("No Navmesh found @ " + pos.ToString() + " bot will be stationary to stop spam.");
                    baseNavigator.CanUseNavMesh = false;
                }
            });
        }
    }
}

hi you can try this

Thortazo

Posted

Thankss! The problem is solved!

Thnx again and great job coding RaidableBases plugin!

  • Like 1
nivex

Posted

Changed Status from Pending to Closed

1.6m

Downloads

Total number of downloads.

7.7k

Customers

Total customers served.

115.7k

Files Sold

Total number of files sold.

2.4m

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.