• NPC's not using weapons
    0 replies, posted
So apparently in GMod when you spawn in npcs by command or with SetPos() they don't spawn with weapons and they don't do anything. I coded them so they can move around and chase the player but when I did enemies:Give("weapon_shotgun") they hold the weapon, but they don't use it. I gave them these capabilities and they still won't use it: enemies:CapabilitiesAdd( CAP_AIM_GUN, CAP_MOVE_GROUND, CAP_MOVE_SHOOT, CAP_WEAPON_RANGE_ATTACK1, CAP_WEAPON_RANGE_ATTACK2, CAP_USE_WEAPONS, CAP_USE_SHOT_REGULATOR, CAP_FRIENDLY_DMG_IMMUNE ) They also do the animation where they run without a weapon but they hold the shotgun. Whenever I spawn a zombie they act like citizens without weapons. Please help! [CODE]//SpawnNPC timer.Create( "NPCSpawn", 4, 0, function() enemies = ents.Create( "npc_citizen" ) if !enemies:IsValid() then return end if game.GetMap() == "ttt_nuketown" then enemies:SetPos( table.Random(nuketownspawns) ) enemies:SetCollisionGroup (COLLISION_GROUP_NPC_SCRIPTED) end enemies:Spawn() local Players = team.GetPlayers( team1 ) table.Add( Players, team.GetPlayers( team2 ) ) table.Add( Players, team.GetPlayers( team3 ) ) for i = 1, table.Count(Players) do local ply = Players[i] local plypos = ply:GetPos() if(plypos:Distance(enemies:GetPos()) < 100000) then if not enemies:IsMoving() then enemies:SetEnemy(ply) enemies:Give("weapon_shotgun") enemies:SetLastPosition(plypos) enemies:UpdateEnemyMemory( ply, plypos ) enemies:Classify(CLASS_CITIZEN_REBEL) enemies:UseAssaultBehavior() enemies:CapabilitiesAdd( CAP_AIM_GUN, CAP_MOVE_GROUND, CAP_MOVE_SHOOT, CAP_WEAPON_RANGE_ATTACK1, CAP_WEAPON_RANGE_ATTACK2, CAP_USE_WEAPONS, CAP_USE_SHOT_REGULATOR, CAP_FRIENDLY_DMG_IMMUNE ) enemies:SetSchedule( SCHED_ARM_WEAPON, SCHED_SHOOT_ENEMY_COVER, SCHED_TARGET_CHASE, SCHED_RANGE_ATTACK1 ) enemies:SetCurrentWeaponProficiency(WEAPON_PROFICIENCY_PERFECT) enemies:AddEntityRelationship( ply, D_HT, 99 ) enemies:Activate() return end end end end)[/CODE] I know the code is a mess and most of it won't apply but I just need them to use weapons before I remove anything.
Sorry, you need to Log In to post a reply to this thread.