So basically, I have been trying to make it so when Reinhard’s shield is out, he takes no damage. After some testing I came up with this:
rule("Reinhardt Shielding")
{
event
{
Ongoing - Each Player;
All;
Reinhardt;
}
conditions
{
Is Firing Secondary(Event Player) == True;
}
actions
{
Set Damage Received(Event Player, 0);
Wait Until(!Is Firing Secondary(Event Player), 100000000);
Set Damage Received(Event Player, 100);
}
}
However, it does not always work for some reason,n and I do not really understand the code myself, so I do not know how to fix that, I would appreciate if anyone knows how I would make it always work because I have been testing for a while and I cannot find a solution.
The easiest way to do this is to create two separate rules, like so:
rule("Rule 1")
{
event
{
Ongoing - Each Player;
All;
Reinhardt;
}
conditions
{
Is Firing Secondary(Event Player) == True;
}
actions
{
Set Damage Received(Event Player, 0);
}
}
rule("Rule 2")
{
event
{
Ongoing - Each Player;
All;
Reinhardt;
}
conditions
{
Is Firing Secondary(Event Player) == False;
}
actions
{
Set Damage Received(Event Player, 100);
}
}
Update: The Weird Part is, when I test your code, it works fine. I’m not sure what’s going on on your end that’s causing it to bug out. That said, the two rule method hasn’t let me down yet, so if the Wait Until function is giving you trouble I’d try that instead and see if that fixes your issue
Update to the Update: Just for fun, I decided to test the same code you used but instead of Is Firing Secondary I used the Is Button Held ( Secondary Fire) and had great success with that, I was even able to disable Rein’s shield entirely and still get the invincibility to trigger while secondary fire was being held, I’ll put the code down below
settings
{
modes
{
disabled Clash
{
Capture Speed Modifier: 45%
Limit Roles: 1 Tank 2 Offense 2 Support
}
disabled Control
{
Limit Roles: 1 Tank 2 Offense 2 Support
}
disabled Escort
{
Limit Roles: 1 Tank 2 Offense 2 Support
}
disabled Flashpoint
{
Limit Roles: 1 Tank 2 Offense 2 Support
}
disabled Hybrid
{
Limit Roles: 1 Tank 2 Offense 2 Support
}
disabled Push
{
Limit Roles: 1 Tank 2 Offense 2 Support
}
Team Deathmatch
{
Enable Perks: On
}
}
heroes
{
General
{
Reinhardt
{
Barrier Field: Disabled
}
}
}
}
rule("Rule 1")
{
event
{
Ongoing - Global;
}
conditions
{
Is Assembling Heroes == True;
}
actions
{
Set Match Time(0);
}
}
rule("Rule 2")
{
event
{
Ongoing - Each Player;
All;
Reinhardt;
}
conditions
{
Is Button Held(Event Player, Button(Secondary Fire)) == True;
}
actions
{
Set Damage Received(Event Player, 0);
Wait Until(!Is Button Held(Event Player, Button(Secondary Fire)), 99999);
Set Damage Received(Event Player, 100);
}
}
Thank you so much for the answer! I was stuck on this problem for a while and I really appreciate the help!
It still does not work 100 percent of the time though for some reason, and also the second solution you made works even while the shield is down which is not what I intended. It might just be a workshop issue though.
well thats why you need a second condition when doing Is Button Held
for Ability Cooldown == 0
or Ability cooldown == null
(same thing since null is 0)
but it wont stop there, you’ll also need to account for other things, is the player is dead, if they are hacked or asleep, knocked down, stunned… etc…
i usually do a Is True for All
fill it with the conditions as the array values (makes it easy to edit), and in the condition for the Is True for All
just put Current Array Element
and its like doing a giant dynamic And
statement.
Thank you for this advice, however i cannot find a good way to turn off the invincibility after its enabled, could you explain how I would do that?
either a second rule with a Is True for Any
using the same conditions but reversed, you can just do !Current Array Element
to reverse it instead of reversing each condition in the array.
or you can also do that as an Wait Until(Is True for Any
(i personally use Wait Until)
it takes a while to fill the same array multiple times unless you edit it externally, so i usually do that. write it once & copy it, paste it into a Notepad or VS-Code, swap the All/Any around then copy paste that back in. its the fastest & simplest way to reverse it.
If you don’t mind sharing the whole code I could take a look, I don’t know that I’d find anything useful but you never know. Off the top of my head, I know some of the scripts I’ve written in custom games don’t work great unless you add a wait() function. I would try just adding a 0.25 second delay at the top of the action sequence, with abort when false selected and see if that makes it more reliable.
How would i detect cooldown and true/false variables in the same is true for all statement?
like i said, you just need to fill the array with conditions. anything that returns True/False
if something doesn’t return True/False
just put it in a Compare
to make it return True/False
Is true for all/any are like running a ForEach loop, you have the elements of the array & the condition each element need to pass…
so if the condition is Current Array Element
then its just comparing it with the array element itself being true or false.
so with the condition being Current Array Element
you can put something like Compare(Ability Cooldown(Button(Ability 1)) == null)
into the array of it and then it’ll return true if the cooldown is null/0.
same for any other added elements to the array, like Compare(Has Status(Event Player, Asleep) == false))
(which is also the same as doing !Has Status(Event Player, Asleep)
)