• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Non-damaging moves inflicting damage?

  • 224
    Posts
    9
    Years
    • Seen Feb 20, 2025
    Quick question for people used to fiddle with moves scripts.
    Based on "Defining a move" and "Function codes" wiki, I am trying to create equivalents of non-damaging moves such as Disable or Whirlwind which would cause low damage when used.

    I thought it would be done easily by adding a base power value to those moves and recategorizing them as Physical or Special in the PBS files. However those moves do not deal any damage whatsoever...
     
    Last edited by a moderator:
    The reason this doesn't work as expected is because the effect codes for non-damaging moves overwrite the standard pbEffect that damaging moves use.

    However, there is a way to do what you're after. Let's look at another effect code that is designed to work for both damaging and non-damaging moves. The code for moves that burn:

    Code:
    ################################################################################
    # Burns the target.
    ################################################################################
    class PokeBattle_Move_00A < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        [COLOR="Red"]return super(attacker,opponent,hitnum) if @basedamage>0[/COLOR]
        return -1 if !opponent.pbCanBurnFromFireMove?(self,true,attacker)
        pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
        opponent.pbBurn(attacker)
        @battle.pbDisplay(_INTL("{1} was burned!",opponent.pbThis))
        return 0
      end
    
      def pbAdditionalEffect(attacker,opponent)
        return false if !opponent.pbCanBurn?(false,self,attacker)
        opponent.pbBurn(attacker)
        @battle.pbDisplay(_INTL("{1} was burned!",opponent.pbThis))
        return true
      end
    end

    notice the line I highlighted in red. This says "if this move is a damaging move, use the standard version of pbEffect instead of this altered one."

    pbAdditionalEffect is used by damaging moves to cause their secondary effects. Other than the line I highlighted in red, it is virtually identical to the pbEffect for the same effect code. The exception is that pbAdditionalEffect uses return true (success) instead of return 0 (success but no damage dealt), and return false (failure) instead of return -1 (failure).

    There are exceptions to this rule. The effect of causing your opponent to switch out, for example, needs two entirely different effect codes - one for damaging moves, one for status moves.
     
    Back
    Top