#library "hrdemode"
#include "zcommon.acs"

#define TID_PLAYER 1000

// Every player has its own TID (TID_PLAYER + i)
script 6000 ENTER
{
	Thing_ChangeTID(0, TID_PLAYER + PlayerNumber());
}

script "levelentrance" (int level, int changemap)
{
	switch(level)
	{
	case 1:
		if (changemap) changelevel("hme1m1", 0, CHANGELEVEL_NOINTERMISSION|CHANGELEVEL_PRERAISEWEAPON);
		else           print(s:"I : cave");
		break;
	default:
		print(s:"This level is not implemented!");
	}
}

script "levelexit" (int level, int depth)
{
	changelevel("hmhub", 1, CHANGELEVEL_NOINTERMISSION|CHANGELEVEL_PRERAISEWEAPON);
}

script 6001 RETURN
{
	//print(s:"Welcome back.");
}

script 9000 KILL
{
	if (CheckFlag(0, "ISMONSTER")  || !CheckFlag(0, "NOBLOOD"))
	{
		Delay(35);
		Spawn("Blood_GrowingPool", GetACtorX(0), GetACtorY(0), GetActorZ(0));
	}
}

function int abs(int a)
{
	if (a < 0.0)
	{
		return -a;
	}
	return a;
}

script 9001 DEATH
{
	Spawn("Blood_GrowingPool", GetACtorX(0), GetACtorY(0), GetActorZ(0));
}

script "RollCamera"(int fixed_amount)
{
	if (fixed_amount != 0)
	{
		SetActorRoll(0, 0.01*fixed_amount);
	}
	else
	{
		int RollAngle = random(0.03, 0.06);
		for (int i = 0.0; i <= abs(Rollangle); i += 0.01)
		{
			if (rollangle < 0)
			{
				SetActorRoll(0, 1.0-i);
			}
			else
			{
				SetActorRoll(0,i);
			}
			delay(1);
		}
	}
}

script "PitchCamera"(int fixed_amount)
{
	Log(f:fixed_amount);
	SetActorPitch(0, fixed_amount);
}
