Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- SHARED:
- DEFINED:
- ITEM:State = "both/weapon/entity"
- MISC:
- ITEM:HOOK:Name(...)
- FUNCTIONS:
- ITEM:GetTrace()
- ITEM:GetInventoryInfo()
- CLIENT:
- MENU:
- ITEM:AddSimpleOption(name, function, ...)
- ITEM:AddEquipOption()
- ITEM:AddBackpackOption()
- ITEM:AddDropOption()
- ITEM:AddSpacer()
- ITEM:AddCustomOption(function)
- ITEM:CallOption(name, function, ...)
- ITEM:MakeMenu()
- ITEM:GetMenu()
- DATA:
- ITEM:CallOnServer(...)
- ITEM:ReceiveUserMessage(...)
- HOOKS:
- ITEM:PreDraw()
- ITEM:PostDraw()
- SERVER:
- MENU:
- ITEM:AllowOption(name, function)
- DATA:
- ITEM:ReceiveFromClient(ply, ...)
- ITEM:SendUserMessage(ply, ...)
- HOOKS:
- ITEM:PreBackpack(ply)
- ITEM:OnEquip(ply)
- ITEM:PreDrop(ply)
- FUNCTIONS:
- ITEM:SetSate(state)
- ITEM:RemoveActiveItem()
- ]]
- items.StartItem("tesla_gun", nil, "weapon_base", "base_anim")
- -- ITEM.WorldModel = "models/weapons/w_rocket_launcher.mdl"
- -- ITEM.ViewModel = "models/weapons/v_RPG.mdl"
- ITEM.WorldModel = "models/weapons/w_physics.mdl"
- ITEM.ViewModel = "models/weapons/v_superphyscannon.mdl"
- ITEM.PrintName = "Tesla Gun"
- ITEM.ViewModelFOV = 50
- ITEM.Instructions = "Aim at the enemy"
- ITEM.Slot = 3
- ITEM.State = "both"
- ITEM.Inventory = {
- name = "Tesla Gun",
- info = [[
- Gun that fires tesla?
- ]],
- }
- function ITEM:Initialize()
- self.DermaMenuOptions = {}
- if CLIENT then
- self:AddBackpackOption()
- self:AddEquipOption()
- self:AddSpacer()
- self:AddSimpleOption("Self Destruct", "StartTimer", LocalPlayer())
- self:AddSimpleOption("Fire Primary", "PrimaryAttack")
- --self:SetModelScale(Vector()*1.5) HitBox failure
- else
- self:AllowOption("Self Destruct", "StartTimer")
- self:AllowOption("Fire Primary", "PrimaryAttack")
- if not self:IsWeapon() then
- self:SetModel( self.WorldModel )
- self:PhysicsInit( SOLID_VPHYSICS )
- self:SetMoveType( MOVETYPE_VPHYSICS )
- self:SetSolid( SOLID_VPHYSICS )
- self:PhysWake()
- self:SetSkin(1)
- end
- end
- end
- function ITEM:SecondaryAttack()
- end
- if SERVER then
- function ITEM:FireTesla()
- self.Owner:MuzzleFlash()
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
- self:EmitSound("ambient/levels/citadel/weapon_disintegrate1.wav")
- local tr = self:GetTrace()
- util.ScreenShake( tr.HitPos, 5, 50, 1, 100 )
- local ent=ents.Create("point_tesla")
- ent:SetKeyValue("texture","models/effects/comball_sphere.vmt")
- ent:SetKeyValue("m_flRadius" , "100")
- ent:SetKeyValue("m_Color" , "255 255 255")
- ent:SetKeyValue("beamcount_min" , "150")
- ent:SetKeyValue("beamcount_max" , "150")
- ent:SetKeyValue("thick_min" , "8")
- ent:SetKeyValue("thick_max" , "20")
- ent:SetKeyValue("lifetime_min" , "0.1")
- ent:SetKeyValue("lifetime_max" , "0.2")
- ent:SetKeyValue("interval_min" , "0.1")
- ent:SetKeyValue("interval_max" , "0.1")
- ent:SetPos(tr.HitPos+tr.HitNormal*10)
- ent:Spawn()
- ent:Activate()
- ent:EmitSound("ambient/energy/spark6.wav")
- ent:Fire("DoSpark")
- ent:Fire("Kill", 0.1)
- util.BlastDamage(self , self.Owner, ent:GetPos(), 100, 10)
- end
- function ITEM:PrimaryAttack()
- if self:IsWeapon() then
- self:SetNextPrimaryFire( CurTime() + 0.1 )
- self:FireTesla()
- else
- self:FireTesla()
- end
- self:SetNWBool("firing", true)
- timer.Create("TeslaGunPrimary"..self:EntIndex(), 0.1, 1, function()
- self:SetNWBool("firing", false)
- end)
- end
- function ITEM:Explode(ply)
- local ent = ents.Create("point_tesla")
- ent:SetKeyValue("texture","models/effects/comball_sphere.vmt")
- ent:SetKeyValue("m_flRadius" , "5000")
- ent:SetKeyValue("m_Color" , "255 255 255")
- ent:SetKeyValue("beamcount_min" , "1000")
- ent:SetKeyValue("beamcount_max" , "1000")
- ent:SetKeyValue("thick_min" , "15")
- ent:SetKeyValue("thick_max" , "20")
- ent:SetKeyValue("lifetime_min" , "0.1")
- ent:SetKeyValue("lifetime_max" , "0.2")
- ent:SetKeyValue("interval_min" , "0.1")
- ent:SetKeyValue("interval_max" , "0.1")
- ent:SetPos(self:GetPos()+Vector(0,0,50))
- ent:Spawn()
- ent:Activate()
- ent:EmitSound("ambient/explosions/explode_7.wav")
- ent:Fire("DoSpark")
- ent:Fire("Kill", "", 0.3)
- util.ScreenShake( self:GetPos(), 50, 5, 3, 5000 )
- util.BlastDamage(self , ply, ent:GetPos(), 4500, 5000)
- self:Remove()
- end
- function ITEM:StartTimer(ply)
- self:SendUserMessage("StartTimer")
- local count = 10
- self:SetNWBool("Counting", true)
- local index = self:EntIndex()
- timer.Create("tesla_gun_countdown: " .. self:EntIndex(), 1, 10, function()
- count = count - 1
- if count == 0 then
- self:Explode(ply)
- elseif not IsValid(self) then
- timer.Remove("tesla_gun_countdown: " .. index)
- end
- end)
- end
- function ITEM:RemoveFunctionByName(name)
- self.DermaMenuOptions[name] = nil
- end
- else
- function ITEM:ReceiveUserMessage(value)
- if value == "StartTimer" then self:RemoveFunctionByName("Self Destruct") end
- self.count = 10
- local index = self:EntIndex()
- timer.Create("tesla_gun_countdown: " .. index, 1, 10, function()
- if IsValid(self) then
- self.count = self.count - 1
- else
- timer.Remove("tesla_gun_countdown: " .. index)
- end
- end)
- end
- function ITEM:RemoveFunctionByName(name)
- for key, data in pairs(self.DermaMenuOptions) do
- if type(data) == "table" and data.name == name then
- self.DermaMenuOptions[key] = nil
- break
- end
- end
- end
- function ITEM:PrimaryAttack()
- self:SetNextPrimaryFire( CurTime() + 0.2 )
- self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
- self.Owner:MuzzleFlash()
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
- end
- local beam_mat = Material("models/effects/splodearc_sheet")
- function ITEM.HOOK:PostDrawOpaqueRenderables()
- if self:GetNWBool("Counting") then
- cam.Start3D2D( self:GetPos()+Vector( 0, 0, 20 )+LocalPlayer():EyeAngles():Up(), Angle( 0, LocalPlayer():EyeAngles().y-90, 90) , 1 )
- draw.DrawText(self.count, "ScoreboardText", 0, 0, Color(255, 0, 0, 255), TEXT_ALIGN_CENTER )
- cam.End3D2D()
- end
- if not self:GetNWBool("firing") then return end
- if self:IsWeapon() then
- start_pos = self.Owner:GetShootPos()+self.Owner:EyeAngles():Forward()*40+self.Owner:EyeAngles():Up()*-6+self.Owner:EyeAngles():Right()*6
- else
- start_pos = self:GetPos()
- end
- --local start_pos = self:GetAttachment(self:LookupAttachment("Muzzle")).Pos
- local end_pos = self:GetTrace().HitPos
- local dir = ( end_pos - start_pos )
- local increment = dir:Length() / 30
- dir:Normalize()
- render.SetMaterial( beam_mat )
- render.StartBeam( 14 )
- render.AddBeam(
- start_pos,
- 10,
- CurTime(),
- Color( 64, 255, 64, 255 )
- )
- local i
- for i = 1, 12 do
- local point = ( start_pos + dir * ( i * increment ) ) + VectorRand() * math.random( 1, 16 )
- local tcoord = CurTime() + ( 1 / 12 ) * i
- render.AddBeam(
- point,
- 10,
- tcoord,
- Color( 64, 255, 64, 255 )
- )
- end
- render.AddBeam(
- end_pos,
- 10,
- CurTime() + 1,
- Color( 64, 255, 64, 255 )
- )
- render.EndBeam()
- end
- function ITEM:DrawInBackPack(model, position, angles)
- model:SetPos(position+Vector(0,0,20))
- angles:RotateAroundAxis(angles:Forward(), 150)
- model:SetAngles(angles)
- model:DrawModel()
- end
- end
- items.EndItem()
- if SERVER then
- items.EasyCreate("tesla_gun", nero.GetPlayer("caps"))
- end
Advertisement
Add Comment
Please, Sign In to add comment