All pastes #267457 Raw Edit

Lua source

public text v1 · immutable
·published 2006-12-04 21:41 UTC
rendered paste body
--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

function flagevent(eventid)
	local player = g_person
	local x1 = 19648
	local y1 = 992
	local x2 = 20208
	local y2 = 1232
	local p = g_person:coords()
	if ( (p.x > x1) and (p.x > x2) and (p.y < y1) and (p.y > y2) ) then
	g_arena:message("This is just a test message, and it means all this fancy stuff is working!")
	 end 
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, 1)
                      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