• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Help with my trigger

Status
Not open for further replies.
Level 13
Joined
Aug 19, 2014
Messages
1,111
Hello guys I need help with my trigger, its doing what it should but not completely. What am I trying to achieve here is that when a hero with a buff (Infused Daggers) attacks 3 times, the buff will be removed on him and on the 3rd attack will slow the enemy unit. That part is okay, the part that is not working is when the hero didn't attack 3 times and the buff dissapear, the variable Set Infused_Count[TempInteger] = 0 doesn't set to 0. So when the hero has the buff again his 1st attack will slow the enemy and the buff is gone.

  • Infused Dagger Damage
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource has buff Infused Daggers ) Equal to True
      • IsDamageSpell Equal to False
    • Actions
      • -------- ------------------------------------------------------------------------------------------------- --------
      • -------- Getting the Spell constants --------
      • -------- ------------------------------------------------------------------------------------------------- --------
      • Set Temp_Unit = DamageEventSource
      • Set TempInteger1 = (Custom value of Temp_Unit)
      • Set Infused_Count[TempInteger] = (Infused_Count[TempInteger] + 1)
      • -------- ------------------------------------------------------------------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Infused_Count[TempInteger] Equal to 3
        • Then - Actions
          • Set Temp_Target = DamageEventTarget
          • Set TempPlayer = (Owner of Temp_Unit)
          • Set Temp_Location = (Position of Temp_Target)
          • Set TempAbility = All Purpose Slow (Dummy Ability)
          • Unit - Create 1 Dummy Unit for TempPlayer at Temp_Location facing Default building facing degrees
          • Set Temp_Dummy = (Last created unit)
          • Unit - Add a 1.50 second Generic expiration timer to Temp_Dummy
          • Unit - Add TempAbility to Temp_Dummy
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Temp_Target is alive) Equal to True
              • (Temp_Target is A structure) Not equal to True
              • (Temp_Target is Magic Immune) Not equal to True
            • Then - Actions
              • Unit - Order Temp_Dummy to Human Sorceress - Activate Slow
              • Unit - Order Temp_Dummy to Human Sorceress - Slow Temp_Target
              • Set Infused_Count[TempInteger] = 0
              • Unit - Remove Infused Daggers buff from Temp_Unit
              • Custom script: call RemoveLocation(udg_Temp_Location)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Temp_Unit has buff Infused Daggers ) Equal to False
                • Then - Actions
                  • Set Infused_Count[TempInteger] = 0
                • Else - Actions
        • Else - Actions
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Infused_Count[] has the index of TempInteger when you store the the custom value of the unit to TempInteger1.

  • -------- --------
  • Set TempInteger1 = (Custom value of Temp_Unit)
  • -------- when you increase the counter --------
  • Set Infused_Count[TempInteger] = (Infused_Count[TempInteger] + 1)
  • -------- when you create the dummy to cast slow --------
  • Set Infused_Count[TempInteger] = 0
  • -------- when Temp_Target does not pass the filters --------
  • Set Infused_Count[TempInteger] = 0
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
I've updated the trigger, but the variable Set Infused_Count[TempInteger] = 0 still doesn't reset to 0 when the hero does not have the Infused Dagger buff.

  • Infused Dagger Damage
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource has buff Infused Daggers ) Equal to True
      • IsDamageSpell Equal to False
    • Actions
      • -------- ------------------------------------------------------------------------------------------------- --------
      • -------- Getting the Spell constants --------
      • -------- ------------------------------------------------------------------------------------------------- --------
      • Set Temp_Unit = DamageEventSource
      • Set DamageEventAmount = (DamageEventAmount x (0.30 x (Real((Intelligence of Temp_Unit (Include bonuses))))))
      • Set TempInteger = (Custom value of Temp_Unit)
      • Set Infused_Count[TempInteger] = (Infused_Count[TempInteger] + 1)
      • -------- ------------------------------------------------------------------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Infused_Count[TempInteger] Equal to 3
        • Then - Actions
          • Set Temp_Target = DamageEventTarget
          • Set TempPlayer = (Owner of Temp_Unit)
          • Set Temp_Location = (Position of Temp_Target)
          • Set TempAbility = All Purpose Slow (Dummy Ability)
          • Unit - Create 1 Dummy Unit for TempPlayer at Temp_Location facing Default building facing degrees
          • Set Temp_Dummy = (Last created unit)
          • Unit - Add a 1.50 second Generic expiration timer to Temp_Dummy
          • Unit - Add TempAbility to Temp_Dummy
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Temp_Target is alive) Equal to True
              • (Temp_Target is A structure) Not equal to True
              • (Temp_Target is Magic Immune) Not equal to True
            • Then - Actions
              • Unit - Order Temp_Dummy to Human Sorceress - Activate Slow
              • Unit - Order Temp_Dummy to Human Sorceress - Slow Temp_Target
              • Set Infused_Count[TempInteger] = 0
              • Unit - Remove Infused Daggers buff from Temp_Unit
              • Custom script: call RemoveLocation(udg_Temp_Location)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Temp_Unit has buff Infused Daggers ) Equal to False
                • Then - Actions
                  • Set Infused_Count[TempInteger] = 0
                • Else - Actions
        • Else - Actions
The spell will give the hero bonus damage good for 3 attacks only and will slow the target on the 3rd attack. My problem is that when the hero attacks only for 2 times and the buff duration expire, and then he again gains the buff and attacks, the buff will disappear and will slow the target on his 1st attack, wasting 2 additional attacks with bonus damage.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
I've updated the trigger, but the variable Set Infused_Count[TempInteger] = 0 still doesn't reset to 0 when the hero does not have the Infused Dagger buff.

That is because you only check for the buff either on damage or when they already have done the 3 attacks with the buff.

Maybe you can change "(DamageEventSource has buff Infused Daggers ) Equal to True" at the top to instead checking if DamageEventSource has the ability. Afterwards, the first If/Then/Else should check if their Infused_Count[] is greater than 0. In the Then - Actions, you can have another If/Then/Else that checks if they have the buff, if not reset to 0 and if so, add to counter.

  • Infused Dagger Damage
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (Level of Your_Ability for DamageEventSource) Greater than or equal to 1
      • IsDamageSpell Equal to False
    • Actions
      • Set Temp_Unit = DamageEventSource
      • Set TempInteger = (Custom value of Temp_Unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Infused_Count[TempInteger] Greater than 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Temp_Unit has buff Infused Daggers Equal to True
            • Then - Actions
              • Set Infused_Count[TempInteger] = (Infused_Count[TempInteger] + 1)
              • -------- If/Then/Else for checking if they have 3 stacks; if so reset and add slow --------
            • Else - Actions
              • Set Infused_Count[TempInteger] = 0
        • Else - Actions
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
Here's what I did, it doesn't slow the unit on the 3rd attack anymore.

  • Infused Dagger Damage
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (Level of Infuse Dagger (Death Prince) for DamageEventSource) Greater than 0
      • IsDamageSpell Equal to False
    • Actions
      • -------- ------------------------------------------------------------------------------------------------- --------
      • -------- Getting the Spell constants --------
      • -------- ------------------------------------------------------------------------------------------------- --------
      • Set Temp_Unit = DamageEventSource
      • Set TempInteger = (Custom value of Temp_Unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Infused_Count[TempInteger] Greater than 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Temp_Unit has buff Infused Daggers ) Equal to True
            • Then - Actions
              • Set Infused_Count[TempInteger] = (Infused_Count[TempInteger] + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Infused_Count[TempInteger] Equal to 3
                • Then - Actions
                  • Set Temp_Target = DamageEventTarget
                  • Set TempPlayer = (Owner of Temp_Unit)
                  • Set Temp_Location = (Position of Temp_Target)
                  • Set TempAbility = All Purpose Slow (Dummy Ability)
                  • Unit - Create 1 Dummy Unit for TempPlayer at Temp_Location facing Default building facing degrees
                  • Set Temp_Dummy = (Last created unit)
                  • Unit - Add a 1.50 second Generic expiration timer to Temp_Dummy
                  • Unit - Add TempAbility to Temp_Dummy
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Temp_Target is alive) Equal to True
                      • (Temp_Target is A structure) Not equal to True
                      • (Temp_Target is Magic Immune) Not equal to True
                    • Then - Actions
                      • Unit - Order Temp_Dummy to Human Sorceress - Activate Slow
                      • Unit - Order Temp_Dummy to Human Sorceress - Slow Temp_Target
                      • Set Infused_Count[TempInteger] = 0
                      • Unit - Remove Infused Daggers buff from Temp_Unit
                      • Custom script: call RemoveLocation(udg_Temp_Location)
                    • Else - Actions
                • Else - Actions
            • Else - Actions
        • Else - Actions
Anyway I'm still trying to fix it.
 

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
Hello.

Try this one:

  • Infused Dagger Damage
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • IsDamageSpell Equal to False
    • Actions
      • Set Temp_Unit = DamageEventSource
      • Set TempInteger1 = (Custom value of Temp_Unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DamageEventSource has buff Infused Daggers ) Equal to True
        • Then - Actions
          • -------- ------------------------------------------------------------------------------------------------- --------
          • -------- Getting the Spell constants --------
          • -------- ------------------------------------------------------------------------------------------------- --------
          • Set Infused_Count[TempInteger] = (Infused_Count[TempInteger] + 1)
          • -------- ------------------------------------------------------------------------------------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Infused_Count[TempInteger] Equal to 3
            • Then - Actions
              • Set Temp_Target = DamageEventTarget
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Temp_Target is alive) Equal to True
                  • (Temp_Target is A structure) Not equal to True
                  • (Temp_Target is Magic Immune) Not equal to True
                • Then - Actions
                  • Set TempPlayer = (Owner of Temp_Unit)
                  • Set Temp_Location = (Position of Temp_Target)
                  • Set TempAbility = All Purpose Slow (Dummy Ability)
                  • Unit - Create 1 Dummy Unit for TempPlayer at Temp_Location facing Default building facing degrees
                  • Set Temp_Dummy = (Last created unit)
                  • Unit - Add a 1.50 second Generic expiration timer to Temp_Dummy
                  • Unit - Add TempAbility to Temp_Dummy
                  • Unit - Order Temp_Dummy to Human Sorceress - Activate Slow
                  • Unit - Order Temp_Dummy to Human Sorceress - Slow Temp_Target
                  • Set Infused_Count[TempInteger] = 0
                  • Custom script: call RemoveLocation(udg_Temp_Location)
                • Else - Actions
              • Unit - Remove Infused Daggers buff from Temp_Unit
            • Else - Actions
        • Else - Actions
          • Set Infused_Count[TempInteger] = 0

The problem is because you reset Infused_Count[TempInteger] in the wrong place.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Temp_Target is alive) Equal to True
      • (Temp_Target is A structure) Not equal to True
      • (Temp_Target is Magic Immune) Not equal to True
    • Then - Actions
      • ...
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Temp_Unit has buff Infused Daggers ) Equal to False
        • Then - Actions
          • Set Infused_Count[TempInteger] = 0 <= wrong
        • Else - Actions
It will never meet the condition as there is already (Temp_Unit has buff Infused Daggers ) Equal to True at the top ITE condition block.

So when the hero has the buff again his 1st attack will slow the enemy and the buff is gone.
You also have to reset Infused_Count[units index] to zero when a unit gains the buff.

The solution above is a bit optimized but not excellent yet, I'm just modifying the code you provided above. The "else" block will still run for any unit without the buff but it's not a big deal. Just tell me if you need further helps. ;)
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Here's what I did, it doesn't slow the unit on the 3rd attack anymore.

As Quilnez, it is because you are resetting Infused_Count[] in the wrong spot. You only reset it when Temp_Target passes the filter when it should reset as soon as it hits 3 stacks. All though Quilnez example trigger is a better solution, I would only add an extra condition that checks if they have the passive ability because the trigger will set Infused_Count[] to 0 of every single unit in the map that deals physical damage, which is completely pointless. You should only be resetting to 0 if they even have the passive ability that gives them the stack counter.
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
Thanks guys I got it working now, I also followed what KILLCIDE said about the passive ability.
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
Um....... guys there's still a problem. How can I reset Infused_Count[units index] to zero when a unit gains the buff in my trigger below? So when the hero gains the buff again, his 1st attack wont slow the unit if he only do 2 previous attacks.

  • Infused Dagger Damage
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (Level of Infuse Dagger (Death Prince) for DamageEventSource) Greater than 0
      • IsDamageSpell Equal to False
    • Actions
      • Set Temp_Unit = DamageEventSource
      • Set TempInteger = (Custom value of Temp_Unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Temp_Unit has buff Infused Daggers ) Equal to True
        • Then - Actions
          • Set Infused_Count[TempInteger] = (Infused_Count[TempInteger] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Infused_Count[TempInteger] Equal to 3
            • Then - Actions
              • Set Temp_Target = DamageEventTarget
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Temp_Target is alive) Equal to True
                  • (Temp_Target is A structure) Not equal to True
                  • (Temp_Target is Magic Immune) Not equal to True
                • Then - Actions
                  • Set TempPlayer = (Owner of Temp_Unit)
                  • Set Temp_Location = (Position of Temp_Target)
                  • Set TempAbility = All Purpose Slow (Dummy Ability)
                  • Unit - Create 1 Dummy Unit for TempPlayer at Temp_Location facing Default building facing degrees
                  • Set Temp_Dummy = (Last created unit)
                  • Unit - Add a 1.50 second Generic expiration timer to Temp_Dummy
                  • Unit - Add TempAbility to Temp_Dummy
                  • Unit - Order Temp_Dummy to Human Sorceress - Activate Slow
                  • Unit - Order Temp_Dummy to Human Sorceress - Slow Temp_Target
                  • Set Infused_Count[TempInteger] = 0
                  • Unit - Remove Infused Daggers buff from Temp_Unit
                  • Custom script: call RemoveLocation(udg_Temp_Location)
                • Else - Actions
            • Else - Actions
        • Else - Actions
          • Set Infused_Count[TempInteger] = 0
  • [/hidden]
 
Status
Not open for further replies.
Top