• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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?

226
Posts
8
Years
    • Age 32
    • Seen Jul 19, 2023
    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:
    824
    Posts
    8
    Years
  • 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