Shared Ability Charges

Right, so as to not create confusion, I’m thinking along the line of the Zarya OW2 rework (reason I want to know how to do this) and the Zarya April fools change (Sam thing). Is there anyway in the workshop I can do either of these relatively ‘easily’

a.) Create ability charges (I have seen this but it didn’t use the actual charge UI, like Tracers for example)

b.) Make them shared between abilities

I’m trying to make all the OW2 changes in a workshop mode but I’m relatively new to the workshop so any help is welcome!

variables
{
	global:
		0: Ability_Cooldown

	player:
		0: Ability_Charges
		1: Ability_Cooldown
}

rule("Global Setup")
{
	event
	{
		Ongoing - Global;
	}

	actions
	{
		Global.Ability_Cooldown = 8;
		Create HUD Text(Filtered Array(Local Player, Hero Of(Current Array Element) == Hero(Zarya)), Null, Null, Custom String(
			"Ability Charges: {0}\r\nNext Charge In: {1}", Local Player.Ability_Charges, Local Player.Ability_Cooldown), Right, 0, Color(
			White), Color(White), Color(White), Visible To and String, Default Visibility);
	}
}

rule("Player Setup")
{
	event
	{
		Ongoing - Each Player;
		All;
		Zarya;
	}

	conditions
	{
		Is Alive(Event Player) == True;
	}

	actions
	{
		Event Player.Ability_Charges = 2;
	}
}

rule("Ability 1 Charge")
{
	event
	{
		Ongoing - Each Player;
		All;
		Zarya;
	}

	conditions
	{
		Ability Cooldown(Event Player, Button(Ability 1)) != Null;
		Event Player.Ability_Charges > 0;
	}

	actions
	{
		Event Player.Ability_Charges -= 1;
	}
}

rule("Ability 2 Charge")
{
	event
	{
		Ongoing - Each Player;
		All;
		Zarya;
	}

	conditions
	{
		Ability Cooldown(Event Player, Button(Ability 2)) != Null;
		Event Player.Ability_Charges > 0;
	}

	actions
	{
		Event Player.Ability_Charges -= 1;
	}
}

rule("Ability Cooldown")
{
	event
	{
		Ongoing - Each Player;
		All;
		Zarya;
	}

	conditions
	{
		Event Player.Ability_Charges > 0;
		(Ability Cooldown(Event Player, Button(Ability 1)) != 0 || Ability Cooldown(Event Player, Button(Ability 2)) != 0) == True;
	}

	actions
	{
		Set Ability Cooldown(Event Player, Button(Ability 1), 0);
		Set Ability Cooldown(Event Player, Button(Ability 2), 0);
	}
}

rule("Set Abilities on Cooldown")
{
	event
	{
		Ongoing - Each Player;
		All;
		Zarya;
	}

	conditions
	{
		Event Player.Ability_Charges == 0;
	}

	actions
	{
		Set Ability Cooldown(Event Player, Button(Ability 1), Event Player.Ability_Cooldown);
		Set Ability Cooldown(Event Player, Button(Ability 2), Event Player.Ability_Cooldown);
	}
}

rule("Recharge Charges")
{
	event
	{
		Ongoing - Each Player;
		All;
		Zarya;
	}

	conditions
	{
		Event Player.Ability_Charges != 2;
	}

	actions
	{
		Event Player.Ability_Cooldown = Global.Ability_Cooldown;
		Chase Player Variable At Rate(Event Player, Ability_Cooldown, 0, 1, None);
		Wait Until(!Event Player.Ability_Cooldown, 99999);
		Event Player.Ability_Charges += 1;
		Loop If Condition Is True;
	}
}

Making the actual UI for Ability charges appear is impossible as of now, sadly.

Thankyou so much! Does the crossing out of part of the original reply mean that there is some UI, even if it isn’t the actual UI?

Thanks for the help!

Curious to know if anyone was able to make it so that Zarya could use Projected Barrier (e) twice simultaneously on different targets. I can make the charges work but I can’t quite figure out recasting while the barrier is in use. I tried different methods of canceling, re-enabling, adjusting timers, and even respawning the hero while copying their data, but I’m not sure. The only other thing I can think of is maybe using a hidden bot but I’d like to maintain the animation from my perspective, maybe there is some trick in doing so. I just wanted to try to maintain visual and functional similarity as much as possible. If anyone has any suggestion, please let me know, thank you!

use this code to see, Y4AY9

1 Like

This is actually the most insane code I’ve ever played, thankyou so much

1 Like

just know it wasn’t made by me, it was made by someone named dab. this is the link to their page https://workshop.codes/Y4AY9/comments

1 Like

Oh yeah, this is the one that KarQ shared on his video, I took a look at it earlier. Sadly, it still has the same issue I’m trying to tackle and that is being able to use the E skill on two heroes at the same time like they do on OW2 or April Fools version. When the first barrier is cast, in the duration the hero has a bubble on them, it locks out the hotkey making it unable to reuse or reset the skill. I’ll keep fiddling though, thank you!

Interesting thing to note, their version cuts damage in half on tanks and makes up the difference to handle ultimate charge passive reduction. My version like cuts ultimate charge in half on everyone and adds to it when dealing damage to non-tanks. They definitely went about it in a more efficient way xD

2 Likes