Lack of inertia/momentum on a loaded game?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
doomduck
Posts: 45
Joined: Wed Apr 15, 2020 6:58 am
Location: The Moon

Lack of inertia/momentum on a loaded game?

Post by doomduck »

Hello!
I have recently been trying to adapt Nash's less slippery movement code to work with another mod (Ashes 2063), however I am having a huge issue with the mod...

The game has vehicle sections, where the player goes into a different state, and in that state, the player does their movement through A_Recoil, and some sections require you to carry this momentum from the recoil in order to jump gaps
In order to not break this system, I have written an "exception" in the code that disables itself whenever you're on this bike state, and that works pretty much perfectly, as expected...

HOWEVER, this ONLY seems to work properly during a first time map load! After you load a save/autosave, while on the ground, the vehicle section works fine, but whenever you're on the air, all momentum is pretty much lost, making completing the level/section IMPOSSIBLE.

I have banged my head against a wall for a long, long time, trying to figure out how to get the damn thing to work, but I've had no luck. I'm only an amateur at coding, so I don't have that much of an idea of what I'm actually doing. If any coders here could maybe put me in the right direction in regards of how to make this mod work, it'd be HUGELY appreciated!

EDIT:

Hey! I have figured out how to fix this!

Code: Select all

                // Air Controller
		if
		(
		FindInventory("motohandles")
		)
		{
			level.aircontrol = 0.00390625;
		}
		else if((Pos.Z != FloorZ) && (vel.x != 0 || vel.y != 0))
		{
			level.airControl = 0.64;
		}
		else
		{
			level.aircontrol = 0.00390625;
		}

Since the problem was that the modified air control was being saved alongside everything else, I have made it so that the air control is handled separetly from the rest of the movement code, and have made it so it only applies the modified air control if you're moving and in the air! This completely solves the issue while also maintaining the greater air control!
Last edited by doomduck on Wed Jul 10, 2024 8:22 am, edited 1 time in total.
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Lack of inertia/momentum on a loaded game?

Post by ramon.dexter »

Well, quickest solution is to stop nash's less slippery movement. I've done it myself and developed my own movement method.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Lack of inertia/momentum on a loaded game?

Post by Jarewill »

Could you show your current code?
User avatar
doomduck
Posts: 45
Joined: Wed Apr 15, 2020 6:58 am
Location: The Moon

Re: Lack of inertia/momentum on a loaded game?

Post by doomduck »

Jarewill wrote: Tue Jul 09, 2024 10:29 am Could you show your current code?
Sure, here it is

Code: Select all

class BuildMoveHandler : StaticEventHandler
{
  MoveManager3 move;
  
  override void WorldLoaded(WorldEvent e)
  {
  if (gamestate != GS_LEVEL)
	return;
  
  ThinkerIterator it = ThinkerIterator.Create("MoveManager3", Thinker.MAX_STATNUM);
  move = MoveManager3(it.Next());
  
  if (!move)
		{
			move = new("MoveManager3");
			move.ChangeStatNum(Thinker.MAX_STATNUM);
		}
  }
}

class MoveManager3 : Thinker
{
	override void Tick()
	{		
		for (uint i = 0; i < MAXPLAYERS; ++i)
		{
			if (!playerInGame[i] || !players[i].mo)
				{
				continue;
				}
    
	let plr = players[i].mo;
	let hasVehicle = ( players[i].mo.FindInventory("motohandles") );
	if (hasVehicle)
	{
	}
	else if ( ((plr.Pos.Z == plr.FloorZ) || plr.bOnMObj || players[i].onGround) /*|| (!plr.curSector || !plr.curSector.flags & 16)*/)
			{
				plr.level.airControl = 0.64;
				plr.vel.xy *= 0.88;
				plr.A_SetSpeed(1.88);
			}
			else
			{
				plr.level.airControl = 0.64;
				plr.vel.xy *= 0.88;
				plr.A_SetSpeed(1.55);
				
            }
	
	}
}
}
User avatar
doomduck
Posts: 45
Joined: Wed Apr 15, 2020 6:58 am
Location: The Moon

Re: Lack of inertia/momentum on a loaded game?

Post by doomduck »

One thing I figured out now is that it's the bigger air control that's messing with the inertia...
The recoil from A_Recoil doesn't seem to carry as well as it does by default if you mess with the air control, or rather, saving/loading seems to mess with the aircontrol
I really don't wanna remove it though, part of the reason I want to have this modified movement in the first place is for easier platforming, which can't happen if the air control is the default GZDoom value...
User avatar
doomduck
Posts: 45
Joined: Wed Apr 15, 2020 6:58 am
Location: The Moon

Re: Lack of inertia/momentum on a loaded game?

Post by doomduck »

Hey! I have figured out how to fix this!

Code: Select all

                // Air Controller
		if
		(
		FindInventory("motohandles")
		)
		{
			level.aircontrol = 0.00390625;
		}
		else if((Pos.Z != FloorZ) && (vel.x != 0 || vel.y != 0))
		{
			level.airControl = 0.64;
		}
		else
		{
			level.aircontrol = 0.00390625;
		}

Since the problem was that the modified air control was being saved alongside everything else, I have made it so that the air control is handled separetly from the rest of the movement code, and have made it so it only applies the modified air control if you're moving and in the air! This completely solves the issue while also maintaining the greater air control!

Return to “Scripting”