// DYNAMITE goal is same as PLANT goal with IgnoreEntity = true

this.SetBaseGoalType("mapgoal_blowuptarget.gm");

this.GoalType = "DYNAMITE";
this.CreateOnLoad = true;
this.MinRadius = 32;
this.IgnoreEntity = true;

//////////////////////////////////////////////////////////////////////////

this.UpgradeVersion = function(Props)
{
	if(Props.Version == 1)
	{
		this.IgnoreTargets = Props.IgnoreTargets;
		this.CoverSpots = Props.CoverSpots;
		this.CoverSplit = Props.CoverSplit;

		if ( this.CoverSpots )
		{
			// clear any occupied slots
			foreach ( spot in this.CoverSpots ) {
				spot.occupied = null;
			}
			// delete empty table
			if (!tableCount(this.CoverSpots)) {
				this.CoverSpots = null;
			}
		}
	}
};

//////////////////////////////////////////////////////////////////////////

this.SaveToTable = function(SaveTable)
{
	SaveTable.CoverSpots = this.CoverSpots;
	SaveTable.CoverSplit = this.CoverSplit;
};

//////////////////////////////////////////////////////////////////////////

this.Help = function()
{
	print(this.GoalType,"goal");
	print("Optional:");
	print("     coverspot - location to go to after planting dynamite, supports multiple");
	print("     coverfacing - Direction the bot should face at cover spot");
	print("     coverstance - stand, crouch, prone");
	print("     covertimeout - how long to stay on cover spot, default value is 25 seconds");
	print("     coverdisablecm - disable combat movement at this cover spot");
	print("     coversplit - facing from use point to goal center, only if goal has 2 use points and multiple cover spots");
};

//////////////////////////////////////////////////////////////////////////

this.BaseSetProperty = this.SetProperty;
this.SetProperty = function(property, value)
{
	if (property.Left(5) != "cover") {
		print(this.GoalType, ": Invalid property:", property);
	} else {
		this.BaseSetProperty(property,value);
	}
};
