mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-31 05:30:48 +00:00
Merge branch 'levelemblems' into 'master'
Level completion emblems Simple port of something I made for a 2.1 exe mod that Mystic mentioned needed doing on the 2.2 Priorities topic (http://mb.srb2.org/showpost.php?p=790613&postcount=4). Adds emblem type "map", which gives you an emblem upon beating the map it's for. Var sets specific condition flags on top of normal completion; 1 or ME_ALLEMERALDS for all Chaos Emeralds, 2 or ME_ULTIMATE for Ultimate mode, and 4 or ME_PERFECT for Perfect Bonus. These can be combined with each other, but they do not all need to be done in one shot; an Ultimate + Perfect emblem isn't impossible as they can be done in separate runs. (This can easily be toned back down to a single choice/removed entirely if requested; these were added simply because it was easy to implement for modders.) Criticism on the way it's coded and/or how it is implemented is highly encouraged. Test wad is <root>/TehRealSalt/levelemblems.wad, pre-compiled exe is <root>/TehRealSalt/levelemblems.exe. See merge request !74
This commit is contained in:
commit
80195b033e
5 changed files with 63 additions and 3 deletions
|
@ -2277,6 +2277,8 @@ static void reademblemdata(MYFILE *f, INT32 num)
|
||||||
emblemlocations[num-1].type = ET_NGRADE;
|
emblemlocations[num-1].type = ET_NGRADE;
|
||||||
else if (fastcmp(word2, "NTIME"))
|
else if (fastcmp(word2, "NTIME"))
|
||||||
emblemlocations[num-1].type = ET_NTIME;
|
emblemlocations[num-1].type = ET_NTIME;
|
||||||
|
else if (fastcmp(word2, "MAP"))
|
||||||
|
emblemlocations[num-1].type = ET_MAP;
|
||||||
else
|
else
|
||||||
emblemlocations[num-1].type = (UINT8)value;
|
emblemlocations[num-1].type = (UINT8)value;
|
||||||
}
|
}
|
||||||
|
@ -7425,6 +7427,11 @@ struct {
|
||||||
{"SF_NOINTERRUPT",SF_NOINTERRUPT},
|
{"SF_NOINTERRUPT",SF_NOINTERRUPT},
|
||||||
{"SF_X2AWAYSOUND",SF_X2AWAYSOUND},
|
{"SF_X2AWAYSOUND",SF_X2AWAYSOUND},
|
||||||
|
|
||||||
|
// Map emblem var flags
|
||||||
|
{"ME_ALLEMERALDS",ME_ALLEMERALDS},
|
||||||
|
{"ME_ULTIMATE",ME_ULTIMATE},
|
||||||
|
{"ME_PERFECT",ME_PERFECT},
|
||||||
|
|
||||||
#ifdef HAVE_BLUA
|
#ifdef HAVE_BLUA
|
||||||
// p_local.h constants
|
// p_local.h constants
|
||||||
{"FLOATSPEED",FLOATSPEED},
|
{"FLOATSPEED",FLOATSPEED},
|
||||||
|
|
38
src/m_cond.c
38
src/m_cond.c
|
@ -929,7 +929,7 @@ UINT8 M_CheckLevelEmblems(void)
|
||||||
// Update Score, Time, Rings emblems
|
// Update Score, Time, Rings emblems
|
||||||
for (i = 0; i < numemblems; ++i)
|
for (i = 0; i < numemblems; ++i)
|
||||||
{
|
{
|
||||||
if (emblemlocations[i].type <= ET_SKIN || emblemlocations[i].collected)
|
if (emblemlocations[i].type <= ET_SKIN || emblemlocations[i].type == ET_MAP || emblemlocations[i].collected)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
levelnum = emblemlocations[i].level;
|
levelnum = emblemlocations[i].level;
|
||||||
|
@ -963,6 +963,42 @@ UINT8 M_CheckLevelEmblems(void)
|
||||||
return somethingUnlocked;
|
return somethingUnlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UINT8 M_CompletionEmblems(void) // Bah! Duplication sucks, but it's for a separate print when awarding emblems and it's sorta different enough.
|
||||||
|
{
|
||||||
|
INT32 i;
|
||||||
|
INT32 embtype;
|
||||||
|
INT16 levelnum;
|
||||||
|
UINT8 res;
|
||||||
|
UINT8 somethingUnlocked = 0;
|
||||||
|
UINT8 flags;
|
||||||
|
|
||||||
|
for (i = 0; i < numemblems; ++i)
|
||||||
|
{
|
||||||
|
if (emblemlocations[i].type != ET_MAP || emblemlocations[i].collected)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
levelnum = emblemlocations[i].level;
|
||||||
|
embtype = emblemlocations[i].var;
|
||||||
|
flags = MV_BEATEN;
|
||||||
|
|
||||||
|
if (embtype & ME_ALLEMERALDS)
|
||||||
|
flags |= MV_ALLEMERALDS;
|
||||||
|
|
||||||
|
if (embtype & ME_ULTIMATE)
|
||||||
|
flags |= MV_ULTIMATE;
|
||||||
|
|
||||||
|
if (embtype & ME_PERFECT)
|
||||||
|
flags |= MV_PERFECT;
|
||||||
|
|
||||||
|
res = ((mapvisited[levelnum - 1] & flags) == flags);
|
||||||
|
|
||||||
|
emblemlocations[i].collected = res;
|
||||||
|
if (res)
|
||||||
|
++somethingUnlocked;
|
||||||
|
}
|
||||||
|
return somethingUnlocked;
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------
|
// -------------------
|
||||||
// Quick unlock checks
|
// Quick unlock checks
|
||||||
// -------------------
|
// -------------------
|
||||||
|
|
|
@ -73,6 +73,12 @@ typedef struct
|
||||||
#define ET_RINGS 4
|
#define ET_RINGS 4
|
||||||
#define ET_NGRADE 5
|
#define ET_NGRADE 5
|
||||||
#define ET_NTIME 6
|
#define ET_NTIME 6
|
||||||
|
#define ET_MAP 7
|
||||||
|
|
||||||
|
// Map emblem flags
|
||||||
|
#define ME_ALLEMERALDS 1
|
||||||
|
#define ME_ULTIMATE 2
|
||||||
|
#define ME_PERFECT 4
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -153,6 +159,7 @@ void M_CheckUnlockConditions(void);
|
||||||
UINT8 M_UpdateUnlockablesAndExtraEmblems(void);
|
UINT8 M_UpdateUnlockablesAndExtraEmblems(void);
|
||||||
void M_SilentUpdateUnlockablesAndEmblems(void);
|
void M_SilentUpdateUnlockablesAndEmblems(void);
|
||||||
UINT8 M_CheckLevelEmblems(void);
|
UINT8 M_CheckLevelEmblems(void);
|
||||||
|
UINT8 M_CompletionEmblems(void);
|
||||||
|
|
||||||
// Checking unlockable status
|
// Checking unlockable status
|
||||||
UINT8 M_AnySecretUnlocked(void);
|
UINT8 M_AnySecretUnlocked(void);
|
||||||
|
|
|
@ -2940,6 +2940,8 @@ static void M_DrawMapEmblems(INT32 mapnum, INT32 x, INT32 y)
|
||||||
curtype = 1; break;
|
curtype = 1; break;
|
||||||
case ET_NGRADE: case ET_NTIME:
|
case ET_NGRADE: case ET_NTIME:
|
||||||
curtype = 2; break;
|
curtype = 2; break;
|
||||||
|
case ET_MAP:
|
||||||
|
curtype = 3; break;
|
||||||
default:
|
default:
|
||||||
curtype = 0; break;
|
curtype = 0; break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -912,6 +912,7 @@ static void Y_UpdateRecordReplays(void)
|
||||||
void Y_StartIntermission(void)
|
void Y_StartIntermission(void)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
UINT8 completionEmblems = M_CompletionEmblems();
|
||||||
|
|
||||||
intertic = -1;
|
intertic = -1;
|
||||||
|
|
||||||
|
@ -1007,6 +1008,9 @@ void Y_StartIntermission(void)
|
||||||
|
|
||||||
if (modeattacking == ATTACKING_RECORD)
|
if (modeattacking == ATTACKING_RECORD)
|
||||||
Y_UpdateRecordReplays();
|
Y_UpdateRecordReplays();
|
||||||
|
|
||||||
|
if (completionEmblems)
|
||||||
|
CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for level completion.\n"), (UINT16)completionEmblems, completionEmblems > 1 ? "s" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
|
@ -1106,6 +1110,10 @@ void Y_StartIntermission(void)
|
||||||
{
|
{
|
||||||
if (!stagefailed)
|
if (!stagefailed)
|
||||||
mapvisited[gamemap-1] |= MV_BEATEN;
|
mapvisited[gamemap-1] |= MV_BEATEN;
|
||||||
|
|
||||||
|
// all emeralds/ultimate/perfect emblems won't be possible in ss, oh well?
|
||||||
|
if (completionEmblems)
|
||||||
|
CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for level completion.\n"), (UINT16)completionEmblems, completionEmblems > 1 ? "s" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// give out ring bonuses
|
// give out ring bonuses
|
||||||
|
|
Loading…
Reference in a new issue