add sborka
This commit is contained in:
46
garrysmod/addons/molotok/lua/entities/constructor_prop.lua
Normal file
46
garrysmod/addons/molotok/lua/entities/constructor_prop.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
AddCSLuaFile()
|
||||
|
||||
ENT.Type = "anim"
|
||||
ENT.Base = "base_gmodentity"
|
||||
ENT.PrintName = "Constructor Prop"
|
||||
|
||||
function ENT:Initialize()
|
||||
if CLIENT then return end
|
||||
|
||||
self:SetModel(self.Model or "models/props_c17/oildrum001.mdl")
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
self:SetMoveType(MOVETYPE_VPHYSICS)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
|
||||
local phys = self:GetPhysicsObject()
|
||||
if IsValid(phys) then
|
||||
phys:EnableMotion(false)
|
||||
phys:SetMass(500)
|
||||
end
|
||||
|
||||
self.hp = self.InitialHealth or 10000
|
||||
|
||||
self:DrawShadow(true)
|
||||
self:SetCollisionGroup(COLLISION_GROUP_NONE)
|
||||
end
|
||||
|
||||
function ENT:OnTakeDamage(dmg)
|
||||
if not SERVER then return end
|
||||
if dmg:GetInflictor() == self or dmg:GetAttacker() == self then return end
|
||||
if self.Exploded then return end
|
||||
|
||||
self.hp = self.hp - dmg:GetDamage()
|
||||
|
||||
if self.hp <= 0 then
|
||||
self.Exploded = true
|
||||
self:Remove()
|
||||
end
|
||||
|
||||
self:TakePhysicsDamage(dmg)
|
||||
end
|
||||
|
||||
if CLIENT then
|
||||
function ENT:Draw()
|
||||
self:DrawModel()
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user