//-- TBK11 --//
//By Strangelove
//v2.2
//31.12.2019

{$I improvestaticai.script}
{$I transformunits.script}
{$I custommarket.script}
{$I difficulty.script}
{$I dynamicmap.script}

{$DEFINE DEBUG} //Enable extended Debug
//{$UNDEF DEBUG}

var
	bMessage: Boolean;

procedure OnMissionStart();
begin
	//Define Modifiers [Easy3, Easy2, Easy1, Normal, Hard1, Hard2, Hard3]
	EquipRateMod := [3, 2, 1.5, 1, 0.66, 0.5, 0.3]; //Schools are usually the limiting factor
	RecruitDelayMod := [1, 1, 1, 1, 1, 1, 1];
	RecruitLimitMod := [1, 1, 1, 1, 1.33, 1.66, 2];
	WorkerLimitMod := [1, 1, 1, 1, 1.33, 1.66, 2];
end;


procedure OnHouseBuilt(aHouseID: Integer);
begin
	if not bMessage then
		if States.HouseType(aHouseID) = 0 then
		begin
			Actions.ShowMsg(-1, '<$0>');
			bMessage := true;
		end;
	//Focus Scouts on Barracks
	if States.HouseType(aHouseID) = 21 then
		if States.HouseOwner(aHouseID) = 0	then
			Actions.AIStartPosition(2, States.HousePositionX(aHouseID), States.HousePositionY(aHouseID));
	//Unlock Watchtower after Sawmill
	if States.HouseType(aHouseID) = 0 then
		if States.HouseOwner(aHouseID) = 0 then
			Actions.HouseUnlock(0, 17);
end;


procedure OnTick();
begin
	if States.GameTime() = (MAX_HANDS +1) then
	case States.MissionDifficulty() of
		mdEasy1:
		begin
			RemoveDefencePositionAndGroup(1, 66, 67);
			RemoveDefencePositionAndGroup(1, 66, 56);
			RemoveDefencePositionAndGroup(2, 77, 42);
			RemoveDefencePositionAndGroup(2, 86, 38);
		end;
		mdNormal: RemoveDefencePositionAndGroup(2, 77, 42);
	end;
	if States.GameTime() mod  61 = 30 then
		ChangeWaterfallEndTiles(43, 45, 28);
end;