--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 flagdrop(eventid)
local player = g_person
local pos = g_person:coords()
g_person:message("This is a drop test, your flag will be dropped in 20 seconds")
if ( (p.x > x1) and (p.x < x2) and (p.y > y1) and (p.y < y2) ) == false then
event_destroy(fid)
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