--- [[[ Zombie Zone Script ]]] --- --- [[ Includes ]] --- --- [[ Globals ]] -------- g_arena = nil -- The global arena class, to avoid having to pass it around functions g_bGameRunning = false -- Is the game rnning? --- [[ Other Functions ]] --- function ChooseZombie(zombie) -- We want to randomly choose a zombie type to use local rand = math.random(1, 100) if (rand < 35) then zombie:setVehicle(100) -- Normal Zombie elseif (rand < 60) then zombie:setVehicle(103) -- Alien Zombie elseif (rand < 80) then zombie:setVehicle(102) -- Flesh Zombie elseif (rand < 95) then zombie:setVehicle(101) -- Assassin Zombie else -- Tell arena! Tough zombie g_arena:message(zombie.m_name .. " has spawned as a super-zombie!") zombie:setVehicle(104) -- Tough Zombie end end --- [[ Event Functions ]] --- function Arena_OnCreate(arena) -- Set our global value g_arena = arena -- Initialize random math.randomseed(os.time()) end function Arena_OnGameStart() -- Ensure the player that the game has started g_arena:message("Game started, you cannot unspec until the game is finished.") -- Lock the arena g_arena:lock(true) g_bGameRunning = true -- Calculate the number of zombies we need local amount = g_arena:num() / 5 -- Turn everyone into marines for x = 1, g_arena:num() do local marine = g_arena:get(x) -- Reset their zombie kills marine:setstat(0, 0) -- If they're not in spec if marine:spectator() == false then -- Make him a marine marine:team_change("Marines", "") marine:setVehicle(10) -- Warp all marines to the center marine:warp(2400, 2608, 80) end end -- Locate the player ids which we will turn to zombies local numplayers = g_arena:num() for x = 0, amount do local zombie = g_arena:get(math.random(1, numplayers)) -- If he's not in spec and not already a zombie if (zombie:spectator() == false) and (zombie:getVehicle():vehicletypeid() < 100) then -- Turn him zombie:team_change("Zombies", "") ChooseZombie(zombie) -- Warp zombies anywhere zombie:warp(2400, 2608, 4800) else -- We'll have to try again x = x - 1 end end end function Arena_OnGameEnd() -- Unlock the arena g_arena:lock(false) g_arena:message("Game is about to start... enter the game now to play.") g_bGameRunning = false end function Player_OnDeath(killer, victim) -- Check if the victim is a marine (isn't a zombie) if (victim:getVehicle():vehicletypeid() < 20) then -- We want to turn the player into a zombie victim:team_change("Zombies", "") ChooseZombie(victim) -- Give him his crown back victim:setcrown(true, 0) -- If the game isn't running, we don't want to do any of the other dynamics if g_bGameRunning == false then return end -- Are we down to one marine yet? local marineteam = team_fromname(g_arena, "Marines") if marineteam:exists() then -- Look to see how many players are actually left playing local nummarines = 0 local winner for x = 1, marineteam:num() do if marineteam:get(x):spectator() == false then nummarines = nummarines + 1 winner = marineteam:get(x) end end -- If there is only one surviving marine if nummarines == 1 then -- Break the news! g_arena:message(winner.m_name .. " was the last marine standing! Celebrate!") -- Let him celebrate :) winner:setVehicle(50) local zombieteam = team_fromname(g_arena, "Zombies") -- Take the crowns from all the zombies if zombieteam:exists() then for x = 1, zombieteam:num() do zombieteam:get(x):setcrown(false, 0) end end end end end -- If the game isn't running, we don't want to do any of the other dynamics if g_bGameRunning == false then return end -- If the victim is a zombie if (victim:getVehicle():vehicletypeid() >= 100) then -- Give him his crown back victim:setcrown(true, 0) -- Make him a random class ChooseZombie(victim) -- If the killer is a marine.. if (killer:getVehicle():vehicletypeid() < 20) then -- Get his zombie kills local zombiekills = killer:getstat(0) zombiekills = zombiekills + 1 -- Is he ready for an upgrade? if (zombiekills == 2) then killer:setVehicle(11) elseif (zombiekills == 4) then killer:setVehicle(12) elseif (zombiekills == 6) then killer:setVehicle(13) end killer:setstat(0, zombiekills) end end end