Allow damage from turrets to Roaming NPCs by walkinrey

Hello, I am trying to find a way to allow turrets to hurt/kill the RoamingNPCs created by the RoamingNPCs plugin. Currently, the turrets track and target the RoamingNPCs, fire upon the RoamingNPC, however will do zero damage. Players are able kill the RoamingNPCs.

Trace from the turret:
From: AutoTurret, autoturret_deployed
To: BasePlayer, player
No exclusion found - looking up RuleSet...
Using RuleSet "default"
No match in pre-checks; evaluating RuleSet rules...
Initiator EntityGroup matches: traps
Target EntityGroup matches: players
Evaluating Rules...
Checking direct initiator->target rules...
Evaluating "traps->players"...
Match found; allow damage? False

Trace from a player:
From: BasePlayer, player
To: BasePlayer, player
No exclusion found - looking up RuleSet...
Using RuleSet "default"
Initiator or target is HumanNPC, with HumanNPCDamage flag set; allow and return

Thank you for any help.

hi,

generally, the TruePVE config should not need to be changed to support other plugins. NPC plugins can be an exception, but that plugin exposes its NPCs only as BasePlayer rather than as a unique RoamingNPC type.

one way for the plugin to become compatible with TruePVE would be to define its own NPC class that inherits from BasePlayer, giving TruePVE a unique type it can identify in the npcs entity group instead.

another option would be for the plugin to implement the CanEntityTakeDamage hook, which is provided by TruePVE specifically for cases like this. this is advised, as it allows the plugin to override TruePVE and apply its own behavior where needed.

Thank you for the information.

Hello, I had a similar problem with the RoamingNPCs having a different behaviour because of their class inheritance. In my case they were shot by the CH-47 Chinook, like normal players. I wrote a short plugin for the CH-47 to destinguish them from normal players. Maybe something similar could be used in this case. The Prefab of the NPCs is "asset/prefabs/player/player.prefab" and the class inheritance is:

- CustomPet
- FrankensteinPet
- BasePet
- NPCPlayer
- BasePlayer
- BaseCombatEntity
- BaseEntity

My tiny plugin:

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

namespace Oxide.Plugins
{
    [Info("NoChinookNpcShooting", "ToliburtiX", "1.0.2")]
    [Description("Prevents the CH-47 Chinook from targeting NPCs.")]
    class NoChinookNpcShooting : RustPlugin
    {
        // Hook: Called when the main Chinook AI tries to target an entity
        private object OnNpcTargetSense(BaseEntity entity, BaseEntity target)
        {
            if (entity == null || target == null) return null;

            // Check if the attacker is the CH-47 Chinook
            if (entity.ShortPrefabName == "scientistnpc_ch47_gunner")
            {
                // Check if the target is an NPC
                if (target.IsNpc || checkIfNpc(target))
                {
                    return true; // Cancel targeting
                }
            }
            return null;
        }


        private bool checkIfNpc(BaseEntity target)
        {
            Type currentType = target.GetType();

            while (currentType != null &&
                   currentType != typeof(UnityEngine.Object) &&
                   currentType != typeof(object) &&
                   currentType != typeof(BaseNetworkable).BaseType &&
                   currentType != typeof(BaseNetworkable))
            {
                if (currentType == typeof(NPCPlayer))
                    return true;
                currentType = currentType.BaseType;

            }
            return false;
        }
    }
}