Page 1 of 1

ACS Help

Posted: Fri Nov 13, 2015 5:39 am
by Scott_Minikhiem

Code: Select all

Script "TiredMain" Enter
{
int mesx = GetActorX(0);
int mesy = GetActorY(0);
//int mesz = GetActorZ(0);
//str FMC = "FloorMoveChecker";
//Spawn(FMC, mesx, mesy, mesz, 0, 0);
Delay(10);
int mesx2 = GetActorX(0);
int mesy2 = GetActorY(0);
//int mesz2 = GetActorZ(0);
//int Jumpz = GetActorZ(5100);

int VelX = (abs(mesx - mesx2));
int VelY = (abs(mesy - mesy2));
int Movement = (VelX+VelY);

//int VelZ = (abs(mesz2 - Jumpz));

	//WEIGHT_VAR = (FixedMul((invnum << 16), 0.002)) ;
int Agility = (CheckInventory("AgilityCounter") << 16);
int CurSpd = GetActorProperty (0, APROP_Speed);
int CurSpd2 = abs(FixedMul((CurSpd << 16), 0.02));
int MaxSpeed = (FixedMul(Agility, 0.02)+0.5);
int MinSpeed = 0.4;
int NewSpd = (CurSpd - 0.005);
Delay(1);
//Print(f:CurSpd2);
if ((Movement >= 100) && (CurSpd >= MinSpeed))
{
	If (Movement >= 200)
	{
		If (Movement >= 400)
		{
			If (Movement >= 800)
			{
			NewSpd = (CurSpd - 0.04);
			SetActorProperty (0, APROP_Speed, NewSpd);
			Print(f:Movement);
			}
		NewSpd = (CurSpd - 0.02);
		SetActorProperty (0, APROP_Speed, NewSpd);
		//Print(f:Movement);
		}
	NewSpd = (CurSpd - 0.01);
	SetActorProperty (0, APROP_Speed, NewSpd);
	//Print(f:Movement);
	}
SetActorProperty (0, APROP_Speed, NewSpd);
//Print(f:Movement);
}
else
{
	if (CurSpd < MaxSpeed)
	{
	NewSpd = (CurSpd + 0.02);
	SetActorProperty (0, APROP_Speed, NewSpd);
	Print(f:NewSpd);
	}

}
restart;
}
I'm trying to make a script that makes the player tired from running jump etc. Here I have an issue with the "Movement" int. In print f it displays the right number, but when it's compared in the if statement the game somehow thinks the number is higher than all 4 comparisons. It's not. Even if I move around and see the numbers stay below 100, the maximum amount of stamina is deducted.

So how can I get Movement>x to work? -Thanks

RE: ACS Help

Posted: Fri Nov 13, 2015 9:54 am
by Ænima
Why would you waste server memory finding the distance between player positions when there are functions for checking actor velocity?

http://zdoom.org/wiki/GetActorVelX

RE: ACS Help

Posted: Fri Nov 13, 2015 4:43 pm
by Scott_Minikhiem
Because if the player doesn't move very much it shouldn't affect his stamina and I don't know how I would use the velocity function and measure it for a period of time. If you can provide an example...