Some Coding assistance?

I’ve been hitting my head against the wall for a long while, mostly cause I can’t code very well, so I’m hoping I could get a bit of a push in the right direction. I have a game mode I invented before Workshop and I need to set a win condition of if 1 tracer is still alive at the end of the elimination round, team tracer wins instead of ties. Could someone nudge me in the right direction please?

Yeah pretty much. It’s a mode where 1 Anna is finding the 6 tracers and I need a better win condition for them as with the base game, 1 Anna and 1 Tracer is a draw when the round time is over. I’d like to flip that to a win instead.

I think my brain is starting to connect the dots.

Here:

rule("Win condition")
{
	event
	{
		Ongoing - Global;
	}

	conditions
	{
		Is Game In Progress == True;
		Is Between Rounds == True;
		Match Time == Null;
	}

	actions
	{
		If(Count Of(Filtered Array(Players On Hero(Hero(Tracer), Team 1), Is Alive(Current Array Element))) == 1 && Count Of(
			Filtered Array(Players On Hero(Hero(Ana), Team 2), Is Alive(Current Array Element))) == 1);
			Declare Round Victory(Team 1);
		Else If(Count Of(Filtered Array(Players On Hero(Hero(Tracer), Team 2), Is Alive(Current Array Element))) == 1 && Count Of(
				Filtered Array(Players On Hero(Hero(Ana), Team 1), Is Alive(Current Array Element))) == 1);
			Declare Round Victory(Team 2);
		Else If(Count Of(All Living Players(Team 1)) > Count Of(All Living Players(Team 2)));
			Declare Round Victory(Team 1);
		Else;
			Declare Round Victory(Team 2);
		End;
	}
}

You may need to set a custom match/round timer for each round and to disable Built-in Game/Match Completion, we don’t know how your mode functions over all, more details would be nice to know.

1 Like

Had to edit it a bit but looks pretty correct. So, it’s Team Grandma (1 Ana) vs 6 Tracers (Team Naughty Kids) and her goal is to put them all to bed before time’s up. And this I would of never found. Man this hurts my head XD I think this pushed it the right way, as I can prob make tweaks and what not from here. Really appreciate it.

1 Like

No problem if you still need help just join back here^^. So Ana puts Tracers into the bed, and these Tracers will die as a result of such naughty action :D? And Ana is unkillable? Just that we know either size of the Living Player Arrays would change so the conditions meet correctly^^.

1 Like

Yeah Ana’s unkillable. It’s a sort of “Hide and seek” but was heavily balanced since before the workshop was a thing~ Just needed to get the win conditions fixed up. Everyone that’s played it loves the mode so I wanted to balance it a bit more~

I’ve already removed the Built-in Mode Completion, so that’s working as intended (it’s funny when the round “ends” but nothing happens XD). The game mode is set to Elimination, no not sure if it’s not working as intended, atm

1 Like

It should work, in case of doubt or when it turns out other wise, just add disable the Built-in Mode Completion action before the if-elseif-else block in the action list, and after the block you can add enable the Built-in Mode Completion to make it all functioning again as default after each round^^.

1 Like

hm, So instead of having it always disabled, when the round should end normally (via kills), the conditions will fire the “in-between rounds” flag, and will prevent the round end by inserting the “disable” action?

Yeah but should trigger only if the rounds Match Time is able to hit Zero, which should only be the case if Ana were not capable of killing everyone in time, otherwise if she is capable of doing so the mode with Elimination type will work as a normal Elimination -since the rule will not trigger- which should be the desired result.

1 Like

Still having an issue with it coming to a draw x,x Tried punching this in several angles. Tried changing the condition values around and looking at it from other angles and can’t seem to get it…

edit: So I removed all conditions and Tracer instantly won with 1 Tracer. That’s a start~ I’ma keep poking the bear now.

Edit 2: I got it working! Here’s what I did, and the edits to your script~

rule("Win condition")
{
	event
	{
		Ongoing - Global;
	}

	conditions
	{
		Is Game In Progress == False;
		Is Between Rounds == True;
	}

	actions
	{
		Disable Built-In Game Mode Completion;
		If(Count Of(Filtered Array(Number Of Living Players(Team 1), Current Array Element)) == 1 && Count Of(Filtered Array(
			Number Of Living Players(Team 2), Is Alive(Current Array Element))) == 0);
			Declare Round Victory(Team 1);
			Set Match Time(0);
			Enable Built-In Game Mode Completion;
		Else If(Count Of(Filtered Array(Number Of Living Players(Team 1), Is Alive(Current Array Element))) == 1 && Count Of(
				Filtered Array(Number Of Living Players(Team 2), Is Alive(Current Array Element))) >= 1);
			Declare Round Victory(Team 2);
			Set Match Time(0);
			Enable Built-In Game Mode Completion;
		End;
	}
}

Here’s a copy of the game code if you or anyone wishes to try it. It’s pretty fun~ QS6FR

1 Like

The if’s looks weird and at some points wrong to me but if it works.

1 Like

Might be the part where the Filtered Array check for living players in a Value that already is the number of living players to then get the size of said array.

@KitBallard and you’re sure it’s working with the # of players you usually have and not just in a “1 Tracer v 1 Ana” scenario ?

1 Like

Yeah I was thinking that late last night and tested it today and it’s doubling the points for the score. The 1v1 works perfect though haha. I’ll work this out, now that I had a decent push, at the very least. Really appreciate the assistance though! If I can’t nail this down, I’ll be back for sure~

In case you need more push, here is a version that works and is tested within the suited enviroment:

rule("Rule 1")
{
	event
	{
		Ongoing - Global;
	}

	conditions
	{
		Is Game In Progress == True;
		(Match Time > 0 && Match Time <= 0.032) == True;
		Is True For Any(All Players(Team 2), Is Alive(Current Array Element)) == True;
	}

	actions
	{
		Wait(0.016, Ignore Condition);
		Disable Built-In Game Mode Completion;
		If(Count Of(Filtered Array(Players On Hero(Hero(Tracer), Team 2), Is Alive(Current Array Element))) == 1 && Count Of(
			Filtered Array(Players On Hero(Hero(Ana), Team 1), Is Alive(Current Array Element))) == 1);
			Declare Round Victory(Team 2);
		Else;
			Wait(0.016, Ignore Condition);
			Enable Built-In Game Mode Completion;
		End;
		Enable Built-In Game Mode Completion;
	}
}

Its actually the end result we accomplish by putting all our inputs and thoughts together^^.

3 Likes

Ran another test and I think the first ignore statement wasn’t needed. I deactivated it and worked per normal as with it on was still a draw. I’ll report back when I can get a full game for once. Most my friends have been busy XD Have updated the WS-Code if you got a group though