Why npcs don't attack nextbots...

Why npcs don’t attack nextbots, even though i set theirs relationships to “D_HT” ?

Because simply the Nextbot is not considered as a NPC by the NPCS themselves.
You’ll need to use hacky workaround, like this:


Still not attacking…

Perhaps there method to make game consider them as ai/npc ?

Do your nextbots have npc_bullseye attached to them? Regular NPCs won’t be able to target them without it.

I know about this, but i want make flexible system of relationships. And, as far as i know, every NPC will attack npc_bullseye.

But maybe i don’t know something…

You just set the dispositions to the bullseye instead of the Nextbot itself.
NPCs won’t have any dispositions to bullseye if you just spawn one in, so you’d have to set them.

Ok, thanks i will try this way

Because nextbots aren’t NPCs

Ok, people, i got error:

“…attempt to call method ‘Disposition’ (a nil value)”

And what is most interesting, Disposition works! It returns me relationship between npc and player, but with this error

So, my question is: What can cause this error?

Client error only?

and post the full error…

[ERROR] addons/test_bot/lua/entities/bot_player/functions.lua:25: attempt to call method ‘Disposition’ (a nil value)

  1. v - addons/test_bot/lua/entities/bot_player/functions.lua:25
  2. unknown - lua/includes/modules/hook.lua:84

I am playing in singleplayer

Well, seems like you’re calling Disposition when it hasn’t yet been defined. If it’s a local function, make sure it’s above the scope you’re calling it from.

It is function in hook

We can’t help you without any code.

hook.Add("OnEntityCreated", "FakePlayerGetRelationships", function( ent )
    if IsValid(ent) and ent:IsNPC() then
        if ent:Disposition( player.GetByID(1) ) == D_ER then print "D_ER" end
	    if ent:Disposition( player.GetByID(1) ) == D_HT then print "D_HT" end
	    if ent:Disposition( player.GetByID(1) ) == D_FR then print "D_FR" end
	    if ent:Disposition( player.GetByID(1) ) == D_LI then print "D_LI" end
	    if ent:Disposition( player.GetByID(1) ) == D_NU then print "D_NU" end

That seems odd, you do check if the entity is an NPC, and Disposition is an NPC method, so perhaps an error on the devs.

To prevent this just check if ent.Disposition exists, for example:

if ( ent.Disposition and ent:Disposition( player.GetByID( 1 ) ) == D_ER ) then

All the code, including nextbot’s code

This works! Thanks! How did you know that?