mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-31 05:30:48 +00:00
Refactored the movefactor changes that made the player go Looney Tunes style on ice.
This commit is contained in:
parent
26f34d1038
commit
aa93f8a25c
5 changed files with 19 additions and 13 deletions
|
@ -7808,7 +7808,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
|||
|
||||
mobj->friction = ORIG_FRICTION;
|
||||
|
||||
mobj->movefactor = ORIG_FRICTION;
|
||||
mobj->movefactor = FRACUNIT;
|
||||
|
||||
// All mobjs are created at 100% scale.
|
||||
mobj->scale = FRACUNIT;
|
||||
|
|
|
@ -1434,6 +1434,7 @@ static inline void SaveFrictionThinker(const thinker_t *th, const UINT8 type)
|
|||
const friction_t *ht = (const void *)th;
|
||||
WRITEUINT8(save_p, type);
|
||||
WRITEINT32(save_p, ht->friction);
|
||||
WRITEINT32(save_p, ht->movefactor);
|
||||
WRITEINT32(save_p, ht->affectee);
|
||||
WRITEINT32(save_p, ht->referrer);
|
||||
WRITEUINT8(save_p, ht->roverfriction);
|
||||
|
@ -2368,6 +2369,7 @@ static inline void LoadFrictionThinker(actionf_p1 thinker)
|
|||
friction_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL);
|
||||
ht->thinker.function.acp1 = thinker;
|
||||
ht->friction = READINT32(save_p);
|
||||
ht->movefactor = READINT32(save_p);
|
||||
ht->affectee = READINT32(save_p);
|
||||
ht->referrer = READINT32(save_p);
|
||||
ht->roverfriction = READUINT8(save_p);
|
||||
|
|
20
src/p_spec.c
20
src/p_spec.c
|
@ -109,7 +109,7 @@ static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline);
|
|||
//static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec);
|
||||
static void P_AddFakeFloorsByLine(size_t line, ffloortype_e ffloorflags, thinkerlist_t *secthinkers);
|
||||
static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec);
|
||||
static void Add_Friction(INT32 friction, INT32 affectee, INT32 referrer);
|
||||
static void Add_Friction(INT32 friction, INT32 movefactor, INT32 affectee, INT32 referrer);
|
||||
static void P_AddSpikeThinker(sector_t *sec, INT32 referrer);
|
||||
|
||||
|
||||
|
@ -4932,7 +4932,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f
|
|||
f = (friction_t *)th;
|
||||
|
||||
if (f->affectee == (INT32)sec2num)
|
||||
Add_Friction(f->friction, (INT32)(sec-sectors), f->affectee);
|
||||
Add_Friction(f->friction, f->movefactor, (INT32)(sec-sectors), f->affectee);
|
||||
}
|
||||
// Should this FOF have wind/current/pusher?
|
||||
else if(th->function.acp1 == (actionf_p1)T_Pusher)
|
||||
|
@ -6978,12 +6978,13 @@ void T_Disappear(disappear_t *d)
|
|||
* \param roverfriction FOF or not
|
||||
* \sa T_Friction, P_SpawnFriction
|
||||
*/
|
||||
static void Add_Friction(INT32 friction, INT32 affectee, INT32 referrer)
|
||||
static void Add_Friction(INT32 friction, INT32 movefactor, INT32 affectee, INT32 referrer)
|
||||
{
|
||||
friction_t *f = Z_Calloc(sizeof *f, PU_LEVSPEC, NULL);
|
||||
|
||||
f->thinker.function.acp1 = (actionf_p1)T_Friction;
|
||||
f->friction = friction;
|
||||
f->movefactor = movefactor;
|
||||
f->affectee = affectee;
|
||||
|
||||
if (referrer != -1)
|
||||
|
@ -7044,7 +7045,7 @@ void T_Friction(friction_t *f)
|
|||
{
|
||||
thing->friction = f->friction;
|
||||
if (thing->player)
|
||||
thing->movefactor = f->friction;
|
||||
thing->movefactor = f->movefactor;
|
||||
}
|
||||
}
|
||||
else if (P_GetSpecialBottomZ(thing, sec, sec) == thing->floorz && (thing->friction == ORIG_FRICTION // normal friction?
|
||||
|
@ -7052,7 +7053,7 @@ void T_Friction(friction_t *f)
|
|||
{
|
||||
thing->friction = f->friction;
|
||||
if (thing->player)
|
||||
thing->movefactor = f->friction;
|
||||
thing->movefactor = f->movefactor;
|
||||
}
|
||||
}
|
||||
node = node->m_snext;
|
||||
|
@ -7070,6 +7071,7 @@ static void P_SpawnFriction(void)
|
|||
register INT32 s;
|
||||
fixed_t strength; // frontside texture offset controls magnitude
|
||||
fixed_t friction; // friction value to be applied during movement
|
||||
INT32 movefactor; // applied to each player move to simulate inertia
|
||||
|
||||
for (i = 0; i < numlines; i++, l++)
|
||||
if (l->special == 540)
|
||||
|
@ -7088,8 +7090,14 @@ static void P_SpawnFriction(void)
|
|||
if (friction < 0)
|
||||
friction = 0;
|
||||
|
||||
movefactor = FixedDiv(ORIG_FRICTION, friction);
|
||||
if (movefactor < FRACUNIT)
|
||||
movefactor = 8*movefactor - 7*FRACUNIT;
|
||||
else
|
||||
movefactor = FRACUNIT;
|
||||
|
||||
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
|
||||
Add_Friction(friction, s, -1);
|
||||
Add_Friction(friction, movefactor, s, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -386,6 +386,7 @@ typedef struct
|
|||
{
|
||||
thinker_t thinker; ///< Thinker structure for friction.
|
||||
INT32 friction; ///< Friction value, 0xe800 = normal.
|
||||
INT32 movefactor; ///< Inertia factor when adding to momentum, FRACUNIT = normal.
|
||||
INT32 affectee; ///< Number of affected sector.
|
||||
INT32 referrer; ///< If roverfriction == true, then this will contain the sector # of the control sector where the effect was applied.
|
||||
UINT8 roverfriction; ///< flag for whether friction originated from a FOF or not
|
||||
|
|
|
@ -6369,11 +6369,6 @@ static void P_MovePlayer(player_t *player)
|
|||
runspd = FixedMul(player->runspeed, player->mo->scale);
|
||||
|
||||
// Let's have some movement speed fun on low-friction surfaces, JUST for players... (high friction surfaces shouldn't have any adjustment, since the acceleration in this game is super high and that ends up cheesing high-friction surfaces.)
|
||||
player->mo->movefactor = FixedDiv(ORIG_FRICTION, player->mo->movefactor);
|
||||
if (player->mo->movefactor < FRACUNIT)
|
||||
player->mo->movefactor = 8*player->mo->movefactor - 7*FRACUNIT;
|
||||
else
|
||||
player->mo->movefactor = FRACUNIT;
|
||||
runspd = FixedMul(runspd, player->mo->movefactor);
|
||||
|
||||
// Control relinquishing stuff!
|
||||
|
@ -6547,7 +6542,7 @@ static void P_MovePlayer(player_t *player)
|
|||
if (!player->mo->momx && !player->mo->momy && !player->mo->momz && player->panim == PA_WALK)
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_STND);
|
||||
|
||||
player->mo->movefactor = ORIG_FRICTION; // We're not going to do any more with this, so let's change it back for the next frame.
|
||||
player->mo->movefactor = FRACUNIT; // We're not going to do any more with this, so let's change it back for the next frame.
|
||||
|
||||
//////////////////
|
||||
//GAMEPLAY STUFF//
|
||||
|
|
Loading…
Reference in a new issue