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

Local variables issue

Status
Not open for further replies.
Level 10
Joined
Mar 17, 2012
Messages
579
Hi there!
I have an issue with one of my abilities as I'm bad at local variables.
My ability has 10 levels and every 8 seconds it picks a random allied unit and grants it with an empty ability-effect that is supposed to be an absorbing shield, which owrks well if there is only 1 unit for every player as I use globals with the number of player index. But now there is a need to apply it for more than 1 unit, so could you help me with that trigger, please? (I also use Bribe's damage engine to detect damage)

Learn an ability
  • Spiritual Energy learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Spiritual Energy
    • Actions
      • Unit Group - Add (Learning Hero) to Spiritual_Energy_Owner_Group
      • Set Spiritual_Energy_Ability = Spiritual Energy effect
      • Trigger - Turn on Spiritual Energy loop <gen>
that's where the "shield" is given
  • Spiritual Energy loop
    • Events
      • Time - Every 8.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Spiritual_Energy_Owner_Group and do (Actions)
        • Loop - Actions
          • Set Spiritual_Energy_Owner = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Spiritual_Energy_Owner is alive) Equal to True
            • Then - Actions
              • Set Spiritual_Energy_Point = (Position of Spiritual_Energy_Owner)
              • Set Spiritual_Energy_Group = (Units within 900.00 of Spiritual_Energy_Point matching ((((Matching unit) belongs to an ally of (Owner of Spiritual_Energy_Owner)) Equal to True) and ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) is alive) Equal to True))))
              • Unit Group - Pick every unit in (Random 1 units from Spiritual_Energy_Group) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Spiritual_Energy_Ability for (Picked unit)) Less than or equal to 0
                    • Then - Actions
                      • Set Spitirual_Energy_Int = (Player number of (Owner of (Picked unit)))
                      • Unit - Add Spiritual_Energy_Ability to (Picked unit)
                      • Set Spiritual_Energy_Shield_Amount[Spitirual_Energy_Int] = (((Real((Level of Spiritual Energy for Spiritual_Energy_Owner))) x 20.00) + 10.00)
                    • Else - Actions
                      • Set Spiritual_Energy_Shield_Amount[Spitirual_Energy_Int] = (((Real((Level of Spiritual Energy for Spiritual_Energy_Owner))) x 20.00) + 10.00)
              • Custom script: call DestroyGroup(udg_Spiritual_Energy_Group)
              • Custom script: call RemoveLocation(udg_Spiritual_Energy_Point)
            • Else - Actions
and here's where the damage is done
  • Spiritual Energy absorb
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (Level of Spiritual_Energy_Ability for DamageEventTarget) Greater than 0
    • Actions
      • Set Spitirual_Energy_Int = (Player number of (Owner of DamageEventTarget))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DamageEventAmount Greater than or equal to Spiritual_Energy_Shield_Amount[Spitirual_Energy_Int]
        • Then - Actions
          • Set DamageEventAmount = (DamageEventAmount - Spiritual_Energy_Shield_Amount[Spitirual_Energy_Int])
          • Set Spiritual_Energy_Shield_Amount[Spitirual_Energy_Int] = 0.00
          • Unit - Remove Spiritual_Energy_Ability from DamageEventTarget
        • Else - Actions
          • Set Spiritual_Energy_Shield_Amount[Spitirual_Energy_Int] = (Spiritual_Energy_Shield_Amount[Spitirual_Energy_Int] - DamageEventAmount)
          • Set DamageEventAmount = 0.00
I'd really appreciate if you helped me a little as I'm not fully sure that I know what is the correct syntax for locals, so an example would be divine :)
 
Status
Not open for further replies.
Top