|
4 | 4 | #include "Event.hpp" |
5 | 5 | #include "Features/Demo/DemoGhostPlayer.hpp" |
6 | 6 | #include "Features/Hud/Hud.hpp" |
| 7 | +#include "Modules/Client.hpp" |
7 | 8 | #include "Modules/Engine.hpp" |
8 | 9 | #include "Modules/Server.hpp" |
9 | 10 | #include "SpeedrunTimer.hpp" |
|
20 | 21 | #endif |
21 | 22 |
|
22 | 23 | Variable sar_speedrun_draw_triggers("sar_speedrun_draw_triggers", "0", "Draw the triggers associated with speedrun rules in the world.\n"); |
| 24 | +Variable sar_speedrun_triggers_info("sar_speedrun_triggers_info", "0", "Print player velocity (and position) upon mtrigger activation.\n1 - position and velocity\n2 - only horizontal velocity\n"); |
23 | 25 |
|
24 | 26 | static std::optional<std::vector<std::string>> extractPartialArgs(const char *str, const char *cmd) { |
25 | 27 | while (*cmd) { |
@@ -116,6 +118,26 @@ static void dispatchRule(std::string name, SpeedrunRule *rule) { |
116 | 118 | } |
117 | 119 |
|
118 | 120 | rule->fired = true; |
| 121 | + |
| 122 | + // Handle `sar_speedrun_triggers_info` |
| 123 | + int info = sar_speedrun_triggers_info.GetInt(); |
| 124 | + if (info == 0) return; |
| 125 | + |
| 126 | + void *player = client->GetPlayer(GET_SLOT() + 1); |
| 127 | + if (!player) return; |
| 128 | + |
| 129 | + Vector pos = client->GetAbsOrigin(player); |
| 130 | + Vector vel = client->GetLocalVelocity(player); |
| 131 | + |
| 132 | + if (info == 1) { |
| 133 | + // Info type 1 prints everything |
| 134 | + console->Print("Player triggered rule '%s':\n", name.c_str()); |
| 135 | + console->Print(" Position: %.2f %.2f %.2f\n", pos.x, pos.y, pos.z); |
| 136 | + console->Print(" Velocity: %.2f %.2f %.2f\n", vel.x, vel.y, vel.z); |
| 137 | + } else if (info == 2) { |
| 138 | + // Info type 2 prints just the horizontal velocity |
| 139 | + console->Print("Player velocity on last rule: %.2f\n", vel.Length2D()); |
| 140 | + } |
119 | 141 | } |
120 | 142 |
|
121 | 143 | ON_EVENT(PRE_TICK) { |
|
0 commit comments