From 9afec47237a8d2ff5e3fbc95e1a084cba37e35af Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 18 Jan 2016 20:21:56 -0500 Subject: Modified npc's to not crash when checking attack priority on a nil target --- gamemode/npcsystem/npcs/antlion1.lua | 1 + gamemode/npcsystem/npcs/antlion2.lua | 1 + gamemode/npcsystem/npcs/antlion3.lua | 1 + gamemode/npcsystem/npcs/antlion4.lua | 1 + gamemode/npcsystem/npcs/bird.lua | 1 + gamemode/npcsystem/npcs/zombie.lua | 1 + 6 files changed, 6 insertions(+) diff --git a/gamemode/npcsystem/npcs/antlion1.lua b/gamemode/npcsystem/npcs/antlion1.lua index 4e35cb3..d772603 100644 --- a/gamemode/npcsystem/npcs/antlion1.lua +++ b/gamemode/npcsystem/npcs/antlion1.lua @@ -87,6 +87,7 @@ NPC.Attacks = { --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) + if not ply then return 0 end local plypos = ply:GetPos() local mypos = self:GetPos() if not plypos then return 0 end diff --git a/gamemode/npcsystem/npcs/antlion2.lua b/gamemode/npcsystem/npcs/antlion2.lua index 353b3cd..5d1a435 100644 --- a/gamemode/npcsystem/npcs/antlion2.lua +++ b/gamemode/npcsystem/npcs/antlion2.lua @@ -109,6 +109,7 @@ NPC.Attacks = { --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) + if not ply then return 0 end local plypos = ply:GetPos() local mypos = self:GetPos() if not plypos then return 0 end diff --git a/gamemode/npcsystem/npcs/antlion3.lua b/gamemode/npcsystem/npcs/antlion3.lua index 0f09214..f5f5486 100644 --- a/gamemode/npcsystem/npcs/antlion3.lua +++ b/gamemode/npcsystem/npcs/antlion3.lua @@ -121,6 +121,7 @@ NPC.Attacks = { --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) + if not ply then return 0 end local plypos = ply:GetPos() local mypos = self:GetPos() if not plypos then return 0 end diff --git a/gamemode/npcsystem/npcs/antlion4.lua b/gamemode/npcsystem/npcs/antlion4.lua index 6e2c7be..e8e7a88 100644 --- a/gamemode/npcsystem/npcs/antlion4.lua +++ b/gamemode/npcsystem/npcs/antlion4.lua @@ -111,6 +111,7 @@ NPC.Attacks = { --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) + if not ply then return 0 end local plypos = ply:GetPos() local mypos = self:GetPos() if not plypos then return 0 end diff --git a/gamemode/npcsystem/npcs/bird.lua b/gamemode/npcsystem/npcs/bird.lua index 48ec71a..af63e76 100644 --- a/gamemode/npcsystem/npcs/bird.lua +++ b/gamemode/npcsystem/npcs/bird.lua @@ -72,6 +72,7 @@ NPC.Target = nil 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) + if not ply then return 0 end local plypos = ply:GetPos() local mypos = self:GetPos() if not plypos then return 0 end diff --git a/gamemode/npcsystem/npcs/zombie.lua b/gamemode/npcsystem/npcs/zombie.lua index 2ae78e8..c18083e 100644 --- a/gamemode/npcsystem/npcs/zombie.lua +++ b/gamemode/npcsystem/npcs/zombie.lua @@ -88,6 +88,7 @@ NPC.Attacks = { --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) + if not ply then return end local plypos = ply:GetPos() local mypos = self:GetPos() if not plypos then return 0 end -- cgit v1.2.3-70-g09d2