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

Lightning error

Status
Not open for further replies.
Level 3
Joined
Nov 2, 2020
Messages
28

  • Hateki
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (Fire (D)
    • Actions
      • Set Hero[8] = (Triggering unit)
      • Set Ab_Group[1] = (Units within 1250.00 of (Position of (Triggering unit)) matching ((((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True) and ((((Matching unit) has buff Invulnerable) Equal to False) and (((Matching unit) is alive) Equal to Tru
      • Unit Group - Pick every unit in Ab_Group[1] and do (Actions)
        • Loop - Actions
          • Animation - Change (Picked unit)'s animation speed to 0.00% of its original speed
          • Unit - Pause (Picked unit)
          • Set Pos[12] = (Position of (Picked unit))
          • Unit - Create 1 Dummy - Hateki for (Owner of Hero[8]) at Pos[12] facing (Random angle) degrees
          • Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
          • For each (Integer A) from 1 to 20, do (Actions)
            • Loop - Actions
              • Set Pos[42] = ((Position of (Picked unit)) offset by (Random real number between 500.00 and 900.00) towards (Random real number between 0.00 and 360.00) degrees)
              • Lightning - Create a Magic Leash lightning effect from source Pos[12] to target Pos[42]
              • Set Lightning[(Integer A)] = (Last created lightning effect)
          • Unit Group - Add (Picked unit) to Ab_Group[1]
      • Countdown Timer - Start Timer[1] as a One-shot timer that will expire in 5.00 seconds
      • Custom script: call RemoveLocation(udg_Pos[12])


  • Hateki End
    • Events
      • Time - Timer[1] expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 20, do (Actions)
        • Loop - Actions
          • Lightning - Destroy Lightning[(Integer A)]
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is in Ab_Group[1]) Equal to True)) and do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 7, do (Actions)
            • Loop - Actions
              • Set Pos[12] = ((Position of (Picked unit)) offset by 210.00 towards ((Real((Integer B))) x 50.00) degrees)
              • Special Effect - Create a special effect at Pos[12] using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
              • Special Effect - Destroy (Last created special effect)
          • Unit - Unpause (Picked unit)
          • Animation - Change (Picked unit)'s animation speed to 100.00% of its original speed
          • Set Pos[13] = (Position of (Picked unit))
          • Unit - Cause Hero[8] to damage (Picked unit), dealing (5.00 x ((Real((Strength of (Picked unit) (Include bonuses)))) + (Real((Intelligence of Hero[8] (Include bonuses)))))) damage of attack type Chaos and damage type Fire
          • Special Effect - Create a special effect at Pos[13] using war3mapImported\newmassiveex.mdx
          • Set Effect[1] = (Last created special effect)
          • Unit Group - Remove (Picked unit) from Ab_Group[1]
          • Custom script: call RemoveLocation(udg_Pos[13])
          • Custom script: call RemoveLocation(udg_Pos[12])
          • Custom script: call RemoveLocation(udg_Pos[42])
          • Special Effect - Destroy Effect[1]
          • Special Effect - Destroy Effect[2]
          • Custom script: call DestroyGroup(udg_Ab_Group[1])

=================================
So my issue is that when the Hateki Ends is triggered it destroys the lightnings but when two units get hit in the first action, only one group of 20 lightnings are destroyed. And the other will remain. It works fine with one unit only but when there are many it only destroys the other 20 lightnings. Pls help me. Sorry for my bad english
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
That is because your spell must be MUI, but currently it is not.
In your Hateki Cast, let's say this action picks two units:
  • Unit Group - Pick every unit in Ab_Group[1] and do (Actions)
    • Loop - Actions
You pick the first unit from unit group and create 20 lightning effects around it. You store those lightning effects in Lightning[ ] array under indices from 1 to 20.
Now you pick the second unit from the unit group and create another 20 lightning effects around it. But the issue is, that you store those lightning effects in Lightning[ ] array again under indices from 1 to 20 - so you effectively overwrote references to the 1st picked unit's lightning effects.

So when your Hateki End trigger attempts to destroy all lightning effects, it again destroys only those effects in Lightning[ ] array with indices from 1 to 20 - so only lightning from the second picked unit.

What you need to do is make the spell MUI - so you will need to store each target in a unit array under different index. The index of your lightning effects should then be calculated as "([index_of_target_unit] - 1) * 20 + n", where "n" is the number from 1 to 20.
So for example if an affected unit is stored in a unit array under index 4, then its lightning effects will be stored under indices "(4-1)*20 + n", so that would be indices 61-80.

You will need to understand dynamic indexing to make the spell MUI. Check this tutorial: Visualize: Dynamic Indexing
 
Status
Not open for further replies.
Top