- Changed G_ChangeLevel()'s parameter list to match the ACS version's.

- Added resethealth to complement resetinventory.

SVN r2377 (trunk)
This commit is contained in:
Randy Heit 2010-06-18 03:35:41 +00:00
parent 1bbae4a8f2
commit 34d8212d64
9 changed files with 47 additions and 39 deletions

View file

@ -2021,7 +2021,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
// Using LEVEL_NOINTERMISSION tends to throw the game out of sync.
// That was a long time ago. Maybe it works now?
level.flags |= LEVEL_CHANGEMAPCHEAT;
G_ChangeLevel(s, pos, false);
G_ChangeLevel(s, pos, 0);
break;
case DEM_SUICIDE:

View file

@ -1163,7 +1163,9 @@ void G_Ticker ()
// G_PlayerFinishLevel
// Called when a player completes a level.
//
void G_PlayerFinishLevel (int player, EFinishLevelType mode, bool resetinventory)
// flags is checked for RESETINVENTORY and RESETHEALTH only.
void G_PlayerFinishLevel (int player, EFinishLevelType mode, int flags)
{
AInventory *item, *next;
player_t *p;
@ -1235,8 +1237,14 @@ void G_PlayerFinishLevel (int player, EFinishLevelType mode, bool resetinventory
P_UndoPlayerMorph (p, p, 0, true);
}
// Resets player health to default
if (flags & CHANGELEVEL_RESETHEALTH)
{
p->health = p->mo->health = p->mo->SpawnHealth();
}
// Clears the entire inventory and gives back the defaults for starting a game
if (resetinventory)
if (flags & CHANGELEVEL_RESETINVENTORY)
{
AInventory *inv = p->mo->Inventory;

View file

@ -71,7 +71,7 @@ enum EFinishLevelType
FINISH_NoHub
};
void G_PlayerFinishLevel (int player, EFinishLevelType mode, bool resetinventory);
void G_PlayerFinishLevel (int player, EFinishLevelType mode, int flags);
void G_DoReborn (int playernum, bool freshbot);

View file

@ -529,10 +529,8 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
static FString nextlevel;
static int startpos; // [RH] Support for multiple starts per level
extern int NoWipe; // [RH] Don't wipe when travelling in hubs
static bool startkeepfacing; // [RH] Support for keeping your facing angle
static bool resetinventory; // Reset the inventory to the player's default for the next level
static int changeflags;
static bool unloading;
static bool g_nomonsters;
//==========================================================================
//
@ -543,8 +541,7 @@ static bool g_nomonsters;
//==========================================================================
void G_ChangeLevel(const char *levelname, int position, bool keepFacing, int nextSkill,
bool nointermission, bool resetinv, bool nomonsters)
void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill)
{
level_info_t *nextinfo = NULL;
@ -573,25 +570,32 @@ void G_ChangeLevel(const char *levelname, int position, bool keepFacing, int nex
if (nextSkill != -1)
NextSkill = nextSkill;
g_nomonsters = nomonsters;
if (nointermission) level.flags |= LEVEL_NOINTERMISSION;
if (flags & CHANGELEVEL_NOINTERMISSION)
{
level.flags |= LEVEL_NOINTERMISSION;
}
cluster_info_t *thiscluster = FindClusterInfo (level.cluster);
cluster_info_t *nextcluster = nextinfo? FindClusterInfo (nextinfo->cluster) : NULL;
startpos = position;
startkeepfacing = keepFacing;
gameaction = ga_completed;
resetinventory = resetinv;
if (nextinfo != NULL)
{
if (thiscluster != nextcluster || (thiscluster && !(thiscluster->flags & CLUSTER_HUB)))
{
resetinventory |= !!(nextinfo->flags2 & LEVEL2_RESETINVENTORY);
if (nextinfo->flags2 & LEVEL2_RESETINVENTORY)
{
flags |= CHANGELEVEL_RESETINVENTORY;
}
if (nextinfo->flags2 & LEVEL2_RESETHEALTH)
{
flags |= CHANGELEVEL_RESETHEALTH;
}
}
}
changeflags = flags;
bglobal.End(); //Added by MC:
@ -667,12 +671,12 @@ const char *G_GetSecretExitMap()
void G_ExitLevel (int position, bool keepFacing)
{
G_ChangeLevel(G_GetExitMap(), position, keepFacing);
G_ChangeLevel(G_GetExitMap(), position, keepFacing ? CHANGELEVEL_KEEPFACING : 0);
}
void G_SecretExitLevel (int position)
{
G_ChangeLevel(G_GetSecretExitMap(), position, false);
G_ChangeLevel(G_GetSecretExitMap(), position, 0);
}
//==========================================================================
@ -786,7 +790,7 @@ void G_DoCompleted (void)
{
if (playeringame[i])
{ // take away appropriate inventory
G_PlayerFinishLevel (i, mode, resetinventory);
G_PlayerFinishLevel (i, mode, changeflags);
}
}
@ -927,7 +931,7 @@ void G_DoLoadLevel (int position, bool autosave)
players[i].fragcount = 0;
}
if (g_nomonsters)
if (changeflags & CHANGELEVEL_NOMONSTERS)
{
level.flags2 |= LEVEL2_NOMONSTERS;
}
@ -1164,7 +1168,7 @@ void G_FinishTravel ()
// The player being spawned here is a short lived dummy and
// must not start any ENTER script or big problems will happen.
pawndup = P_SpawnPlayer (&playerstarts[pawn->player - players], true);
if (!startkeepfacing)
if (!changeflags & CHANGELEVEL_KEEPFACING)
{
pawn->angle = pawndup->angle;
pawn->pitch = pawndup->pitch;

View file

@ -201,6 +201,7 @@ enum ELevelFlags
LEVEL2_SMOOTHLIGHTING = 0x01000000, // Level uses the smooth lighting feature.
LEVEL2_POLYGRIND = 0x02000000, // Polyobjects grind corpses to gibs.
LEVEL2_RESETINVENTORY = 0x04000000, // Resets player inventory when starting this level (unless in a hub)
LEVEL2_RESETHEALTH = 0x08000000, // Resets player health when starting this level (unless in a hub)
};
@ -491,8 +492,17 @@ void G_SecretExitLevel (int position);
const char *G_GetExitMap();
const char *G_GetSecretExitMap();
void G_ChangeLevel(const char * levelname, int position, bool keepFacing, int nextSkill=-1,
bool nointermission=false, bool resetinventory=false, bool nomonsters=false);
enum
{
CHANGELEVEL_KEEPFACING = 1,
CHANGELEVEL_RESETINVENTORY = 2,
CHANGELEVEL_NOMONSTERS = 4,
CHANGELEVEL_CHANGESKILL = 8,
CHANGELEVEL_NOINTERMISSION = 16,
CHANGELEVEL_RESETHEALTH = 32,
};
void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill=-1);
void G_SetForEndGame (char *nextmap);

View file

@ -1373,6 +1373,7 @@ MapFlagHandlers[] =
{ "grinding_polyobj", MITYPE_SETFLAG2, LEVEL2_POLYGRIND, 0 },
{ "no_grinding_polyobj", MITYPE_CLRFLAG2, LEVEL2_POLYGRIND, 0 },
{ "resetinventory", MITYPE_SETFLAG2, LEVEL2_RESETINVENTORY, 0 },
{ "resethealth", MITYPE_SETFLAG2, LEVEL2_RESETHEALTH, 0 },
{ "unfreezesingleplayerconversations",MITYPE_SETFLAG2, LEVEL2_CONV_SINGLE_UNFREEZE, 0 },
{ "nobotnodes", MITYPE_IGNORE, 0, 0 }, // Skulltag option: nobotnodes
{ "compat_shorttex", MITYPE_COMPATFLAG, COMPATF_SHORTTEX},

View file

@ -6250,12 +6250,7 @@ int DLevelScript::RunScript ()
case PCD_CHANGELEVEL:
{
int flags = STACK(2);
G_ChangeLevel(FBehavior::StaticLookupString(STACK(4)), STACK(3),
!!(flags & CHANGELEVEL_KEEPFACING), STACK(1),
!!(flags & CHANGELEVEL_NOINTERMISSION),
!!(flags & CHANGELEVEL_RESETINVENTORY),
!!(flags & CHANGELEVEL_NOMONSTERS));
G_ChangeLevel(FBehavior::StaticLookupString(STACK(4)), STACK(3), STACK(2), STACK(1));
sp -= 4;
}
break;

View file

@ -667,16 +667,6 @@ public:
SCRIPT_ModulusBy0,
};
enum
{
CHANGELEVEL_KEEPFACING = 1,
CHANGELEVEL_RESETINVENTORY = 2,
CHANGELEVEL_NOMONSTERS = 4,
CHANGELEVEL_CHANGESKILL = 8,
CHANGELEVEL_NOINTERMISSION = 16
};
DLevelScript (AActor *who, line_t *where, int num, const ScriptPtr *code, FBehavior *module,
bool backSide, int arg0, int arg1, int arg2, int always);
~DLevelScript ();

View file

@ -792,7 +792,7 @@ FUNC(LS_Teleport_NewMap)
if (info && CheckIfExitIsGood (it, info))
{
G_ChangeLevel(info->mapname, arg1, !!arg2);
G_ChangeLevel(info->mapname, arg1, arg2 ? CHANGELEVEL_KEEPFACING : 0);
return true;
}
}