Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- easylua.Start(Ply"oh") -- this is just a helper thing so you have vars like "me" in the script which is yourself
- local SWEP = {Primary = {}, Secondary = {}}
- SWEP.ClassName = "toybox_owner_gun"
- SWEP.Base = "weapon_base"
- do --random toybox swep
- SWEP.ViewModelFlip = false
- SWEP.Category = "ownage";
- SWEP.Author = "SOD:Reaper";
- SWEP.Contact = "";
- SWEP.Purpose = "";
- SWEP.Instructions = "";
- SWEP.PrintName = "Owner_pwnage_Gun";
- SWEP.Slot = 1;
- SWEP.SlotPos = 1;
- SWEP.DrawCrosshair = true;
- SWEP.DrawAmmo = true;
- SWEP.ViewModel = "models/weapons/v_irifle.mdl";
- SWEP.WorldModel = "models/weapons/w_physcannon.mdl";
- SWEP.ViewModelFOV = 70;
- SWEP.ReloadSound = "weapons/smg1/smg1_reload.wav";
- SWEP.HoldType = "ar2";
- SWEP.Spawnable = true;
- SWEP.AdminSpawnable = true;
- SWEP.Weight = 10;
- SWEP.AutoSwitchTo = false;
- SWEP.AutoSwitchFrom = true;
- SWEP.FiresUnderwater = true;
- SWEP.Primary.Zap = false;
- SWEP.Primary.ZapRadius = 15000;
- SWEP.Primary.ZapDamage = 3000000000;
- SWEP.Primary.RPG = false
- SWEP.Primary.RPGType = "bazooka_round"
- SWEP.Primary.Sound = "weapons/physcannon/superphys_launch1.wav"
- SWEP.Primary.Tracer = 1;
- SWEP.Primary.Automatic = true;
- SWEP.Primary.Force = 1000000000;
- SWEP.Primary.FireFromHip = true;
- SWEP.Primary.Weld = false;
- SWEP.Primary.Ammo = "ar2";
- SWEP.Primary.ExplosionShot = false;
- SWEP.Primary.BulletShot = true;
- SWEP.Primary.ModelShot = false;
- SWEP.Primary.BreakAll = false;
- SWEP.Primary.Ignite = false;
- SWEP.Primary.ClipSize = 100;
- SWEP.Primary.DefaultClip = 100;
- SWEP.Primary.Recoil = 0;
- SWEP.Primary.Damage = 1000000;
- SWEP.Primary.NumberofShots = 10;
- SWEP.Primary.Spread = 0.1;
- SWEP.Primary.Delay = 0.0001;
- SWEP.Primary.Model = "models/props_c17/FurnitureChair001a.mdl";
- SWEP.Primary.ExplosionSound = "weapon_AWP.Single";
- SWEP.Primary.ExplosionSoundDistance = 4000;
- SWEP.Primary.ExplosionSize = 1750;
- SWEP.Primary.TakeAmmo = 0;
- SWEP.Secondary.RPG = false
- SWEP.Secondary.RPGType = "bazooka_round"
- SWEP.Secondary.Sound = "weapons/mortar/mortar_fire1.wav"
- SWEP.Secondary.Tracer = 1;
- SWEP.Secondary.Force = 100;
- SWEP.Secondary.Automatic = false;
- SWEP.Secondary.FireFromHip = true;
- SWEP.Secondary.Weld = false;
- SWEP.Secondary.ExplosionShot = true;
- SWEP.Secondary.BulletShot = false;
- SWEP.Secondary.ModelShot = false;
- SWEP.Secondary.BreakAll = true;
- SWEP.Secondary.Zap = false;
- SWEP.Secondary.ZapRadius = 1500;
- SWEP.Secondary.ZapDamage = 30000;
- SWEP.Secondary.Ignite = true;
- SWEP.Secondary.Recoil = 0;
- SWEP.Secondary.Spread = 0.1;
- SWEP.Secondary.Delay = 0.01;
- SWEP.Secondary.Automatic = true;
- SWEP.Secondary.Sound = "weapons/mortar/mortar_fire1.wav";
- SWEP.Secondary.TakeAmmo = 0;
- SWEP.Secondary.Model = "models/props_c17/FurnitureChair001a.mdl";
- SWEP.Secondary.ExplosionSound = "weapon_AWP.Single";
- SWEP.Secondary.ExplosionSoundDistance = 400;
- SWEP.Secondary.ExplosionSize = 175;
- function SWEP:Initialize()
- util.PrecacheSound(self.Primary.Sound);
- util.PrecacheSound(self.Secondary.Sound);
- if ( SERVER ) then
- self:SetWeaponHoldType( self.HoldType );
- end
- end
- function SWEP:PrimaryAttack()
- if ( !self:CanPrimaryAttack() ) then return end
- //Default stuff, normally used in any condition.
- local tr = self.Owner:GetEyeTrace();
- self.Weapon:EmitSound ( self.Primary.Sound );
- self:ShootEffects();
- self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay );
- self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay ); self:TakePrimaryAmmo(self.Primary.TakeAmmo);
- local rnda = -self.Primary.Recoil;
- local rndb = self.Primary.Recoil * math.random(-1, 1);
- self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) );
- //The attack mode, can vary from the user settings
- if ( self.Primary.ModelShot ) then
- if (!SERVER) then return end;
- local ent = ents.Create ("prop_physics");
- ent:SetModel ( self.Primary.Model );
- if ( self.Primary.FireFromHip ) then
- ent:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 32));
- else
- ent:SetPos (tr.HitPos + self.Owner:GetAimVector() * -16);
- end
- ent:SetAngles (self.Owner:EyeAngles());
- ent:Spawn();
- local phys = ent:GetPhysicsObject();
- local shot_length = tr.HitPos:Length();
- if ( self.Primary.Weld ) then
- local weld = constraint.Weld( tr.Entity, ent, tr.PhysicsBone, 0, 0 );
- end
- phys:ApplyForceCenter (self.Owner:GetAimVector():GetNormalized() * math.pow (shot_length, 3));
- cleanup.Add (self.Owner, "props", ent);
- undo.Create ("Thrown model");
- undo.AddEntity (ent);
- undo.SetPlayer (self.Owner);
- undo.Finish();
- end if ( self.Primary.BulletShot ) then
- local bullet = {};
- bullet.Num = self.Primary.NumberofShots;
- bullet.Src = self.Owner:GetShootPos();
- bullet.Dir = self.Owner:GetAimVector();
- bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0);
- bullet.Tracer = self.Primary.Tracer;
- bullet.Force = self.Primary.Force;
- bullet.Damage = self.Primary.Damage;
- bullet.AmmoType = self.Primary.Ammo;
- self.Owner:FireBullets( bullet );
- end
- if ( self.Primary.ExplosionShot ) then
- local explode = ents.Create( "env_explosion" );
- explode:SetPos( tr.HitPos );
- explode:SetOwner( self.Owner );
- explode:Spawn();
- explode:SetKeyValue( "iMagnitude", self.Primary.ExplosionSize );
- explode:Fire( "Explode", 0, 0 );
- explode:EmitSound( self.Primary.ExplosionSound, self.Primary.ExplosionSoundDistance, self.Primary.ExplosionSoundDistance );
- end
- if ( self.Primary.BreakAll ) then
- if( tr.Entity:IsValid() and tr.Entity:GetClass() == "prop_physics" ) then
- constraint.RemoveAll( tr.Entity );
- local physobject = tr.Entity:GetPhysicsObject();
- physobject:EnableMotion( true );
- physobject:SetVelocity( self.Owner:GetAimVector() * 2 );
- end
- end
- if ( self.Primary.Zap ) then
- local vaporize = ents.Create ( "point_hurt" )
- vaporize:SetKeyValue ( "DamageRadius", self.Primary.ZapRadius )
- vaporize:SetKeyValue ( "Damage" , self.Primary.ZapDamage )
- vaporize:SetKeyValue ( "DamageDelay", 0 )
- vaporize:SetKeyValue ( "DamageType" ,"67108864" )
- vaporize:SetPos ( tr.HitPos )
- vaporize:Fire ( "TurnOn" , "", 0 )
- vaporize:Fire ( "TurnOff" , "", 0.5 )
- end
- if ( self.Primary.RPG ) then
- local shotpos = self.Owner:GetShootPos()
- shotpos = shotpos + self.Owner:GetForward() * 0
- shotpos = shotpos + self.Owner:GetRight() * 10
- shotpos = shotpos + self.Owner:GetUp() * -6
- local rocket = ents.Create("hl2_rocket")
- if (ValidEntity(rocket)) then
- rocket:SetPos(shotpos)
- rocket:SetOwner(self.Owner)
- rocket:Spawn()
- rocket.Owner = self.Owner
- local TF2Rocket = ents.Create("prop_dynamic")
- if (ValidEntity(TF2Rocket)) then
- TF2Rocket:SetPos(shotpos)
- TF2Rocket:SetModel( "models/weapons/w_missile.mdl" )
- TF2Rocket:Spawn()
- TF2Rocket:SetParent(rocket)
- end
- local b = ents.Create( "info_target" )
- if (ValidEntity(b)) then
- b:SetPos( self.Owner:GetEyeTrace( ).HitPos + Vector(0,0,0))
- b:Spawn( )
- rocket:PointAtEntity( b )
- b:Remove( )
- end
- end
- end
- if ( self.Primary.Ignite ) then
- if (!tr.Entity) then return false end
- if (!tr.Entity:IsValid() ) then return false end
- if (tr.Entity:IsPlayer()) then return false end
- if (tr.Entity:IsWorld()) then return false end
- if ( CLIENT ) then return true end
- local Time = math.random(20);
- tr.Entity:Extinguish();
- tr.Entity:Ignite( Time, 0 );
- end
- end
- function SWEP:SecondaryAttack()
- if ( !self:CanPrimaryAttack() ) then return end
- //Default stuff, normally used in any condition.
- local tr = self.Owner:GetEyeTrace();
- self.Weapon:EmitSound ( self.Secondary.Sound );
- self:ShootEffects();
- self.Weapon:SetNextPrimaryFire( CurTime() + self.Secondary.Delay );
- self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay );
- self:TakePrimaryAmmo(self.Secondary.TakeAmmo);
- local rnda = -self.Secondary.Recoil;
- local rndb = self.Secondary.Recoil * math.random(-1, 1);
- self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) );
- //The attack mode, can vary from the user settings
- if ( self.Secondary.ModelShot ) then
- if (!SERVER) then return end
- local ent = ents.Create ("prop_physics");
- ent:SetModel ( self.Secondary.Model );
- if ( self.Secondary.FireFromHip ) then
- ent:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 32));
- else
- ent:SetPos (tr.HitPos + self.Owner:GetAimVector() * -16);
- end
- ent:SetAngles (self.Owner:EyeAngles());
- ent:Spawn();
- local phys = ent:GetPhysicsObject();
- local shot_length = tr.HitPos:Length();
- if ( self.Secondary.Weld ) then
- local weld = constraint.Weld( tr.Entity, ent, tr.PhysicsBone, 0, 0 );
- end
- phys:ApplyForceCenter (self.Owner:GetAimVector():GetNormalized() * math.pow (shot_length, 3));
- cleanup.Add (self.Owner, "props", ent);
- undo.Create ("Thrown model");
- undo.AddEntity (ent);
- undo.SetPlayer (self.Owner);
- undo.Finish();
- end if (self.Secondary.BulletShot ) then
- local bullet = {};
- bullet.Num = self.Secondary.NumberofShots;
- bullet.Src = self.Owner:GetShootPos();
- bullet.Dir = self.Owner:GetAimVector();
- bullet.Spread = Vector( self.Secondary.Spread * 0.1 , self.Secondary.Spread * 0.1, 0);
- bullet.Tracer = self.Secondary.Tracer;
- bullet.Force = self.Secondary.Force;
- bullet.Damage = self.Secondary.Damage;
- bullet.AmmoType = self.Primary.Ammo;
- self.Owner:FireBullets( bullet );
- end
- if ( self.Secondary.Zap ) then
- local vaporize = ents.Create ( "point_hurt" )
- vaporize:SetKeyValue ( "DamageRadius", self.Secondary.ZapRadius )
- vaporize:SetKeyValue ( "Damage" , self.Secondary.ZapDamage )
- vaporize:SetKeyValue ( "DamageDelay", 0 )
- vaporize:SetKeyValue ( "DamageType" ,"67108864" )
- vaporize:SetPos ( tr.HitPos )
- vaporize:Fire ( "TurnOn" , "", 0 )
- vaporize:Fire ( "TurnOff" , "", 0.5 )
- end
- if ( self.Secondary.ExplosionShot ) then
- local explode = ents.Create( "env_explosion" );
- explode:SetPos( tr.HitPos );
- explode:SetOwner( self.Owner );
- explode:Spawn();
- explode:SetKeyValue( "iMagnitude", self.Secondary.ExplosionSize );
- explode:Fire( "Explode", 0, 0 );
- explode:EmitSound( self.Secondary.ExplosionSound, self.Secondary.ExplosionSoundDistance, self.Secondary.ExplosionSoundDistance );
- end
- if ( self.Secondary.BreakAll ) then
- if( tr.Entity:IsValid() and tr.Entity:GetClass() == "prop_physics" ) then
- constraint.RemoveAll( tr.Entity );
- local physobject = tr.Entity:GetPhysicsObject();
- physobject:EnableMotion( true );
- physobject:SetVelocity( self.Owner:GetAimVector() * 2 );
- end
- end
- if ( self.Secondary.RPG ) then
- local shotpos = self.Owner:GetShootPos()
- shotpos = shotpos + self.Owner:GetForward() * 0
- shotpos = shotpos + self.Owner:GetRight() * 10
- shotpos = shotpos + self.Owner:GetUp() * -6
- local rocket = ents.Create("hl2_rocket")
- if (ValidEntity(rocket)) then
- rocket:SetPos(shotpos)
- rocket:SetOwner(self.Owner)
- rocket:Spawn()
- rocket.Owner = self.Owner
- local TF2Rocket = ents.Create("prop_dynamic")
- if (ValidEntity(TF2Rocket)) then
- TF2Rocket:SetPos(shotpos)
- TF2Rocket:SetModel( "models/weapons/w_missile.mdl" )
- TF2Rocket:Spawn()
- TF2Rocket:SetParent(rocket)
- end
- local b = ents.Create( "info_target" )
- if (ValidEntity(b)) then
- b:SetPos( self.Owner:GetEyeTrace( ).HitPos + Vector(0,0,0))
- b:Spawn( )
- rocket:PointAtEntity( b )
- b:Remove( )
- end
- end
- end
- if ( self.Secondary.Ignite ) then
- if (!tr.Entity) then return false end
- if (!tr.Entity:IsValid() ) then return false end
- if (tr.Entity:IsPlayer()) then return false end
- if (tr.Entity:IsWorld()) then return false end
- if ( CLIENT ) then return true end
- local Time = math.random(20);
- tr.Entity:Extinguish();
- tr.Entity:Ignite( Time, 0 ); end
- end
- function SWEP:Think()
- end
- function SWEP:Reload()
- self.Weapon:DefaultReload(ACT_VM_RELOAD);
- return true
- end
- function SWEP:Deploy()
- self.Weapon:SendWeaponAnim(ACT_VM_DRAW);
- return true
- end
- function SWEP:Holster()
- return true
- end
- function SWEP:OnRemove()
- end
- function SWEP:OnRestore()
- end
- function SWEP:Precache()
- end
- function SWEP:OwnerChanged()
- end
- end
- -- more hooks can be found at http://wiki.garrysmod.com/?title=Weapon_Hooks
- weapons.Register(SWEP, SWEP.ClassName, true)
- -- uncomment this if you want to make it update without the need to respawn it
- --for key, entity in pairs(ents.FindByClass(SWEP.ClassName)) do
- -- table.Merge(entity:GetTable(), SWEP)
- -- entity:Initialize() -- this will call SWEP:Initialize()
- --end
- if SERVER then
- me:Give(SWEP.ClassName)
- end
- easylua.End()
Advertisement
Add Comment
Please, Sign In to add comment