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

Lighting Impact

Level 15
Joined
Dec 6, 2008
Messages
345
Hi, I can't figure out where is the problem. I want to this trigger to cast lighting bold after short delay and damage all units in AOE. But it damages (kills) only one unit in the AOE.

  • LightingImpact
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Lighting Impact (SORC)
    • Actions
      • Set VariableSet Integer = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet LightingImpactDelay[Integer] = 0.75
      • Set VariableSet LightingImpactIsActive[Integer] = True
      • Set VariableSet LightingImpactLocation[Integer] = (Target point of ability being cast)
      • Set VariableSet LightingImpactCaster[Integer] = (Triggering unit)
      • Set VariableSet Point = (Target point of ability being cast)
      • Special Effect - Create a special effect at Point using Abilities\Spells\Human\Feedback\ArcaneTowerAttack.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_Point)
      • Trigger - Turn on LightingImpactEffect <gen>
  • LightingImpactEffect
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet Integer = 0
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LightingImpactIsActive[(Integer A)] Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LightingImpactDelay[(Integer A)] Greater than 0.00
                • Then - Actions
                  • Set VariableSet LightingImpactDelay[(Integer A)] = (LightingImpactDelay[(Integer A)] - 0.03)
                • Else - Actions
                  • Set VariableSet Point = LightingImpactLocation[(Integer A)]
                  • Unit - Create 1 Lighting for (Owner of LightingImpactCaster[(Integer A)]) at Point facing Default building facing degrees
                  • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                  • Sound - Play LightningBolt <gen> at 100.00% volume, located at Point with Z offset 0.00
                  • Set VariableSet Group = (Units within 280.00 of Point matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of LightingImpactCaster[(Integer A)]).) Equal to True) and (((Matching unit) is A ground unit) Equal to True))).)
                  • Custom script: call RemoveLocation(udg_Point)
                  • Unit Group - Pick every unit in Group and do (Actions)
                    • Loop - Actions
                      • Unit - Cause LightingImpactCaster[(Integer A)] to damage (Picked unit), dealing 500.00 damage of attack type Magic and damage type Normal
                  • Custom script: call DestroyGroup(udg_Group)
                  • Set VariableSet LightingImpactIsActive[(Integer A)] = False
            • Else - Actions
              • Set VariableSet Integer = (Integer + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Integer Equal to 6
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 
Level 39
Joined
Feb 27, 2007
Messages
5,023
You’re targeting multiple hostile, non-flying units within 280 of the initial location? I see no reason it shouldn’t damage every unit in the group, so if it gets one it should get them all.

My only guess then is that you’re falling victim to how Units in Range works. It will not pick units unless the origin of their model lies within the specified range of the target; normal abilities will affect any units whose models overlap the targeted area. Basically collision size isn’t taken into account. In order to fix this you need to add 1/2 of the maximum collision size in your map to your search radius, or just pick +32 which will probably be good enough.

Your method in general is pretty good for MPI (not MUI, though) but what you’re doing with Integer can be simplified. Instead you can increment Integer by +1 when a cast is detected, then decrement it by -1 when the impact occurs; check if it’s 0 at the end of the loop, and if so then all instances of the spell have finished.
 
Level 39
Joined
Feb 27, 2007
Messages
5,023
My only guess then is that you’re falling victim to how Units in Range works. It will not pick units unless the origin of their model lies within the specified range of the target; normal abilities will affect any units whose models overlap the targeted area. Basically collision size isn’t taken into account. In order to fix this you need to add 1/2 of the maximum collision size in your map to your search radius, or just pick +32 which will probably be good enough.
Please read and look at the diagram below for what I think is happening. A normal wc3 spell will pick up the unit in red in this scenario because its collision size overlaps the search area, even though it's further than 280 away from the search point. Units in Range will not pick up this unit because it doesn't take collision size into account.

1703112346410.png
 
Top