Credit players for deathpits that result from their hits

This commit is contained in:
AJ Martinez 2024-02-11 21:40:53 -07:00
parent 7a54b3eb3b
commit c0598610e9
6 changed files with 32 additions and 1 deletions

View file

@ -965,6 +965,8 @@ struct player_t
mobj_t *hand;
mobj_t *flickyAttacker;
SINT8 pitblame; // Index of last player that hit you, resets after being in control for a bit. If you deathpit, credit the old attacker!
UINT8 instaWhipCharge;
UINT8 defenseLockout; // Committed to universal attack/defense, make 'em vulnerable! No whip/guard.
UINT8 instaWhipChargeLockout; // Input safety

View file

@ -2389,6 +2389,8 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
p->ringvolume = 255;
p->ringtransparency = 255;
p->pitblame = -1;
p->topAccel = MAXTOPACCEL;
p->botvars.rubberband = FRACUNIT;

View file

@ -8914,6 +8914,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
player->incontrol = min(player->incontrol, 5*TICRATE);
player->incontrol = max(player->incontrol, -5*TICRATE);
if (player->incontrol == 3*TICRATE)
player->pitblame = -1;
if (P_PlayerInPain(player) || player->respawn.state != RESPAWNST_NONE)
{
player->lastpickuptype = -1; // got your ass beat, go grab anything

View file

@ -351,6 +351,8 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->topAccel);
else if (fastcmp(field,"instaWhipCharge"))
lua_pushinteger(L, plr->instaWhipCharge);
else if (fastcmp(field,"pitblame"))
lua_pushinteger(L, plr->pitblame);
else if (fastcmp(field,"defenseLockout"))
lua_pushinteger(L, plr->defenseLockout);
else if (fastcmp(field,"oldGuard"))
@ -877,6 +879,8 @@ static int player_set(lua_State *L)
plr->topAccel = luaL_checkinteger(L, 3);
else if (fastcmp(field,"instaWhipCharge"))
plr->instaWhipCharge = luaL_checkinteger(L, 3);
else if (fastcmp(field,"pitblame"))
plr->pitblame = luaL_checkinteger(L, 3);
else if (fastcmp(field,"defenseLockout"))
plr->defenseLockout = luaL_checkinteger(L, 3);
else if (fastcmp(field,"oldGuard"))

View file

@ -2502,7 +2502,15 @@ static boolean P_KillPlayer(player_t *player, mobj_t *inflictor, mobj_t *source,
if (gametyperules & (GTR_BUMPERS|GTR_CHECKPOINTS))
{
player->mo->health--;
if ((player->pitblame != -1) && (playeringame[player->pitblame]) && (!players[player->pitblame].spectator)
&& (players[player->pitblame].mo) && (!P_MobjWasRemoved(players[player->pitblame].mo)))
{
P_DamageMobj(player->mo, players[player->pitblame].mo, players[player->pitblame].mo, 1, DMG_KARMA);
}
else if (player->mo->health > 1 || battleprisons)
{
player->mo->health--;
}
}
if (player->mo->health <= 0)
@ -3134,6 +3142,14 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
}
}
if (source && source != player->mo && source->player)
{
if (damagetype != DMG_DEATHPIT)
{
player->pitblame = source->player - players;
}
}
player->sneakertimer = player->numsneakers = 0;
player->driftboost = player->strongdriftboost = 0;
player->gateBoost = 0;

View file

@ -578,6 +578,8 @@ static void P_NetArchivePlayers(savebuffer_t *save)
WRITEMEM(save->p, players[i].public_key, PUBKEYLENGTH);
WRITESINT8(save->p, players[i].pitblame);
WRITEUINT8(save->p, players[i].instaWhipCharge);
WRITEUINT8(save->p, players[i].defenseLockout);
WRITEUINT8(save->p, players[i].oldGuard);
@ -1153,6 +1155,8 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
READMEM(save->p, players[i].public_key, PUBKEYLENGTH);
players[i].pitblame = READSINT8(save->p);
players[i].instaWhipCharge = READUINT8(save->p);
players[i].defenseLockout = READUINT8(save->p);
players[i].oldGuard = READUINT8(save->p);