this:ExecScript("scripts/mapgoals/mapgoal_camp.gm");
this.GoalType = "Defend";
this.Version = 1;
this.DefaultPriority = 0.5;

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

this.UpgradeVersion = function(Props)
{
	// version 0 is string,string key/values from the old waypoint format
	if(Props.Version==0)
	{
		// Version 1 Schema, upgrade from waypoint format
		Props.Version = 1;

		Props.AimVectors = { ToVector(Props.Facing) };
		Props.Weapons = {};
		Props.Stance = "stand";
		Props.Roles = {};

		// cs: can't do this since it is unreliable. constructable bridges for example
		//this.SetPosition( GroundPoint(this.GetPosition()) );

		// offset instead
		this.SetPosition(this.GetPosition() + Util.WaypointGoalOffset);

		this.SetBounds(Vec3(-5,-5,0),Vec3(5,5,96));
	}
	else if(Props.Version == this.Version)
	{
		this.MinCampTime = ToFloat( Props["MinCampTime"], 2.0 );
		this.MaxCampTime = ToFloat( Props["MaxCampTime"], 6.0 );

		this.AimVectors = Props.AimVectors;
		this.Weapons = Props.Weapons;
		this.Stance = Props.Stance;
		this.Roles = Props.Roles;

		if (!this.Weapons)
		{
			this.Weapons = {};
		}
		else if ( tableCount(this.Weapons) > 0 )
		{
			this.LimitToWeapon(this.Weapons);
			this.DefaultPriority += 0.2;
		}

		if ( Props.DisableCM ) {
			this.DisableCM = Props.DisableCM;
		}
		else {
			this.DisableCM = 0;
		}

		// detect 0 facing vectors
		if ( typeId(Props.AimVectors) == 6 )
		{
			numFacings = tableCount(Props.AimVectors);
			foreach(id and facing in Props.AimVectors ) {
				if ( facing.IsZero() ) {
					Props.AimVectors[id] = null; // clear it
					Util.MapDebugPrint(this.GetName() + " facing " + id + " is zero!", true);
				}
			}
		}

		if(!this.Schema.Check(this))
		{
			this.DisableGoal(true);
		}
	}
};

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