• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • 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] Attack + Heal Block

abegraham

Banned
  • 18
    Posts
    4
    Years
    • Seen Aug 19, 2020
    What I want is an attack that deals damage and applies the heal block effect.

    I made a move that's a physical attack with the function code for heal block, but using the move is similar to just using heal block. Is there a way to make an attack that deals damage then applies the heal block effect?
     
    Take a look at this code as an example. Notice how it makes a call to the super class if (and only if) the move is damaging. You could do something similar for Heal Block:
    Code:
    ################################################################################
    # Target can no longer switch out or flee, as long as the user remains active.
    # (Block, Mean Look, Spider Web, Thousand Waves)
    ################################################################################
    class PokeBattle_Move_0EF < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        if pbIsDamaging?
          ret=super(attacker,opponent,hitnum,alltargets,showanimation)
          if opponent.damagestate.calcdamage>0 && !opponent.damagestate.substitute &&
             !opponent.fainted?
            if opponent.effects[PBEffects::MeanLook]<0 &&
               (!USENEWBATTLEMECHANICS || !opponent.pbHasType?(:GHOST))
              opponent.effects[PBEffects::MeanLook]=attacker.index
              @battle.pbDisplay(_INTL("{1} can no longer escape!",opponent.pbThis))
            end
          end
          return ret
        end
        if opponent.effects[PBEffects::MeanLook]>=0 ||
           (opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker))
          @battle.pbDisplay(_INTL("But it failed!"))
          return -1
        end
        if USENEWBATTLEMECHANICS && opponent.pbHasType?(:GHOST)
          @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
          return -1
        end
        pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
        opponent.effects[PBEffects::MeanLook]=attacker.index
        @battle.pbDisplay(_INTL("{1} can no longer escape!",opponent.pbThis))
        return 0
      end
    end
     
    Back
    Top