• Artillery Strike type SWEP/STOOL
    2 replies, posted
This may be quite easy for most Lua coders, but as I'm starting to catch on and taking on bigger projects, I wanna know if it's possible to modify where projectiles spawn and come from. Like if you pull the trigger on a SWEP, something that does this? [lua]function SWEP:PrimaryAttack() local vect = table.create(Vector(ply:GetPos() + vec.z(5))) end[/lua] Add a bunch of vectors which cause it to shoot from random places and converge onto one point, or have it spawn from one location in the map and have the projectiles perform an arc down onto the target area. (Please don't ridicule me for the stupid use of the table, this is my first time actually using something like it :|)
There used to be one that would involve throwing a red smoke grenade, followed by a sound of a plane flying by, and about 5 PHX mk-82 bombs spawning randomly above the smoke. I unfortunately can't find it anywhere.
Have my missile test file. [lua]-- Missile fun -- ~Lexi~ local function makemissile(pos,ply) local missile = ents.Create"rpg_missile" missile:SetPos(pos) missile:SetAngles(ply:GetAimVector():Angle()) missile:SetKeyValue("damage","100") missile:Spawn() missile:Activate() missile:SetOwner(ply) return missile end -- Fire a lot of missiles at the red dot of the rocket launcher you just gave the player concommand.Add("boom",function(ply) for i = -100, 100, 100 do for j = -100, 100, 100 do for k = -100, 100, 100 do makemissile(ply:GetPos() + ply:GetUp() * i + ply:GetRight() * j + ply:GetForward() * k,ply) end end end ply:Give"weapon_rpg" ply:SelectWeapon"weapon_rpg" end) -- Fire a bunch of missiles that converge on the player's aim point concommand.Add("plib",function(ply) local tr = ply:GetEyeTrace() if not (tr.Hit or tr.HitWorld) then return end local e = ents.Create"npc_satchel" e:SetPos(tr.HitPos) e:Spawn() for i = -100, 100, 100 do for j = -100, 100, 100 do local m = makemissile(ply:GetPos() + ply:GetUp() * i + ply:GetRight() * j,ply) m:PointAtEntity(e) end end e:Remove() end) -- Fire a bunch of missiles that converge on a point 1024 units along the player's aim concommand.Add("plob",function(ply) local e = ents.Create"npc_satchel" e:SetPos(ply:GetShootPos() + ply:GetAimVector() * 1024) e:Spawn() for i = -100, 100, 100 do for j = -100, 100, 100 do local m = makemissile(ply:GetPos() + ply:GetUp() * i + ply:GetRight() * j,ply) m:PointAtEntity(e) end end e:Remove() end) -- Make a tripmine local a90 = Angle(90, 0, 0) concommand.Add("bam",function(ply) local trace = ply:GetEyeTrace() if not trace.Hit then return end local ent = ents.Create"npc_tripmine" ent:SetAngles( trace.HitNormal:Angle() + a90 ); ent:SetPos(trace.HitPos + ent:GetUp() * 2) ent:SetOwner(ply) ent:Spawn(); end) -- Make a satchelbomb concommand.Add("bim",function(ply) local trace = ply:GetEyeTrace() if not trace.Hit then return end local ent = ents.Create"npc_satchel" ent:SetAngles( trace.HitNormal:Angle() + a90 ); ent:SetPos(trace.HitPos + ent:GetUp() * 2) ent:SetOwner(ply) ent:Spawn(); end)[/lua]
Sorry, you need to Log In to post a reply to this thread.