Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit 942eb13

Browse files
committed
Add Super 8 category for Portal 2
1 parent 0b3b611 commit 942eb13

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/Features/Speedrun/Rules/Portal2Rules.cpp

+27-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
#define Offset_m_bDisabled 980
1313
#define Offset_m_bPlayerStateA 960
1414
#define Offset_m_bPlayerStateB 961
15+
#define Offset_m_flFOV 1736
1516
#else
1617
#define Offset_m_iTouchingPortalCount 1148
1718
#define Offset_m_bDisabled 1004
1819
#define Offset_m_bPlayerStateA 984
1920
#define Offset_m_bPlayerStateB 985
21+
#define Offset_m_flFOV 1760
2022
#endif
2123

2224
SAR_RULE(view_change, "sp_a1_intro1", "player", "CBasePlayer", m_hViewEntity, SearchMode::Classes)
@@ -79,5 +81,29 @@ SAR_RULE3(gate_opens, "mp_coop_paint_crazy_box", "coopman_airlock_success", Sear
7981
return TimerAction::DoNothing;
8082
}
8183

82-
SAR_CATEGORY(Portal2, RTA, _Rules({ &view_change, &moon_shot }));
84+
SAR_RULE(gain_control, "e1912", "player", "CBasePlayer", m_hVehicle, SearchMode::Classes)
85+
{
86+
// Wait some ticks till we get into the vehicle
87+
if (engine->GetSessionTick() > 13 && *m_hVehicle == -1) {
88+
return TimerAction::Start;
89+
}
90+
91+
return TimerAction::DoNothing;
92+
}
93+
94+
SAR_RULE3(vehicle_lock, "e1912", "crash-vehicle_outro", SearchMode::Names)
95+
{
96+
// CPropVehicleChoreoGeneric aka prop_vehicle_choreo_generic
97+
// m_savedVehicleView.flFOV
98+
auto flFOV = reinterpret_cast<float*>((uintptr_t)entity + Offset_m_flFOV);
99+
100+
if (*flFOV != 0) {
101+
return TimerAction::End;
102+
}
103+
104+
return TimerAction::DoNothing;
105+
}
106+
107+
SAR_CATEGORY(Portal2, RTA, _Rules({ &view_change, &moon_shot }));
83108
SAR_CATEGORY(Portal2, CoopRTA, _Rules({ &players_teleport, &players_taunt, &gate_opens }));
109+
SAR_CATEGORY(Portal2, Super8, _Rules({ &gain_control, &vehicle_lock }));

0 commit comments

Comments
 (0)