diff --git a/MorbusGamemode/gamemodes/morbusgame/entities/entities/ent_frag/shared.lua b/MorbusGamemode/gamemodes/morbusgame/entities/entities/ent_frag/shared.lua index 8897475..40fe851 100644 --- a/MorbusGamemode/gamemodes/morbusgame/entities/entities/ent_frag/shared.lua +++ b/MorbusGamemode/gamemodes/morbusgame/entities/entities/ent_frag/shared.lua @@ -5,22 +5,19 @@ ENT.Type = "anim" if SERVER then -AddCSLuaFile("shared.lua") + AddCSLuaFile("shared.lua") -function ENT:Initialize() - self:SetMoveType( MOVETYPE_NONE ) - self:SetSolid( SOLID_NONE ) - self:SetCollisionGroup( COLLISION_GROUP_NONE ) - self:DrawShadow(false) - self:SetModel("models/weapons/w_eq_fraggrenade.mdl") - -end - function ENT:Think() + function ENT:Initialize() + self:SetMoveType( MOVETYPE_NONE ) + self:SetSolid( SOLID_NONE ) + self:SetCollisionGroup( COLLISION_GROUP_NONE ) + self:DrawShadow(false) + self:SetModel("models/weapons/w_eq_fraggrenade.mdl") + local player = self:GetOwner() self:SetColor(player:GetColor()) - self:SetMaterial(player:GetMaterial()) -end - + self:SetMaterial(player:GetMaterial()) + end end if CLIENT then @@ -46,10 +43,10 @@ if CLIENT then self:SetPos(position + x + y + z) self:SetAngles(angles) end - local eyepos = EyePos() - local eyepos2 = LocalPlayer():EyePos() - if eyepos:Distance(eyepos2) > 5 or LocalPlayer() != self:GetOwner() then - self:DrawModel() - end + local eyepos = EyePos() + local eyepos2 = LocalPlayer():EyePos() + if eyepos:Distance(eyepos2) > 5 or LocalPlayer() != self:GetOwner() then + self:DrawModel() + end end -end +end diff --git a/MorbusGamemode/gamemodes/morbusgame/entities/entities/ent_frag_grenade/init.lua b/MorbusGamemode/gamemodes/morbusgame/entities/entities/ent_frag_grenade/init.lua index e2bca29..b5cfca7 100644 --- a/MorbusGamemode/gamemodes/morbusgame/entities/entities/ent_frag_grenade/init.lua +++ b/MorbusGamemode/gamemodes/morbusgame/entities/entities/ent_frag_grenade/init.lua @@ -10,8 +10,6 @@ function ENT:Initialize() self:SetSolid(SOLID_VPHYSICS) local phys = self:GetPhysicsObject() if phys:IsValid() then phys:Wake() end - self.Death = CurTime() + 3 - self.Exploded = false end function ENT:SpawnFunction( ply, tr ) @@ -25,9 +23,6 @@ function ENT:SpawnFunction( ply, tr ) end ents.Create("prop_physics") -function ENT:OnRemove() -end - function ENT:Explode() local effectdata = EffectData() effectdata:SetNormal( Vector(0,0,1) ) @@ -57,27 +52,18 @@ function ENT:Explode() shake:Spawn() shake:Activate() shake:Fire( "StartShake", "", 0 ) -end - -function ENT:Think() + + --remove after explosion + self.Entity:Remove() end local BounceSnd = Sound( "HEGrenade.Bounce" ) function ENT:PhysicsCollide( data, phys ) -if data.Speed > 50 then - self:EmitSound( BounceSnd ) -end -local impulse = (-data.Speed * data.HitNormal * .4 + (data.OurOldVelocity * -.6))*0.5 -phys:ApplyForceCenter( impulse ) - -if self.Exploded == true then return end - self.Exploded = true - timer.Simple(3, function() - if !self.Entity:IsValid() then return end - self:Explode() - self:Remove() - end) - + if data.Speed > 50 then + self:EmitSound( BounceSnd ) + end + local impulse = (-data.Speed * data.HitNormal * .4 + (data.OurOldVelocity * -.6))*0.5 + phys:ApplyForceCenter( impulse ) end function ENT:Use( activator, caller ) diff --git a/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_frag/shared.lua b/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_frag/shared.lua index 3c16d70..f878b75 100644 --- a/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_frag/shared.lua +++ b/MorbusGamemode/gamemodes/morbusgame/entities/weapons/weapon_frag/shared.lua @@ -9,7 +9,7 @@ if ( CLIENT ) then SWEP.ViewModelFlip = true SWEP.CSMuzzleFlashes = false SWEP.PrintName = "Frag Grenade" - SWEP.Slot = 4 + SWEP.Slot = WEAPON_GRENADE - 1 SWEP.SlotPos = 0 end @@ -33,14 +33,11 @@ SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" SWEP.AllowDrop = true -SWEP.Kind = WEAPON_MISC +SWEP.Kind = WEAPON_GRENADE SWEP.KGWeight = 8 SWEP.AutoSpawnable = true SWEP.StoredAmmo = 0 -function SWEP:Think() -end - function SWEP:Initialize() self:SetWeaponHoldType( self.HoldType ) end @@ -58,64 +55,63 @@ function SWEP:Deploy() ent:SetColor(self.Owner:GetColor()) ent:SetMaterial(self.Owner:GetMaterial()) ent:Spawn() - end + end +end - +function SWEP:PrimaryAttack() + self:PrepareAttack() + self:DuringAttack(self:GetRandomVector(), 1000) + self:AfterAttack() end -function SWEP:Reload() +function SWEP:GetRandomVector() + return Vector(math.random(-50,50),math.random(-50,50),math.random(-50,50)) end -function SWEP:PrimaryAttack() +function SWEP:SecondaryAttack() + self:PrepareAttack() + self:DuringAttack(Vector(0,0,0), 30) + self:AfterAttack() +end + +function SWEP:PrepareAttack() 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 +end + +function SWEP:DuringAttack(vec, speed) if SERVER then local ent = ents.Create("ent_frag_grenade") - + ent.GrenadeOwner = self.Owner ent:SetPos(self.Owner:GetShootPos()) ent:SetAngles(Angle(1,0,0)) ent:Spawn() - + local phys = ent:GetPhysicsObject() - phys:SetVelocity(self.Owner:GetAimVector() * 1000) - phys:AddAngleVelocity(Vector(math.random(-50,50),math.random(-50,50),math.random(-50,50))) - end - self:EmitSound( "vo/npc/male01/watchout.wav", 100, math.random( 95, 105 ) ); - 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_frag" and v:GetOwner() == self.Owner then - v:Remove() + phys:SetVelocity(self.Owner:GetAimVector() * speed) + phys:AddAngleVelocity(vec) + + local entOwner = self.Owner + + timer.Simple(3, + function() + if !ent then return end + if !IsValid(ent) then return end + + if !entOwner:IsSwarm() then + ent:Explode() end - end - self.Owner:StripWeapon("weapon_frag") - self.Owner:SelectWeapon("weapon_mor_crowbar") + + ent:Remove() + end) 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_frag_grenade") - - ent.GrenadeOwner = self.Owner - 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 + +function SWEP:AfterAttack() self:EmitSound( "vo/npc/male01/watchout.wav", 100, math.random( 95, 105 ) ); self.Weapon:SendWeaponAnim(ACT_VM_DRAW) if self.Weapon:Clip1() < 1 && SERVER then @@ -123,34 +119,31 @@ function SWEP:SecondaryAttack() for k, v in pairs(worldmodel) do if v:GetClass() == "ent_frag" and v:GetOwner() == self.Owner then v:Remove() - end + end end self.Owner:StripWeapon("weapon_frag") self.Owner:SelectWeapon("weapon_mor_crowbar") 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_frag" and v:GetOwner() == self.Owner then v:Remove() - end + 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() @@ -167,10 +160,8 @@ function SWEP:PreDrop() 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_frag" and v:GetOwner() == self.Owner then @@ -187,7 +178,6 @@ function SWEP:DampenDrop() end end - function SWEP:Equip(newowner) if SERVER then if self:IsOnFire() then @@ -206,4 +196,4 @@ end function SWEP:IsEquipment() return WEPS.IsEquipment(self) -end \ No newline at end of file +end diff --git a/MorbusGamemode/gamemodes/morbusgame/gamemode/shared.lua b/MorbusGamemode/gamemodes/morbusgame/gamemode/shared.lua index ecb6477..a4c8a1f 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_GRENADE = 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