#
# Timer code for monster 2
#

Object	obj = getThisObject();
Object	hero = getHero();
int	pos = getObjectVar(obj, 0);

if (pos == 0)
{
	int	objy = getObjectYPosition(obj);
	int	heroy = getObjectYPosition(hero);
	int	dist = absi(objy - heroy);
	
	if (dist < 20)
	{
		Object	projectile;
		
		playSample(makeCode("mon2"));

		if (getObjectOrientation(obj) == ORIENTATION_LEFT)
		{		
			projectile = createObject(makeCode("m4pj"),
				getObjectXPosition(obj) - 1, objy + 15);
			createMotionController(projectile);
			setObjectMovement(projectile, 8.0, 0.0);
			flipObjectOrientation(projectile);
		}
		else
		{
			projectile = createObject(makeCode("m4pj"),
				getObjectXPosition(obj) + 32, objy + 15);
			createMotionController(projectile);
			setObjectMovement(projectile, 8.0, 0.0);
		}
		setObjectGravity(projectile, 0.0);
				
		setObjectSprite(obj, "monster4");
	
		if (getLevel() < 5)
			setObjectVar(obj, 0, 64);
		else
			setObjectVar(obj, 0, 16);
	}
}
else 
{
	int	mpos;
	
	if (getLevel() < 5)
		mpos = 32;
	else
		mpos = 8;
	if (pos == mpos)
		setObjectSprite(obj, "monster3");
	setObjectVar(obj, 0, pos - 1);
}

