Lightning Effect Display Bug

Level 6
Joined
Mar 16, 2014
Messages
116
I have a strange graphical issue that I have been unable to find a cause for. It is for Sweeping beams by D4RK_G4ND4LF found here: http://www.hiveworkshop.com/forums/...-1-a-180409/?prev=search=sweeping&d=list&r=20

I am having an issue getting the beam effect to appear on the first cast. It will not show up on any map other than the test map on the first cast, all variables are correctly copied.

Lightning Effect Display Bug

Someone else had this exact problem with this spell a couple years ago and a solution was proposed that apparently worked for him. When I copy in the code posted by Maker, however, I get an error saying "expected a name" and it fails.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,326
It is probably a syntax error or a variable that does not exist. Please post your triggers so we can see what causes this.
Do you have the variables?
- Sweep_zLoc (Point)
- Sweep_x2 (Real)
- Sweep_y2 (Real)
 
Level 6
Joined
Mar 16, 2014
Messages
116
It is correct that the variables do not exist. The post in 2014 is asking me to put in variable names that don't exist to try to fix the bug where the lightning does not show up on the first cast of the ability. I am going to guess that the spell map with the trigger has changed since 2014 or something.

Here are the triggers anyway if you don't want to download the map.
  • Sweep Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Sweep_DataCount = 14
      • Set zLoc = (Point(0.00, 0.00))
  • Sweep Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Eye Lasers
    • Actions
      • -------- Caster --------
      • Set u = (Triggering unit)
      • -------- Caster coords --------
      • Custom script: set udg_x2 = GetUnitX(udg_u)
      • Custom script: set udg_y2 = GetUnitY(udg_u)
      • -------- Two beams just look best but other numbers will work, too --------
      • Set i2 = 2
      • For each (Integer i) from 1 to i2, do (Actions)
        • Loop - Actions
          • -------- Radius of beam --------
          • Set r = 200.00
          • -------- Coords of target point --------
          • Custom script: set udg_x = GetSpellTargetX()
          • Custom script: set udg_y = GetSpellTargetY()
          • -------- Offset angle of beam --------
          • Set a = ((Atan2((y - y2), (x - x2))) + ((Real(((360 / i2) x i))) + 90.00))
          • -------- Calculating beam target point coords based on that --------
          • Set x = (x + (r x (Cos(a))))
          • Set y = (y + (r x (Sin(a))))
          • -------- Direction of beam --------
          • Set a = (a + 180.00)
          • -------- Create sweep lightning --------
          • Set Sweep_Max = (Sweep_Max + 1)
          • Lightning - Create a Finger of Death lightning effect from source zLoc to target zLoc
          • Set Sweep_Lightning[Sweep_Max] = (Last created lightning effect)
          • Custom script: if udg_Sweep_Group[udg_i] == null then
          • Custom script: set udg_Sweep_Group[udg_i] = CreateGroup()
          • Custom script: endif
          • -------- Caster again --------
          • Set Sweep_Caster[Sweep_Max] = u
          • -------- Start distance value (should be 0) --------
          • Set Sweep_Data[(Sweep_Max x Sweep_DataCount)] = 0.00
          • -------- Distance the beam will travel --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 1)] = (r x 2.00)
          • -------- Speed of beam (will move 8 every 1/0.03 sec) --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 2)] = 8.00
          • -------- X of target point --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 3)] = x
          • -------- Y of target point --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 4)] = y
          • -------- X component of speed --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 5)] = (Sweep_Data[((Sweep_Max x Sweep_DataCount) + 2)] x (Cos(a)))
          • -------- Y component of speed --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 6)] = (Sweep_Data[((Sweep_Max x Sweep_DataCount) + 2)] x (Sin(a)))
          • -------- Caster beam offset distance --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 7)] = 0.00
          • -------- Caster beam offset angle --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 8)] = (a - ((Atan2((y - y2), (x - x2))) + 90.00))
          • -------- Caster beam height offset --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 9)] = 215.00
          • -------- Aoe of beam --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 10)] = 150.00
          • -------- Damage of beam --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 11)] = (25.00 + (55.00 x (Real((Level of Eye Lasers for u)))))
          • -------- Sfx start count --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 12)] = 0.00
          • -------- Sfx max count --------
          • Set Sweep_Data[((Sweep_Max x Sweep_DataCount) + 13)] = 3.00
      • Trigger - Turn on Sweep Loop <gen>
  • Sweep Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • -------- Standard d4rk_g4nd4lf indexing --------
      • For each (Integer i) from 1 to Sweep_Max, do (Actions)
        • Loop - Actions
          • Set u = Sweep_Caster[i]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • u Not equal to No unit
              • (Life of u) Greater than 0.00
              • Sweep_Data[(i x Sweep_DataCount)] Less than Sweep_Data[((i x Sweep_DataCount) + 1)]
            • Then - Actions
              • -------- Count on distance --------
              • Set Sweep_Data[(i x Sweep_DataCount)] = (Sweep_Data[(i x Sweep_DataCount)] + Sweep_Data[((i x Sweep_DataCount) + 2)])
              • -------- Lightning coords caster --------
              • Custom script: set udg_x2 = GetUnitX(udg_u)
              • Custom script: set udg_y2 = GetUnitY(udg_u)
              • -------- Apply offset based on facing --------
              • Set a = ((Facing of u) + (Sweep_Data[((i x Sweep_DataCount) + 8)] - 90.00))
              • Set x2 = (x2 + (Sweep_Data[((i x Sweep_DataCount) + 7)] x (Cos(a))))
              • Set y2 = (y2 + (Sweep_Data[((i x Sweep_DataCount) + 7)] x (Sin(a))))
              • -------- Get terrain z-height --------
              • Custom script: call MoveLocation(udg_zLoc, udg_x2, udg_y2)
              • Custom script: set udg_r2 = GetLocationZ(udg_zLoc)
              • -------- Apply z offset --------
              • Set r2 = (r2 + Sweep_Data[((i x Sweep_DataCount) + 9)])
              • -------- Lightning coords target point --------
              • -------- Move lightning target coords --------
              • Set x = (Sweep_Data[((i x Sweep_DataCount) + 3)] + Sweep_Data[((i x Sweep_DataCount) + 5)])
              • Set y = (Sweep_Data[((i x Sweep_DataCount) + 4)] + Sweep_Data[((i x Sweep_DataCount) + 6)])
              • -------- Save new position --------
              • Set Sweep_Data[((i x Sweep_DataCount) + 3)] = x
              • Set Sweep_Data[((i x Sweep_DataCount) + 4)] = y
              • Custom script: call MoveLocation(udg_zLoc, udg_x, udg_y)
              • -------- Create special effect every x iterations --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Sweep_Data[((i x Sweep_DataCount) + 12)] Greater than or equal to Sweep_Data[((i x Sweep_DataCount) + 13)]
                • Then - Actions
                  • Set Sweep_Data[((i x Sweep_DataCount) + 12)] = 0.00
                  • Special Effect - Create a special effect at zLoc using Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
                  • Special Effect - Destroy (Last created special effect)
                • Else - Actions
                  • Set Sweep_Data[((i x Sweep_DataCount) + 12)] = (Sweep_Data[((i x Sweep_DataCount) + 12)] + 1.00)
              • Set r = Sweep_Data[((i x Sweep_DataCount) + 10)]
              • -------- Pick units in range --------
              • Custom script: call GroupEnumUnitsInRange(udg_g, udg_x, udg_y, udg_r, null)
              • Unit Group - Pick every unit in g and do (Actions)
                • Loop - Actions
                  • Set u2 = (Picked unit)
                  • -------- Check if picked unit is valid target --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Life of u2) Greater than 0.00
                      • (u2 is A structure) Equal to False
                      • (u2 is A flying unit) Equal to False
                      • (u2 is Mechanical) Equal to False
                      • (u2 is Magic Immune) Equal to False
                      • (u2 is in Sweep_Group[i]) Equal to False
                      • (u2 belongs to an enemy of (Owner of u)) Equal to True
                    • Then - Actions
                      • -------- Add to group so it won't get damaged twice --------
                      • Unit Group - Add u2 to Sweep_Group[i]
                      • -------- Damage --------
                      • Unit - Cause u to damage u2, dealing Sweep_Data[((i x Sweep_DataCount) + 11)] damage of attack type Chaos and damage type Universal
                    • Else - Actions
              • -------- Move lightning --------
              • Custom script: call MoveLightningEx(udg_Sweep_Lightning[udg_i], true, udg_x, udg_y, GetLocationZ(udg_zLoc), udg_x2, udg_y2, udg_r2)
            • Else - Actions
              • -------- Clean up and resort data --------
              • Set Sweep_Caster[i] = Sweep_Caster[Sweep_Max]
              • Lightning - Destroy Sweep_Lightning[i]
              • Set Sweep_Lightning[i] = Sweep_Lightning[Sweep_Max]
              • Unit Group - Remove all units from Sweep_Group[i]
              • Unit Group - Add all units of Sweep_Group[Sweep_Max] to Sweep_Group[i]
              • Unit Group - Remove all units from Sweep_Group[Sweep_Max]
              • For each (Integer i2) from 0 to (Sweep_DataCount - 1), do (Actions)
                • Loop - Actions
                  • Set Sweep_Data[((i x Sweep_DataCount) + i2)] = Sweep_Data[((Sweep_Max x Sweep_DataCount) + i2)]
              • Set Sweep_Max = (Sweep_Max - 1)
              • Set i = (i - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Sweep_Max Less than 1
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
  • Sweep Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • -------- Standard d4rk_g4nd4lf indexing --------
      • For each (Integer i) from 1 to Sweep_Max, do (Actions)
        • Loop - Actions
          • Set u = Sweep_Caster[i]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • u Not equal to No unit
              • (Life of u) Greater than 0.00
              • Sweep_Data[(i x Sweep_DataCount)] Less than Sweep_Data[((i x Sweep_DataCount) + 1)]
            • Then - Actions
              • -------- Count on distance --------
              • Set Sweep_Data[(i x Sweep_DataCount)] = (Sweep_Data[(i x Sweep_DataCount)] + Sweep_Data[((i x Sweep_DataCount) + 2)])
              • -------- Lightning coords caster --------
              • Custom script: set udg_x2 = GetUnitX(udg_u)
              • Custom script: set udg_y2 = GetUnitY(udg_u)
              • -------- Apply offset based on facing --------
              • Set a = ((Facing of u) + (Sweep_Data[((i x Sweep_DataCount) + 8)] - 90.00))
              • Set x2 = (x2 + (Sweep_Data[((i x Sweep_DataCount) + 7)] x (Cos(a))))
              • Set y2 = (y2 + (Sweep_Data[((i x Sweep_DataCount) + 7)] x (Sin(a))))
              • -------- Get terrain z-height --------
              • Custom script: call MoveLocation(udg_zLoc, udg_x2, udg_y2)
              • Custom script: set udg_r2 = GetLocationZ(udg_zLoc)
              • -------- Apply z offset --------
              • Set r2 = (r2 + Sweep_Data[((i x Sweep_DataCount) + 9)])
              • -------- Lightning coords target point --------
              • -------- Move lightning target coords --------
              • Set x = (Sweep_Data[((i x Sweep_DataCount) + 3)] + Sweep_Data[((i x Sweep_DataCount) + 5)])
              • Set y = (Sweep_Data[((i x Sweep_DataCount) + 4)] + Sweep_Data[((i x Sweep_DataCount) + 6)])
              • -------- Save new position --------
              • Set Sweep_Data[((i x Sweep_DataCount) + 3)] = x
              • Set Sweep_Data[((i x Sweep_DataCount) + 4)] = y
              • Custom script: call MoveLocation(udg_zLoc, udg_x, udg_y)
              • -------- Create special effect every x iterations --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Sweep_Data[((i x Sweep_DataCount) + 12)] Greater than or equal to Sweep_Data[((i x Sweep_DataCount) + 13)]
                • Then - Actions
                  • Set Sweep_Data[((i x Sweep_DataCount) + 12)] = 0.00
                  • Special Effect - Create a special effect at zLoc using Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
                  • Special Effect - Destroy (Last created special effect)
                • Else - Actions
                  • Set Sweep_Data[((i x Sweep_DataCount) + 12)] = (Sweep_Data[((i x Sweep_DataCount) + 12)] + 1.00)
              • Set r = Sweep_Data[((i x Sweep_DataCount) + 10)]
              • -------- Pick units in range --------
              • Custom script: call GroupEnumUnitsInRange(udg_g, udg_x, udg_y, udg_r, null)
              • Unit Group - Pick every unit in g and do (Actions)
                • Loop - Actions
                  • Set u2 = (Picked unit)
                  • -------- Check if picked unit is valid target --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Life of u2) Greater than 0.00
                      • (u2 is A structure) Equal to False
                      • (u2 is A flying unit) Equal to False
                      • (u2 is Mechanical) Equal to False
                      • (u2 is Magic Immune) Equal to False
                      • (u2 is in Sweep_Group[i]) Equal to False
                      • (u2 belongs to an enemy of (Owner of u)) Equal to True
                    • Then - Actions
                      • -------- Add to group so it won't get damaged twice --------
                      • Unit Group - Add u2 to Sweep_Group[i]
                      • -------- Damage --------
                      • Unit - Cause u to damage u2, dealing Sweep_Data[((i x Sweep_DataCount) + 11)] damage of attack type Chaos and damage type Universal
                    • Else - Actions
              • -------- Move lightning --------
              • Custom script: call MoveLightningEx(udg_Sweep_Lightning[udg_i], true, udg_x, udg_y, GetLocationZ(udg_zLoc), udg_x2, udg_y2, udg_r2)
            • Else - Actions
              • -------- Clean up and resort data --------
              • Set Sweep_Caster[i] = Sweep_Caster[Sweep_Max]
              • Lightning - Destroy Sweep_Lightning[i]
              • Set Sweep_Lightning[i] = Sweep_Lightning[Sweep_Max]
              • Unit Group - Remove all units from Sweep_Group[i]
              • Unit Group - Add all units of Sweep_Group[Sweep_Max] to Sweep_Group[i]
              • Unit Group - Remove all units from Sweep_Group[Sweep_Max]
              • For each (Integer i2) from 0 to (Sweep_DataCount - 1), do (Actions)
                • Loop - Actions
                  • Set Sweep_Data[((i x Sweep_DataCount) + i2)] = Sweep_Data[((Sweep_Max x Sweep_DataCount) + i2)]
              • Set Sweep_Max = (Sweep_Max - 1)
              • Set i = (i - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Sweep_Max Less than 1
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,326
I don't have time to take look a the triggers now. It's late for me. I will have a look at them tomorrow.
 
Level 6
Joined
Mar 16, 2014
Messages
116
Additional information I found: This bug only occurs if the unit casting the ability is not on the map at game start. If I place the unit on the map and have him cast the ability, it works the first time. If I buy the hero from the tavern and have him cast it, it will not work the first time. Seems to work if the hero has casted another ability before it as well.
 
Last edited:

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,326
I checked the map and I did not find anything. It worked when I tested it. If you could send me the exact map, where this bug happens, maybe I can see what's causing it.
I don't know what Maker meant with the solution. The lightning is probably null, if the location is null as well. But changing the position of the location does not change anything, if it is null.
 
Top