@@ -31,11 +31,16 @@ void RocketLeagueAssistant::onLoad()
31
31
cvarManager->registerCvar (" ha_home" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-home" );
32
32
cvarManager->registerCvar (" ha_away" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-away" );
33
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" );
34
+ // cvarManager->registerCvar("ha_goalScored", "http://192.168.1.256:8123/api/webhook/webhook-light-example-goalscored");
35
35
cvarManager->registerCvar (" ha_freeplay" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-freeplay" );
36
36
cvarManager->registerCvar (" ha_mainmenu" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-mainmenu" );
37
37
cvarManager->registerCvar (" ha_overtime" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-overtime" );
38
38
cvarManager->registerCvar (" ha_exit" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-exit" );
39
+ cvarManager->registerCvar (" ha_goalHome" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-homegoal" );
40
+ cvarManager->registerCvar (" ha_goalAway" , " http://192.168.1.256:8123/api/webhook/webhook-light-example-awaygoal" );
41
+
42
+ // Team CVAR
43
+ cvarManager->registerCvar (" ha_playersTeam" , " 2" );
39
44
40
45
// Prep for possibly using tokens in the future for requests over https
41
46
cvarManager->registerCvar (" ha_token" , " Generated Token" , " Home Assistant URL" );
@@ -49,7 +54,7 @@ void RocketLeagueAssistant::onLoad()
49
54
50
55
_globalCvarManager = cvarManager;
51
56
52
-
57
+
53
58
}
54
59
55
60
void RocketLeagueAssistant::onUnload ()
@@ -67,12 +72,12 @@ void RocketLeagueAssistant::LoadHooks()
67
72
68
73
69
74
// Goal Scored
70
- gameWrapper->HookEvent (" Function TAGame.Ball_TA.Explode" , std::bind (&RocketLeagueAssistant::GoalScoredHook, this , std::placeholders::_1));
75
+ // gameWrapper->HookEvent("Function TAGame.Ball_TA.Explode", std::bind(&RocketLeagueAssistant::GoalScoredHook, this, std::placeholders::_1));
71
76
72
- // Demo Feature
77
+ // Stats Feature
73
78
gameWrapper->HookEventWithCallerPost <ActorWrapper>(" Function TAGame.GFxHUD_TA.HandleStatTickerMessage" ,
74
79
[this ](ActorWrapper caller, void * params, std::string eventname) {
75
- DemosHook (params);
80
+ StatsHook (params);
76
81
});
77
82
78
83
// Overtime
@@ -87,8 +92,25 @@ void RocketLeagueAssistant::LoadHooks()
87
92
// Check if it is a replay
88
93
gameWrapper->HookEvent (" Function GameEvent_Soccar_TA.ReplayPlayback.BeginState" , std::bind (&RocketLeagueAssistant::Replay, this , std::placeholders::_1));
89
94
gameWrapper->HookEvent (" Function GameEvent_Soccar_TA.ReplayPlayback.EndState" , std::bind (&RocketLeagueAssistant::NotReplay, this , std::placeholders::_1));
95
+
96
+
97
+
98
+
99
+
100
+
101
+ // Goal Scored Hook Test
102
+
103
+
104
+
105
+
106
+ // gameWrapper->HookEventWithCallerPost<ServerWrapper>(
107
+ // "Function TAGame.GFxHUD_TA.HandleStatTickerMessage",
108
+ // std::bind(&RocketLeagueAssistant::GoalScoredTest, this,
109
+ // std::placeholders::_1, std::placeholders::_2));
110
+
90
111
}
91
112
113
+
92
114
void RocketLeagueAssistant::SendCommands (std::string reqUrl)
93
115
{
94
116
@@ -182,32 +204,40 @@ void RocketLeagueAssistant::LoadTeams(std::string name)
182
204
if (!haHomeCVar) { return ; }
183
205
CVarWrapper haAwayCVar = cvarManager->getCvar (" ha_away" );
184
206
if (!haAwayCVar) { return ; }
207
+
208
+ // get current team cvar
209
+ CVarWrapper ha_playersTeam = cvarManager->getCvar (" ha_playersTeam" );
210
+ if (!ha_playersTeam) { return ; }
185
211
//
186
212
187
213
// this may be redundant?
188
214
auto reqUrlHome = cvarManager->getCvar (" ha_home" );
189
215
auto reqUrlAway = cvarManager->getCvar (" ha_away" );
216
+
190
217
//
191
218
192
219
// convert haurlcvars to string
193
220
std::string reqUrlHomeString = reqUrlHome.getStringValue ();
194
221
std::string reqUrlAwayString = reqUrlAway.getStringValue ();
195
- //
196
222
197
223
// Send based on home or away team
198
224
if (teamnum <= 1 ) {
199
225
200
226
if (teamnum == 0 ) {
201
227
228
+
202
229
std::string reqUrlTeam = reqUrlHomeString;
203
230
SendCommands (reqUrlTeam);
231
+ ha_playersTeam.setValue (teamnum);
204
232
LOG (" Using Home Team Colors" );
233
+
205
234
}
206
235
207
236
if (teamnum == 1 ) {
208
237
209
238
std::string reqUrlTeam = reqUrlAwayString;
210
239
SendCommands (reqUrlTeam);
240
+ ha_playersTeam.setValue (teamnum);
211
241
LOG (" Using Away Team Colors" );
212
242
}
213
243
@@ -242,7 +272,7 @@ void RocketLeagueAssistant::ConvertLinearColor(float red, float green, float blu
242
272
}
243
273
244
274
245
- void RocketLeagueAssistant::DemosHook (void * params)
275
+ void RocketLeagueAssistant::StatsHook (void * params)
246
276
{
247
277
248
278
// Check if plugin is enabled
@@ -254,35 +284,100 @@ void RocketLeagueAssistant::DemosHook(void* params)
254
284
// See if demos are enabled
255
285
CVarWrapper demosEnabledCvar = cvarManager->getCvar (" demos_enabled" );
256
286
bool demosEnabled = demosEnabledCvar.getBoolValue ();
257
- if (!demosEnabled) { LOG (" Demos Automations are not enabled" ); return ; }
287
+ // if (!demosEnabled) { LOG("Demos Automations are not enabled"); return; }
258
288
259
289
// See if it is a replay
260
290
CVarWrapper replayCvar = cvarManager->getCvar (" isReplay" );
261
291
bool isReplay = replayCvar.getBoolValue ();
262
292
if (isReplay == true ) { Log (" It's a replay" ); return ; }
263
293
294
+
295
+ // Get goals automation url, transform, and convert to string
296
+ CVarWrapper haGoalHomeCVar = cvarManager->getCvar (" ha_goalHome" );
297
+ if (!haGoalHomeCVar) { return ; }
298
+ CVarWrapper haGoalAwayCVar = cvarManager->getCvar (" ha_goalAway" );
299
+ if (!haGoalAwayCVar) { return ; }
300
+ //
301
+
302
+ // Current team CVAR
303
+ // get current team cvar
304
+ CVarWrapper ha_playersTeam = cvarManager->getCvar (" ha_playersTeam" );
305
+ if (!ha_playersTeam) { return ; }
306
+ //
307
+ auto haplayersTeam = cvarManager->getCvar (" ha_playersTeam" );
308
+ int haplayersTeam2 = haplayersTeam.getIntValue ();
309
+
310
+ // convert team to int
311
+ // int haplayersTeam = ha_playersTeam.getIntValue();
312
+ //
313
+ //
314
+ // this may be redundant?
315
+ auto reqGoalUrlHome = cvarManager->getCvar (" ha_goalHome" );
316
+ auto reqGoalUrlAway = cvarManager->getCvar (" ha_goalAway" );
317
+ //
318
+
319
+ // convert haurlcvars to string
320
+ std::string reqUrlGoalHomeString = reqGoalUrlHome.getStringValue ();
321
+ std::string reqUrlGoalAwayString = reqGoalUrlAway.getStringValue ();
322
+
264
323
// Get demos automation url, transform, and convert to string
265
324
CVarWrapper haDemosCVar = cvarManager->getCvar (" ha_demos" );
266
325
if (!haDemosCVar) { return ; }
267
326
auto reqUrlDemos = cvarManager->getCvar (" ha_demos" );
268
327
std::string reqUrlDemosString = reqUrlDemos.getStringValue ();
269
328
270
- // Get a demo 's info
329
+ // Get a StatEvent 's info
271
330
struct StatTickerParams {
272
331
uintptr_t Receiver;
273
332
uintptr_t Victim;
274
333
uintptr_t StatEvent;
275
334
};
276
335
336
+
337
+
277
338
StatTickerParams* pStruct = (StatTickerParams*)params;
278
339
PriWrapper receiver = PriWrapper (pStruct->Receiver );
279
340
PriWrapper victim = PriWrapper (pStruct->Victim );
280
341
281
342
StatEventWrapper statEvent = StatEventWrapper (pStruct->StatEvent );
282
343
283
344
//
345
+ LOG (" StateEventOccured" );
346
+ if (statEvent.GetEventName () == " Goal" ) {
284
347
348
+ // See if Goal Scored hook is enabled
349
+ CVarWrapper goalScoredEnabledCvar = cvarManager->getCvar (" goalScored_enabled" );
350
+ bool goalScoredEnabled = goalScoredEnabledCvar.getBoolValue ();
351
+ if (!goalScoredEnabled) { LOG (" goalScored Automations are not enabled" ); return ; }
352
+
353
+ // See if it is a replay
354
+ CVarWrapper replayCvar = cvarManager->getCvar (" isReplay" );
355
+ bool isReplay = replayCvar.getBoolValue ();
356
+ if (isReplay == true ) { Log (" It's a replay" ); return ; }
357
+
358
+ int tmpCounter = 0 ;
359
+ int lastGoalScoredBy = receiver.GetTeamNum ();
360
+
361
+ if (lastGoalScoredBy <= 1 ) {
362
+
363
+ if (lastGoalScoredBy == haplayersTeam2) {
364
+
365
+ LOG (" Your team scored" );
366
+ SendCommands (reqUrlGoalHomeString);
367
+ }
368
+
369
+ if (lastGoalScoredBy != haplayersTeam2) {
370
+
371
+ LOG (" Other team scored" );
372
+ SendCommands (reqUrlGoalAwayString);
373
+ }
285
374
375
+ }
376
+
377
+
378
+
379
+ LOG (" Using Goals Hook" , lastGoalScoredBy);
380
+ }
286
381
if (statEvent.GetEventName () == " Demolish" ) {
287
382
288
383
CVarWrapper demosEnabledCvar = cvarManager->getCvar (" demos_enabled" );
@@ -301,6 +396,7 @@ void RocketLeagueAssistant::DemosHook(void* params)
301
396
// Compare the primary player to the victim
302
397
if (playerPRI.memory_address != victim.memory_address ) {
303
398
399
+ LOG (" Using Demos Hook" );
304
400
SendCommands (reqUrlDemosString);
305
401
306
402
@@ -317,11 +413,11 @@ void RocketLeagueAssistant::FreeplayHook()
317
413
318
414
if (!enabled) { LOG (" RocketLeagueAssistant is not enabled" ); return ; }
319
415
320
- // Check if it is a replay (this is may be temporary to minimize log flooding on Home Assistant)
416
+ // // Check if it is a replay (this is may be temporary to minimize log flooding on Home Assistant)
321
417
322
- CVarWrapper replayCvar = cvarManager->getCvar (" isReplay" );
323
- bool isReplay = replayCvar.getBoolValue ();
324
- if (!isReplay) { Log (" It's a replay" ); return ; }
418
+ // CVarWrapper replayCvar = cvarManager->getCvar("isReplay");
419
+ // bool isReplay = replayCvar.getBoolValue();
420
+ // if (!isReplay) { Log("It's a replay"); return; }
325
421
326
422
// May be redundant, but good to check
327
423
@@ -363,35 +459,35 @@ void RocketLeagueAssistant::MainMenuHook(std::string name)
363
459
364
460
}
365
461
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
- }
462
+ // void RocketLeagueAssistant::GoalScoredHook(std::string name)
463
+ // {
464
+ // //Check if plugin is enabled
465
+ // CVarWrapper enableCvar = cvarManager->getCvar("ha_enabled");
466
+ // bool enabled = enableCvar.getBoolValue();
467
+ //
468
+ // if (!enabled) { LOG("RocketLeagueAssistant is not enabled"); return; }
469
+ //
470
+ //
471
+ // //See if Goal Scored hook is enabled
472
+ // CVarWrapper goalScoredEnabledCvar = cvarManager->getCvar("goalScored_enabled");
473
+ // bool goalScoredEnabled = goalScoredEnabledCvar.getBoolValue();
474
+ // if (!goalScoredEnabled) { LOG("goalScored Automations are not enabled"); return; }
475
+ //
476
+ // //See if it is a replay
477
+ // CVarWrapper replayCvar = cvarManager->getCvar("isReplay");
478
+ // bool isReplay = replayCvar.getBoolValue();
479
+ // if (isReplay == true) { Log("It's a replay"); return; }
480
+ //
481
+ // //Get Goal Scored automation url, transform, and convert to string
482
+ // CVarWrapper hagoalScoredCVar = cvarManager->getCvar("ha_goalScored");
483
+ // if (!hagoalScoredCVar) { return; }
484
+ // auto reqUrlgoalScored = cvarManager->getCvar("ha_goalScored");
485
+ // std::string reqUrlgoalScoredString = reqUrlgoalScored.getStringValue();
486
+ //
487
+ // LOG("Using Goal Scored Hook");
488
+ // SendCommands(reqUrlgoalScoredString);
489
+ //
490
+ // }
395
491
396
492
void RocketLeagueAssistant::OvertimeHook (std::string name)
397
493
{
0 commit comments