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

[Trigger] [Solved] Calculating coordinate of the parallel line splash?

Level 8
Joined
May 12, 2018
Messages
106
Hello readers,
I want to create a normal attack that deals splash damage to the attacker's parallel lines. (It would be convenient considering the Colossus of Starcraft II)
But this is much more difficult than the coordinate calculations that I'd got answered before. I need your help.
I am Using Damage Engine 5.9.0.0.
선.gif
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,536

Using the above system, create a line that starts at the origin of the primary target and then extend it outwards over time.

For the Colossus attack you could use two lines that start offset from the primary target and then move them over time.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
You can look how StarCraft II implemented it. They literally do (did, last checked a long time ago) a bunch of point offsets. In Warcraft III this would have to be bigger radius from point enums with a unit in range filter to factor in unit collision rather than just unit origin like radius from point enums do.

Start by finding the angle from the colossus (attacker) to the marine (attacked). Then add 90 degres to that so that it is perpendicular to the line of attack. You can then use a polar offset from the attacker to get the far side point using this angle and some distance. Then in a loop add units to a filter group in range of that point, and then offset by a negative distance representing each step. Repeat this until the far point on the other side is reached. Finally damage the filter group.

The filter group's purpose is to prevent the same unit being damaged multiple times due to overlapping 2 or more points. You can either add units to the filter group and then damage them all at the end, or you can check if the unit is in the filter group before damaging it so it can only be damaged once.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,536
I realize the suggestion in my last post was not really necessary. Here's a working example of the Colossus attack which should function closely to what the Good Dr said.

It was designed for SD mode and may have visual glitches in HD.

Edit: So I can't figure out what's causing it to break. For some reason the Lightning isn't MUI while everything else is and I can't tell why. Visual glitches aside I believe everything else is working properly.
  • Line Cross Attack Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set VariableSet LA_Hash = (Last created hashtable)
  • Line Cross Attack
    • Events
      • Unit - A unit About to take damage
    • Conditions
      • (Level of Crossfire for (Damage source)) Greater than 0
      • (Damage From Normal Attack) Equal to True
    • Actions
      • Set VariableSet LA_Index = (LA_Index + 1)
      • -------- --------
      • Set VariableSet LA_AttackingUnit[LA_Index] = (Damage source)
      • Set VariableSet LA_AttackingPlayer[LA_Index] = (Owner of LA_AttackingUnit[LA_Index])
      • -------- --------
      • -------- ============================================================ --------
      • -------- Define the line distance traveled, starting angles, speed, and area of effect: --------
      • -------- ============================================================ --------
      • Set VariableSet LA_Distance[LA_Index] = 200.00
      • Set VariableSet LA_Angle[LA_Index] = ((Facing of LA_AttackingUnit[LA_Index]) + 90.00)
      • Set VariableSet LA_Speed[LA_Index] = 20.00
      • Set VariableSet LA_AreaOfEffect[LA_Index] = 100.00
      • -------- --------
      • -------- ( Optional ) Change the damage dealt and attack type: --------
      • Set VariableSet LA_Damage[LA_Index] = (Damage taken)
      • Set VariableSet LA_AttackType[LA_Index] = (Damage Attack Type)
      • -------- ============================================================ --------
      • -------- --------
      • Custom script: set udg_LA_TargetsHit = CreateGroup()
      • Hashtable - Save Handle OfLA_TargetsHit as 1 of LA_Index in LA_Hash.
      • -------- --------
      • Set VariableSet LA_Points[1] = (Position of LA_AttackingUnit[LA_Index])
      • Set VariableSet LA_Points[2] = (Position of (Damage Target))
      • -------- --------
      • Set VariableSet X1 = (X of LA_Points[1])
      • Set VariableSet Y1 = (Y of LA_Points[1])
      • -------- --------
      • -------- End X/Y: --------
      • Set VariableSet X2 = (X of LA_Points[2])
      • Set VariableSet Y2 = (Y of LA_Points[2])
      • Hashtable - Save X2 as 2 of LA_Index in LA_Hash.
      • Hashtable - Save Y2 as 3 of LA_Index in LA_Hash.
      • -------- --------
      • -------- Start and End Z: --------
      • Set VariableSet Z1 = (Current flying height of LA_AttackingUnit[LA_Index])
      • Set VariableSet Z2 = (Current flying height of (Damage Target))
      • Hashtable - Save Z1 as 4 of LA_Index in LA_Hash.
      • Hashtable - Save Z2 as 5 of LA_Index in LA_Hash.
      • -------- --------
      • Set VariableSet LA_Points[3] = (LA_Points[2] offset by LA_Distance[LA_Index] towards LA_Angle[LA_Index] degrees.)
      • Set VariableSet X2 = (X of LA_Points[3])
      • Set VariableSet Y2 = (Y of LA_Points[3])
      • Custom script: set udg_LA_Lightning[1] = AddLightningEx("AFOD", true, udg_X1, udg_Y1, udg_Z1, udg_X2, udg_Y2, udg_Z2)
      • Hashtable - Save Handle OfLA_Lightning[1] as 6 of LA_Index in LA_Hash.
      • -------- --------
      • Set VariableSet LA_Points[4] = (LA_Points[2] offset by (LA_Distance[LA_Index] x -1.00) towards LA_Angle[LA_Index] degrees.)
      • Set VariableSet X2 = (X of LA_Points[4])
      • Set VariableSet Y2 = (Y of LA_Points[4])
      • Custom script: set udg_LA_Lightning[2] = AddLightningEx("AFOD", true, udg_X1, udg_Y1, udg_Z1, udg_X2, udg_Y2, udg_Z2)
      • Hashtable - Save Handle OfLA_Lightning[2] as 7 of LA_Index in LA_Hash.
      • -------- --------
      • -------- Used to determine when to end the instance. +1 is to address floating point errors: --------
      • Set VariableSet LA_End[LA_Index] = ((LA_Distance[LA_Index] x -1.00) + 1.00)
      • -------- --------
      • Custom script: call RemoveLocation(udg_LA_Points[1])
      • Custom script: call RemoveLocation(udg_LA_Points[2])
      • Custom script: call RemoveLocation(udg_LA_Points[3])
      • Custom script: call RemoveLocation(udg_LA_Points[4])
      • -------- --------
      • -------- The attack isn't supposed to deal damage: --------
      • Event Response - Set Damage of Unit Damaged Event to 0.00
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LA_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on Line Cross Attack Loop <gen>
        • Else - Actions
  • Line Cross Attack Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LA_Loop) from 1 to LA_Index, do (Actions)
        • Loop - Actions
          • -------- Targets Hit (so far): --------
          • Set VariableSet LA_TargetsHit = (Load 1 of LA_Loop in LA_Hash.)
          • -------- --------
          • -------- Start X/Y: --------
          • Custom script: set udg_X1 = GetUnitX(udg_LA_AttackingUnit[udg_LA_Loop])
          • Custom script: set udg_X2 = GetUnitY(udg_LA_AttackingUnit[udg_LA_Loop])
          • -------- --------
          • -------- End X/Y: --------
          • Set VariableSet X2 = (Load 2 of LA_Loop from LA_Hash.)
          • Set VariableSet Y2 = (Load 3 of LA_Loop from LA_Hash.)
          • -------- --------
          • -------- Start and End Z: --------
          • Set VariableSet Z1 = (Load 4 of LA_Loop from LA_Hash.)
          • Set VariableSet Z2 = (Load 5 of LA_Loop from LA_Hash.)
          • -------- --------
          • -------- The origin of the target: --------
          • Set VariableSet LA_Points[1] = (Point(X2, Y2))
          • -------- --------
          • -------- Get new lightning positions: --------
          • Set VariableSet LA_Points[2] = (LA_Points[1] offset by LA_Distance[LA_Loop] towards LA_Angle[LA_Loop] degrees.)
          • Set VariableSet LA_Points[3] = (LA_Points[1] offset by (LA_Distance[LA_Loop] x -1.00) towards LA_Angle[LA_Loop] degrees.)
          • -------- --------
          • -------- Damage around first lightning: --------
          • Set VariableSet LA_TempGroup = (Units within LA_AreaOfEffect[LA_Loop] of LA_Points[2].)
          • Unit Group - Pick every unit in LA_TempGroup and do (Actions)
            • Loop - Actions
              • Set VariableSet LA_Target = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (LA_Target is in LA_TargetsHit.) Equal to False
                  • (LA_Target is alive) Equal to True
                  • (LA_Target belongs to an enemy of LA_AttackingPlayer[LA_Loop].) Equal to True
                  • (LA_Target is invulnerable) Equal to False
                • Then - Actions
                  • Unit - Cause LA_AttackingUnit[LA_Loop] to damage LA_Target, dealing LA_Damage[LA_Loop] damage of attack type LA_AttackType[LA_Loop] and damage type Normal
                  • Unit Group - Add LA_Target to LA_TargetsHit
                • Else - Actions
          • Custom script: call DestroyGroup(udg_LA_TempGroup)
          • -------- --------
          • -------- Damage around second lightning: --------
          • Set VariableSet LA_TempGroup = (Units within LA_AreaOfEffect[LA_Loop] of LA_Points[3].)
          • Unit Group - Pick every unit in LA_TempGroup and do (Actions)
            • Loop - Actions
              • Set VariableSet LA_Target = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (LA_Target is in LA_TargetsHit.) Equal to False
                  • (LA_Target is alive) Equal to True
                  • (LA_Target belongs to an enemy of LA_AttackingPlayer[LA_Loop].) Equal to True
                  • (LA_Target is invulnerable) Equal to False
                • Then - Actions
                  • Unit - Cause LA_AttackingUnit[LA_Loop] to damage LA_Target, dealing LA_Damage[LA_Loop] damage of attack type LA_AttackType[LA_Loop] and damage type Normal
                  • Unit Group - Add LA_Target to LA_TargetsHit
                • Else - Actions
          • Custom script: call DestroyGroup(udg_LA_TempGroup)
          • -------- --------
          • -------- Move first lightning: --------
          • Set VariableSet LA_Lightning[1] = (Load 6 of LA_Loop in LA_Hash.)
          • Set VariableSet X2 = (X of LA_Points[2])
          • Set VariableSet Y2 = (Y of LA_Points[2])
          • Custom script: call MoveLightningEx(udg_LA_Lightning[1], true, udg_X1, udg_Y1, udg_Z1, udg_X2, udg_Y2, udg_Z2)
          • -------- --------
          • -------- Move second lightning: --------
          • Set VariableSet LA_Lightning[2] = (Load 7 of LA_Loop in LA_Hash.)
          • Set VariableSet X2 = (X of LA_Points[3])
          • Set VariableSet Y2 = (Y of LA_Points[3])
          • Custom script: call MoveLightningEx(udg_LA_Lightning[2], true, udg_X1, udg_Y1, udg_Z1, udg_X2, udg_Y2, udg_Z2)
          • -------- --------
          • -------- Create some optional fireworks: --------
          • Special Effect - Create a special effect at LA_Points[2] using Abilities\Weapons\LordofFlameMissile\LordofFlameMissile.mdl
          • Special Effect - Destroy (Last created special effect)
          • Special Effect - Create a special effect at LA_Points[3] using Abilities\Weapons\LordofFlameMissile\LordofFlameMissile.mdl
          • Special Effect - Destroy (Last created special effect)
          • -------- --------
          • Custom script: call RemoveLocation(udg_LA_Points[1])
          • Custom script: call RemoveLocation(udg_LA_Points[2])
          • Custom script: call RemoveLocation(udg_LA_Points[3])
          • -------- --------
          • -------- Adjust the distance to calculate new positions for the lightning (this acts like Speed): --------
          • Set VariableSet LA_Distance[LA_Loop] = (LA_Distance[LA_Loop] - LA_Speed[LA_Loop])
          • -------- --------
          • -------- Check if finished: --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LA_Distance[LA_Loop] Less than or equal to LA_End[LA_Loop]
            • Then - Actions
              • -------- Clean up: --------
              • Lightning - Destroy LA_Lightning[1]
              • Lightning - Destroy LA_Lightning[2]
              • Custom script: call DestroyGroup(udg_LA_TargetsHit)
              • Hashtable - Clear all child hashtables of child LA_Loop in LA_Hash.
              • -------- --------
              • -------- Replace the current instance with the last instance in the For Loop: --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LA_Loop Not equal to LA_Index
                • Then - Actions
                  • Set VariableSet LA_AttackingUnit[LA_Loop] = LA_AttackingUnit[LA_Index]
                  • Set VariableSet LA_AttackingPlayer[LA_Loop] = LA_AttackingPlayer[LA_Index]
                  • Set VariableSet LA_Damage[LA_Loop] = LA_Damage[LA_Index]
                  • Set VariableSet LA_Distance[LA_Loop] = LA_Distance[LA_Index]
                  • Set VariableSet LA_Angle[LA_Loop] = LA_Angle[LA_Index]
                  • Set VariableSet LA_Speed[LA_Loop] = LA_Speed[LA_Index]
                  • Set VariableSet LA_AreaOfEffect[LA_Loop] = LA_AreaOfEffect[LA_Index]
                  • Set VariableSet LA_AttackType[LA_Loop] = LA_AttackType[LA_Index]
                  • Set VariableSet LA_End[LA_Loop] = LA_End[LA_Index]
                  • -------- --------
                  • Hashtable - Save Handle Of(Load 1 of LA_Index in LA_Hash.) as 1 of LA_Loop in LA_Hash.
                  • Hashtable - Save (Load 2 of LA_Index from LA_Hash.) as 2 of LA_Loop in LA_Hash.
                  • Hashtable - Save (Load 3 of LA_Index from LA_Hash.) as 3 of LA_Loop in LA_Hash.
                  • Hashtable - Save (Load 4 of LA_Index from LA_Hash.) as 4 of LA_Loop in LA_Hash.
                  • Hashtable - Save (Load 5 of LA_Index from LA_Hash.) as 5 of LA_Loop in LA_Hash.
                  • Hashtable - Save Handle Of(Load 6 of LA_Index in LA_Hash.) as 6 of LA_Loop in LA_Hash.
                  • Hashtable - Save Handle Of(Load 7 of LA_Index in LA_Hash.) as 7 of LA_Loop in LA_Hash.
                • Else - Actions
              • -------- --------
              • -------- Push the For Loop back a cycle so it repeats. It will now reference the last instance which was just shifted over: --------
              • Set VariableSet LA_Index = (LA_Index - 1)
              • Set VariableSet LA_Loop = (LA_Loop - 1)
              • -------- --------
              • -------- Turn off the Loop while no instances are active: --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LA_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
 

Attachments

  • Line Cross Attack 2.w3m
    27.2 KB · Views: 4
Last edited:
Top