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

nesting "Pick each unit" oddity

Status
Not open for further replies.
Level 14
Joined
Aug 30, 2004
Messages
909
I cannot handle the data editor, and so I'm making "land mine" and "napalm" abilities with the trigger editor. I do this by making a unit group called "Land Mines" and then picking each one every .0625 seconds and doing a scan for enemies nearby. If an enemy is near the land mine, I blow it up. If an enemy is near a napalm unit I give it an "on fire" buff.

My repeat trigger picks every unit in the unit group Land Mine and then calls this function:

  • Land Mine Hits
    • Options: Action
    • Return Type: (None)
    • Parameters
      • Land Mine = No Unit <Unit>
    • Grammar Text: Land Mine Hits(Land Mine)
    • Hint Text: (None)
    • Custom Script Code
    • Local Variables
      • Point = (Position of Land Mine) <Point>
      • tempUnitGroup = (Empty unit group) <Unit Group>
    • Actions
      • Unit Group - Pick each unit in (Units in (Empty region) having alliance Any with player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
        • Actions
      • ------- Above removes a bug where "picked unit" below doesn't work for some reason... works on napalm fire, but not on cars.
      • General - If (Conditions) then do (Actions) else do (Actions)
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • (Unit type of Land Mine) == Napalm Fire
        • Then
          • Unit Group - Pick each unit in (Units in (Region(Point, 1.0)) having alliance Any with player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
            • Actions
              • General - If (Conditions) then do (Actions) else do (Actions)
                • If
                  • (Unit type of (Picked unit)) == Napalm Fire
                • Then
                • Else
                  • Environment - Deal damage using Firebat - Flame Thrower (Damage) on (Picked unit) from Land Mine with 10.0 extra damage
                  • Unit - Add 1 On Fire to (Picked unit) from Land Mine
        • Else
This trigger works, but only because of my very bizarre first action. This first action picks every unit in an empty region and does nothing at all to them. If I delete that first action, the "picked unit" this is what happens: the "Pick each unit" cycle will only pick the Napalm Fire unit (which is the picked unit from the "Pick each unit" cycle that calls this action). It will not pick units that are right next to it even though it meets the criteria.

This isn't urgent, as I have stumbled upon a fix, but I would like to understand what is happening here if someone knows.

For completeness, the code that calls this action is given below:

  • Unit Group - Pick each unit in Land Mines and do (Actions)
    • Actions
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • (Count of units in (Region((Position of (Picked unit)), 0.6)) having alliance Any with player Any Player matching Required: Ground; Excluded: Air, Hover, Missile, Dead, Hidden, with at most Any Amount) > 0
        • Then
          • Land Mine Hits((Picked unit))
        • Else
 
Level 25
Joined
May 11, 2007
Messages
4,651
Err.. I don't have the editor up atm, but can't you replace:
Pick each unit in (Units in (Empty region) having alliance Any with player Any Player
to just.. Units in region awesome region0023
Pick each unit in (Units in (Empty region) What?

Also, I'm pretty sure that if you do a "pick all units who are allied to x" it won't pick those units that are owned by X, since you can't be allied with yourself?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
do this by making a unit group called "Land Mines" and then picking each one every .0625 seconds and doing a scan for enemies nearby.
I do not advise that for a nice play experience. Rather let the inbuilt proximity systems handle that natively than do so with triggers.

Imagine 200 mines...

What I would do is give each mine an weapon with short range (the area that triggers the mine) and when the weapon runs the damage effect (unique to it obviously) I get the trigger to do what I want (deal AoE splash damage with some kind of formula? Why else use triggers?) and kill the source unit.
 
Level 14
Joined
Aug 30, 2004
Messages
909
Err.. I don't have the editor up atm, but can't you replace:
Pick each unit in (Units in (Empty region) having alliance Any with player Any Player
to just.. Units in region awesome region0023
Pick each unit in (Units in (Empty region) What?

Also, I'm pretty sure that if you do a "pick all units who are allied to x" it won't pick those units that are owned by X, since you can't be allied with yourself?

I know the "pick all units" in an empty region is absolutely crazy. I really know that. But I swear on my life the trigger doesn't work when I remove it! It took me a hell of a lot of bug hunting to find that problem, and I still don't understand it. The "any" alliance condition works as long as I have that ridiculous pick each unit in the empty region trigger.

Dr. Supergood: I'm sure you're right that it would be easier to use the data editor for this. I hear a lot about how good the editor is, but it's traumatized me. The last time I tried making a new unit I somehow turned every one of my zerglings into a coup... and my mutalisk was a flying coup that for some reason beyond my comprehension fired motorcycles at ground units! Also all my civilians were coups. The data editor is not for cowards, and I'm afraid I am one.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
If you look at how GUI compiles to galaxy to perform unit group loops you will see that they might not be nest-able.

// Unit group
native void UnitGroupLoopBegin (unitgroup g);
native void UnitGroupLoopStep ();
native bool UnitGroupLoopDone ();
native unit UnitGroupLoopCurrent ();
native void UnitGroupLoopEnd ();

Entirely depends if it pushes to stack or uses a thread allocated global.
 
Level 9
Joined
Dec 21, 2006
Messages
490
i have that in my map and it is really no big deal to have a data only solution.

give the mine a buff. this buff has a periodic search effect, if a unit is close kill the mine.
then add a dmg effect (with area dmg) to the death response of the buff, don't forget to set the % to 1.
now set the buff periodic time to 0.5 or w/e you wish in which interval the mine shall trigger.

really no big deal, effient, less error prone
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
give the mine a buff. this buff has a periodic search effect, if a unit is close kill the mine.
then add a dmg effect (with area dmg) to the death response of the buff, don't forget to set the % to 1.
now set the buff periodic time to 0.5 or w/e you wish in which interval the mine shall trigger.
Except you could just give the mine a weapon like how spider mines did in in WoL...
 
Status
Not open for further replies.
Top