WANTED recalculates on hit, tons of spectator changes

This commit is contained in:
TehRealSalt 2018-07-03 21:12:25 -04:00
parent cbfa6bbe83
commit fbcf566874
11 changed files with 75 additions and 47 deletions

View file

@ -4263,7 +4263,7 @@ void D_GameTypeChanged(INT32 lastgametype)
// When swapping to a gametype that supports spectators,
// make everyone a spectator initially.
/*if (!splitscreen && (G_GametypeHasSpectators()))
/*if (G_GametypeHasSpectators())
{
INT32 i;
for (i = 0; i < MAXPLAYERS; i++)

View file

@ -449,6 +449,7 @@ extern boolean mirrormode;
extern boolean comeback;
extern SINT8 battlewanted[4];
extern tic_t wantedcalcdelay;
extern tic_t indirectitemcooldown;
extern tic_t spbincoming;
extern UINT8 spbplayer;

View file

@ -258,6 +258,7 @@ SINT8 pickedvote; // What vote the host rolls
// Server-sided variables
SINT8 battlewanted[4]; // WANTED players in battle, worth x2 points
tic_t wantedcalcdelay; // Time before it recalculates WANTED
tic_t indirectitemcooldown; // Cooldown before any more Shrink, SPB, or any other item that works indirectly is awarded
tic_t spbincoming; // Timer before SPB hits, can switch targets at this point
UINT8 spbplayer; // Player num that used the last SPB

View file

@ -1496,9 +1496,9 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, boolean trapitem
karmahitbox->destscale = player->mo->scale;
P_SetScale(karmahitbox, player->mo->scale);
CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]);
if (K_IsPlayerWanted(player))
K_CalculateBattleWanted();
}
if (K_IsPlayerWanted(player))
K_CalculateBattleWanted();
player->kartstuff[k_bumper]--;
}
@ -1563,9 +1563,9 @@ void K_SquishPlayer(player_t *player, mobj_t *source)
karmahitbox->destscale = player->mo->scale;
P_SetScale(karmahitbox, player->mo->scale);
CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]);
if (K_IsPlayerWanted(player))
K_CalculateBattleWanted();
}
if (K_IsPlayerWanted(player))
K_CalculateBattleWanted();
player->kartstuff[k_bumper]--;
}
@ -1624,9 +1624,9 @@ void K_ExplodePlayer(player_t *player, mobj_t *source) // A bit of a hack, we ju
karmahitbox->destscale = player->mo->scale;
P_SetScale(karmahitbox, player->mo->scale);
CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]);
if (K_IsPlayerWanted(player))
K_CalculateBattleWanted();
}
if (K_IsPlayerWanted(player))
K_CalculateBattleWanted();
player->kartstuff[k_bumper]--;
}
@ -3275,13 +3275,9 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
if (player->kartstuff[k_positiondelay])
player->kartstuff[k_positiondelay]--;
// Race Spectator
if (netgame && player->jointime < 1
&& G_RaceGametype() && countdown)
{
player->spectator = true;
player->powers[pw_nocontrol] = 5;
}
// Race force spectate
if (player->spectator && netgame && G_RaceGametype() && P_FindHighestLap() > 0)
player->powers[pw_flashing] = 5;
if ((player->pflags & PF_ATTACKDOWN) && !(cmd->buttons & BT_ATTACK))
player->pflags &= ~PF_ATTACKDOWN;
@ -3843,6 +3839,8 @@ void K_CalculateBattleWanted(void)
return;
}
wantedcalcdelay = wantedfrequency;
for (i = 0; i < MAXPLAYERS; i++)
camppos[i] = -1; // initialize

View file

@ -2839,9 +2839,9 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage)
karmahitbox->destscale = player->mo->scale;
P_SetScale(karmahitbox, player->mo->scale);
CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]);
if (K_IsPlayerWanted(player))
K_CalculateBattleWanted();
}
if (K_IsPlayerWanted(player))
K_CalculateBattleWanted();
player->kartstuff[k_bumper]--;
}

View file

@ -183,6 +183,7 @@ boolean P_AnalogMove(player_t *player);
boolean P_TransferToNextMare(player_t *player);
UINT8 P_FindLowestMare(void);
UINT8 P_FindLowestLap(void);
UINT8 P_FindHighestLap(void);
void P_FindEmerald(void);
void P_TransferToAxis(player_t *player, INT32 axisnum);
boolean P_PlayerMoving(INT32 pnum);

View file

@ -6940,7 +6940,7 @@ void P_MobjThinker(mobj_t *mobj)
{
P_SetMobjState(mobj, S_PLAYERARROW_BOX);
mobj->tracer->sprite = SPR_ITEM;
mobj->tracer->frame = FF_FULLBRIGHT|((mobj->target->player->kartstuff[k_itemroulette] % (13*3)) / 3);
mobj->tracer->frame = FF_FULLBRIGHT|(((mobj->target->player->kartstuff[k_itemroulette] % (13*3)) / 3) + 1);
}
else if (mobj->target->player->kartstuff[k_itemtype])
{
@ -6962,9 +6962,11 @@ void P_MobjThinker(mobj_t *mobj)
break;
}
if (mobj->target->player->kartstuff[k_growshrinktimer])
if (mobj->target->player->kartstuff[k_growshrinktimer] > 0)
{
mobj->tracer->sprite = SPR_ITEM;
mobj->tracer->frame = FF_FULLBRIGHT|KITEM_GROW;
if (leveltime & 1)
mobj->tracer->flags2 |= MF2_DONTDRAW;
else
@ -8178,7 +8180,7 @@ void P_MobjThinker(mobj_t *mobj)
P_TeleportMove(mobj, mobj->target->x, mobj->target->y, mobj->target->z);
break;
case MT_KARMAHITBOX:
if (!mobj->target || !mobj->target->health || !mobj->target->player
if (!mobj->target || !mobj->target->health || !mobj->target->player || mobj->target->player->spectator
|| (G_RaceGametype() || mobj->target->player->kartstuff[k_bumper]))
{
P_RemoveMobj(mobj);
@ -9797,24 +9799,27 @@ void P_RespawnSpecials(void)
//
void P_SpawnPlayer(INT32 playernum)
{
UINT8 i, pcount = 0;
player_t *p = &players[playernum];
mobj_t *mobj;
if (p->playerstate == PST_REBORN)
G_PlayerReborn(playernum);
for (i = 0; i < MAXPLAYERS; i++)
{
if (i == playernum)
continue;
if (!playeringame[i] || players[i].spectator)
continue;
pcount++;
}
// spawn as spectator determination
if (!G_GametypeHasSpectators())
{
// Special case for (NiGHTS) special stages!
// if stage has already started, force players to become spectators until the next stage
/*if (multiplayer && netgame && G_IsSpecialStage(gamemap) && useNightsSS && leveltime > 0)
p->spectator = true;
else*/
p->spectator = false;
}
else if (netgame && p->jointime < 1)
/*p->spectator = true*/;
p->spectator = false;
else if (netgame && p->jointime <= 1 && pcount > 1)
p->spectator = true;
else if (multiplayer && !netgame)
{
// If you're in a team game and you don't have a team assigned yet...
@ -9893,19 +9898,10 @@ void P_SpawnPlayer(INT32 playernum)
overheadarrow->flags2 |= MF2_DONTDRAW;
P_SetScale(overheadarrow, mobj->destscale);
/*INT32 i;
INT32 pcount = 0;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator || &players[i] == p)
continue;
if (players[i].jointime > 1)
continue;
pcount++;
}*/
if (p->kartstuff[k_bumper] > 0 || leveltime < 1/* || pcount <= 1*/)
if (p->spectator) // HEY! No being cheap...
p->kartstuff[k_bumper] = 0;
else if (p->kartstuff[k_bumper] > 0 || leveltime < 1
|| (p->jointime <= 1 && pcount <= 1))
{
INT32 i;
angle_t newangle;
@ -9913,8 +9909,8 @@ void P_SpawnPlayer(INT32 playernum)
fixed_t newx;
fixed_t newy;
mobj_t *mo;
if (leveltime < 1 && !p->spectator /*|| pcount <= 1*/) // Start of the map?
if (leveltime < 1 || (p->jointime <= 1 && pcount <= 1)) // Start of the map?
p->kartstuff[k_bumper] = cv_kartbumpers.value; // Reset those bumpers!
if (p->kartstuff[k_bumper] <= 1)

View file

@ -3260,6 +3260,7 @@ static void P_NetArchiveMisc(void)
for (i = 0; i < 4; i++)
WRITESINT8(save_p, battlewanted[i]);
WRITEUINT32(save_p, wantedcalcdelay);
WRITEUINT32(save_p, indirectitemcooldown);
WRITEUINT32(save_p, spbincoming);
WRITEUINT8(save_p, spbplayer);
@ -3363,6 +3364,7 @@ static inline boolean P_NetUnArchiveMisc(void)
for (i = 0; i < 4; i++)
battlewanted[i] = READSINT8(save_p);
wantedcalcdelay = READUINT32(save_p);
indirectitemcooldown = READUINT32(save_p);
spbincoming = READUINT32(save_p);
spbplayer = READUINT8(save_p);

View file

@ -3009,6 +3009,7 @@ boolean P_SetupLevel(boolean skipprecip)
for (i = 0; i < 4; i++)
battlewanted[i] = -1;
wantedcalcdelay = wantedfrequency*2;
indirectitemcooldown = 0;
spbincoming = 0;
spbplayer = 0;

View file

@ -677,9 +677,6 @@ void P_Ticker(boolean run)
if (countdown2)
countdown2--;
if (G_BattleGametype() && leveltime % wantedfrequency == 0 && leveltime > wantedfrequency)
K_CalculateBattleWanted();
if (spbincoming && --spbincoming <= 0)
{
UINT8 best = 0;
@ -715,6 +712,12 @@ void P_Ticker(boolean run)
if (indirectitemcooldown)
indirectitemcooldown--;
if (G_BattleGametype())
{
if (wantedcalcdelay && --wantedcalcdelay <= 0)
K_CalculateBattleWanted();
}
if (quake.time)
{
fixed_t ir = quake.intensity>>1;

View file

@ -406,6 +406,31 @@ UINT8 P_FindLowestLap(void)
return lowest;
}
//
// P_FindHighestLap
//
UINT8 P_FindHighestLap(void)
{
INT32 i;
UINT8 highest = 0;
if (!G_RaceGametype())
return 0;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator)
continue;
if (players[i].laps > highest)
highest = players[i].laps;
}
CONS_Debug(DBG_GAMELOGIC, "Highest laps found: %d\n", highest);
return highest;
}
//
// P_TransferToNextMare
//