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

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