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

[Solved] Loop not executing in its enirety.

Status
Not open for further replies.

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Hello, Hive.

I've recently got this little problem on my hand. Basically I have a spell that unleashes Death Coils around the hero that deal damage. Each "Death Coil" is based on a Carrion Swarm ability which in this trigger is ToD_Dummy_Ability. I use a loop to direct each Death Coil in the necessary degrees so it can make a full circle.

Here is the issue: At first, the spell functions correctly. Early on in the game several (~3) of the Death Coils no longer show up (Degrees 336, 312 and 288 I believe). The ability deals damage via Unit Group pick which is not shown in the trigger below, since the damage dealt is not related to the Death Coils which are purely visual.

Basically the last Death Coils in the loop do not happen after a certain point of time. What could be the reason?

[trigger=""]Unholy Fury
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Unholy Fury
Actions
Set Generic_Point = (Position of (Triggering unit))
Set ToD_Dummy_Ability = Taste of Death(dummy)
For each (Integer A) from 1 to 15, do (Actions)
Loop - Actions
Set ToD_Target_Location = (Generic_Point offset by 50.00 towards (24.00 x (Real((Integer A)))) degrees)
Unit - Create 1 Dummy (Generic Uses) for (Owner of (Triggering unit)) at Generic_Point facing Default building facing degrees
Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
Unit - Add ToD_Dummy_Ability to (Last created unit)
Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm ToD_Target_Location
Custom script: call RemoveLocation(udg_ToD_Target_Location)
Custom script: call RemoveLocation(udg_Generic_Point)
[/trigger]
 
"Integer A" is a global reference. If an other triggers gets fired for example by the "Unit - Order" event and also uses "Integer A" loop, the value will remain when the runtime execution jumps back to your first trigger.

and what "You could print values in the loop." means.
That you can print the value of "Integer A" in each loop run. Also print the value once after the loop with also an extra info like "after loop".
 
Not entirely sure what you mean with "Is ensured "Integer A" doesn't get new values there?" and what "You could print values in the loop." means.
He means if you have another trigger with the event "Unit enters Map" or "Unit gains order" and one of this Contains a for each Integer A, It can lead to not wanted results.
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Sorry for the delayed response. The issue must have been what @IcemanBo reported, namely the Integer A messing things up. Here is the fix:
[trigger=""]
Unholy Fury
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Unholy Fury
Actions
Set UnholyFury_Ability = Taste of Death(dummy)
Set UnholyFury_Count = 0
For each (Integer UnholyFury_Count) from 1 to 15, do (Actions)
Loop - Actions
Set UnholyFury_Point = (Generic_Point offset by 50.00 towards (24.00 x (Real(UnholyFury_Count))) degrees)
Unit - Create 1 Dummy (Generic Uses) for (Owner of (Triggering unit)) at Generic_Point facing Default building facing degrees
Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
Unit - Add UnholyFury_Ability to (Last created unit)
Unit - Order (Last created unit) to Undead Dreadlord - Carrion Swarm UnholyFury_Point
Custom script: call RemoveLocation(udg_UnholyFury_Point)
Custom script: call RemoveLocation(udg_Generic_Point)
Custom script: call DestroyGroup(udg_Generic_Group)
-------- - --------
[/trigger]
 
Status
Not open for further replies.
Top