Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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) )
Expand Down Expand Up @@ -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 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -58,99 +55,95 @@ 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
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
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()
Expand All @@ -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
Expand All @@ -187,7 +178,6 @@ function SWEP:DampenDrop()
end
end


function SWEP:Equip(newowner)
if SERVER then
if self:IsOnFire() then
Expand All @@ -206,4 +196,4 @@ end

function SWEP:IsEquipment()
return WEPS.IsEquipment(self)
end
end
3 changes: 2 additions & 1 deletion MorbusGamemode/gamemodes/morbusgame/gamemode/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ WEAPON_LIGHT = 2
WEAPON_RIFLE = 3
WEAPON_HEAVY = 4
WEAPON_MISC = 5
WEAPON_GRENADE = 5
WEAPON_ROLE = 6


Expand Down Expand Up @@ -164,4 +165,4 @@ LoadModels(Models.Male)
LoadModels(Models.Female)


//I removed my little monologue here because it was pretty dumb
//I removed my little monologue here because it was pretty dumb