• 🏆 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] Condition Problem

Status
Not open for further replies.
Level 20
Joined
Apr 14, 2012
Messages
2,901
So I created this spell that is basically an advanced version of the Holy Light. When cast on an ally, it will heal the target and will either heal/damage the surrounding units depending on their controlling player.

Now, my problem is, and I can't figure out how to fix it, is when the spell is cast on an ally, it heals enemy structures. This puzzles me so much because I always filter the units, and in those filters I include the "If Picked Unit is a structure == false", so why does it heal enemy structures when cast on an ally?

Please help.



  • AHL Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Advanced Holy Light
    • Actions
      • Set AHL_Caster = (Triggering unit)
      • Set AHL_Target = (Target unit of ability being cast)
      • Set AHL_Real = 0.00
      • Set AHL_Level = (Level of Advanced Holy Light for AHL_Caster)
      • Set AHL_TempPoint = (Position of AHL_Target)
      • Set AHL_TempGroup = (Units within AHL_Range[AHL_Level] of AHL_TempPoint)
      • -------- Since the spell targets undead units and alive units by default, less filtering is needed. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (AHL_Target belongs to an enemy of (Owner of AHL_Caster)) Equal to True
        • Then - Actions
          • -------- If the target is an enemy of the caster, the following actions are performed: --------
          • Unit Group - Pick every unit in AHL_TempGroup and do (Actions)
            • Loop - Actions
              • Set AHL_TempUnit = (Picked unit)
              • -------- If the units around the target unit are friendly, then the THEN actions are executed: --------
              • -------- But if those units are enemies, the ELSE actions are executed. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (AHL_TempUnit is A structure) Equal to False
                  • (AHL_TempUnit belongs to an ally of (Owner of AHL_Caster)) Equal to True
                  • (AHL_TempUnit is alive) Equal to True
                • Then - Actions
                  • Set AHL_Life = (Life of AHL_Target)
                  • Set AHL_Real = (AHL_Life x AHL_FriendlyPercentHeal[AHL_Level])
                  • Special Effect - Create a special effect attached to the chest of AHL_TempUnit using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                  • Unit - Set life of (Picked unit) to ((Life of AHL_TempUnit) + AHL_Real)
                  • Special Effect - Destroy (Last created special effect)
                  • Special Effect - Create a special effect attached to the chest of AHL_Caster using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                  • Unit - Set life of AHL_Caster to ((Life of AHL_Caster) + AHL_Real)
                  • Special Effect - Destroy (Last created special effect)
                • Else - Actions
                  • Set AHL_Real = AHL_DamagePercent[AHL_Level]
                  • Special Effect - Create a special effect attached to the chest of AHL_TempUnit using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                  • Unit - Cause AHL_Caster to damage AHL_TempUnit, dealing ((Life of AHL_TempUnit) x AHL_Real) damage of attack type Normal and damage type Normal
                  • Special Effect - Destroy (Last created special effect)
              • -------- The caster damages the target and then knocks it back --------
              • Unit - Cause AHL_Caster to damage AHL_Target, dealing AHL_InitialDamage[AHL_Level] damage of attack type Chaos and damage type Normal
              • Set KB2D_Source = AHL_Caster
              • Set KB2D_Target = AHL_Target
              • Custom script: set udg_KB2D_TempKey = GetHandleId(udg_KB2D_Target)
              • Set KB2D_SFX = AHL_KB2DSFX[AHL_Level]
              • Set KB2D_Distance = AHL_KB2D_Distance[AHL_Level]
              • Set KB2D_Duration = AHL_KB2D_Duration[AHL_Level]
              • Set KB2D_Loc = (Position of KB2D_Source)
              • Set KB2D_Offset = (Position of KB2D_Target)
              • Set KB2D_Angle = (Angle from KB2D_Loc to KB2D_Offset)
              • Set KB2D_AllowTreeDestroy = True
              • Custom script: call ExecuteFunc("ApplyKnockbackEffect")
              • Custom script: call RemoveLocation(udg_KB2D_Offset)
              • Custom script: call RemoveLocation(udg_KB2D_Loc)
        • Else - Actions
          • -------- If the target is an ally of the caster, the following actions are performed: --------
          • Special Effect - Create a special effect attached to the chest of AHL_Target using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
          • Set AHL_Life = (Life of AHL_Target)
          • Unit - Set life of AHL_Target to (AHL_Life + AHL_InitialHeal[AHL_Level])
          • Special Effect - Destroy (Last created special effect)
          • -------- Now, if the units around the target are enemies, the following actions are executed: --------
          • Unit Group - Pick every unit in AHL_TempGroup and do (Actions)
            • Loop - Actions
              • Set AHL_TempUnit = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (AHL_TempUnit is A structure) Equal to False
                  • (AHL_TempUnit belongs to an enemy of (Owner of AHL_Caster)) Equal to True
                  • (AHL_TempUnit is alive) Equal to True
                • Then - Actions
                  • Set AHL_Life = (Life of AHL_TempUnit)
                  • Set AHL_Real = (AHL_Life x AHL_EnemyPercentHeal[AHL_Level])
                  • Special Effect - Create a special effect attached to the chest of AHL_Target using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                  • Unit - Set life of AHL_Target to ((Life of AHL_Target) + AHL_Real)
                  • Special Effect - Destroy (Last created special effect)
                  • Special Effect - Create a special effect attached to the chest of AHL_Caster using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                  • Unit - Set life of AHL_Caster to ((Life of AHL_Caster) + AHL_Real)
                  • Special Effect - Destroy (Last created special effect)
                  • Unit - Cause AHL_Caster to damage AHL_TempUnit, dealing AHL_FinalEnemyDamage[AHL_Level] damage of attack type Normal and damage type Normal
                • Else - Actions
                  • Set AHL_Real = AHL_PickedFriendlyHeal[AHL_Level]
                  • Special Effect - Create a special effect attached to the chest of AHL_TempUnit using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                  • Unit - Set life of AHL_TempUnit to ((Life of AHL_TempUnit) + ((Life of AHL_TempUnit) x AHL_Real))
                  • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_AHL_TempPoint)
      • Custom script: call DestroyGroup(udg_AHL_TempGroup)
      • Custom script: set udg_AHL_TempUnit = null
      • -------- End Cast --------


Oh and if mckill2009 happens to read this, please be informed that I made this spell before you taught me how you index spells.
 
Level 5
Joined
May 6, 2013
Messages
125


  • AHL Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Advanced Holy Light
    • Actions
      • Unit Group - Pick every unit in AHL_TempGroup and do (Actions)
        • Loop - Actions
          • Set AHL_TempUnit = (Picked unit)
          • -------- If the units around the target unit are friendly, then the THEN actions are executed: --------
          • -------- But if those units are enemies, the ELSE actions are executed. --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (AHL_TempUnit is A structure) Equal to False
              • (AHL_TempUnit belongs to an ally of (Owner of AHL_Caster)) Equal to True
              • (AHL_TempUnit is alive) Equal to True
            • Then - Actions
              • Set AHL_Life = (Life of AHL_Target)
              • Set AHL_Real = (AHL_Life x AHL_FriendlyPercentHeal[AHL_Level])
              • Special Effect - Create a special effect attached to the chest of AHL_TempUnit using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
              • Unit - Set life of (Picked unit) to ((Life of AHL_TempUnit) + AHL_Real)
              • Special Effect - Destroy (Last created special effect)
              • Special Effect - Create a special effect attached to the chest of AHL_Caster using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
              • Unit - Set life of AHL_Caster to ((Life of AHL_Caster) + AHL_Real)
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • Set AHL_Real = AHL_DamagePercent[AHL_Level]
              • Special Effect - Create a special effect attached to the chest of AHL_TempUnit using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
              • Unit - Cause AHL_Caster to damage AHL_TempUnit, dealing ((Life of AHL_TempUnit) x AHL_Real) damage of attack type Normal and damage type Normal
              • Special Effect - Destroy (Last created special effect)

-------- If the units around the target unit are friendly, then the THEN actions are executed: -------- -------- But if those units are enemies, the ELSE actions are executed. --------

That comment is simply wrong. The conditions you gave for the if are
-> the unit is a friend AND the unit is not a structure AND the unit is alive
Which means that the else is executed when
-> not (the unit is a friend AND the unit is not a structure AND the unit is alive)
which means
-> not (the unit is a friend) OR not (the unit is not a structure) OR not (the unit is alive).
You imply that the else is only executed when the unit is an enemy, but in fact, it is executed whenever the any of the above conditions evaluate to false, which means dead units and structures automatically go into the else.
You made this same mistake two times, which means all structures, dead units and non-allies are damaged when targeting an enemy, and all structures, dead units and non-enemys are healed when targeting and ally.

The easiest way to fix this is to filter dead units and structures out of AHL_TempGroup at creation i guess.

Hehe. comments with a drawback. Thats mean ;)
 
Level 30
Joined
Nov 29, 2012
Messages
6,637
I think youve got the concept of the Then and Else. As what genius Imp Midna ^.^ said, Then is only run if the If is met or should we say the condition itself and Else is run if the condition is not met. And I can see from your trigger is the opposite.
 
Status
Not open for further replies.
Top