Garry's Mod

Garry's Mod

NextFX - Stylish Chase FX [EASY Custom Packs]
More accurate detection for friendly NPCs
As for now, the way it detects whenever is NPC friendly or not through checking if it's classname in the table of friendly npcs, which is not accurate for few reasons:

1. No support for addons. Friendly NPCs from addons won't be considered as friendly automatically
2. Doesn't consider actual relationship towards player. Because it assumes that certain NPCs are friendly to players, when in some case they are hostile, chase effect will not play. And vice versa, when normally hostile NPC is friendly to the player, but triggers the chase. You can test by spawning Enemy Rebel from "Combine" category and "Resistance Turret" from "Humans + Resistance" category.
3. Doesn't consider NextBots. This check only happens for NPCs. However, NextBots also can be friendly to players if they support relationships. As for example, NextBots based on DrGBase can be friendly, neutral, aggresive or be scared towards player.

To make things more accurate, you should use method Disposition() on entity you want to check.
Pretty much, this is how it should look:

local isFriendly = false
if isfunction(ent.Disposition) then -- checking if this method exists
local disp = ent:Disposition(ply) -- ply is Player
if disp == D_LI or disp == D_NU then --We'll consider neutral npcs as a friendlies too
isFriendly = true
end
else
//Some other way to check if it's friendly or not
end