mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-16 17:11:33 +00:00
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 more specific conditions; 1 for all emeralds completion, 2 for Ultimate mode completion, 3 for Perfect Bonus completion. (These can be easily removed 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.
This commit is contained in:
parent
a979b425e0
commit
b418ac0acb
5 changed files with 57 additions and 1 deletions
|
@ -2277,6 +2277,8 @@ static void reademblemdata(MYFILE *f, INT32 num)
|
|||
emblemlocations[num-1].type = ET_NGRADE;
|
||||
else if (fastcmp(word2, "NTIME"))
|
||||
emblemlocations[num-1].type = ET_NTIME;
|
||||
else if (fastcmp(word2, "MAP"))
|
||||
emblemlocations[num-1].type = ET_MAP;
|
||||
else
|
||||
emblemlocations[num-1].type = (UINT8)value;
|
||||
}
|
||||
|
|
41
src/m_cond.c
41
src/m_cond.c
|
@ -929,7 +929,7 @@ UINT8 M_CheckLevelEmblems(void)
|
|||
// Update Score, Time, Rings emblems
|
||||
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;
|
||||
|
||||
levelnum = emblemlocations[i].level;
|
||||
|
@ -963,6 +963,45 @@ UINT8 M_CheckLevelEmblems(void)
|
|||
return somethingUnlocked;
|
||||
}
|
||||
|
||||
UINT8 M_CompletionEmblems(void) // Bah! Duplication! :/
|
||||
{
|
||||
INT32 i;
|
||||
INT32 embtype;
|
||||
INT16 levelnum;
|
||||
UINT8 res;
|
||||
UINT8 somethingUnlocked = 0;
|
||||
|
||||
for (i = 0; i < numemblems; ++i)
|
||||
{
|
||||
if (emblemlocations[i].type != ET_MAP || emblemlocations[i].collected)
|
||||
continue;
|
||||
|
||||
levelnum = emblemlocations[i].level;
|
||||
embtype = emblemlocations[i].var;
|
||||
|
||||
switch (embtype)
|
||||
{
|
||||
case 1: // Requires map to be beaten with all emeralds
|
||||
res = ((mapvisited[levelnum - 1] & MV_ALLEMERALDS) == MV_ALLEMERALDS);
|
||||
break;
|
||||
case 2: // Requires map to be beaten in Ultimate mode
|
||||
res = ((mapvisited[levelnum - 1] & MV_ULTIMATE) == MV_ULTIMATE);
|
||||
break;
|
||||
case 3: // Requires map to be beaten with a perfect bonus
|
||||
res = ((mapvisited[levelnum - 1] & MV_PERFECT) == MV_PERFECT);
|
||||
break;
|
||||
default: // Requires map to be beaten, no special requirements
|
||||
res = ((mapvisited[levelnum - 1] & MV_BEATEN) == MV_BEATEN);
|
||||
break;
|
||||
}
|
||||
|
||||
emblemlocations[i].collected = res;
|
||||
if (res)
|
||||
++somethingUnlocked;
|
||||
}
|
||||
return somethingUnlocked;
|
||||
}
|
||||
|
||||
// -------------------
|
||||
// Quick unlock checks
|
||||
// -------------------
|
||||
|
|
|
@ -73,6 +73,7 @@ typedef struct
|
|||
#define ET_RINGS 4
|
||||
#define ET_NGRADE 5
|
||||
#define ET_NTIME 6
|
||||
#define ET_MAP 7
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -153,6 +154,7 @@ void M_CheckUnlockConditions(void);
|
|||
UINT8 M_UpdateUnlockablesAndExtraEmblems(void);
|
||||
void M_SilentUpdateUnlockablesAndEmblems(void);
|
||||
UINT8 M_CheckLevelEmblems(void);
|
||||
UINT8 M_CompletionEmblems(void);
|
||||
|
||||
// Checking unlockable status
|
||||
UINT8 M_AnySecretUnlocked(void);
|
||||
|
|
|
@ -2940,6 +2940,8 @@ static void M_DrawMapEmblems(INT32 mapnum, INT32 x, INT32 y)
|
|||
curtype = 1; break;
|
||||
case ET_NGRADE: case ET_NTIME:
|
||||
curtype = 2; break;
|
||||
case ET_MAP:
|
||||
curtype = 3; break;
|
||||
default:
|
||||
curtype = 0; break;
|
||||
}
|
||||
|
|
|
@ -1007,6 +1007,10 @@ void Y_StartIntermission(void)
|
|||
|
||||
if (modeattacking == ATTACKING_RECORD)
|
||||
Y_UpdateRecordReplays();
|
||||
|
||||
UINT8 completionEmblems = M_CompletionEmblems();
|
||||
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)
|
||||
|
@ -1106,6 +1110,13 @@ void Y_StartIntermission(void)
|
|||
{
|
||||
if (!stagefailed)
|
||||
mapvisited[gamemap-1] |= MV_BEATEN;
|
||||
|
||||
// all emeralds/ultimate/perfect emblems won't be possible in ss, oh well?
|
||||
{
|
||||
UINT8 completionEmblems = M_CompletionEmblems();
|
||||
if (completionEmblems)
|
||||
CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for level completion.\n"), (UINT16)completionEmblems, completionEmblems > 1 ? "s" : "");
|
||||
}
|
||||
}
|
||||
|
||||
// give out ring bonuses
|
||||
|
|
Loading…
Reference in a new issue