Mission = {
};


function Mission:OnInit()
	-- you may want to load a string-table etc. here...
end

function Mission:OnUpdate()
	local i;
	local bFinished=1;
	for i,objective in Mission do
		if (type(objective)~="function") then
			if (objective==0) then 
				bFinished=0;				
			else
			end
		end	
	end
	if (bFinished==1) then	
		self.Finish();
	end
end

function Mission:moveplayercam(cameraname)
--	System:LogToConsole("Event_moveplayer");
	local camera=System:GetEntityByName(cameraname);
	if((camera)and(_localplayer))then
		local camerapos=camera:GetPos();
		camerapos.z=camerapos.z-1.7;
		_localplayer:SetPos(camerapos);
		_localplayer:SetAngles(camera:GetAngles());
	end
end



--MISC----------------------------------------------------

function Mission:Event_MissionFinished()
	_localplayer.cnt:SavePlayerElements();
	Game:SendMessage('StartLevelFade Level_One');
end

function Mission:moveplayercam(cameraname)
--	System:LogToConsole("Event_moveplayer");
	local camera=System:GetEntityByName(cameraname);
	if((camera)and(_localplayer))then
		local camerapos=camera:GetPos();
		camerapos.z=camerapos.z-1.7;
		_localplayer:SetPos(camerapos);
		_localplayer:SetAngles(camera:GetAngles());
	end
end

function Mission:Event_GameSaved()
-- displays game saved message
Hud:AddMessage("Game Saved", 60);
end

function Mission:Event_FlashObj()
-- Flash All Objectives
Hud:FlashObjectives({},"");
Hud:SetRadarObjective("nil");
end

function Mission:Event_ObjectivesReminder()
-- displays message reminding to check any updated objectives
Hud:AddMessage("CHECK YOUR OBJECTIVES", 120);
end

--OBJECTIVES----------------------------------------------------


function Mission:Event_ShotGun()
  -- First objective
Hud:PushObjective({},"Find weapons, ammo and armor");
Hud:AddMessage("NEW OBJECTIVE: FIND A WEAPON, AMMO AND ARMOR", 120);
Hud:SetRadarObjective("ShotGunHere");
end

function Mission:Event_ShotGunComplete()
	--First objective completed
	Hud:CompleteObjective("Find a weapons, ammo and armor");
end

function Mission:Event_SearchHut()
  --Second objective
Hud:PushObjective({},"Search the Hut Nearby for Clues");
Hud:AddMessage("NEW OBJECTIVE: SEARCH THE HUT NEARBY FOR CLUES", 120);
Hud:SetRadarObjective("SearchHut");
end

function Mission:Event_SearchHutComplete()
	--Second objective completed
	Hud:CompleteObjective("Search the Hut Nearby for Clues");
end

function Mission:Event_RoadBlock()
  -- Third objective
Hud:PushObjective({},"Locate the Lieutenant");
Hud:AddMessage("NEW OBJECTIVE: LOCATE THE LIEUTENANT", 120);
Hud:SetRadarObjective("RoadBlock");
end

function Mission:Event_RoadBlockComplete()
	--Third objective completed
	Hud:CompleteObjective("Locate the Lieutenant");
end

function Mission:Event_Sniper_Tower()
  --Fourth objective
Hud:PushObjective({},"Take out the Sniper. Reach the High Ground");
Hud:AddMessage("NEW OBJECTIVE: TAKE OUT THE SNIPER. REACH THE HIGH GROUND", 120);
Hud:SetRadarObjective("nil");
end

function Mission:Event_Sniper_TowerComplete()
	--Fourth objective completed
	Hud:CompleteObjective("Take out the Sniper. Reach the High Ground");
end


function Mission:Event_EastHut()
  -- Fifth objective
Hud:PushObjective({},"Find a Computer Terminal and Gain Network Access");
Hud:AddMessage("NEW OBJECTIVE: FIND A COMPUTER TERMINAL AND GAIN NETWORK ACCESS", 120);
Hud:SetRadarObjective("EastHut");
end

function Mission:Event_EastHutComplete()
	--Fifth objective completed
	Hud:CompleteObjective("Find a Computer Terminal and Gain Network Access");
end
 
function Mission:Event_WestHut()
-- Sixth objective
Hud:PushObjective({},"Find the hut on the west coast of the island");
Hud:AddMessage("NEW OBJECTIVE: FIND THE HUT ON THE WEST COAST OF THE ISLAND", 120);
Hud:SetRadarObjective("WestHut");
end

function Mission:Event_WestHutComplete()
	--Sixth objective completed
	Hud:CompleteObjective("Find the hut on the west coast of the island");
end

function Mission:Event_Encampment()
	--Seventh objective
Hud:PushObjective({},"Find the Keycard that will get you into the Shipyard");
Hud:AddMessage("NEW OBJECTIVE: FIND KEYCARD TO ACCESS SHIPYARD", 120);
Hud:SetRadarObjective("Encampment");
end

function Mission:Event_EncampmentComplete()
	--Seventh objective completed
	Hud:CompleteObjective("Find the Keycard that will get you into the Shipyard");
end

function Mission:Event_GetIntoShipyard()
	--Eighth objective
	Hud:PushObjective({}, "Get into the Shipyard");
	Hud:AddMessage("NEW OBJECTIVE: GET INTO THE SHIPYARD", 120);
	Hud:SetRadarObjective("Shipyard1");
end

function Mission:Event_ShipyardDirectionUpdate()
	--Shipyard direction update
	Hud:SetRadarObjective("Shipyard");
end

function Mission:Event_GetIntoShipyardComplete()
	--Eighth objective completed
	Hud:CompleteObjective("Get into the Shipyard");
end

function Mission:Event_GetExpShipyard()
  -- Ninth objective
Hud:PushObjective({},"Get some Explosives from the Armoury!");
Hud:AddMessage("NEW OBJECTIVE: GET SOME EXPLOSIVES FROM THE ARMOURY!", 120);
Hud:SetRadarObjective("ArmouryExp");
end

function Mission:Event_GetExpShipyardComplete()
	--Ninth objective completed
	Hud:CompleteObjective("Get some Explosives from the Armoury!");
end

function Mission:Event_BlowGens()
  --Tenth objective
Hud:PushObjective({},"Blow the Generators");
Hud:AddMessage("NEW OBJECTIVE: BLOW THE GENERATORS", 120);
Hud:SetRadarObjective("nil");
end

function Mission:Event_BlowGensComplete()
	--Tenth objective completed
	Hud:CompleteObjective("Blow the Generators");
end

function Mission:Event_GetOntoFreighter()
  --Eleventh objective
Hud:PushObjective({},"Find a way to get onto the Freighter");
Hud:AddMessage("NEW OBJECTIVE: FIND A WAY TO GET ONTO THE FREIGHTER", 120);
end

function Mission:Event_GetOntoFreighterComplete()
	--Eleventh objective completed
	Hud:CompleteObjective("Find a way to get onto the Freighter");
end

function Mission:Event_GetFormula()
  --Twelfth objective
Hud:PushObjective({},"Get the Nerve Agent Formula");
Hud:AddMessage("NEW OBJECTIVE: GET THE NERVE AGENT FORMULA", 120);
Hud:SetRadarObjective("RadarFormula");
end

function Mission:Event_GetFormulaComplete()
	--Twelfth objective completed
	Hud:CompleteObjective("Get the Nerve Agent Formula");
end

function Mission:Event_SinkFreighter()
  --Thirteenth objective
Hud:PushObjective({},"Plant 2 Explosives below the waterline to sink the Freighter");
Hud:AddMessage("NEW OBJECTIVE: PLANT 2 EXPLOSIVES BELOW THE WATERLINE", 120);
Hud:SetRadarObjective("nil");
end

function Mission:Event_SinkFreighterComplete()
	--Thirteenth objective completed
	Hud:CompleteObjective("Plant 2 Explosives below the waterline to sink the Freighter");
end

function Mission:Event_GetAshore()
  --Fourteenth objective
Hud:PushObjective({},"Get ashore");
Hud:AddMessage("NEW OBJECTIVE: GET ASHORE", 120);
Hud:SetRadarObjective("Ashore");
end

function Mission:Event_GetAshoreComplete()
	--Fourteenth objective completed
	Hud:CompleteObjective("Get ashore");
end

function Mission:Event_FindMap()
  --Fifteenth objective
Hud:PushObjective({},"Find the map of the island");
Hud:AddMessage("NEW OBJECTIVE: FIND THE MAP OF THE ISLAND", 120);
Hud:SetRadarObjective("Map");
end

function Mission:Event_FindMapComplete()
	--Fifteenth objective completed
	Hud:CompleteObjective("Find the map of the island");
end

function Mission:Event_FindInstallation()
  --Sixteenth objective
Hud:PushObjective({},"Find a way into the Underground Installation");
Hud:AddMessage("NEW OBJECTIVE: FIND A WAY INTO THE UNDERGROUND INSTALLATION", 120);
Hud:SetRadarObjective("InstallationA");
end

function Mission:Event_FindInstallationComplete()
	--Sixteenth objective completed
	Hud:CompleteObjective("Find a way into the Underground Installation");
	Hud:CompleteObjective("Near the other Satellite Dish");
end

function Mission:Event_DestroyInstallation()
  --Seventeenth objective
Hud:PushObjective({},"Find a way to Destroy the Installation");
Hud:AddMessage("NEW OBJECTIVE: FIND A WAY TO DESTROY THE INSTALLATION", 120);
Hud:SetRadarObjective("nil");
end

function Mission:Event_DestroyInstallationComplete()
	--Seventeenth objective completed
	Hud:CompleteObjective("Find a way to Destroy the Installation");
end

function Mission:Event_Rendezvous()
  --Eighteenth objective
Hud:PushObjective({},"Meet up with contact");
Hud:AddMessage("NEW OBJECTIVE: MEET UP WITH CONTACT", 120);
Hud:SetRadarObjective("Contact");
end

function Mission:Event_RendezvousComplete()
	--Eighteenth objective completed
	Hud:CompleteObjective("Meet up with contact");
end

function Mission:Event_BarracksArmoury()
  --Nineteenth objective
Hud:PushObjective({},"Find the keycard and get into the barracks armoury");
Hud:AddMessage("NEW OBJECTIVE: FIND THE KEYCARD AND GET INTO THE BARRACKS ARMOURY", 120);
Hud:SetRadarObjective("BarracksArmoury");
end

function Mission:Event_BarracksArmouryComplete()
	--Nineteenth objective completed
	Hud:CompleteObjective("Find the keycard and get into the barracks armoury");
end

function Mission:Event_RadioTowers()
  --Twentieth objective
Hud:PushObjective({},"Destroy the 3 Radio Towers");
Hud:AddMessage("NEW OBJECTIVE: DESTROY THE 3 RADIO TOWERS", 120);
Hud:SetRadarObjective("Tower1");
end

function Mission:Event_Tower1()
  --Twentieth objective First Tower
Hud:SetRadarObjective("Tower1");
end

function Mission:Event_Tower2()
  --Twentieth objective Second Tower
Hud:SetRadarObjective("Tower2");
end

function Mission:Event_Tower3()
  --Twentieth objective Third Tower
Hud:SetRadarObjective("Tower3");
end

function Mission:Event_RadioTowersComplete()
	--Twentieth objective completed
	Hud:CompleteObjective("Destroy the 3 Radio Towers");
end

function Mission:Event_RoadToFreedom()
  --Twenty First objective
Hud:PushObjective({},"Find a vehicle and escape via the road North");
Hud:AddMessage("NEW OBJECTIVE: FIND A VEHICLE AND ESCAPE VIA THE ROAD NORTH", 120);
Hud:SetRadarObjective("RoadStart");
end

function Mission:Event_RoadToFreedomComplete()
	--Twenty First objective completed
	Hud:CompleteObjective("Find a vehicle and escape via the road North");
end

--SELF----------------------------------------------------

function Mission:Event_Self1()
	--Self1
	Hud:AddMessage("PITY I KNOCKED MY EQUIPMENT PACK OVERBOARD !!!", 120);
end

function Mission:Event_Self2()
	--Self2
	Hud:AddMessage("HMM, A MAP SHOWING SOME SORT OF HIDDEN UNDERGROUND STORAGE NEAR WHERE I FOUND THAT DEAD LIEUTENANT", 120);
end

function Mission:Event_Self3()
	--Self3
	Hud:AddMessage("I MIGHT NEED THAT KEYCARD I JUST LEFT BEHIND", 120);
end

function Mission:Event_Self4()
	--Self4
	Hud:AddMessage("I NEED THE LIEUTENANT'S CREDENTIALS TO GET NETWORK ACCESS", 120);
	Hud:SetRadarObjective("RoadBlock");
end

function Mission:Event_Self5()
	--Self5
	Hud:AddMessage("SERIOUS TROUBLE HEADING YOUR WAY, USE THAT MOUNTED WEAPON!!!", 120);
end

function Mission:Event_Self6()
	--Self6
	Hud:AddMessage("HMM THAT DIDN'T WORK!!!", 120);
end

function Mission:Event_Self7()
	--Self7
	Hud:AddMessage("LOOKS LIKE THEY WERE PLANNING ON SELLING THIS", 120);
end

function Mission:Event_Self8()
	--Self8
	Hud:AddMessage("WHAT'S THIS SCRIBBLED AT THE BOTTOM - MUST BE THE ENTRY CODE", 120);
end

function Mission:Event_Self9()
	--Self9
	Hud:AddMessage("HMM THIS IS CLEARLY NO ENTRANCE THE MAP SHOWS ANOTHER VERY NEAR THE OTHER SATELLITE DISH", 120);
	Hud:PushObjective({},"Near the other Satellite Dish");
	Hud:SetRadarObjective("nil");
end

function Mission:Event_Self10()
	--Self10
	Hud:AddMessage("OOPS", 120);
end

function Mission:Event_Self11()
	--Self11
	Hud:AddMessage("TIME TO GO!!!!!!!!!!!", 120);
	Hud:PushObjective({},"ARE YOU MAD GET OUT!!!!!!!!");
end

function Mission:Event_Self12()
	--Self12
	Hud:AddMessage("A MAP AND A NOTE!", 120);
end

function Mission:Event_Self13()
	--Self13
	Hud:AddMessage("CAME UNDER INTENSE ATTACK, WILL WAIT FOR YOU AT THE PICKUP SHOWN ON THE MAP", 120);
end

function Mission:Event_Self14()
	--Self14
	Hud:AddMessage("THE TUNNEL TO YOUR LEFT LEADS TO THE BARRACKS", 120);
end

function Mission:Event_Self15()
	--Self15
	Hud:AddMessage("THE ROAD TO YOUR RIGHT LEADS TO A BRIDGE WHICH IS YOUR ESCAPE ROUTE NORTH", 120);
end

function Mission:Event_Self16()
	--Self16
	Hud:AddMessage("OH AND IF YOU DON'T MAKE IT HAPPY BIRTHDAY FOR TOMORROW, VAL", 120);
end

function Mission:Event_Self17()
	--Self17
	Hud:AddMessage("DON'T WASTE TIME YOU HAVE TO GET TO THE PICKUP POINT BEFORE THEY LEAVE!!!!!!", 120);
end

function Mission:Event_Self18()
	--Self18
	Hud:AddMessage("WOW I GUESS THIS WAS TO BE THE PRODUCTION FACILITY, VAL MUST BE NEAR", 120);
end

function Mission:Event_Self19()
	--Self19
	Hud:AddMessage("LOOKS LIKE I'LL GET THAT BIRTHDAY PRESENT AFTER ALL....", 120);
end

function Mission:Event_Self20()
	--Self20
	Hud:AddMessage("HINT: TAKE OUT THE SNIPER ON THE HILL", 120);
end

function Mission:Event_Self21()
	--redirect northern pickup point
	Hud:AddMessage("KEEP HEADING NORTH", 120);
	Hud:SetRadarObjective("nil");
end

function Mission:Event_Self22()
	--Self22
	Hud:AddMessage("GET ON BOARD", 120);
end

function Mission:Event_Self23()
	--Self23
	Hud:AddMessage("THIS'LL HELP, BUT I NEED SOMETHING HEAVIER LIKE A SHOTGUN AND ARMOR", 120);
end

function Mission:Event_Self24()
	--Hint to use radar often
	Hud:AddMessage("HINT: USE YOUR RADAR OFTEN", 120);
end


--RELOCATIONS---------------------------------------------

function Mission:Event_MovePlayerHut()
	Mission:moveplayercam("MovePlayer1")
end

function Mission:Event_MovePlayerWestHut()
	Mission:moveplayercam("MovePlayer2")
end

--CUT SCENES----------------------------------------------

function Mission:Event_WestHutCutScene()
  Movie:PlaySequence('WestHut.cutscene');
end

----------------------------------------------------------

function Mission:Event_EndOfGame()
	--End of Game
	Game:SendMessage('StartLevelFade Level_One');
end


function Mission:Finish()
	-- go to next mission...
end

