• Is there any way to make NPC's shoot at cars while i'm inside?
    8 replies, posted
ok here's the deal, i wanted to do a epic chase scene though GM_bigcity, i planed the route, set up traps, NPC shoot-outs triggred events (i.e. i hit a box that broke and caused something to fall) and it looked great so i went to test it i reached the first set of NPC's and they just stood there looking at me in my car needless to say, it ruined the game is there anyway to make them shoot at me when i am in a veichle?
Even if you could, their bullets wouldn't do crap to you in the vehicle. only explosives can kill someone in any kind of vehicle.
[QUOTE=Jova;21484422]Even if you could, their bullets wouldn't do crap to you in the vehicle. only explosives can kill someone in any kind of vehicle.[/QUOTE] i wouldn't care.. still makes it seem better than them just standing in front of you while you slowly drive into them and them not doing anything
Place this in autorun and run the console command whenever : [lua]concommand.Add("npchatejeeps", function() for key,ent in pairs(ents.GetAll()) do if ent:IsNPC() then ent:AddRelationship("prop_vehicle_jeep D_HT 99") ent:AddRelationship("prop_vehicle_jeep_old D_HT 99") end end end)[/lua] Or just type paste this in console : [code]lua_run for key,ent in pairs(ents.GetAll()) do if ent:IsNPC() then ent:AddRelationship("prop_vehicle_jeep D_HT 99") ent:AddRelationship("prop_vehicle_jeep_old D_HT 99") end end[/code] As usual this code is untested but should work. [b][url=http://wiki.garrysmod.com/?title=NPC.AddRelationship]NPC.AddRelationship [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
You could also hook that to a [b][url=wiki.garrysmod.com/?title=Gamemode.PlayerSpawnedNPC]Gamemode.PlayerSpawnedNPC [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] hook. Untested: [lua]function EnemyNPCHateJeep(ply, npc) if npc:IsValid() and npc:IsNPC() and IsEnemyEntityName(npc:GetClass()) then npc:AddRelationship("prop_vehicle_jeep D_HT 99") npc:AddRelationship("prop_vehicle_jeep_old D_HT 99") npc:AddRelationship("prop_vehicle_airboat D_HT 99") end end hook.Add("PlayerSpawnedNPC", "EnemyNPCHateJeep", EnemyNPCHateJeep)[/lua]
[QUOTE=Crazy Quebec;21486354] [lua]concommand.Add("npchatejeeps", function() for key,ent in pairs(ents.GetAll()) do if ent:IsNPC() then ent:AddRelationship("prop_vehicle_jeep D_HT 99") ent:AddRelationship("prop_vehicle_jeep_old D_HT 99") end end end)[/lua] Or just type paste this in console : [code]lua_run for key,ent in pairs(ents.GetAll()) do if ent:IsNPC() then ent:AddRelationship("prop_vehicle_jeep D_HT 99") ent:AddRelationship("prop_vehicle_jeep_old D_HT 99") end end[/code] As usual this code is untested but should work. [/QUOTE] Won't work, you cannot set the relationship of a NPC to anything other than another NPC or player.
Oh, right. New solution : Use the same code except with npc_bullseye as the hated entity, and parent a few npc_bullseye entities to the outside of the car.
[QUOTE=Crazy Quebec;21506136]Oh, right. New solution : Use the same code except with npc_bullseye as the hated entity, and parent a few npc_bullseye entities to the outside of the car.[/QUOTE] Yeah after a while I noticed even if it did work that would make them attack all jeeps. [lua] function SpawnNPCBull(ply) if ply:IsValid() then local tr = ply:GetEyeTrace() local ent = tr.Entity if tr.Hit and ent:IsValid() then local pent = ents.Create("npc_bullseye") pent:SetPos(ent:GetPos()) pent:SetAngles(ent:GetAngles()) pent:SetParent(ent) pent:Spawn() end end end concommand.Add("spawn_bullseye", SpawnNPCBull) function EnemyNPCHateBullseye(ply, npc) if npc:IsValid() and npc:IsNPC() and IsEnemyEntityName(npc:GetClass()) then npc:AddRelationship("npc_bullseye D_HT 99") end end hook.Add("PlayerSpawnedNPC", "EnemyNPCHateBullseye", EnemyNPCHateBullseye) [/lua]
If the player is in the car then the NPC hates the bullseye, but if they aren't in it then set the relationship to neutral
Sorry, you need to Log In to post a reply to this thread.