Overwatch-Script-To-Workshop icon indicating copy to clipboard operation
Overwatch-Script-To-Workshop copied to clipboard

Calling methods inside conditions will not refresh the argument variables before calling

Open Alexejhero opened this issue 2 years ago • 1 comments

If you call a custom method from a condition, the condition will be evaluated before the body of the rule, which sets the required arguments variables

rule: "Example"
Event.OnDeath
if (IsGameInProgress())
if (Attacker() != Victim())
if (IsWinning(Attacker()))
{
	// whatever
}

compiles to

rule("Example")
{

    event
    {
        Player died;
        All;
        All;
    }

    conditions
    {
        Is Game In Progress == True;
        Attacker != Victim;
        Value In Array(Global Variable(Scores), Slot Of(Player Variable(Event Player, Player))) >= Subtract(Count Of(Global Variable(HeroList)), 1);
    }

    // Action count: 10
    actions
    {
        Set Player Variable(Event Player, Player, Attacker);
		// whatever
    }
}

As such, this condition is evaluated incorrectly.

Alexejhero avatar Oct 28 '22 14:10 Alexejhero

Sorry for the late response! You can use in parameters or macros so that the parameters are not set to a value.

// These do the exact same thing
// Macro
Boolean X(Number value): value + 2;

// Function
Boolean X(in Number value) {
    // This will output correctly as long as nothing inside the method generates actions.
    return value + 2;
}

OSTW will need to ensure that users don't generate actions in conditions

ItsDeltin avatar Feb 14 '23 00:02 ItsDeltin