Jump to content
  • 0

Wallfriction


Wo0p

Question

Hello everyone,

 

Hope y'all are doing fine. Right, I'm trying to figure out how to manipulate wallfriction modifiers. One of the most irksome aspects to me in Doom is the aggressiveness with which the engine saps all of your momentum if you run into a wall at even a, seemingly, slight angle. I've heard of and looked at "ZMovement" but I don't know how to read its innards to divine customization. Or maybe math is just too much of a mystery to me (Which is true most of the time). Does anyone have any tips where to look or know of other mods that incorporate some sort of wallfriction reduction so I can gander at it?

 

Relevant? tags: GZDoom 4.10, UDMF, Doom2

Edited by Wo0p

Share this post


Link to post

2 answers to this question

Recommended Posts

  • 0

Looking at that mod, it would be better for you to go for the SLIDESONWALLS flag, until we'll both reach a higher level of comprehension of this sorcery

 

Spoiler

void WallSlideMove()
	{
		Usercmd cmd = ZMPlayer.cmd;
		
		//====================================================
		//Dumb ways to fail...so many don't waste your time
		
		//Common reasons of failure
		if(!WaterLevel >= 2 || bNOGRAVITY || ZMPlayer.OnGround || (!cmd.forwardmove && !cmd.sidemove))
		{
			StopWSlide();
			return;
		}
		
		//WallCheck
		Float WallDistance;
		FLineTraceData SlideWallCheck;
		Int i;
		for(i = 0; i < 8; i++)
		{
			LineTrace(i * 45, (Radius * 3) / 2, 0, 0, data: SlideWallCheck);
			if(!WallDistance || SlideWallCheck.Distance <= WallDistance) { WallDistance = SlideWallCheck.Distance; }
		}
		if(WallDistance >= (Radius * 3) / 2)
		{
			StopWSlide();
			return;
		}
		
		//Moving away from wall
		Float WishDirection = Angle - VectorAngle(cmd.forwardmove, cmd.sidemove);
		Float VelAngle = VectorAngle(Vel.X, Vel.Y);
		Float DirAngle = AbsAngle(WishDirection, VelAngle);
		if(DirAngle >= 30)
		{
			StopWSlide();
			return;
		}
		
		//Wall changed angle, adjust slide velocity
		Int SlideAngleDelta = AbsAngle(VectorAngle(WSlideVelocity.X, WSlideVelocity.Y), VelAngle);
		if(SlideAngleDelta && SlideAngleDelta <= 30)
		{
			WSlideVelocity = WSlideVelocity.Length() * SafeUnit2(Vel.XY);
			Vel.XY = WSlideVelocity; //needed to not make velocity check fail
		}
		else if(SlideAngleDelta > 30)
		{
			StopWSlide();
			return;
		}
		
		//Too slow
		if(Vel.XY.Length() < MaxGroundSpeed)
		{
			StopWSlide();
			return;
		}
		
		//==============================================
		
		Vel.XY = WSlideVelocity;
		Vel.Z *= zm_wslidevelz;
		A_PlaySound("WallSlide", CHAN_BODY, 0.3, True);
		
		//Sprite animation
		PlayIdle();
	}
	
	void StopWSlide()
	{
		CanWSlide = False;
		WSlideVelocity = (0, 0);
		A_StopSound(CHAN_BODY);
	}

This is just the wallslide script, which is not exactly what you're looking for, because I cannot see a way to really modulate the wall "friction" (I believe it doesn't exist a way to do it without altering the engine at this point).

As you can see, the author of the mod uses several variables to have a perfect control over every single movement, but it's hell to extract the thing.

 

Edited by Kan3

Share this post


Link to post
  • 0
Spoiler
7 hours ago, Kan3 said:

Looking at that mod, it would be better for you to go for the SLIDESONWALLS flag, until we'll both reach a higher level of comprehension of this sorcery

 

  Hide contents



void WallSlideMove()
	{
		Usercmd cmd = ZMPlayer.cmd;
		
		//====================================================
		//Dumb ways to fail...so many don't waste your time
		
		//Common reasons of failure
		if(!WaterLevel >= 2 || bNOGRAVITY || ZMPlayer.OnGround || (!cmd.forwardmove && !cmd.sidemove))
		{
			StopWSlide();
			return;
		}
		
		//WallCheck
		Float WallDistance;
		FLineTraceData SlideWallCheck;
		Int i;
		for(i = 0; i < 8; i++)
		{
			LineTrace(i * 45, (Radius * 3) / 2, 0, 0, data: SlideWallCheck);
			if(!WallDistance || SlideWallCheck.Distance <= WallDistance) { WallDistance = SlideWallCheck.Distance; }
		}
		if(WallDistance >= (Radius * 3) / 2)
		{
			StopWSlide();
			return;
		}
		
		//Moving away from wall
		Float WishDirection = Angle - VectorAngle(cmd.forwardmove, cmd.sidemove);
		Float VelAngle = VectorAngle(Vel.X, Vel.Y);
		Float DirAngle = AbsAngle(WishDirection, VelAngle);
		if(DirAngle >= 30)
		{
			StopWSlide();
			return;
		}
		
		//Wall changed angle, adjust slide velocity
		Int SlideAngleDelta = AbsAngle(VectorAngle(WSlideVelocity.X, WSlideVelocity.Y), VelAngle);
		if(SlideAngleDelta && SlideAngleDelta <= 30)
		{
			WSlideVelocity = WSlideVelocity.Length() * SafeUnit2(Vel.XY);
			Vel.XY = WSlideVelocity; //needed to not make velocity check fail
		}
		else if(SlideAngleDelta > 30)
		{
			StopWSlide();
			return;
		}
		
		//Too slow
		if(Vel.XY.Length() < MaxGroundSpeed)
		{
			StopWSlide();
			return;
		}
		
		//==============================================
		
		Vel.XY = WSlideVelocity;
		Vel.Z *= zm_wslidevelz;
		A_PlaySound("WallSlide", CHAN_BODY, 0.3, True);
		
		//Sprite animation
		PlayIdle();
	}
	
	void StopWSlide()
	{
		CanWSlide = False;
		WSlideVelocity = (0, 0);
		A_StopSound(CHAN_BODY);
	}

This is just the wallslide script, which is not exactly what you're looking for, because I cannot see a way to really modulate the wall "friction" (I believe it doesn't exist a way to do it without altering the engine at this point).

As you can see, the author of the mod uses several variables to have a perfect control over every single movement, but it's hell to extract the thing.

 

 

 

Hm I shall look into this esoteric SlidesOnWalls then!

 

And yeah that's the conclusion I also came to... damn you code gods! Why must you be so unknowable?

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...