From 35ca8e6191cdb79047249af019fa11d7e7de0a5e Mon Sep 17 00:00:00 2001 From: toaster Date: Tue, 17 Oct 2023 22:53:40 +0100 Subject: [PATCH] UCRP_SPEEDOMETER Provide a percentage between 100 and 999 inclusive. Reach that speed on the speedometer at any point during the race to achieve the condition. --- src/d_player.h | 2 ++ src/deh_soc.c | 12 ++++++++++++ src/m_cond.c | 10 ++++++++++ src/m_cond.h | 6 ++++-- src/p_user.c | 13 +++++++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index cde2c9b80..c01f82241 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -422,6 +422,8 @@ struct roundconditions_t targetdamaging_t targetdamaging; UINT8 gachabom_miser; + fixed_t maxspeed; + mobjeflag_t wet_player; // 32 triggers, one bit each, for map execution diff --git a/src/deh_soc.c b/src/deh_soc.c index 61752866b..909d7f7ba 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -2949,6 +2949,18 @@ static void readcondition(UINT16 set, UINT32 id, char *word2) return; } } + else if (fastcmp(params[0], "SPEEDOMETER")) + { + PARAMCHECK(1); + ty = UCRP_SPEEDOMETER; + re = get_number(params[1]); + + if (re < 100 || re > 999) + { + deh_warning("Speed percent %d out of range (100 - 999) for condition ID %d", re, id+1); + return; + } + } else if (fastcmp(params[0], "TRIGGER")) { PARAMCHECK(1); diff --git a/src/m_cond.c b/src/m_cond.c index a7e8e3c2d..36baab845 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -1599,6 +1599,9 @@ boolean M_CheckCondition(condition_t *cn, player_t *player) case UCRP_RINGSEXACT: return (player->hudrings == cn->requirement); + case UCRP_SPEEDOMETER: + return (player->roundconditions.maxspeed >= cn->requirement); + case UCRP_TRIGGER: // requires map trigger set return !!(player->roundconditions.unlocktriggers & (1 << cn->requirement)); @@ -2369,6 +2372,13 @@ static const char *M_GetConditionString(condition_t *cn) case UCRP_RINGSEXACT: return va("with exactly %d Rings", cn->requirement); + case UCRP_SPEEDOMETER: + return va("reach %s%u%% on the speedometer", + (cn->requirement == 999) + ? "" : "at least", + cn->requirement + ); + case UCRP_TRIGGER: return "do something special"; diff --git a/src/m_cond.h b/src/m_cond.h index 5914e07f5..1db82c79d 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -108,8 +108,10 @@ typedef enum UCRP_FINISHTIMEEXACT, // Finish == [time, tics] UCRP_FINISHTIMELEFT, // Finish with at least [time, tics] to spare - UCRP_RINGS, // Finish >= [rings] - UCRP_RINGSEXACT, // Finish == [rings] + UCRP_RINGS, // >= [rings] + UCRP_RINGSEXACT, // == [rings] + + UCRP_SPEEDOMETER, // >= [percentage] UCRP_TRIGGER, // Map execution trigger [id] diff --git a/src/p_user.c b/src/p_user.c index 30266cb02..934614651 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1920,6 +1920,19 @@ static void P_3dMovement(player_t *player) // Calculates player's speed based on distance-of-a-line formula player->speed = R_PointToDist2(0, 0, player->rmomx, player->rmomy); + const fixed_t topspeed = K_GetKartSpeed(player, false, true); + + if (player->speed > topspeed) + { + const fixed_t convSpeed = (player->speed * 100) / topspeed; + + if (convSpeed > player->roundconditions.maxspeed) + { + player->roundconditions.maxspeed = convSpeed; + //player->roundconditions.checkthisframe = true; -- no, safe to leave until lapchange at worst + } + } + // Monster Iestyn - 04-11-13 // Quadrants are stupid, excessive and broken, let's do this a much simpler way! // Get delta angle from rmom angle and player angle first