Respawn Certain Monitors in Co-op

This commit is contained in:
SMS Alfredo 2024-02-12 05:46:25 +00:00 committed by Logan Aerl Arias
parent bf9904cfc2
commit 2e7fa1990a
2 changed files with 21 additions and 5 deletions

View file

@ -2530,8 +2530,14 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
{
P_SetTarget(&target->target, source);
source->player->numboxes++;
if (cv_itemrespawn.value && gametype != GT_COOP && (modifiedgame || netgame || multiplayer))
target->fuse = cv_itemrespawntime.value*TICRATE + 2; // Random box generation
// Set respawn
if (!(target->flags2 & MF2_DONTRESPAWN))
{
if (!(netgame || multiplayer))
target->fuse = atoi(cv_itemrespawntime.defaultvalue)*TICRATE + 2;
else if (cv_itemrespawn.value)
target->fuse = cv_itemrespawntime.value*TICRATE + 2;
}
}
// Award Score Tails

View file

@ -10063,9 +10063,10 @@ static void P_MonitorFuseThink(mobj_t *mobj)
{
mobj_t *newmobj;
// Special case for ALL monitors.
// Special case for ALL monitors outside of co-op.
// If a box's speed is nonzero, it's allowed to respawn as a WRM/SRM.
if (mobj->info->speed != 0 && (mobj->flags2 & (MF2_AMBUSH|MF2_STRONGBOX)))
if (!G_CoopGametype() && mobj->info->speed != 0
&& (mobj->flags2 & (MF2_AMBUSH|MF2_STRONGBOX)))
{
mobjtype_t spawnchance[64];
INT32 numchoices = 0, i = 0;
@ -10855,11 +10856,20 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type, ...)
// Set shadowscale here, before spawn hook so that Lua can change it
mobj->shadowscale = P_DefaultMobjShadowScale(mobj);
// A monitor can't respawn if we're not in multiplayer,
// or if we're in co-op and it's score or a 1up
if (mobj->flags & MF_MONITOR && (!(netgame || multiplayer)
|| (G_CoopGametype()
&& (mobj->type == MT_1UP_BOX
|| mobj->type == MT_SCORE1K_BOX
|| mobj->type == MT_SCORE10K_BOX)
)))
mobj->flags2 |= MF2_DONTRESPAWN;
if (!(mobj->flags & MF_NOTHINK))
P_AddThinker(THINK_MOBJ, &mobj->thinker);
if (type == MT_PLAYER)
{
// when spawning MT_PLAYER, set mobj->player before calling MobjSpawn hook to prevent P_RemoveMobj from succeeding on player mobj.