give builder 11 random towers from the 200 existing towers?
Moderator: Cheaters
-
- Shopping Maul USA Creator
- Posts: 1746
- Joined: January 18th, 2007, 11:07 am
- Title: No Comment
- Location: Calgary Canada
- Been thanked: 2 times
give builder 11 random towers from the 200 existing towers?
I was wondering if it was possible that instead of a builder/race having the same towers, it could be coded that the builder would receive all of his towers randomly when the game starts up.
So if there were basic, normal and advanced towers:
A B C D E (Basic)
F G H I J (Normal)
K L M N O (Advanced)
He could get something like this as his "structures built":
B D E
F I J
K M O
And maybe next game he gets this:
A B E
G H I
L N O
BTW, I use GUI, so pleeeeze don't spit out any jass crap to me or I will be so cunfused that I will have to post a pic of a dog tilting its head.
So if there were basic, normal and advanced towers:
A B C D E (Basic)
F G H I J (Normal)
K L M N O (Advanced)
He could get something like this as his "structures built":
B D E
F I J
K M O
And maybe next game he gets this:
A B E
G H I
L N O
BTW, I use GUI, so pleeeeze don't spit out any jass crap to me or I will be so cunfused that I will have to post a pic of a dog tilting its head.
-
- Forum Staff
- Posts: 506
- Joined: November 17th, 2008, 3:49 pm
Re: give builder 11 random towers from the 200 existing towe
The key here is the trigger "Player - Set Training/Construction Availability Of Unit.". What your gonna have to do is add each tower to a unit, then at the start of the game disable each of the towers.
Then create some type of trigger to get random numbers.
Then the code to check and add the towers, one will need to be done for each player.
Now, this is just the base, and there is a serious problem with it that needs to be fixed if you want to use this method. The random number does not check if there are duplicates..so it may come out to something like 1,4,2,1,1..which will result in only 3 towers instead of the intended 5. At this time i have no idea how it would be fixed..so you may have to brainstorm on that for a bit, otherwise just create a different type of trigger to check.
Anyways, i tested it out and was able to get different towers for each time. So i believe this is a good place to start.
Edit..oh..shit. I just realized the title said 200 towers..err..sorry i couldn't make it any easier but this was the only way i found that could do something like this.
Code: Select all
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Player - Make Town Hall Unavailable for training/construction by (Picked player)
Player - Make Farm Unavailable for training/construction by (Picked player)
Player - Make Altar of Kings Unavailable for training/construction by (Picked player)
...
Code: Select all
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
Set TowersRed[(Integer A)] = (Random integer number between 1 and 10)
Set TowersBlue[(Interger A)] = (Random integer number between 1 and 10)
...
Code: Select all
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TowersRed[(Integer A)] Equal to 1
Then - Actions
Player - Make Town Hall Available for training/construction by Player 1 (Red)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TowersRed[(Integer A)] Equal to 2
Then - Actions
Player - Make Keep Available for training/construction by Player 1 (Red)
Else - Actions
Anyways, i tested it out and was able to get different towers for each time. So i believe this is a good place to start.
Edit..oh..shit. I just realized the title said 200 towers..err..sorry i couldn't make it any easier but this was the only way i found that could do something like this.
-
- Shopping Maul USA Creator
- Posts: 1746
- Joined: January 18th, 2007, 11:07 am
- Title: No Comment
- Location: Calgary Canada
- Been thanked: 2 times
Re: give builder 11 random towers from the 200 existing towe
Hey good start. I think I see a problem though.
This will disable the towers for EVERY race. Don't forget, I still need to be able to use the other races still.
Using this method, I am wondering if it would be easiest to add 200 towers to the builder, and then a trigger to randomly disable 190 towers. But I wonder if a builder can actually have 200 towers.
EDIT: Well I think I may have to get rid of this windows 8 crap and go back to using win7. My damn WC crashes every time I want to test any triggers. Even with older untouched versions.
Code: Select all
Player Group - Pick every player in (All players) and do (Actions)
This will disable the towers for EVERY race. Don't forget, I still need to be able to use the other races still.
Using this method, I am wondering if it would be easiest to add 200 towers to the builder, and then a trigger to randomly disable 190 towers. But I wonder if a builder can actually have 200 towers.
EDIT: Well I think I may have to get rid of this windows 8 crap and go back to using win7. My damn WC crashes every time I want to test any triggers. Even with older untouched versions.
-
- Forum Staff
- Posts: 506
- Joined: November 17th, 2008, 3:49 pm
Re: give builder 11 random towers from the 200 existing towe
Yeah, i wasn't sure how your game played so i put it for all players but that is easily changed. About the unit having 200 buildings, as a test i added multiple units to the peasant, i was able to add over 200 units and it did not crash in-game when i opened the build menu for him.Vegas wrote: This will disable the towers for EVERY race. Don't forget, I still need to be able to use the other races still.
Using this method, I am wondering if it would be easiest to add 200 towers to the builder, and then a trigger to randomly disable 190 towers. But I wonder if a builder can actually have 200 towers.
So..about just disabling them, when i was testing with all the towers available and disabling them i realized that it goes by the units build order, the way you added the towers to the builder. Basically..if a number gets selected twice, one or more of the first 11 towers will always be shown... as you imagine this is a problem. So, using this method we are basically stuck until a way past this is made.
If we disable all towers then randomly enable them, if the number is picked twice there will be less than 11 towers available. And if they are enabled and randomly disabled one of the first 11 towers will always be shown. We have to find either a way to add the towers that does not rely so much on the random trigger, or see if there is a way to check to see individual integers to see if its duplicated.
I've been working out a way, which should work but its a bit of extra work..basically you got two triggers, well, three but the third can be done without much effort....First is setting each tower to a unit-type variable. Then, making an action which makes a integer variable random numbers for each player.
Code: Select all
Untitled Trigger 004 Copy
Events
Map initialization
Conditions
Actions
Set Towers[1] = Town Hall
Set Towers[2] = Keep
Set Towers[3] = Castle
Set Towers[4] = Barracks
...
For each (Integer A) from 1 to 11, do (Actions)
Loop - Actions
Set TowersIntRed[(Integer A)] = (Random integer number between 1 and 200)
For each (Integer A) from 1 to 11, do (Actions)
Loop - Actions
Set TowersIntBlue[(Integer A)] = (Random integer number between 1 and 200)
...
Code: Select all
Untitled Trigger 005
Events
Time - Every 0.30 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
TowersIntRed[1] Equal to TowersIntRed[2]
TowersIntRed[1] Equal to TowersIntRed[3]
TowersIntRed[1] Equal to TowersIntRed[4]
...
Then - Actions
Set TowersIntRed[1] = (Random integer number between 1 and 200)
Player - Make Towers[TowersIntRed[1]] Available for training/construction by Player 1 (Red)
Else - Actions
Player - Make Towers[TowersIntRed[1]] Available for training/construction by Player 1 (Red)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
TowersIntRed[2] Equal to TowersIntRed[3]
TowersIntRed[2] Equal to TowersIntRed[4]
TowersIntRed[2] Equal to TowersIntRed[5]
...
Then - Actions
Set TowersIntRed[2] = (Random integer number between 1 and 200)
Player - Make Towers[TowersIntRed[2]] Available for training/construction by Player 1 (Red)
Else - Actions
Player - Make Towers[TowersIntRed[2]] Available for training/construction by Player 1 (Red)
The final trigger is simply one to turn off the last trigger.
Code: Select all
Untitled Trigger 006
Events
Time - Elapsed game time is 3.00 seconds
Conditions
Actions
Trigger - Turn off Untitled Trigger 005 <gen>
Edit : Forgot to add, in the trigger that adds the towers to the interger you will need to disable the towers for this one to work since we are enableing them. With the towers being added to the integer this can easily be done by adding the action
Code: Select all
Player Group - Pick every player in (All players) and do (For each (Integer A) from 1 to 200, do (Player - Make Towers[(Integer A)] Unavailable for training/construction by (Picked player)))
Last edited by Syre on November 1st, 2012, 7:17 am, edited 1 time in total.
-
- Shopping Maul USA Creator
- Posts: 1746
- Joined: January 18th, 2007, 11:07 am
- Title: No Comment
- Location: Calgary Canada
- Been thanked: 2 times
Re: give builder 11 random towers from the 200 existing towe
Cool. Thanks for your input again. I will see if I can try it this afternoon, but if you noticed another post of mine, I am having problems with saving in WEU. Have to try and fix this problem first, otherwise I cant do anything!!
-
- Shopping Maul USA Creator
- Posts: 1746
- Joined: January 18th, 2007, 11:07 am
- Title: No Comment
- Location: Calgary Canada
- Been thanked: 2 times
Re: give builder 11 random towers from the 200 existing towe
Hahaha, I finally got my WEU figured out. So I still am trying to work out these triggers and nothing is working yet. Still curious about this one
Won't this turn off the towers for all the other players?
Also do I really need "TowersIntRed[1] " and "TowersIntBlue[1]" ??
The trigger should be activated by player, whichever color he may be. Remember it could be that 10 players are other races, and player 6 wants to be this race.
BTW, I'm not complaining, just trying to figure this out still. I do appreciate your help, especially since I'm re-learning WE again after so long away.
Code: Select all
Player Group - Pick every player in (All players) and do (For each (Integer A) from 1 to 200, do (Player - Make Towers[(Integer A)] Unavailable for training/construction by (Picked player)))
Also do I really need "TowersIntRed[1] " and "TowersIntBlue[1]" ??
The trigger should be activated by player, whichever color he may be. Remember it could be that 10 players are other races, and player 6 wants to be this race.
BTW, I'm not complaining, just trying to figure this out still. I do appreciate your help, especially since I'm re-learning WE again after so long away.
-
- Forum Staff
- Posts: 506
- Joined: November 17th, 2008, 3:49 pm
Re: give builder 11 random towers from the 200 existing towe
Ah, alright i understand a bit better now. Since im not editing the map myself i dont know how you wanted this to be done. I was under the impression that you were making it so every builder had random towers, not just one, hence i put it for all players. So..try something like this instead.
Trigger 1
Trigger 2
Its..basically the same triggers except less work. In the first trigger ive removed the loop and put it inside trigger two, so that a random integer is set each time a builder is picked. Trigger 2 is pretty much the same except i removed the timer and instead it works when the builder is chosen. Also you don't have to have towersint for each player. Since it changes the way each time a builder is picked its no longer needed.
However, since ive simplified this by removing the checks for each player, it only checks once. The odds are very poor since it does do a check, but its still possible for a number to be chosen twice.
Trigger 1
Code: Select all
Untitled Trigger 004 Copy
Events
Map initialization
Conditions
Actions
Set Towers[1] = Town Hall
Set Towers[2] = Keep
Set Towers[3] = Castle
Set Towers[4] = Barracks
...
Code: Select all
Untitled Trigger 008
Events
Unit - A unit Finishes training a unit
Conditions
(Unit-type of (Trained unit)) Equal to Builder
Actions
For each (Integer A) from 1 to 11, do (Actions)
Loop - Actions
Set TowersInt[(Integer A)] = (Random integer number between 1 and 200)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
TowersInt[1] Equal to TowersInt[2]
TowersInt[1] Equal to TowersInt[3]
TowersInt[1] Equal to TowersInt[4]
...
Then - Actions
Set TowersInt[1] = (Random integer number between 1 and 200)
Player - Make Towers[TowersInt[1]] Available for training/construction by (Owner of (Trained unit))
Else - Actions
Player - Make Towers[TowersInt[1]] Available for training/construction by (Owner of (Trained unit))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
TowersInt[2] Equal to TowersInt[3]
TowersInt[2] Equal to TowersInt[4]
TowersInt[2] Equal to TowersInt[5]
...
Then - Actions
Set TowersInt[2] = (Random integer number between 1 and 200)
Player - Make Towers[TowersInt[2]] Available for training/construction by (Owner of (Trained unit))
Else - Actions
Player - Make Towers[TowersInt[2]] Available for training/construction by (Owner of (Trained unit))
...
However, since ive simplified this by removing the checks for each player, it only checks once. The odds are very poor since it does do a check, but its still possible for a number to be chosen twice.
-
- Shopping Maul USA Creator
- Posts: 1746
- Joined: January 18th, 2007, 11:07 am
- Title: No Comment
- Location: Calgary Canada
- Been thanked: 2 times
Re: give builder 11 random towers from the 200 existing towe
Cool, thanks. I am just doing my paperwork for the month of October, but hopefully can look at it in-depth in about an hour.
just wondering how did you come up with this:
Player - Make Towers[TowersInt[1]] Available for training/construction by (Owner of (Trained unit))
I can only get this:
Player - Make A_tower[1] Available for training/construction by (Owner of (Trained unit))
Maybe I have my variables wrong.
A_towersint is an interger array size 11 intiail size is 1
A_towers is Unit-type unicode array size 11 initial is no-unit
just wondering how did you come up with this:
Player - Make Towers[TowersInt[1]] Available for training/construction by (Owner of (Trained unit))
I can only get this:
Player - Make A_tower[1] Available for training/construction by (Owner of (Trained unit))
Maybe I have my variables wrong.
A_towersint is an interger array size 11 intiail size is 1
A_towers is Unit-type unicode array size 11 initial is no-unit
-
- Forum Staff
- Posts: 506
- Joined: November 17th, 2008, 3:49 pm
Re: give builder 11 random towers from the 200 existing towe
Click the little [1] next to a_towers. Then at the top, select the integer variable a_towerint. Then click index, and change that option for the check. Also..sorry to bring bad news but a_towers has to be an array size of 200...Its for each tower that you have. You have to set it one by one in the first trigger.