diff options
| author | Alexander Pickering <Alexander.Pickering@anondomain.site90.net> | 2015-12-29 22:34:58 -0500 |
|---|---|---|
| committer | Alexander Pickering <Alexander.Pickering@anondomain.site90.net> | 2015-12-29 22:34:58 -0500 |
| commit | 383aebf4bd5cfaf31702b3b5bbf94d331d6256fd (patch) | |
| tree | e0e2ae28e514f55f07a4da1e475889fc8e6a0f4c /gamemode/npcsystem/npcs/bird.lua | |
| parent | 95e0c9c23c6233f3120dfed25ded206ad1c1d8e8 (diff) | |
| download | wintersurvival2-383aebf4bd5cfaf31702b3b5bbf94d331d6256fd.tar.gz wintersurvival2-383aebf4bd5cfaf31702b3b5bbf94d331d6256fd.tar.bz2 wintersurvival2-383aebf4bd5cfaf31702b3b5bbf94d331d6256fd.zip | |
Added dodos
Diffstat (limited to 'gamemode/npcsystem/npcs/bird.lua')
| -rw-r--r-- | gamemode/npcsystem/npcs/bird.lua | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/gamemode/npcsystem/npcs/bird.lua b/gamemode/npcsystem/npcs/bird.lua index 007c16a..d09f1ef 100644 --- a/gamemode/npcsystem/npcs/bird.lua +++ b/gamemode/npcsystem/npcs/bird.lua @@ -36,30 +36,43 @@ function NPC:Behave() print("Going into bird's custom behaviour")
while ( true ) do
self:StartActivity( ACT_IDLE ) -- walk anims
- self.loco:SetDesiredSpeed( 100 ) -- walk speeds
- self:MoveToPos( self:GetPos() + Vector( math.Rand( -1, 1 ), math.Rand( -1, 1 ), 0 ) * 200 ) -- walk to a random place within about 200 units (yielding)
-
-
- -- revert to idle activity
-
-
self:PlaySequenceAndWait( "Idle01" ) -- Sit on the floor
--Check if there are any players nearby
local players = ents.FindByClass("Player")
+ local playernearby = false
for k,v in pairs(players) do
local fardist = 800
local closedist = 300
+ local removedist = 2000
local iscrouched = v:Crouching()
local dist = v:GetPos():Distance(self:GetPos())
- if((dist < fardist and not iscrouched) or (dist < closedist)) then
+ --Remove ourselves if there's noone nearby
+ if(dist > 2000) then
+ playernearby = true
+ end
+ --Keep flying away as long as we're being chased
+ while((dist < fardist and not iscrouched) or (dist < closedist)) do
self:StartActivity(ACT_FLY)
- print("I should fly away")
self:SetSequence( "Fly01" )
- local topos = self:GetPos() + Vector( math.Rand( -1, 1 ), math.Rand( -1, 1 ), 0 ) * 1000
+
+ --Find a position in roughly the oposite direction of the player
+ local tpos = self:GetPos()
+ local ppos = v:GetPos()
+ local direction = Vector(tpos.x - ppos.x, tpos.y - ppos.y, tpos.z - ppos.z)
+ direction:Normalize()
+ local addition = direction * 1000
+ local topos = self:GetPos() + addition
self:MoveToPos(topos)
- print("Flying to (" .. topos.x .. "," .. topos.y .. "," .. topos.z .. ")")
+
+ --Check to see if we're being chased
+ iscrouched = v:Crouching()
+ dist = v:GetPos():Distance(self:GetPos())
end
end
+ if not playernearby then
+ local di = DamageInfo()
+ self:BecomeRagdoll(di)
+ end
--self:SetSequence( "sit_ground" ) -- Stay sitting
--coroutine.wait( self:PlayScene( "scenes/eli_lab/mo_gowithalyx01.vcd" ) ) -- play a scene and wait for it to finish before progressing
-- Get up
|
