• 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.

How to make trigger have a CHANCE to do some action?

Status
Not open for further replies.
Level 13
Joined
Oct 27, 2008
Messages
1,176
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Equal to 1
        • Then - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 100) Equal to 2
            • Then - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 100) Equal to 3
                • Then - Actions
                • Else - Actions
Fill in the rest of the info
 
Level 2
Joined
Mar 7, 2005
Messages
23
greasontim has a good way..

u can even try this :
  • Random item creation if a unit dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to "YOUR_UNIT"
    • Actions
      • Set "A_RANDOM_INTEGER_VAR" = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • "A_RANDOM_INTEGER_VAR" Less than or equal to 3
        • Then - Actions
          • Item - Create "YOUR_ITEM_1" at (Position of (Triggering unit))
          • Item - Create "YOUR_ITEM_2" at (Position of (Triggering unit))
        • Else - Actions
hope it helps..
cheer
 
Level 8
Joined
Nov 9, 2008
Messages
502
I will add to alreeedo's post by saying if you set the result of the "roll" to a variable at start of trigger you can use that value throughout with the same result whereas in greasontim's trigger it will "roll" at each IF.
 
Level 14
Joined
Mar 4, 2009
Messages
1,156
  • Shit happens
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) is A Hero) Equal to True
    • Actions
      • Set dropsomeshit[1] = Small Shit
      • Set dropsomeshit[2] = Small Shit
      • Set dropsomeshit[3] = Small Shit
      • Set dropsomeshit[4] = Small Shit
      • Set dropsomeshit[5] = Small Shit
      • Set dropsomeshit[50] = Big shit
      • Set FIXLAGS = (Position of (Dying unit))
      • Item - Create dropsomeshit[(Random integer number between 1 and 50)] at FIXLAGS
      • Custom script: call RemoveLocation(udg_FIXLAGS)
      • Game - Display to (All players) the text: BIG VAMP
Ok i made it like this but it doesn't´s work only item droped from dead unit may be "big shit" but not the small one too,why?
I should have 10% for "small shit" and 2 % for "big shit"...
 
Level 8
Joined
Nov 9, 2008
Messages
502
You are confusing your random item placement with a chance function.
Should be more like this

  • Shit happens
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) is A Hero) Equal to True
    • Actions
      • Set tempinteger= (Random integer number between 1 and 100)
      • Set FIXLAGS = (Position of (Dying unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tempinteger less than or equal to 3
        • Then - Actions
          • Set dropsomeshit[50] = Big shit
          • Item - Create dropsomeshit[50] at FIXLAGS
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If- Conditions
              • tempinteger less than or equal to 5
            • Then - Actions
              • Set dropsomeshit[1] = Small Shit
              • Set dropsomeshit[2] = Small Shit
              • Set dropsomeshit[3] = Small Shit
              • Set dropsomeshit[4] = Small Shit
              • Set dropsomeshit[5] = Small Shit
              • Item - Create dropsomeshit[(Random integer number between 1 and 5)] at FIXLAGS
            • Else - Actions
      • Custom script: call RemoveLocation(udg_FIXLAGS)
      • Game - Display to (All players) the text: BIG VAMP
It will drop big shit if 3% chance occured and wont drop any others. If 3% didnt occur then it checks if the 5% occured and drops random small shit.
 
Level 14
Joined
Mar 4, 2009
Messages
1,156
You are confusing your random item placement with a chance function.
Should be more like this

  • Shit happens
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) is A Hero) Equal to True
    • Actions
      • Set tempinteger= (Random integer number between 1 and 100)
      • Set FIXLAGS = (Position of (Dying unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tempinteger less than or equal to 3
        • Then - Actions
          • Set dropsomeshit[50] = Big shit
          • Item - Create dropsomeshit[50] at FIXLAGS
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If- Conditions
              • tempinteger less than or equal to 5
            • Then - Actions
              • Set dropsomeshit[1] = Small Shit
              • Set dropsomeshit[2] = Small Shit
              • Set dropsomeshit[3] = Small Shit
              • Set dropsomeshit[4] = Small Shit
              • Set dropsomeshit[5] = Small Shit
              • Item - Create dropsomeshit[(Random integer number between 1 and 5)] at FIXLAGS
            • Else - Actions
      • Custom script: call RemoveLocation(udg_FIXLAGS)
      • Game - Display to (All players) the text: BIG VAMP
It will drop big shit if 3% chance occured and wont drop any others. If 3% didnt occur then it checks if the 5% occured and drops random small shit.
I´m not shure will it work but i need 10% to drop "small shit" and 2% to drop "big shit"
 
Level 5
Joined
Dec 21, 2008
Messages
101
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Equal to 1
        • Then - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 100) Equal to 2
            • Then - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 100) Equal to 3
                • Then - Actions
                • Else - Actions
Fill in the rest of the info
This method works well and simple too but.. except theres a little difference to mine..
  • Item Drop Rate On Death
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to X
    • Actions
      • Set VariableInteger1 = 0
      • Set VariableInteger1 = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • VariableInteger1 Equal to 0
        • Then - Actions
          • Do nothing
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • VariableInteger1 Equal to 1
            • Then - Actions
              • Item - Create X at (Center of (X))
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • VariableInteger1 Equal to 2
                • Then - Actions
                  • Item - Create X at (Center of (X))
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • VariableInteger1 Equal to 3
                    • Then - Actions
                      • Item - Create X at (Center of (X))
                    • Else - Actions
                      • Do nothing
      • Set VariableInteger1 = 0
 
Level 14
Joined
Mar 4, 2009
Messages
1,156
Dude, it's simple. Please turn your brain on.

I turned on my brain:grin:damn it was very hard to do .....
ok i did it on your way but the chances to drop gold wore to big....
so i did it like this
  • PLAYAER 11 DROPS GOLD COINTS
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) is A Hero) Equal to True
      • (Owner of (Killing unit)) Equal to Player 11 (Dark Green)
    • Actions
      • Set DROP[1] = Gold Coint
      • Set DROP[2] = Gold Coint
      • Set DROP[3] = Gold Coint
      • Set DROP[4] = Gold Coint
      • Set DROP[5] = Gold Coint
      • Set DROP[6] = Gold Coint
      • Set DROP[7] = Gold Coint
      • Set DROP[8] = Gold Coint
      • Set DROP[9] = Big Gold Coint
      • Set FIXLAGS = (Position of (Dying unit))
      • Item - Create DROP[(Random integer number between 1 and 100)] at FIXLAGS
      • Custom script: call RemoveLocation(udg_FIXLAGS)
8% chance for normal "Gold Coint"
1% for "Big Gold Coint"
 
Level 12
Joined
Mar 10, 2008
Messages
869
I still don't think that your brain is on...
firstly, shouldn't it be COIN instead of COINT
secondly, I think you mean "(Owner of (Dying unit))" instead of "(Owner of (Killing unit))"
thirdly, why not just do "if integer is 8 or lower do drop gold coin" then "if integer is 9 drop big gold coin"
That WILL work.

FOURTHLY
you should have set the drop things in INITIALIZATION, not when a unit dies.
 
Level 8
Joined
Nov 9, 2008
Messages
502
His use of random array index is good, that works but it's not most efficient. You have 9 variables (the items) when you only really need 2. And yes you can set them at map init like manstie.

All these things serve to optimise your trigger. You can make a different way work but it's good practice to streamline your triggers as much as possible. Up to you.
 
Level 14
Joined
Mar 4, 2009
Messages
1,156
I still don't think that your brain is on...
firstly, shouldn't it be COIN instead of COINT
secondly, I think you mean "(Owner of (Dying unit))" instead of "(Owner of (Killing unit))"
thirdly, why not just do "if integer is 8 or lower do drop gold coin" then "if integer is 9 drop big gold coin"
That WILL work.

FOURTHLY
you should have set the drop things in INITIALIZATION, not when a unit dies.
condition is good it means that only when player 11 kills a unit with his hero it may have chance to drop gold from dying unit like in "Vampirism Fire 5.06"
Ok il put it at map initialization.
 
Level 12
Joined
Mar 10, 2008
Messages
869
lol, if bytes aren't noticeable, then yeh.
anyway, this guy should be finished with the trigger.. now/in 1 second.
at least.

1 letter/number/anythingonyourkeyboard/thoserandomfacyletters all equal to 1 byte. I tested thus by making a txt document with 3 letters, it was 3 bytes. So transfer thy trigger to jass manually then count thy letters to see how much space thy has taken up.
So if you think about it, cuz all of it basically is jass, its taking up more than 0.1kb of space per trigger, average. When u add them all up... 10 triggers = 1kb :O
 
Level 8
Joined
Nov 9, 2008
Messages
502
Just FYI You do Not need to set the integer into a variable.

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Random integer number between 1 and 100) Less than or equal to 3
works just the same without the hassle.

Ok but he has 2 actions that could happen. If you put both in IFs and don't use variables, there is chance that both will play no?
 
Status
Not open for further replies.
Top