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

[Trigger] Random Real between 1.00 and 100.00

Status
Not open for further replies.
Level 3
Joined
Nov 26, 2008
Messages
23
I've got a question concerning a random real number between 1.00 and 100.00. If you use that condition in, lets say, a critical strike formula, would it work like an integer and do a random number between 1 and 100 (no decimals) or will it also include any numbers from 1.00 to 100.00 (including the decimals)? The reason im wondering this is because i want like a 7.25% chance of critting instead of having a flat 7% chance.
 
Level 5
Joined
Nov 30, 2010
Messages
184
This is how to get a random 2 decimal place real
  • trigger
  • Event
  • Condition
  • Action
  • .Set integerA equal to a random number between 1 and 100
  • ..If
  • ...integerA equals 100
  • ..Then
  • ...Set realA equal to convert from integer to real integerA
  • ...Set FinalNumber equal to realA
  • ..Else
  • ...Set integerB equals to a random number between 0 and 99
  • ...Set realB equal to integerB divided by 100
  • ...Set realA equal to convert from integer to real integerA
  • ...Set FinalNumber equal to realA plus realB
You have to make your own critical strike with triggers to use decimals.
 
Level 26
Joined
Aug 18, 2009
Messages
4,099
Well you can't have chance below 5% :)
below 2.49 = 0
0.50 to 7.49 = 5%
...

Something like that :)
So if you want to create really accurate chance you will fail :)

Nope, in GUI it only shows you two decimals when entering a fix value but reals can have more and when using this random function, it also does. You can test this by multiplying the result by 1000 for example and printing that. Another possibility would be to use integers. Just do not do it from 1 to 100 but in a greater range and also increase the threshold value for the condition.
 
Nope, in GUI it only shows you two decimals when entering a fix value but reals can have more and when using this random function, it also does. You can test this by multiplying the result by 1000 for example and printing that. Another possibility would be to use integers. Just do not do it from 1 to 100 but in a greater range and also increase the threshold value for the condition.
http://www.hiveworkshop.com/forums/1758553-post8.html
 
Level 5
Joined
Nov 30, 2010
Messages
184
  • Trigger
  • Events
  • .A unit attacks
  • Conditions
  • Actions
  • .Set Real equal to random number between 100 and 10000 divided by 100
  • .If or then else (multiple functions)
  • .If (conditions)
  • ...Real is equal to or less than 7.25
  • .Then (Actions)
  • ...Something
  • .Else (Actions)
  • .Set Real equal to 0
 
Last edited:
Level 22
Joined
Nov 14, 2008
Messages
3,256
  • Trigger
  • Events
  • .A unit attacks
  • Conditions
  • Actions
  • .Set Real equal to random number between 100 and 10000 divided by 100
  • .If or then else (multiple functions)
  • .If (conditions)
  • ...Real is equal to or less than 7.25
  • .Then (Actions)
  • ...Something
  • .Else (Actions)
  • .Set Real equal to 0

Useless.

Why not have in the conditon random real value between 0. - 100. is less than or equals to 7.25. No need for the division.
 
  • Trigger
  • Events
  • .A unit attacks
  • Conditions
  • Actions
  • .Set Real equal to random number between 100 and 10000 divided by 100
  • .If or then else (multiple functions)
  • .If (conditions)
  • ...Real is equal to or less than 7.25
  • .Then (Actions)
  • ...Something
  • .Else (Actions)
  • .Set Real equal to 0

why do you even use reals for that?
int i = random integer between 1 and 10000
if i <= 725 do something

just as waterknight suggested
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
Because there was no damn need to make it more accurate if you bother to read the actual chances blizzard used it at.

WC3 was not primarilly designed for modding. As such they did not think "lets add more complicated and slower maths so someone might be able to use it in the future". There is no practicle situation where you need chances more accurate than 5% for critical strike as the random fluctuation is so large.
 
Status
Not open for further replies.
Top