diff options
Diffstat (limited to 'entities')
| -rw-r--r-- | entities/entities/npc_nb_base/shared.lua | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/entities/entities/npc_nb_base/shared.lua b/entities/entities/npc_nb_base/shared.lua index c2557bb..5be63a5 100644 --- a/entities/entities/npc_nb_base/shared.lua +++ b/entities/entities/npc_nb_base/shared.lua @@ -68,12 +68,13 @@ function ENT:Initialize() self.DmgTable = {} self.LastPos = self.Entity:GetPos() - self.Stuck = CurTime() + 10 + self.Stuck = CurTime() + 1 end function ENT:Think() - + v1 = self:GetNWVector("tracestart") + v2 = self:GetNWVector("traceend") self.Entity:OnThink() if ( self.IdleTalk or 0 ) < CurTime() then @@ -82,14 +83,14 @@ function ENT:Think() self.IdleTalk = CurTime() + math.Rand(10,20) end - if ( self.Stuck or 0 ) < CurTime() then + if self.LastPos:Distance( self.Entity:GetPos() ) < 50 then + self.Entity:StuckThink() + end - self.Entity:StuckThink() - self.Stuck = CurTime() + 10 + self.Stuck = CurTime() + 1 self.LastPos = self.Entity:GetPos() - end if self.Entity:OnFire() and self.FireDamageTime < CurTime() then @@ -173,12 +174,7 @@ function ENT:OnThink() end function ENT:StuckThink() - self.LastPos = self.LastPos or Vector(0,0,0) - if self.LastPos:Distance( self.Entity:GetPos() ) < 50 then - - self.Entity:StartRespawn() - end end @@ -643,6 +639,9 @@ function ENT:OnHitBreakable( ent ) if not IsValid( ent ) then return end + local min,max = ent:WorldSpaceAABB() + local height = max.z - min.z + if string.find( ent:GetClass(), "func_breakable" ) then ent:TakeDamage( 25, self.Entity, self.Entity ) @@ -657,6 +656,14 @@ function ENT:OnHitBreakable( ent ) ent:Remove() + elseif string.find( ent:GetClass(), "prop_physics" ) and height > 10 and ent:GetCollisionGroup() != COLLISION_GROUP_DEBRIS then + + ent:GetPhysicsObject():AddVelocity((self:GetForward()*200)+Vector(0,0,100)) + + if(height < 30) then + table.RemoveByValue(GAMEMODE.Breakables, ent) + end + else if not ent.Hits then @@ -713,10 +720,6 @@ function ENT:OnHitBreakable( ent ) end -function ENT:BehaveAct() // what does this do? - -end - function ENT:IsZombie() return true @@ -853,28 +856,11 @@ end function ENT:OnStuck() - local ent = self.Entity:GetBreakable() - - if IsValid( ent ) then - self.Obstructed = true - else - - self.Obstructed = false - - //self.loco:SetDesiredSpeed( self.BumpSpeed ) - //self.loco:Jump() - //self.loco:SetDesiredSpeed( self.BumpSpeed ) - - end - - self.loco:ClearStuck() - end function ENT:OnUnStuck() - self.Obstructed = false end @@ -929,10 +915,27 @@ function ENT:RunBehaviour() self.Entity:StartActivity( ACT_IDLE ) else - if self.Obstructed then - self.Entity:BreakableRoutine() + local tp = self:GetPos() + local fp = self:GetForward()*20 + local trdata = { + start = tp+fp+Vector(0,0,50), + endpos = fp+tp + } + local tr = util.TraceLine(trdata) + --If we can climb over this obstical, do that + if(tr.Fraction < 0.9) then + self:SetPos(tp+Vector(0,0,50)+(fp/19)) + self:PlaySequenceAndWait("pickup") + self:SetPos(tp+fp+Vector(0,0,50)) + else + self.Entity:BreakableRoutine() + end + self:SetNWVector("startrace",tr.start) + self:SetNWVector("endtrace",tr.endpos) + + self.loco:ClearStuck() coroutine.yield() |
