Fix oddities with duel items not always spawning

This commit is contained in:
Sally Coolatta 2022-10-01 22:58:58 -04:00
parent bf6439731c
commit 7b7cbbbf26
3 changed files with 64 additions and 16 deletions

View file

@ -49,10 +49,53 @@
// battlewanted is an array of the WANTED player nums, -1 for no player in that slot
// mapreset is set when enough players fill an empty server
boolean K_IsDuelItem(mobjtype_t type)
{
switch (type)
{
case MT_DUELBOMB:
case MT_BANANA:
case MT_EGGMANITEM:
case MT_SSMINE:
case MT_LANDMINE:
case MT_HYUDORO_CENTER:
case MT_DROPTARGET:
case MT_POGOSPRING:
return true;
default:
return false;
}
}
boolean K_DuelItemAlwaysSpawns(mapthing_t *mt)
{
return (mt->options & MTF_EXTRA);
}
static void K_SpawnDuelOnlyItems(void)
{
mapthing_t *mt = NULL;
size_t i;
mt = mapthings;
for (i = 0; i < nummapthings; i++, mt++)
{
mobjtype_t type = P_GetMobjtype(mt->type);
if (K_IsDuelItem(type) == true
&& K_DuelItemAlwaysSpawns(mt) == false)
{
P_SpawnMapThing(mt);
}
}
}
void K_TimerReset(void)
{
starttime = introtime = 3;
numbulbs = 1;
inDuel = false;
}
void K_TimerInit(void)
@ -109,6 +152,12 @@ void K_TimerInit(void)
// NOW you can try to spawn in the Battle capsules, if there's not enough players for a match
K_BattleInit();
if (inDuel == true)
{
K_SpawnDuelOnlyItems();
}
//CONS_Printf("numbulbs set to %d (%d players, %d spectators) on tic %d\n", numbulbs, numPlayers, numspec, leveltime);
}

View file

@ -38,6 +38,9 @@ angle_t K_ReflectAngle(angle_t angle, angle_t against, fixed_t maxspeed, fixed_t
void K_RegisterKartStuff(void);
boolean K_IsDuelItem(mobjtype_t type);
boolean K_DuelItemAlwaysSpawns(mapthing_t *mt);
void K_TimerReset(void);
void K_TimerInit(void);
UINT32 K_GetPlayerDontDrawFlag(player_t *player);

View file

@ -11755,30 +11755,26 @@ static boolean P_AllowMobjSpawn(mapthing_t* mthing, mobjtype_t i)
return false;
}
break;
case MT_DUELBOMB:
case MT_BANANA:
case MT_EGGMANITEM:
case MT_SSMINE:
case MT_LANDMINE:
case MT_HYUDORO_CENTER:
case MT_DROPTARGET:
case MT_POGOSPRING:
{
// Duel objects.
// Normally only spawn when placed by the map in Duels,
// but can be forced to always spawn with the Extra flag.
if (inDuel == false && !(mthing->options & MTF_EXTRA))
return false;
}
break;
default:
break;
}
if (inDuel == false)
{
if (K_IsDuelItem(i) == true
&& K_DuelItemAlwaysSpawns(mthing) == false)
{
// Only spawns in Duels.
return false;
}
}
// No bosses outside of a combat situation.
// (just in case we want boss arenas to do double duty as battle maps)
if (!bossinfo.boss && (mobjinfo[i].flags & MF_BOSS))
{
return false;
}
if (metalrecording) // Metal Sonic can't use these things.
{