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:
[CODE]MyNPC:SetEnemy(NextBotEntity)[/CODE]
[QUOTE=Gedo789;49972640]
You'll need to use hacky workaround, like this:
[CODE]MyNPC:SetEnemy(NextBotEntity)[/CODE][/QUOTE]
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.
[QUOTE=MysticLlama;49974548]Do your nextbots have npc_bullseye attached to them? Regular NPCs won't be able to target them without it.[/QUOTE]
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...
[QUOTE=Neyt;49974640] And, as far as i know, every NPC will attack npc_bullseye.[/QUOTE]
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.
[QUOTE=MysticLlama;49974920]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.[/QUOTE]
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?
[QUOTE=Neyt;49990679]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?[/QUOTE]
Client error only?
and post the full error...
[QUOTE=McDunkable;49991017]and post the full error...[/QUOTE]
[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
[QUOTE=Ylsid;49991007]Client error only?[/QUOTE]
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.
[QUOTE=McDunkable;49991120]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.[/QUOTE]
It is function in hook
[QUOTE=Neyt;49991130]It is function in hook[/QUOTE]
We can't help you without any code.
[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
end
end) [/CODE]
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:
[code]
if ( ent.Disposition and ent:Disposition( player.GetByID( 1 ) ) == D_ER ) then
...
end
[/code]
All the code, including nextbot's code
[QUOTE=McDunkable;49992063]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:
[code]
if ( ent.Disposition and ent:Disposition( player.GetByID( 1 ) ) == D_ER ) then
...
end
[/code][/QUOTE]
This works! Thanks! How did you know that?
Sorry, you need to Log In to post a reply to this thread.