Skip to content

Commit

Permalink
Add global callbacks intermission() and restartround()
Browse files Browse the repository at this point in the history
 * intermission() is called when intermission starts
 * restartround() is called right before the round is restarted, to allow for Lua to persist data before the Lua environment is destroyed and re-created
  • Loading branch information
squeek502 committed Apr 25, 2015
1 parent 252ff1b commit facb165
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion game_shared/ff/ff_gamerules.cpp
Expand Up @@ -630,7 +630,12 @@ ConVar mp_friendlyfire_armorstrip( "mp_friendlyfire_armorstrip",
// absolutely everything - scores, players, entities, etc.
if( bFullReset )
{
// TODO: Do stuff!
// give lua a chance to prepare for the restart
if (_scriptman.GetLuaState() != NULL)
{
CFFLuaSC hRestartRound;
_scriptman.RunPredicates_LUA(NULL, &hRestartRound, "restartround");
}

m_flIntermissionEndTime = 0.f;

Expand Down Expand Up @@ -1036,6 +1041,17 @@ ConVar mp_friendlyfire_armorstrip( "mp_friendlyfire_armorstrip",
}
}

void CFFGameRules::GoToIntermission()
{
if ( g_fGameOver )
return;

BaseClass::GoToIntermission();

CFFLuaSC hIntermission;
_scriptman.RunPredicates_LUA(NULL, &hIntermission, "intermission");
}

//-----------------------------------------------------------------------------
// Purpose: creates a list of valid spawn points
//-----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions game_shared/ff/ff_gamerules.h
Expand Up @@ -150,6 +150,7 @@ class CFFGameRules : public CTeamplayRules
virtual void RestartRound( void );

virtual void ResetUsingCriteria( bool *pbFlags, int iTeam = TEAM_UNASSIGNED, CFFPlayer *pFFPlayer = NULL, bool bFullReset = false );
virtual void GoToIntermission( void );

virtual void UpdateSpawnPoints();
CUtlVector<CBaseEntity*> m_SpawnPoints;
Expand Down

0 comments on commit facb165

Please sign in to comment.