ACS Help

Discuss all aspects related to modding Zandronum here.
Post Reply
Scott_Minikhiem
New User
Posts: 14
Joined: Mon Nov 19, 2012 12:46 am

ACS Help

#1

Post by Scott_Minikhiem » Fri Nov 13, 2015 5:39 am

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

User avatar
Ænima
Addicted to Zandronum
Posts: 3579
Joined: Tue Jun 05, 2012 6:12 pm

RE: ACS Help

#2

Post by Ænima » Fri Nov 13, 2015 9:54 am

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
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

Scott_Minikhiem
New User
Posts: 14
Joined: Mon Nov 19, 2012 12:46 am

RE: ACS Help

#3

Post by Scott_Minikhiem » Fri Nov 13, 2015 4:43 pm

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...

Post Reply