SPB Capsule improvements

- Destroy all SPB Capsules in the stage when an SPB becomes relevant
    - When an SPB is put in a player's roulette
    - When an SPB is thrown
        - Automatically happens when SPB Capsule is touched
- Don't respawn a popped SPB Capsule while an SPB is out
This commit is contained in:
toaster 2023-12-08 22:24:38 +00:00
parent ee0eff89b4
commit c34b5f6034
5 changed files with 44 additions and 1 deletions

View file

@ -5060,7 +5060,7 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I
Obj_JawzThrown(th, finalspeed, dir);
break;
case MT_SPB:
th->movefactor = finalspeed;
Obj_SPBThrown(th, finalspeed);
break;
case MT_BUBBLESHIELDTRAP:
P_SetScale(th, ((5*th->destscale)>>2)*4);

View file

@ -41,9 +41,11 @@ void Obj_ItemDebrisThink(mobj_t *debris);
fixed_t Obj_ItemDebrisBounce(mobj_t *debris, fixed_t momz);
/* SPB */
void Obj_SPBThrown(mobj_t *spb, fixed_t finalspeed);
void Obj_SPBThink(mobj_t *spb);
void Obj_SPBExplode(mobj_t *spb);
void Obj_SPBTouch(mobj_t *spb, mobj_t *toucher);
void Obj_SPBEradicateCapsules(void);
/* SPB Juicebox Rings */
void Obj_MantaRingThink(mobj_t *manta);

View file

@ -1577,6 +1577,9 @@ static void K_KartGetItemResult(player_t *const player, kartitems_t getitem)
player->itemtype = K_ItemResultToType(getitem);
player->itemamount = K_ItemResultToAmount(getitem);
if (player->itemtype == KITEM_SPB)
Obj_SPBEradicateCapsules();
}
/*--------------------------------------------------

View file

@ -74,6 +74,36 @@ enum
#define spb_owner(o) ((o)->target)
#define spb_chase(o) ((o)->tracer)
void Obj_SPBEradicateCapsules(void)
{
thinker_t *think;
mobj_t *mo;
// Expensive operation :D?
for (think = thlist[THINK_MOBJ].next; think != &thlist[THINK_MOBJ]; think = think->next)
{
if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
continue;
mo = (mobj_t *)think;
if (mo->type != MT_ITEMCAPSULE)
continue;
if (!mo->health || mo->fuse)
continue;
P_KillMobj(mo, NULL, NULL, DMG_NORMAL);
}
}
void Obj_SPBThrown(mobj_t *spb, fixed_t finalspeed)
{
spb_speed(spb) = finalspeed;
Obj_SPBEradicateCapsules();
}
static void SPBMantaRings(mobj_t *spb)
{
fixed_t vScale = INT32_MAX;

View file

@ -10435,6 +10435,14 @@ static boolean P_FuseThink(mobj_t *mobj)
return false;
case MT_ITEMCAPSULE:
if (mobj->threshold == KITEM_SPB && K_IsSPBInGame())
{
// SPB is in play. Try again in a short bit.
mobj->fuse += TICRATE/2;
return true;
}
if (mobj->spawnpoint)
P_SpawnMapThing(mobj->spawnpoint);
else