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

% chance

Status
Not open for further replies.
Level 4
Joined
Jun 14, 2008
Messages
72
id there anyway to make a percent chance that somthing will hapen... like...

50% chance unit will be replaced on death and 50% nothing hapens...
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
the if statments of JASS are both simple and multiple selection.
JASS:
if boolean then
elseif boolean then
elseif boolean then
else
endif

So I fail to see how that would be a problem.

Also remember that for optimization sake, a 50/100 chance is basicaly a 1/2 chance, so you reduce the random integer to the smallest denomator. Thus for a 25% chance you use a random number between 1 and 4. If it is equal to 1 then do your actions, as there will be a 25% chance that the number 1 will be generated in theory (as computers are not truely random, the chance may not be exact but overal as far as you need to care it is exact).
 
Status
Not open for further replies.
Top