My own script - Having Problems

Ultima01

Unhinged
Veteran
Joined
Mar 13, 2013
Messages
69
Reaction score
11
First Language
English
Primarily Uses
N/A
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.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
if I understand you try to cut the damage by half when the magic evade is actif?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
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...
 

Ultima01

Unhinged
Veteran
Joined
Mar 13, 2013
Messages
69
Reaction score
11
First Language
English
Primarily Uses
N/A
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
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,574
Latest member
nikisknight
Top