From 10ef2a646da0b67d5c1baaed9ac4b0b17a800a98 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 7 Mar 2016 16:52:07 -0500 Subject: Cleanued up crow code --- entities/entities/ws_pigeon/cl_init.lua | 56 +++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 20 deletions(-) (limited to 'entities') diff --git a/entities/entities/ws_pigeon/cl_init.lua b/entities/entities/ws_pigeon/cl_init.lua index 8ac0557..da6e4a8 100644 --- a/entities/entities/ws_pigeon/cl_init.lua +++ b/entities/entities/ws_pigeon/cl_init.lua @@ -8,27 +8,43 @@ function ENT:Initialize() self.Player = NULL self.Seq = -1 self.Rate = 1 - - self.AutomaticFrameAdvance = true - - timer.Simple(0.5,function() if (IsValid(self)) then self:InitializeOwner() end end) + + self.AutomaticFrameAdvance = true + + timer.Simple(0.5,function() + if (IsValid(self)) then + self:InitializeOwner() + end + end) end function ENT:InitializeOwner() for k,v in pairs(player.GetAll()) do - if (IsValid(v.Pigeon) and v.Pigeon == self) then self.Player = v v.DeathPos = nil return end + if (IsValid(v.Pigeon) and v.Pigeon == self) then + self.Player = v + v.DeathPos = nil + return + end end - - timer.Simple(0.5,function() if (IsValid(self)) then self:InitializeOwner() end end) + + timer.Simple(0.5,function() + if (IsValid(self)) then + self:InitializeOwner() + end + end) end function ENT:OnRemove() if (IsValid(self.Player)) then - self.Player.DeathPos = self:GetPos() + self.Player.DeathPos = self:GetPos() local Rag = self:BecomeRagdollOnClient( ) local Phy = Rag:GetPhysicsObject() Phy:ApplyForceCenter(self:GetVelocity()*Phy:GetMass()*12) - timer.Simple(3,function() if (IsValid(Rag)) then Rag:Remove() end end) + timer.Simple(3,function() + if (IsValid(Rag)) then + Rag:Remove() + end + end) end end @@ -36,19 +52,19 @@ function ENT:Think() local Pos = self:GetPos() local vel = self:GetVelocity() local velL = vel:Length() - + local tr = util.TraceLine({ start = Pos, endpos = Pos - Vector(0,0,12), filter = self, }) - + local ground = tr.Hit - + if (velL < 16 and !ground) then self.Seq = 0 self.Rate = 0.7 - + elseif (ground) then if (velL > 30) then self.Rate = 2 @@ -66,20 +82,20 @@ function ENT:Think() else self.Seq = 7 end - - if (self:GetSequence() != self.Seq) then self:SetSequence(self.Seq) end - + + if (self:GetSequence() != self.Seq) then self:SetSequence(self.Seq) end + local delta = UnPredictedCurTime()-self.lastdraw self.lastdraw = UnPredictedCurTime() - + self.Cycle = self.Cycle + delta*self.Rate if (self.Cycle > 1) then self.Cycle = 0 end - + self:SetCycle(self.Cycle) end function ENT:Draw() if (!IsValid(self.Player)) then return end - + self:DrawModel() -end \ No newline at end of file +end -- cgit v1.2.3-70-g09d2