From b73bbd3712cdda0b89190c4d73e3db20d6beef90 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 19 Dec 2022 15:25:15 -0800 Subject: [PATCH] Add invulnhitlag, timeshit and timeshitprev fields to player_t --- src/d_player.h | 8 +++++++- src/lua_playerlib.c | 12 ++++++++++++ src/p_saveg.c | 8 ++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index af6e75517..265bd13cb 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -466,6 +466,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 UINT8 wipeoutslow; // Timer before you slowdown when getting wiped out UINT8 justbumped; // Prevent players from endlessly bumping into each other UINT8 tumbleBounces; @@ -615,7 +616,12 @@ struct player_t INT16 lastsidehit, lastlinehit; - //UINT8 timeshit; // That's TIMES HIT, not TIME SHIT, you doofus! -- in memoriam + // These track how many things tried to damage you, not + // whether you actually took damage. + UINT8 timeshit; // times hit this tic + UINT8 timeshitprev; // times hit before + // That's TIMES HIT, not TIME SHIT, you doofus! -- in memoriam + // No longer in memoriam =P -jart INT32 onconveyor; // You are on a conveyor belt if nonzero diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 3bc7e1584..7195c90f0 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -232,6 +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,"wipeoutslow")) lua_pushinteger(L, plr->wipeoutslow); else if (fastcmp(field,"justbumped")) @@ -472,6 +474,10 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->lastsidehit); else if (fastcmp(field,"lastlinehit")) lua_pushinteger(L, plr->lastlinehit); + else if (fastcmp(field,"timeshit")) + lua_pushinteger(L, plr->timeshit); + else if (fastcmp(field,"timeshitprev")) + lua_pushinteger(L, plr->timeshitprev); else if (fastcmp(field,"onconveyor")) lua_pushinteger(L, plr->onconveyor); else if (fastcmp(field,"awayviewmobj")) @@ -604,6 +610,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,"wipeoutslow")) plr->wipeoutslow = luaL_checkinteger(L, 3); else if (fastcmp(field,"justbumped")) @@ -830,6 +838,10 @@ static int player_set(lua_State *L) plr->lastsidehit = (INT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"lastlinehit")) plr->lastlinehit = (INT16)luaL_checkinteger(L, 3); + else if (fastcmp(field,"timeshit")) + plr->timeshit = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"timeshitprev")) + plr->timeshitprev = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"onconveyor")) plr->onconveyor = (INT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"awayviewmobj")) diff --git a/src/p_saveg.c b/src/p_saveg.c index f36d94319..b7d3802ff 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -190,6 +190,9 @@ static void P_NetArchivePlayers(void) WRITEINT32(save_p, players[i].onconveyor); + WRITEUINT8(save_p, players[i].timeshit); + WRITEUINT8(save_p, players[i].timeshitprev); + WRITEUINT32(save_p, players[i].jointime); WRITEUINT8(save_p, players[i].splitscreenindex); @@ -266,6 +269,7 @@ static void P_NetArchivePlayers(void) WRITEUINT16(save_p, players[i].spinouttimer); WRITEUINT8(save_p, players[i].spinouttype); WRITEUINT8(save_p, players[i].instashield); + WRITEINT32(save_p, players[i].invulnhitlag); WRITEUINT8(save_p, players[i].wipeoutslow); WRITEUINT8(save_p, players[i].justbumped); WRITEUINT8(save_p, players[i].tumbleBounces); @@ -557,6 +561,9 @@ static void P_NetUnArchivePlayers(void) players[i].lastsidehit = READINT16(save_p); players[i].lastlinehit = READINT16(save_p); + players[i].timeshit = READUINT8(save_p); + players[i].timeshitprev = READUINT8(save_p); + players[i].onconveyor = READINT32(save_p); players[i].jointime = READUINT32(save_p); @@ -615,6 +622,7 @@ static void P_NetUnArchivePlayers(void) 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].wipeoutslow = READUINT8(save_p); players[i].justbumped = READUINT8(save_p); players[i].tumbleBounces = READUINT8(save_p);