diff options
| author | Alexander Pickering <Alexander.Pickering@anondomain.site90.net> | 2016-01-10 21:10:03 -0500 |
|---|---|---|
| committer | Alexander Pickering <Alexander.Pickering@anondomain.site90.net> | 2016-01-10 21:10:03 -0500 |
| commit | 31641879af7d32f1570b59bb5d27a193ed0931c3 (patch) | |
| tree | 65799bc24214382c26ee212b460a6b84ace5b8e9 /gamemode/npcsystem/npcs/bird.lua | |
| parent | 312f321f771960872fb3ee3e1bb24ebaf91aa38f (diff) | |
| download | wintersurvival2-31641879af7d32f1570b59bb5d27a193ed0931c3.tar.gz wintersurvival2-31641879af7d32f1570b59bb5d27a193ed0931c3.tar.bz2 wintersurvival2-31641879af7d32f1570b59bb5d27a193ed0931c3.zip | |
Fixed npc's breaking when they don't have an initial target
Diffstat (limited to 'gamemode/npcsystem/npcs/bird.lua')
| -rw-r--r-- | gamemode/npcsystem/npcs/bird.lua | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gamemode/npcsystem/npcs/bird.lua b/gamemode/npcsystem/npcs/bird.lua index 7b19457..d8dfb30 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 = {}
-
+`w`
--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())
+ local plypos = ply:GetPos()
+ local mypas = self:GetPos()
+ if not plypos then return 0 end
+ local dist = plypos:Distance(mypos)
return self.Stats["AwareDist"] - dist
end
|
