Add S-Monitor power-up

- Give Invincibility effect to player
- Bumping players does not extend Invincibility time while
  power-up is active
This commit is contained in:
James R 2023-06-29 18:48:05 -07:00
parent 299a8b707c
commit b0b7bf8185
5 changed files with 35 additions and 1 deletions

View file

@ -463,6 +463,7 @@ typedef struct {
// player_t struct for power-ups // player_t struct for power-ups
struct powerupvars_t { struct powerupvars_t {
UINT16 superTimer;
mobj_t *flickyController; mobj_t *flickyController;
}; };

View file

@ -8090,6 +8090,11 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
} }
} }
if (player->powerup.superTimer > 0)
{
player->powerup.superTimer--;
}
if (player->guardCooldown) if (player->guardCooldown)
player->guardCooldown--; player->guardCooldown--;

View file

@ -8,6 +8,9 @@ tic_t K_PowerUpRemaining(const player_t* player, kartitems_t powerup)
{ {
switch (powerup) switch (powerup)
{ {
case POWERUP_SMONITOR:
return player->powerup.superTimer;
case POWERUP_SUPERFLICKY: case POWERUP_SUPERFLICKY:
return Obj_SuperFlickySwarmTime(player->powerup.flickyController); return Obj_SuperFlickySwarmTime(player->powerup.flickyController);
@ -20,6 +23,11 @@ void K_GivePowerUp(player_t* player, kartitems_t powerup, tic_t time)
{ {
switch (powerup) switch (powerup)
{ {
case POWERUP_SMONITOR:
K_DoInvincibility(player, time);
player->powerup.superTimer += time;
break;
case POWERUP_SUPERFLICKY: case POWERUP_SUPERFLICKY:
if (K_PowerUpRemaining(player, POWERUP_SUPERFLICKY)) if (K_PowerUpRemaining(player, POWERUP_SUPERFLICKY))
{ {
@ -38,6 +46,19 @@ void K_GivePowerUp(player_t* player, kartitems_t powerup, tic_t time)
void K_DropPowerUps(player_t* player) void K_DropPowerUps(player_t* player)
{ {
auto simple_drop = [player](kartitems_t powerup, auto& timer)
{
tic_t remaining = K_PowerUpRemaining(player, powerup);
if (remaining)
{
K_DropPaperItem(player, powerup, remaining);
timer = 0;
}
};
simple_drop(POWERUP_SMONITOR, player->powerup.superTimer);
if (K_PowerUpRemaining(player, POWERUP_SUPERFLICKY)) if (K_PowerUpRemaining(player, POWERUP_SUPERFLICKY))
{ {
mobj_t* swarm = player->powerup.flickyController; mobj_t* swarm = player->powerup.flickyController;

View file

@ -2418,7 +2418,8 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
if (source && source != player->mo && source->player) if (source && source != player->mo && source->player)
{ {
// Extend the invincibility if the hit was a direct hit. // Extend the invincibility if the hit was a direct hit.
if (inflictor == source && source->player->invincibilitytimer) if (inflictor == source && source->player->invincibilitytimer &&
!K_PowerUpRemaining(player, POWERUP_SMONITOR))
{ {
tic_t kinvextend; tic_t kinvextend;

View file

@ -634,6 +634,9 @@ static void P_NetArchivePlayers(savebuffer_t *save)
// ACS has read access to this, so it has to be net-communicated. // ACS has read access to this, so it has to be net-communicated.
// It is the ONLY roundcondition that is sent over the wire and I'd like it to stay that way. // It is the ONLY roundcondition that is sent over the wire and I'd like it to stay that way.
WRITEUINT32(save->p, players[i].roundconditions.unlocktriggers); WRITEUINT32(save->p, players[i].roundconditions.unlocktriggers);
// powerupvars_t
WRITEUINT16(save->p, players[i].powerup.superTimer);
} }
} }
@ -1059,6 +1062,9 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
// It is the ONLY roundcondition that is sent over the wire and I'd like it to stay that way. // It is the ONLY roundcondition that is sent over the wire and I'd like it to stay that way.
players[i].roundconditions.unlocktriggers = READUINT32(save->p); players[i].roundconditions.unlocktriggers = READUINT32(save->p);
// powerupvars_t
players[i].powerup.superTimer = READUINT16(save->p);
//players[i].viewheight = P_GetPlayerViewHeight(players[i]); // scale cannot be factored in at this point //players[i].viewheight = P_GetPlayerViewHeight(players[i]); // scale cannot be factored in at this point
} }
} }