Please help this scripting noob

● ARCHIVED · READ-ONLY
Started by Ultima01 8 posts View original ↗
  1. I am having problems with the below script, intended to check for the critical flag when called from the formula box.
     
      def is_this_critical?
        if @result.critical
          true
        else
          false
        end
      end
     
    As an example, I'm using one of the formulas for an attack that ignores DEF on critical hit.
     
    ( is_this_critical? ) ? a.atk * 4 : a.atk * 4 - b.def * 2

    When I call it in the formula box though, the skill suddenly does no damage whatsoever.  What am I doing wrong, and where?
  2. There is already a critical system in RPG Maker.

    So... I'm curious as to what your purpose is?
  3. Two problems with this.


    Why do you want to create a method when you could just say

    @result.criticalfor exactly the same thing?
    @result.critical doesn't get set until after the damage formula is evaluated. So it will ALWAYS be false and the second part of the equation would be returned.


    As to why it's always doing no damage ... what are the ATK and DEF values of your actor and target respectively?
  4. Code:
    b.result.critical ? a.atk * 4 : a.atk * 4 - b.def * 2
  5. Doesn't change the fact that critical is not set until AFTER the damage formula has been evaluated, so is of no use IN the damage formula.
  6. critical is set before damage formula is evaluated
  7. Xypher said:
    b.result.critical ? a.atk * 4 : a.atk * 4 - b.def * 2
    It worked! Thank you.
  8. wow, you learn something new every day. I would have thought critical would be based somehow on the actual damage caused. That means you can get really low hits that are critical, and much higher hits that are not. Maybe I just misunderstand what "critical" means ...


    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.