mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-31 04:02:37 +00:00
Refactor player->invulnhitlag -> player->nullHitlag
- Move condition for whether hitlag came from a constant damage source into P_DamageMobj directly. Should be more accurate if a player is dealt brand new damage, the constant damage still won't count. - player->invulnhitlag renamed to player->nullHitlag
This commit is contained in:
parent
cdecada971
commit
b2a6ffecf9
5 changed files with 51 additions and 39 deletions
|
|
@ -490,7 +490,7 @@ struct player_t
|
|||
UINT16 spinouttimer; // Spin-out from a banana peel or oil slick (was "pw_bananacam")
|
||||
UINT8 spinouttype; // Determines the mode of spinout/wipeout, see kartspinoutflags_t
|
||||
UINT8 instashield; // Instashield no-damage animation timer
|
||||
INT32 invulnhitlag; // Numbers of tics of hitlag added this tic for "potential" damage -- not real damage
|
||||
INT32 nullHitlag; // Numbers of tics of hitlag that will ultimately be ignored by subtracting from hitlag
|
||||
UINT8 wipeoutslow; // Timer before you slowdown when getting wiped out
|
||||
UINT8 justbumped; // Prevent players from endlessly bumping into each other
|
||||
UINT8 tumbleBounces;
|
||||
|
|
|
|||
24
src/k_kart.c
24
src/k_kart.c
|
|
@ -8290,30 +8290,14 @@ void K_KartPlayerAfterThink(player_t *player)
|
|||
K_LookForRings(player->mo);
|
||||
}
|
||||
|
||||
if (player->invulnhitlag > 0)
|
||||
if (player->nullHitlag > 0)
|
||||
{
|
||||
// Hitlag from what would normally be damage but the
|
||||
// player was invulnerable.
|
||||
//
|
||||
// If we're constantly getting hit the same number of
|
||||
// times, we're probably standing on a damage floor.
|
||||
//
|
||||
// Checking if we're hit more than before ensures
|
||||
// that:
|
||||
//
|
||||
// 1) repeating damage doesn't count
|
||||
// 2) new damage sources still count
|
||||
|
||||
if (player->timeshit <= player->timeshitprev)
|
||||
if (!P_MobjWasRemoved(player->mo))
|
||||
{
|
||||
if (!P_MobjWasRemoved(player->mo))
|
||||
{
|
||||
player->mo->hitlag -= player->invulnhitlag;
|
||||
player->mo->eflags &= ~(MFE_DAMAGEHITLAG);
|
||||
}
|
||||
player->mo->hitlag -= player->nullHitlag;
|
||||
}
|
||||
|
||||
player->invulnhitlag = 0;
|
||||
player->nullHitlag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -232,8 +232,8 @@ static int player_get(lua_State *L)
|
|||
lua_pushinteger(L, plr->spinouttimer);
|
||||
else if (fastcmp(field,"instashield"))
|
||||
lua_pushinteger(L, plr->instashield);
|
||||
else if (fastcmp(field,"invulnhitlag"))
|
||||
lua_pushinteger(L, plr->invulnhitlag);
|
||||
else if (fastcmp(field,"nullHitlag"))
|
||||
lua_pushinteger(L, plr->nullHitlag);
|
||||
else if (fastcmp(field,"wipeoutslow"))
|
||||
lua_pushinteger(L, plr->wipeoutslow);
|
||||
else if (fastcmp(field,"justbumped"))
|
||||
|
|
@ -614,8 +614,8 @@ static int player_set(lua_State *L)
|
|||
plr->spinouttimer = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"instashield"))
|
||||
plr->instashield = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"invulnhitlag"))
|
||||
plr->invulnhitlag = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"nullHitlag"))
|
||||
plr->nullHitlag = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"wipeoutslow"))
|
||||
plr->wipeoutslow = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"justbumped"))
|
||||
|
|
|
|||
|
|
@ -2003,6 +2003,43 @@ static boolean P_KillPlayer(player_t *player, mobj_t *inflictor, mobj_t *source,
|
|||
return true;
|
||||
}
|
||||
|
||||
static void AddTimesHit(player_t *player)
|
||||
{
|
||||
const INT32 oldtimeshit = player->timeshit;
|
||||
|
||||
player->timeshit++;
|
||||
|
||||
// overflow prevention
|
||||
if (player->timeshit < oldtimeshit)
|
||||
{
|
||||
player->timeshit = oldtimeshit;
|
||||
}
|
||||
}
|
||||
|
||||
static void AddNullHitlag(player_t *player, tic_t oldHitlag)
|
||||
{
|
||||
if (player == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Hitlag from what would normally be damage but the
|
||||
// player was invulnerable.
|
||||
//
|
||||
// If we're constantly getting hit the same number of
|
||||
// times, we're probably standing on a damage floor.
|
||||
//
|
||||
// Checking if we're hit more than before ensures that:
|
||||
//
|
||||
// 1) repeating damage doesn't count
|
||||
// 2) new damage sources still count
|
||||
|
||||
if (player->timeshit <= player->timeshitprev)
|
||||
{
|
||||
player->nullHitlag += (player->mo->hitlag - oldHitlag);
|
||||
}
|
||||
}
|
||||
|
||||
/** Damages an object, which may or may not be a player.
|
||||
* For melee attacks, source and inflictor are the same.
|
||||
*
|
||||
|
|
@ -2104,17 +2141,8 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
|||
|
||||
if (player) // Player is the target
|
||||
{
|
||||
{
|
||||
const INT32 oldtimeshit = player->timeshit;
|
||||
|
||||
player->timeshit++;
|
||||
|
||||
// overflow prevention
|
||||
if (player->timeshit < oldtimeshit)
|
||||
{
|
||||
player->timeshit = oldtimeshit;
|
||||
}
|
||||
}
|
||||
AddTimesHit(player);
|
||||
|
||||
if (player->pflags & PF_GODMODE)
|
||||
return false;
|
||||
|
|
@ -2179,12 +2207,12 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
|||
|
||||
if (invincible && type != DMG_STUMBLE)
|
||||
{
|
||||
const INT32 oldhitlag = target->hitlag;
|
||||
const INT32 oldHitlag = target->hitlag;
|
||||
|
||||
laglength = max(laglength / 2, 1);
|
||||
K_SetHitLagForObjects(target, inflictor, laglength, false);
|
||||
|
||||
player->invulnhitlag += (target->hitlag - oldhitlag);
|
||||
AddNullHitlag(player, oldHitlag);
|
||||
|
||||
if (player->timeshit > player->timeshitprev)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ static void P_NetArchivePlayers(savebuffer_t *save)
|
|||
WRITEUINT16(save->p, players[i].spinouttimer);
|
||||
WRITEUINT8(save->p, players[i].spinouttype);
|
||||
WRITEUINT8(save->p, players[i].instashield);
|
||||
WRITEINT32(save->p, players[i].invulnhitlag);
|
||||
WRITEINT32(save->p, players[i].nullHitlag);
|
||||
WRITEUINT8(save->p, players[i].wipeoutslow);
|
||||
WRITEUINT8(save->p, players[i].justbumped);
|
||||
WRITEUINT8(save->p, players[i].tumbleBounces);
|
||||
|
|
@ -651,7 +651,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
|
|||
players[i].spinouttimer = READUINT16(save->p);
|
||||
players[i].spinouttype = READUINT8(save->p);
|
||||
players[i].instashield = READUINT8(save->p);
|
||||
players[i].invulnhitlag = READINT32(save->p);
|
||||
players[i].nullHitlag = READINT32(save->p);
|
||||
players[i].wipeoutslow = READUINT8(save->p);
|
||||
players[i].justbumped = READUINT8(save->p);
|
||||
players[i].tumbleBounces = READUINT8(save->p);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue