• 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!
  • Akari, Selene, Mint, Solana - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

Help making a Fourth Pledge

  • 143
    Posts
    11
    Years
    • Seen Jun 11, 2021
    I've been having trouble creating an Electric Pledge for my game. Whenever I try to use it in conjunction with the other pledges, the game tends to throw an error at me. This is the code I have made:
    Code:
    class PokeBattle_Move_15A < PokeBattle_Move
      def pbOnStartUse(attacker)
        @doubledamage=false; @overridetype=false
        if attacker.effects[PBEffects::FirstPledge]==0x106 ||   # Grass Pledge
           attacker.effects[PBEffects::FirstPledge]==0x107 ||   # Fire Pledge
           attacker.effects[PBEffects::FirstPledge]==0x108      # Water Pledge
          @battle.pbDisplay(_INTL("The two moves have become one! It's a combined move!"))
          @doubledamage=true
          if attacker.effects[PBEffects::FirstPledge]==0x108   # Water Pledge
            @overridetype=true
          end
        end
        return true
      end
    
      def pbBaseDamage(basedmg,attacker,opponent)
        if @doubledamage
          return basedmg*2
        end
        return basedmg
      end
    
      def pbModifyType(type,attacker,opponent)
        if @overridetype
          type=getConst(PBTypes,:GRASS) || 0
        end
        return super(type,attacker,opponent)
      end
    
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        if [email protected] || !attacker.pbPartner || attacker.pbPartner.isFainted?
          attacker.effects[PBEffects::FirstPledge]=0
          return super(attacker,opponent,hitnum,alltargets,showanimation)
        end
        # Combined move's effect
        if attacker.effects[PBEffects::FirstPledge]==0x106   # Grass Pledge
          ret=super(attacker,opponent,hitnum,alltargets,showanimation)
          if opponent.damagestate.calcdamage>0
            attacker.pbOpposingSide.effects[PBEffects::ElectricThorns]=4
            if [email protected]?(attacker.index)
              @battle.pbDisplay(_INTL("Electrified thorns surrounded the opposing team!"))
              @battle.pbCommonAnimation("ElectricThornsOpp",nil,nil)
            else
              @battle.pbDisplay(_INTL("Electrified thorns surrounded your team!"))
              @battle.pbCommonAnimation("ElectricThorns",nil,nil)
            end
          end
          attacker.effects[PBEffects::FirstPledge]=0
          return ret
        elsif attacker.effects[PBEffects::FirstPledge]==0x107   # Fire Pledge
          ret=super(attacker,opponent,hitnum,alltargets,showanimation)
          if opponent.damagestate.calcdamage>0
            attacker.pbOwnSide.effects[PBEffects::VolcanicStorm]=4
            if [email protected]?(attacker.index)
              @battle.pbDisplay(_INTL("A volcanic storm occurred on your team's side!"))
              @battle.pbCommonAnimation("VolcanicStorm",nil,nil)
            else
              @battle.pbDisplay(_INTL("A volcanic storm occurred on the opposing team's side!"))
              @battle.pbCommonAnimation("VolcanicOpp",nil,nil)
            end
          end
          attacker.effects[PBEffects::FirstPledge]=0
          return ret
        elsif attacker.effects[PBEffects::FirstPledge]==0x108   # Water Pledge
          ret=super(attacker,opponent,hitnum,alltargets,showanimation)
          if opponent.damagestate.calcdamage>0
            attacker.pbOwnSide.effects[PBEffects::Thunderstorm]=4
            if [email protected]?(attacker.index)
              @battle.pbDisplay(_INTL("A thunderstorm appeared in the sky on the opposing team!"))
              @battle.pbCommonAnimation("ThunderstormOpp",nil,nil)
            else
              @battle.pbDisplay(_INTL("A thunderstorm appeared in the sky on your team!"))
              @battle.pbCommonAnimation("Thunderstorm",nil,nil)
            end
          end
          attacker.effects[PBEffects::FirstPledge]=0
          return ret
        end
        # Set up partner for a combined move
        attacker.effects[PBEffects::FirstPledge]=0
        partnermove=-1
        if @battle.choices[attacker.pbPartner.index][0]==1 # Chose a move
          if !attacker.pbPartner.hasMovedThisRound?
            [email protected][attacker.pbPartner.index][2]
            if move && move.id>0
              [email protected][attacker.pbPartner.index][2].function
            end
          end
        end
        if partnermove==0x106 ||   # Grass Pledge
           partnermove==0x107 ||   # Fire Pledge
           partnermove==0x108      # Water Pledge
          @battle.pbDisplay(_INTL("{1} is waiting for {2}'s move...",attacker.pbThis,attacker.pbPartner.pbThis(true)))
          attacker.pbPartner.effects[PBEffects::FirstPledge]==@function
          attacker.pbPartner.effects[PBEffects::MoveNext]=true
          return 0
        end
        # Use the move on its own
        return super(attacker,opponent,hitnum,alltargets,showanimation)
      end
    
      def pbShowAnimation(id,attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        if @overridetype
          return super(getConst(PBMoves,:GRASSPLEDGE),attacker,opponent,hitnum,alltargets,showanimation)
        end
        return super(id,attacker,opponent,hitnum,alltargets,showanimation)
      end
    end
    Doing this is really tricky. Also, yes. I've already got Thunderstorm, ElectricThorns, and VolcanicStorm defined in PBEffects.
     
    Last edited:
    Back
    Top