Mantis 0000972, 0001034, 0001033:

o Tweaked the wallwalk:
- The wallwalk scans only fire upwards in the NE, SE, SW, and NW directions, not down and not in the player's view direction.
- The origin displacelemt does not fire if the player has a floor 10 units underneeth him/her, so that skulks on the ground won't snap to the wall.
- If the player's view is directed roughly 45 degrees out from the current surface normal, the origin displacement is disabled, allowing skulks to fall off walls by simply looking outwards and moving away from the wall. Note that this makes it harder to climb around edges.

git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@121 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
tankefugl 2005-05-19 14:07:02 +00:00
parent 10b9fde0f5
commit b9e6317dfc

View file

@ -1268,11 +1268,13 @@ bool NS_CheckOffsetFromOrigin(float inX, float inY, float inZ, vec3_t& outNormal
if (trace.fraction < 1) if (trace.fraction < 1)
{ {
// tankefugl: Don't weight it if surface normal is too plane
if (trace.plane.normal[2] > 0.7)
return true;
// Weight the normal based on how close the intersection is. // Weight the normal based on how close the intersection is.
vec3_t normal; vec3_t normal;
VectorScale(trace.plane.normal, 1.0f / (trace.fraction + 0.1f), normal); VectorScale(trace.plane.normal, 1.0f / (trace.fraction + 0.1f), normal);
VectorAdd(normal, outNormal, outNormal); VectorAdd(normal, outNormal, outNormal);
@ -1440,15 +1442,15 @@ void NS_UpdateWallsticking()
// tankefugl: fix to allow skulks to climb walls oriented 45 degrees in the x-y plane // tankefugl: fix to allow skulks to climb walls oriented 45 degrees in the x-y plane
// it also allows for easier climbing around courners // it also allows for easier climbing around courners
wallsticking |= NS_CheckOffsetFromOrigin(pmove->forward[0], pmove->forward[1], pmove->forward[2], theSurfaceNormal); //wallsticking |= NS_CheckOffsetFromOrigin(pmove->forward[0], pmove->forward[1], pmove->forward[2], theSurfaceNormal);
if (wallsticking) //if (wallsticking)
VectorScale(theSurfaceNormal, 5, theSurfaceNormal); // VectorScale(theSurfaceNormal, 5, theSurfaceNormal);
// :tankefugl // :tankefugl
wallsticking |= NS_CheckOffsetFromOrigin(theMinPoint[0], theMinPoint[1], theMinPoint[2], theSurfaceNormal); //wallsticking |= NS_CheckOffsetFromOrigin(theMinPoint[0], theMinPoint[1], theMinPoint[2], theSurfaceNormal);
wallsticking |= NS_CheckOffsetFromOrigin(theMinPoint[0], theMaxPoint[1], theMinPoint[2], theSurfaceNormal); //wallsticking |= NS_CheckOffsetFromOrigin(theMinPoint[0], theMaxPoint[1], theMinPoint[2], theSurfaceNormal);
wallsticking |= NS_CheckOffsetFromOrigin(theMaxPoint[0], theMinPoint[1], theMinPoint[2], theSurfaceNormal); //wallsticking |= NS_CheckOffsetFromOrigin(theMaxPoint[0], theMinPoint[1], theMinPoint[2], theSurfaceNormal);
wallsticking |= NS_CheckOffsetFromOrigin(theMaxPoint[0], theMaxPoint[1], theMinPoint[2], theSurfaceNormal); //wallsticking |= NS_CheckOffsetFromOrigin(theMaxPoint[0], theMaxPoint[1], theMinPoint[2], theSurfaceNormal);
wallsticking |= NS_CheckOffsetFromOrigin(theMinPoint[0], theMinPoint[1], theMaxPoint[2], theSurfaceNormal); wallsticking |= NS_CheckOffsetFromOrigin(theMinPoint[0], theMinPoint[1], theMaxPoint[2], theSurfaceNormal);
wallsticking |= NS_CheckOffsetFromOrigin(theMinPoint[0], theMaxPoint[1], theMaxPoint[2], theSurfaceNormal); wallsticking |= NS_CheckOffsetFromOrigin(theMinPoint[0], theMaxPoint[1], theMaxPoint[2], theSurfaceNormal);
@ -1460,14 +1462,19 @@ void NS_UpdateWallsticking()
if (wallsticking) if (wallsticking)
{ {
// tankefugl: 0000972 // tankefugl: 0000972
if (theSurfaceNormal[2] < 0.95 && pmove->waterjumptime == 0) if (/*theSurfaceNormal[2] < 0.95 && */ pmove->waterjumptime == 0)
{
float dotNormalView = DotProduct(pmove->forward, theSurfaceNormal);
vec3_t tempNormal = {0, 0, 0};
bool checkedDownOffset = NS_CheckOffsetFromOrigin(0, 0, theMinPoint[2] * 2, tempNormal);
if (dotNormalView < 0.7 && (checkedDownOffset == false))
{ {
VectorCopy(theSurfaceNormal, gSurfaceNormal); VectorCopy(theSurfaceNormal, gSurfaceNormal);
if (theSurfaceNormal[2] < 0.7) if (theSurfaceNormal[2] < 0.7)
{ {
vec3_t theDispVect; vec3_t theDispVect;
VectorScale(theSurfaceNormal, -5, theDispVect); VectorScale(theSurfaceNormal, theMinPoint[0], theDispVect);
VectorAdd(pmove->origin, theDispVect, theDispVect); VectorAdd(pmove->origin, theDispVect, theDispVect);
pmtrace_t wallclimbTrace = NS_PlayerTrace(pmove, pmove->origin, theDispVect, PM_NORMAL, -1); pmtrace_t wallclimbTrace = NS_PlayerTrace(pmove, pmove->origin, theDispVect, PM_NORMAL, -1);
@ -1477,6 +1484,7 @@ void NS_UpdateWallsticking()
VectorCopy(wallclimbTrace.endpos, pmove->origin); VectorCopy(wallclimbTrace.endpos, pmove->origin);
} }
} }
}
// Set wall sticking to true. // Set wall sticking to true.
SetUpgradeMask(&pmove->iuser4, MASK_WALLSTICKING); SetUpgradeMask(&pmove->iuser4, MASK_WALLSTICKING);
@ -5188,7 +5196,7 @@ void PM_Jump (void)
} }
// tankefugl: 0000972 walljump // tankefugl: 0000972 walljump
if (GetHasUpgrade(pmove->iuser4, MASK_WALLSTICKING) && (pmove->cmd.buttons & IN_JUMP) && !(pmove->oldbuttons & IN_JUMP) && (gSurfaceNormal[2] < 0.5)) if (GetHasUpgrade(pmove->iuser4, MASK_WALLSTICKING) && (pmove->cmd.buttons & IN_JUMP) && !(pmove->oldbuttons & IN_JUMP) && (gSurfaceNormal[2] < 0.3))
{ {
vec3_t theJumpVect; vec3_t theJumpVect;
VectorScale(pmove->forward, pmove->maxspeed, pmove->velocity); VectorScale(pmove->forward, pmove->maxspeed, pmove->velocity);