• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Real Value Bugged

Status
Not open for further replies.
Level 3
Joined
Apr 5, 2016
Messages
21
So i was making a map, and i use real value to roll a number between 0.01 - 0.03 i make 3 different effect each abilities has a trigger like this:
Event - a unit starts the effect of ability
Condition - Ability being cast equal to (Dice Roll)
Action - Set (Roll) = roll a random number between 0.01 - 0.03
If (Roll) equal to 0.01 then blah blah blah the effect and keep repeating like that till 0.03


the problem is everytime i cast the ability it always get 0.03 it even got 2 effect at the same time so i tried removing the 0.03 and everytime i cast sometimes theres no effect sometimes there's an effect. how do i fix this? please help!
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Real values can also be 0.015347 for example.

Use integers instead they are discrete.
 
Level 2
Joined
Nov 3, 2017
Messages
25
Do you know that between 0.01 and 0.03 are, like, infinity amount of numbers? Guess you're looking for random number between integers 1 and 3
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Real equality test has a large epsilon error to it. The inequality comparator does correct floating point comparisons. This means that there exist real values that are both equal and not equal to each other.

For chance mechanics I recommend using random integer values instead. They are much easier to define and think about.
 
Level 20
Joined
Feb 23, 2014
Messages
1,264
Real(Integer(Random real number between 1 and 3)) / 100
So, convert Real to Integer and then to Real again?

I think it's better to just go with an integer for this one :)
Or do something like this if the OP really wants a Real - Real(Random integer number between 1 and 3)/100.
 
Status
Not open for further replies.
Top