• can someone help me fine tune my dumb SWEP?
    2 replies, posted
Okay so I recently downloaded Vette's starwars blaster pack, and I've been making some tweaks of it for personal use, I'm not going to be an asshat and upload this, I'm just doing this for myself. However I've noticed two flaws with this SWEP: 1) If you fire downwards at just the right angle, you can actually end up shooting yourself, so I'm assuming if I can tweak the code and make the shot spawn a bit farther away when you fire that should clear up that problem. 2) Is there a way to remove the shell casings flying out of the pistol for this SWEP? It's kinda strange that an energy weapon is ejecting casings. [CODE] SWEP.Author = "Vette, edit by Kegan"; SWEP.Purpose = "whittle 'em down!"; SWEP.Instructions = "Pull trigger."; SWEP.Category = "sidearm" SWEP.Spawnable = true; SWEP.AdminSpawnable = true; SWEP.ViewModel = "models/weapons/v_pistol.mdl"; SWEP.WorldModel = "models/weapons/w_pistol.mdl"; SWEP.ShellEffect = "none" SWEP.Primary.ClipSize = -1; SWEP.Primary.DefaultClip = -1; SWEP.Primary.Automatic = false; SWEP.Primary.Ammo = "none"; SWEP.Secondary.ClipSize = -1; SWEP.Secondary.DefaultClip = -1; SWEP.Secondary.Automatic = false; SWEP.Secondary.Ammo = "none"; //local ShootSound = Sound ("/laser"); function SWEP:Reload() end function SWEP:Think() end function SWEP:Shoot () //self.Weapon:EmitSound (ShootSound); self.Weapon:EmitSound("laser.wav", 100, 100); self.BaseClass.ShootEffects (self); local ang = self.Owner:GetCursorAimVector( ):GetNormalized(); local r = 255; local g = 255; local b = 255; local brightness = 1; local pos = self.Owner:EyePos() + (self.Owner:GetAimVector() * 32); bullet = MakeLight (self:GetOwner(), r, g, b, brightness, 80, 1, { Pos = pos, Angle = ang }); // SPRITE TRAIL // (prototype) util.SpriteTrail( Entity entity, Integer AttachmentID, Color color, Boolean additive, Float Start Width, Float End Width, Float LifeTime, Float TextureRes, String Texture ) local attachId = 0; local color = Color(0,0,255); local isAdditive = false; local startWidth = 10; local endWidth = 10; local lifetime = 0.075; local textureRes = 1/(startWidth+endWidth)*0.5; local texture = "trails/plasma.vmt"; local trail = util.SpriteTrail(bullet, attachId, color, isAdditive, startWidth, endWidth, lifetime, textureRes, texture); local phys = bullet:GetPhysicsObject(); phys:EnableGravity( false ); phys:ApplyForceCenter (self.Owner:GetAimVector() * 1000); function bullet:PhysicsCollide( data, phys ) data.HitObject:GetEntity():TakeDamage(10); data.HitObject:ApplyForceCenter(self:GetPhysicsObject():GetVelocity() * 40) local vPoint = self:GetPos() local effectdata = EffectData() effectdata:SetStart( vPoint ) // not sure if we need a start and origin (endpoint) for this effect, but whatever effectdata:SetOrigin( vPoint ) effectdata:SetScale( 1 ) util.Effect( "StunstickImpact", effectdata ) self:EmitSound("physics/plastic/plastic_box_impact_hard3.wav", 100, 100); self:EmitSound("physics/plastic/plastic_box_impact_hard3.wav", 100, 100); self:Remove(); end cleanup.Add (self.Owner, "props", ent); undo.Create ("Blaster Bullet"); undo.AddEntity (bullet); undo.SetPlayer (self.Owner); undo.Finish(); end function SWEP:PrimaryAttack() self:Shoot (); end function MakeLight( pl, r, g, b, brght, size, KeyDown, Data ) if ( !pl:CheckLimit( "lights" ) ) then return false end local lamp = ents.Create( "gmod_light" ) if (!lamp:IsValid()) then return end duplicator.DoGeneric( lamp, Data ) lamp:SetLightColor( r, g, b ) lamp:SetBrightness( brght ) lamp:SetLightSize( size ) lamp:Spawn() duplicator.DoGenericPhysics( lamp, pl, Data ) lamp:SetPlayer( pl ) lamp:SetGravity( 0 ) pl:AddCount( "lights", lamp ) pl:AddCleanup( "lights", lamp ) lamp.lightr = r lamp.lightg = g lamp.lightb = b lamp.Brightness = brght lamp.Size = size lamp.KeyDown = KeyDown lamp.KeyBind = numpad.OnDown( pl, KeyDown, "LightToggle", lamp ) return lamp end [/CODE]
[lua] function bullet:PhysicsCollide( data, phys ) if data.HitEntity == self:GetPlayer() then return end data.HitObject:GetEntity():TakeDamage(10); data.HitObject:ApplyForceCenter(self:GetPhysicsObject():GetVelocity() * 40) local vPoint = self:GetPos() local effectdata = EffectData() effectdata:SetStart( vPoint ) // not sure if we need a start and origin (endpoint) for this effect, but whatever effectdata:SetOrigin( vPoint ) effectdata:SetScale( 1 ) util.Effect( "StunstickImpact", effectdata ) self:EmitSound("physics/plastic/plastic_box_impact_hard3.wav", 100, 100); self:EmitSound("physics/plastic/plastic_box_impact_hard3.wav", 100, 100); self:Remove(); end [/lua] That should fix the shooting your self part.
Thank you man, it was aggravating that I was shooting myself earlier. as for my other problem, is there even a way to hide the shells? Oh and upon further tooling around with this, is there any way to speed the projectiles up? I don't need them much faster mind you I just want a SLIGHT speed boost. I'm trying to pretty much replicate the Mega Buster
Sorry, you need to Log In to post a reply to this thread.