Workshop help with code

I really wanna make a custom mode where everyone has stupid abilities or gimmicks but i have never used the workshop before, can someone help me with my current project by telling me what to do?
Currently i want to make Sigmas ult stun anyone who gets slammed by it.

Are you wanting to learn how to use the Workshop? Or just have someone make you the hero gimmicks per request?

Here’s a quick rule i threw together for Sig. Use whatever one makes more since to you. But make sure BOTH aren’t active at the same time as they Will conflict.

rule("Sigma Ult Stun - Simple")
{
	event
	{
		Player Dealt Damage;
		All;
		Sigma;
	}

	conditions
	{
		Is Using Ultimate(Event Player) == True;
	}

	actions
	{
		Modify Player Variable(Event Player, A, Append To Array, Victim);
		Wait(0.016, Restart When True);
		Wait Until(!Is Using Ultimate(Event Player), 10);
		Set Status(Event Player.A, Event Player, Knocked Down, 5);
		Wait(1, Restart When True);
		Event Player.A = Empty Array;
	}
}

rule("Sigma Ult Stun - Complex")
{
	event
	{
		Ongoing - Each Player;
		All;
		Sigma;
	}

	conditions
	{
		Is Using Ultimate(Event Player) == True;
	}

	actions
	{
		Wait Until(Is Button Held(Event Player, Button(Primary Fire)), 6);
		Abort If(!Is Using Ultimate(Event Player));
		Event Player.A = Ray Cast Hit Position(Eye Position(Event Player), Eye Position(Event Player) + Facing Direction Of(Event Player)
			* 35, Null, All Players(All Teams), False);
		If(Distance Between(Eye Position(Event Player), Event Player.A) >= 35);
			Event Player.B = Ray Cast Hit Position(Event Player.A, Event Player.A + Down * 40, Null, All Players(All Teams), False);
			Event Player.A = Event Player.B;
		End;
		Event Player.B = Remove From Array(Players Within Radius(Event Player.A, 8, Opposite Team Of(Team Of(Event Player)), Off),
			All Dead Players(All Teams));
		Wait Until(!Is Using Ultimate(Event Player), 10);
		Skip If(Has Status(Event Player, Hacked) || Has Status(Event Player, Stunned), 1);
		Set Status(Event Player.B, Event Player, Knocked Down, 5);
		Wait(0.250, Ignore Condition);
		Event Player.B = Null;
	}
}

Is the array really necessary in the ‘simple sigma ult’?
I mean wouldn’t this rule apply to every victim regardless?

Yes legal context values are Attacker and Victim, and apply to each player that would recieve damage after the slam and trigger the damage dealt event executed by the Sigma player who is the Attacker.

1 Like

At least in early Workshop, Player Dealt Damage would struggle for AoE damage. When the damage occurs, actions affecting ‘Victim’ would only work on one player hit by the damage and not all of them. This may have changed and work fine, but I’ve always used Player Took Damage since.

The array is there because Play Dealt Damage only works for 1 player at a time & since Flux can hit multiple players, the Workshop script would only trigger for 1 person. So by adding the Player’s who took damage to an Array, you can Then use the Array to do…whatever. But it too has it’s limitations…
& the problem with Player Took Damage is this event triggers Every time ANYONE takes damage. Even IF conditions are not met to execute the Actions section of the Rule, the Workshop event viewer will show the Rule was triggers but Conditions weren’t met. While in This specific case it isn’t an issue because the game isn’t very big. In larger games w/ multiple Player Took Damage rules, i’ve noticed increased server loads because of this… Player Dealt Damage can be set to a specific hero. Thus, the rule won’t trigger unless specific hero dealt damage, so lower server load.

i need to admit Sigma is a tricky case and seems special, but the most part of the statement you made is false, the context values in conjunction to the events work as intended and with some testing i found a convenient way to get OP’s desired behaviour without using an Array for the special candidate Sigma:

rule("Rule 1")
{
	event
	{
		Player Dealt Damage;
		All;
		Sigma;
	}

	conditions
	{
		Event Ability == Button(Ultimate);
		Event Damage >= Health(Victim) / 2;
	}

	actions
	{
		Set Status(Victim, Attacker, Knocked Down, 5);
	}
}

The event will trigger after the slam phase of Flux, the event ability is still considered as Button Ultimate and due we know that the damage dealt is always half the Vicitms/Players HP, we can differenciate between the little damage done at lifting with Flux and the slamming down part, the lifiting part is ignored thanks to the additional comparision of event damage. If we don’t do that the rule will trigger for the both damage phases which we do not want to happen.

1 Like

Seems to work…how would you fix the issue w/ players who are already less than half HP when picked up from Flux, being stunned?
Or players like Hog, Orisa, Torb?, Queen? using an ability to mitigate the event damage? Take a Breather, Fortify, Overload? Shout?

Well that extends the complexity in case of Sigma, this actually is an issue i tested again and as you said if they have already less than half HP the lifitng triggers the status application again, so we end up still finding a way to skip the lifting damage part of Flux. Well surprisingly i found a away using a weird Turing machine approach, this solution is also dedicated to Alan Turing, god bless him in heaven, here it goes:

variables
{
	player:
		0: FluxPhase
}

rule("Rule 1")
{
	event
	{
		Player Dealt Damage;
		All;
		Sigma;
	}

	conditions
	{
		Event Ability == Button(Ultimate);
	}

	actions
	{
		"Change Phase from 0 to 1 when first part of Flux deals damage, after skipping the Phase changes from -1 to 0."
		Victim.FluxPhase += 1;
		"Skips the next action, which is the status applying, if phase is 1."
		Skip If(Victim.FluxPhase == 1, 1);
		"Will only execute when Phase is 0."
		Set Status(Victim, Attacker, Knocked Down, 5);
		"Changes the Phase after lifting from 1 to -1, and after slamming back to 0."
		Victim.FluxPhase = Victim.FluxPhase - 2 == -2 ? 0 : Victim.FluxPhase - 2;
	}
}

Tell me if it causes any further problems.

2 Likes

Yeah a guarding rule can make sure of reseting the variable.

2 Likes

I ended up forgetting about this because I figured something out myself (not very well, but it worked) but I am trying to learn it. I’m just not very good with variables.