Split battlebox respawning into its own function
This commit is contained in:
parent
ef1596caeb
commit
15aded75f9
4 changed files with 53 additions and 41 deletions
|
|
@ -527,3 +527,54 @@ afteritembreaker:
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle respawning the battle boxes.
|
||||
void K_RespawnBattleBoxes(void)
|
||||
{
|
||||
if (!(gametyperules & GTR_BATTLEBOXES))
|
||||
return;
|
||||
|
||||
if (itembreaker)
|
||||
return;
|
||||
|
||||
if (numgotboxes < (4*nummapboxes/5))
|
||||
return;
|
||||
|
||||
thinker_t *th;
|
||||
|
||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
||||
{
|
||||
mobj_t *box;
|
||||
mobj_t *newmobj;
|
||||
|
||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ UINT8 K_NumEmeralds(player_t *player);
|
|||
void K_RunPaperItemSpawners(void);
|
||||
void K_SpawnPlayerBattleBumpers(player_t *p);
|
||||
void K_BattleInit(void);
|
||||
void K_RespawnBattleBoxes(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
|||
41
src/p_mobj.c
41
src/p_mobj.c
|
|
@ -12267,47 +12267,6 @@ void P_RespawnSpecials(void)
|
|||
INT32 time = 30*TICRATE; // Respawn things in empty dedicated servers
|
||||
mapthing_t *mthing = NULL;
|
||||
|
||||
if ((gametyperules & GTR_BATTLEBOXES) && !itembreaker && numgotboxes >= (4*nummapboxes/5)) // Battle Mode respawns all boxes in a different way
|
||||
{
|
||||
thinker_t *th;
|
||||
|
||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
||||
{
|
||||
mobj_t *box;
|
||||
mobj_t *newmobj;
|
||||
|
||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
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;
|
||||
}
|
||||
|
||||
// wait time depends on player count
|
||||
for (p = 0; p < MAXPLAYERS; p++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -889,6 +889,7 @@ void P_Ticker(boolean run)
|
|||
|
||||
P_UpdateSpecials();
|
||||
P_RespawnSpecials();
|
||||
K_RespawnBattleBoxes();
|
||||
|
||||
// Lightning, rain sounds, etc.
|
||||
P_PrecipitationEffects();
|
||||
|
|
|
|||
Loading…
Reference in a new issue