Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- AddCSLuaFile("shared.lua")
- end
- if CLIENT then
- SWEP.PrintName = "Mjolnir"
- SWEP.Author = "Upset"
- SWEP.Slot = 5
- SWEP.SlotPos = 0
- SWEP.WepSelectIcon = surface.GetTextureID("weapons/mjol_icon")
- SWEP.ViewModelFOV = 90
- killicon.Add("weapon_q1_mjolnir", "weapons/mjol_icon", Color(255, 80, 0, 255))
- end
- function SWEP:PrimaryAttack()
- if self.Owner:GetAmmoCount(self.Primary.Ammo) >= 15 then
- self:SetNextPrimaryFire(CurTime() + self.Primary.ZapDelay)
- self:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
- self.Owner:SetAnimation(PLAYER_ATTACK1)
- if SERVER then self.Owner:EmitSound(self.Primary.Sound) end
- self.attackdelay = CurTime() +.5
- self.cantholster = CurTime() +.6
- self:SuperDamageSound()
- else
- self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
- self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
- self.Owner:SetAnimation(PLAYER_ATTACK1)
- if SERVER then self.Owner:EmitSound(self.Primary.Sound) end
- self.attackdelay = CurTime() +.2
- self.cantholster = CurTime() +.5
- self:SuperDamageSound()
- end
- end
- function SWEP:SpecialThink()
- if self.attackdelay and CurTime() > self.attackdelay then
- self.attackdelay = nil
- if self.Owner:GetAmmoCount(self.Primary.Ammo) >= 15 then
- self:Mjolnir()
- else
- self:Melee()
- end
- end
- end
- function SWEP:Melee()
- if SERVER then self.Owner:LagCompensation(true) end
- local tr = util.TraceLine({
- start = self.Owner:GetShootPos(),
- endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * self.MeleeHitDist,
- filter = self.Owner
- })
- if !IsValid(tr.Entity) then
- tr = util.TraceHull({
- start = self.Owner:GetShootPos(),
- endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * self.MeleeHitDist,
- filter = self.Owner,
- mins = Vector(-1, -1, -1),
- maxs = Vector(1, 1, 1)
- })
- end
- if tr.Hit then
- util.ImpactEffect(tr)
- if CLIENT then return end
- local dmginfo = DamageInfo()
- local attacker = self.Owner
- if (!IsValid(attacker)) then attacker = self end
- dmginfo:SetAttacker(attacker)
- dmginfo:SetInflictor(self)
- dmginfo:SetDamage(self.Primary.DamageMelee)
- dmginfo:SetDamageForce(self.Owner:GetUp() *4000 +self.Owner:GetForward() *15000)
- tr.Entity:TakeDamageInfo(dmginfo)
- self:EmitSound(self.Primary.HitFlesh)
- end
- if tr.HitWorld then
- if SERVER then self.Owner:EmitSound(self.Primary.HitMetal) end
- end
- if SERVER then self.Owner:LagCompensation(false) end
- end
- function util.ImpactEffect(tr)
- local e = EffectData()
- e:SetOrigin(tr.HitPos)
- e:SetStart(tr.StartPos)
- e:SetSurfaceProp(tr.SurfaceProps)
- e:SetDamageType(DMG_BULLET)
- e:SetHitBox(tr.HitBox)
- if CLIENT then
- e:SetEntity(tr.Entity)
- else
- e:SetEntIndex(tr.Entity:EntIndex())
- end
- util.Effect("Impact", e)
- end
- function SWEP:Mjolnir()
- if self.Owner:WaterLevel() > 2 then
- self.Owner:Kill()
- end
- self:TakeAmmo(15)
- local tr = util.TraceLine({
- start = self.Owner:GetShootPos(),
- endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * self.HitDist,
- filter = self.Owner
- })
- local ents = ents.FindInSphere(tr.StartPos, self.HitDist)
- for k,v in pairs(ents) do
- if IsValid(v) and (v:IsPlayer() or v:IsNPC() or v:Health() > 0) and v != self:GetOwner() then
- if v:IsPlayer() and !v:Alive() then return end
- local dmginfo = DamageInfo()
- dmginfo:SetDamage(self.Primary.Damage)
- dmginfo:SetDamageType(DMG_ENERGYBEAM)
- dmginfo:SetAttacker(self.Owner)
- dmginfo:SetInflictor(self)
- v:TakeDamageInfo(dmginfo)
- end
- end
- self.Owner:EmitSound(self.Primary.Zap)
- self:SetNWBool("DrawBeam", true)
- self:DoLightningEffect(tr)
- self:DoLightningEffect(tr)
- timer.Simple(.05, function()
- self:DoLightningEffect(tr)
- end)
- timer.Simple(.1, function()
- self:DoLightningEffect(tr)
- end)
- timer.Simple(.15, function()
- self:DoLightningEffect(tr)
- end)
- timer.Simple(.2, function()
- self:DoLightningEffect(tr)
- end)
- timer.Simple(.25, function()
- self:DoLightningEffect(tr)
- end)
- timer.Simple(.3, function()
- self:DoLightningEffect(tr)
- end)
- timer.Simple(.35, function()
- self:DoLightningEffect(tr)
- end)
- timer.Simple(.4, function()
- self:DoLightningEffect(tr)
- end)
- timer.Simple(.45, function()
- self:DoLightningEffect(tr)
- end)
- timer.Simple(.5, function()
- self:DoLightningEffect(tr)
- self:SetNWBool("DrawBeam", false)
- end)
- end
- function SWEP:DoLightningEffect(tr)
- local pos = self.Owner:GetShootPos()
- local ang = self.Owner:GetAimVector():Angle()
- pos = pos +ang:Up() *-20
- if IsFirstTimePredicted then
- local beameffect = EffectData()
- beameffect:SetEntity(self)
- beameffect:SetStart(pos)
- beameffect:SetOrigin(tr.HitPos + ang:Right() *math.Rand(-128,128))
- util.Effect("q1_mjolnir_lightning", beameffect)
- end
- end
- local lightning = Material("sprites/q1lightning")
- function SWEP:ViewModelDrawn()
- if !self:GetNWBool("DrawBeam") then return end
- local pos = self.Owner:GetShootPos()
- local ang = self.Owner:GetAimVector():Angle()
- pos = pos +ang:Up() *-20
- local ents = ents.FindInSphere(pos, self.HitDist)
- for k,v in pairs(ents) do
- if IsValid(v) and (v:IsPlayer() or v:IsNPC() or v:Health() > 0) and v != self:GetOwner() then
- if v:IsPlayer() and !v:Alive() then return end
- local endpos = v:GetPos() + ((v:OBBMins() + v:OBBMaxs()) *.5)
- local rot = CurTime()
- render.SetMaterial(lightning)
- render.DrawBeam(pos, endpos, 10, rot, rot -1, Color(255, 255, 255, 255))
- render.DrawBeam(pos, endpos, 20, rot, rot -2, Color(255, 255, 255, 255))
- self:SetRenderBoundsWS(pos, endpos)
- end
- end
- end
- function SWEP:DrawWorldModel()
- self:DrawModel()
- if !self:GetNWBool("DrawBeam") then return end
- local pos = self.Owner:GetShootPos()
- local ang = self.Owner:GetAimVector():Angle()
- pos = pos +ang:Up() *-20 +ang:Forward() *20
- local ents = ents.FindInSphere(pos, self.HitDist)
- for k,v in pairs(ents) do
- if IsValid(v) and (v:IsPlayer() or v:IsNPC() or v:Health() > 0) and v != self:GetOwner() then
- if v:IsPlayer() and !v:Alive() then return end
- local endpos = v:GetPos() + ((v:OBBMins() + v:OBBMaxs()) *.5)
- local rot = CurTime()
- render.SetMaterial(lightning)
- render.DrawBeam(pos, endpos, 10, rot, rot -1, Color(255, 255, 255, 255))
- render.DrawBeam(pos, endpos, 20, rot, rot -2, Color(255, 255, 255, 255))
- self:SetRenderBoundsWS(pos, endpos)
- end
- end
- end
- SWEP.HoldType = "melee"
- SWEP.Base = "weapon_q1_base"
- SWEP.Category = "Quake 1"
- SWEP.Spawnable = true
- SWEP.ViewModel = "models/weapons/v_q1_mjolnir.mdl"
- SWEP.WorldModel = "models/weapons/w_q1_mjolnir.mdl"
- SWEP.Primary.Sound = Sound("weapons/q1/ax1.wav")
- SWEP.Primary.Zap = Sound("weapons/hipweap/mjolhit.wav")
- SWEP.Primary.HitMetal = Sound("weapons/hipweap/mjoltink.wav")
- SWEP.Primary.HitFlesh = Sound("weapons/hipweap/mjolslap.wav")
- SWEP.Primary.Damage = 30
- SWEP.Primary.DamageMelee = 25
- SWEP.Primary.ClipSize = -1
- SWEP.Primary.Delay = 1.1
- SWEP.Primary.ZapDelay = 1.5
- SWEP.Primary.DefaultClip = 20
- SWEP.Primary.Automatic = true
- SWEP.Primary.Ammo = "Q1Cells"
- SWEP.HitDist = 256
- SWEP.MeleeHitDist = 80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement