Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile()
- ENT.Type = "anim"
- ENT.Base = "base_anim"
- ENT.PrintName = "Builder_Barricade"
- ENT.Category = "Builder-Hammer"
- ENT.Builder_PickUp = false
- ENT.IsBuilder = true
- local EntName = "builder_barricade"
- local net_receive = "builder_"..ENT.PrintName
- ENT.Spawnable = true
- ENT.AdminOnly = false
- if SERVER then
- util.AddNetworkString( "Builder_Can_Damage" )
- function ENT:Initialize()
- self.Entity:SetModel( "models/props_lab/blastdoor001c.mdl" )
- self:PhysicsInit( SOLID_VPHYSICS )
- self:SetMoveType( MOVETYPE_VPHYSICS )
- self:SetSolid( SOLID_VPHYSICS )
- local phys = self:GetPhysicsObject()
- if phys:IsValid() then
- phys:Wake()
- end
- self:SetMaterial( "models/wireframe" )
- self:SetColor(Color(0, 0, 0, 255))
- self.Ent_Health = 300
- self:DrawShadow()
- self.CanBuilderDo = 0
- self.MaxGoal = 100
- end
- function ENT:SpawnFunction( ply, tr )
- local ent = ents.Create(EntName)
- ent:SetPos( ply:GetEyeTrace().HitPos + ply:GetEyeTrace().HitNormal * 32 )
- ent:Spawn()
- ent:Activate()
- return ent
- end
- function ENT:Think()
- return false
- end
- function ENT:OnTakeDamage( dmg )
- if Builder.GetScore(self) >= Builder.GetGoal(self) then
- self:SetColor(Color(255, 255, 255, 255))
- local ply = dmg:GetAttacker()
- local inflictor = dmg:GetInflictor()
- if type(inflictor) == "Entity" then return end
- if self.Ent_Health <= 0 then
- local effectdata = EffectData()
- effectdata:SetStart( self:GetPos() )
- effectdata:SetOrigin( self:GetPos() )
- effectdata:SetScale( 1 )
- util.Effect( "Explosion", effectdata )
- self:Dmger(ply)
- self:Remove()
- return
- end
- self.Ent_Health = self.Ent_Health - dmg:GetDamage()
- net.Start("Builder_Can_Damage")
- net.WriteString("Builder_Can_Damage")
- net.WriteString(tostring(self.Ent_Health))
- net.Send(ply)
- end
- end
- function ENT:Use( btn, ply )
- if Builder.GetScore(self) >= Builder.GetGoal(self) then
- self:SetMaterial( "" )
- self.Builder_PickUp = true
- end
- end
- function ENT:StartTouch( entity )
- return false
- end
- function ENT:EndTouch( entity )
- return false
- end
- function ENT:Touch( entity )
- return false
- end
- end
- if CLIENT then
- ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
- surface.CreateFont( "BuilderText",
- {
- font = "Arial",
- size = 21,
- weight = 400
- })
- function ENT:Initialize()
- self.Complete = self.Complete or 0
- self.Goal = self.Goal or 100
- net.Receive(net_receive.."_"..self:EntIndex(), function()
- self.Complete = net.ReadString()
- self.Goal = net.ReadString()
- end)
- net.Receive("Builder_Can_Damage", function()
- local n_candmg = net.ReadString()
- local n_hp = net.ReadString()
- --print(n_hp)
- self.BarricadeHP = n_hp
- if n_candmg == "Builder_Can_Damage" then
- self.CanDmg = true
- end
- end)
- end
- function ENT:Draw()
- self:DrawModel()
- local ply = LocalPlayer()
- local tr = ply:GetEyeTrace()
- local ent = tr.Entity
- if ent:EntIndex() == self:EntIndex() and ent:GetClass() == "builder_barricade" then
- if tonumber(self.Complete) >= 100 and Builder.GCV("Builder_Complete") == "1" then return end
- if tonumber(self.Complete) < tonumber(self.Goal) then
- AddWorldTip( "",tostring(self.Complete).."/"..tostring(self.Goal).."% Complete!", "", self:GetPos(), self )
- end
- if self.CanDmg == true and tonumber(self.BarricadeHP) >= 1 and tonumber(self.Complete) >= tonumber(self.Goal) then
- AddWorldTip( "", "Health: "..tonumber(self.BarricadeHP), "", self:GetPos(), self )
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement