How do I hard code this LUK change?

● ARCHIVED · READ-ONLY
Started by menea6587 3 posts View original ↗
  1. I want to change the LUK system so that it makes a bit more intuitive sense.

    Someone who has 68 luck has twice as many luck points as someone with 34. Thus they are "Twice as lucky" which can be understood as getting something good twice as often or dodging something bad twice as often.

    Thus, I changed the code from:

    def luk_effect_rate(user) [1.0 + (user.luk - luk) * 0.001, 0.0].max   endto the following:

    def luk_effect_rate(user) [(user.luk) / (luk), 0.0].max endThen I changed my attack states to all be 100% and let LUK quotients be the deciding factor of how often someone is hit by the status condition.

    However, I noticed that the code was evaluating something binary; if the target has less luck than the user, then the user always hits. If the target has higher luck than the user, the user never hits. I did some digging and found that the code evaluates variables based on the number of floating digits there are. Since all stats are integers with 0 floaters, I changed the code again to:

    def luk_effect_rate(user) [(user.luk * 1.00) / (luk * 1.00), 0.00].max endso that the system rounded the difference to the closest lower 0.01.

    However, I'm still getting the binary behavior depending on if the difference is either positive or negative.

    What should I change to accomplish what I want out of the luck stat?
  2. When you divide two integers in ruby, the result will be truncated to an integer. When divisor or numerator is a floating point number (Float), then the result will be a float as well. That behaviour has nothing to do with the number of digits you write down when defining a float:

    995 / 500   # => 1
    995.0 / 500 # => 1.99


    Your last version of the method seems to work for me, I don't know what is going wrong.
  3. I played around with the code more and found out that removing [a, b] max function and just leaving the quotient as in the 3rd block works fine now.

    solved.