#
# Timer script for fish
#

Object	obj = getThisObject();
int	tick = getObjectVar(obj, 0);
int	wantedTick = getObjectVar(obj, 1);

if (tick >= wantedTick)
{
	int	x = getObjectXPosition(obj) + 16;
	int	y = getObjectYPosition(obj);
	
	createParticleObject(makeCode("par4"), x, y, 270.0, 0.4+rand()/2.0, randi(40, 60));
	createParticleObject(makeCode("par4"), x + 3, y - 5, 270.0, 0.4+rand()/2.0, randi(30, 60));
	createParticleObject(makeCode("par4"), x - 2, y - 9, 270.0, 0.4+rand()/2.0, randi(50, 70));
	setObjectVar(obj, 1, randi(110, 200));
	tick = 0;
}

if (canObjectSeeObject(obj, getHero()))
{
	setObjectVar(obj, 2, true);
	if (getObjectOrientation(obj) == ORIENTATION_LEFT)
		setObjectMovement(obj, 0.0-2.5, 0.0);
	else
		setObjectMovement(obj, 2.5, 0.0);
}
else if (getObjectVar(obj, 2))
{
	setObjectVar(obj, 2, false);
	if (getObjectOrientation(obj) == ORIENTATION_LEFT)
		setObjectMovement(obj, 0.0-1.0, 0.0);
	else
		setObjectMovement(obj, 1.0, 0.0);
}

setObjectVar(obj, 0, tick + 1);

