slideTolerance is missting from the wiki

slideTolerance is missting from the wiki

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
Godde
Posts: 268
Joined: 29 Mar 2010, 17:54

slideTolerance is missting from the wiki

Post by Godde »

I think SlideTolerance is a multiplier of maxSlope in movedefs.lua.
It makes units slide/bounce whenever they are in greater slope than that value. SlopeTolerance 1 can make units drive off cliffs and stuff "unintentionally". Slope tolerance below 1 seems to do nothing.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: slideTolerance is missting from the wiki

Post by knorke »

Code: Select all

slideTolerance = udTable.GetFloat("slideTolerance", 0.0f); // disabled
says "disabled" but it seems to be used in some function to decide if a unit can can "skid" on a slope:

from groundmovetype.cpp:

Code: Select all

bool CGroundMoveType::OnSlope() {
	const UnitDef* ud = owner->unitDef;
	const float3& mp = owner->midPos;

	return
		(ud->slideTolerance >= 1.0f) &&
		(mp.IsInBounds()) &&
		(ground->GetSlope(mp.x, mp.z) > (ud->movedata->maxSlope * ud->slideTolerance));
}
how I understand all this skidding thing:
"skidding" is moving down a slope where the unit "should not be" due to groundSlope > unit's maxSlope.
with slideTolerance the formula is basically changed to:
groundSlope > unit's maxSlope * slideTolerance

if slideTolerance is < 1.0, it is ignored and the unit will never skid.

(skidding speed is also influenced by map gravity.)

Code: Select all

if (OnSlope() && (!floatOnWater || ground->GetHeight(owner->midPos.x, owner->midPos.z) > 0))
		skidding = true;

	if (skidding) {
		UpdateSkid();
		return;
So to slideTolerance is used to decide if the unit will skid.
But it is not always used, ie UpdateSkid() uses its own formula without slideTolerance. So the actual skidding movement is not influenced by this tag.

Code: Select all

// does not use OnSlope() because then it could stop on an invalid path
		// location, and be teleported back.
		const bool onSlope =
			midPos.IsInBounds() &&
			(ground->GetSlope(midPos.x, midPos.z) > ud->movedata->maxSlope) &&
			(!floatOnWater || ground->GetHeight(midPos.x, midPos.z) > 0.0f);

I also did some tests and it seems to be something like that.
fun fact:
If units skid into each other they seem somewhat likely to catapult each other across the map or even high in the sky, from where they never return. :shock:

here is a video of that:
http://www.youtube.com/watch?v=RbZIbgJFaPM

/edit
mighty strange.
if you have a unit with slideTolerance and spawn in on a steep slope, it will not slide down. Then you have another unit slide down into the stuck unit and now both will slide.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: slideTolerance is missting from the wiki

Post by FLOZi »

It was intentionally left out. (as were commander, cobID and now smoothAnim)
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: slideTolerance is missting from the wiki

Post by knorke »

hm, but unlike some other depreciated tags slideTolerance actually has an effect
slideTolerance < 1 :arrow: unit stays on slopes
slideTolerance > 1 :arrow: unit slides down

it does work, just imo not very good.
Godde
Posts: 268
Joined: 29 Mar 2010, 17:54

Re: slideTolerance is missting from the wiki

Post by Godde »

Wouldn't it be fun if slideTolerance<1 would actually do something and make stuff slide even on terrain they can drive on?
So that they try to go up a hill and unless they got enough speed they would fall back like a car driving up a sandy slope.
Post Reply

Return to “Engine”