Need help optimizing ACS that stops player's momentum

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Jekyll Grim Payne
Global Moderator
Posts: 1117
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Need help optimizing ACS that stops player's momentum

Post by Jekyll Grim Payne »

I wanted to make a simple ACS that would remove the player's momentum as soon as they stop pressing movement keys. (To remove Doom's annoying "sliding" behavior and make real jump puzzles possible). For now it looks something like this:

Code: Select all

Script "Movestop" Enter
{
int buttons;
buttons = GetPlayerInput(-1, INPUT_BUTTONS);

if (buttons & BT_FORWARD || buttons & BT_BACK || buttons & BT_MOVELEFT || buttons & BT_MOVERIGHT) 
	{ 
	delay(5);
	restart;
	}
else
	{
	delay(5);
	Thing_Stop(0);
	}

restart;
}
First, since I'm not great with ACS, I'm pretty sure I added lots of unnecessary stuff. Like, I'm pretty sure the if/else statements can be replaced with while, but I'm not entirely sure about how to reverse the condition properly.

Second, if I step off a cliff and stop pressing any buttons, the script will create hiccups where I stop falling repeatedly then go on. I'd like this thing to not affect Z movement at all.

Third, I'm not sure I need all those delays.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Need help optimizing ACS that stops player's momentum

Post by Matt »

Do you need Zandronum support? If not, override void MovePlayer() and replacing the "Thrust" calls with TryMove should work.

Something like:

Code: Select all

            if (forwardmove)
            {
                TryMove(pos.xy+(cos(angle),sin(angle))*forwardmove,true);
//                Bob(Angle, cmd.forwardmove * bobfactor / 256., true);
//                ForwardThrust(forwardmove, Angle);
            }
            if (sidemove)
            {
                let a = Angle - 90;
                TryMove(pos.xy+(cos(a),sin(a))*sidemove,true);
//                Bob(a, cmd.sidemove * bobfactor / 256., false);
//                Thrust(sidemove, a);
            } 
Locked

Return to “Editing (Archive)”