Ensure ALL boxes are respawned for overtime

This commit is contained in:
TehRealSalt 2018-12-07 18:50:36 -05:00
parent 399cc44b93
commit 312dd3f57f
3 changed files with 49 additions and 43 deletions

View file

@ -1792,7 +1792,7 @@ void P_CheckTimeLimit(void)
//Optional tie-breaker for Match/CTF //Optional tie-breaker for Match/CTF
else*/ else*/
#define TESTOVERTIMEINFREEPLAY //#define TESTOVERTIMEINFREEPLAY
if (cv_overtime.value) if (cv_overtime.value)
{ {
#ifndef TESTOVERTIMEINFREEPLAY #ifndef TESTOVERTIMEINFREEPLAY
@ -1811,6 +1811,8 @@ void P_CheckTimeLimit(void)
thinker_t *th; thinker_t *th;
mobj_t *item = NULL; mobj_t *item = NULL;
P_RespawnBattleBoxes(); // FORCE THESE TO BE RESPAWNED FOR THIS!!!!!!!
// Find us an item box to center on. // Find us an item box to center on.
for (th = thinkercap.next; th != &thinkercap; th = th->next) for (th = thinkercap.next; th != &thinkercap; th = th->next)
{ {

View file

@ -216,6 +216,7 @@ extern tic_t itemrespawntime[ITEMQUESIZE];
extern size_t iquehead, iquetail; extern size_t iquehead, iquetail;
extern consvar_t cv_gravity/*, cv_viewheight*/; extern consvar_t cv_gravity/*, cv_viewheight*/;
void P_RespawnBattleBoxes(void);
void P_RespawnSpecials(void); void P_RespawnSpecials(void);
mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type);

View file

@ -9544,10 +9544,7 @@ for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) s
if (G_BattleGametype() && (mobj->threshold != 70)) if (G_BattleGametype() && (mobj->threshold != 70))
{ {
if (mobj->threshold != 69) if (mobj->threshold != 69)
{
mobj->fuse = cv_itemrespawntime.value*TICRATE + 2;
break; break;
}
} }
else else
{ {
@ -10900,6 +10897,50 @@ void P_PrecipitationEffects(void)
} }
} }
void P_RespawnBattleBoxes(void)
{
thinker_t *th;
if (!G_BattleGametype())
return;
for (th = thinkercap.next; th != &thinkercap; th = th->next)
{
mobj_t *box;
mobj_t *newmobj;
if (th->function.acp1 != (actionf_p1)P_MobjThinker) // not a mobj
continue;
box = (mobj_t *)th;
if (box->type != MT_RANDOMITEM || box->threshold != 68 || box->fuse) // only popped items
continue;
// Respawn from mapthing if you have one!
if (box->spawnpoint)
{
P_SpawnMapThing(box->spawnpoint);
newmobj = box->spawnpoint->mobj; // this is set to the new mobj in P_SpawnMapThing
P_SpawnMobj(box->spawnpoint->mobj->x, box->spawnpoint->mobj->y, box->spawnpoint->mobj->z, MT_EXPLODE); // poof into existance
}
else
{
newmobj = P_SpawnMobj(box->x, box->y, box->z, box->type);
P_SpawnMobj(newmobj->x, newmobj->y, newmobj->z, MT_EXPLODE); // poof into existance
}
// Transfer flags2 (strongbox, objectflip)
newmobj->flags2 = box->flags2;
P_RemoveMobj(box); // make sure they disappear
numgotboxes--; // you've restored a box, remove it from the count
//continue; -- irrelevant?
}
if (numgotboxes < 0)
numgotboxes = 0;
}
// //
// P_RespawnSpecials // P_RespawnSpecials
// //
@ -10911,45 +10952,7 @@ void P_RespawnSpecials(void)
mapthing_t *mthing = NULL; mapthing_t *mthing = NULL;
if (G_BattleGametype() && numgotboxes >= (4*nummapboxes/5)) // Battle Mode respawns all boxes in a different way if (G_BattleGametype() && numgotboxes >= (4*nummapboxes/5)) // Battle Mode respawns all boxes in a different way
{ P_RespawnBattleBoxes();
thinker_t *th;
for (th = thinkercap.next; th != &thinkercap; th = th->next)
{
mobj_t *box;
mobj_t *newmobj;
if (th->function.acp1 != (actionf_p1)P_MobjThinker) // not a mobj
continue;
box = (mobj_t *)th;
if (box->type != MT_RANDOMITEM || box->threshold != 68 || box->fuse) // only popped items
continue;
// Respawn from mapthing if you have one!
if (box->spawnpoint)
{
P_SpawnMapThing(box->spawnpoint);
newmobj = box->spawnpoint->mobj; // this is set to the new mobj in P_SpawnMapThing
P_SpawnMobj(box->spawnpoint->mobj->x, box->spawnpoint->mobj->y, box->spawnpoint->mobj->z, MT_EXPLODE); // poof into existance
}
else
{
newmobj = P_SpawnMobj(box->x, box->y, box->z, box->type);
P_SpawnMobj(newmobj->x, newmobj->y, newmobj->z, MT_EXPLODE); // poof into existance
}
// Transfer flags2 (strongbox, objectflip)
newmobj->flags2 = box->flags2;
P_RemoveMobj(box); // make sure they disappear
numgotboxes--; // you've restored a box, remove it from the count
//continue; -- irrelevant?
}
if (numgotboxes < 0)
numgotboxes = 0;
}
// only respawn items when cv_itemrespawn is on // only respawn items when cv_itemrespawn is on
if (!cv_itemrespawn.value) if (!cv_itemrespawn.value)