Zezombye / overpy

High-level language for the Overwatch Workshop with support for compilation and decompilation.
GNU General Public License v3.0
175 stars 25 forks source link

Macros don't override old macros with the same name #322

Open piousdeer opened 1 year ago

piousdeer commented 1 year ago
rule "1":
  @Event eachPlayer
  #!define _condition eventPlayer.isAlive()
  @Condition _condition
  smallMessage(eventPlayer, "Alive")
  waitUntil(not _condition, 9999)
  smallMessage(eventPlayer, "Aliven't")

rule "2":
  @Event eachPlayer
  #!define _condition eventPlayer.getCurrentHero() == Hero.GENJI
  @Condition _condition
  smallMessage(eventPlayer, "Genji")
  waitUntil(not _condition, 9999)
  smallMessage(eventPlayer, "Genjin't")

Expected output:

rule ("1") {
    event {
        Ongoing - Each Player;
        All;
        All;
    }
    conditions {
        Is Alive(Event Player) == True;
    }
    actions {
        Small Message(Event Player, Custom String("Alive", Null, Null, Null));
        Wait Until(Is Dead(Event Player), 9999);
        Small Message(Event Player, Custom String("Aliven't", Null, Null, Null));
    }
}

rule ("2") {
    event {
        Ongoing - Each Player;
        All;
        All;
    }
    conditions {
        Hero Of(Event Player) == Hero(Genji);
    }
    actions {
        Small Message(Event Player, Custom String("Genji", Null, Null, Null));
        Wait Until(Not(Compare(Hero Of(Event Player), ==, Hero(Genji))), 9999);
        Small Message(Event Player, Custom String("Genjin't", Null, Null, Null));
    }
}

Actual output:

rule ("1") {
    event {
        Ongoing - Each Player;
        All;
        All;
    }
    conditions {
        Is Alive(Event Player) == True;
    }
    actions {
        Small Message(Event Player, Custom String("Alive", Null, Null, Null));
        Wait Until(Is Dead(Event Player), 9999);
        Small Message(Event Player, Custom String("Aliven't", Null, Null, Null));
    }
}

rule ("2") {
    event {
        Ongoing - Each Player;
        All;
        All;
    }
    conditions {
        Is Alive(Event Player) == True;
    }
    actions {
        Small Message(Event Player, Custom String("Genji", Null, Null, Null));
        Wait Until(Is Dead(Event Player), 9999);
        Small Message(Event Player, Custom String("Genjin't", Null, Null, Null));
    }
}