• 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] About the method "pbhastype?"

Telemetius

Tele*
  • 256
    Posts
    10
    Years
    I've encountered this problem multiple times and I feel like I'm doing something wrong.

    Let's say I make a new simple move, something that behaves like hyper beam and that it's flying type.

    As an additional effect this move deals double damage if the enemy is of flying type.
    I want the player to know that the move is dealing an additional damage, so why if I use this code:

    Code:
    class PokeBattle_Move_13A < PokeBattle_Move
        def pbBaseDamage(basedmg,attacker,opponent)
          [COLOR="Red"]if opponent.pbHasType?(:FLYING)
            @battle.pbDisplay(_INTL("Double damage!"))[/COLOR]
            return basedmg*2
          end
          return basedmg
        end
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
        ret=super(attacker,opponent,hitnum,alltargets,showanimation)
        if opponent.damagestate.calcdamage>0
          attacker.effects[PBEffects::HyperBeam]=2
          attacker.currentMove=@id
        end
        return ret
      end
    end

    The message is shown and if I use this one:

    Code:
    class PokeBattle_Move_13A < PokeBattle_Move
        def pbBaseDamage(basedmg,attacker,opponent)
          if opponent.pbHasType?(:FLYING)
            return basedmg*2
          end
          return basedmg
        end
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
        ret=super(attacker,opponent,hitnum,alltargets,showanimation)
        if opponent.damagestate.calcdamage>0
          attacker.effects[PBEffects::HyperBeam]=2
          attacker.currentMove=@id
        end
    [COLOR="red"]    if opponent.pbHasType?(:FLYING)
         @battle.pbDisplay(_INTL("Double damage!"))
        end[/COLOR]
        return ret
      end
    end

    Nothing appears at all? Is there something wrong with the utility pbhastype?
     
    Back
    Top