From 39eceade5e7423e7e331e8e18ce529b95d24ff5e Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Thu, 25 Oct 2018 22:01:29 -0400 Subject: Randomized the locations zombies will spawn at --- gamemode/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gamemode') diff --git a/gamemode/init.lua b/gamemode/init.lua index 5a5c72a..40587fd 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -788,6 +788,13 @@ function GM:GetZombieClass() end function GM:NPCRespawnThink() + --Pick a random player, sort spawns based on where they are + local allplayers = player.GetAll() + local rngplayer = allplayers[math.random(#allplayers)] + --Randomize our spawn list based on the palyer we chose + GAMEMODE.NPCSpawns = table.sort(GAMEMODE.NPCSpawns, function(a,b) + return a:GetPos():Distance(rngplayer:GetPos()) < b:GetPos():Distance(rngplayer:GetPos()) + end) for k,v in pairs( ( GAMEMODE.NPCSpawns or {} ) ) do -- cgit v1.2.3-70-g09d2