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") -- Not sure how I should do this (if it's a neat way)
- -- The world model is used by entity and weapon
- ITEM.WorldModel = "models/weapons/w_rocket_launcher.mdl"
- ITEM.ViewModel = "models/weapons/v_RPG.mdl"
- ITEM.PrintName = "Tesla Gun"
- -- "both" means that the item is a weapon when equiped, and an entity when it's on ground
- ITEM.State = "both"
- ITEM.Inventory = {
- name = "Tesla Gun",
- info = [[
- Gun that fires tesla?
- ]],
- }
- function ITEM:Initialize()
- -- Don't really need this, it's just for constant reloading (I'm runstringing this) so the menu doesn't stack up
- self.DermaMenuOptions = {}
- if CLIENT then
- self:AddBackpackOption()
- self:AddEquipOption()
- self:AddSpacer()
- -- First argument is the label in the menu, second is the function name we're going to call when it's selected
- self:AddSimpleOption("SelfDestruct", "Exp")
- self:AddSimpleOption("Fire Primary", "PrimaryAttack")
- else
- self:AllowOption("SelfDestruct", "Exp")
- -- self:AllowOption("Fire Secondary", "SecondaryAttack")
- self:AllowOption("Fire Primary", "PrimaryAttack")
- -- self:AllowOption("Spawn Random", "MakeEnt")
- -- Only do this if it's not a weapon
- if not self:IsWeapon() then
- self:SetModel( self.WorldModel )
- self:PhysicsInit( SOLID_VPHYSICS )
- self:SetMoveType( MOVETYPE_VPHYSICS )
- self:SetSolid( SOLID_VPHYSICS )
- self:PhysWake()
- end
- end
- end
- if SERVER then
- function ITEM:MakeEnt(class)
- self.Owner:MuzzleFlash()
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
- self.Owner:EmitSound("ambient/levels/citadel/weapon_disintegrate1.wav")
- self.Owner:ViewPunch(Angle( -5, 0, 0 ))
- local tr = self:GetTrace() -- This returns GetEyeTrace if it's held, and a custom trace if it's not held
- util.ScreenShake( tr.HitPos+tr.HitNormal*10, 5, 50, 1, 100 )
- local ent=ents.Create(class)
- 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"
- util.BlastDamage(self , self.Owner, ent:GetPos(), 100, 10)
- timer.Simple(0.1,function()
- if ent:IsValid() then
- ent:Remove()
- end
- end)
- local effect = EffectData()
- effect:SetStart(self.Owner:GetShootPos())
- effect:SetEntity(ent)
- effect:SetOrigin(tr.HitPos)
- effect:SetAngle(self.Owner:EyeAngles())
- util.Effect( "TeslaZap", effect )
- util.Effect("CommandPointer", effect )
- end
- function ITEM:PrimaryAttack()
- if self:IsWeapon() then
- self.Weapon:SetNextPrimaryFire( CurTime() + 0.2 )
- self:MakeEnt("point_tesla")
- else
- self:MakeEnt("point_tesla")
- end
- end
- function ITEM:Exp()
- local ent2=ents.Create("point_tesla")
- ent2:SetKeyValue("texture","models/effects/comball_sphere.vmt")
- ent2:SetKeyValue("m_flRadius" , "5000")
- ent2:SetKeyValue("m_Color" , "255 255 255")
- ent2:SetKeyValue("beamcount_min" , "1000")
- ent2:SetKeyValue("beamcount_max" , "1000")
- ent2:SetKeyValue("thick_min" , "15")
- ent2:SetKeyValue("thick_max" , "20")
- ent2:SetKeyValue("lifetime_min" , "0.1")
- ent2:SetKeyValue("lifetime_max" , "0.2")
- ent2:SetKeyValue("interval_min" , "0.1")
- ent2:SetKeyValue("interval_max" , "0.1")
- ent2:SetPos(self:GetPos()+Vector(0,0,50))
- ent2:Spawn()
- ent2:Activate()
- ent2:EmitSound("ambient/explosions/explode_7.wav")
- ent2:Fire"DoSpark"
- util.ScreenShake( self:GetPos(), 50, 5, 3, 5000 )
- util.BlastDamage(self , self.Owner, ent2:GetPos(), 4500, 5000)
- self:Remove()
- timer.Simple(0.1,function()
- if ent2:IsValid() then
- ent2:Remove()
- end
- end)
- end
- else
- function ITEM:PrimaryAttack()
- self.Weapon:SetNextPrimaryFire( CurTime() + 0.2 )
- self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
- self.Owner:MuzzleFlash()
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
- sekf.firing = true
- timer.Create("TeslaGunPrimary"..self:EntIndex(), 0.2, 0, function()
- self.firing = false
- end)
- end
- function ITEM.HOOK:PostDrawOpaqueRenderables()
- if not self.firing then return end
- start_pos = self:GetPos();
- end_pos = LocalPlayer():GetTrace().HitPos
- dir = ( end_pos - start_pos );
- increment = dir:Length() / 12;
- dir:Normalize();
- render.SetMaterial( Material("models/effects/comball_sphere.vmt") );
- render.StartBeam( 14 );
- render.AddBeam(
- start_pos,
- 5,
- 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,
- 5,
- tcoord,
- Color( 64, 255, 64, 255 )
- );
- end
- render.AddBeam(
- end_pos,
- 5,
- 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("mare"))
- end
Add Comment
Please, Sign In to add comment