{
	//target ["NULL"]
	targetID
	targetObj
	isPlayer [0]
	saved_game [0]

	Init[ (s)
	{
		SetNationality(1);
		SetLineOfSight(2,90);
			
		if( saved_game = 0 )
		{
			saved_game = 1;
			SetAttackDistance(10,10);
			SetEntityHealth(2048);
			TurnTo(Level.GetPlayer());
		}
	}]
	
	
	DelayReached[ (ID)
	{
		if( ID=20 )
		{
			GoPath("E_01Tank", 1);
		}
		if( ID=21 )
		{
			GoPath("E_02Tank", 1);
		}
		if( ID=24 )
		{
			GoPath("E_03Tank", 1);
		}
		if( ID=25 )
		{
			GoPath("E_06Tank", 2);
		}
		if( ID=26 )
		{
			GoPath("E_PathTank01", 1);
		}
		if( ID=27 )
		{
			GoPath("E_07Tank", 1);
		}
		if( ID=22 )
		{
			GoPath("E_05Tank",1);
		}
		if( ID=23 )
		{
			FireNear( targetID );
		}
		if( ID=100 )
		{
			HideTank();	
		}
		// if( ID=101 )
		// {
		// 	SetPosition( 41345, 1409, -8 );		
		// }

	}]
	
	HideTank[ ()
	{
		// SetDead(true);
		SetPassable(true);
		ShowEntity(false);
		SetPosition( 41344, 1408, -8 );	
		// Delay(1, 101);
	}]
	
	GoPath[ (Path, Target)
	{
		FollowPath(Path, 0);

		switch(Target)
		{
			case 1
			{
				targetID = "A_Tank";
			}
			case 2
			{
				targetID = "DefaultPlayer";
			}
		}
		FollowPathCallback( 127, "FireNear" );
	}]

	FireNear[ ()
	{
		Level.Log("--> (PANZER) FireNear():  me:  " # GetID() # "  target:  " # targetID);

		dead = 0;
		if( targetID = "DefaultPlayer" )
		{
			dead = 1;
		}
		else
		{
			if( isPlayer = 1 )
			{
				dead = Level.GetPlayer().IsDead();
			} 
			else {
				dead = Level.GetEntity(targetID).IsDead();
			}
		}

		if( dead = 1 )
		{
		// always choose player
			pickme = 1;
			isPlayer = 1;
		}
		else
		{
			// pick between target or the player
			pickme = Random(0,1);
			if( pickme = 0 )
			{
				Level.Log("        Target is Entity:  " # targetID);
				isPlayer = 0;
			} else 
			{
				Level.Log("        Target is Player");
				isPlayer = 1;
			}
		}

		if( isPlayer = 1 )
		{
			Xpos = Level.GetPlayer().GetPositionX();
			Ypos = Level.GetPlayer().GetPositionY();
		} else 
		{
			Level.Log( "        targetID = " # targetID );
			targetAsdfObj = Level.GetEntity(targetID);
			if( isObject( targetAsdfObj ) )
			{
				Level.Log( "        its an object, dammit" );
				Xpos = targetAsdfObj.GetPositionX();
				Ypos = targetAsdfObj.GetPositionY();
			}
		}

		Xoff = Random(-1500, 1500);
		Yoff = Random(-1500, 1500);
		Xpos = (Xpos + Xoff);
		Ypos = (Ypos + Yoff);

		TurretShootAt(Xpos, Ypos);
		// SetInvulnerable(false);
		// SetPassable(false);

		Delay(4,23);

		Level.Log("<-- (PANZER)FireNear()");
	}]
}