• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

Units in a region

Status
Not open for further replies.
Level 1
Joined
Jul 18, 2009
Messages
1
Hello, I have a region called Lumber, and I want it so that when I put 10 or more rabbits inside the region, it removes 10 rabbits and gives 15 lumber to the player. Here's my trigger:
  • RabbitLumber
    • Events
      • Unit - A unit enters Lumber <gen>
    • Conditions
    • Actions
      • Set Temp_Group = (Units in Lumber <gen> matching ((Unit-type of (Matching unit)) Equal to Rabbit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Temp_Group) Greater than or equal to 10
        • Then - Actions
          • For each (Integer A) from 1 to 10, do (Actions)
            • Loop - Actions
              • Set TempUnit = (Random unit from Temp_Group)
              • Unit - Remove TempUnit from the game
              • Unit Group - Remove TempUnit from Temp_Group
          • Player - Add 15 to (Owner of (Triggering unit)) Current lumber
        • Else - Actions
      • Custom script: call DestroyGroup(udg_Temp_Group)
It works fine, but I need at least 11 rabbits in the region. When I put only 10 rabbits in the region, nothing happens. I need the 11th rabbit to enter for the game to remove 10 rabbits and add 15 lumber to the player. If I change the condition to 9, i get this:

  • RabbitLumber
    • Events
      • Unit - A unit enters Lumber <gen>
    • Conditions
    • Actions
      • Set Temp_Group = (Units in Lumber <gen> matching ((Unit-type of (Matching unit)) Equal to Rabbit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Temp_Group) Greater than or equal to 9
        • Then - Actions
          • For each (Integer A) from 1 to 10, do (Actions)
            • Loop - Actions
              • Set TempUnit = (Random unit from Temp_Group)
              • Unit - Remove TempUnit from the game
              • Unit Group - Remove TempUnit from Temp_Group
          • Player - Add 15 to (Owner of (Triggering unit)) Current lumber
        • Else - Actions
      • Custom script: call DestroyGroup(udg_Temp_Group)
What happens with this trigger is that the 10th rabbit that comes in triggers the effect, but only the 9 rabbits that first arrived are removed. The 10th rabbit does not seem to be counted in the "units in lumber."

Edit: Nevermind, I fixed it :)
 
Last edited:
Status
Not open for further replies.
Top