Skip to content

Commit

Permalink
Revert to the old way of starting setup time
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikusch committed Feb 22, 2025
1 parent 368d313 commit 5e762e0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/mitm.sp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
// Uncomment this for diagnostic messages in server console (very verbose)
// #define DEBUG

#define PLUGIN_VERSION "1.0.1"
#define PLUGIN_VERSION "1.0.2"

// Global entities
CMannVsMachineStats g_pMVMStats = view_as<CMannVsMachineStats>(INVALID_ENT_REFERENCE);
Expand Down
8 changes: 0 additions & 8 deletions addons/sourcemod/scripting/mitm/events.sp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ static void EventHook_PlayerSpawn(Event event, const char[] name, bool dontBroad

CTFPlayer(client).Spawn();
CTFPlayer(client).m_annotationTimer = CreateTimer(1.0, Timer_CheckGateBotAnnotation, GetClientUserId(client), TIMER_REPEAT);

TFTeam team = view_as<TFTeam>(event.GetInt("team"));

// Once first player picks a class and spawns in, automatically start ready timer
if (team == TFTeam_Defenders && (GameRules_GetProp("m_bInSetup") || g_pObjectiveResource.GetMannVsMachineIsBetweenWaves()) && !IsInWaitingForPlayers() && GameRules_GetPropFloat("m_flRestartRoundTime") == -1)
{
BeginSetup();
}
}

static void EventHook_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
Expand Down
22 changes: 22 additions & 0 deletions addons/sourcemod/scripting/mitm/hooks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void Hooks_Init()
PSM_AddUserMessageHook(GetUserMessageId("TextMsg"), OnTextMsg, true);

PSM_AddEntityOutputHook("trigger_remove_tf_player_condition", "OnStartTouch", EntityOutput_CTriggerRemoveTFPlayerCondition_OnStartTouch);
PSM_AddEntityOutputHook("tf_gamerules", "OnStateEnterBetweenRounds", EntityOutput_CTFGameRules_OnStateEnterBetweenRounds);
}

static Action OnSayText2(UserMsg msg_id, BfRead msg, const int[] players, int clientsNum, bool reliable, bool init)
Expand Down Expand Up @@ -190,3 +191,24 @@ static void EntityOutput_CTriggerRemoveTFPlayerCondition_OnStartTouch(const char
// Copy behavior of CTriggerRemoveTFPlayerCondition::StartTouch
SDKCall_CBaseCombatCharacter_ClearLastKnownArea(activator);
}

static void EntityOutput_CTFGameRules_OnStateEnterBetweenRounds(const char[] output, int caller, int activator, float delay)
{
if (!IsInWaitingForPlayers() && mitm_setup_time.IntValue > 0)
{
RequestFrame(RequestFrame_StartReadyTimer);
}
}

static void RequestFrame_StartReadyTimer()
{
GameRules_SetPropFloat("m_flRestartRoundTime", GetGameTime() + mitm_setup_time.FloatValue);
GameRules_SetProp("m_bAwaitingReadyRestart", false);

Event event = CreateEvent("teamplay_round_restart_seconds");
if (event)
{
event.SetInt("seconds", mitm_setup_time.IntValue);
event.Fire();
}
}
13 changes: 0 additions & 13 deletions addons/sourcemod/scripting/mitm/util.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,19 +1116,6 @@ void ShowProgressBar(int client, const char[] szTitle, float flProgress, float i
ShowSyncHudText(client, g_hWarningHudSync, "%t\n%s", szTitle, szProgressBar);
}

void BeginSetup()
{
GameRules_SetPropFloat("m_flRestartRoundTime", GetGameTime() + mitm_setup_time.FloatValue);
GameRules_SetProp("m_bAwaitingReadyRestart", false);

Event event = CreateEvent("teamplay_round_restart_seconds");
if (event)
{
event.SetInt("seconds", mitm_setup_time.IntValue);
event.Fire();
}
}

void SelectNewDefenders()
{
for (int client = 1; client <= MaxClients; client++)
Expand Down

0 comments on commit 5e762e0

Please sign in to comment.