• 🏆 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]Dynamic Indexing UnitGroup.

Status
Not open for further replies.
Level 11
Joined
Aug 1, 2009
Messages
714
It's been... 3 years since the last map I made for Wc3...
And here I am... creating another one.. A comeback I guess?
And look... this post is making my post number to 667... Not that number anymore... Huhuhu

Anyway... here's some code I created. My first MUI spell.
  • FreezingWave Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Freezing Wave
    • Actions
      • Set FW_LoopLimiter = (FW_LoopLimiter + 1)
      • Set FW_Caster[FW_LoopLimiter] = (Triggering unit)
      • Set FW_CasterPoint = (Position of FW_Caster[FW_LoopLimiter])
      • Set FW_TargetPoint = (Target point of ability being cast)
      • Set FW_Angle[FW_LoopLimiter] = (Angle from FW_CasterPoint to FW_TargetPoint)
      • Set FW_Distance[FW_LoopLimiter] = 0.00
      • Unit - Create 1 Freezing Wave - Projectile for (Owner of (Triggering unit)) at FW_CasterPoint facing FW_Angle[FW_LoopLimiter] degrees
      • Set FW_Dummy[FW_LoopLimiter] = (Last created unit)
      • Custom script: call RemoveLocation (udg_FW_CasterPoint)
      • Custom script: call RemoveLocation (udg_FW_TargetPoint)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FW_LoopLimiter Equal to 1
        • Then - Actions
          • Trigger - Turn on FreezingWave Loop <gen>
        • Else - Actions
  • [/stable]


  • FreezingWave Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer FW_LoopController) from 1 to FW_LoopLimiter, do (Actions)
        • Loop - Actions
          • Set FW_CasterPoint = (Position of FW_Dummy[FW_LoopController])
          • Set FW_TargetPoint = (FW_CasterPoint offset by 50.00 towards FW_Angle[FW_LoopController] degrees)
          • Set FW_Distance[FW_LoopController] = (FW_Distance[FW_LoopController] + 50.00)
          • Unit - Move FW_Dummy[FW_LoopController] instantly to FW_TargetPoint
          • Set FW_UnitDamage[FW_LoopController] = (Units within 175.00 of FW_TargetPoint matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is in FW_UnitDamageControl[FW_LoopController]) Equal to False)) and ((((Matching unit) is Magic Immune) Equal to False) and (((Owner of (
          • Unit Group - Pick every unit in FW_UnitDamage[FW_LoopController] and do (Actions)
            • Loop - Actions
              • Unit Group - Add (Picked unit) to FW_UnitDamageControl[FW_LoopController]
              • Unit - Cause FW_Caster[FW_LoopController] to damage (Picked unit), dealing ((150.00 x (Real((Level of Freezing Wave for FW_Caster[FW_LoopController])))) + (((0.30 x (Real((Hero level of FW_Caster[FW_LoopController])))) x (Real((Agility of FW_Caster[FW_LoopController] (Include bonuses))))) + (15.00 + (15.00 x (Real((Level of FW_Cast damage of attack type Spells and damage type Normal
          • Custom script: call RemoveLocation (udg_FW_CasterPoint)
          • Custom script: call RemoveLocation (udg_FW_TargetPoint)
          • Custom script: call DestroyGroup (udg_FW_UnitDamage[udg_FW_LoopController])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • FW_Distance[FW_LoopController] Greater than or equal to 850.00
            • Then - Actions
              • Unit - Kill FW_Dummy[FW_LoopController]
              • Custom script: call DestroyGroup (udg_FW_UnitDamageControl[udg_FW_LoopController])
              • Set FW_Caster[FW_LoopController] = FW_Caster[FW_LoopLimiter]
              • Set FW_Dummy[FW_LoopController] = FW_Dummy[FW_LoopLimiter]
              • Set FW_Distance[FW_LoopController] = FW_Distance[FW_LoopLimiter]
              • Set FW_Angle[FW_LoopController] = FW_Angle[FW_LoopLimiter]
              • Set FW_LoopController = (FW_LoopController - 1)
              • Set FW_LoopLimiter = (FW_LoopLimiter - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • FW_LoopLimiter Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions

Here's the problem.
When I first casted the skill, it works fine.
But the successive casts were disasterous...
I mean, it damages the unit EVERY LOOP.

Help...
 
Last edited by a moderator:
Level 13
Joined
Mar 24, 2013
Messages
1,105
Please use hidden tags, its stretching the page alot.

I'm assuming you want a unit to be only harmed once per cast?

You need to create the Unit Group in the cast trigger with yourUnitGroup = CreateGroup().

Then in the loop, you need to make a TempGroup,pick all the units in range, and if they're already in the FW_UnitGroup[CurrentIndex] then do nothing, otherwise damage them, and add them to the group.
 
Level 11
Joined
Aug 1, 2009
Messages
714
I'm not sure what you mean. But as pOke said, you would add this to your cast trigger :
  • Custom script: set udg_FW_UnitDamageControl[udg_FW_LoopLimiter] = CreateGroup()
This will ensure that the group exists on successive casts.

  • Custom script: set udg_FW_UnitDamageControl[udg_FW_LoopLimiter] = CreateGroup()
I've added this one and it works.
But it appears there's more question in my head.
Do I have to use
  • Custom script: set newUnitGroup = CreateGroup()
everytime I have an array of a variable-type of UnitGroup? and not gonna use it when not using an array?
 
Status
Not open for further replies.
Top