mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
Friction value is used, implemented DefaultTerrain
This commit is contained in:
parent
150faf9de6
commit
53d777788a
3 changed files with 91 additions and 1 deletions
|
|
@ -153,6 +153,58 @@ void K_UpdateMobjTerrain(mobj_t *mo, INT32 flatID)
|
||||||
mo->terrain = K_GetTerrainForTextureName(levelFlat->name);
|
mo->terrain = K_GetTerrainForTextureName(levelFlat->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void K_SetDefaultFriction(mobj_t *mo)
|
||||||
|
{
|
||||||
|
mo->friction = ORIG_FRICTION;
|
||||||
|
|
||||||
|
if (mo->player != NULL)
|
||||||
|
{
|
||||||
|
mo->movefactor = FRACUNIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mo->terrain != NULL)
|
||||||
|
{
|
||||||
|
fixed_t strength = mo->terrain->friction;
|
||||||
|
|
||||||
|
fixed_t newFriction = INT32_MAX;
|
||||||
|
fixed_t newMovefactor = INT32_MAX;
|
||||||
|
|
||||||
|
if (strength > 0) // sludge
|
||||||
|
{
|
||||||
|
strength = strength*2; // otherwise, the maximum sludginess value is +967...
|
||||||
|
}
|
||||||
|
|
||||||
|
// The following might seem odd. At the time of movement,
|
||||||
|
// the move distance is multiplied by 'friction/0x10000', so a
|
||||||
|
// higher friction value actually means 'less friction'.
|
||||||
|
newFriction = ORIG_FRICTION - FixedMul(0x1EB8, strength) / 0x80; // ORIG_FRICTION is 0xE800
|
||||||
|
|
||||||
|
if (newFriction > FRACUNIT)
|
||||||
|
{
|
||||||
|
newFriction = FRACUNIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newFriction < 0)
|
||||||
|
{
|
||||||
|
newFriction = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
newMovefactor = FixedDiv(ORIG_FRICTION, newFriction);
|
||||||
|
|
||||||
|
if (newMovefactor < FRACUNIT)
|
||||||
|
{
|
||||||
|
newMovefactor = 19*newMovefactor - 18*FRACUNIT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newMovefactor = FRACUNIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
mo->friction = newFriction;
|
||||||
|
mo->movefactor = newMovefactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Parser code starts here.
|
// Parser code starts here.
|
||||||
//
|
//
|
||||||
|
|
@ -316,6 +368,43 @@ static boolean K_TERRAINLumpParser(UINT8 *data, size_t size)
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (stricmp(tkn, "defaultTerrain") == 0)
|
||||||
|
{
|
||||||
|
Z_Free(tkn);
|
||||||
|
tkn = M_GetToken(NULL);
|
||||||
|
pos = M_GetTokenPos();
|
||||||
|
|
||||||
|
if (tkn && pos < size)
|
||||||
|
{
|
||||||
|
terrain_t *t = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < numTerrainDefs; i++)
|
||||||
|
{
|
||||||
|
t = &terrainDefs[i];
|
||||||
|
|
||||||
|
if (stricmp(tkn, t->name) == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == numTerrainDefs)
|
||||||
|
{
|
||||||
|
CONS_Alert(CONS_ERROR, "Invalid DefaultTerrain type.\n");
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
defaultTerrain = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO: the other block types!
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CONS_Alert(CONS_ERROR, "No DefaultTerrain type.\n");
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, "Unknown field '%s' found in TERRAIN lump.\n", tkn);
|
CONS_Alert(CONS_ERROR, "Unknown field '%s' found in TERRAIN lump.\n", tkn);
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ terrain_t *K_GetTerrainForTextureNum(INT32 textureNum);
|
||||||
terrain_t *K_GetTerrainForTextureName(const char *checkName);
|
terrain_t *K_GetTerrainForTextureName(const char *checkName);
|
||||||
|
|
||||||
void K_UpdateMobjTerrain(mobj_t *mo, INT32 flatID);
|
void K_UpdateMobjTerrain(mobj_t *mo, INT32 flatID);
|
||||||
|
void K_SetDefaultFriction(mobj_t *mo);
|
||||||
|
|
||||||
void K_InitTerrain(UINT16 wadNum);
|
void K_InitTerrain(UINT16 wadNum);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1341,7 +1341,7 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy)
|
||||||
mo->momy = FixedMul(mo->momy, mo->friction);
|
mo->momy = FixedMul(mo->momy, mo->friction);
|
||||||
}
|
}
|
||||||
|
|
||||||
mo->friction = ORIG_FRICTION;
|
K_SetDefaultFriction(mo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue