• retarded npc won't fire
    12 replies, posted
[lua]concommand.Add("admin_spawndroid", function(player,command,arguments) if ( player:IsAdmin() or player:IsSuperAdmin() ) then local tr = player:GetEyeTrace(); local npc = ents.Create("npc_combine_s"); npc:SetModel( arguments[2] or "models/sgg/starwars/battledroid.mdl" ); npc:SetPos(tr.HitPos); npc:Spawn(); local weapon = arguments[1] or "weapon_752_e11"; npc:Give(weapon); end; end);[/lua] trying to help someone out, the npc won't fire the weapon lol.
Lol "retarded". It is not programmed to fire it, so it won't fire it. Your weapon basically isn't compatible with NPCs.
incorrect, i've tried giving them ar2s same method and they won't fire tried with like every default gun they won't fire it, but a few of them they'll melee you with it, like the smg and ar2 they will hit you but won't shoot.
They work fine for me, means you did something wrong.
did you run the exact script that i posted? you couldn't have, because i just tested it on a completely vanilla gmod and they won't fire.
[QUOTE=LauScript;42767287]did you run the exact script that i posted? you couldn't have, because i just tested it on a completely vanilla gmod and they won't fire.[/QUOTE] If you want to give NPCs any of the vanilla weapons, you have to use their ai_* versions. (e.g. 'ai_weapon_ar2')
what about for sweps?
[QUOTE=LauScript;42767422]what about for sweps?[/QUOTE] SWEPs have to be designed to be usable by NPCs. They might work nonetheless, but most likely not the way they're supposed to. Most scripters either don't care, or don't know that you have to set them up specifically for NPCs. There are some NPC-related methods (SetNPCMinBurst,SetNPCMaxBurst,SetNPCFireRate,etc), as well as some functions you have to define yourself (NPCShoot_Primary,NPCShoot_Secondary), none of which are documented (Big surprise here).
The problem is that Weapon:SetNPC* functions don't actually do anything.
[QUOTE=Robotboy655;42767733]The problem is that Weapon:SetNPC* functions don't actually do anything.[/QUOTE] They only work for SWEPs, and you have to set them up yourself: [LUA]AccessorFunc(SWEP,"fNPCMinBurst","NPCMinBurst") AccessorFunc(SWEP,"fNPCMaxBurst","NPCMaxBurst") AccessorFunc(SWEP,"fNPCFireRate","NPCFireRate") AccessorFunc(SWEP,"fNPCMinRestTime","NPCMinRest") AccessorFunc(SWEP,"fNPCMaxRestTime","NPCMaxRest")[/LUA] After that the AI should be using them automatically.
[QUOTE=Silverlan;42767793]They only work for SWEPs, and you have to set them up yourself: [LUA]AccessorFunc(SWEP,"fNPCMinBurst","NPCMinBurst") AccessorFunc(SWEP,"fNPCMaxBurst","NPCMaxBurst") AccessorFunc(SWEP,"fNPCFireRate","NPCFireRate") AccessorFunc(SWEP,"fNPCMinRestTime","NPCMinRest") AccessorFunc(SWEP,"fNPCMaxRestTime","NPCMaxRest")[/LUA] After that the AI should be using them automatically.[/QUOTE] I have to set them up in each SWEP?
[QUOTE=Robotboy655;42767811]I have to set them up in each SWEP?[/QUOTE] The base code will do just fine.
[QUOTE=Silverlan;42767900]The base code will do just fine.[/QUOTE] Nope, it just doesn't do anything. I tried setting the firerate to 10 in SWEP:Init & through console and given the weapon to npc_alyx.
Sorry, you need to Log In to post a reply to this thread.