aboutsummaryrefslogtreecommitdiff
path: root/gamemode/npcsystem/npcs/bird.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/npcsystem/npcs/bird.lua')
-rw-r--r--gamemode/npcsystem/npcs/bird.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/gamemode/npcsystem/npcs/bird.lua b/gamemode/npcsystem/npcs/bird.lua
index 7b19457..af63e76 100644
--- a/gamemode/npcsystem/npcs/bird.lua
+++ b/gamemode/npcsystem/npcs/bird.lua
@@ -70,10 +70,13 @@ NPC.Target = nil
--All enemies that this NPC is aware of
NPC.AwareEnemies = {}
-
--Attack priority is a fucntion that takes a player, and returns an int describing it's prority to attack (higher = more important) NPC will always attack the player with the highest priority
function NPC:AttackPriority(ply)
- local dist = ply:GetPos():Distance(self:GetPos())
+ if not ply then return 0 end
+ local plypos = ply:GetPos()
+ local mypos = self:GetPos()
+ if not plypos then return 0 end
+ local dist = plypos:Distance(mypos)
return self.Stats["AwareDist"] - dist
end