--- [[[ Zombie Zone Script ]]] ------ [[ Includes ]] ------ [[ Globals ]] --------g_arena = nil -- The global arena class, to avoid having to pass it around functionsg_bGameRunning = false -- Is the game running?g_winner = nil -- The player who wong_winnerevent = 0 -- The eventid for the repeating winner event--- [[ Other Functions ]] ----- ChooseZombie = For randomly choosing a zombie type function ChooseZombie(zombie) -- We want to randomly choose a zombie type to use local rand = math.random(1, 100) if (rand < 32) then zombie:setVehicle(100) -- Normal Zombie elseif (rand < 54) then zombie:setVehicle(103) -- Alien Zombie elseif (rand < 75) then zombie:setVehicle(102) -- Flesh Zombie elseif (rand < 87) then zombie:setVehicle(101) -- Assassin Zombie elseif (rand < 95) then zombie:setVehicle(105) -- Devourer Zombie else -- Tell arena! Tough zombie g_arena:message(zombie.m_name .. " has spawned as a super-zombie!") zombie:setVehicle(104) -- Tough Zombie endend-- Fireworks = For creating celebration explosions around the player :Dfunction Fireworks(eventid) -- Create an explosion randomly around the player local c = g_winner:coords() g_arena:explosion_create("GG Explode", c.x + math.random(-60, 60), c.y + math.random(-60, 60), c.rotation)end--- [[ Event Functions ]] ---function Vehicle_OnCreate(born)endfunction Vehicle_OnDeath(victim, killer)endfunction Item_OnPickUp(looter, loot, loot_type, amounttopickup) -- If he picked up an engineer kit if (loot_type.m_name == "Engineer Kit") then -- Player needs to be a marine, and only picking up one kit if (amounttopickup > 1) then looter:message("You are only allowed one engineer kit.") return false elseif (looter:getVehicle():vehicletypeid() >= 15) then looter:message("You need to be a marine to become an engineer.") return false end -- Otherwise, we want to make him an engineer. :) g_arena:message(looter.m_name .. " has become an engineer.") looter:setVehicle(15) -- ..and give him a few turrets to place local stopabuse = looter:inventory_find("Plasma Turret Kit") looter:inventory_modify("Plasma Turret Kit", 2 - stopabuse) local stopabuse = looter:inventory_find("Wall Kit") looter:inventory_modify("Wall Kit", 10 - stopabuse) -- Now we want to destroy the item local itmstruct = loot:get_struct() if (itmstruct.amount == 1) then loot:destroy() else itmstruct.amount = itmstruct.amount - 1 loot:update() end return false end return trueendfunction Arena_OnCreate(arena) -- Set our global value g_arena = arena -- Initialize random math.randomseed(os.time())endfunction Arena_OnGameStart() -- Destroy the celebration event event_destroy(g_winnerevent) -- 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 -- Spawn some engineer kits local numengys = g_arena:num() / 10 for x = 1, numengys do -- Randomize the spawn local randx = math.random(-100, 100) local randy = math.random(-100, 100) -- Spawn a kit somewhere around the center g_arena:item_create("Engineer Kit", 1, 2400 + randx, 2608 + randy) end -- 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) -- Remove any engineer items marine:inventory_modify("Plasma Turret Kit", -1000) marine:inventory_modify("Wall Kit", -1000) -- 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 endendfunction 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 = falseendfunction Player_OnDeath(killer, victim) -- If the game isn't running, we don't want to do any of the other dynamics if g_bGameRunning == false then return end -- Check if the victim is a marine (isn't a zombie) if (victim:getVehicle():vehicletypeid() < 20) then -- First, we'll stick a corpse on top of him local pos = victim:coords() g_arena:vehicle_create(300, pos.x, pos.y, pos.rotation) -- Remove any engineer items victim:inventory_modify("Plasma Turret Kit", -1000) victim:inventory_modify("Wall Kit", -1000) -- We want to turn the player into a zombie victim:team_change("Zombies", "") ChooseZombie(victim) -- Give him his crown back victim:setcrown(true, 0) -- 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_winner = winner g_arena:message(winner.m_name .. " was the last marine standing! Celebrate!") -- Let him celebrate :) winner:setVehicle(50) g_winnerevent = event_create(Fireworks, -350) 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 -- If the victim is a zombie elseif (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() < 15) 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 endend