• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Simple % based trigger

Status
Not open for further replies.
Level 4
Joined
Oct 13, 2009
Messages
43
can someone please show me how to do it?

i just need to set possibility of action happening for example-


unit enters region and there is 25% A stuff happens or 25% B stuff happens and 50% nothing happnes. :) help please
 
Level 16
Joined
Mar 25, 2016
Messages
1,327
First use a variable and store a random variable. Then you do different things depending on the value of the variable.
  • Random
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Set RandomInteger = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomInteger Less than or equal to 25
        • Then - Actions
          • -------- A --------
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomInteger Less than or equal to 50
            • Then - Actions
              • -------- B --------
            • Else - Actions
              • -------- nothing --------
 
Level 4
Joined
Oct 13, 2009
Messages
43
First use a variable and store a random variable. Then you do different things depending on the value of the variable.
  • Random
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Set RandomInteger = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomInteger Less than or equal to 25
        • Then - Actions
          • -------- A --------
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomInteger Less than or equal to 50
            • Then - Actions
              • -------- B --------
            • Else - Actions
              • -------- nothing --------

im not good with veriables ( setting integer its like dice right? 1-100 and then you just roll it by "less or equal to 25?
 
Level 16
Joined
Mar 25, 2016
Messages
1,327
Yeah, you set it to a random value between (including 1 and 100) 1 and 100, so basically like a dice with 100 sides.
You roll the dice with the first action, not with less or equal to 25.
After that you look at the dice and do something depending on the number. (if dice number less or equal to 25)
It's important to store the value, so you don't have to roll the dice multiple times.
You can also use smaller numbers. You basically only need 4. (1->A, 2->B, 3 and 4 -> nothing)


If you would roll the multiple times it will be more complicated and slower too:
  • Random
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 4) Equal to 1
        • Then - Actions
          • -------- A --------
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 3) Equal to 1
            • Then - Actions
              • -------- B --------
            • Else - Actions
              • -------- nothing --------
 
Level 4
Joined
Oct 13, 2009
Messages
43
Yeah, you set it to a random value between (including 1 and 100) 1 and 100, so basically like a dice with 100 sides.
You roll the dice with the first action, not with less or equal to 25.
After that you look at the dice and do something depending on the number. (if dice number less or equal to 25)
It's important to store the value, so you don't have to roll the dice multiple times.
You can also use smaller numbers. You basically only need 4. (1->A, 2->B, 3 and 4 -> nothing)


If you would roll the multiple times it will be more complicated and slower too:
  • Random
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 4) Equal to 1
        • Then - Actions
          • -------- A --------
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 3) Equal to 1
            • Then - Actions
              • -------- B --------
            • Else - Actions
              • -------- nothing --------

thank you for explanation i understood everything.
 
Status
Not open for further replies.
Top