Merge branch 'capsule-jank' into 'master'

Improve Item Capsule spawning

See merge request KartKrew/Kart!1281
This commit is contained in:
Sal 2023-06-14 11:14:32 +00:00
commit 37efa6782a
4 changed files with 75 additions and 20 deletions

View file

@ -104,6 +104,60 @@ void K_TimerReset(void)
g_pointlimit = 0;
}
static void K_SpawnItemCapsules(void)
{
mapthing_t *mt = mapthings;
size_t i = SIZE_MAX;
for (i = 0; i < nummapthings; i++, mt++)
{
boolean isRingCapsule = false;
INT32 modeFlags = 0;
if (mt->type != mobjinfo[MT_ITEMCAPSULE].doomednum)
{
continue;
}
isRingCapsule = (mt->args[0] < 1 || mt->args[0] == KITEM_SUPERRING || mt->args[0] >= NUMKARTITEMS);
if (isRingCapsule == true && ((gametyperules & GTR_SPHERES) || (modeattacking & ATTACKING_SPB)))
{
// don't spawn ring capsules in ringless gametypes
continue;
}
modeFlags = mt->args[3];
if (modeFlags == TMICM_DEFAULT)
{
if (isRingCapsule == true)
{
modeFlags = TMICM_MULTIPLAYER|TMICM_TIMEATTACK;
}
else
{
modeFlags = TMICM_MULTIPLAYER;
}
}
if (K_CapsuleTimeAttackRules() == true)
{
if ((modeFlags & TMICM_TIMEATTACK) == 0)
{
continue;
}
}
else
{
if ((modeFlags & TMICM_MULTIPLAYER) == 0)
{
continue;
}
}
P_SpawnMapThing(mt);
}
}
void K_TimerInit(void)
{
UINT8 i;
@ -199,6 +253,7 @@ void K_TimerInit(void)
}
}
K_SpawnItemCapsules();
K_BattleInit(domodeattack);
timelimitintics = K_TimeLimitForGametype();

View file

@ -4426,7 +4426,7 @@ static void P_RefreshItemCapsuleParts(mobj_t *mobj)
color = SKINCOLOR_GOLD;
newRenderFlags |= RF_SEMIBRIGHT;
}
else if (mobj->args[2] & TMICF_INVERTTIMEATTACK)
else if (mobj->args[3] & TMICM_TIMEATTACK)
color = SKINCOLOR_SAPPHIRE;
else if (itemType == KITEM_SPB)
color = SKINCOLOR_JET;
@ -12180,21 +12180,6 @@ static boolean P_AllowMobjSpawn(mapthing_t* mthing, mobjtype_t i)
{
switch (i)
{
case MT_ITEMCAPSULE:
{
boolean isRingCapsule = (mthing->args[0] < 1 || mthing->args[0] == KITEM_SUPERRING || mthing->args[0] >= NUMKARTITEMS);
// don't spawn ring capsules in GTR_SPHERES gametypes
if (isRingCapsule && ((gametyperules & GTR_SPHERES) || (modeattacking & ATTACKING_SPB)))
return false;
// in record attack, only spawn ring capsules
// (behavior can be inverted with the Extra flag, i.e. item capsule spawns and ring capsule does not)
if (K_CapsuleTimeAttackRules() == true
&& (!(mthing->args[2] & TMICF_INVERTTIMEATTACK) == !isRingCapsule))
return false;
}
break;
case MT_RING:
if (modeattacking & ATTACKING_SPB)
return false;

View file

@ -758,8 +758,11 @@ static void P_SpawnMapThings(boolean spawnemblems)
continue; // These were already spawned
}
if (mt->type == mobjinfo[MT_BATTLECAPSULE].doomednum)
continue; // This will spawn later
if (mt->type == mobjinfo[MT_BATTLECAPSULE].doomednum
|| mt->type == mobjinfo[MT_ITEMCAPSULE].doomednum)
{
continue; // These will spawn later
}
if (!spawnemblems && mt->type == mobjinfo[MT_EMBLEM].doomednum)
continue;
@ -7081,7 +7084,12 @@ static void P_ConvertBinaryThingTypes(void)
if (mapthings[i].options & MTF_EXTRA)
{
mapthings[i].args[2] |= TMICF_INVERTTIMEATTACK;
// was advertised as an "invert time attack" flag, actually was an "all gamemodes" flag
mapthings[i].args[3] = TMICM_MULTIPLAYER|TMICM_TIMEATTACK;
}
else
{
mapthings[i].args[3] = TMICM_DEFAULT;
}
if (mapthings[i].options & MTF_AMBUSH)

View file

@ -143,10 +143,17 @@ typedef enum
typedef enum
{
TMICF_INVERTTIMEATTACK = 1,
//TMICF_UNUSED = 1,
TMICF_INVERTSIZE = 1<<1,
} textmapitemcapsuleflags_t;
typedef enum
{
TMICM_DEFAULT = 0, // Time Attack only has rings, multiplayer has everything
TMICM_MULTIPLAYER = 1,
TMICM_TIMEATTACK = 1<<1,
} textmapitemcapsulemodes_t;
typedef enum
{
TMMA_WARN = 1,