diff --git a/src/deh_soc.c b/src/deh_soc.c index c3c67bcac..0d329a05b 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -2844,6 +2844,13 @@ static void readcondition(UINT16 set, UINT32 id, char *word2) return; } } + else if (fastcmp(params[0], "HASFOLLOWER")) + { + PARAMCHECK(1); + ty = UCRP_HASFOLLOWER; + stringvar = Z_StrDup(params[1]); + re = -1; + } else if (fastcmp(params[0], "ISDIFFICULTY")) { //PARAMCHECK(1); diff --git a/src/m_cond.c b/src/m_cond.c index ccdefe978..e2dadb6d2 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -1103,7 +1103,7 @@ void M_FinaliseGameData(void) void M_UpdateConditionSetsPending(void) { - UINT32 i, j; + UINT32 i, j, k; conditionset_t *c; condition_t *cn; @@ -1139,6 +1139,29 @@ void M_UpdateConditionSetsPending(void) break; } + case UCRP_HASFOLLOWER: + { + // match deh_soc readfollower() + for (k = 0; cn->stringvar[k]; k++) + { + if (cn->stringvar[k] == '_') + cn->stringvar[k] = ' '; + } + + cn->requirement = K_FollowerAvailable(cn->stringvar); + + if (cn->requirement < 0) + { + CONS_Alert(CONS_WARNING, "UC TYPE %u: Invalid character %s for condition ID %d", cn->type, cn->stringvar, cn->id+1); + continue; + } + + Z_Free(cn->stringvar); + cn->stringvar = NULL; + + break; + } + case UCRP_WETPLAYER: { if (cn->extrainfo1) @@ -1460,6 +1483,8 @@ boolean M_CheckCondition(condition_t *cn, player_t *player) skins[player->skin].kartweight, skins[player->skin].flags ) == (unsigned)cn->requirement); + case UCRP_HASFOLLOWER: + return (cn->requirement != -1 && player->followerskin == cn->requirement); case UCRP_ISDIFFICULTY: if (grandprixinfo.gp == false) return (gamespeed >= cn->requirement); @@ -2272,6 +2297,13 @@ static const char *M_GetConditionString(condition_t *cn) return va("as %s", work); case UCRP_ISENGINECLASS: return va("with engine class %c", 'A' + cn->requirement); + case UCRP_HASFOLLOWER: + if (cn->requirement < 0 || !followers[cn->requirement].name[0]) + return va("INVALID FOLLOWER CONDITION \"%d:%d\"", cn->type, cn->requirement); + work = (K_FollowerUsable(cn->requirement)) + ? followers[cn->requirement].name + : "???"; + return va("with %s in tow", work); case UCRP_ISDIFFICULTY: { const char *speedtext = ""; diff --git a/src/m_cond.h b/src/m_cond.h index 24e26895c..a13bd014c 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -87,6 +87,7 @@ typedef enum UCRP_ISCHARACTER, // character == [skin] UCRP_ISENGINECLASS, // engine class [class] + UCRP_HASFOLLOWER, // follower == [followerskin] UCRP_ISDIFFICULTY, // difficulty >= [difficulty] UCRP_PODIUMCUP, // cup == [cup] [optional: >= grade OR place]