From b94ae1f187c46f1f775575daadc893a35890b6c3 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sat, 2 Jan 2016 22:24:46 -0500 Subject: Introduced npc-determined spawn position --- gamemode/npcsystem/aidirector.lua | 5 ++- gamemode/npcsystem/npcs/zombie.lua | 76 -------------------------------------- 2 files changed, 3 insertions(+), 78 deletions(-) (limited to 'gamemode/npcsystem') diff --git a/gamemode/npcsystem/aidirector.lua b/gamemode/npcsystem/aidirector.lua index f5cf2b4..a78e41e 100644 --- a/gamemode/npcsystem/aidirector.lua +++ b/gamemode/npcsystem/aidirector.lua @@ -94,8 +94,9 @@ hook.Add("Tick","SpawnAmbient",function() --print("Appropriate place found, spawning bird)") local randnpcnum = math.Round(math.Rand(0, #ambientnpcs)) local npc = GetNpcByName(ambientnpcs[randnpcnum]) - if(npc:) - SpawnNpcByName(ambientnpcs[randnpcnum],Pos) + if(npc:SpawnLocations(Pos)) then + SpawnNpcByName(ambientnpcs[randnpcnum],Pos) + end break end end diff --git a/gamemode/npcsystem/npcs/zombie.lua b/gamemode/npcsystem/npcs/zombie.lua index 216ca43..a725a04 100644 --- a/gamemode/npcsystem/npcs/zombie.lua +++ b/gamemode/npcsystem/npcs/zombie.lua @@ -108,82 +108,6 @@ function NPC:Stuck() --If we're stuck, jump backwards end ---What to replace ENT:RunBehaviour with ---[[ -function NPC:Behave() - --[[ - print("Going into antlion's custom behaviour") - while ( true ) do - --self:PlaySequenceAndWait( "Idle" ) - - --Main loop for ai - - --Update aware enemies - local players = ents.FindByClass("Player") - for k,v in pairs(players) do - if(v:IsPigeon()) then continue end - local dist = v:GetPos():Distance(self:GetPos()) - if( dist < self.Stats["AwareDist"]) then - table.insert(self.AwareEnemies,v) - end - end - - --Find the enemy with the highest priority - local maxpriority = -1 - local maxprioritytarget = nil - for k,v in pairs(self.AwareEnemies) do - local priority = self:AttackPriority(v) - if(priority > maxpriority) then - maxpriority = priority - maxprioritytarget = v - end - end - self.Target = maxprioritytarget - - --If we can't find anyone to attack, just stay idle - if(self.Target == nil) then - print("Couldn't find anyone to attack!") - --Play an idle sequence - local randanim = math.Round(math.Rand(0,#self.IdleSequences)) - self:PlaySequenceAndWait( self.IdleSequences[randanim] ) - self:StartActivity( ACT_IDLE ) - else - --We have a target to attack! - print("We found something to attack!") - --Find which attack will do the most dammage - local maxdammage = -1 - local maxdammagefunc = nil - for k,v in pairs(self.Attacks) do - local dammagefunc = nil - local attackfunc = nil - for i,j in pairs(v) do - dammagefunc = i - attackfunc = j - end - print("Using damagefunc:") - print(dammagefunc) - local dammage = dammagefunc(self, self.Target) - print("dammage is ") - print(dammage) - if(dammage > maxdammage) then - maxdammage = dammage - maxdammagefunc = attackfunc - end - end - - --Do that attack - if(maxdammagefunc) then - maxdammagefunc(self, self.Target) - else - print("It looked like we could attack, but we can't!") - end - end - --coroutine.yield() - end - - coroutine.yield() -end ---]] --These are just here to tell the editors/develoeprs what functions are available.. dont un-comment them out, as this could affect all the items. /* function NPC:OnSpawn() -- cgit v1.2.3-70-g09d2