• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

[Spell] Why is this trigger reacting to a unit dying when it's OFF at the time of death

Status
Not open for further replies.
Level 12
Joined
May 16, 2020
Messages
660
Hi guys,

Below you find 2 triggers which run when a hero dies.
I want the first trigger to run only when a hero dies the first time ("First Blood"). Upon triggering First Blood, this first trigger turns OFF, and turns ON the second trigger, which going forward keeps track of hero kills.

However, for some reason the second trigger still registers the kill that happens the first time, even though it is OFF at the time of the unit dying.

  • Kill Streak First Blood
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set VariableSet KA_Killer = (Killing unit)
      • Set VariableSet KA_Dying = (Triggering unit)
      • Set VariableSet KA_PlayerNumberKiller = (Player number of (Owner of KA_Killer))
      • Set VariableSet KA_PlayerNumberDying = (Player number of (Owner of KA_Dying))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of KA_Killer) is in Players.) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • KA_Killer Equal to KA_Dying
            • Then - Actions
              • Game - Display to (All players) the text: (PlayerNames[KA_PlayerNumberKiller] + denied himself!)
              • Skip remaining actions
            • Else - Actions
          • -------- --------
          • Set VariableSet KA_Bounty = ((110 + ((Hero level of KA_Dying) x 8)) + 150)
          • Sound - Play firstblood <gen>
          • Game - Display to (All players) the text: ((PlayerNames[KA_PlayerNumberKiller] + just pawned ) + ((PlayerNames[KA_PlayerNumberDying] + 's head for ) + (|cffffcc00 + ((String(KA_Bounty)) + |r gold!))))
          • Game - Display to (All players) the text: (PlayerNames[KA_PlayerNumberKiller] + just drew |cffff0000First Blood|r!)
          • Player - Add KA_Bounty to (Owner of KA_Killer).Current gold
          • -------- --------
          • Set VariableSet KA_CounterKill[KA_PlayerNumberKiller] = (KA_CounterKill[KA_PlayerNumberKiller] + 1)
          • -------- --------
          • Trigger - Turn off (This trigger)
          • Trigger - Turn on Kill Streak System <gen>
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • X_LastAttacker[KA_PlayerNumberDying] Equal to 0
            • Then - Actions
              • Game - Display to (All players) the text: (PlayerNames[KA_PlayerNumberKiller] + was executed.)
            • Else - Actions
              • -------- --------
              • Set VariableSet KA_Bounty = ((110 + ((Hero level of KA_Dying) x 8)) + 150)
              • Sound - Play firstblood <gen>
              • Game - Display to (All players) the text: ((PlayerNames[X_LastAttacker[KA_PlayerNumberDying]] + just pawned ) + ((PlayerNames[KA_PlayerNumberDying] + 's head for ) + (|cffffcc00 + ((String(KA_Bounty)) + |r gold!))))
              • Game - Display to (All players) the text: (PlayerNames[X_LastAttacker[KA_PlayerNumberDying]] + just drew |cffff0000First Blood|r!)
              • Player - Add KA_Bounty to (Owner of KA_Killer).Current gold
              • -------- --------
              • Set VariableSet KA_CounterKill[KA_PlayerNumberKiller] = (KA_CounterKill[KA_PlayerNumberKiller] + 1)
              • -------- --------
              • Game - Display to (All players) the text: TEST: END MESSAGE A...
              • Trigger - Turn off (This trigger)
              • Trigger - Turn on Kill Streak System <gen>
  • Kill Streak System
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • (Player number of (Owner of (Killing unit))) Greater than 0
      • (Player number of (Owner of (Killing unit))) Less than or equal to 12
      • (Player number of (Owner of (Triggering unit))) Not equal to 13
    • Actions
      • Game - Display to (All players) the text: WHY IS THIS TRIGGER...
      • Set VariableSet KA_Killer = (Killing unit)
      • Set VariableSet KA_Dying = (Triggering unit)
      • Set VariableSet KA_PlayerNumberKiller = (Player number of (Owner of KA_Killer))
      • Set VariableSet KA_PlayerNumberDying = (Player number of (Owner of KA_Dying))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KA_Killer Equal to KA_Dying
        • Then - Actions
          • Game - Display to (All players) the text: (PlayerNames[KA_PlayerNumberKiller] + denied himself!)
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • Set VariableSet KA_Bounty = ((110 + ((Hero level of KA_Dying) x 8)) + (KA_CounterKillStreak[KA_PlayerNumberDying] x 60))
      • Game - Display to (All players) the text: ((PlayerNames[KA_PlayerNumberKiller] + just pawned ) + ((PlayerNames[KA_PlayerNumberDying] + 's head for ) + (|cffffcc00 + ((String(KA_Bounty)) + |r gold!))))
      • Player - Add KA_Bounty to (Owner of KA_Killer).Current gold
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KA_CounterKill[KA_PlayerNumberKiller] Less than 10
        • Then - Actions
          • Set VariableSet KA_CounterKill[KA_PlayerNumberKiller] = (KA_CounterKill[KA_PlayerNumberKiller] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • KA_CounterKill[KA_PlayerNumberKiller] Greater than or equal to 3
            • Then - Actions
              • Set VariableSet KA_CounterKillStreak[KA_PlayerNumberKiller] = (KA_CounterKillStreak[KA_PlayerNumberKiller] + 1)
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KA_CounterKillStreak[KA_PlayerNumberKiller] Greater than or equal to 1
        • Then - Actions
          • Sound - Play KA_KillStreakSound[KA_CounterKillStreak[KA_PlayerNumberKiller]]
          • Game - Display to (All players) the text: (PlayerNames[KA_PlayerNumberKiller] + KA_KillStreakString[KA_CounterKillStreak[KA_PlayerNumberKiller]])
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KA_CounterKillStreak[KA_PlayerNumberDying] Not equal to 0
        • Then - Actions
          • Sound - Play ReceiveGold <gen> at 100.00% volume, attached to KA_Killer
          • Set VariableSet KA_Bounty = (KA_CounterKillStreak[KA_PlayerNumberDying] x 60)
          • Game - Display to (All players) the text: ((PlayerNames[KA_PlayerNumberDying] + ('s + KA_KillStreakStringEnd[KA_CounterKillStreak[KA_PlayerNumberDying]])) + (( streak has been ended by + PlayerNames[KA_PlayerNumberKiller]) + ( for + ((|cffffcc00 + (String(KA_Bounty))) + |r gold.))))
        • Else - Actions
      • Set VariableSet KA_CounterKill[KA_PlayerNumberDying] = 0
      • Set VariableSet KA_CounterKillStreak[KA_PlayerNumberDying] = 0
      • -------- --------
      • -------- Kills must be within 15 seconds for Kill Loop --------
      • Unit Group - Add KA_Killer to KA_KillGroup
      • Set VariableSet KA_CV = (Custom value of KA_Killer)
      • Set VariableSet KA_KillStreakDuration[KA_CV] = 0
      • Set VariableSet KA_KillStreakCounter[KA_CV] = (KA_KillStreakCounter[KA_CV] + 1)
      • Set VariableSet KA_KillStreakBoolean[KA_CV] = False
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Kill Streak Kill Loop <gen> is on) Equal to False
        • Then - Actions
          • Countdown Timer - Start KA_KillTimer as a Repeating timer that will expire in 0.50 seconds
          • Trigger - Turn on Kill Streak Kill Loop <gen>
        • Else - Actions

Here proof that it's turned off, and not accidently on:
1631129890091.png


Here the in-game log:

1631130091804.png


Is a unit's death somehow triggering multiple times?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
Dunno why that's happening but have you tried using the Turn Off trigger action?

  • Events:
  • Map initialization
  • Actions:
  • Trigger - Turn off Kill Stream System

If the issue still continues after that I would try to combine the two triggers into one. Then use a Boolean or something to determine whether or not First Blood has happened.
 
Level 12
Joined
May 16, 2020
Messages
660
Thank you Uncle. Tried your suggestion, but still having the same issue.

I actually had the two triggers combined in one previously (and that worked with a Boolean)! But I thought I could get a bit of performance if the trigger doesn't have to run the boolean on each kill. But I guess it's a miniscule save anyhow...
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
Weird, Reforged just got an update so I wonder if they broke some more stuff. Anyway, a single Boolean check shouldn't matter. If you're looking for minor optimizations I would find a way to turn those 3 Player number conditions into a single condition.
 
Level 20
Joined
Feb 27, 2019
Messages
593
Enter the Object Manager and Triggers and make sure there is no unknown Trigger using Kill Streak System that turns it on.
 
Level 12
Joined
May 16, 2020
Messages
660
Enter the Object Manager and Triggers and make sure there is no unknown Trigger using Kill Streak System that turns it on.
Tried it, unfortunately no - nothing is turning it on.

But anyhow, it works as it should now with the boolean:

  • Kill Streak System
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • (Owner of (Triggering unit)) Not equal to Player 13 (Maroon)
    • Actions
      • Set VariableSet KA_Killer = (Killing unit)
      • Set VariableSet KA_Dying = (Triggering unit)
      • Set VariableSet KA_PlayerNumberKiller = (Player number of (Owner of KA_Killer))
      • Set VariableSet KA_PlayerNumberDying = (Player number of (Owner of KA_Dying))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KA_FirstBlood Equal to False
        • Then - Actions
          • -------- ----------------------- --------
          • -------- FIRST BLOOD --------
          • -------- ----------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Owner of KA_Killer) is in PlayersAll.) Equal to True
            • Then - Actions
              • -------- PLAYER DEALT KILLING BLOW --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • KA_Killer Equal to KA_Dying
                • Then - Actions
                  • Game - Display to (All players) the text: (PlayerNames[KA_PlayerNumberKiller] + killed himself!)
                  • Skip remaining actions
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • X_LastAttacker[KA_PlayerNumberDying] Equal to 0
                • Then - Actions
                  • -------- NO PLAYER DEALT DAMAGE --------
                  • Game - Display to (All players) the text: (PlayerNames[KA_PlayerNumberKiller] + was executed.)
                  • Skip remaining actions
                • Else - Actions
                  • -------- PLAYER DEALT DAMAGE --------
                  • Set VariableSet KA_PlayerNumberKiller = X_LastAttacker[KA_PlayerNumberDying]
          • -------- --------
          • Set VariableSet KA_Bounty = ((110 + ((Hero level of KA_Dying) x 8)) + 150)
          • Sound - Play firstblood <gen>
          • Game - Display to (All players) the text: ((PlayerNames[KA_PlayerNumberKiller] + pawned ) + ((PlayerNames[KA_PlayerNumberDying] + 's head for ) + (|cffffcc00 + ((String(KA_Bounty)) + |r gold!))))
          • Game - Display to (All players) the text: (PlayerNames[KA_PlayerNumberKiller] + just drew |cffff0000First Blood|r!)
          • Player - Add KA_Bounty to (Player(KA_PlayerNumberKiller)).Current gold
          • -------- --------
          • Set VariableSet KA_CounterKill[KA_PlayerNumberKiller] = (KA_CounterKill[KA_PlayerNumberKiller] + 1)
          • -------- --------
          • Set VariableSet KA_FirstBlood = True
        • Else - Actions
          • -------- ------------------------------------- --------
          • -------- AFTER FIRST BLOOD --------
          • -------- ------------------------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Owner of KA_Killer) is in PlayersAll.) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • KA_Killer Equal to KA_Dying
                • Then - Actions
                  • Game - Display to (All players) the text: (PlayerNames[KA_PlayerNumberKiller] + killed himself!)
                  • Skip remaining actions
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • X_LastAttacker[KA_PlayerNumberDying] Equal to 0
                • Then - Actions
                  • Game - Display to (All players) the text: (PlayerNames[KA_PlayerNumberKiller] + was executed.)
                  • Skip remaining actions
                • Else - Actions
                  • Set VariableSet KA_PlayerNumberKiller = X_LastAttacker[KA_PlayerNumberDying]
          • -------- --------
          • Set VariableSet KA_Bounty = ((110 + ((Hero level of KA_Dying) x 8)) + (KA_CounterKillStreak[KA_PlayerNumberDying] x 60))
          • Player - Add KA_Bounty to (Owner of KA_Killer).Current gold
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • KA_CounterKillStreak[KA_PlayerNumberDying] Equal to 0
            • Then - Actions
              • Game - Display to (All players) the text: ((PlayerNames[KA_PlayerNumberKiller] + pawned ) + ((PlayerNames[KA_PlayerNumberDying] + 's head for ) + (|cffffcc00 + ((String(KA_Bounty)) + |r gold!))))
            • Else - Actions
              • Game - Display to (All players) the text: ((PlayerNames[KA_PlayerNumberKiller] + has just ended ) + (((PlayerNames[KA_PlayerNumberDying] + 's ) + KA_KillStreakStringEnd[KA_CounterKillStreak[KA_PlayerNumberDying]]) + ( streak for + ((|cffffcc00 + (String(KA_Bounty))) + |r gold!!))))
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • KA_CounterKill[KA_PlayerNumberKiller] Less than 10
            • Then - Actions
              • Set VariableSet KA_CounterKill[KA_PlayerNumberKiller] = (KA_CounterKill[KA_PlayerNumberKiller] + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • KA_CounterKill[KA_PlayerNumberKiller] Greater than or equal to 3
                • Then - Actions
                  • Set VariableSet KA_CounterKillStreak[KA_PlayerNumberKiller] = (KA_CounterKillStreak[KA_PlayerNumberKiller] + 1)
                • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • KA_CounterKillStreak[KA_PlayerNumberKiller] Greater than or equal to 1
            • Then - Actions
              • Sound - Play KA_KillStreakSound[KA_CounterKillStreak[KA_PlayerNumberKiller]]
              • Game - Display to (All players) the text: (PlayerNames[KA_PlayerNumberKiller] + KA_KillStreakString[KA_CounterKillStreak[KA_PlayerNumberKiller]])
            • Else - Actions
          • -------- --------
          • Set VariableSet KA_CounterKill[KA_PlayerNumberDying] = 0
          • Set VariableSet KA_CounterKillStreak[KA_PlayerNumberDying] = 0
      • -------- Kills must be within 15 seconds for Kill Loop --------
      • Unit Group - Add KA_Killer to KA_KillGroup
      • Set VariableSet KA_CV = (Custom value of KA_Killer)
      • Set VariableSet KA_KillStreakDuration[KA_CV] = 0
      • Set VariableSet KA_KillStreakCounter[KA_CV] = (KA_KillStreakCounter[KA_CV] + 1)
      • Set VariableSet KA_KillStreakBoolean[KA_CV] = False
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Kill Streak Kill Loop <gen> is on) Equal to False
        • Then - Actions
          • Countdown Timer - Start KA_KillTimer as a Repeating timer that will expire in 0.50 seconds
          • Trigger - Turn on Kill Streak Kill Loop <gen>
        • Else - Actions
 
Status
Not open for further replies.
Top