So i'm trying my hand with nextbots.
Thus far, I've been able to make a simple nextbot that finds the player, runs up to him, and uses a melee attack.
Now i wanna try ranged combat (which may or may not be a stretch for me), but i can't figure out how to give my bot a weapon.
I've heard that it involves Bonemerging, and i tried to use some code i found around here:
[CODE]function giveNPCWeapon(ent, class)
if !IsValid(ent) || !ent:IsNPC() then return end
local att = "anim_attachment_RH"
local shootpos = ent:GetAttachment(ent:LookupAttachment(att))
local wep = ents.Create("weapon_smg1")
wep:SetOwner(ent)
wep:SetPos(shootpos.Pos)
wep:Spawn()
wep:SetSolid(SOLID_NONE)
wep:SetParent(ent)
wep:Fire("setparentattachment","anim_attachment_RH")
wep:AddEffects(EF_BONEMERGE)
wep:SetAngles(ent:GetForward():Angle())
ent.Weapon = wep
end
end[/CODE]
But when my bot runs, it still spawns unarmed.
No errors, the code just doesn't do anything.
Any ideas?
Also, whoever's code i copied this from, is it okay that i use it?
P.S
does anyone know the Activity name for the Combine soldier's melee animation?
Are you sure the attachement point exists on the model you are using?
I have been struggling with nextbots as well. Unfortunately the nextbot api that garry provided is completely flawed, so much that you just shouldn't use it. You can do most simple things and maybe some complex things with it. But if you want to do more than that you are screwed.
[QUOTE=syl0r;45401998]Are you sure the attachement point exists on the model you are using?[/QUOTE]
Yeah, i'm using the combine soldier model, and according to the model viewer, that point exists on them
[QUOTE]I have been struggling with nextbots as well. Unfortunately the nextbot api that garry provided is completely flawed, so much that you just shouldn't use it. You can do most simple things and maybe some complex things with it. But if you want to do more than that you are screwed.[/QUOTE]
i've seen nextbots that hold things like knives or grenades.
If you're saying shooting a gun is more complex than throwing a grenade, then i'm not sure what to say.
Since it worked for the guy you copied the code from it is probably something else that is wrong. I am also not sure if nextbots return true on IsNPC so check if the function completes properly, add a print or something to the end.
[QUOTE=MysticLlama;45402152]
i've seen nextbots that hold things like knives or grenades.
If you're saying shooting a gun is more complex than throwing a grenade, then i'm not sure what to say.[/QUOTE]
No, that is 100% possible using nextbots. I am talking about things like nextbots not being full regular entities, so they are missing things like ENT:Touch.
MoveToPos is completely useless unless you recreate it and make it better yourself, it already fails when there is someone standing in the way.
It gets stuck extremely easily. There is no way to find spots close to the path except for hiding spots.
Garry clearly only made some things for himself so he could say that he implemented nextbots instead of providing useful functions.
[QUOTE]does anyone know the Activity name for the Combine soldier's melee animation?[/QUOTE]
Use PrintTable on ent:GetSequenceList(), it will probably be obvious which one is the right one
Sorry, you need to Log In to post a reply to this thread.