As for the path-finding since it’s A* based there’s no shot at avoiding calculating only part of the path without having the AI run into dead ends or loops.
However I’d at least recommend reducing the lookup set size for when the target location is known.
Like it being a health pack or the objective.
Pre-filter those locations so that even if you need to know the current closest node to the target it isn’t looking through all of them, even ones that are completely unreasonable.
Yeah that targeting would greatly profit off of just setting select things as variables on the Heroes and comparing the variables in the targeting system instead.
Similarly many of the Fade out’s like Doom’s Meteorstrike, Moira’s Fade, and Reaper’s wraith could be unified under the Phased out status.
Never mind, that’s already in it as well so all those checks are mostly redundant. (Disabled)
As a micro improvement, which might have some bigger change here due to the sheer amount of comparisons, you can Check most cases of Duplication & Non - Duplication Hero with a single Array Contains comparison.
Event Player.Targets = Append To Array(Filtered Array(All Living Players(Opposite Team Of(Team Of(Event Player))),
Is In Line of Sight(Eye Position(Event Player), Eye Position(Current Array Element), Barriers Do Not Block LOS)),
Filtered Array(All Living Players(Opposite Team Of(Team Of(Event Player))), Event Player.Seen_By_Memory > 0));
Unless I am mistaken, this has some redundancy in adding duplicate entries & needlessly filtering over an entire array
Else If((Array Contains(Array(Hero Of(Event Player), Hero Being Duplicated(Event Player)), Hero(Zenyatta)))
&& !Is In Alternate Form(Event Player));
Can Zenyatta even enter an “Alternate form” not that I know of, so could also be trimmed if true-
Any variation of Global.Targeting_Type == (0 || 2)
also shouldn’t work as intended as the result of the “Or” will always be true, allowing any non-zero “Targeting_Type” state to trigger this or its variations.
The final wait should also always be 1.5 thanks to the Max
which makes the Server Load math redundant.
Same with it in the pathfinding, except there it locks down to 0.5 then.
The highest the server can ideally reach without crashing, would probably be around 0.3 with that calculation.
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(All Living Players(Opposite Team Of(Team Of(
Event Player))), Distance Between(Event Player, Current Array Element) <= Global.Secondary_Sound_Max[Index Of Array Value(
Global.All_Heros, Hero Of(Current Array Element))] && Is Firing Secondary(Current Array Element)));
The Volume related blocks can be improved by directly Filtering the already made Targets array as this avoid needlessly iterating over targets which already aren’t in it anymore.
Technically not only them, but I am not dealing with rewriting all that as well…
And from the looks of it I think the stealth detection code is outdated due to Sombra’s reworks.
Most of the changes mentioned should be made in this, no guarantees the rule is still working as intended, though hard to tell if it was previously.
rule("Bot Target List")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
(Is Dummy Bot(Event Player) || Event Player.AI_Control_Player) == True;
Has Spawned(Event Player) == True;
Is Alive(Event Player) == True;
}
actions
{
Skip If(Array Contains(Array(0, 2), Global.Targeting_Type), 4);
If(Is True For Any(Players On Hero(Hero(Widowmaker), Team Of(
Event Player)), Is Using Ultimate(Current Array Element)));
Event Player.Targets = All Living Players(Opposite Team Of(Team Of(Event Player)));
Else;
Event Player.Targets = ((Event Player.Seen_By_Memory > 0) ? All Living Players(Opposite Team Of(Team Of(Event Player))) : Filtered Array(All Living Players(Opposite Team Of(Team Of(Event Player))),
Is In Line of Sight(Eye Position(Event Player), Eye Position(Current Array Element), Barriers Do Not Block LOS)));
Skip If(Array Contains(Array(0, 1), Global.Targeting_Type), 8);
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(All Living Players(Opposite Team Of(Team Of(
Event Player))), Has Status(Current Array Element, Hacked)));
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(All Living Players(Opposite Team Of(Team Of(
Event Player))), Distance Between(Event Player, Current Array Element) <= Global.Primary_Sound_Max[Index Of Array Value(
Global.All_Heros, Hero Of(Current Array Element))] && ((Is Duplicating(Current Array Element) ? Hero Being Duplicated(
Current Array Element) : Hero Of(Current Array Element)) == Hero(D.Va) || (Is Duplicating(Current Array Element)
? Hero Being Duplicated(Current Array Element) : Hero Of(Current Array Element)) == Hero(Illari) ? Is Button Held(
Current Array Element, Button(Primary Fire)) : Is Firing Primary(Current Array Element))));
Event Player.Targets = Filtered Array(Event Player.Targets, (Is Firing Secondary(Current Array Element) ? Distance Between(Event Player, Current Array Element) > Global.Secondary_Sound_Max[Index Of Array Value(
Global.All_Heros, Hero Of(Current Array Element))] : True));
Event Player.Targets = Filtered Array(Event Player.Targets, (Is Using Ability 1(Current Array Element) ? Distance Between(Event Player, Current Array Element) > Global.Ability1_Sound_Max[Index Of Array Value(
Global.All_Heros, Hero Of(Current Array Element))] : True));
Event Player.Targets = Filtered Array(Event Player.Targets, (Is Using Ability 2(Current Array Element) ? Distance Between(Event Player, Current Array Element) > Global.Ability2_Sound_Max[Index Of Array Value(
Global.All_Heros, Hero Of(Current Array Element))] : True));
Event Player.Targets = Filtered Array(Event Player.Targets, (Is Using Ultimate(Current Array Element) ? Distance Between(Event Player, Current Array Element) > Global.Ultimate_Sound_Max[Index Of Array Value(
Global.All_Heros, Hero Of(Current Array Element))] : True));
Event Player.Targets = Filtered Array(Event Player.Targets, (Is Moving(
Current Array Element) ? Distance Between(Event Player, Current Array Element) > (Is Crouching(Current Array Element) ? Global.Crouch_Walk_Sound_Max : Global.Walking_Sound_Max)[Index Of Array Value(
Global.All_Heros, Hero Of(Current Array Element))] : True));
Event Player.Targets = Filtered Array(Event Player.Targets, (Is Meleeing(Current Array Element) ? Distance Between(Event Player, Current Array Element) > Melee_Sound_Max[Index Of Array Value(
Global.All_Heros, Hero Of(Current Array Element))] : True));
If(Global.Invisible_Targeting == 0);
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Players On Hero(Hero(Sombra), Opposite Team Of(
Team Of(Event Player))),
Current Array Element.Invisible_Cooldown == 0 && Current Array Element.Is_Visible_Array == Empty Array && !Is Firing Secondary(
Current Array Element) && Distance Between(Eye Position(Event Player), Position Of(Current Array Element))
> 4 && Distance Between(Position Of(Event Player), Position Of(Current Array Element)) > 4));
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Players On Hero(Hero(Echo), Opposite Team Of(Team Of(
Event Player))), Hero Being Duplicated(Current Array Element) == Hero(Sombra) && Is Using Ability 1(Current Array Element)
&& !Is Firing Secondary(Current Array Element) && Distance Between(Eye Position(Event Player), Position Of(
Current Array Element)) > 4 && Distance Between(Position Of(Event Player), Position Of(Current Array Element)) > 4));
Else If(Global.Invisible_Targeting == 3);
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Players On Hero(Hero(Sombra), Opposite Team Of(
Team Of(Event Player))),
Current Array Element.Invisible_Cooldown == 0 && Current Array Element.Is_Visible_Array == Empty Array));
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Players On Hero(Hero(Echo), Opposite Team Of(Team Of(
Event Player))), Hero Being Duplicated(Current Array Element) == Hero(Sombra)
&& Current Array Element.Invisible_Cooldown == 0 && Current Array Element.Is_Visible_Array == Empty Array));
Else If(Global.Invisible_Targeting == 1);
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Players On Hero(Hero(Sombra), Opposite Team Of(
Team Of(Event Player))),
Current Array Element.Invisible_Cooldown == 0 && Current Array Element.Is_Visible_Array == Empty Array && !Is Firing Secondary(
Current Array Element)));
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Players On Hero(Hero(Echo), Opposite Team Of(Team Of(
Event Player))),
Current Array Element.Invisible_Cooldown == 0 && Current Array Element.Is_Visible_Array == Empty Array && !Is Firing Secondary(
Current Array Element) && Hero Being Duplicated(Current Array Element) == Hero(Sombra)));
Else;
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Players On Hero(Hero(Sombra), Opposite Team Of(
Team Of(Event Player))), Is Using Ability 1(Current Array Element) && Distance Between(Eye Position(Event Player), Position Of(
Current Array Element)) > 4 && Distance Between(Position Of(Event Player), Position Of(Current Array Element)) > 4));
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Players On Hero(Hero(Echo), Opposite Team Of(Team Of(
Event Player))), Is Using Ability 1(Current Array Element) && Hero Being Duplicated(Current Array Element) == Hero(Sombra)
&& Distance Between(Eye Position(Event Player), Position Of(Current Array Element)) > 4 && Distance Between(Position Of(
Event Player), Position Of(Current Array Element)) > 4));
End;
End;
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(All Players(All Teams), Has Status(
Current Array Element, Asleep) || Is In Spawn Room(Current Array Element) || Has Status(Current Array Element, Phased Out)
|| !Has Spawned(Current Array Element)));
Skip If(Global.Ignore_Abilitys == True, 5);
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Append To Array(Players On Hero(Hero(D.Va),
All Teams), Hero Being Duplicated(Event Player) == Hero(D.Va)), Is Firing Secondary(Current Array Element) && Is In View Angle(
Current Array Element, Eye Position(Event Player), 70)));
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Append To Array(Players On Hero(Hero(Zarya),
All Teams), Hero Being Duplicated(Event Player) == Hero(Zarya)), Is Using Ability 1(Current Array Element)));
disabled Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Append To Array(Players On Hero(Hero(Reaper),
All Teams), Hero Being Duplicated(Event Player) == Hero(Reaper)), Is Using Ability 1(Current Array Element)));
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Append To Array(Players On Hero(Hero(Genji),
All Teams), Hero Being Duplicated(Event Player) == Hero(Genji)), Is Using Ability 2(Current Array Element) && Is In View Angle(
Current Array Element, Eye Position(Event Player), 70)));
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Append To Array(Players On Hero(Hero(Sigma),
All Teams), Hero Being Duplicated(Event Player) == Hero(Sigma)), Is Using Ability 1(Current Array Element) && Is In View Angle(
Current Array Element, Eye Position(Event Player), 70)));
Skip If(Global.Team_Based_Targeting == False, 25);
If((Array Contains(Array(Hero Of(Event Player), Hero Being Duplicated(Event Player)), Hero(Zarya))) && Ability Cooldown(Event Player,
Button(Ability 2)) == Null);
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(All Living Players(Team Of(Event Player)),
Normalized Health(Current Array Element) < 0.400));
Else If((Array Contains(Array(Hero Of(Event Player), Hero Being Duplicated(Event Player)), Hero(Moira))) && Ability Resource(
Event Player, Button(Primary Fire)) > 0);
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(All Living Players(Team Of(Event Player)),
Normalized Health(Current Array Element) < (Count Of(Event Player.Targets) > 0 ? 0.800 : 1)));
Else If(Array Contains(Array(Hero Of(Event Player), Hero Being Duplicated(Event Player)), Hero(Mercy)));
Modify Player Variable(Event Player, Targets, Append To Array, Append To Array(Filtered Array(All Living Players(Team Of(
Event Player)), Normalized Health(Current Array Element) < 1), Filtered Array(All Players(Team Of(Event Player)), Is Dead(
Current Array Element))));
Else If((Array Contains(Array(Hero Of(Event Player), Hero Being Duplicated(Event Player)), Hero(Brigitte))) && Ability Charge(
Event Player, Button(Ability 2)) > 0);
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(All Living Players(Team Of(Event Player)),
Normalized Health(Current Array Element) < 1));
Else If(Array Contains(Array(Hero Of(Event Player), Hero Being Duplicated(Event Player)), Hero(Baptiste)));
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(All Living Players(Team Of(Event Player)),
Normalized Health(Current Array Element) < (Count Of(Event Player.Targets) > 0 ? 0.800 : 1)));
Else If(Array Contains(Array(Hero Of(Event Player), Hero Being Duplicated(Event Player)), Hero(Ana)));
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(All Living Players(Team Of(Event Player)),
Normalized Health(Current Array Element) < (Count Of(Event Player.Targets) > 0 ? 0.800 : 1)));
Else If((Array Contains(Array(Hero Of(Event Player), Hero Being Duplicated(Event Player)), Hero(Lúcio))) && !Is In Alternate Form(
Event Player));
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(All Living Players(Team Of(Event Player)),
Normalized Health(Current Array Element) < 1));
Else If(Array Contains(Array(Hero Of(Event Player), Hero Being Duplicated(Event Player)), Hero(Kiriko)));
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(All Living Players(Team Of(Event Player)),
Normalized Health(Current Array Element) < (Count Of(Event Player.Targets) > 0 ? 0.800 : 1)));
Else If((Array Contains(Array(Hero Of(Event Player), Hero Being Duplicated(Event Player)), Hero(Zenyatta)))
&& !Is In Alternate Form(Event Player));
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(Remove From Array(All Living Players(Team Of(
Event Player)), Event Player), Normalized Health(Current Array Element) < 1));
Skip If(!Entity Exists(First Of(Filtered Array(Event Player.Targets, Team Of(Current Array Element) == Team Of(Event Player)))),
1);
Event Player.Targets = First Of(Filtered Array(Sorted Array(Event Player.Targets, Distance Between(Event Player,
Current Array Element) * Health(Current Array Element)), Team Of(Current Array Element) == Team Of(Event Player)))
== Event Player.Zen_Orb_Target ? Filtered Array(Event Player.Targets, Team Of(Current Array Element) != Team Of(Event Player))
: Event Player.Targets;
Else If(Array Contains(Array(Hero Of(Event Player), Hero Being Duplicated(Event Player)), Hero(Lifeweaver)));
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(All Living Players(Team Of(Event Player)),
Normalized Health(Current Array Element) < (Count Of(Event Player.Targets) > 0 ? 0.800 : 1)));
Else If(Array Contains(Array(Hero Of(Event Player), Hero Being Duplicated(Event Player)), Hero(Illari)));
Modify Player Variable(Event Player, Targets, Append To Array, Filtered Array(All Living Players(Team Of(Event Player)),
Normalized Health(Current Array Element) < (Count Of(Event Player.Targets) > 0 ? 0.800 : 1)));
End;
Modify Player Variable(Event Player, Targets, Remove From Array By Value, Append To Array(Event Player, Filtered Array(All Players(
All Teams), !Has Spawned(Current Array Element))));
disabled Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Append To Array(Players On Hero(Hero(Doomfist),
All Teams), Hero Being Duplicated(Event Player) == Hero(Doomfist)), Is Using Ultimate(Current Array Element)));
disabled Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Append To Array(Players On Hero(Hero(Moira),
All Teams), Hero Being Duplicated(Event Player) == Hero(Moira)), Is Using Ability 1(Current Array Element)));
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Append To Array(Players On Hero(Hero(Mei),
All Teams), Hero Being Duplicated(Event Player) == Hero(Mei)), Is Using Ability 1(Current Array Element)));
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Append To Array(Players On Hero(Hero(Zenyatta),
All Teams), Hero Being Duplicated(Event Player) == Hero(Zenyatta)), Is Using Ultimate(Current Array Element)));
disabled Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(Append To Array(Players On Hero(Hero(Tracer),
All Teams), Hero Being Duplicated(Event Player) == Hero(Tracer)), Is Using Ability 2(Current Array Element)));
Event Player.Targets = Remove From Array(Event Player.Targets, Filtered Array(All Living Players(Opposite Team Of(Team Of(
Event Player))), !Is On Objective(Current Array Element) && Is Communicating Any Emote(Current Array Element)));
Event Player.Target_Order = Sorted Array(Event Player.Targets, Distance Between(Event Player, Current Array Element) * Health(
Current Array Element) - (Team Of(Current Array Element) == Team Of(Event Player) ? (Is In Line of Sight(Eye Position(
Event Player), Eye Position(Current Array Element), Barriers Do Not Block LOS) ? 1000 : 0) : 0));
If(!Entity Exists(First Of(Event Player.Target_Order)));
Press Button(Event Player, Button(Reload));
End;
Wait(Max(Server Load / 105, 1.5), Ignore Condition);
Loop If Condition Is True;
}
}