K_GetPossibleSpecialTarget()

* Standardises conditions under which the UFO Catcher can be "targeted" (Jawz, SPB, tether)
* Makes SPBs explode a little ahead of driving distance if UFO Catcher is no longer targetable
This commit is contained in:
toaster 2022-12-28 23:31:46 +00:00
parent c992438e3c
commit e45282bdff
5 changed files with 53 additions and 25 deletions

View file

@ -1339,9 +1339,7 @@ static boolean K_TryDraft(player_t *player, mobj_t *dest, fixed_t minDist, fixed
*/
static void K_UpdateDraft(player_t *player)
{
const boolean addUfo = ((specialstageinfo.valid == true)
&& (specialstageinfo.ufo != NULL && P_MobjWasRemoved(specialstageinfo.ufo) == false)
&& specialstageinfo.ufo->health > 1);
mobj_t *addUfo = K_GetPossibleSpecialTarget();
fixed_t topspd = K_GetKartSpeed(player, false, false);
fixed_t draftdistance;
@ -1381,10 +1379,10 @@ static void K_UpdateDraft(player_t *player)
// Not enough speed to draft.
if (player->speed >= 20 * player->mo->scale)
{
if (addUfo == true)
if (addUfo != NULL)
{
// Tether off of the UFO!
if (K_TryDraft(player, specialstageinfo.ufo, minDist, draftdistance, leniency) == true)
if (K_TryDraft(player, addUfo, minDist, draftdistance, leniency) == true)
{
return; // Finished doing our draft.
}
@ -1438,11 +1436,11 @@ static void K_UpdateDraft(player_t *player)
fixed_t dist = P_AproxDistance(P_AproxDistance(victim->mo->x - player->mo->x, victim->mo->y - player->mo->y), victim->mo->z - player->mo->z);
K_DrawDraftCombiring(player, victim->mo, dist, draftdistance, true);
}
else if (addUfo == true)
else if (addUfo != NULL)
{
// kind of a hack to not have to mess with how lastdraft works
fixed_t dist = P_AproxDistance(P_AproxDistance(specialstageinfo.ufo->x - player->mo->x, specialstageinfo.ufo->y - player->mo->y), specialstageinfo.ufo->z - player->mo->z);
K_DrawDraftCombiring(player, specialstageinfo.ufo, dist, draftdistance, true);
fixed_t dist = P_AproxDistance(P_AproxDistance(addUfo->x - player->mo->x, addUfo->y - player->mo->y), addUfo->z - player->mo->z);
K_DrawDraftCombiring(player, addUfo, dist, draftdistance, true);
}
}
else // Remove draft speed boost.
@ -6831,8 +6829,8 @@ mobj_t *K_FindJawzTarget(mobj_t *actor, player_t *source, angle_t range)
if (specialstageinfo.valid == true)
{
// Always target the UFO.
return specialstageinfo.ufo;
// Always target the UFO (but not the emerald)
return K_GetPossibleSpecialTarget();
}
for (i = 0; i < MAXPLAYERS; i++)
@ -8066,10 +8064,11 @@ void K_KartPlayerAfterThink(player_t *player)
mobj_t *ret = NULL;
if (specialstageinfo.valid == true && lastTargID == MAXPLAYERS)
if (specialstageinfo.valid == true
&& lastTargID == MAXPLAYERS)
{
// Aiming at the UFO.
lastTarg = specialstageinfo.ufo;
// Aiming at the UFO (but never the emerald).
lastTarg = K_GetPossibleSpecialTarget();
}
else if ((lastTargID >= 0 && lastTargID <= MAXPLAYERS)
&& playeringame[lastTargID] == true)

View file

@ -1122,9 +1122,7 @@ void K_FillItemRouletteData(const player_t *player, itemroulette_t *const roulet
// Use a special, pre-determined item reel for Time Attack / Free Play / End of Sealed Stars
if (specialstageinfo.valid)
{
if (specialstageinfo.ufo == NULL
|| P_MobjWasRemoved(specialstageinfo.ufo)
|| specialstageinfo.ufo->health == 1)
if (K_GetPossibleSpecialTarget() == NULL)
{
for (i = 0; K_KartItemReelSpecialEnd[i] != KITEM_NONE; i++)
{

View file

@ -121,3 +121,18 @@ void K_TickSpecialStage(void)
K_MoveExitBeam();
}
mobj_t *K_GetPossibleSpecialTarget(void)
{
if (specialstageinfo.valid == false)
return NULL;
if (specialstageinfo.ufo == NULL
|| P_MobjWasRemoved(specialstageinfo.ufo))
return NULL;
if (specialstageinfo.ufo->health <= 1) //UFOEmeraldChase(specialstageinfo.ufo)
return NULL;
return specialstageinfo.ufo;
}

View file

@ -50,5 +50,16 @@ void K_InitSpecialStage(void);
void K_TickSpecialStage(void);
/*--------------------------------------------------
mobj_t *K_GetPossibleSpecialTarget(void)
Gets the global special stage target if valid
(for Jawz, tether, etc)
Return:-
Target or NULL
--------------------------------------------------*/
mobj_t *K_GetPossibleSpecialTarget(void);
#endif

View file

@ -857,6 +857,20 @@ void Obj_SPBThink(mobj_t *spb)
ghost->colorized = true;
}
if (spb_nothink(spb) <= 1)
{
if (specialstageinfo.valid == true)
{
bestRank = 0;
if ((bestMobj = K_GetPossibleSpecialTarget()) == NULL)
{
spb->fuse = TICRATE/3;
spb_nothink(spb) = spb->fuse + 2;
}
}
}
if (spb_nothink(spb) > 0)
{
// Init values, don't think yet.
@ -874,15 +888,6 @@ void Obj_SPBThink(mobj_t *spb)
}
else
{
if (specialstageinfo.valid == true)
{
if (specialstageinfo.ufo != NULL && P_MobjWasRemoved(specialstageinfo.ufo) == false)
{
bestRank = 1;
bestMobj = specialstageinfo.ufo;
}
}
// Find the player with the best rank
for (i = 0; i < MAXPLAYERS; i++)
{