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

[Solved] Why my unit group didnt work?

Status
Not open for further replies.
Level 6
Joined
Jul 22, 2015
Messages
66
Help and Hello hive family!, i made a Spell called Excalibur but seem don't work on last phase in unit group if i using more than one unit to casting spell, can someone help me? it already done in mui both stage 1 and 2 are work properly.

Here my GUI triggrer :

  • Excalibur
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Excalibur
    • Actions
      • Set ExcaliburInt = (ExcaliburInt + 1)
      • Set ExcaliburCaster[ExcaliburInt] = (Triggering unit)
      • Sound - Play SaberSpellExcalibur <gen> at 100.00% volume, attached to ExcaliburCaster[ExcaliburInt]
      • Set ExcaliburLevel[ExcaliburInt] = (Level of Excalibur for ExcaliburCaster[ExcaliburInt])
      • Set ExcaliburDamage[ExcaliburInt] = (ExcaliburBaseDamage[ExcaliburLevel[ExcaliburInt]] + ((Real((((Base Damage of ExcaliburCaster[ExcaliburInt] for weapon index 1) + (Hero level of ExcaliburCaster[ExcaliburInt])) + (Strength of ExcaliburCaster[ExcaliburInt] (Include bonuses))))) x ExcaliburMulti)
      • Set ExcaliburAngle[ExcaliburInt] = (Facing of ExcaliburCaster[ExcaliburInt])
      • Set CharismaPoint[0] = (Position of ExcaliburCaster[ExcaliburInt])
      • Set ExcaliburPhase[ExcaliburInt] = 1
      • Unit - Pause ExcaliburCaster[ExcaliburInt]
      • Unit - Make ExcaliburCaster[ExcaliburInt] Invulnerable
      • Unit - Create 1 Caster for (Owner of ExcaliburCaster[ExcaliburInt]) at CharismaPoint[0] facing ExcaliburAngle[ExcaliburInt] degrees
      • Set ExcaliburDummy[ExcaliburInt] = (Last created unit)
      • Set ExcaliburDurCon[ExcaliburInt] = 0.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ExcaliburInt Equal to 1
        • Then - Actions
          • Trigger - Turn on Excalibur2 <gen>
        • Else - Actions
      • Custom script: call RemoveLocation(udg_CharismaPoint[0])
  • For each (Integer ExcaliburInt2) from 1 to ExcaliburInt, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ExcaliburPhase[ExcaliburInt2] Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ExcaliburDurCon[ExcaliburInt2] Greater than or equal to ExcaliburDuration
            • Then - Actions
              • Set ExcaliburPhase[ExcaliburInt2] = 2
              • Set ExcaliburDurCon[ExcaliburInt2] = 0.00
              • Animation - Play ExcaliburCaster[ExcaliburInt2]'s Spell 2 animation
            • Else - Actions
              • Set ExcaliburDurCon[ExcaliburInt2] = (ExcaliburDurCon[ExcaliburInt2] + 0.10)
              • Set CharismaPoint[0] = (Position of ExcaliburDummy[ExcaliburInt2])
              • Set CharismaPoint[1] = (CharismaPoint[0] offset by 150.00 towards ExcaliburAngle[ExcaliburInt2] degrees)
              • Unit - Move ExcaliburDummy[ExcaliburInt2] instantly to CharismaPoint[1], facing ExcaliburAngle[ExcaliburInt2] degrees
              • Unit - Create 1 Footman for (Owner of ExcaliburCaster[ExcaliburInt2]) at CharismaPoint[1] facing Default building facing degrees
              • Unit Group - Add (Last created unit) to ExcaliburPickGroup[ExcaliburInt2]
              • Special Effect - Create a special effect at CharismaPoint[1] using war3mapImported\Firebolt Rough Major.mdx
              • Special Effect - Destroy (Last created special effect)
              • Custom script: call RemoveLocation(udg_CharismaPoint[0])
              • Custom script: call RemoveLocation(udg_CharismaPoint[1])
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ExcaliburPhase[ExcaliburInt2] Equal to 2
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ExcaliburDurCon[ExcaliburInt2] Greater than or equal to ExcaliburDuration
            • Then - Actions
              • Set ExcaliburPhase[ExcaliburInt2] = 3
            • Else - Actions
              • Set ExcaliburDurCon[ExcaliburInt2] = (ExcaliburDurCon[ExcaliburInt2] + 0.10)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ExcaliburDurCon[ExcaliburInt2] Equal to 0.50
                • Then - Actions
                  • Special Effect - Create a special effect attached to the chest of ExcaliburCaster[ExcaliburInt2] using war3mapImported\Bondage Red HD.mdx
                  • Set ExcaliburEffect[ExcaliburInt2] = (Last created special effect)
                • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ExcaliburPhase[ExcaliburInt2] Equal to 3
        • Then - Actions
          • Special Effect - Destroy ExcaliburEffect[ExcaliburInt2]
          • Unit - Kill ExcaliburDummy[ExcaliburInt2]
          • Unit - Unpause ExcaliburCaster[ExcaliburInt2]
          • Unit - Make ExcaliburCaster[ExcaliburInt2] Vulnerable
          • Unit Group - Pick every unit in ExcaliburPickGroup[ExcaliburInt2] and do (Actions)
            • Loop - Actions
              • Set CharismaPoint[2] = (Position of (Picked unit))
              • Special Effect - Create a special effect at CharismaPoint[2] using Abilities\Spells\Other\Doom\DoomDeath.mdl
              • Special Effect - Set Scale of (Last created special effect) to 2.00
              • Special Effect - Destroy (Last created special effect)
              • Set ExcaliburDummyGroup[ExcaliburInt2] = (Units within 300.00 of CharismaPoint[2] matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of ExcaliburCaster[ExcaliburInt2])) Equal to True)))
              • Unit Group - Pick every unit in ExcaliburDummyGroup[ExcaliburInt2] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in ExcaliburPickDamage[ExcaliburInt2]) Equal to False
                    • Then - Actions
                      • Unit - Cause ExcaliburCaster[ExcaliburInt2] to damage (Picked unit), dealing ExcaliburDamage[ExcaliburInt2] damage of attack type Chaos and damage type Normal
                      • Unit Group - Add (Picked unit) to ExcaliburPickDamage[ExcaliburInt2]
                    • Else - Actions
              • Destructible - Pick every destructible within 300.00 of CharismaPoint[2] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • KillTree Equal to True
                    • Then - Actions
                      • Destructible - Kill (Picked destructible)
                    • Else - Actions
              • Custom script: call DestroyGroup(udg_ExcaliburDummyGroup[udg_ExcaliburInt2])
              • Custom script: call RemoveLocation(udg_CharismaPoint[2])
              • Unit - Kill (Picked unit)
          • Unit Group - Remove all units from ExcaliburPickDamage[ExcaliburInt2]
          • Set ExcaliburDummy[ExcaliburInt2] = ExcaliburDummy[ExcaliburInt]
          • Set ExcaliburDummy[ExcaliburInt] = No unit
          • Set ExcaliburCaster[ExcaliburInt2] = ExcaliburCaster[ExcaliburInt]
          • Set ExcaliburCaster[ExcaliburInt] = No unit
          • Set ExcaliburDurCon[ExcaliburInt2] = ExcaliburDurCon[ExcaliburInt]
          • Set ExcaliburPhase[ExcaliburInt2] = ExcaliburPhase[ExcaliburInt]
          • Set ExcaliburDamage[ExcaliburInt2] = ExcaliburDamage[ExcaliburInt]
          • Set ExcaliburAngle[ExcaliburInt2] = ExcaliburAngle[ExcaliburInt]
          • Set ExcaliburInt2 = (ExcaliburInt2 - 1)
          • Set ExcaliburInt = (ExcaliburInt - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ExcaliburInt Equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,546
[EDIT]

Unit Group arrays need to be initialized in GUI:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Excalibur
  • Actions
    • Set ExcaliburInt = (ExcaliburInt + 1)
    • Custom script: set udg_ExcaliburPickGroup[udg_ExcaliburInt] = CreateGroup()
Then make sure to destroy this Unit Group when you're done with it:
  • Then - Actions
    • Custom script: call DestroyGroup(udg_ExcaliburPickGroup[udg_ExcaliburInt2]
Then shift it's index like you did with the other variables:
  • Set ExcaliburPickGroup[ExcaliburInt2] = ExcaliburPickGroup[ExcaliburInt]
Another thing, this looks pointless:
  • Set ExcaliburDummy[ExcaliburInt] = No unit
  • Set ExcaliburCaster[ExcaliburInt] = No unit
Also, ExcaliburDummyGroup[] and ExcaliburPickDamage[] do not need to be Arrays.
 
Last edited:
Level 6
Joined
Jul 22, 2015
Messages
66
Unit Group arrays need to be initialized in GUI:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Excalibur
  • Actions
    • Set ExcaliburInt = (ExcaliburInt + 1)
    • Custom script: set udg_ExcaliburPickGroup[udg_ExcaliburInt] = CreateGroup()
    • Custom script: set udg_ExcaliburPickDamage[udg_ExcaliburInt] = CreateGroup()
And you should be Destroying the Unit Groups in Phase 3 instead of Removing units from them. You should do this after you pick through the groups but before you shift their indexes (see step 2):
  • Then - Actions
    • Custom script: call DestroyGroup(udg_ExcaliburPickGroup[udg_ExcaliburInt2]
    • Custom script: call DestroyGroup(udg_ExcaliburPickDamage[udg_ExcaliburInt2]
Step 2, Unit Groups need to be shifted as well:
  • Set ExcaliburPickGroup[ExcaliburInt2] = ExcaliburPickGroup[ExcaliburInt]
  • Set ExcaliburPickDamage[ExcaliburInt2] = ExcaliburPickDamage[ExcaliburInt]
Another thing, this looks pointless:
  • Set ExcaliburDummy[ExcaliburInt] = No unit
  • Set ExcaliburCaster[ExcaliburInt] = No unit
Also, ExcaliburDummyGroup[] doesn't need to be an Array.
OMG, it workedd!!! thanks a lot!!!
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,546
OMG, it workedd!!! thanks a lot!!!
No problem.

So I just looked over the triggers again and realized I made a mistake. ExcaliburPickDamage[] AND ExcaliburDummyGroup[] do NOT need to be Arrays. Instead, you can Clear them in Phase 3 once you're done using them. This is because those two Unit Groups don't need to track anything over time, everything can be handled all at once without causing any conflicts.

On the contrary, ExcaliburPickGroup[] needs to remain an Array because it tracks multiple Footman over the duration of the spell. Once you add in that time component you need to take extra measures to make things MUI.
 
Last edited:
Status
Not open for further replies.
Top