Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // copypasta from microwave.
- AddCSLuaFile("cl_init.lua")
- AddCSLuaFile("shared.lua")
- include('shared.lua')
- function ENT:SpawnFunction( ply, tr )
- if ( !tr.Hit ) then return end
- local SpawnPos = tr.HitPos + tr.HitNormal * 42
- local ent = ents.Create( "healthdispenser" )
- ent:SetPos( SpawnPos )
- ent:Spawn()
- ent:Activate()
- return ent
- end
- function ENT:Initialize()
- self.Entity:SetModel( "models/props_lab/reciever_cart.mdl")
- self.Entity:PhysicsInit(SOLID_VPHYSICS)
- self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
- self.Entity:SetNWInt("upgrade", 0)
- self.Entity:SetSolid(SOLID_VPHYSICS)
- local phys = self.Entity:GetPhysicsObject()
- if(phys:IsValid()) then phys:Wake() end
- self.Entity:SetNWBool("sparking",false)
- self.Entity:SetNWInt("damage",500)
- local ply = self.Entity:GetNWEntity( "owner" )
- ply:GetTable().maxdispensers=ply:GetTable().maxhealthdispensers + 1
- self.Entity:SetNWInt("power",0)
- self.scrap = false
- end
- function ENT:MakeScraps()
- if !self.scrap then
- self.scrap = true
- local value = CfgVars["healthdispensercost"]/8
- if value<5 then value = 5 end
- for i=0, 5, 1 do
- local scrap = ents.Create("prop_physics")
- scrap:SetModel( "models/gibs/metal_gib" .. math.random(1,5) .. ".mdl" );
- local randpos = Vector(math.random(-5,5), math.random(-5,5), math.random(0,5))
- scrap:SetNWEntity("owner", self.Entity:GetNWEntity("owner"))
- scrap:SetPos(self.Entity:GetPos()+randpos)
- scrap:Spawn()
- scrap:GetTable().ScrapMetal = true
- scrap:GetTable().Amount = math.random(3,value)
- scrap:Activate()
- scrap:GetPhysicsObject():SetVelocity(randpos*35)
- end
- end
- end
- function ENT:Use(activator,caller)
- if self.Entity:GetNWBool("sparking") == true then return end
- plgun = activator:GetActiveWeapon()
- if activator:Health()<activator:GetMaxHealth() then
- activator:SetHealth(activator:Health()+25)
- activator:SetArmor(activator:Armor()+15)
- if (activator:Armor()>100) then activator:SetArmor(100) end
- if (activator:Health()>activator:GetMaxHealth()) then activator:SetHealth(activator:GetMaxHealth()) end
- end
- self.Entity:SetNWBool("sparking",true)
- if (self.Entity:GetNWInt("upgrade")>0) then
- activator:SetHealth(activator:Health()+25)
- activator:SetArmor(activator:Armor()+20)
- if (activator:Armor()>100) then activator:SetArmor(100) end
- if (activator:Health()>activator:GetMaxHealth()) then activator:SetHealth(activator:GetMaxHealth()) end
- timer.Create( tostring(self.Entity) .. "resup", 0.75, 1, self.resupply, self)
- end
- if (self.Entity:GetNWInt("upgrade")==2) then
- activator:SetHealth(activator:Health()+25)
- activator:SetArmor(activator:Armor()+25)
- if (activator:Armor()>100) then activator:SetArmor(100) end
- end
- end
- function ENT:resupply()
- self.Entity:SetNWBool("sparking",false)
- end
- function ENT:Think()
- if (ValidEntity(self.Entity:GetNWEntity("owner"))!=true) then
- self.Entity:Remove()
- end
- end
- function ENT:OnRemove( )
- timer.Destroy(tostring(self.Entity))
- local ply = self.Entity:GetNWEntity( "owner" )
- if ValidEntity(ply) then
- ply:GetTable().maxhealthdispensers=ply:GetTable().maxhealthdispensers - 1
- end
- timer.Destroy(tostring(self.Entity) .. "resup")
- end
Add Comment
Please, Sign In to add comment