Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- easylua.StartEntity("sent_juice")
- ENT.Type = "anim"
- ENT.Base = "base_gmodentity"
- ENT.Model = Model("models/props_junk/glassjug01.mdl")
- ENT.ClassName = "sent_juice"
- function ENT:Initialize()
- self.CreateTime = CurTime()
- if(SERVER) then
- self:SetJColor(HSVToColor(math.random(360),1,1))
- self:SetNWInt("Height",200)
- self:SetModel(ENT.Model)
- self:PhysicsInit(SOLID_VPHYSICS)
- self:SetMoveType(MOVETYPE_VPHYSICS)
- self:SetSolid(SOLID_VPHYSICS)
- self:StartMotionController()
- local phys = self:GetPhysicsObject()
- if(phys:IsValid()) then
- phys:SetMass(100)
- phys:Wake()
- --phys:EnableGravity(false)
- phys:EnableMotion(true)
- end
- self:PhysWake()
- self:SetUseType(SIMPLE_USE)
- else
- --self:SetRenderGroup(
- self.Juice = ClientsideModel("models/holograms/hq_cylinder.mdl",RENDERGROUP_BOTH)
- self.Juice:SetNoDraw(true)
- end
- end
- function ENT:Draw()
- render.SuppressEngineLighting(true)
- local scale = Vector(0.45,0.45,0.25 * (self:GetNWInt("Height")/100))
- local color = Color(self:GetNWInt("R"),self:GetNWInt("G"),self:GetNWInt("B"))
- self.Juice:SetRenderOrigin(self:LocalToWorld(scale*Vector(0,0,6)+Vector(0,0,0.48)))
- self.Juice:SetModelScale(scale)
- self.Juice:SetRenderAngles(self:GetAngles())
- render.SetColorModulation(color.r / 255, color.g /255, color.b /255)
- self.Juice:SetupBones()
- self.Juice:DrawModel()
- self.Juice:SetModelScale(scale*-1)
- self.Juice:SetupBones()
- self.Juice:DrawModel()
- render.SetColorModulation(1,1,1)
- render.SuppressEngineLighting(false)
- self:DrawModel()
- end
- function ENT:IsTranslucent()
- return true
- end
- local emitter = nil
- function ENT:GetJuice()
- return self:GetNWInt("Height")
- end
- function ENT:GetJColor()
- return Color(self:GetNWInt("R"),self:GetNWInt("G"),self:GetNWInt("B"))
- end
- local mat = Material("particle/rain")
- local callback
- callback = function(part, pos, norm)
- part:SetVelocity(part:GetVelocity() + Vector(math.random(-3,3),math.random(-3,3),math.random(0,2))*30)
- util.DecalEx(mat, LocalPlayer(), pos, norm, 100, 100, 1)
- end
- function ENT:Think()
- if(self:GetUp().z < 0) then
- if(CLIENT) then
- emitter = emitter or ParticleEmitter(self:GetPos())
- emitter:SetPos(self:GetPos())
- for I=1,2 do
- local part = emitter:Add("particle/rain",self:GetPos()+self:GetUp()*12)
- if part then
- part:SetDieTime(10)
- part:SetLifeTime(0)
- local col = self:GetJColor()
- part:SetColor(col.r,col.g,col.b,255)
- part:SetStartSize(0)
- part:SetEndSize(50)
- part:SetStartLength(8)
- part:SetEndLength(8)
- part:SetGravity(physenv.GetGravity())
- part:SetVelocity(Vector(math.random(-0.5,0.5),math.random(-0.5,0.5),math.random(0,-1))*2)
- part:SetCollide(true)
- part:SetBounce(0.2)
- part:SetCollideCallback(callback)
- end
- end
- else
- --self:SetJuice(self:GetJuice()-1)
- end
- end
- self:NextThink(RealTime()+1)
- end
- if(SERVER) then
- function ENT:SetJColor(color)
- if(color.r and color.g and color.b) then
- self:SetNWInt("R",color.r)
- self:SetNWInt("G",color.g)
- self:SetNWInt("B",color.b)
- end
- end
- function ENT:SetJuice(num)
- if(type(num)=="number") then
- self:SetNWInt("Height",math.Clamp(num,0,200))
- if(num<=0) then self:Remove() end
- end
- end
- function ENT:Use(act,cal)
- if(act:GetEyeTrace().Entity==self) then
- WorldSound("vo/sandwicheat09.wav",act:GetShootPos(),75,100)
- --self:EmitSound("vo/sandwicheat09.wav")
- act:SetHealth(act:Health()+5)
- self:SetJuice(self:GetJuice()-50)
- end
- end
- end
- easylua.EndEntity(true, true)
Advertisement
Add Comment
Please, Sign In to add comment