Add UC_CHARACTERWINS

Just in case I don't get to do a major pass on adding a ton of extra unlockable conditions later, this is an easy, quick add featuring a stat gamedata and the statistics menu has been tracking for a while.
This commit is contained in:
toaster 2023-08-23 18:58:10 +01:00
parent b9a6f7362b
commit 595b3d67d5
3 changed files with 33 additions and 17 deletions

View file

@ -2542,6 +2542,14 @@ static void readcondition(UINT16 set, UINT32 id, char *word2)
return;
}
}
else if (fastcmp(params[0], "CHARACTERWINS"))
{
PARAMCHECK(2);
ty = UC_CHARACTERWINS;
stringvar = Z_StrDup(params[1]);
re = -1;
x1 = atoi(params[2]);
}
else if ((offset=0) || fastcmp(params[0], "ALLCHAOS")
|| (++offset && fastcmp(params[0], "ALLSUPER"))
|| (++offset && fastcmp(params[0], "ALLEMERALDS")))
@ -2662,22 +2670,8 @@ static void readcondition(UINT16 set, UINT32 id, char *word2)
{
PARAMCHECK(1);
ty = UCRP_ISCHARACTER;
#if 0
{
re = R_SkinAvailable(params[1]);
if (re < 0)
{
deh_warning("Invalid character %s for condition ID %d", params[1], id+1);
return;
}
}
#else
{
stringvar = Z_StrDup(params[1]);
re = -1;
}
#endif
stringvar = Z_StrDup(params[1]);
re = -1;
}
else if (fastcmp(params[0], "ISENGINECLASS"))
{

View file

@ -819,13 +819,14 @@ void M_UpdateConditionSetsPending(void)
switch (cn->type)
{
case UC_CHARACTERWINS:
case UCRP_ISCHARACTER:
{
cn->requirement = R_SkinAvailable(cn->stringvar);
if (cn->requirement < 0)
{
CONS_Alert(CONS_WARNING, "UCRP_ISCHARACTER: Invalid character %s for condition ID %d", cn->stringvar, cn->id+1);
CONS_Alert(CONS_WARNING, "UC TYPE %u: Invalid character %s for condition ID %d", cn->type, cn->stringvar, cn->id+1);
continue;
}
@ -981,6 +982,12 @@ boolean M_CheckCondition(condition_t *cn, player_t *player)
case UC_MAPTIME: // Requires time on map <= x
return (G_GetBestTime(cn->extrainfo1) <= (unsigned)cn->requirement);
case UC_CHARACTERWINS:
if (cn->requirement < 0)
return false;
return (skins[cn->requirement].records.wins >= (UINT32)cn->extrainfo1);
case UC_ALLCHAOS:
case UC_ALLSUPER:
case UC_ALLEMERALDS:
@ -1353,6 +1360,19 @@ static const char *M_GetConditionString(condition_t *cn)
return work;
}
case UC_CHARACTERWINS:
{
if (cn->requirement < 0 || !skins[cn->requirement].realname[0])
return va("INVALID CHAR CONDITION \"%d:%d:%d\"", cn->type, cn->requirement, cn->extrainfo1);
work = (R_SkinUsable(-1, cn->requirement, false))
? skins[cn->requirement].realname
: "???";
return va("win %d Round%s as %s",
cn->extrainfo1,
cn->extrainfo1 == 1 ? "" : "s",
work);
}
case UC_ALLCHAOS:
case UC_ALLSUPER:
case UC_ALLEMERALDS:

View file

@ -41,6 +41,8 @@ typedef enum
UC_MAPSPBATTACK, // MAPSPBATTACK [map]
UC_MAPTIME, // MAPTIME [map] [time to beat, tics]
UC_CHARACTERWINS, // CHARACTERWINS [character] [x rounds]
UC_ALLCHAOS, // ALLCHAOS [minimum difficulty]
UC_ALLSUPER, // ALLSUPER [minimum difficulty]
UC_ALLEMERALDS, // ALLEMERALDS [minimum difficulty]