summaryrefslogtreecommitdiff
path: root/gamemode
diff options
context:
space:
mode:
authorAlexander Pickering <alex@cogarr.net>2018-10-25 22:01:29 -0400
committerAlexander Pickering <alex@cogarr.net>2018-10-25 22:01:29 -0400
commit39eceade5e7423e7e331e8e18ce529b95d24ff5e (patch)
tree3fa5b1ed284b219826ee27f8c985f2582cf2b025 /gamemode
parent84324e0e66c8bd7046490cc53d59cfa7b964bea3 (diff)
downloadredead-39eceade5e7423e7e331e8e18ce529b95d24ff5e.tar.gz
redead-39eceade5e7423e7e331e8e18ce529b95d24ff5e.tar.bz2
redead-39eceade5e7423e7e331e8e18ce529b95d24ff5e.zip
Randomized the locations zombies will spawn atHEADmaster
Diffstat (limited to 'gamemode')
-rw-r--r--gamemode/init.lua7
1 files changed, 7 insertions, 0 deletions
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