My own script - Having Problems

I have the script
 
def magic_evade?( a, b )
  c = rand(100000) / 100000.0
  if c < b.mev
    return true
  else
    return false
  end
end

I'm trying to emulate Breath Weapons from Dungeons and Dragons, which did half damage instead of none when magic resist was in effect.
 
example damage formula: ( magic_evade?( a, b ) ) ? x : 2x
 
But calling this seems to make the skill do absolutely nothing regardless of the target's MEV.  I have no idea what's causing this.
if I understand you try to cut the damage by half when the magic evade is actif?
all numbers are integer by default until they are converted to float - and in your case, c is always lower than 1 and thereby the function will always return true.


also, how did you define x as a damage number?


and 2x is not a valid mathematical statement...
if I understand you try to cut the damage by half when the magic evade is actif?
Pretty much, yeah.

all numbers are integer by default until they are converted to float - and in your case, c is always lower than 1 and thereby the function will always return true.
Tried that. Went so far as to convert them to floats too. (using .to_f, making the denominator in the script 100000.0)
UPDATE: I take that back. Your suggestion worked.

also, how did you define x as a damage number?
In the case I was testing, x = a.mat * 2 - b.mdf * 1

and 2x is not a valid mathematical statement...
I meant 2 * x

Original thread: https://forums.rpgmakerweb.com/threads/my-own-script-having-problems.29829/