All pastes #273132 Raw Edit

Stuff

public text v1 · immutable
·published 2006-12-09 16:57 UTC
rendered paste body
--Bughunt script

--- [[ 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_personA = nil -- the person currently holding A

g_calledA = false -- has the drop event just started?
g_calledA2 = false -- has it reached 5 seconds yet?
g_calledA3 = false -- has it reached 10 seconds yet?
g_calledA4 = false -- has it reached 15 seconds yet?
g_calledA5 = false -- has it reached 20 seconds yet?

g_startTimeA = nil
g_currentDiffA = nil
g_eventA = nil
gc_startingammo = 250	-- The amount of ammo the marine starts with

-- One Spawn Point --
g_x1 = 13227
g_y1 = 247
g_x2 = 13774
g_y2 = 447 
-----------------------
dofile("bhstats.lua")


function Arena_OnCreate(arena)        
    g_arena = arena
		local cfg = GameSettings()

	cfg.minplayers = 1
	cfg.gamedelay = 20
	
	cfg.str_pregame = "Game starting in "
	cfg.str_noplayers = "Not Enough Men"

	cfg.bDesertedGameEnd = false

	cfg.bIngameTicker = true
	cfg.tckrUpdateSpacing = 10000

	g_state = g_arena:Takeover_State(cfg)
    math.randomseed(os.time())
end

-- when a player kills another player drop some body parts for the killer
function Player_OnDeath(killer, victim)

	victim:inventory_modify("Science Object A",-100)
	local pos = victim:coords()
	if (victim:getVehicle():vehicletypeid() >= 200) then
                g_arena:item_create("Body Parts", 2, pos.x, pos.y)
	end
end

function FlagEventA(eventA)
	if (g_startTimeA ~= nil) then
		g_currentDiffA = (os.time() - g_startTimeA)
	end
	--local player = g_personA
	local coords = g_personA:coords()

	if ( ((coords.x > g_x1) and (coords.x < g_x2) and (coords.y > g_y1) and (coords.y < g_y2)) == true ) then -- are they in a position to drop the flag?
		
		if (g_personA:inventory_find("Science Object A") >= 1) then -- is the player still alive? (if they die this item will be removed)
			
			if (g_calledA == false) then
				g_startTimeA = os.time()
				g_personA:message("Dropping flag in 20 seconds")
				g_calledA = true
				end
			
			if (g_currentDiffA == 5) then 
				if (g_calledA2 == false) then
					g_personA:message("Dropping flag in 15 seconds")
					g_calledA2 = true
				end
			end
			
			if (g_currentDiffA == 10) then
				if (g_calledA3 == false) then
					g_personA:message("Dropping flag in 10 seconds")
					g_calledA3 = true
				end
			end
			
			if (g_currentDiffA == 15) then
				if (g_calledA4 == false) then
					g_personA:message("Dropping flag in 5 seconds")
					g_calledA4 = true
				end
			end
			
			if (g_currentDiffA == 20) then
				if (g_calledA5 == false) then
					event_destroy(g_event)
					g_personA:message("Flag Dropped")
					g_personA:inventory_modify("Science Object A",-100)
					g_arena:item_create("Science Object A Captured", 1, coords.x, coords.y)
					g_state:Endgame()
					g_calledA5 = true
					end
			return true
		end
	return false
end
		
	elseif (g_calledA == true) then--they have the flag, but have now stepped out the area!! omg, lets reset their timer
		g_personA:message("You exited the flag drop area, timer has been reset")
		g_calledA = false 
		g_calledA2 = false 
		g_calledA3 = false 
		g_calledA4 = false 
		g_calledA5 = false
			return true
		end
	return false
end


function Item_OnPickUp(looter, loot, loot_type, amounttopickup)
	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
			g_personA = looter
			g_event = event_create(FlagEventA, -50, g_arena)-- Every minute	
			end
		return true
	elseif (loot_type.m_name == "Science Object A Captured") then
		looter:message("This objective has already been captured!")
		return false
		end
	return false
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