From 87416106eb3df619f464441fb4f5dbd31cd3aff3 Mon Sep 17 00:00:00 2001 From: stickz Date: Fri, 29 Apr 2016 21:00:17 -0400 Subject: [PATCH 1/6] Add Base GlowStick Class --- .../weapon_mor_base_glowstick/shared.lua | 186 ++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_mor_base_glowstick/shared.lua diff --git a/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_mor_base_glowstick/shared.lua b/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_mor_base_glowstick/shared.lua new file mode 100644 index 0000000..d37db31 --- /dev/null +++ b/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_mor_base_glowstick/shared.lua @@ -0,0 +1,186 @@ +/*--------------------------------------------------------- +The base class for glowsticks! +---------------------------------------------------------*/ +if (SERVER) then + AddCSLuaFile("shared.lua") +end + +if ( CLIENT ) then + SWEP.DrawCrosshair = true + SWEP.ViewModelFOV = 70 + SWEP.ViewModelFlip = false + SWEP.CSMuzzleFlashes = false + SWEP.PrintName = "Glow Sticks" + SWEP.Slot = WEAPON_GLOWSTICK - 1 + SWEP.SlotPos = 0 +end + +SWEP.EntName = "ent_glowstick" +SWEP.FlyEntName = "ent_glowstick_fly" + +SWEP.ViewModel = "models/glowstick/v_glowstick.mdl" +SWEP.WorldModel = "models/glowstick/stick.mdl" + +SWEP.PrimaryAttackVector = Vector(math.random(-100,100),math.random(-100,100),math.random(-100,100)) +SWEP.SecondaryAttackVector = Vector(0,0,0) +SWEP.DropOnSpot = 30 + +--these two values have overrides in the gravity stick class +SWEP.PropelForwardSpeed = 600 +SWEP.UseGravity = true +SWEP.Primary.ClipSize = 6 +SWEP.Primary.DefaultClip = 6 + +SWEP.Spawnable = false +SWEP.AdminSpawnable = false +SWEP.HoldType = "normal" + +SWEP.Primary.Automatic = false +SWEP.Primary.Ammo = "none" +SWEP.Primary.Delay = 1 + +SWEP.Secondary.ClipSize = -1 +SWEP.Secondary.DefaultClip = -1 +SWEP.Secondary.Automatic = false +SWEP.Secondary.Ammo = "none" + +SWEP.AllowDrop = true +SWEP.Kind = WEAPON_GLOWSTICK +SWEP.KGWeight = 8 +SWEP.AutoSpawnable = true +SWEP.StoredAmmo = 0 + +function SWEP:Initialize() + self:SetWeaponHoldType( self.HoldType ) +end + +function SWEP:PrimaryAttack() + self:BeforeAttack() + self:DuringAttack(self.FlyEntName, self.PrimaryAttackVector, self.PropelForwardSpeed ) + self:AfterAttack(self.EntName, self.WepName, self.Owner) +end + +function SWEP:SecondaryAttack() + self:BeforeAttack() + self:DuringAttack(self.FlyEntName, self.SecondaryAttackVector, self.DropOnSpot ) + self:AfterAttack(self.EntName, self.WepName, self.Owner) +end + +function SWEP:Deploy() + self.Weapon:SendWeaponAnim(ACT_VM_DRAW) + + if SERVER then + self.Owner:DrawWorldModel(false) + + local ent = ents.Create(self.EntName) + ent:SetOwner(self.Owner) + ent:SetParent(self.Owner) + ent:SetPos(self.Owner:GetPos()) + ent:SetColor(self.Owner:GetColor()) + ent:SetMaterial(self.Owner:GetMaterial()) + ent:Spawn() + end +end + +function RemoveGlowStick(name, owner) + local worldmodel = ents.FindInSphere(owner:GetPos(),0.6) + for k, v in pairs(worldmodel) do + if v:GetClass() == name and v:GetOwner() == owner then + v:Remove() + end + end +end + +function SWEP:Holster() + if !self.Owner then return end + if !IsValid(self.Owner) then return end + + RemoveGlowStick(self.EntName, self.Owner) + return true +end + +function SWEP:PreDrop() + if SERVER and ValidEntity(self.Owner) and self.Primary.Ammo != "none" then + local ammo = self:Ammo1() + + -- Do not drop ammo if we have another gun that uses this type + for _, w in pairs(self.Owner:GetWeapons()) do + if ValidEntity(w) and w != self and w:GetPrimaryAmmoType() == self:GetPrimaryAmmoType() then + ammo = 0 + end + end + + self.StoredAmmo = ammo + + if ammo > 0 then + self.Owner:RemoveAmmo(ammo, self.Primary.Ammo) + end + end + + RemoveGlowStick(self.EntName, self.Owner) +end + +function SWEP:BeforeAttack() + self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) + self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay) + self:TakePrimaryAmmo(1) + self.Weapon:SendWeaponAnim( ACT_VM_THROW ) // View model animation + self.Owner:SetAnimation( PLAYER_ATTACK1 ) +end + +function SWEP:DuringAttack(name, vec, speed) + if SERVER then + local ent = ents.Create(name) + + ent:SetPos(self.Owner:GetShootPos()) + ent:SetAngles(Angle(1,0,0)) + ent:Spawn() + + local phys = ent:GetPhysicsObject() + phys:SetVelocity(self.Owner:GetAimVector() * speed) + phys:AddAngleVelocity(vec) + + phys:EnableGravity( self.UseGravity ) + end + + self.Weapon:SendWeaponAnim(ACT_VM_DRAW) +end + +function SWEP:AfterAttack(entName, wepName, owner) + if self.Weapon:Clip1() < 1 && SERVER then + RemoveGlowStick(entName, owner) + self.Owner:StripWeapon(wepName) + end +end + +function SWEP:Ammo1() + return ValidEntity(self.Owner) and self.Owner:GetAmmoCount(self.Primary.Ammo) or false +end + +function SWEP:DampenDrop() + local phys = self:GetPhysicsObject() + if IsValid(phys) then + phys:SetVelocityInstantaneous(Vector(0,0,-75) + phys:GetVelocity() * 0.001) + phys:AddAngleVelocity(phys:GetAngleVelocity() * -0.99) + end +end + +function SWEP:Equip(newowner) + if SERVER then + if self:IsOnFire() then + self:Extinguish() + end + + if ValidEntity(newowner) and self.StoredAmmo > 0 and self.Primary.Ammo != "none" then + local ammo = newowner:GetAmmoCount(self.Primary.Ammo) + local given = math.min(self.StoredAmmo, (self.Primary.ClipSize*3) - ammo) + + newowner:GiveAmmo( given, self.Primary.Ammo) + self.StoredAmmo = 0 + end + end +end + +function SWEP:IsEquipment() + return WEPS.IsEquipment(self) +end From cad771ac66cacd0fb5ae10668d25c3410c40a6bb Mon Sep 17 00:00:00 2001 From: stickz Date: Fri, 29 Apr 2016 21:03:36 -0400 Subject: [PATCH 2/6] Inherit Stickies from Base Class --- .../weapon_glowstick_sticky/shared.lua | 200 +----------------- 1 file changed, 6 insertions(+), 194 deletions(-) diff --git a/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick_sticky/shared.lua b/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick_sticky/shared.lua index 55a8349..68473e2 100644 --- a/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick_sticky/shared.lua +++ b/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick_sticky/shared.lua @@ -1,202 +1,14 @@ -if (SERVER) then - AddCSLuaFile("shared.lua") -end - if ( CLIENT ) then - SWEP.DrawCrosshair = true - SWEP.ViewModelFOV = 70 - SWEP.ViewModelFlip = false - SWEP.CSMuzzleFlashes = false SWEP.PrintName = "Sticky Glow Sticks" - SWEP.Slot = 4 - SWEP.SlotPos = 0 end +SWEP.Base = "weapon_mor_base_glowstick" -SWEP.Spawnable = false -SWEP.AdminSpawnable = false -SWEP.HoldType = "normal" +--EntName & FlyEntName overrides +SWEP.EntName = "ent_sglowstick" +SWEP.FlyEntName = "ent_sglowstick_fly" +SWEP.WepName = "weapon_glowstick_sticky" +--ViewModel and WorldModel overrides SWEP.ViewModel = "models/glowstick/v_glowstick_rng.mdl" SWEP.WorldModel = "models/glowstick/stick_rng.mdl" - -SWEP.Primary.ClipSize = 3 -SWEP.Primary.DefaultClip = 3 -SWEP.Primary.Automatic = false -SWEP.Primary.Ammo = "none" -SWEP.Primary.Delay = 1 - -SWEP.Secondary.ClipSize = -1 -SWEP.Secondary.DefaultClip = -1 -SWEP.Secondary.Automatic = false -SWEP.Secondary.Ammo = "none" - -SWEP.AllowDrop = true -SWEP.Kind = WEAPON_MISC -SWEP.KGWeight = 8 -SWEP.AutoSpawnable = true -SWEP.StoredAmmo = 0 - -function SWEP:Think() -end - -function SWEP:Initialize() - self:SetWeaponHoldType( self.HoldType ) -end - -function SWEP:Deploy() - self.Weapon:SendWeaponAnim(ACT_VM_DRAW) - if SERVER then - self.Owner:DrawWorldModel(false) - self.Owner:DrawWorldModel(false) - - local ent = ents.Create("ent_sglowstick") - ent:SetOwner(self.Owner) - ent:SetParent(self.Owner) - ent:SetPos(self.Owner:GetPos()) - ent:SetColor(self.Owner:GetColor()) - ent:SetMaterial(self.Owner:GetMaterial()) - ent:Spawn() - end - - -end - -function SWEP:Reload() -end - -function SWEP:PrimaryAttack() - self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) - self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay) - self:TakePrimaryAmmo(1) - self.Weapon:SendWeaponAnim( ACT_VM_THROW ) // View model animation - self.Owner:SetAnimation( PLAYER_ATTACK1 ) // 3rd Person Animation - if SERVER then - local ent = ents.Create("ent_sglowstick_fly") - - ent:SetPos(self.Owner:GetShootPos()) - ent:SetAngles(Angle(1,0,0)) - ent:Spawn() - - local phys = ent:GetPhysicsObject() - phys:SetVelocity(self.Owner:GetAimVector() * 600) - phys:AddAngleVelocity(Vector(math.random(-100,100),math.random(-100,100),math.random(-100,100))) - end - self.Weapon:SendWeaponAnim(ACT_VM_DRAW) - if self.Weapon:Clip1() < 1 && SERVER then - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_sglowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end - self.Owner:StripWeapon("weapon_glowstick_sticky") - end - -end -function SWEP:SecondaryAttack() - self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) - self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay) - self:TakePrimaryAmmo(1) - self.Weapon:SendWeaponAnim( ACT_VM_THROW ) // View model animation - self.Owner:SetAnimation( PLAYER_ATTACK1 ) - if SERVER then - local ent = ents.Create("ent_sglowstick_fly") - - ent:SetPos(self.Owner:GetShootPos()) - ent:SetAngles(Angle(1,0,0)) - ent:Spawn() - - local phys = ent:GetPhysicsObject() - phys:SetVelocity(self.Owner:GetAimVector() * 30) - phys:AddAngleVelocity(Vector(0,0,0)) - end - self.Weapon:SendWeaponAnim(ACT_VM_DRAW) - if self.Weapon:Clip1() < 1 && SERVER then - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_sglowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end - self.Owner:StripWeapon("weapon_glowstick_sticky") - end - -end - -function SWEP:Holster() - if !self.Owner then return end - if !IsValid(self.Owner) then return end - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_sglowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end - - return true - -end - - -function SWEP:Ammo1() - return ValidEntity(self.Owner) and self.Owner:GetAmmoCount(self.Primary.Ammo) or false -end - - -function SWEP:PreDrop() - if SERVER and ValidEntity(self.Owner) and self.Primary.Ammo != "none" then - local ammo = self:Ammo1() - - -- Do not drop ammo if we have another gun that uses this type - for _, w in pairs(self.Owner:GetWeapons()) do - if ValidEntity(w) and w != self and w:GetPrimaryAmmoType() == self:GetPrimaryAmmoType() then - ammo = 0 - end - end - - self.StoredAmmo = ammo - - if ammo > 0 then - self.Owner:RemoveAmmo(ammo, self.Primary.Ammo) - end - - - - end - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_sglowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end -end - -function SWEP:DampenDrop() - local phys = self:GetPhysicsObject() - if IsValid(phys) then - phys:SetVelocityInstantaneous(Vector(0,0,-75) + phys:GetVelocity() * 0.001) - phys:AddAngleVelocity(phys:GetAngleVelocity() * -0.99) - end -end - - -function SWEP:Equip(newowner) - if SERVER then - if self:IsOnFire() then - self:Extinguish() - end - end - - if SERVER and ValidEntity(newowner) and self.StoredAmmo > 0 and self.Primary.Ammo != "none" then - local ammo = newowner:GetAmmoCount(self.Primary.Ammo) - local given = math.min(self.StoredAmmo, (self.Primary.ClipSize*3) - ammo) - - newowner:GiveAmmo( given, self.Primary.Ammo) - self.StoredAmmo = 0 - end -end - -function SWEP:IsEquipment() - return WEPS.IsEquipment(self) -end \ No newline at end of file From 0c5a9e7201923d5330f6b6d00ffb0be3d16dedab Mon Sep 17 00:00:00 2001 From: stickz Date: Fri, 29 Apr 2016 21:04:14 -0400 Subject: [PATCH 3/6] Inherit Specials from Base Class --- .../weapon_glowstick_special/shared.lua | 204 +----------------- 1 file changed, 5 insertions(+), 199 deletions(-) diff --git a/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick_special/shared.lua b/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick_special/shared.lua index 72cc35f..344bd29 100644 --- a/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick_special/shared.lua +++ b/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick_special/shared.lua @@ -1,202 +1,8 @@ -if (SERVER) then - AddCSLuaFile("shared.lua") -end +SWEP.Base = "weapon_mor_base_glowstick" -if ( CLIENT ) then - SWEP.DrawCrosshair = true - SWEP.ViewModelFOV = 70 - SWEP.ViewModelFlip = false - SWEP.CSMuzzleFlashes = false - SWEP.PrintName = "Glow Sticks" - SWEP.Slot = 4 - SWEP.SlotPos = 0 -end +SWEP.WepName = "weapon_glowstick_special" - -SWEP.Spawnable = false -SWEP.AdminSpawnable = false -SWEP.HoldType = "normal" - -SWEP.ViewModel = "models/glowstick/v_glowstick.mdl" -SWEP.WorldModel = "models/glowstick/stick.mdl" - -SWEP.Primary.ClipSize = 5 -SWEP.Primary.DefaultClip = 5 -SWEP.Primary.Automatic = false -SWEP.Primary.Ammo = "none" -SWEP.Primary.Delay = 1 - -SWEP.Secondary.ClipSize = -1 -SWEP.Secondary.DefaultClip = -1 -SWEP.Secondary.Automatic = false -SWEP.Secondary.Ammo = "none" - -SWEP.AllowDrop = true -SWEP.Kind = WEAPON_MISC -SWEP.KGWeight = 0 -SWEP.AutoSpawnable = true -SWEP.StoredAmmo = 0 +--special glow sticks have a higher clipsize and NeverRandom +SWEP.Primary.ClipSize = 8 +SWEP.Primary.DefaultClip = 8 SWEP.NeverRandom = true - -function SWEP:Think() -end - -function SWEP:Initialize() - self:SetWeaponHoldType( self.HoldType ) -end - -function SWEP:Deploy() - self.Weapon:SendWeaponAnim(ACT_VM_DRAW) - if SERVER then - self.Owner:DrawWorldModel(false) - self.Owner:DrawWorldModel(false) - - local ent = ents.Create("ent_glowstick") - ent:SetOwner(self.Owner) - ent:SetParent(self.Owner) - ent:SetPos(self.Owner:GetPos()) - ent:SetColor(self.Owner:GetColor()) - ent:SetMaterial(self.Owner:GetMaterial()) - ent:Spawn() - end -end - -function SWEP:Reload() -end - -function SWEP:PrimaryAttack() - self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) - self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay) - self:TakePrimaryAmmo(1) - self.Weapon:SendWeaponAnim( ACT_VM_THROW ) // View model animation - self.Owner:SetAnimation( PLAYER_ATTACK1 ) // 3rd Person Animation - if SERVER then - local ent = ents.Create("ent_glowstick_fly") - - ent:SetPos(self.Owner:GetShootPos()) - ent:SetAngles(Angle(1,0,0)) - ent:Spawn() - - local phys = ent:GetPhysicsObject() - phys:SetVelocity(self.Owner:GetAimVector() * 600) - phys:AddAngleVelocity(Vector(math.random(-100,100),math.random(-100,100),math.random(-100,100))) - end - self.Weapon:SendWeaponAnim(ACT_VM_DRAW) - if self.Weapon:Clip1() < 1 && SERVER then - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_glowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end - self.Owner:StripWeapon("weapon_glowstick_special") - end - -end -function SWEP:SecondaryAttack() - self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) - self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay) - self:TakePrimaryAmmo(1) - self.Weapon:SendWeaponAnim( ACT_VM_THROW ) // View model animation - self.Owner:SetAnimation( PLAYER_ATTACK1) - if SERVER then - local ent = ents.Create("ent_glowstick_fly") - - ent:SetPos(self.Owner:GetShootPos()) - ent:SetAngles(Angle(1,0,0)) - ent:Spawn() - - local phys = ent:GetPhysicsObject() - phys:SetVelocity(self.Owner:GetAimVector() * 30) - phys:AddAngleVelocity(Vector(0,0,0)) - end - self.Weapon:SendWeaponAnim(ACT_VM_DRAW) - if self.Weapon:Clip1() < 1 && SERVER then - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_glowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end - self.Owner:StripWeapon("weapon_glowstick_special") - end - -end - -function SWEP:Holster() - if !self.Owner then return end - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_glowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end - return true - -end - -function SWEP:OnRemove() - return true -end - -function SWEP:Ammo1() - return ValidEntity(self.Owner) and self.Owner:GetAmmoCount(self.Primary.Ammo) or false -end - - -function SWEP:PreDrop() - if SERVER and ValidEntity(self.Owner) and self.Primary.Ammo != "none" then - local ammo = self:Ammo1() - - -- Do not drop ammo if we have another gun that uses this type - for _, w in pairs(self.Owner:GetWeapons()) do - if ValidEntity(w) and w != self and w:GetPrimaryAmmoType() == self:GetPrimaryAmmoType() then - ammo = 0 - end - end - - self.StoredAmmo = ammo - - if ammo > 0 then - self.Owner:RemoveAmmo(ammo, self.Primary.Ammo) - end - - - - end - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_glowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end -end - -function SWEP:DampenDrop() - local phys = self:GetPhysicsObject() - if IsValid(phys) then - phys:SetVelocityInstantaneous(Vector(0,0,-75) + phys:GetVelocity() * 0.001) - phys:AddAngleVelocity(phys:GetAngleVelocity() * -0.99) - end -end - - -function SWEP:Equip(newowner) - if SERVER then - if self:IsOnFire() then - self:Extinguish() - end - end - - if SERVER and ValidEntity(newowner) and self.StoredAmmo > 0 and self.Primary.Ammo != "none" then - local ammo = newowner:GetAmmoCount(self.Primary.Ammo) - local given = math.min(self.StoredAmmo, (self.Primary.ClipSize*3) - ammo) - - newowner:GiveAmmo( given, self.Primary.Ammo) - self.StoredAmmo = 0 - end -end - -function SWEP:IsEquipment() - return WEPS.IsEquipment(self) -end \ No newline at end of file From 5e01ca31d8cf0ddfd0aeaae5e33798fcff6c2998 Mon Sep 17 00:00:00 2001 From: stickz Date: Fri, 29 Apr 2016 21:04:49 -0400 Subject: [PATCH 4/6] Inherit Gravs from Base Class --- .../weapons/weapon_glowstick_grav/shared.lua | 211 +----------------- 1 file changed, 12 insertions(+), 199 deletions(-) diff --git a/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick_grav/shared.lua b/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick_grav/shared.lua index 1cb192b..ab02d78 100644 --- a/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick_grav/shared.lua +++ b/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick_grav/shared.lua @@ -1,207 +1,20 @@ -if (SERVER) then - AddCSLuaFile("shared.lua") -end - if ( CLIENT ) then - SWEP.DrawCrosshair = true - SWEP.ViewModelFOV = 70 - SWEP.ViewModelFlip = false - SWEP.CSMuzzleFlashes = false SWEP.PrintName = "Grav Sticks" - SWEP.Slot = 4 - SWEP.SlotPos = 0 end +SWEP.Base = "weapon_mor_base_glowstick" + +--override these value for grav sticks +SWEP.PropelForwardSpeed = 300 +SWEP.UseGravity = false +SWEP.Primary.ClipSize = 4 +SWEP.Primary.DefaultClip = 4 -SWEP.Spawnable = false -SWEP.AdminSpawnable = false -SWEP.HoldType = "normal" +--EntName & FlyEntName overrides +SWEP.EntName = "ent_bglowstick" +SWEP.FlyEntName = "ent_bglowstick_fly" +SWEP.WepName = "weapon_glowstick_grav" +--ViewModel and WorldModel overrides SWEP.ViewModel = "models/glowstick/v_glowstick_lblu.mdl" SWEP.WorldModel = "models/glowstick/stick_lblu.mdl" - -SWEP.Primary.ClipSize = 2 -SWEP.Primary.DefaultClip = 2 -SWEP.Primary.Automatic = false -SWEP.Primary.Ammo = "none" -SWEP.Primary.Damage = 0 -SWEP.Primary.Cone = 0 -SWEP.Primary.Recoil = 0 -SWEP.Primary.Delay = 1 - -SWEP.Secondary.ClipSize = -1 -SWEP.Secondary.DefaultClip = -1 -SWEP.Secondary.Automatic = false -SWEP.Secondary.Ammo = "none" - -SWEP.AllowDrop = true -SWEP.Kind = WEAPON_MISC -SWEP.KGWeight = 8 -SWEP.AutoSpawnable = true -SWEP.StoredAmmo = 0 - -function SWEP:Think() -end - -function SWEP:Initialize() - self:SetWeaponHoldType( self.HoldType ) -end - -function SWEP:Deploy() - self.Weapon:SendWeaponAnim(ACT_VM_DRAW) - if SERVER then - self.Owner:DrawWorldModel(false) - self.Owner:DrawWorldModel(false) - - local ent = ents.Create("ent_bglowstick") - ent:SetOwner(self.Owner) - ent:SetParent(self.Owner) - ent:SetPos(self.Owner:GetPos()) - ent:SetColor(self.Owner:GetColor()) - ent:SetMaterial(self.Owner:GetMaterial()) - ent:Spawn() - end - - -end - -function SWEP:Reload() -end - -function SWEP:PrimaryAttack() - self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) - self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay) - self:TakePrimaryAmmo(1) - self.Weapon:SendWeaponAnim( ACT_VM_THROW ) // View model animation - self.Owner:SetAnimation( PLAYER_ATTACK1 ) // 3rd Person Animation - if SERVER then - local ent = ents.Create("ent_bglowstick_fly") - - ent:SetPos(self.Owner:GetShootPos()) - ent:SetAngles(Angle(1,0,0)) - ent:Spawn() - - local phys = ent:GetPhysicsObject() - phys:SetVelocity(self.Owner:GetAimVector() * 300) - phys:AddAngleVelocity(Vector(math.random(-100,100),math.random(-100,100),math.random(-100,100))) - phys:EnableGravity( false ) - end - self.Weapon:SendWeaponAnim(ACT_VM_DRAW) - if self.Weapon:Clip1() < 1 && SERVER then - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_bglowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end - self.Owner:StripWeapon("weapon_glowstick_grav") - end - -end -function SWEP:SecondaryAttack() - self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) - self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay) - self:TakePrimaryAmmo(1) - self.Weapon:SendWeaponAnim( ACT_VM_THROW ) // View model animation - self.Owner:SetAnimation( PLAYER_ATTACK1 ) - if SERVER then - local ent = ents.Create("ent_bglowstick_fly") - - ent:SetPos(self.Owner:GetShootPos()) - ent:SetAngles(Angle(1,0,0)) - ent:Spawn() - - local phys = ent:GetPhysicsObject() - phys:SetVelocity(self.Owner:GetAimVector() * 30) - phys:AddAngleVelocity(Vector(0,0,0)) - phys:EnableGravity( false ) - end - self.Weapon:SendWeaponAnim(ACT_VM_DRAW) - if self.Weapon:Clip1() < 1 && SERVER then - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_bglowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end - self.Owner:StripWeapon("weapon_glowstick_grav") - end - -end - -function SWEP:Holster() - if !self.Owner then return end - if !IsValid(self.Owner) then return end - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_bglowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end - - return true - -end - - -function SWEP:Ammo1() - return ValidEntity(self.Owner) and self.Owner:GetAmmoCount(self.Primary.Ammo) or false -end - - -function SWEP:PreDrop() - if SERVER and ValidEntity(self.Owner) and self.Primary.Ammo != "none" then - local ammo = self:Ammo1() - - -- Do not drop ammo if we have another gun that uses this type - for _, w in pairs(self.Owner:GetWeapons()) do - if ValidEntity(w) and w != self and w:GetPrimaryAmmoType() == self:GetPrimaryAmmoType() then - ammo = 0 - end - end - - self.StoredAmmo = ammo - - if ammo > 0 then - self.Owner:RemoveAmmo(ammo, self.Primary.Ammo) - end - - - - end - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_bglowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end -end - -function SWEP:DampenDrop() - local phys = self:GetPhysicsObject() - if IsValid(phys) then - phys:SetVelocityInstantaneous(Vector(0,0,-75) + phys:GetVelocity() * 0.001) - phys:AddAngleVelocity(phys:GetAngleVelocity() * -0.99) - end -end - - -function SWEP:Equip(newowner) - if SERVER then - if self:IsOnFire() then - self:Extinguish() - end - end - - if SERVER and ValidEntity(newowner) and self.StoredAmmo > 0 and self.Primary.Ammo != "none" then - local ammo = newowner:GetAmmoCount(self.Primary.Ammo) - local given = math.min(self.StoredAmmo, (self.Primary.ClipSize*3) - ammo) - - newowner:GiveAmmo( given, self.Primary.Ammo) - self.StoredAmmo = 0 - end -end - -function SWEP:IsEquipment() - return WEPS.IsEquipment(self) -end \ No newline at end of file From d08f85579a59d9da690d95bdcf87b5770a1ba6ac Mon Sep 17 00:00:00 2001 From: stickz Date: Fri, 29 Apr 2016 21:05:33 -0400 Subject: [PATCH 5/6] Inherit Normals from Base Class --- .../weapons/weapon_glowstick/shared.lua | 204 +----------------- 1 file changed, 2 insertions(+), 202 deletions(-) diff --git a/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick/shared.lua b/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick/shared.lua index 3758d17..5aeac76 100644 --- a/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick/shared.lua +++ b/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_glowstick/shared.lua @@ -1,202 +1,2 @@ -if (SERVER) then - AddCSLuaFile("shared.lua") -end - -if ( CLIENT ) then - SWEP.DrawCrosshair = true - SWEP.ViewModelFOV = 70 - SWEP.ViewModelFlip = false - SWEP.CSMuzzleFlashes = false - SWEP.PrintName = "Glow Sticks" - SWEP.Slot = 4 - SWEP.SlotPos = 0 -end - - -SWEP.Spawnable = false -SWEP.AdminSpawnable = false -SWEP.HoldType = "normal" - -SWEP.ViewModel = "models/glowstick/v_glowstick.mdl" -SWEP.WorldModel = "models/glowstick/stick.mdl" - -SWEP.Primary.ClipSize = 3 -SWEP.Primary.DefaultClip = 3 -SWEP.Primary.Automatic = false -SWEP.Primary.Ammo = "none" -SWEP.Primary.Delay = 1 - -SWEP.Secondary.ClipSize = -1 -SWEP.Secondary.DefaultClip = -1 -SWEP.Secondary.Automatic = false -SWEP.Secondary.Ammo = "none" - -SWEP.AllowDrop = true -SWEP.Kind = WEAPON_MISC -SWEP.KGWeight = 8 -SWEP.AutoSpawnable = true -SWEP.StoredAmmo = 0 - -function SWEP:Think() -end - -function SWEP:Initialize() - self:SetWeaponHoldType( self.HoldType ) -end - -function SWEP:Deploy() - self.Weapon:SendWeaponAnim(ACT_VM_DRAW) - if SERVER then - self.Owner:DrawWorldModel(false) - self.Owner:DrawWorldModel(false) - - local ent = ents.Create("ent_glowstick") - ent:SetOwner(self.Owner) - ent:SetParent(self.Owner) - ent:SetPos(self.Owner:GetPos()) - ent:SetColor(self.Owner:GetColor()) - ent:SetMaterial(self.Owner:GetMaterial()) - ent:Spawn() - end - - -end - -function SWEP:Reload() -end - -function SWEP:PrimaryAttack() - self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) - self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay) - self:TakePrimaryAmmo(1) - self.Weapon:SendWeaponAnim( ACT_VM_THROW ) // View model animation - self.Owner:SetAnimation( PLAYER_ATTACK1 ) // 3rd Person Animation - if SERVER then - local ent = ents.Create("ent_glowstick_fly") - - ent:SetPos(self.Owner:GetShootPos()) - ent:SetAngles(Angle(1,0,0)) - ent:Spawn() - - local phys = ent:GetPhysicsObject() - phys:SetVelocity(self.Owner:GetAimVector() * 600) - phys:AddAngleVelocity(Vector(math.random(-100,100),math.random(-100,100),math.random(-100,100))) - end - self.Weapon:SendWeaponAnim(ACT_VM_DRAW) - if self.Weapon:Clip1() < 1 && SERVER then - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_glowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end - self.Owner:StripWeapon("weapon_glowstick") - end - -end -function SWEP:SecondaryAttack() - self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) - self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay) - self:TakePrimaryAmmo(1) - self.Weapon:SendWeaponAnim( ACT_VM_THROW ) // View model animation - self.Owner:SetAnimation( PLAYER_ATTACK1 ) - if SERVER then - local ent = ents.Create("ent_glowstick_fly") - - ent:SetPos(self.Owner:GetShootPos()) - ent:SetAngles(Angle(1,0,0)) - ent:Spawn() - - local phys = ent:GetPhysicsObject() - phys:SetVelocity(self.Owner:GetAimVector() * 30) - phys:AddAngleVelocity(Vector(0,0,0)) - end - self.Weapon:SendWeaponAnim(ACT_VM_DRAW) - if self.Weapon:Clip1() < 1 && SERVER then - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_glowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end - self.Owner:StripWeapon("weapon_glowstick") - end - -end - -function SWEP:Holster() - if !self.Owner then return end - if !IsValid(self.Owner) then return end - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_glowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end - - return true - -end - - -function SWEP:Ammo1() - return ValidEntity(self.Owner) and self.Owner:GetAmmoCount(self.Primary.Ammo) or false -end - - -function SWEP:PreDrop() - if SERVER and ValidEntity(self.Owner) and self.Primary.Ammo != "none" then - local ammo = self:Ammo1() - - -- Do not drop ammo if we have another gun that uses this type - for _, w in pairs(self.Owner:GetWeapons()) do - if ValidEntity(w) and w != self and w:GetPrimaryAmmoType() == self:GetPrimaryAmmoType() then - ammo = 0 - end - end - - self.StoredAmmo = ammo - - if ammo > 0 then - self.Owner:RemoveAmmo(ammo, self.Primary.Ammo) - end - - - - end - local worldmodel = ents.FindInSphere(self.Owner:GetPos(),0.6) - for k, v in pairs(worldmodel) do - if v:GetClass() == "ent_glowstick" and v:GetOwner() == self.Owner then - v:Remove() - end - end -end - -function SWEP:DampenDrop() - local phys = self:GetPhysicsObject() - if IsValid(phys) then - phys:SetVelocityInstantaneous(Vector(0,0,-75) + phys:GetVelocity() * 0.001) - phys:AddAngleVelocity(phys:GetAngleVelocity() * -0.99) - end -end - - -function SWEP:Equip(newowner) - if SERVER then - if self:IsOnFire() then - self:Extinguish() - end - end - - if SERVER and ValidEntity(newowner) and self.StoredAmmo > 0 and self.Primary.Ammo != "none" then - local ammo = newowner:GetAmmoCount(self.Primary.Ammo) - local given = math.min(self.StoredAmmo, (self.Primary.ClipSize*3) - ammo) - - newowner:GiveAmmo( given, self.Primary.Ammo) - self.StoredAmmo = 0 - end -end - -function SWEP:IsEquipment() - return WEPS.IsEquipment(self) -end \ No newline at end of file +SWEP.Base = "weapon_mor_base_glowstick" +SWEP.WepName = "weapon_glowstick" From c3ef12824c18f140d16de61dc92179afa04e124f Mon Sep 17 00:00:00 2001 From: stickz Date: Fri, 29 Apr 2016 21:11:19 -0400 Subject: [PATCH 6/6] Create GlowStick Constant --- MorbusGamemode/gamemodes/morbusgame/gamemode/shared.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MorbusGamemode/gamemodes/morbusgame/gamemode/shared.lua b/MorbusGamemode/gamemodes/morbusgame/gamemode/shared.lua index ecb6477..628104c 100644 --- a/MorbusGamemode/gamemodes/morbusgame/gamemode/shared.lua +++ b/MorbusGamemode/gamemodes/morbusgame/gamemode/shared.lua @@ -66,6 +66,7 @@ WEAPON_LIGHT = 2 WEAPON_RIFLE = 3 WEAPON_HEAVY = 4 WEAPON_MISC = 5 +WEAPON_GLOWSTICK = 5 WEAPON_ROLE = 6 @@ -164,4 +165,4 @@ LoadModels(Models.Male) LoadModels(Models.Female) -//I removed my little monologue here because it was pretty dumb \ No newline at end of file +//I removed my little monologue here because it was pretty dumb