• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Trigger] Event doesn't activate properly

Level 4
Joined
Mar 9, 2023
Messages
37
Hello again!
At the end of my map there are two triggers that become enabled. They check if the fight is over, and to see who the winner who the winner is. I need help getting the triggers to guaranteed trigger, and ideally not be too hasty in case they've got Reincarnation. These triggers leak, I know, that's not what I need help with.

Trigger checking for hero win:
  • CinematicWinHeroes
    • Events
      • Time - Every 6.00 seconds of game time
    • Conditions
      • (BOSSARENA <gen> contains ChosenHeroUnit) Equal to False
    • Actions
      • Trigger - Turn off Remove <gen>
      • Player Group - Pick every player in Thralls and do (Actions)
        • Loop - Actions
          • Set VariableSet Points[(Player number of (Picked player))] = (Points[(Player number of (Picked player))] + 10)
      • Trigger - Run CinematicEndGood <gen> (ignoring conditions)
      • Trigger - Turn off (This trigger)
Trigger checking for traitor win:
  • CinematicWinTraitor
    • Events
      • Time - Every 6.00 seconds of game time
    • Conditions
      • (BOSSARENA <gen> contains ChosenHeroUnit) Equal to True
    • Actions
      • Set VariableSet AliveHeroes = 0
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is dead) Equal to False
            • Then - Actions
              • Set VariableSet AliveHeroes = (AliveHeroes + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AliveHeroes Less than or equal to 1
        • Then - Actions
          • Trigger - Run CinematicEndBad <gen> (ignoring conditions)
          • Trigger - Turn off Remove <gen>
          • Set VariableSet Points[(Player number of (Owner of ChosenHeroUnit))] = (Points[(Player number of (Owner of ChosenHeroUnit))] + (Players x 10))
          • Trigger - Turn off (This trigger)
        • Else - Actions
ChosenHeroUnit is defined in a previous trigger, it is the Traitor Hero.
Thralls is each player except for the Traitor Player.
Remove trigger handles Hero deaths, where when they die the unit is saved and removed.

What currently happens is that when the Heroes are supposed to win, the event doesn't kick off. The Traitor win event is easier to kick off. I've tried a few different conditions, like checking if the ChosenHeroUnit is dead, which I think was a bust, and something more I can't remember.

I'm currently thinking that a solution could be to make the event a Unit Dies. Then run a timer for a new trigger, checking something about the ChosenHeroUnit. But it's a very hard event to test, so I can't try out all wacky solutions. Are there any good solutions that come to mind?
 
Level 12
Joined
Jan 10, 2023
Messages
191
I think you are right to use a Unit Dies event, periodic checks could work fine, but it's best to use the most relevant event IMO.

I would do a unit dies event and then start a timer that will give the reincarnation time a buffer, I there may be a better way to track reincarnation, but I'm not aware of it.

On one occasion, I supplemented reincarnation with a (hidden) hydra-summon ability and made it spawn a single dummy when the unit died.
When a unit dies I start a timer, Then if a unit summons a unit and the summoned unit is equal to the reincarnation dummy, I would turn off the timer before it expire. If the timer expires, the unit does not have reincarnation and I treated it like a dead unit.
 
Level 4
Joined
Mar 9, 2023
Messages
37
I went ahead with what you suggested.

Not like your hydra example hehe, that one was pretty wild.
  • CinematicWinHeroes
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Dying unit) Equal to ChosenHeroUnit
    • Actions
      • Countdown Timer - Start IsAliveTimer as a One-shot timer that will expire in 10.00 seconds
  • CinematicWinHeroesCheck
    • Events
      • Time - IsAliveTimer expires
    • Conditions
      • (ChosenHeroUnit is alive) Equal to False
    • Actions
      • Trigger - Turn off Remove <gen>
      • Player Group - Pick every player in Thralls and do (Actions)
        • Loop - Actions
          • Set VariableSet Points[(Player number of (Picked player))] = (Points[(Player number of (Picked player))] + 10)
      • Trigger - Run CinematicEndGood <gen> (ignoring conditions)
      • Trigger - Turn off CinematicWinHeroes <gen>
      • Trigger - Turn off (This trigger)
It turned out simpler than I thought. I considered just making Jass version to keep it in the same trigger, but I'm pretty bad at conditions. No idea if it works just yet, but it looks good imo.
 
Level 12
Joined
Jan 10, 2023
Messages
191
I think it is definitely worth exploring JASS (usually I see Lua recommended over JASS for a few good reasons, I just like JASS because I haven't learned Lua and JASS is the first code language I really sank into beyond very amateur java)

It isn't very hard and you get a lot more control. For example, timers won't need triggers at all, they just run a code when the timer runs up.

I know that dummy concept was one of my first moves with JASS, so it is a little bit out there, but if you wanted something that left the player unable to detect the timing.
for example, whether there is reincarnation or not, the player waits 10 seconds, but with that dummy system, it was quicker than the eye can see it, so I liked that the player doesn't notice what's happening.

Definitely can be done better!
 
Level 12
Joined
Jan 10, 2023
Messages
191
A unit dying with Reincarnation will not fire the "A unit dies" Event. It doesn't actually die.

In fact, you need a special setup to detect when Reincarnation happens (It involves the Defend ability and detecting the "undefend" order).
That MIGHT be why I did the hydra thing as a work around... I knew I had some decent (albeit unenlightened) reason for it.

Thanks Uncle, this will help me from spending hours figuring that out the hard way.
 
Top