• 🏆 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] Spawning Effects in a circular lines

Status
Not open for further replies.
Level 5
Joined
Feb 8, 2015
Messages
93
Not sure if the title is misleading, but I'll make a drawing to demonstrate the issue.

I'm trying to get Holy Light special effects (actually just a unit with the holy light model) to spawn in seven lines of 3 effects in a circle (see drawing in Spoiler)

A Hero casts a point-targeted spell, and the effects are supposed to emnate out of that point in a circle.
Nothing displays however...

I'm trying to run a loop inside a loop with Integer A/B - is that an issue?

The trigger itself is fairly lengthy, but I've just cut out all but the important bit (the bit that's not working)

Rough Sketch.png

  • DEHero Splendour
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to DarkElf: Splendour (GrandMissionaryW - Channel)
    • Actions
      • Set Splendour_Tempp1 = (Target point of ability being cast)
      • -------- Flashy Effects (initially resets angle) --------
      • Set Splendour_ang = 0.00
      • For each (Integer A) from 1 to 7, do (Actions)
        • Loop - Actions
          • -------- Moves the angle to the next stage, and resets the distance --------
          • Set Splendour_ang = (Splendour_ang + (360.00 / 7.00))
          • Set Splendour_dist = 100.00
          • For each (Integer B) from 1 to 3, do (Actions)
            • Loop - Actions
              • -------- Creates 3 effects in a line given by the angle, and with increasing dist --------
              • Set Tempp2 = (Splendour_Tempp1 offset by Splendour_dist towards Splendour_ang degrees)
              • Set Splendour_dist = (Splendour_dist + 100.00)
              • Unit - Create 1 Dummy Holy Light Effect for Neutral Passive at Splendour_Tempp2 facing Default building facing degrees
              • Unit - Add a 0.98 second Generic expiration timer to (Last created unit)
              • Custom script: call RemoveLocation(udg_Splendour_Tempp2)
      • -------- Cleanup --------
      • Custom script: call RemoveLocation(udg_Splendour_Tempp1)
      • Custom script: call RemoveLocation(udg_Splendour_Tempp2)
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
You create the dummy unit on Splendour_Tempp2, which isn't defined anywhere in the trigger you are showing us. I believe it should be created on Tempp2 because that is the variable you use to store the offset location:
  • Set Tempp2 = (Splendour_Tempp1 offset by Splendour_dist towards Splendour_ang degrees)
I'm trying to run a loop inside a loop with Integer A/B - is that an issue?
It can pose as an issue if you use Integer A/B in other triggers that can run in the middle of this trigger (ex: unit enters map, region, etc).
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Check that all the loops iterate correctly. A debug message in the inner loop should print exactly 24 times to achieve what you want. The outer loop should iterate 8 times each with an inner loop running 3 times.

Be aware 100 distance is <1 tile (128 distance). As such all effects might be very close together around the target point.
 
Level 8
Joined
Jan 28, 2016
Messages
486
To add to what the guys above have already stated, you're not actually changing the angle for each Integer A. The way you have it at the moment, you're setting the variable to Splendour_ang + (360.00/7.00) each time but it won't change whether it's at 1 or 100 in the loop because it will give you the same value every time. Instead try setting the angle to Integer A x 45°. Hope this helps.

  • DEHero Splendour
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to DarkElf: Splendour (GrandMissionaryW - Channel)
    • Actions
      • Set Splendour_Tempp1 = (Target point of ability being cast)
      • -------- Flashy Effects (initially resets angle) --------
      • Set Splendour_ang = 0.00
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • -------- Moves the angle to the next stage, and resets the distance --------
          • Set Splendour_ang = ((Real((Integer A))) x 45.00)
          • Set Splendour_dist = 100.00
          • For each (Integer B) from 1 to 3, do (Actions)
            • Loop - Actions
              • -------- Creates 3 effects in a line given by the angle, and with increasing dist --------
              • Set Tempp2 = (Splendour_Tempp1 offset by Splendour_dist towards Splendour_ang degrees)
              • Set Splendour_dist = (Splendour_dist + 100.00)
              • Unit - Create 1 Dummy Holy Light Effect for Neutral Passive at Splendour_Tempp2 facing Default building facing degrees
              • Unit - Add a 0.98 second Generic expiration timer to (Last created unit)
              • Custom script: call RemoveLocation(udg_Splendour_Tempp2)
      • -------- Cleanup --------
      • Custom script: call RemoveLocation(udg_Splendour_Tempp1)
 
Level 5
Joined
Feb 8, 2015
Messages
93
Thanks for all the help guys, I fixed the issues you mentioned (the dummest of which was me saving Tempp2 rather than Splendour_Tempp2 which I actually needed...)

I'll post the functioning trigger here, in case anyone else comes across a similar problem and wants to have a look.
  • DEHero Splendour
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to DarkElf: Splendour (GrandMissionaryW - Channel)
    • Actions
      • Set Splendour_Tempp1 = (Target point of ability being cast)
      • -------- Flashy Effects (initially resets angle) --------
      • Set Splendour_ang = 0.00
      • For each (Integer Splendour_tempiA) from 1 to 8, do (Actions)
        • Loop - Actions
          • -------- Moves the angle to the next stage, and resets the distance --------
          • Set Splendour_ang = ((Real(Splendour_tempiA)) x 45.00)
          • Set Splendour_dist = 128.00
          • For each (Integer Splendour_tempiB) from 1 to 3, do (Actions)
            • Loop - Actions
              • -------- Creates 3 effects in a line given by the angle, and with increasing dist --------
              • Set Splendour_Tempp2 = (Splendour_Tempp1 offset by Splendour_dist towards Splendour_ang degrees)
              • Set Splendour_dist = (Splendour_dist + 128.00)
              • Unit - Create 1 Dummy Holy Light Effect for Neutral Passive at Splendour_Tempp2 facing Default building facing degrees
              • Unit - Add a 0.98 second Generic expiration timer to (Last created unit)
              • Custom script: call RemoveLocation(udg_Splendour_Tempp2)
      • -------- Cleanup --------
      • Custom script: call RemoveLocation(udg_Splendour_Tempp1)
      • Custom script: call RemoveLocation(udg_Splendour_Tempp2)
      • Custom script: call DestroyGroup(udg_Splendour_Tempug1)
      • Custom script: call DestroyGroup(udg_Splendour_Tempug2)

+Rep!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
To add to what the guys above have already stated, you're not actually changing the angle for each Integer A. The way you have it at the moment, you're setting the variable to Splendour_ang + (360.00/7.00) each time but it won't change whether it's at 1 or 100 in the loop because it will give you the same value every time.
Please explain how it cannot change every loop?

A0 = 0
A1 = A0 + 1 = 1
A2 = A1 + 1 = 2
A3 = A2 + 1 = 3
...

The fact it should be 360/8 is another problem. However what he did appears to be perfectly fine incrementing to me.
 
Last edited:
Level 5
Joined
Feb 8, 2015
Messages
93
Please explain how it cannot change every loop?

A0 = 0
A1 = A0 + 1 = 1
A2 = A1 + 1 = 2
A3 = A2 + 1 = 3
...

The fact it should be 360/8 is another problem. However what he did appears to be perfectly fine incrementing to me.
I can confirm that this works perfectly well - it is a solution I have used several times.

The angle = 45*LoopInteger is a very elegant solution as well.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
The angle = 45*LoopInteger is a very elegant solution as well.
That only works because 360/8 is 45. If you were to do any other number that doesn't give you 45, your effect would look weird. It's better off just taking 360 and dividing it by the number of effects to evenly spread the effects in a circle.
 
Status
Not open for further replies.
Top