Items respawn in Battle properly again

and in a slightly less wasteful way.
This commit is contained in:
TehRealSalt 2018-03-27 17:53:47 -04:00
parent e16bf1cf75
commit acc9abca55
2 changed files with 34 additions and 100 deletions

View file

@ -211,7 +211,6 @@ extern size_t iquehead, iquetail;
extern consvar_t cv_gravity, cv_viewheight;
void P_RespawnSpecials(void);
void P_RespawnBattleSpecials(void);
mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type);

View file

@ -8275,12 +8275,9 @@ for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) s
P_RemoveMobj(mobj); // make sure they disappear
return;
case MT_RANDOMITEM:
if (G_BattleGametype() && numgotboxes < (4*nummapboxes/5))
{
mobj->fuse = 2;
if (G_BattleGametype())
break;
}
numgotboxes = 0;
// Respawn from mapthing if you have one!
if (mobj->spawnpoint)
{
@ -9371,10 +9368,39 @@ void P_RespawnSpecials(void)
mobj_t *mo = NULL;
mapthing_t *mthing = NULL;
if (G_BattleGametype()) // Battle Mode vers
if (G_BattleGametype() && numgotboxes >= (4*nummapboxes/5)) // Battle Mode respawns all boxes in a different way
{
P_RespawnBattleSpecials();
return;
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
}
else
newmobj = P_SpawnMobj(box->x, box->y, box->z, box->type);
// Transfer flags2 (strongbox, objectflip)
newmobj->flags2 = box->flags2;
P_RemoveMobj(box); // make sure they disappear
continue;
}
numgotboxes = 0;
}
// only respawn items when cv_itemrespawn is on
@ -9468,97 +9494,6 @@ void P_RespawnSpecials(void)
iquetail = (iquetail+1)&(ITEMQUESIZE-1);
}
//
// P_RespawnBattleSpecials
//
void P_RespawnBattleSpecials(void)
{
fixed_t x, y, z;
subsector_t *ss;
mobj_t *mo = NULL;
mapthing_t *mthing = NULL;
// only respawn items when cv_itemrespawn is on
if (!cv_itemrespawn.value)
return;
// Didn't collect enough boxes
if (numgotboxes < (4*nummapboxes/5))
return;
// wait a teeeensy bit after collecting everything
if (leveltime - itemrespawntime[iquehead-1] < (tic_t)cv_itemrespawntime.value*(5*TICRATE))
return;
while (iquehead != iquetail) // respawn EVERYTHING in que!
{
mthing = itemrespawnque[iquetail];
#ifdef PARANOIA
if (!mthing)
I_Error("itemrespawnque[iquetail] is NULL!");
#endif
if (mthing)
{
mobjtype_t i;
x = mthing->x << FRACBITS;
y = mthing->y << FRACBITS;
ss = R_PointInSubsector(x, y);
// find which type to spawn
for (i = 0; i < NUMMOBJTYPES; i++)
if (mthing->type == mobjinfo[i].doomednum)
break;
//CTF rings should continue to respawn as normal rings outside of CTF.
if (gametype != GT_CTF)
{
if (i == MT_REDTEAMRING || i == MT_BLUETEAMRING)
i = MT_RING;
}
if (mthing->options & MTF_OBJECTFLIP)
{
z = (
#ifdef ESLOPE
ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) :
#endif
ss->sector->ceilingheight) - (mthing->options >> ZSHIFT) * FRACUNIT;
if (mthing->options & MTF_AMBUSH
&& (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i)))
z -= 24*FRACUNIT;
z -= mobjinfo[i].height; // Don't forget the height!
}
else
{
z = (
#ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) :
#endif
ss->sector->floorheight) + (mthing->options >> ZSHIFT) * FRACUNIT;
if (mthing->options & MTF_AMBUSH
&& (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i)))
z += 24*FRACUNIT;
}
mo = P_SpawnMobj(x, y, z, i);
mo->spawnpoint = mthing;
mo->angle = ANGLE_45 * (mthing->angle/45);
if (mthing->options & MTF_OBJECTFLIP)
{
mo->eflags |= MFE_VERTICALFLIP;
mo->flags2 |= MF2_OBJECTFLIP;
}
}
// pull it from the que
iquetail = (iquetail+1)&(ITEMQUESIZE-1);
}
numgotboxes = 0;
}
//
// P_SpawnPlayer
// Called when a player is spawned on the level.