Files
VnUtest/garrysmod/addons/molotok/lua/entities/constructor_prop.lua
2026-03-31 10:27:04 +03:00

47 lines
1.0 KiB
Lua

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