Unit Group Problem (adding and removing)

Level 11
Joined
Oct 9, 2015
Messages
721
I have an unit problem and hope somebody can help me with it! I searched a lot in the hive before, that's why I'm creating this thread.

My problem is I have a trigger that fires when a unit dies, then I pick some units arround it and make actions with them, THEN I create another unit like the one who died to fire the trigger and add 0.5 expiration timer to it, this is making the trigger pick the same units twice, I tried add said units to a group after they are picked and check with a boolean to only pick the units if they aren't in that group, it works fine, but I can't seem to be able to remove them from the group after.

  • Trigger
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Dummy
        • Then - Actions
          • Set Loc1 = (Position of (Triggering unit))
          • Unit Group - Pick every unit in (Units within 512.00 of Loc1) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Picked unit) Not equal to (Triggering unit)
                  • ((Picked unit) is in UnitGroup) Equal to False
                • Then - Actions
                  • Unit - Cause (Triggering unit) to damage (Picked unit), dealing 10.00 damage of attack type Spells and damage type Normal
                  • Unit Group - Add (Picked unit) to UnitGroup
                • Else - Actions
                  • Unit Group - Remove (Picked unit) from UnitGroup
          • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at Loc1 facing (Facing of (Triggering unit)) degrees
          • Unit - Add a 0.05 second Generic expiration timer to (Last created unit)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Loc1)
 
Level 36
Joined
Jul 22, 2015
Messages
3,491
Well you shouldn't be dealing damage to dead units, so why don't you add a filter to check to make sure that the (Picked unit) isn't dead instead? You don't have to check if (Picked unit) Not equal to (Triggering unit) and if (Picked unit) is in UnitGroup) Equal to False

I'm also not entirely sure if your logic is correct. You add (Picked unit) to UnitGroup if they pass the filters, but you remove (Picked unit) if they do not? Where are you adding this (Picked unit) in the first place? From what I can see, units can only be added to UnitGroup if they pass the filters. What is the purpose of the UnitGroup variable all together?

Another side note is that the unit group will leak everytime A unit Dies and you have the possibility of removing a null location. Move the call RemoveLocation(udg_Loc1) inside the Then - Actions.
 
Level 11
Joined
Oct 9, 2015
Messages
721
I check to see if picked unit not equal to triggering unit to avoiding it being damaged, the unit group check is meant so that the unit is only picked once when the first dummy dies, but I don't know how to properly do it. I need to make the picked unit only be affected once, but when creating another unit it will be picked twice. by the way thanks for pointing the Loc1 removal!
 
Level 36
Joined
Jul 22, 2015
Messages
3,491
I check to see if picked unit not equal to triggering unit to avoiding it being damaged
Just do what I said and add a condition that checks if the (Picked unit) is alive. You shouldn't be dealing damage to dead units anyway.

the unit group check is meant so that the unit is only picked once when the first dummy dies
Do you mind explaining more in detail why you create another dummy? I read that you said you want to fire the trigger event again, but I'm a little confused.
 
Level 11
Joined
Oct 9, 2015
Messages
721
I'll add the "alive" check... I need to refire the trigger because the second dummy is actually created in another location, very close to the first location, that's why it will pick the same unit again, and I need to be picked only once. Imagine there are 2 units side-by-side, the first dummy is created at the left side of the first unit, the second in the middle of them. The second dummy will pick the two units, but first unit has already been picked so I don't want to pick it anymore.
 
Level 36
Joined
Jul 22, 2015
Messages
3,491
the second dummy is actually created in another location, very close to the first location, that's why it will pick the same unit again, and I need to be picked only once.

Is there another trigger involved with this then? You create the dummy on the same location the dummy died in. I never see you offset the location. On top of that, wouldn't that just create an infinite loop of dying dummies constantly dealing damage in an AoE?

Also, to properly remove the units after they've taken damage, you need some sort of timer of when you want to remove it. Once the timer expires, just pick all units in UnitGroup and remove them. If the unit were to somehow get out of range before the 2nd dummy dies, they would never be removed from the group again until they were to be caught in another AoE of a dying dummy.
 
Level 11
Joined
Oct 9, 2015
Messages
721
This first trigger creates the first dummy
  • FIRST TRIGGER
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Ataque
          • (Ability being cast) Equal to Ataque Pesado
    • Actions
      • Set Loc1 = (Position of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Ataque
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit[(Player number of (Owner of (Triggering unit)))] has an item of type Espada de Bronze) Equal to True
            • Then - Actions
              • Set Loc2 = (Loc1 offset by 120.00 towards ((Facing of Unit[(Player number of (Owner of (Triggering unit)))]) + 90.00) degrees)
            • Else - Actions
        • Else - Actions
      • Unit - Create 1 Dummy Attack for (Owner of (Triggering unit)) at Loc2 facing (Facing of (Triggering unit)) degrees
      • Unit - Add a 0.05 second Generic expiration timer to (Last created unit)
      • Set AtacandoBool[(Player number of (Owner of (Triggering unit)))] = True
      • Set AtacandoInteger[(Player number of (Owner of (Triggering unit)))] = 1
      • Custom script: call RemoveLocation(udg_Loc1)
      • Custom script: call RemoveLocation(udg_Loc2)
This second trigger does the damage and all
  • SECOND TRIGGER
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Dummy Attack
          • AtacandoBool[(Player number of (Owner of (Triggering unit)))] Equal to True
        • Then - Actions
          • Set Loc1 = (Position of Unit[(Player number of (Owner of (Triggering unit)))])
          • Set Loc2 = (Position of (Triggering unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit[(Player number of (Owner of (Triggering unit)))] has an item of type Espada de Bronze) Equal to True
            • Then - Actions
              • Set Loc3 = (Loc1 offset by 120.00 towards ((Facing of Unit[(Player number of (Owner of (Triggering unit)))]) + (90.00 - ((Real(AtacandoInteger[(Player number of (Owner of (Triggering unit)))])) x 10.00))) degrees)
              • Else -Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AtacandoInteger[(Player number of (Owner of (Triggering unit)))] Greater than or equal to 13
                • Then - Actions
                  • Set AtacandoInteger[(Player number of (Owner of (Triggering unit)))] = 0
                  • Set AtacandoBool[(Player number of (Owner of (Triggering unit)))] = False
                • Else - Actions
            • Else - Actions
          • Set AtacandoInteger[(Player number of (Owner of (Triggering unit)))] = (AtacandoInteger[(Player number of (Owner of (Triggering unit)))] + 1)
          • Custom script: call GroupEnumUnitsInRangeOfSegmentLoc( udg_TempGroup, udg_Loc1, udg_Loc2, 10.0, null )
          • Custom script: call DestroyGroup(udg_UnitGroup)
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Picked unit) Not equal to (Triggering unit)
                  • ((Picked unit) is in UnitGroup) Equal to False
                • Then - Actions
                  • Unit - Cause Unit[(Player number of (Owner of (Triggering unit)))] to damage (Picked unit), dealing 10.00 damage of attack type Spells and damage type Normal
                  • Unit Group - Add (Picked unit) to UnitGroup
                  • Set AtacandoBool[(Player number of (Owner of (Triggering unit)))] = False
                • Else - Actions
                  • Unit Group - Remove (Picked unit) from UnitGroup
          • Unit - Create 1 Dummy Attack for (Owner of (Triggering unit)) at Loc3 facing (Facing of (Triggering unit)) degrees
          • Unit - Add a 0.05 second Generic expiration timer to (Last created unit)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Loc1)
      • Custom script: call RemoveLocation(udg_Loc2)
      • Custom script: call RemoveLocation(udg_Loc3)
      • Trigger - Turn on (This trigger)
 
Level 36
Joined
Jul 22, 2015
Messages
3,491
Your first trigger:
  • Loc2 is only created when (Unit[(Player number of (Owner of (Triggering unit)))] has an item of type Espada de Bronze) Equal to True, yet you create a dummy and remove this location regardless of the condition being met or not. This can lead to some undesirable effects

Second trigger:
  • Loc3 has the same issue with Loc2 in your first trigger
  • Is call GroupEnumUnitsInRangeOfSegmentLoc() part of an imported library?
  • What's the point of checking if (Picked unit) is in UnitGroup if you destroy the group literally right before the loop for TempGroup o.o

Aside from all that, I still stand by my suggestion earlier about what you should do about preventing units from taking double the damage. I don't see how its possible to avoid any bugs without using some sort of timer that detects when you should be able to damage previously affected units again.
 
Level 36
Joined
Jul 22, 2015
Messages
3,491
Use the Unit Group - Clear action to empty your group when the spell ends.

That's not the issue anymore. His issue is adding a timer of when he should remove affected units.

I don't know how to properly remove the unit from the group, and don't know another way of doing it, how can a timer be introduced in this function ?
It's fairly easy, however I will be using a boolean array (requires a unit indexer) to determine when units can't be hit since I find it more efficient than having to loop through a unit group. You will also need a unit indexer to create special timers for each unit.

I'll call the boolean NoDamage[]. When it is false, it means that a unit CAN be damaged (booleans are always initialized as false). Before dealing damage, add a boolean comparision that checks if NoDamage[Custom value of Unit] is false, if so deal damage. Once you deal damage, set NoDamage[] to true and add the unit to a unit group variable. You can then start a loop timer that increments a counter, and when the counter hits your desired value, set NoDamage[] back to false, remove the unit from the unit group, and now the unit can be damaged again.

In this example trigger, I want units to not take damage from this specific "spell" for two seconds:

When dealing damage:
  • Set DamagedUnit = (Some unit that you will be damaging)
  • Set Unit_ID = (Custom value of DamagedUnit)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • NoDamage[Unit_ID] Equal to False
    • Then - Actions
      • -------- deal damage to unit --------
      • Set NoDamage[Unit_ID] = True
      • Set Counter[Unit_ID] = 0.00
      • Unit Group - Add DamagedUnit to DamagedGroup
      • Set TotalCount = (TotalCount + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TotalCount Equal to 1
        • Then - Actions
          • Trigger - Turn on Loop <gen>
        • Else - Actions
    • Else - Actions

Loop:
  • Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in DamagedGroup and do (Actions)
        • Loop - Actions
          • Set DamagedUnit = (Picked unit)
          • Set Unit_ID = (Custom value of DamagedUnit)
          • -------- --------
          • Set Counter[Unit_ID] = (Counter[Unit_ID] + 1.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Counter[Unit_ID] Greater than or equal to 2.00
            • Then - Actions
              • Set NoDamage[Unit_ID] = False
              • Unit Group - Remove DamagedUnit from DamagedGroup
              • Set TotalCount = (TotalCount - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TotalCount Equal to 0
                • Then - Actions
                  • Trigger - Turn off Loop <gen>
                • Else - Actions
            • Else - Actions
 
Level 7
Joined
Oct 19, 2015
Messages
286
why would you need a timer? He already knows when the spell ends: when AtacandoInteger reaches 13 and he sets AtacandoBool to false. When that condition is met, he can also clear the group at the end of the trigger. Also, there's no need to use a unit indexer so that he can attach a boolean to a unit, adding the unit to a group instead is just fine, in fact since the spell is multi-instanceable (MPI in his case) using a group is the correct approach since you can allocate a group for each instance whereas a boolean array is static.

You should also change the trigger so that you don't create a new dummy unit when AtacandoBool is set to false. Also, you don't strictly need that variable since you could just check if AtacandoInteger is equal to 0 instead.
 
Level 36
Joined
Jul 22, 2015
Messages
3,491
why would you need a timer? He already knows when the spell ends: when AtacandoInteger reaches 13 and he sets AtacandoBool to false. When that condition is met, he can also clear the group at the end of the trigger.
I wasn't entirely sure what AtacandoInteger was counting to be honest. If this is true, then yes, you can just clear the group whenever the counter reaches 13.

Also, there's no need to use a unit indexer so that he can attach a boolean to a unit, adding the unit to a group instead is just fine, in fact since the spell is multi-instanceable (MPI in his case) using a group is the correct approach since you can allocate a group for each instance whereas a boolean array is static.
I suggested a boolean because it would be more efficient than having the trigger enumerate through multiple units to find out if said unit is present. An upside to using unit group arrays would mean that you can make it so that a unit can't take damage from a specific instance more than once instead of all instances (I may have misunderstood what his trigger was trying to accomplish).

you can allocate a group for each instance whereas a boolean array is static.
Sorry I'm a little confused, are you suggesting a unit group array? If that's the case, he will need to manually initialize on cast, and then destroy and null them when it is over (not that there is anything wrong with it).
 
Level 11
Joined
Oct 9, 2015
Messages
721
  • x
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Dummy Attack
          • AtacandoBool[(Player number of (Owner of (Triggering unit)))] Equal to True
        • Then - Actions
          • Set Loc1 = (Position of Unit[(Player number of (Owner of (Triggering unit)))])
          • Set Loc2 = (Position of (Triggering unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit[(Player number of (Owner of (Triggering unit)))] has an item of type Espada de Bronze) Equal to True
            • Then - Actions
              • Set Loc3 = (Loc1 offset by 120.00 towards ((Facing of Unit[(Player number of (Owner of (Triggering unit)))]) + (90.00 - ((Real(AtacandoInteger[(Player number of (Owner of (Triggering unit)))])) x 10.00))) degrees)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AtacandoInteger[(Player number of (Owner of (Triggering unit)))] Greater than or equal to 13
                • Then - Actions
                  • Set AtacandoInteger[(Player number of (Owner of (Triggering unit)))] = 0
                  • Set AtacandoBool[(Player number of (Owner of (Triggering unit)))] = False
                • Else - Actions
            • Else - Actions
          • Set AtacandoInteger[(Player number of (Owner of (Triggering unit)))] = (AtacandoInteger[(Player number of (Owner of (Triggering unit)))] + 1)
          • Custom script: call GroupEnumUnitsInRangeOfSegmentLoc( udg_TempGroup, udg_Loc1, udg_Loc2, 10.0, null )
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Picked unit) Not equal to Unit[(Player number of (Owner of (Triggering unit)))]
                  • ((Picked unit) is alive) Equal to True
                  • ((Picked unit) is in UnitGroup) Equal to True
                • Then - Actions
                  • Unit - Cause Unit[(Player number of (Owner of (Triggering unit)))] to damage (Picked unit), dealing 10.00 damage of attack type Spells and damage type Normal
                  • Unit Group - Remove (Picked unit) from UnitGroup
                • Else - Actions
                  • Unit Group - Add (Picked unit) to UnitGroup
          • Unit - Create 1 Dummy Attack for (Owner of (Triggering unit)) at Loc3 facing (Facing of (Triggering unit)) degrees
          • Unit - Add a 0.05 second Generic expiration timer to (Last created unit)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Loc1)
      • Custom script: call RemoveLocation(udg_Loc2)
      • Custom script: call RemoveLocation(udg_Loc3)
      • Unit Group - Remove all units from UnitGroup
      • Trigger - Turn on (This trigger)
Can you dettect what m'I doing wrong here, please?
Thanks for helping me out, you guys are awesome!
 
Level 36
Joined
Jul 22, 2015
Messages
3,491
If AtacandoInteger[] represents the end of the instance, "Unit Group - Remove all units from UnitGroup" should be moved to the inside of the If/Then/Else that checks if Integer[] == 13.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • AtacandoInteger[(Player number of (Owner of (Triggering unit)))] Greater than or equal to 13
    • Then - Actions
      • Unit Group - Remove all units from UnitGroup
      • Set AtacandoInteger[(Player number of (Owner of (Triggering unit)))] = 0
      • Set AtacandoBool[(Player number of (Owner of (Triggering unit)))] = False
    • Else - Actions
 
Level 7
Joined
Oct 19, 2015
Messages
286
If AtacandoInteger[] represents the end of the instance, "Unit Group - Remove all units from UnitGroup" should be moved to the inside of the If/Then/Else that checks if Integer[] == 13.
This. Also, you need to rework your if statement structure, for example right now you only initialize Loc3 if the unit has the item but you do your other code that uses Loc3 regardless. You need to move pretty much all of your code into that if statement. Think about it, which actions need to run if the unit no longer has the item and which don't.

Also, when checking if the integer is greater than 13, you should only create the next dummy unit (and increase the integer) if the integer isn't greater than 13, not always, so again you need to move some code inside the if statement. You should also put that if statement towards the end of the code, otherwise you will empty the group before doing the last unit group loop.

Also, when looping through the group, your if statement is incorrect. You need to check if the unit isn't in the group, not if it is, and then when you damage it, you need to add it to the group, not remove it. You don't need to remove it from the group at all, that will happen when the spell ends.


I suggested a boolean because it would be more efficient than having the trigger enumerate through multiple units to find out if said unit is present.
IsUnitInGroup is a native so the trigger doesn't have to do any enumeration. If any looping is done at all, it's done by internal wc3 code which is way faster than JASS.

Sorry I'm a little confused, are you suggesting a unit group array? If that's the case, he will need to manually initialize on cast, and then destroy and null them when it is over (not that there is anything wrong with it).
Yes, that's the idea. Since his spell is MPI, though, he doesn't really need to dynamically allocate the groups, he could simply set the size of the array to 12 so that the groups will be created automatically when the game starts and then reuse those groups.
 
Level 11
Joined
Oct 9, 2015
Messages
721
It worked, however if a unit is really close it gets picked twice. thats better because before they were getting picked three or four times, or even more, I don't know whats happening now :(

  • x
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Dummy Attack
          • AtacandoBool[(Player number of (Owner of (Triggering unit)))] Equal to True
        • Then - Actions
          • Set Loc1 = (Position of Unit[(Player number of (Owner of (Triggering unit)))])
          • Set Loc2 = (Position of (Triggering unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit[(Player number of (Owner of (Triggering unit)))] has an item of type Espada de Bronze) Equal to True
            • Then - Actions
              • Set Loc3 = (Loc1 offset by 120.00 towards ((Facing of Unit[(Player number of (Owner of (Triggering unit)))]) + (90.00 - ((Real(AtacandoInteger[(Player number of (Owner of (Triggering unit)))])) x 10.00))) degrees)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AtacandoInteger[(Player number of (Owner of (Triggering unit)))] Greater than or equal to 13
                • Then - Actions
                  • Set AtacandoInteger[(Player number of (Owner of (Triggering unit)))] = 0
                  • Set AtacandoBool[(Player number of (Owner of (Triggering unit)))] = False
                  • Unit Group - Remove all units from DamageGroup[(Player number of (Owner of (Triggering unit)))]
                • Else - Actions
            • Else - Actions
          • Set AtacandoInteger[(Player number of (Owner of (Triggering unit)))] = (AtacandoInteger[(Player number of (Owner of (Triggering unit)))] + 1)
          • Custom script: call GroupEnumUnitsInRangeOfSegmentLoc( udg_TempGroup, udg_Loc1, udg_Loc2, 10.0, null )
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Picked unit) Not equal to Unit[(Player number of (Owner of (Triggering unit)))]
                  • ((Picked unit) is alive) Equal to True
                  • ((Picked unit) is in DamageGroup[(Player number of (Owner of (Triggering unit)))]) Equal to False
                • Then - Actions
                  • Unit Group - Add (Picked unit) to DamageGroup[(Player number of (Owner of (Triggering unit)))]
                  • Unit - Cause Unit[(Player number of (Owner of (Triggering unit)))] to damage (Picked unit), dealing 10.00 damage of attack type Spells and damage type Normal
                • Else - Actions
          • Unit - Create 1 Dummy Attack for (Owner of (Triggering unit)) at Loc3 facing (Facing of (Triggering unit)) degrees
          • Unit - Add a 0.05 second Generic expiration timer to (Last created unit)
          • Custom script: call RemoveLocation(udg_Loc1)
          • Custom script: call RemoveLocation(udg_Loc2)
          • Custom script: call RemoveLocation(udg_Loc3)
        • Else - Actions
      • Trigger - Turn on (This trigger)
 
Last edited:
Level 7
Joined
Oct 19, 2015
Messages
286
Like I said, you need to rework the structure of your if statements.

You need to take the following code:
  • Set AtacandoInteger[(Player number of (Owner of (Triggering unit)))] = (AtacandoInteger[(Player number of (Owner of (Triggering unit)))] + 1)
  • Custom script: call GroupEnumUnitsInRangeOfSegmentLoc( udg_TempGroup, udg_Loc1, udg_Loc2, 10.0, null )
  • Unit Group - Pick every unit in TempGroup and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Picked unit) Not equal to Unit[(Player number of (Owner of (Triggering unit)))]
          • ((Picked unit) is alive) Equal to True
          • ((Picked unit) is in DamageGroup[(Player number of (Owner of (Triggering unit)))]) Equal to False
        • Then - Actions
          • Unit Group - Add (Picked unit) to DamageGroup[(Player number of (Owner of (Triggering unit)))]
          • Unit - Cause Unit[(Player number of (Owner of (Triggering unit)))] to damage (Picked unit), dealing 10.00 damage of attack type Spells and damage type Normal
        • Else - Actions
...and put it after this line:
  • Set Loc3 = (Loc1 offset by 120.00 towards ((Facing of Unit[(Player number of (Owner of (Triggering unit)))]) + (90.00 - ((Real(AtacandoInteger[(Player number of (Owner of (Triggering unit)))])) x 10.00))) degrees)
Then you need to take the remaining two lines:
  • Unit - Create 1 Dummy Attack for (Owner of (Triggering unit)) at Loc3 facing (Facing of (Triggering unit)) degrees
  • Unit - Add a 0.05 second Generic expiration timer to (Last created unit)
And put them under the "else" actions of the if statement that is checking if the integer is greater than 13, because you only need to create more units if the spell hasn't ended yet.

How are you initializing the unit group arrays? You will need to manually initialize them on map init like so:
No need, GUI arrays get auto-initialized up to their declared size.
 
Last edited:
Level 36
Joined
Jul 22, 2015
Messages
3,491
No need, GUI arrays get auto-initialized up to their declared size.
I don't think so. I've made a lot of spells that required unit group arrays, and they always caused problems unless I initialized them like so:
  • Custom script: if udg_UnitGroup[Some_Index] == null then
  • Custom script: set udg_UnitGroup[Some_Index] = CreateGroup()
  • Custom script: endif

EDIT: Just realized you said declared size. Are you referring to the variable editor?
 
Last edited:
Level 11
Joined
Oct 9, 2015
Messages
721
Anitarf, I could't understand your structuration, could you make it openable like the one I posted so I can have a better understanding? I tried to make them but was unsuccesfull
Killcide, do I need or not to use these custom scripts you've sent ?
 
Level 36
Joined
Jul 22, 2015
Messages
3,491
Killcide, do I need or not to use these custom scripts you've sent ?

I just ran some tests on Antiraf's statement. He is right - changing the array size of the unit group variable to however many you need will automatically initialialize a handle for them. I still think it is better to dynamically create them though, but do whatever is easier for you.
 
Level 7
Joined
Oct 19, 2015
Messages
286
Anitarf, I could't understand your structuration, could you make it openable like the one I posted so I can have a better understanding?
Sorry about that, I kinda forgot I wasn't done editing the code yet and posted it unfinished. I apologise for the confusion. I edited the post now.
 
Level 11
Joined
Oct 9, 2015
Messages
721
Thanks Anitarf, I'll try it now!

Edit: The trigger kept picking the unit twice times or more, however I came up with a solution that consisted in placing the unit in the DamageGroup in the first trigger (spell cast trigger) then it got picked in the second trigger and the group were cleaned after it, this has make the unit be picked only once! Thanks everyone for your time and for helping me out, you guys are awesome! I think I got it from here, if I need any more advice or solutions I'll come back here to ask.
 
Last edited:
Top