Items respawn in GP

This commit is contained in:
Sally Coolatta 2020-05-13 03:04:33 -04:00
parent 482141a95f
commit e51bceb567
4 changed files with 20 additions and 30 deletions

View file

@ -682,8 +682,6 @@ void D_RegisterServerCommands(void)
AddMServCommands(); AddMServCommands();
// p_mobj.c // p_mobj.c
CV_RegisterVar(&cv_itemrespawntime);
CV_RegisterVar(&cv_itemrespawn);
CV_RegisterVar(&cv_flagtime); CV_RegisterVar(&cv_flagtime);
CV_RegisterVar(&cv_suddendeath); CV_RegisterVar(&cv_suddendeath);
@ -5152,11 +5150,6 @@ void D_GameTypeChanged(INT32 lastgametype)
// There will always be a server, and this only needs to be done once. // There will always be a server, and this only needs to be done once.
if (server && (multiplayer || netgame)) if (server && (multiplayer || netgame))
{ {
if (gametype == GT_COMPETITION || gametype == GT_COOP)
CV_SetValue(&cv_itemrespawn, 0);
else if (!cv_itemrespawn.changed)
CV_SetValue(&cv_itemrespawn, 1);
switch (gametype) switch (gametype)
{ {
case GT_MATCH: case GT_MATCH:
@ -5167,8 +5160,6 @@ void D_GameTypeChanged(INT32 lastgametype)
CV_SetValue(&cv_pointlimit, 0); CV_SetValue(&cv_pointlimit, 0);
CV_SetValue(&cv_timelimit, 120); CV_SetValue(&cv_timelimit, 120);
} }
if (!cv_itemrespawntime.changed)
CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue); // respawn normally
break; break;
case GT_TAG: case GT_TAG:
case GT_HIDEANDSEEK: case GT_HIDEANDSEEK:
@ -5179,8 +5170,6 @@ void D_GameTypeChanged(INT32 lastgametype)
CV_SetValue(&cv_timelimit, 5); CV_SetValue(&cv_timelimit, 5);
CV_SetValue(&cv_pointlimit, 0); CV_SetValue(&cv_pointlimit, 0);
} }
if (!cv_itemrespawntime.changed)
CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue); // respawn normally
break; break;
case GT_CTF: case GT_CTF:
if (!cv_timelimit.changed && !cv_pointlimit.changed) // user hasn't changed limits if (!cv_timelimit.changed && !cv_pointlimit.changed) // user hasn't changed limits
@ -5189,17 +5178,12 @@ void D_GameTypeChanged(INT32 lastgametype)
CV_SetValue(&cv_timelimit, 0); CV_SetValue(&cv_timelimit, 0);
CV_SetValue(&cv_pointlimit, 5); CV_SetValue(&cv_pointlimit, 5);
} }
if (!cv_itemrespawntime.changed)
CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue); // respawn normally
break; break;
} }
} }
else if (!multiplayer && !netgame) else if (!multiplayer && !netgame)
{ {
gametype = GT_RACE; // SRB2kart gametype = GT_RACE;
// These shouldn't matter anymore
//CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue);
//CV_SetValue(&cv_itemrespawn, 0);
} }
// reset timelimit and pointlimit in race/coop, prevent stupid cheats // reset timelimit and pointlimit in race/coop, prevent stupid cheats

View file

@ -60,10 +60,6 @@ extern consvar_t cv_usemouse2;
extern consvar_t cv_mouse2opt; extern consvar_t cv_mouse2opt;
#endif #endif
// normally in p_mobj but the .h is not read
extern consvar_t cv_itemrespawntime;
extern consvar_t cv_itemrespawn;
extern consvar_t cv_flagtime; extern consvar_t cv_flagtime;
extern consvar_t cv_suddendeath; extern consvar_t cv_suddendeath;

View file

@ -2217,11 +2217,28 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
{ {
if (target->flags & MF_MONITOR || target->type == MT_RANDOMITEM) if (target->flags & MF_MONITOR || target->type == MT_RANDOMITEM)
{ {
UINT8 i;
P_SetTarget(&target->target, source); P_SetTarget(&target->target, source);
source->player->numboxes++; source->player->numboxes++;
if (cv_itemrespawn.value && (netgame || multiplayer))
for (i = 0; i < MAXPLAYERS; i++)
{ {
target->fuse = cv_itemrespawntime.value*TICRATE + 2; // Random box generation if (&players[i] == source->player)
{
continue;
}
if (playeringame[i] && !players[i].spectator && players[i].lives != 0)
{
break;
}
}
if (i < MAXPLAYERS)
{
// Respawn items in multiplayer, don't respawn them when alone
target->fuse = 2*TICRATE + 2;
} }
} }

View file

@ -11377,9 +11377,6 @@ void P_RemoveSavegameMobj(mobj_t *mobj)
P_RemoveThinker((thinker_t *)mobj); P_RemoveThinker((thinker_t *)mobj);
} }
static CV_PossibleValue_t respawnitemtime_cons_t[] = {{1, "MIN"}, {300, "MAX"}, {0, NULL}};
consvar_t cv_itemrespawntime = {"respawnitemtime", "2", CV_NETVAR|CV_CHEAT, respawnitemtime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_itemrespawn = {"respawnitem", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t flagtime_cons_t[] = {{0, "MIN"}, {300, "MAX"}, {0, NULL}}; static CV_PossibleValue_t flagtime_cons_t[] = {{0, "MIN"}, {300, "MAX"}, {0, NULL}};
consvar_t cv_flagtime = {"flagtime", "30", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, flagtime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_flagtime = {"flagtime", "30", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, flagtime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_suddendeath = {"suddendeath", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_suddendeath = {"suddendeath", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@ -11650,10 +11647,6 @@ void P_RespawnSpecials(void)
time = (time * 3) / max(1, mapheaderinfo[gamemap-1]->numlaps); time = (time * 3) / max(1, mapheaderinfo[gamemap-1]->numlaps);
} }
// only respawn items when cv_itemrespawn is on
//if (!cv_itemrespawn.value) // TODO: remove this cvar
//return;
// nothing left to respawn? // nothing left to respawn?
if (iquehead == iquetail) if (iquehead == iquetail)
return; return;