Help needed with units in a region

chenobi

New Member
Reaction score
0
I have this region called Lumber, and I need to make it so that when i put 10 rabbits inside that region, the rabbits disappear and 15 lumber is added to that player's lumber. I have a 7 player map.

Trigger:
  • RabbitLumber
    • Events
      • Unit - A unit enters Lumber <gen>
    • Conditions
    • Actions
      • Trigger - Run AddLumber <gen> (ignoring conditions)
      • For each (Integer A) from 1 to 7, do (If ((Number of units in (Units in Lumber <gen> owned by (Player((Integer A))))) Greater than or equal to 10) then do (Unit Group - Pick every unit in (Units in Lumber <gen> owned by (Player((Integer A)))) and do (Unit - Remove (Picked unit) from the game))



Trigger:
  • AddLumber
    • Events
    • Conditions
    • Actions
      • If ((Number of units in (Units in Lumber <gen>)) Equal to 10) then do (Player - Add 15 to (Player((Integer A))) Current lumber) else do (Do nothing)


In Starcraft, here's the trigger, and it works fine.
CONDITIONS:
-Current player brings at least 10 rabbits to Location 25
ACTIONS:
-Modify resources for current player: Add 15 Gas
-Remove 10 rabbits for current player location 25.
-Preserve trigger

When I use the WC3 triggers and place let's say, 13 rabbits in the region, they all disappear. If I change "Greater than or equal to"
to "equal to" and I place 13 rabbits inside the region, nothing happens. Is there a way to make it so that if i place more than 10 rabbits inside the region the game only removes 10 rabbits from the region and adds 15 lumber to the player's lumber? I think the unit group leaks, but I'll deal with that later.
 

Asdfblah1

New Member
Reaction score
10
set integer = 0
pick every unit in rabbits
set integer = integer + 1
set rabbits[integer] = picked unit

for each 1 to 10
unit remove rabbits[integer a]

deebee's below is probably more efficient.
 

deebee

New Member
Reaction score
15
Trigger:
  • RabbitLumber
    • Events
      • Unit - A unit enters Lumber <gen>
    • Conditions
    • Actions
      • Set TempGroup = (Units in Lumber matching (((Unit-type of (Matching unit)) Equal to Rabbit) and ((Owner of (Matching unit)) Equal to (Owner of (Triggering unit)))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup) 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 TempGroup)
              • Unit - Remove TempUnit from the game
              • Unit Group - Remove TempUnit from TempGroup
          • Player - Add 15 to (Owner of (Triggering unit)) Current lumber
        • Else - Actions
      • Custom script: call DestroyGroup(udg_TempGroup)


There is probably a better way to do this though :p

And what is AddLumber trigger?
 

chenobi

New Member
Reaction score
0
I used deebee's trigger and it worked perfectly. Thanks a lot :)

Edit: I also want to make a trigger similar to the one above, but instead of lumber, it creates units for the players at their spawn spots. If I have regions SpawnRed Spawnblue etc, how would I go about doing the trigger so that it spawns in the correct player's spot?
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
Just use arays and then the aray player number of owner of tempunit
 

chenobi

New Member
Reaction score
0
I noticed when I used the script above for the lumber, if I place exactly 10 Rabbits inside Lumber, nothing happens. I have to add another rabbit in order for 10 rabbits to disappear and the 15 lumber to add. I'm pretty sure I have the condition set to "Greater than or equal to" 10. Why is this happening?
 

chenobi

New Member
Reaction score
0
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) and ((Owner of (Matching unit)) Equal to (Owner of (Triggering unit)))))
      • 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)
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
Take away that owner of matching unit equal to owner of triggering unit. Completely useless
 

chenobi

New Member
Reaction score
0
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)


Thanks for pointing that out. However, I still need to put more than 10 rabbits in the region for the thing to work, any ideas?
 

chenobi

New Member
Reaction score
0
When I set it to Greater than or equal to 9, it only remove 9 rabbits from the region when i put 10 rabbits in.
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
Huh how posable did you leave the integer a to from 1 to 10
 

chenobi

New Member
Reaction score
0
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 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)


Using this trigger, when I place 9 rabbits in the region, nothing happens. As soon as the 10th rabbit hits the region, the 9 rabbits that were inside the region disappear and the 10th rabbit is still there.
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
That if condition move it to the condition under events and make it unit in lumber gen not temp_group. The delete the action where you set the group. The move the integer a out side the then. Then delete the if then else. Then delete the action were you set temp unit and where you remove temp unit from the temp group then where you remove the unit from the game do remove random unit in lumber gen from the game.
 

chenobi

New Member
Reaction score
0
Like this?
Trigger:
  • RabbitLumber
    • Events
      • Unit - A unit enters Lumber <gen>
    • Conditions
      • (Number of units in (Units in Lumber <gen>)) Greater than or equal to 10
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Unit - Remove (Random unit from (Units in Lumber <gen>)) from the game
      • Player - Add 15 to (Owner of (Triggering unit)) Current lumber


When I use this trigger, the same thing pretty much happens. I need more the 11th rabbit to come in for it to work.

If I change it to

Trigger:
  • RabbitLumber
    • Events
      • Unit - A unit enters Lumber <gen>
    • Conditions
      • (Number of units in (Units in Lumber <gen>)) Greater than or equal to 9
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Unit - Remove (Random unit from (Units in Lumber <gen>)) from the game
      • Player - Add 15 to (Owner of (Triggering unit)) Current lumber

Then the 10th rabbit activates the action, but only 9 rabbits are removed. The last one that came in(10th) stayed intact, for some reason it's not being counted as a unit in Lumber.
 

deebee

New Member
Reaction score
15
Take away that owner of matching unit equal to owner of triggering unit. Completely useless

It is not useless if you have multiple players using the same region. I couldnt tell though :p

Sorry for not testing my own trigger. I fixed it. You are going to need two triggers and turn TempGroup into an array unless you only need this for one player.

Trigger:
  • RabbitLumber
    • Events
      • Unit - A unit enters Lumber <gen>
    • Conditions
    • Actions
      • Unit Group - Add (Triggering unit) to TempGroup[(Player number of (Owner of (Triggering unit)))]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup[(Player number of (Owner of (Triggering unit)))]) 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 TempGroup[(Player number of (Owner of (Triggering unit)))])
              • Unit - Remove TempUnit from the game
              • Unit Group - Remove TempUnit from TempGroup[(Player number of (Owner of (Triggering unit)))]
          • Player - Add 15 to (Owner of (Triggering unit)) Current lumber
        • Else - Actions


Trigger:
  • RabbitLumber2
    • Events
      • Unit - A unit leaves Lumber <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Rabbit
    • Actions
      • Unit Group - Remove (Triggering unit) from TempGroup[(Player number of (Owner of (Triggering unit)))]
 

chenobi

New Member
Reaction score
0
Thanks Much Again :)

Is there like a thing in world editor where you do like "Search" and then replace every certain variable in a trigger with another variable automatically? Because I have multiple regions, I have to make a new array for every region, and thus I have to change the Group for every region I have.
 

chenobi

New Member
Reaction score
0
Yes, there's an island where rabbits spawn and there's like 7 regions for different things you can get with the rabbits. If I use the same array for every region, i can put 2 rabbits at lumber region and 8 rabbits at unit region and get lumber lol.

It's no biggie, just takes a minute or two to replace the 4 lumber groups with something else
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top