Page 1 of 1

Lack of inertia/momentum on a loaded game?

Posted: Mon Jul 08, 2024 3:41 pm
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!

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

Posted: Mon Jul 08, 2024 11:36 pm
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.

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

Posted: Tue Jul 09, 2024 10:29 am
by Jarewill
Could you show your current code?

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

Posted: Tue Jul 09, 2024 11:03 am
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);
				
            }
	
	}
}
}

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

Posted: Tue Jul 09, 2024 12:11 pm
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...

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

Posted: Wed Jul 10, 2024 8:22 am
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!