• AI Relationships
    6 replies, posted
Quick and (hopefully) simple question... I was working on a simple script to make NPC's have preffered targets among players. Let's say I have a variable like .KillDeathRatio on a player or something. Is it possible to make the NPC's want to shoot the player with the highest KillDeathRatio more than other players with lower KDRations? I thought about using [URL="http://wiki.garrysmod.com/?title=NPC.AddEntityRelationship"]this[/URL] function and making the NPC's hate players, and making higher priority players the ones with higher .KilldeathRatio. Yet, Does priority work like that? If a priority 1 player is next to a priority 99 player, will the NPC's prefer to shoot the 99 player? I really don't understand all that much about AI and NPC's a this point, am still working on though, so any insight on the matter is appreciated.
I like this idea. I think it should be called "AI Priority System".
What's your code at the moment?
how about you test the difference between a priority 1 and 99? most likely, a 99 will attract the fire.
I'd test it in SP but seeing as how I'm the only player, I can't test ift effectively. Also citizens have lower health than players do, thus they would die quicker regardless. I think this is doing the trick, I spawned and didn't kill anything, and spawned a few rebels. Then I laid down some combine and I didn't attract much fire. then I turned off AI and just mowed down about 20 of them and started and I got a LOT more fire. Westpoint: [lua] function GM:OnEntityCreated(ent) if ent:IsNPC() then for k,v in pairs(player.GetAll()) do local disp = ent:Disposition(v) if (disp == 1 || disp == 2) then local priority = math.Clamp((v.kdr*2), 1, 99) ent:AddEntityRelationship(v, disp, priority) end end end end [/lua]
[QUOTE=kraizer793;21292228]I'd test it in SP but seeing as how I'm the only player, I can't test ift effectively. Also citizens have lower health than players do, thus they would die quicker regardless. I think this is doing the trick, I spawned and didn't kill anything, and spawned a few rebels. Then I laid down some combine and I didn't attract much fire. then I turned off AI and just mowed down about 20 of them and started and I got a LOT more fire. Westpoint: [lua] function GM:OnEntityCreated(ent) if ent:IsNPC() then for k,v in pairs(player.GetAll()) do local disp = ent:Disposition(v) if (disp == 1 || disp == 2) then local priority = math.Clamp((v.kdr*2), 1, 99) ent:AddEntityRelationship(v, disp, priority) end end end end [/lua][/QUOTE] Use [lua]CODE[/ lua] for lua code.
fix'd
Sorry, you need to Log In to post a reply to this thread.