So I was thinking of making a game where you get random minerals every so often and you would have the ability to upgrade so you have better chances to get a higher amount so like.
[Trigger]
<Event> Periodic Event - 1 sec
<Local Variables>
mineral_chance[5] = 0
i = 0
<Action>
for players in all player group {
SWITCH upgrade level of (your upgrade name) of picked player {
case (==2):
set variable mineral_chance[1] = 60
set variable mineral_chance[2] = 30
set variable mineral_chance[3] = 10
case (== 3):
set variable mineral_chance[1] = 50
set variable mineral_chance[2] = 30
set variable mineral_chance[3] = 20
...(Repeat for 4 & 5 & 6 upgrades)
default:
set variable mineral_chance[1] = 80
set variable mineral_chance[2] = 20
}
for 1 to (number of mineral chance which is 5) variable i {
IF {
<Condition>
mineral_chance[i] > 0
mineral_chance[i] > random_int
<Action> {
modify picked player's minerals add i
}
}
}
random_int is just using function random integer within integer function
I don't have the Galaxy Editor opened in front of me at this moment (i'm on a Mac), but my last game utilized a lot of chance mechanics.
The way I do it (and the way I used to do it in WC3 editor) is you create an integer variable. Then, for your first trigger, have the actions as If/Then/Else after a set variable. So it would look something like this:
Event -
Every 20 seconds of Game Time.
Loc.Variables (don't use your variable here, make it a Global one to use it in multiple triggers)
Conditions
Actions
Set Mineral_Chance (this is your integer variable) to random number between 1-10 (inclusive).
If
Mineral_Chance =<8
Then
Set Player (#) property to ((Current Minerals)+1)
Else
If
Mineral_Chance > 8
Then
Set Player (#) property to ((Current Minerals)+2)
Then you can make a different trigger for your difference chance events the same way. If you are using a 0-100% chance range with all factors of 10, then simply stick with an integer variable set of between 1-10. However, if you want numbers such as 23%, you can set the number between 1-100 and have it as a range equation, like
0=<Mineral_Chance=<23, or
0=<Mineral_Chance=<23.
So I was thinking of making a game where you get random minerals every so often and you would have the ability to upgrade so you have better chances to get a higher amount so like.
First: 80% 1mineral 20% 2mineral 0% 3minerals 0% 4minerals 0% 5minerals Second: 60% 1mineral 30% 2mineral 10% 3minerals 0% 4minerals 0% 5minerals Third: 50% 1mineral 30% 2mineral 20% 3minerals 0% 4minerals 0% 5minerals Fourth: 30% 1mineral 40% 2mineral 20% 3minerals 10% 4minerals 0% 5minerals Fifth: 10% 1mineral 40% 2mineral 30% 3minerals 20% 4minerals 0% 5minerals Sixth: 0% 1mineral 40% 2mineral 30% 3minerals 20% 4minerals 10% 5minerals
Anyone have any idea on how I could go about doing this? I know its possible in WC3 so there has to be a way in SC2
Anyone O_o? This would be very helpful!
[Trigger]
<Event> Periodic Event - 1 sec
<Local Variables>
mineral_chance[5] = 0
i = 0
<Action>
for players in all player group {
SWITCH upgrade level of (your upgrade name) of picked player {
case (==2):
set variable mineral_chance[1] = 60
set variable mineral_chance[2] = 30
set variable mineral_chance[3] = 10
case (== 3):
set variable mineral_chance[1] = 50
set variable mineral_chance[2] = 30
set variable mineral_chance[3] = 20
...(Repeat for 4 & 5 & 6 upgrades)
default:
set variable mineral_chance[1] = 80
set variable mineral_chance[2] = 20
}
for 1 to (number of mineral chance which is 5) variable i {
IF {
<Condition>
mineral_chance[i] > 0
mineral_chance[i] > random_int
<Action> {
modify picked player's minerals add i
}
}
}
random_int is just using function random integer within integer function
Haven't checked I don't see why it wouldn't work
@ZeroAme: Go
I don't have the Galaxy Editor opened in front of me at this moment (i'm on a Mac), but my last game utilized a lot of chance mechanics.
The way I do it (and the way I used to do it in WC3 editor) is you create an integer variable. Then, for your first trigger, have the actions as If/Then/Else after a set variable. So it would look something like this:
Event -
Every 20 seconds of Game Time.
Loc.Variables (don't use your variable here, make it a Global one to use it in multiple triggers)
Conditions
Actions
Set Mineral_Chance (this is your integer variable) to random number between 1-10 (inclusive).
If
Mineral_Chance =<8
Then
Set Player (#) property to ((Current Minerals)+1)
Else
If
Mineral_Chance > 8
Then
Set Player (#) property to ((Current Minerals)+2)
Then you can make a different trigger for your difference chance events the same way. If you are using a 0-100% chance range with all factors of 10, then simply stick with an integer variable set of between 1-10. However, if you want numbers such as 23%, you can set the number between 1-100 and have it as a range equation, like
0=<Mineral_Chance=<23, or
0=<Mineral_Chance=<23.
Hope that helps to get you started.
thanks guys, both of those methods are better then what i had thought of lol
Zifoon what is your variable i for? can you explain it a little?