All pastes #628168 Raw Edit

Untitled

public text v1 · immutable
·published 2007-07-20 19:54 UTC
rendered paste body
--- [[ Global Variables ]] ----------
 
g_arena = nil      -- The global arena class, to avoid having to pass it around functions
g_state = nil
g_bGameRunning = false  -- Is the game running?
g_titan = 400
g_collie = 402

--- [[ Functions ]] -------

function Arena_OnCreate(arena)
	-- Set our global value
	g_arena = arena

	-- Initialize random
	math.randomseed(os.time())

	-- Use our own game dynamic
	local cfg = GameSettings()

	cfg.minplayers = 2
	cfg.gamedelay = 15
	
	cfg.str_pregame = "Game starting in "
	cfg.str_noplayers = "Not Enough Players"

	cfg.bDesertedGameEnd = false

	cfg.bIngameTicker = true
	cfg.tckrUpdateSpacing = 10000

	g_state = g_arena:Takeover_State(cfg)
end

-- Code in this function is carried out when the player joins 
function Player_OnJoin(player)
    player:message("Welcome to Traffic Control, Lua is running.")
end


function Player_OnDeath(killer, victim) -- player, player
end

-- when the game starts, it sets gameRunning to true
function Arena_OnGameStart()
	g_bGameRunning = true
	local collie = g_arena:vehicle_create(g_collie, 319, 4705, 0)
	local titan = g_arena:vehicle_create(g_titan, 4543, 390, 0)
	titan:setfrequency(0)
	collie:setfrequency(1)
end

-- when the game finishes, it sets gameRunning to false
function Arena_OnGameEnd()
	g_bGameRunning = false
end

function Vehicle_OnDeath(victim, killer, itemid)
	local vid = victim:vehicletypeid()
	if (vid == g_titan) then --titan?
		g_state:Endgame()
		g_arena:message("Collective has destroyed Titan's tank factory. Game Over")
	elseif (vid == g_collie) then --collie?
		g_state:Endgame()
		g_arena:message("Titan has destroyed Collective's tank factory. Game Over")

	end
end
	
		

function CollieWin()
g_arena:message("Collective has destroyed Titan's tank factory. Game Over")
end

function TitanWin()
g_arena:message("Titan has destroyed Collective's tank factory. Game Over")
end