• 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] Checking Moveset, Strange Error

  • 217
    Posts
    15
    Years
    • Seen Nov 29, 2021
    So I'm programming some moves who's BP and Effect chance are doubled if they're all on the same pokemon. Would the following work, or am I using "getConst(PBMoves,:MOVE)" all wrong?
    Code:
        if getConst(PBMoves,:ALPHASHOCK) && getConst(PBMoves,:BETAFLAME) && 
          getConst(PBMoves,:GAMMASPORE) && getConst(PBMoves,:DELTAWAVE)
     
    Last edited:
    To check if a single Pokémon has certain moves during battle, use this code:
    Code:
        if attacker.pbHasMove?(:ALPHASHOCK) && attacker.pbHasMove?(:BETAFLAME) &&
           attacker.pbHasMove?(:GAMMASPORE) && attacker.pbHasMove?(:DELTAWAVE)
        [COLOR=Green]# attacker is of course the PokeBattle_Battler object defined as such[/COLOR]
     
    I'm getting the following error
    Code:
    Exception: NoMethodError
    
    Message: undefined method `*' for nil:NilClass
    
    PokeBattle_Move:834:in `pbCalcDamage'
    
    PokeBattle_Move:1283:in `pbEffect'
    
    PokeBattle_Battler:2744:in `pbProcessMoveAgainstTarget'
    
    PokeBattle_Battler:2687:in `each'
    
    PokeBattle_Battler:2687:in `pbProcessMoveAgainstTarget'
    
    PokeBattle_Battler:3176:in `pbUseMove'
    
    PokeBattle_Battler:3156:in `loop'
    
    PokeBattle_Battler:3179:in `pbUseMove'
    
    PokeBattle_Battler:3377:in `pbProcessTurn'
    
    PokeBattle_Battler:3376:in `logonerr'
    When I use this code:
    Code:
    class PokeBattle_Move_201 < PokeBattle_Move
      def pbBaseDamage(basedmg,attacker,opponent)
        if attacker.pbHasMove?(:ALPHASHOCK) && attacker.pbHasMove?(:BETAFLAME) &&
           attacker.pbHasMove?(:GAMMASPORE) && attacker.pbHasMove?(:DELTAWAVE)
          return basedmg=basedmg*2
        end
      end
    end
    Does anyone know why?
     
    Try this code:
    Code:
    class PokeBattle_Move_201 < PokeBattle_Move
      def pbBaseDamage(basedmg,attacker,opponent)
        [COLOR=Red]basedmg*=2 [/COLOR]if attacker.pbHasMove?(:ALPHASHOCK) && attacker.pbHasMove?(:BETAFLAME) &&
           attacker.pbHasMove?(:GAMMASPORE) && attacker.pbHasMove?(:DELTAWAVE)[COLOR=Red]
        return basedmg[/COLOR]
      end
    end
     
    Thanks, that worked.

    Okay so now I'm having problems with the effect :/

    Code:
    class PokeBattle_Move_203 < PokeBattle_Move
      def pbBaseDamage(basedmg,attacker,opponent)
        basedmg*=2 if attacker.pbHasMove?(:ALPHASHOCK) && attacker.pbHasMove?(:BETAFLAME) &&
           attacker.pbHasMove?(:GAMMASPORE) && attacker.pbHasMove?(:DELTAWAVE)
        return basedmg
      end
      
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        multiplier = 1
        multiplier = 2 if attacker.pbHasMove?(:ALPHASHOCK) && attacker.pbHasMove?(:BETAFLAME) &&
           attacker.pbHasMove?(:GAMMASPORE) && attacker.pbHasMove?(:DELTAWAVE)
        [email protected](10/multiplier)
        case rnd
          when 0
          if isConst?(@id,PBMoves,:ALPHASHOCK)
             return false if !opponent.pbCanParalyze?(attacker,false,self)
             opponent.pbParalyze(attacker)
             return true
          elsif isConst?(@id,PBMoves,:BETAFLAME)
             return false if !opponent.pbCanBurn?(attacker,false,self)
             opponent.pbBurn(attacker)
             return true
          elsif isConst?(@id,PBMoves,:GAMMASPORE)
              return false if !opponent.pbCanPoison?(attacker,false,self)
              opponent.pbPoison(attacker)
              return true
          else isConst?(@id,PBMoves,:DELTAWAVE)
             return false if !opponent.pbCanConfuse?(false)
             opponent.effects[PBEffects::Confusion][email protected](4)
             @battle.pbCommonAnimation("Confusion",attacker,opponent)
             @battle.pbDisplay(_INTL("{1} became confused!",opponent.pbThis))
             return true
          end
        end
        return false
      end
    end
    The error I'm getting is:
    Code:
    Exception: NoMethodError
    Message: undefined method `>' for false:FalseClass
    PokeBattle_Battler:2745:in `pbProcessMoveAgainstTarget'
    PokeBattle_Battler:2687:in `each'
    PokeBattle_Battler:2687:in `pbProcessMoveAgainstTarget'
    PokeBattle_Battler:3176:in `pbUseMove'
    PokeBattle_Battler:3156:in `loop'
    PokeBattle_Battler:3179:in `pbUseMove'
    PokeBattle_Battler:3377:in `pbProcessTurn'
    PokeBattle_Battler:3376:in `logonerr'
    PokeBattle_Battler:3376:in `pbProcessTurn'
    PokeBattle_Battle:2908:in `pbAttackPhase'
     
    Last edited:
    A lot of the coding for these moves can be handled in def pbCalcDamage in the PokeBattle_Move class.

    In PokeBattle_Move, def pbCalcDamage you can handle the damage calculation and effect chance multiplier with the following piece of code:
    Code:
        damagemult=0x1000
    [COLOR=Red]    if @function==0x203 && [COLOR=Green]# move function codes are in hexadecimal[/COLOR]
           attacker.pbHasMove?(:ALPHASHOCK) &&
           attacker.pbHasMove?(:BETAFLAME) &&
           attacker.pbHasMove?(:GAMMASPORE) &&
           attacker.pbHasMove?(:DELTAWAVE)
          damagemult=(damagemult*2.0).round
          @addlEffect*=2
        end[/COLOR]

    In PokeBattle_MoveEffects the move itself can be simply coded as follows:
    Code:
    [COLOR=Red]class PokeBattle_Move_203 < PokeBattle_Move
      def pbAdditionalEffect(attacker,opponent)
        case @id
        when getConst?(PBMoves,:ALPHASHOCK)
          return false if !opponent.pbCanParalyze?(attacker,false,self)
          opponent.pbParalyze(attacker)
          return true
        when getConst?(PBMoves,:BETAFLAME)
          return false if !opponent.pbCanBurn?(attacker,false,self)
          opponent.pbBurn(attacker)
          return true
        when getConst?(PBMoves,:GAMMASPORE)
          return false if !opponent.pbCanPoison?(attacker,false,self)
          opponent.pbPoison(attacker)
          return true
        when getConst?(PBMoves,:DELTAWAVE)
          return false if !opponent.pbCanConfuse?(false)
          opponent.effects[PBEffects::Confusion][email protected](4)
          @battle.pbCommonAnimation("Confusion",attacker,opponent)
          @battle.pbDisplay(_INTL("{1} became confused!",opponent.pbThis))
          return true
        end
        return false
      end
    end[/COLOR]
    In the PBS file moves.txt, set your moves' additional effect chances to 10.
     
    Last edited:
    Before more bugs come up, here's a fix to the move effects code:
    Code:
    class PokeBattle_Move_203 < PokeBattle_Move
      def pbAdditionalEffect(attacker,opponent)
        case @id
        when [COLOR=Red]getConst[/COLOR](PBMoves,:ALPHASHOCK)
          return false if !opponent.pbCanParalyze?(attacker,false,self)
          opponent.pbParalyze(attacker)
          return true
        when [COLOR=Red]getConst[/COLOR](PBMoves,:BETAFLAME)
          return false if !opponent.pbCanBurn?(attacker,false,self)
          opponent.pbBurn(attacker)
          return true
        when [COLOR=Red]getConst[/COLOR](PBMoves,:GAMMASPORE)
          return false if !opponent.pbCanPoison?(attacker,false,self)
          opponent.pbPoison(attacker)
          return true
        when [COLOR=Red]getConst[/COLOR](PBMoves,:DELTAWAVE)
          return false if !opponent.pbCanConfuse?(false)
          opponent.effects[PBEffects::Confusion][email protected](4)
          @battle.pbCommonAnimation("Confusion",attacker,opponent)
          @battle.pbDisplay(_INTL("{1} became confused!",opponent.pbThis))
          return true
        end
        return false
      end
    end
     
    The handy thing about mistakes is you learn from them. I and a lot of other members will be happy to help you out if you need it.
     
    Back
    Top