Page 1 of 1

Need help optimizing ACS that stops player's momentum

Posted: Thu Sep 21, 2017 5:11 am
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.

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

Posted: Thu Sep 21, 2017 9:36 am
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);
            }