@@ -20,15 +20,18 @@ void RocketLeagueAssistant::onLoad()
20
20
cvarManager->registerCvar (" ha_enabled" , " 1" , " Enable Plugin" , true , true , 0 , true , 1 );
21
21
cvarManager->registerCvar (" teams_enabled" , " 1" , " Enable Team Colors" , true , true , 0 , true , 1 );
22
22
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 );
23
24
cvarManager->registerCvar (" freeplay_enabled" , " 1" , " Enable Freeplay Webhook" , true , true , 0 , true , 1 );
24
25
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 );
27
29
28
30
// URL Cvars
29
31
cvarManager->registerCvar (" ha_home" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-home" );
30
32
cvarManager->registerCvar (" ha_away" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-away" );
31
33
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" );
32
35
cvarManager->registerCvar (" ha_freeplay" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-freeplay" );
33
36
cvarManager->registerCvar (" ha_mainmenu" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-mainmenu" );
34
37
cvarManager->registerCvar (" ha_overtime" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-overtime" );
@@ -63,6 +66,9 @@ void RocketLeagueAssistant::LoadHooks()
63
66
gameWrapper->HookEvent (" Function Engine.Pawn.GetTeam" , std::bind (&RocketLeagueAssistant::LoadTeams, this , std::placeholders::_1));
64
67
65
68
69
+ // Goal Scored
70
+ gameWrapper->HookEvent (" Function TAGame.Ball_TA.Explode" , std::bind (&RocketLeagueAssistant::GoalScoredHook, this , std::placeholders::_1));
71
+
66
72
// Demo Feature
67
73
gameWrapper->HookEventWithCallerPost <ActorWrapper>(" Function TAGame.GFxHUD_TA.HandleStatTickerMessage" ,
68
74
[this ](ActorWrapper caller, void * params, std::string eventname) {
@@ -78,7 +84,9 @@ void RocketLeagueAssistant::LoadHooks()
78
84
// On Game Exit
79
85
gameWrapper->HookEvent (" Function ProjectX.GFxShell_X.ExitGame" , std::bind (&RocketLeagueAssistant::ExitHook, this , std::placeholders::_1));
80
86
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));
82
90
}
83
91
84
92
void RocketLeagueAssistant::SendCommands (std::string reqUrl)
@@ -105,6 +113,19 @@ void RocketLeagueAssistant::LoadTeams(std::string name)
105
113
106
114
if (!enabled) { LOG (" RocketLeagueAssistant is not enabled" ); return ; }
107
115
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
+
108
129
// Get player team and primary color
109
130
110
131
if (gameWrapper->IsInFreeplay ()) {
@@ -122,6 +143,11 @@ void RocketLeagueAssistant::LoadTeams(std::string name)
122
143
123
144
if (!gameWrapper->IsInFreeplay ()) {
124
145
146
+
147
+ CVarWrapper replayCvar = cvarManager->getCvar (" isReplay" );
148
+ bool isReplay = replayCvar.getBoolValue ();
149
+ if (isReplay == true ) { Log (" It's a replay" ); return ; }
150
+
125
151
cvarManager->log (" Player in game, using team colors" );
126
152
127
153
ServerWrapper server = gameWrapper->GetCurrentGameState ();
@@ -218,6 +244,7 @@ void RocketLeagueAssistant::ConvertLinearColor(float red, float green, float blu
218
244
219
245
void RocketLeagueAssistant::DemosHook (void * params)
220
246
{
247
+
221
248
// Check if plugin is enabled
222
249
CVarWrapper enableCvar = cvarManager->getCvar (" ha_enabled" );
223
250
bool enabled = enableCvar.getBoolValue ();
@@ -229,6 +256,11 @@ void RocketLeagueAssistant::DemosHook(void* params)
229
256
bool demosEnabled = demosEnabledCvar.getBoolValue ();
230
257
if (!demosEnabled) { LOG (" Demos Automations are not enabled" ); return ; }
231
258
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
+
232
264
// Get demos automation url, transform, and convert to string
233
265
CVarWrapper haDemosCVar = cvarManager->getCvar (" ha_demos" );
234
266
if (!haDemosCVar) { return ; }
@@ -268,9 +300,7 @@ void RocketLeagueAssistant::DemosHook(void* params)
268
300
269
301
// Compare the primary player to the victim
270
302
if (playerPRI.memory_address != victim.memory_address ) {
271
- LOG (" Hah you got demoed get good {}" , victim.GetPlayerName ().ToString ());
272
303
273
-
274
304
SendCommands (reqUrlDemosString);
275
305
276
306
@@ -287,6 +317,11 @@ void RocketLeagueAssistant::FreeplayHook()
287
317
288
318
if (!enabled) { LOG (" RocketLeagueAssistant is not enabled" ); return ; }
289
319
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 ; }
290
325
291
326
// May be redundant, but good to check
292
327
@@ -328,6 +363,36 @@ void RocketLeagueAssistant::MainMenuHook(std::string name)
328
363
329
364
}
330
365
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
+
331
396
void RocketLeagueAssistant::OvertimeHook (std::string name)
332
397
{
333
398
// Check if plugin is enabled
@@ -380,6 +445,30 @@ void RocketLeagueAssistant::ExitHook(std::string name)
380
445
381
446
382
447
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
+
383
472
}
384
473
385
474
void RocketLeagueAssistant::Log (std::string msg)
0 commit comments