All pastes #287860 Raw Edit

Something

public lua v1 · immutable
#287860 ·published 2006-12-21 21:05 UTC
rendered paste body
--Bughunt script--- [[ Global Variables ]] ----------g_arena = nil      -- The global arena class, to avoid having to pass it around functionsg_bGameRunning = false  -- Is the game running?g_statsEvent = 0 -- holds the event for displaying stats when the game endsg_gameTime = nil -- holds the game timeg_startTime = nil -- for timer stuff--- Science Object A ---g_personA = nil -- the person currently holding Ag_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 -- the start time of when the flag has first entered the drop areag_currentDiffA = nilg_eventA = nilg_wonA = false----------------------------Flag spawnsg_x5 = 10776g_y5 = 1336g_x6 = 9400g_y6 = 10708--- Science Object B ---g_personB = nil -- the person currently holding Bg_calledB = false -- has the drop event just started?g_calledB2 = false -- has it reached 5 seconds yet?g_calledB3 = false -- has it reached 10 seconds yet?g_calledB4 = false -- has it reached 15 seconds yet?g_calledB5 = false -- has it reached 20 seconds yet?g_startTimeB = nil -- the start time of when the flag has first entered the drop areag_currentDiffB = nilg_eventB = nilg_wonB = false------------------------------ first drop area --g_x1 = 13227g_y1 = 247g_x2 = 13774g_y2 = 447 ------------------------ and the other area --g_x3 = 5676g_y3 = 2740g_x4 = 6152g_y4 = 2996------------------------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 Players"	cfg.bDesertedGameEnd = false	cfg.bIngameTicker = true	cfg.tckrUpdateSpacing = 1000	g_state = g_arena:Takeover_State(cfg)    math.randomseed(os.time())end-- when a player kills another player drop some body parts for the killerfunction Player_OnDeath(killer, victim)		if (victim:inventory_find("Science Object A") >= 1) then				g_arena:item_create("Science Object A", 1, 10776, 1336)				victim:Removeobjects()				event_flush(eventA)		return true	end		if (victim:inventory_find("Science Object B") >= 1) then				g_arena:item_create("Science Object B", 1, 9400, 10708)				victim:Removeobjects()				event_flush(eventB)		return true	end			local pos = victim:coords()	--lets refill each marine's ammo, first heavy		if (victim:getVehicle():vehicletypeid() == 104) then			victim:inventory_modify("Ammo",400)				killer:inventory_modify("Cash",2)				g_arena:item_create("Ammo", 150, pos.x, pos.y)			g_arena:item_create("Marine Heart", 1, pos.x, pos.y)		return true	--then for marine		elseif (victim:getVehicle():vehicletypeid() == 100) then			victim:inventory_modify("Ammo",400)				killer:inventory_modify("Cash",2)				g_arena:item_create("Ammo", 150, pos.x, pos.y)			g_arena:item_create("Marine Heart", 1, pos.x, pos.y)		return true	--then for the medic		elseif (victim:getVehicle():vehicletypeid() == 102) then			victim:inventory_modify("Ammo",400)				killer:inventory_modify("Cash",2)				g_arena:item_create("Ammo", 150, pos.x, pos.y)			g_arena:item_create("Marine Heart", 1, pos.x, pos.y)		return true	--and finally,for the sergeant		elseif (victim:getVehicle():vehicletypeid() == 101) then			victim:inventory_modify("Ammo",400)				killer:inventory_modify("Cash",2)				g_arena:item_create("Ammo", 150, pos.x, pos.y)			g_arena:item_create("Marine Heart", 1, pos.x, pos.y)		return true	end		if (g_bGameRunning == 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	end	-- else one player killed another player, so we increase the kill count and death count respectively			IncreaseKill(killer)			IncreaseDeath(victim)endfunction FlagEventA(eventA)	if (g_startTimeA ~= nil) then		g_currentDiffA = (os.time() - g_startTimeA)	end	if (g_personA:spectator() == true) then		g_arena:item_create("Science Object A", 1, 10776, 1336)		event_destroy(eventA, g_arena)		return true	end		if (g_personA:valid() == false) then		event_destroy(eventA, g_arena)		return true	end		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)) or ((coords.x > g_x3) and (coords.x < g_x4) and (coords.y > g_y3) and (coords.y < g_y4)) == 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 he dies 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			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					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_calledA5 = true					g_wonA = true					event_destroy(g_eventA)					if ((g_wonA == true) and (g_wonB == true)) then						g_arena:message("&The Marines have Captured the Science Objectives! Game Over")						g_state:Endgame()						end					end				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 			end		return false	endfunction FlagEventB(eventB)	if (g_startTimeB ~= nil) then		g_currentDiffB = (os.time() - g_startTimeB)	end	if (g_personB:spectator() == true) then		g_arena:item_create("Science Object B", 1, 9400, 10708)		event_destroy(eventB, g_arena)		return true	end	if (g_personB:valid() == false) then		event_destroy(eventB, g_arena)		return true	end		local coords = g_personB:coords()	if ( ((coords.x > g_x1) and (coords.x < g_x2) and (coords.y > g_y1) and (coords.y < g_y2)) or ((coords.x > g_x3) and (coords.x < g_x4) and (coords.y > g_y3) and (coords.y < g_y4)) == true ) then -- are they in a position to drop the flag?				if (g_personB:inventory_find("Science Object B") >= 1) then -- is the player still alive? (if he dies this item will be removed)						if (g_calledB == false) then				g_startTimeB = os.time()				g_personB:message("Dropping flag in 20 seconds")				g_calledB = true				end			end						if (g_currentDiffB == 5) then 				if (g_calledB2 == false) then					g_personB:message("Dropping flag in 15 seconds")					g_calledB2 = true				end			end						if (g_currentDiffB == 10) then				if (g_calledB3 == false) then					g_personB:message("Dropping flag in 10 seconds")					g_calledB3 = true				end			end						if (g_currentDiffB == 15) then				if (g_calledB4 == false) then					g_personB:message("Dropping flag in 5 seconds")					g_calledB4 = true				end			end						if (g_currentDiffB == 20) then				if (g_calledB5 == false) then					g_personB:message("Flag Dropped")					g_personB:inventory_modify("Science Object B",-100)					g_arena:item_create("Science Object B Captured", 1, coords.x, coords.y)					g_calledB5 = true					g_wonB = true					event_destroy(g_eventB)					if ((g_wonA == true) and (g_wonB == true)) then						g_arena:message("&The Marines have Captured the Science Objectives! Game Over")						g_state:Endgame()					return true					end			end		end			elseif (g_calledB == true) then--they have the flag, but have now stepped out the area!! omg, lets reset their timer		g_personB:message("You exited the flag drop area, timer has been reset")		g_calledB = false 		g_calledB2 = false 		g_calledB3 = false 		g_calledB4 = false 		g_calledB5 = false 		end	return falseendfunction 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_eventA = event_create(FlagEventA, -50, g_arena)-- whatever				end		return true	elseif (loot_type.m_name == "Science Object A Captured") then		looter:message("This objective has already been captured!")		return false	end		if (loot_type.m_name == "Science Object B") 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_personB = looter			g_eventB = event_create(FlagEventB, -50, g_arena)-- whatever			end		return true	elseif (loot_type.m_name == "Science Object B Captured") then		looter:message("This objective has already been captured!")			return false		end	return trueend   -- when a player enters the zone, it gives them this messagefunction Player_OnJoin(player)    player:message("&Note: Welcome to Bughunt, Check out Skrallistan at www.skrallistan.co.nr! Post any Ideas/Suggestions you have on there!")	WipePlayerStats(player)	Removeobjects(player)end-- when the game starts, it sets gameRunning to truefunction Arena_OnGameStart()	g_arena:item_create("Science Object A", 1, 10776, 1336)	g_arena:item_create("Science Object B", 1, 9400, 10708)	g_startTime = os.time()	g_bGameRunning = true	g_gameTime = os.time()		for x = 1, g_arena:num() do		local player = g_arena:get(x)		WipePlayerStats(player)		Removeobjects(player)	end		--- Lets clear all the crap for the next game ---	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 -- the start time of when the flag has first entered the drop area	g_currentDiffA = nil	g_eventA = nil	g_wonA = false	g_personB = nil -- the person currently holding B	g_calledB = false -- has the drop event just started?	g_calledB2 = false -- has it reached 5 seconds yet?	g_calledB3 = false -- has it reached 10 seconds yet?	g_calledB4 = false -- has it reached 15 seconds yet?	g_calledB5 = false -- has it reached 20 seconds yet?	g_startTimeB = nil -- the start time of when the flag has first entered the drop area	g_currentDiffB = nil	g_eventB = nil	g_wonB = false	end-- when the game finishes, it sets gameRunning to falsefunction Arena_OnGameEnd()DisplayStats()if ((g_wonA == false) or (g_wonB == false)) theng_arena:message("Skrall is Victorious!")	--stop all events that are still running	event_flush(g_arena)	g_bGameRunning = false	endendfunction DisplayCoords()h = g_arena:getPlayer("HellSpawn"):coords()g_arena:message("x = " .. h.x .. " y = " .. h.y .. "")endfunction Arena_TickerUpdate()	-- Set some locals	if g_startTime ~= nil then		local currentTime = (600 - (os.time() - g_startTime))	if (currentTime == 0) then		g_state:Endgame()	end	-- Show the timer		g_state:SetNotice(0, "Game Time = " .. currentTime .. "")	endendfunction Removeobjects(player)	player:inventory_modify("Science Object A", -1000)	player:inventory_modify("Science Object A", -1000)end