#define WIN32_LEAN_AND_MEAN		
#include <windows.h>
#include "Outpost2DLL\Outpost2DLL.h"
#include "OP2Helper\OP2Helper.h"
#include "BaseData.h"

char MapName[]			= "newworldv11.map";						// The .map file used for this level
char LevelDesc[]		= "6P,LoS,Around the World V1.1";		// Description appearing in the game list box
char TechtreeName[]		= "MULTITEK.TXT";						// File to use for the tech tree
SDescBlock DescBlock	= { MultiLastOneStanding, 6, 12, 0 };	// Important level details

BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
	if (fdwReason == DLL_PROCESS_ATTACH) 
	{
		DisableThreadLibraryCalls(hinstDLL);
	}

    return TRUE;
}

int InitProc()
{
	// Randomize starting locations
	RandomizeStartingLocations(autosize(startLocation));

	// Place all bases on the map
	for (int i = 0; i < TethysGame::NoPlayers(); i++)
	{
		InitPlayerResources(i);

		StartLocation &sLoc = startLocation[i];
		CreateBase(i, sLoc.x, sLoc.y, *sLoc.baseInfo);
		Player[i].CenterViewOn(sLoc.x, sLoc.y);

		Player[i].MarkResearchComplete(3303);
		Player[i].MarkResearchComplete(3304);
		Player[i].MarkResearchComplete(3305);
		Player[i].MarkResearchComplete(3401);
		Player[i].MarkResearchComplete(5110);

								
	}

	// Misc initialization
	TethysGame::ForceMoraleGood(-1);
	if (TethysGame::UsesMorale())
		TethysGame::FreeMoraleLevel(-1);
	TethysGame::SetDaylightEverywhere(TethysGame::UsesDayNight() == 0);
	TethysGame::SetDaylightMoves(0);
	GameMap::SetInitialLightLevel(-32);
	
	//Common
	TethysGame::CreateBeacon(mapMiningBeacon, 140, 194, 0, 2, 2);
	TethysGame::CreateBeacon(mapMiningBeacon, 508, 188, 0, 2, 2);
	TethysGame::CreateBeacon(mapMiningBeacon, 357, 190, 0, 2, 2);
	TethysGame::CreateBeacon(mapMiningBeacon, 339, 52, 0, 2, 2);
	TethysGame::CreateBeacon(mapMiningBeacon, 127, 49, 0, 2, 2);
	TethysGame::CreateBeacon(mapMiningBeacon, 492, 51, 0, 2, 2);
	//Rare
	TethysGame::CreateBeacon(mapMiningBeacon, 141, 236, 1, 1, 1);
	TethysGame::CreateBeacon(mapMiningBeacon, 509, 230, 1, 1, 1);
	TethysGame::CreateBeacon(mapMiningBeacon, 358, 231, 1, 1, 1);
	TethysGame::CreateBeacon(mapMiningBeacon, 339, 10, 1, 1, 1);
	TethysGame::CreateBeacon(mapMiningBeacon, 492, 9, 1, 1, 1);
	TethysGame::CreateBeacon(mapMiningBeacon, 127, 7, 1, 1, 1);

	
	
	{		
		Trigger trig;        // Create a trigger variable.  If you don't know what that means, don't worry about it.
		trig = CreateOnePlayerLeftTrigger(1, 0, "NoResponseToTrigger");  // NoResponseToTrigger is a generic catch-all function that does nothing when invoked
		CreateVictoryCondition(1, 0, trig, "Eliminate your opponents.");	// Use that trigger to create a victory condition
	}

	// You win when there is only one human opponent left or all surviving human players are allied.
	// This also creates corresponding failure conditions

	return 1; // return 1 if OK; 0 on failure
}

void AIProc() 
{
	
}

void __cdecl GetSaveRegions(struct BufferDesc &bufDesc)
{
	bufDesc.bufferStart = 0;	// Pointer to a buffer that needs to be saved
	bufDesc.length = 0;			// sizeof(buffer)
}

int StatusProc()
{
	return 0; // must return 0
}

SCRIPT_API void NoResponseToTrigger()
{	
}
