Skip to content

Commit

Permalink
feat: reloaded coop sar_speedrun_skip_cutscenes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisAMJ committed Aug 24, 2023
1 parent 2a34fb3 commit 7381244
Showing 1 changed file with 44 additions and 12 deletions.
56 changes: 44 additions & 12 deletions src/Features/Speedrun/SpeedrunTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,54 @@ ON_EVENT_P(SESSION_START, 1000) {
ON_EVENT_P(SESSION_START, -1000) {
g_inDemoLoad = false;
}

static bool g_cutsceneskipdone = false;
ON_EVENT(SESSION_START) {
g_cutsceneskipdone = false;
if (!sar_speedrun_skip_cutscenes.GetBool()) return;
if (sar.game->GetVersion() != SourceGame_Portal2) return;
if (Game::IsSpeedrunMod()) return;
if (engine->IsOrange()) return;
switch (sar.game->GetVersion()) {
case SourceGame_Portal2:
if (Game::IsSpeedrunMod()) return;

if (SpeedrunTimer::IsRunning()) {
// HACKHACK: Since Any% enters Tube Ride via wrongwarp, skip_cutscenes
// doesn't work as ent_fire is restricted in CM. Workaround by
// temporarily setting cheats
sv_cheats.ThisPtr()->m_nValue = 1;
if (g_speedrun.lastMap == "sp_a2_bts6") {
engine->ExecuteCommand("ent_fire @exit_teleport Teleport", true);
} else if (g_speedrun.lastMap == "sp_a3_00") {
engine->ExecuteCommand("ent_fire speedmod kill; ent_fire bottomless_pit_teleport Teleport", true);
}
sv_cheats.SetValue(sv_cheats.GetString());
}
break;
case SourceGame_PortalReloaded:
if (engine->GetCurrentMapName() == "mp_coop_pr_cubes") {
if (!sv_cheats.GetBool()) sv_cheats.SetValue(2); // mod is bad so we shouldn't reset cheats after
engine->ExecuteCommand("ent_fire start_movie kill; ent_fire vc_blue disable; ent_fire vc_orange disable; ent_fire @tp_blue enable; ent_fire @tp_orange enable; ent_fire rt_stop_sounds kill", true);
}
break;
default:
break;
}
}

if (SpeedrunTimer::IsRunning()) {
// HACKHACK: Since Any% enters Tube Ride via wrongwarp, skip_cutscenes
// doesn't work as ent_fire is restricted in CM. Workaround by
// temporarily setting cheats
sv_cheats.ThisPtr()->m_nValue = 1;
if (g_speedrun.lastMap == "sp_a2_bts6") {
engine->ExecuteCommand("ent_fire @exit_teleport Teleport", true);
} else if (g_speedrun.lastMap == "sp_a3_00") {
engine->ExecuteCommand("ent_fire speedmod kill; ent_fire bottomless_pit_teleport Teleport", true);
ON_EVENT(PRE_TICK) {
if (g_cutsceneskipdone) return;
if (!sar_speedrun_skip_cutscenes.GetBool()) return;
if (engine->IsOrange()) return;

if (engine->GetCurrentMapName() == "mp_coop_pr_cubes") {
auto player = server->GetPlayer(1);
if (player) {
auto originZ = server->GetAbsOrigin(player).z;
if (originZ < 3518 && originZ > 3400) {
engine->ExecuteCommand("ent_fire prop_iris_1 SetAnimation item_dropper_open", true);
g_cutsceneskipdone = true;
}
}
sv_cheats.SetValue(sv_cheats.GetString());
}
}

Expand Down

0 comments on commit 7381244

Please sign in to comment.