-- Player stat settings (used for player:setstat & player:getstat) -- 0 - Kills -- 1 - Deaths -- 2 - Crown kills?????? (to-do) -- 3 - Consec kills (current) -- 5 - Has Crown? Boolean yes/no 1/0 -- 9 - Consec kills (best) -- For NiTe: Added in expItem and cashItem, and fiddled with lua items such as burrow/burrowing -- Warp graphics when ds etc -- Other crown detect items -- Stat stuff.. and show last crown - -- C4/translocator to-do -- Keep same hp when using warp items, such as burrow g_arena = nil -- holds the arena object g_bGameRunningArena = false -- says whether the game is running or not, this is false when the Arena_OnGameEnd is called g_bGameRunningStats = false -- says whether the game is running or not, this is false when the DisplayStats is called g_statsEvent = 0 -- holds the event for displaying stats when the game ends g_crownEvent = 0 --holds the event for continually checking the status of all the crowns g_gameTime = nil -- holds the game time function Arena_OnCreate(arena) g_arena = arena math.randomseed(os.time()) end function Player_OnWarpItem(user, itemid, target) g_arena:message("" .. itemid) if (itemid == 184) then -- Telekinesis -- Click on target player, and use, displays coords if (target:valid() == false) then user:message("No target selected") user:inventory_modify("Telekinesis", 1) return false elseif (target:crown() == false) then user:message("Target had no crown, Telekinesis wasted.") return false else local coordsArray = GetCoordsArray(target:coords()) local x = coordsArray[0] local y = coordsArray[1] user:message("" .. target.m_name .. " has been sensed at " .. x .. y .. "") return true end elseif (itemid == 185) then -- Adv. Telekinesis -- Use and it displays all crowners local crownString = "" for x = 1, g_arena:num() do local player = g_arena:get(x) if (player:crown() == true) then local coordsArray = GetCoordsArray(player:coords()) local x = coordsArray[0] local y = coordsArray[1] crownString = (crownString .. " " .. player.m_name .. ":" .. x .. y .. "") end end if (crownString == "") then user:message("No crowns sensed in the arena, Telekenesis wasted.") return false else user:message("" .. crownString .. "") end elseif (itemid == 81) then -- Burrow -- Change the alien into his burrowing form -- Get him, and his vehicle id, and store in an array local burrowArray = { } burrowArray[0] = user burrowArray[1] = user:getVehicle():vehicletypeid() g_arena:message("" .. burrowArray[1] .. "") -- Change him to the burrow vehicle user:setVehicle(170) -- Give him an item to show how long he's got left user:inventory_modify("Burrowing", 1) -- And start an event to change him back in 5 seconds event_createarg(ChangeBackToOldVehicle, 5000, g_arena, burrowArray) elseif (itemid == 137) then -- Greater Burrow -- Change the alien into his burrowing form -- Get him, and his vehicle id, and store in an array local burrowArray = { } burrowArray[0] = user burrowArray[1] = user:getVehicle():vehicletypeid() g_arena:message("" .. burrowArray[1] .. "") -- Change him to the burrow vehicle user:setVehicle(170) -- Give him an item to show how long he's got left user:inventory_modify("Burrowing!", 1) -- And start an event to change him back in 5 seconds event_createarg(ChangeBackToOldVehicle, 8000, g_arena, burrowArray) elseif (itemid == 138) then -- Permeability -- Get him, and his vehicle id, and store in an array local permArray = { } permArray[0] = user permArray[1] = user:getVehicle():vehicletypeid() -- Change him to the permea vehicle user:setVehicle(159) -- Give him an item to show how long he's got left user:inventory_modify("Permeable", 1) -- And start an event to change him back in 5 seconds event_createarg(ChangeBackToOldVehicle, 5000, g_arena, permArray) elseif (itemid == 139) then -- Enhanced Permeability -- Get him, and his vehicle id, and store in an array local permArray = { } permArray[0] = user permArray[1] = user:getVehicle():vehicletypeid() -- Change him to the permea vehicle user:setVehicle(159) -- Give him an item to show how long he's got left user:inventory_modify("Permeable!", 1) -- And start an event to change him back in 5 seconds event_createarg(ChangeBackToOldVehicle, 8000, g_arena, permArray) elseif (itemid == 244) then -- Give steroids to all the team around you local radius = 50 local players = {} local numplayers = g_arena:GetPlayersInArea(players, user:coords().x, user:coords().y, 50) if (numplayers > 0) then for i = 1, numplayers do local player = players[i] -- Is on the users team? if (player:getTeam().m_name == user:getTeam().m_name) then player:inventory_modify("Steroid Lite",1) end end end elseif (itemid == 57) then g_arena:message("" .. user.m_name .. " has just warped to the DS") elseif (itemid == 25) then g_arena:message("" .. user.m_name .. " has just warped to another player") end return true end function Msg_OnCommand(player, command, payload, recipient, msg_type) if (command == "?breakdown") then --Breakdown(player) player:message("?breakdown not added in yet, to-do") end end function ChangeBackToOldVehicle(playerArray) local player = playerArray[0] local oldVehicleID = playerArray[1] if (player:valid()) then player:setVehicle(oldVehicleID) end return true end function GetCoordsArray(coords) local x = coords.x local y = coords.y local lettercoord = "" local numbercoord = "" x = math.floor((x / 80) / 16) y = ((y / 80) / 16) + 1 local numbercoord = ("" .. math.floor(y) .. "") if (x == 0) then lettercoord = "A" elseif (x == 1) then lettercoord = "B" elseif (x == 2) then lettercoord = "C" elseif (x == 3) then lettercoord = "D" elseif (x == 4) then lettercoord = "E" elseif (x == 5) then lettercoord = "F" elseif (x == 6) then lettercoord = "G" elseif (x == 7) then lettercoord = "H" elseif (x == 8) then lettercoord = "I" elseif (x == 9) then lettercoord = "J" elseif (x == 10) then lettercoord = "K" elseif (x == 11) then lettercoord = "L" elseif (x == 12) then lettercoord = "M" elseif (x == 13) then lettercoord = "N" elseif (x == 14) then lettercoord = "O" elseif (x == 15) then lettercoord = "P" else lettercoord = "LuaError" end local coordsArray = {} coordsArray[0] = lettercoord coordsArray[1] = numbercoord return coordsArray end function Player_OnJoin(player) player:message("Welcome to the tournament " .. player.m_name .. ", may your weapons of choice serve you well") WipePlayerStats(player) end function Vehicle_OnProduce(vehicle, user, menuitem) return true end function DisplayStats(ev) g_bGameRunningStats = false local bestKiller = "" local bestVictim = "" local bestCrowns = "" local bestCon = "" local mostKills = 0 local mostDeaths = 0 local mostCrowns = 0 local mostCon = 0 for x = 1, g_arena:num() do --This gets the person with most kills local player = g_arena:get(x) if (player:getstat(0) > mostKills) then mostKills = player:getstat(0) bestKiller = player.m_name elseif (player:getstat(0) == mostKills) then bestKiller = ("" .. bestKiller .. ", " .. player.m_name .. "") end if (player:getstat(1) > mostDeaths) then mostDeaths = player:getstat(1) bestVictim = player.m_name elseif (player:getstat(1) == mostDeaths) then bestVictim = ("" .. bestVictim .. ", " .. player.m_name .. "") end if (player:getstat(2) > mostDeaths) then mostCrowns = player:getstat(2) bestCrowns = player.m_name elseif (player:getstat(2) == mostCrowns) then bestCrowns = ("" .. bestCrowns .. ", " .. player.m_name .. "") end if (player:getstat(9) > mostCon) then mostCon = player:getstat(9) bestCon = player.m_name elseif (player:getstat(9) == mostCon) then bestCon = ("" .. bestCon .. ", " .. player.m_name .. "") end end ------------------------------------------------------------------------- -- GAME TIME STATISTICS -- if (g_gameTime ~= nil) then local diff = (os.time() - g_gameTime) local minutes = math.floor(diff / 60) if (minutes == 1) then local seconds = (diff-60*math.floor(diff/60)) g_arena:message("Total Game Time: " .. minutes .. " minute, " .. seconds .. " seconds") elseif (minutes > 1) then local seconds = (diff-60*math.floor(diff/60)) g_arena:message("Total Game Time: " .. minutes .. " minutes, " .. seconds .. " seconds") else g_arena:message("Total Game Time: " .. diff .. " seconds") end else g_arena:message("No game is running, weird..") end ------------------------------------------------------------------------ ------------------------------------------------------------------------ -- PLAYER STATISTICS -- if (mostKills == 0) then g_arena:message("!_ No one got any kills!") else g_arena:message("!_ Most Kills: " .. bestKiller .. "(" .. mostKills .. ")") end if (mostCrowns == 0) then g_arena:message("!_ No one got any crowner kills!") else g_arena:message("!_ Most Crowner Kills: " .. bestCrowns .. "(" .. mostCrowns .. ")") end if (mostCon == 0) then g_arena:message("!_ No one got any consecutive kills!") else g_arena:message("!_ Most Consecutive Kills: " .. bestCon .. "(" .. mostCon .. ")") end if (mostDeaths == 0) then g_arena:message("!_ No one got any deaths!") else g_arena:message("!_ Most Deaths: " .. bestVictim .. "(" .. mostDeaths .. ")") end ------------------------------------------------------------------------ return true end function Arena_OnGameEnd() g_bGameRunningArena = false event_destroy(g_crownEvent) g_statsEvent = event_create(DisplayStats, 200, g_arena) end function Arena_OnGameStart() g_bGameRunningArena = true g_bGameRunningStats = true g_gameTime = os.time() for x = 1, g_arena:num() do local player = g_arena:get(x) WipePlayerStats(player) end g_testEvent = event_create(Eventt, -100, g_arena) end function WipePlayerStats(player) player:setstat(0,0) player:setstat(1,0) player:setstat(2,0) player:setstat(3,0) player:setstat(4,0) player:setstat(5,0) end function Player_OnDeath(killer, victim) ----=== STAT CODE ===---- if (g_bGameRunningStats == false) then -- if the game isn't running, don't record stats return elseif (killer:valid() == false) then -- if the killer was a turret/terrain we just increase the death count IncreaseDeath(victim) return elseif (killer.m_name == victim.m_name) then -- if the player killed themself we just increase the death count IncreaseDeath(victim) return else -- else one player killed another player, so we increase the kill count and death count respectively IncreaseKill(killer) IncreaseDeath(victim) end ----=== CROWN CODE ===---- if (victim:getstat(5) == 1) then -- then the victim had a crown local stolecrown = false if (g_bGameRunningArena == false) then-- the game HAS ended, but the stats havn't been shown yet, this means this kill must been the last kill, let them know they killed the last crowner local reward = (g_arena:num() * 10) killer:inventory_modify("expItem", reward) killer:inventory_modify("cashItem", reward) killer:message("!You killed the last crowner! - received " .. reward .. " bonus cash/xp") IncreaseCrownerKill(killer) --TEST CODE:::: To see if we can see who the winning crowner is killer:setstat(5,0) for x = 1, g_arena:num() do local player = g_arena:get(x) if (player:getstat(5) == 1) then g_arena:message("" .. player.m_name .. " was the last crowner...? (test)") end end --::::::::::::::::::::: end if ((killer:getstat(5) == 0) and (killer:crown() == true)) then-- if they didn't have a crown, but they now do, they must have stolen the crown! stolecrown = true killer:setstat(5,1) -- set it so he now shows to have a crown g_arena:message("!" .. killer.m_name .. " has stolen " .. victim.m_name .. "'s crown!") end if (g_bGameRunningArena == true) then CheckCrowns() local reward = ((g_arena:numplaying() - g_numCrowners) * 5) killer:inventory_modify("expItem", reward) killer:inventory_modify("cashItem", reward) killer:message("!You killed 1 of the last " .. (g_crowners + 1).. " crowners - received " .. reward .. " bonus cash/xp") IncreaseCrownerKill(killer) end end victim:setstat(5,0) -- set it so the victim no longer has a crown end function UpdateCrownList(ev) for x = 1, g_arena:num() do local player = g_arena:get(x) if (player:crown() == true) then player:setstat(5,1) else player:setstat(5,0) end end return false end function CheckCrowns(ev) local crowners = 0 for x = 1, g_arena:num() do local player = g_arena:get(x) if (player:crown() == true) then player:setstat(5,1) crowners = (crowners + 1) end end g_numCrowners = crowners return false end function IncreaseKill(killer) killer:setstat(0,(killer:getstat(0) + 1)) -- increase kills killer:setstat(3,(killer:getstat(3) + 1)) if (killer:getstat(3) > killer:getstat(8)) then killer:setstat(9,killer:getstat(3)) end local kills = killer:getstat(3) local x = killer:coords().x local y = killer:coords().y if (kills == 2) then -- g_arena:explosion_create("Double Kill", x, y, 0, 0) elseif (kills == 5) then g_arena:explosion_create("Killing Spree", x, y, 0, 0) elseif (kills == 10) then g_arena:explosion_create("Rampage", x, y, 0, 0) elseif (kills == 15) then g_arena:explosion_create("Dominating", x, y, 0, 0) elseif (kills == 20) then g_arena:explosion_create("Unstoppable", x, y, 0, 0) elseif (kills == 25) then g_arena:explosion_create("Slaughter", x, y, 0, 0) elseif (kills == 30) then g_arena:explosion_create("Wicked Sick", x, y, 0, 0) elseif (kills == 35) then g_arena:explosion_create("Holy Shit", x, y, 0, 0) elseif (kills == 40) then g_arena:explosion_create("God Like", x, y, 0, 0) end end function IncreaseCrownerKill(killer) killer:setstat(2,(killer:getstat(2) + 1)) -- increase crown kills end function IncreaseDeath(victim) victim:setstat(1,(victim:getstat(1) + 1)) -- increase deaths victim:setstat(3,0) end