--Bughunt script --HellSpawn --11.29.06 --- [[ Global Variables ]] ---------- g_arena = nil -- The global arena class, to avoid having to pass it around functions g_bGameRunning = false -- Is the game running? g_person = nil --g_winner = nil -- The player who won --- no use for this at the moment --g_state = nil -- The global GameState class --- no use for this at the moment --- [[ Functions ]] ------- -- when the arena is created, it runs this function Arena_OnCreate(arena) g_arena = arena math.randomseed(os.time()) end -- when a player kills another player drop some body parts for the killer function Player_OnDeath(killer, victim) local pos = victim:coords() if (victim:getVehicle():vehicletypeid() >= 200) then g_arena:item_create("Body Parts", 2, pos.x, pos.y) end end -- This is the event that is run when a player steps into a dropzone with a flag function flagtimer1(eid) local player = g_person local p = g_person:coords() local x1 = 13227 local y1 = 247 local x2 = 13774 local y2 = 447 g_person:message("Dropping Flag in 15 Seconds") flagtimer2 = event_create(flagtimer2, 5000) if ( (p.x > x1) and (p.x < x2) and (p.y > y1) and (p.y < y2) ) == false then event_destroy(timerid) return true end return false end function flagtimer2(eid) local player = g_person local p = g_person:coords() local x1 = 13227 local y1 = 247 local x2 = 13774 local y2 = 447 g_person:message("Dropping Flag in 10 Seconds") flagtimer3 = event_create(flagtimer3, 5000) if ( (p.x > x1) and (p.x < x2) and (p.y > y1) and (p.y < y2) ) == false then event_destroy(timerid) return true end return false end function flagtimer3(eid) local player = g_person local p = g_person:coords() local x1 = 13227 local y1 = 247 local x2 = 13774 local y2 = 447 g_person:message("Dropping Flag in 5 Seconds") flagtimer4 = event_create(flagtimer4, 5000) if ( (p.x > x1) and (p.x < x2) and (p.y > y1) and (p.y < y2) ) == false then event_destroy(timerid) return true end return false end function flagtimer4(eid) local player = g_person local p = g_person:coords() local x1 = 13227 local y1 = 247 local x2 = 13774 local y2 = 447 player:inventory_modify("Science Object A",-1) g_arena:item_create("Science Object A Captured", 1, p.x, p.y) g_person:message("Flag Dropped") event_destroy(timerid) if ( (p.x > x1) and (p.x < x2) and (p.y > y1) and (p.y < y2) ) == false then event_destroy(timerid) return true end return false end function flagdrop(eventid) local player = g_person local p = g_person:coords() local x1 = 13227 local y1 = 247 local x2 = 13774 local y2 = 447 g_person:message("Dropping Flag in 20 Seconds") timerid = event_create(flagtimer1, 5000) if ( (p.x > x1) and (p.x < x2) and (p.y > y1) and (p.y < y2) ) == false then event_destroy(fid) event_destroy(timerid) return true end return false end function flagevent(eid) local player = g_person local x1 = 13227 local y1 = 247 local x2 = 13774 local y2 = 447 local p = g_person:coords() if ( (p.x > x1) and (p.x < x2) and (p.y > y1) and (p.y < y2) ) then fid = event_create(flagdrop, 1) event_destroy(eid) return true end return false end function Item_OnPickUp(looter, loot, loot_type, amounttopickup) g_person = looter if (loot_type.m_name == "Science Object A") then -- Dont't let skrall or any other class besides sergeant pick it up if (looter:getVehicle():vehicletypeid() >= 200) then looter:message("You can't eat the science objects!") return false elseif (looter:getVehicle():vehicletypeid() == 104) then looter:message("Only the Sergeant may capture the Science objects!") return false elseif (looter:getVehicle():vehicletypeid() == 100) then looter:message("Only the Sergeant may capture the Science objects!") return false elseif (looter:getVehicle():vehicletypeid() == 102) then looter:message("Only the Sergeant may capture the Science objects!") return false elseif (looter:getVehicle():vehicletypeid() == 103) then looter:message("Only the Sergeant may capture the Science objects!") return false elseif (looter:getVehicle():vehicletypeid() == 101) then eid = event_create(flagevent, -100) return true end end return true end -- when a player enters the zone, it gives them this message function Player_OnJoin(player) player:message("&Note: Welcome to Bughunt. Report any bugs or suggestions on the forums!") end -- when the game starts, it sets gameRunning to true function Arena_OnGameStart() g_bGameRunning = true end -- when the game finishes, it sets gameRunning to false function Arena_OnGameEnd() g_bGameRunning = false end