• Trouble spawning combine soldiers from gamemode
    4 replies, posted
Hi all, I'm having a bit of an issue with my gamemode. I want to spawn combine soldiers, and have them attack players, run around, basically behave the way combine do when spawned in sandbox. Here's the code I'm using: [CODE] function SpawnNPC( location ) if not location then print (" Bad location ") return end if #ents.FindByClass("npc_combine_s") < 10 then local npc = ents.Create( "npc_combine_s") npc:SetModel ( "models/combine_soldier.mdl") npc:SetPos( location ) npc:Give ( "weapon_ar2") npc:Spawn() npc:Activate() print ("Spawned bot") end end [/CODE] This spawns the npc but they just stand in one spot and aim at me. They don't shoot, they don't move, all they do is occasionally crouch. The map has a proper nodegraph and everything, if I spawn combine soldiers in sandbox mode on the same map everything works fine. I don't need any extra AI functions I just want them to shoot players on sight like they normally do. If they could run around/patrol that would be an plus, but really I just want it to work right now. Any help? TLDR: I'm trying to emulate the command [code] npc_create_equipment weapon_ar2 npc_create npc_combine_s [/code] with lua.
I think you'd want to add in a line that says 'npc:CapabilitiesAdd( CAP_MOVE_GROUND, CAP_INNATE_MELEE_ATTACK1, CAP_WEAPON_RANGE_ATTACK1 )'
[QUOTE=NiandraLades;44925636]I think you'd want to add in a line that says 'npc:CapabilitiesAdd( CAP_MOVE_GROUND, CAP_INNATE_MELEE_ATTACK1, CAP_WEAPON_RANGE_ATTACK1 )'[/QUOTE] Thanks for the fast reply, but it did not work. Same issue. I don't know if it matters but they do melee me when I get close, but they did this before I put that line is as well. PS Some extra info: The AI does seem to be active - they stand with their gun lowered until they see me or hear me shoot - they then raise their gun and get into the combat stance, and then just stare at me. If I move around they follow me with their aim but they don't move or shoot. I've made sure they are not spawning inside the ground, etc.
Oh, where did you put the code I suggested? You may need to place it in ENT:Initialize()
[QUOTE=NiandraLades;44926015]Oh, where did you put the code I suggested? You may need to place it in ENT:Initialize()[/QUOTE] I don't have an ENT:Initialize, I'm trying to spawn the default half life 2 combine soldier - npc_combine_s is not my custom entity. I just put [code] ... npc:Give ( "weapon_ar2") npc:CapabilitiesAdd( CAP_MOVE_GROUND, CAP_INNATE_MELEE_ATTACK1, CAP_WEAPON_RANGE_ATTACK1 ) npc:Spawn() ... [/code]
Sorry, you need to Log In to post a reply to this thread.