mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-31 05:30:48 +00:00
Make sector friction a floating-point field
This commit is contained in:
parent
e4d7b3df6c
commit
577ae68d6d
5 changed files with 24 additions and 16 deletions
|
@ -250,8 +250,8 @@ universalfields
|
|||
|
||||
friction
|
||||
{
|
||||
type = 0;
|
||||
default = 0;
|
||||
type = 1;
|
||||
default = 0.90625;
|
||||
}
|
||||
|
||||
triggertag
|
||||
|
|
|
@ -679,7 +679,7 @@ static int sector_get(lua_State *L)
|
|||
lua_pushinteger(L, (UINT8)sector->triggerer);
|
||||
return 1;
|
||||
case sector_friction: // friction
|
||||
lua_pushinteger(L, sector->friction);
|
||||
lua_pushfixed(L, sector->friction);
|
||||
return 1;
|
||||
case sector_gravity: // gravity
|
||||
lua_pushfixed(L, sector->gravity);
|
||||
|
|
|
@ -1054,6 +1054,8 @@ static void P_LoadSectors(UINT8 *data)
|
|||
ss->triggertag = 0;
|
||||
ss->triggerer = TO_PLAYER;
|
||||
|
||||
ss->friction = ORIG_FRICTION;
|
||||
|
||||
P_InitializeSector(ss);
|
||||
}
|
||||
}
|
||||
|
@ -1720,7 +1722,7 @@ static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val)
|
|||
else if (fastcmp(param, "ropehang") && fastcmp("true", val))
|
||||
sectors[i].specialflags |= SSF_ROPEHANG;
|
||||
else if (fastcmp(param, "friction"))
|
||||
sectors[i].friction = atol(val);
|
||||
sectors[i].friction = FLOAT_TO_FIXED(atof(val));
|
||||
else if (fastcmp(param, "gravity"))
|
||||
sectors[i].gravity = FLOAT_TO_FIXED(atof(val));
|
||||
else if (fastcmp(param, "damagetype"))
|
||||
|
@ -2034,6 +2036,8 @@ static void P_LoadTextmap(void)
|
|||
sc->triggertag = 0;
|
||||
sc->triggerer = TO_PLAYER;
|
||||
|
||||
sc->friction = ORIG_FRICTION;
|
||||
|
||||
textmap_colormap.used = false;
|
||||
textmap_colormap.lightcolor = 0;
|
||||
textmap_colormap.lightalpha = 25;
|
||||
|
@ -4921,8 +4925,20 @@ static void P_ConvertBinaryMap(void)
|
|||
case 540: //Floor friction
|
||||
{
|
||||
INT32 s;
|
||||
fixed_t strength; // friction value of sector
|
||||
fixed_t friction; // friction value to be applied during movement
|
||||
|
||||
strength = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
|
||||
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'.
|
||||
friction = ORIG_FRICTION - (0x1EB8*strength)/0x80; // ORIG_FRICTION is 0xE800
|
||||
|
||||
TAG_ITER_SECTORS(tag, s)
|
||||
sectors[s].friction = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
|
||||
sectors[s].friction = friction;
|
||||
break;
|
||||
}
|
||||
case 541: //Wind
|
||||
|
|
12
src/p_spec.c
12
src/p_spec.c
|
@ -8337,23 +8337,15 @@ static void P_SpawnFriction(void)
|
|||
size_t i;
|
||||
sector_t *s = sectors;
|
||||
|
||||
fixed_t strength; // friction value of sector
|
||||
fixed_t friction; // friction value to be applied during movement
|
||||
INT32 movefactor; // applied to each player move to simulate inertia
|
||||
|
||||
for (i = 0; i < numsectors; i++, s++)
|
||||
{
|
||||
if (!s->friction)
|
||||
if (s->friction == ORIG_FRICTION)
|
||||
continue;
|
||||
|
||||
strength = s->friction;
|
||||
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'.
|
||||
friction = ORIG_FRICTION - (0x1EB8*strength)/0x80; // ORIG_FRICTION is 0xE800
|
||||
friction = s->friction;
|
||||
|
||||
if (friction > FRACUNIT)
|
||||
friction = FRACUNIT;
|
||||
|
|
|
@ -428,7 +428,7 @@ typedef struct sector_s
|
|||
mtag_t triggertag; // tag to call upon triggering
|
||||
UINT8 triggerer; // who can trigger?
|
||||
|
||||
INT32 friction;
|
||||
fixed_t friction;
|
||||
|
||||
// Sprite culling feature
|
||||
struct line_s *cullheight;
|
||||
|
|
Loading…
Reference in a new issue