Add special behavior for SPB item capsules

This commit is contained in:
lachablock 2021-06-21 22:39:21 +10:00
parent 6477176c31
commit 05749b9773
5 changed files with 54 additions and 3 deletions

View file

@ -4470,7 +4470,7 @@ static mobj_t *K_FindLastTrailMobj(player_t *player)
return trail; return trail;
} }
static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t mapthing, INT32 defaultDir, INT32 altthrow) mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t mapthing, INT32 defaultDir, INT32 altthrow)
{ {
mobj_t *mo; mobj_t *mo;
INT32 dir; INT32 dir;
@ -9419,4 +9419,36 @@ UINT8 K_GetOrbinautItemFrame(UINT8 count)
return min(count - 1, 3); return min(count - 1, 3);
} }
boolean K_IsSPBInGame(void)
{
UINT8 i;
thinker_t *think;
// is there an SPB chasing anyone?
if (spbplace != -1)
return true;
// do any players have an SPB in their item slot?
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator)
continue;
if (players[i].itemtype == KITEM_SPB)
return true;
}
// spbplace is still -1 until a fired SPB finds a target, so look for an in-map SPB just in case
for (think = thlist[THINK_MOBJ].next; think != &thlist[THINK_MOBJ]; think = think->next)
{
if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
continue;
if (((mobj_t *)think)->type == MT_SPB)
return true;
}
return false;
}
//} //}

View file

@ -74,6 +74,7 @@ void K_SpawnSparkleTrail(mobj_t *mo);
void K_SpawnWipeoutTrail(mobj_t *mo, boolean offroad); void K_SpawnWipeoutTrail(mobj_t *mo, boolean offroad);
void K_SpawnDraftDust(mobj_t *mo); void K_SpawnDraftDust(mobj_t *mo);
void K_DriftDustHandling(mobj_t *spawner); void K_DriftDustHandling(mobj_t *spawner);
mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t mapthing, INT32 defaultDir, INT32 altthrow);
void K_PuntMine(mobj_t *mine, mobj_t *punter); void K_PuntMine(mobj_t *mine, mobj_t *punter);
void K_DoSneaker(player_t *player, INT32 type); void K_DoSneaker(player_t *player, INT32 type);
void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, UINT8 sound); void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, UINT8 sound);
@ -120,6 +121,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground);
void K_CheckSpectateStatus(void); void K_CheckSpectateStatus(void);
UINT8 K_GetInvincibilityItemFrame(void); UINT8 K_GetInvincibilityItemFrame(void);
UINT8 K_GetOrbinautItemFrame(UINT8 count); UINT8 K_GetOrbinautItemFrame(UINT8 count);
boolean K_IsSPBInGame(void);
// sound stuff for lua // sound stuff for lua
void K_PlayAttackTaunt(mobj_t *source); void K_PlayAttackTaunt(mobj_t *source);

View file

@ -14687,6 +14687,8 @@ void P_RefreshItemCapsuleParts(mobj_t *mobj)
} }
else if (mobj->spawnpoint && (mobj->spawnpoint->options & MTF_EXTRA)) else if (mobj->spawnpoint && (mobj->spawnpoint->options & MTF_EXTRA))
color = SKINCOLOR_SAPPHIRE; color = SKINCOLOR_SAPPHIRE;
else if (itemType == KITEM_SPB)
color = SKINCOLOR_JET;
else else
color = SKINCOLOR_NONE; color = SKINCOLOR_NONE;
@ -14743,6 +14745,7 @@ void P_RefreshItemCapsuleParts(mobj_t *mobj)
count = mobj->movecount * 5; count = mobj->movecount * 5;
break; break;
case KITEM_SAD: // never display the number case KITEM_SAD: // never display the number
case KITEM_SPB:
break; break;
default: default:
if (mobj->movecount > 1) if (mobj->movecount > 1)

View file

@ -278,8 +278,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
P_KillMobj(special, toucher, toucher, DMG_NORMAL); P_KillMobj(special, toucher, toucher, DMG_NORMAL);
break; break;
case MT_ITEMCAPSULE: case MT_ITEMCAPSULE:
if (special->threshold != KITEM_SUPERRING && !P_CanPickupItem(player, 1)) if (special->threshold != KITEM_SUPERRING
return; && special->threshold != KITEM_SPB
&& !P_CanPickupItem(player, 1))
return;
if ((gametyperules & GTR_BUMPERS) && player->bumpers <= 0) if ((gametyperules & GTR_BUMPERS) && player->bumpers <= 0)
return; return;
@ -287,6 +289,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (special->scale < special->extravalue1) // don't break it while it's respawning if (special->scale < special->extravalue1) // don't break it while it's respawning
return; return;
if (special->threshold == KITEM_SPB && K_IsSPBInGame()) // don't spawn a second SPB
return;
S_StartSound(toucher, special->info->deathsound); S_StartSound(toucher, special->info->deathsound);
P_KillMobj(special, toucher, toucher, DMG_NORMAL); P_KillMobj(special, toucher, toucher, DMG_NORMAL);
return; return;
@ -1376,6 +1381,13 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
break; break;
} }
// special behavior for SPB capsules
if (target->threshold == KITEM_SPB)
{
K_ThrowKartItem(player, true, MT_SPB, 1, 0);
break;
}
if (target->threshold < 1 || target->threshold >= NUMKARTITEMS) // bruh moment prevention if (target->threshold < 1 || target->threshold >= NUMKARTITEMS) // bruh moment prevention
{ {
player->itemtype = KITEM_SAD; player->itemtype = KITEM_SAD;

View file

@ -9439,6 +9439,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
#if 0 // set to 1 to test capsules with random items, e.g. with objectplace #if 0 // set to 1 to test capsules with random items, e.g. with objectplace
if (P_RandomChance(FRACUNIT/3)) if (P_RandomChance(FRACUNIT/3))
mobj->threshold = KITEM_SUPERRING; mobj->threshold = KITEM_SUPERRING;
else if (P_RandomChance(FRACUNIT/3))
mobj->threshold = KITEM_SPB;
else if (P_RandomChance(FRACUNIT/3)) else if (P_RandomChance(FRACUNIT/3))
mobj->threshold = KITEM_ORBINAUT; mobj->threshold = KITEM_ORBINAUT;
else else