RATools icon indicating copy to clipboard operation
RATools copied to clipboard

Triggers and ResetIfs - always_false() appended to reset Alt Group

Open TwosomesUP opened this issue 1 year ago • 2 comments

I'm using the following function in one of my scripts, which should display a Challenge Icon during a boss fight, pause if any of the disallowed actions occur, and reset if the player is no longer fighting the boss:

function SakuraBossChallenge(){
    return IsValidSession() &&
        IsFightingBoss("Sakura") &&
        (
                trigger_when(IsPlayer1() && IsCharacter("P1", "Sakura") && PlayerDefeatedBoss()) ||
                trigger_when(IsPlayer2() && IsCharacter("P2", "Sakura") && PlayerDefeatedBoss())
        ) &&
        disable_when(IsFightingBoss("Sakura") && IsPlayer1() && PlayerUsedInput("P1", "ShootLeft"), IsOnStageSelect() || IsOnTitle()) &&
        disable_when(IsFightingBoss("Sakura") && IsPlayer1() && PlayerUsedInput("P1", "ShootRight"), IsOnStageSelect() || IsOnTitle()) &&
        disable_when(IsFightingBoss("Sakura") && IsPlayer2() && PlayerUsedInput("P2", "ShootLeft"), IsOnStageSelect() || IsOnTitle()) &&
        disable_when(IsFightingBoss("Sakura") && IsPlayer2() && PlayerUsedInput("P2", "ShootRight"), IsOnStageSelect() || IsOnTitle()) &&
        disable_when(IsFightingBoss("Sakura") && PlayerUsedBomb(), IsOnStageSelect() || IsOnTitle()) &&
        disable_when(IsFightingBoss("Sakura") && PlayerUsedContinue(), IsOnStageSelect() || IsOnTitle())
}

Looking at the generated logic, it's moving the ResetIfs to an Alt Group as expected, but's it's appending an always_false(). Which typically wouldn't be an issue, but because I'm also using Triggers, this prevents the Challenge Icon from appearing:

image

With that in mind, I was able to get around this by moving the resets to the first two Alt Groups with the Triggers:

function SakuraBossChallenge(){
    return IsValidSession() &&
        IsFightingBoss("Sakura") &&
        (
            (
                trigger_when(IsPlayer1() && IsCharacter("P1", "Sakura") && PlayerDefeatedBoss()) &&
                never(IsOnStageSelect()) && 
                never(IsOnTitle()) 
            ) ||
            (
                trigger_when(IsPlayer2() && IsCharacter("P2", "Sakura") && PlayerDefeatedBoss()) &&
                never(IsOnStageSelect()) && 
                never(IsOnTitle()) 
            )
        ) &&
        disable_when(IsFightingBoss("Sakura") && IsPlayer1() && PlayerUsedInput("P1", "ShootLeft")) &&
        disable_when(IsFightingBoss("Sakura") && IsPlayer1() && PlayerUsedInput("P1", "ShootRight")) &&
        disable_when(IsFightingBoss("Sakura") && IsPlayer2() && PlayerUsedInput("P2", "ShootLeft")) &&
        disable_when(IsFightingBoss("Sakura") && IsPlayer2() && PlayerUsedInput("P2", "ShootRight")) &&
        disable_when(IsFightingBoss("Sakura") && PlayerUsedBomb()) &&
        disable_when(IsFightingBoss("Sakura") && PlayerUsedContinue())
}

image

Which fixed my Challenge Icon issue, but I thought I'd report it just in case it's not working as intended.

TwosomesUP avatar Jun 18 '24 18:06 TwosomesUP

The always_false() prevents the alt from being true as a group with no logic is treated as true. As such, alt 3 is effectively just a holder for the ResetIfs.

I don't see any benefit for moving the ResetIfs out of alts 1 and 2 and into a separate alt 3, but I could understand the optimizer doing so to eliminate the redundancy. But then it would also be expected to eliminate the redundancy of the third and fourth trigger_when clauses by moving them to core - I'm guessing the ResetIfs get moved first, which confuses the optimizer into seeing that that redundant trigger_when clauses aren't in alt 3 and therefore aren't fully redundant.

Logically, everything seems the same to me. The challenge icon should appear when all conditions in core and either alt 1 or alt 2 (that are not trigger conditions) are true. The way things were moved around, the same logic should be true both in the left and right side of the diff. Could you clarify why the changes are causing a problem?

Jamiras avatar Jun 18 '24 19:06 Jamiras

No problems with the changes, just wanted to be sure the always_false in group 3 was expected. Other than there being redundancy with the group 1 and 2 resets, everything seems to be working with the changes I made.

TwosomesUP avatar Jun 18 '24 19:06 TwosomesUP