@DeepCover187: Go You have to add an If, and in the conditions you do a simple math to compare a fixed number with a random Int. You can define the fixed number and interval of variation of your random Int to achieve the % you want. Making the interval be 0 ~ 100 makes it very easy to select % for any random action you want.
Development > Triggers
How do I make an action that has a certain % chance of triggering?
- 7 posts
-
SoulFilcher Author
- Battle.net
- SoulFilcher
- #637 NA
- Join date
- Aug 11, 2011
- Location
- Brazil
- Reputation
- 114
- Posts
- 2,642
- Projects
- 10
- Last login
- Jun 20, 2013
-
Projekton Author
- Battle.net
- Projekton
- #195 NA
- Join date
- Mar 10, 2012
- Location
- Canada
- Reputation
- 2
- Posts
- 145
- Projects
- 1
- Last login
- Jun 01, 2013
@DeepCover187:
Here's how I would do something like this.
Initialization
Events
Game - Map initialization
Local Variables
Interger = 0 <Integer>
Conditions
Actions
Variable - Set Interger = (Random integer between 0 and 100)
General - If (Conditions) then do (Actions) else do (Actions)
If
Interger == 1
Then
Sound - Play Sound Link for (All players) (at 100.0% volume, skip the first 0.0 seconds)
Else -
BasharTeg Author
- Battle.net
- Miles
- #152 NA
- Join date
- Sep 15, 2010
- Location
- United States
- Reputation
- 31
- Posts
- 1,142
- Projects
- 4
- Last login
- Jun 19, 2013
Quote from Projekton: Go
@DeepCover187:
Here's how I would do something like this.
Initialization Events Game - Map initialization Local Variables Interger = 0 <Integer> Conditions Actions Variable - Set Interger = (Random integer between 0 and 100) General - If (Conditions) then do (Actions) else do (Actions) If Interger == 1 Then Sound - Play Sound Link for (All players) (at 100.0% volume, skip the first 0.0 seconds) Else
For a 2% chance, you could do the condition "If Integer <= 1"
My Projects:
Malum Ruina: SC2Mapster
Eternal Exile: SC2Mapster
Spine Crawler Madness: SC2Mapster
Xeno Crisis: SC2Mapster -
Spoolofwhool Regular Shmoe
- Join date
- Oct 02, 2011
- Location
- Canada
- Reputation
- 6
- Posts
- 197
- Last login
- Jun 18, 2013
Quote from BasharTeg: Go
For a 2% chance, you could do the condition "If Integer <= 1"
Or instead of that, you could make the variable be from 0 to 50, that and make it only work if the variable is 1, it would still be a 2% chance.
Assistant Team Leader of "Generic Code" and User of the All-Mighty Data Editor.
-
DeepCover187 Regular Shmoe
- Join date
- Jan 26, 2011
- Location
- Sweden
- Reputation
- 0
- Posts
- 30
- Last login
- Apr 16, 2013
Thanks a ton guys, got it to work now! :)
-
Projekton Author
- Battle.net
- Projekton
- #195 NA
- Join date
- Mar 10, 2012
- Location
- Canada
- Reputation
- 2
- Posts
- 145
- Projects
- 1
- Last login
- Jun 01, 2013
@DeepCover187:
Awesome, glad to help. :)
- 7 posts
DeepCover187 Regular ShmoeHi guys, I'm trying to put in an action where there's like 2% chance a certain sound file is played in the middle of a trigger, and I basically have no idea as to how I should make this "chance" condition. I'd appreciate any help on the matter. Thanks in advance!