Skip to content

Commit 76460b4

Browse files
authored
Merge pull request #3 from Gtt1229/Demos,-goals,-and-replays
Demos, goals, and replays
2 parents c3de8a4 + af503eb commit 76460b4

File tree

4 files changed

+127
-6
lines changed

4 files changed

+127
-6
lines changed

RocketLeagueAssistant/RocketLeagueAssistant.cpp

+94-5
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ void RocketLeagueAssistant::onLoad()
2020
cvarManager->registerCvar("ha_enabled", "1", "Enable Plugin", true, true, 0, true, 1);
2121
cvarManager->registerCvar("teams_enabled", "1", "Enable Team Colors", true, true, 0, true, 1);
2222
cvarManager->registerCvar("demos_enabled", "1", "Enable Demos Webhook", true, true, 0, true, 1);
23+
cvarManager->registerCvar("goalScored_enabled", "1", "Enable Overtime Webhook", true, true, 0, true, 1);
2324
cvarManager->registerCvar("freeplay_enabled", "1", "Enable Freeplay Webhook", true, true, 0, true, 1);
2425
cvarManager->registerCvar("mainmenu_enabled", "1", "Enable Mainemenu Webhook", true, true, 0, true, 1);
25-
cvarManager->registerCvar("overtime_enabled", "1", "Enable Mainemenu Webhook", true, true, 0, true, 1);
26-
cvarManager->registerCvar("exit_enabled", "1", "Enable Mainemenu Webhook", true, true, 0, true, 1);
26+
cvarManager->registerCvar("overtime_enabled", "1", "Enable Overtime Webhook", true, true, 0, true, 1);
27+
cvarManager->registerCvar("exit_enabled", "1", "Enable Exit Webhook", true, true, 0, true, 1);
28+
cvarManager->registerCvar("isReplay", "0", "Replay boolean", true, true, 0, true, 1);
2729

2830
//URL Cvars
2931
cvarManager->registerCvar("ha_home", "http://192.168.1.256:8123/api/webhook/webhook-light-example-home");
3032
cvarManager->registerCvar("ha_away", "http://192.168.1.256:8123/api/webhook/webhook-light-example-away");
3133
cvarManager->registerCvar("ha_demos", "http://192.168.1.256:8123/api/webhook/webhook-light-example-demos");
34+
cvarManager->registerCvar("ha_goalScored", "http://192.168.1.256:8123/api/webhook/webhook-light-example-goalscored");
3235
cvarManager->registerCvar("ha_freeplay", "http://192.168.1.256:8123/api/webhook/webhook-light-example-freeplay");
3336
cvarManager->registerCvar("ha_mainmenu", "http://192.168.1.256:8123/api/webhook/webhook-light-example-mainmenu");
3437
cvarManager->registerCvar("ha_overtime", "http://192.168.1.256:8123/api/webhook/webhook-light-example-overtime");
@@ -63,6 +66,9 @@ void RocketLeagueAssistant::LoadHooks()
6366
gameWrapper->HookEvent("Function Engine.Pawn.GetTeam", std::bind(&RocketLeagueAssistant::LoadTeams, this, std::placeholders::_1));
6467

6568

69+
//Goal Scored
70+
gameWrapper->HookEvent("Function TAGame.Ball_TA.Explode", std::bind(&RocketLeagueAssistant::GoalScoredHook, this, std::placeholders::_1));
71+
6672
//Demo Feature
6773
gameWrapper->HookEventWithCallerPost<ActorWrapper>("Function TAGame.GFxHUD_TA.HandleStatTickerMessage",
6874
[this](ActorWrapper caller, void* params, std::string eventname) {
@@ -78,7 +84,9 @@ void RocketLeagueAssistant::LoadHooks()
7884
//On Game Exit
7985
gameWrapper->HookEvent("Function ProjectX.GFxShell_X.ExitGame", std::bind(&RocketLeagueAssistant::ExitHook, this, std::placeholders::_1));
8086

81-
87+
//Check if it is a replay
88+
gameWrapper->HookEvent("Function GameEvent_Soccar_TA.ReplayPlayback.BeginState", std::bind(&RocketLeagueAssistant::Replay, this, std::placeholders::_1));
89+
gameWrapper->HookEvent("Function GameEvent_Soccar_TA.ReplayPlayback.EndState", std::bind(&RocketLeagueAssistant::NotReplay, this, std::placeholders::_1));
8290
}
8391

8492
void RocketLeagueAssistant::SendCommands(std::string reqUrl)
@@ -105,6 +113,19 @@ void RocketLeagueAssistant::LoadTeams(std::string name)
105113

106114
if (!enabled) { LOG("RocketLeagueAssistant is not enabled"); return; }
107115

116+
//See if team colors are enabled
117+
CVarWrapper teamsEnabledCvar = cvarManager->getCvar("teams_enabled");
118+
bool teamsEnabled = teamsEnabledCvar.getBoolValue();
119+
if (!teamsEnabled) { LOG("Team color Automations are not enabled"); return; }
120+
121+
//Check if it is a replay (this is may be temporary to minimize log flooding on Home Assistant)
122+
123+
CVarWrapper replayCvar = cvarManager->getCvar("isReplay");
124+
bool isReplay = replayCvar.getBoolValue();
125+
if (isReplay == true) { Log("It's a replay"); return; }
126+
127+
128+
108129
//Get player team and primary color
109130

110131
if (gameWrapper->IsInFreeplay()) {
@@ -122,6 +143,11 @@ void RocketLeagueAssistant::LoadTeams(std::string name)
122143

123144
if (!gameWrapper->IsInFreeplay()) {
124145

146+
147+
CVarWrapper replayCvar = cvarManager->getCvar("isReplay");
148+
bool isReplay = replayCvar.getBoolValue();
149+
if (isReplay == true) { Log("It's a replay"); return; }
150+
125151
cvarManager->log("Player in game, using team colors");
126152

127153
ServerWrapper server = gameWrapper->GetCurrentGameState();
@@ -218,6 +244,7 @@ void RocketLeagueAssistant::ConvertLinearColor(float red, float green, float blu
218244

219245
void RocketLeagueAssistant::DemosHook(void* params)
220246
{
247+
221248
//Check if plugin is enabled
222249
CVarWrapper enableCvar = cvarManager->getCvar("ha_enabled");
223250
bool enabled = enableCvar.getBoolValue();
@@ -229,6 +256,11 @@ void RocketLeagueAssistant::DemosHook(void* params)
229256
bool demosEnabled = demosEnabledCvar.getBoolValue();
230257
if (!demosEnabled) { LOG("Demos Automations are not enabled"); return; }
231258

259+
//See if it is a replay
260+
CVarWrapper replayCvar = cvarManager->getCvar("isReplay");
261+
bool isReplay = replayCvar.getBoolValue();
262+
if (isReplay == true) { Log("It's a replay"); return; }
263+
232264
//Get demos automation url, transform, and convert to string
233265
CVarWrapper haDemosCVar = cvarManager->getCvar("ha_demos");
234266
if (!haDemosCVar) { return; }
@@ -268,9 +300,7 @@ void RocketLeagueAssistant::DemosHook(void* params)
268300

269301
// Compare the primary player to the victim
270302
if (playerPRI.memory_address != victim.memory_address) {
271-
LOG("Hah you got demoed get good {}", victim.GetPlayerName().ToString());
272303

273-
274304
SendCommands(reqUrlDemosString);
275305

276306

@@ -287,6 +317,11 @@ void RocketLeagueAssistant::FreeplayHook()
287317

288318
if (!enabled) { LOG("RocketLeagueAssistant is not enabled"); return; }
289319

320+
//Check if it is a replay (this is may be temporary to minimize log flooding on Home Assistant)
321+
322+
CVarWrapper replayCvar = cvarManager->getCvar("isReplay");
323+
bool isReplay = replayCvar.getBoolValue();
324+
if (!isReplay) { Log("It's a replay"); return; }
290325

291326
//May be redundant, but good to check
292327

@@ -328,6 +363,36 @@ void RocketLeagueAssistant::MainMenuHook(std::string name)
328363

329364
}
330365

366+
void RocketLeagueAssistant::GoalScoredHook(std::string name)
367+
{
368+
//Check if plugin is enabled
369+
CVarWrapper enableCvar = cvarManager->getCvar("ha_enabled");
370+
bool enabled = enableCvar.getBoolValue();
371+
372+
if (!enabled) { LOG("RocketLeagueAssistant is not enabled"); return; }
373+
374+
375+
//See if Goal Scored hook is enabled
376+
CVarWrapper goalScoredEnabledCvar = cvarManager->getCvar("goalScored_enabled");
377+
bool goalScoredEnabled = goalScoredEnabledCvar.getBoolValue();
378+
if (!goalScoredEnabled) { LOG("goalScored Automations are not enabled"); return; }
379+
380+
//See if it is a replay
381+
CVarWrapper replayCvar = cvarManager->getCvar("isReplay");
382+
bool isReplay = replayCvar.getBoolValue();
383+
if (isReplay == true) { Log("It's a replay"); return; }
384+
385+
//Get Goal Scored automation url, transform, and convert to string
386+
CVarWrapper hagoalScoredCVar = cvarManager->getCvar("ha_goalScored");
387+
if (!hagoalScoredCVar) { return; }
388+
auto reqUrlgoalScored = cvarManager->getCvar("ha_goalScored");
389+
std::string reqUrlgoalScoredString = reqUrlgoalScored.getStringValue();
390+
391+
LOG("Using Goal Scored Hook");
392+
SendCommands(reqUrlgoalScoredString);
393+
394+
}
395+
331396
void RocketLeagueAssistant::OvertimeHook(std::string name)
332397
{
333398
//Check if plugin is enabled
@@ -380,6 +445,30 @@ void RocketLeagueAssistant::ExitHook(std::string name)
380445

381446

382447

448+
}
449+
450+
451+
void RocketLeagueAssistant::Replay(std::string name)
452+
{
453+
LOG("Replay start");
454+
CVarWrapper replayCvar = cvarManager->getCvar("isReplay");
455+
bool isReplay = replayCvar.getBoolValue();
456+
isReplay = true;
457+
LOG("{}", isReplay);
458+
replayCvar.setValue(isReplay);
459+
460+
461+
}
462+
463+
void RocketLeagueAssistant::NotReplay(std::string name)
464+
{
465+
LOG("Replay ended");
466+
CVarWrapper replayCvar = cvarManager->getCvar("isReplay");
467+
bool isReplay = replayCvar.getBoolValue();
468+
isReplay = false;
469+
LOG("{}", isReplay);
470+
replayCvar.setValue(isReplay);
471+
383472
}
384473

385474
void RocketLeagueAssistant::Log(std::string msg)

RocketLeagueAssistant/RocketLeagueAssistant.h

+3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ class RocketLeagueAssistant: public BakkesMod::Plugin::BakkesModPlugin, public B
2626
void FreeplayHook();
2727
void MainMenuHook(std::string name);
2828
void OvertimeHook(std::string name);
29+
void GoalScoredHook(std::string name);
2930
void ExitHook(std::string name);
31+
void Replay(std::string name);
32+
void NotReplay(std::string name);
3033

3134
void SendCommands(std::string reqUrl);
3235

RocketLeagueAssistant/RocketLeagueAssistantGUI.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ void RocketLeagueAssistant::RenderSettings() {
2323

2424
//Get URL related Cvars
2525
CVarWrapper enableCvar = cvarManager->getCvar("ha_enabled");
26+
2627
CVarWrapper teamsEnableCvar = cvarManager->getCvar("teams_enabled");
2728
CVarWrapper haHomeCvargui = cvarManager->getCvar("ha_home");
2829
CVarWrapper haAwayCvargui = cvarManager->getCvar("ha_away");
2930

31+
CVarWrapper goalScoredEnableCvar = cvarManager->getCvar("goalScored_enabled");
32+
CVarWrapper haGoalScoredCvargui = cvarManager->getCvar("ha_goalScored");
33+
3034
CVarWrapper mainmenuEnableCvar = cvarManager->getCvar("mainmenu_enabled");
3135
CVarWrapper haMainMenuCvargui = cvarManager->getCvar("ha_mainmenu");
3236

@@ -47,6 +51,8 @@ void RocketLeagueAssistant::RenderSettings() {
4751

4852
if (!enableCvar) { return; }
4953
if (!teamsEnableCvar) { return; }
54+
if (!goalScoredEnableCvar) { return; }
55+
if (!overtimeEnableCvar) { return; }
5056
if (!demosEnableCvar) { return; }
5157
if (!freeplayEnableCvar) { return; }
5258
if (!mainmenuEnableCvar) { return; }
@@ -110,6 +116,29 @@ void RocketLeagueAssistant::RenderSettings() {
110116
}
111117

112118

119+
//Goal Scored hook Gui
120+
121+
bool goalScoredEnabled = goalScoredEnableCvar.getBoolValue();
122+
123+
if (ImGui::Checkbox("Enable goalScored Webhook", &goalScoredEnabled)) {
124+
goalScoredEnableCvar.setValue(goalScoredEnabled);
125+
}
126+
if (ImGui::IsItemHovered()) {
127+
ImGui::SetTooltip("Toggle Webhook");
128+
}
129+
130+
if (goalScoredEnabled == true) {
131+
132+
if (!haGoalScoredCvargui) { return; }
133+
std::string reqgoalScoredUrlex = haGoalScoredCvargui.getStringValue();
134+
135+
if (ImGui::InputText("Home Assistant Web Hook URL For Goals", &reqgoalScoredUrlex)) {
136+
137+
haGoalScoredCvargui.setValue(reqgoalScoredUrlex);
138+
139+
}
140+
}
141+
113142
//Demos hook Gui
114143

115144
bool demosEnabled = demosEnableCvar.getBoolValue();

RocketLeagueAssistant/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define VERSION_MAJOR 1
33
#define VERSION_MINOR 0
44
#define VERSION_PATCH 0
5-
#define VERSION_BUILD 359
5+
#define VERSION_BUILD 377
66

77
#define stringify(a) stringify_(a)
88
#define stringify_(a) #a

0 commit comments

Comments
 (0)