• 🏆 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!

[Trigger] "Charge" ability triggering

Status
Not open for further replies.
Level 6
Joined
Mar 17, 2012
Messages
105
I have an ability Shock Charge based on Endurance Aura that adds the buff "Charge Ready" to the unit that has the ability. It is supposed to simulate a knight dealing additional damage upon his first attack in a battle (a charge). I have two triggers:

  • ChargeAttack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Heavy Man-at-arms [Default]
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacking unit) has buff Charge Ready ) Equal to True
        • Then - Actions
          • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing 30.00 damage of attack type Hero and damage type Normal
          • Unit - Remove Shock Charge [Active] from (Attacking unit)
          • Unit - Remove Charge Ready buff from (Attacking unit)
        • Else - Actions
          • Do nothing
  • ChargeReset
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units of type Heavy Man-at-arms [Default]) and do (Actions)
        • Loop - Actions
          • Set UNIT_TempUnit[5] = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (UNIT_TempUnit[5] has buff Charge Ready ) Equal to True
            • Then - Actions
              • Do nothing
            • Else - Actions
              • Unit Group - Pick every unit in (Units within 1024.00 of (Position of UNIT_TempUnit[5])) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • And - All (Conditions) are true
                        • Conditions
                          • (Picked unit) Not equal to UNIT_TempUnit[5]
                          • ((Picked unit) belongs to an ally of (Owner of UNIT_TempUnit[5])) Not equal to True
                          • (Owner of (Picked unit)) Not equal to (Owner of UNIT_TempUnit[5])
                          • ((Picked unit) belongs to an enemy of (Owner of UNIT_TempUnit[5])) Equal to True
                    • Then - Actions
                      • Do nothing
                    • Else - Actions
                      • Unit - Add Shock Charge [Active] to UNIT_TempUnit[5]
Problem: the Heavy Man-at-arms loses the Charge ability and buff when he attacks a foe, but he just gains it back every 5 seconds, even though there are enemies within 1024 range of him; as if all of the conditions under my "And" are ignored. What's going on here?
 
Level 12
Joined
Nov 3, 2013
Messages
989
No reason to use "and" since there is no "or"

All the conditions all ready have to be checked (and cleared/passed) by default, unless there's an or, after all.
 
Level 12
Joined
Nov 3, 2013
Messages
989
Try changing the pick unit group to "pick units in region matching condition" instead of "units of unit type"

I recall people saying there's bad stuff with it, though it might not be the issue either.

so it would be like this instead;

Pick every unit in (playable map area) matching (unit type is equal to xxxxxx) and do (Actions)

Also maybe you should have a unit group variable with all those relevant units, if you add and remove them when they enter the map and then die, then you wouldn't filter through all the units in the entire map every 5 seconds to find the relevant ones like you're doing now. (Which can be pretty costly with a lot of units.)
 
Level 6
Joined
Mar 17, 2012
Messages
105
Try changing the pick unit group to "pick units in region matching condition" instead of "units of unit type"

I recall people saying there's bad stuff with it, though it might not be the issue either.

so it would be like this instead;

Pick every unit in (playable map area) matching (unit type is equal to xxxxxx) and do (Actions)

Also maybe you should have a unit group variable with all those relevant units, if you add and remove them when they enter the map and then die, then you wouldn't filter through all the units in the entire map every 5 seconds to find the relevant ones like you're doing now. (Which can be pretty costly with a lot of units.)

Thanks for the second suggestion, I'll do that. However the triggers still do not work!
 
Level 12
Joined
Nov 3, 2013
Messages
989
Honestly no "real" idea but try swapping the "not equal to true"s with "equal to true" and vice versa in the last part. Then move add shock charge to "then actions" instead of "else".

If nothing else at least it could be more intuitive so as to easier visualize what's going on to find the problem :<

(p.s. probably not related to the actual problem but note that, unlike what it implies, "do nothing" actually does something (Which doesn't do "anything".), leaving it empty instead is what you'd do to actually do nothing.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Set group = Units within 1000 of position of unit
Pick every unit in group
--If
---Or - multiple conditions
----picked unit is dead == true
----picked unit belongs to an enemy of unit == false
--Then
----Unit group - remove picked unit from group
--Else (nothing here, not even Do nothing)
If number of units in group > 0 then add buff to unit

http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
 
Status
Not open for further replies.
Top