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

Unit Groups & Waits Questions

Status
Not open for further replies.
Level 4
Joined
Oct 19, 2010
Messages
71
Hi. Thanks for taking the time to read this. I think I've narrowed down a bug in a map to this trigger. It sometimes stops doing what it is supposed to do for some reason. I have 3 related questions that I think are causing it:

1) Unit Groups
a) If a unit that was in a unit group is destroyed, is it removed from the unit group or do you have to do that manually?
b) If a unit that was in a unit group upgrades, how does that affect its being in the unit group?

2) Waits - What happens if a trigger is asked to wait a negative wait time?

I think those answers will help me figure this out. I'm pasting the trigger just in case someone wants to see it. Thanks for any help.

  • MilkOudIlaz
    • Events
      • Time - Every 50.00 seconds of game time
    • Conditions
      • (Number of units in (Units in MilkingOudIlaz <gen> matching (((Matching unit) is in Milking) Equal to True))) Equal to 1
    • Actions
      • Trigger - Turn off (This trigger)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units in MilkingOudIlaz <gen> matching ((Unit-type of (Matching unit)) Equal to Sheep 1))) Equal to 0
        • Then - Actions
          • Trigger - Turn on (This trigger)
          • Skip remaining actions
        • Else - Actions
      • Custom script: set bj_wantDestroyGroup=true
      • Wait (66.66 - (WaitingTimeMilk x (Real((Number of units in (Units in MilkingOudIlaz <gen> matching ((Unit-type of (Matching unit)) Equal to Sheep 1))))))) seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units in MilkingOudIlaz <gen> matching ((Unit-type of (Matching unit)) Equal to Sheep 1))) Equal to 0
        • Then - Actions
          • Trigger - Turn on (This trigger)
          • Skip remaining actions
        • Else - Actions
      • Custom script: set bj_wantDestroyGroup=true
      • Wait (66.66 - (WaitingTimeMilk x (Real((Number of units in (Units in MilkingOudIlaz <gen> matching ((Unit-type of (Matching unit)) Equal to Sheep 1))))))) seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units in MilkingOudIlaz <gen> matching ((Unit-type of (Matching unit)) Equal to Sheep 1))) Equal to 0
        • Then - Actions
          • Trigger - Turn on (This trigger)
          • Skip remaining actions
        • Else - Actions
      • Custom script: set bj_wantDestroyGroup=true
      • Wait (66.66 - (WaitingTimeMilk x (Real((Number of units in (Units in MilkingOudIlaz <gen> matching ((Unit-type of (Matching unit)) Equal to Sheep 1))))))) seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units in MilkingOudIlaz <gen> matching ((Unit-type of (Matching unit)) Equal to Sheep 1))) Greater than 0
        • Then - Actions
          • Set StockOfMilk[(Player number of OwnerOfOudIlaz)] = (StockOfMilk[(Player number of OwnerOfOudIlaz)] + 1)
          • Custom script: set bj_wantDestroyGroup=true
          • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)) of type Warehouse) and do (Actions)
            • Loop - Actions
              • Neutral Building - Remove |cffffcc00Grain |r from (Picked unit)
              • Neutral Building - Remove |cffffcc00Bread |r from (Picked unit)
              • Neutral Building - Remove |cffffcc00Grape |r from (Picked unit)
              • Neutral Building - Remove |cffffcc00Wine |r from (Picked unit)
              • Neutral Building - Remove |cffffcc00Iron Ore |r from (Picked unit)
              • Neutral Building - Remove |cffffcc00Weapon |r from (Picked unit)
              • Neutral Building - Remove |cffffcc00Silk |r from (Picked unit)
              • Neutral Building - Remove |cffffcc00Silk Fabric |r from (Picked unit)
              • Neutral Building - Remove |cffffcc00Milk |r from (Picked unit)
              • Neutral Building - Add |cffffcc00Grain |r to (Picked unit) with 0 in stock and a max stock of StockOfGrain[(Player number of (Owner of (Triggering unit)))]
              • Neutral Building - Add |cffffcc00Bread |r to (Picked unit) with 0 in stock and a max stock of StockOfBread[(Player number of (Owner of (Triggering unit)))]
              • Neutral Building - Add |cffffcc00Grape |r to (Picked unit) with 0 in stock and a max stock of StockOfGrape[(Player number of (Owner of (Triggering unit)))]
              • Neutral Building - Add |cffffcc00Wine |r to (Picked unit) with 0 in stock and a max stock of StockOfWine[(Player number of (Owner of (Triggering unit)))]
              • Neutral Building - Add |cffffcc00Iron Ore |r to (Picked unit) with 0 in stock and a max stock of StockOfIronOre[(Player number of (Owner of (Triggering unit)))]
              • Neutral Building - Add |cffffcc00Weapon |r to (Picked unit) with 0 in stock and a max stock of StockOfWeapon[(Player number of (Owner of (Triggering unit)))]
              • Neutral Building - Add |cffffcc00Silk |r to (Picked unit) with 0 in stock and a max stock of StockOfSilk[(Player number of (Owner of (Triggering unit)))]
              • Neutral Building - Add |cffffcc00Silk Fabric |r to (Picked unit) with 0 in stock and a max stock of StockOfSilkFabric[(Player number of (Owner of (Triggering unit)))]
              • Neutral Building - Add |cffffcc00Milk |r to (Picked unit) with 0 in stock and a max stock of StockOfMilk[(Player number of (Owner of (Triggering unit)))]
        • Else - Actions
      • Trigger - Turn on (This trigger)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
1a) If you're destroying the unit with a trigger you might aswell remove it from the group. Units that are removed from the game will not affect "count units in group". However dead units will affect it, it takes 88 seconds for the bones of a unit to decay (if it is set to decay), and dead units in a group still count.

1b) I don't think so.

2) Negative values become zero. Time can't be negative.

These kind of enumerations leak, add bj_wantDestroyGroup before them:
  • (Number of units in (Units in MilkingOudIlaz <gen> matching ((Unit-type of (Matching unit)) Equal to Sheep 1))) Equal to 0
Your trigger runs every 50 seconds, but you might end up waiting longer than that, upto 66 seconds. The trigger could have overlapping instances.
 
Status
Not open for further replies.
Top