• 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] Eating a berry on using a certain type of move

220
Posts
14
Years
    • Seen Nov 29, 2021
    So I'm planning on implementing a set of berries that increase a stat. At first I wanted it to happen on entry, so I had this:
    Code:
            if self.pbCanIncreaseStatStage?(PBStats::SPATK,self,false,self) #NEW
              if self.hasWorkingItem(:FLASHWEED)
                pbActivateBerryEffect
                return
              end
            end
    Which... kinda works. It seems a bit random as to when it triggers.

    But now I want it to be consumed just before a pokemon uses a move of it's type (so if it raises Sp. Atk, it's consumed just before the holder uses a special move). How would I go about this?
     

    Telemetius

    Tele*
    267
    Posts
    9
    Years
  • Def pbUseMove, just after the stancechange ability check, seems to me the optimal place to force something to activate just before the attack.
     
    220
    Posts
    14
    Years
    • Seen Nov 29, 2021
    Def pbUseMove, just after the stancechange ability check, seems to me the optimal place to force something to activate just before the attack.

    That doesn't work because movetype has yet to be defined. First place I see movetype be defined is on damage.

    Probably a simple way around that, but I know it not.
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    So I'm planning on implementing a set of berries that increase a stat. At first I wanted it to happen on entry, so I had this:
    Code:
            if self.pbCanIncreaseStatStage?(PBStats::SPATK,self,false,self) #NEW
              if self.hasWorkingItem(:FLASHWEED)
                pbActivateBerryEffect
                return
              end
            end
    Which... kinda works. It seems a bit random as to when it triggers.

    But now I want it to be consumed just before a pokemon uses a move of it's type (so if it raises Sp. Atk, it's consumed just before the holder uses a special move). How would I go about this?
    In PokeBattle_Battler, def pbUseMove you can try this bit of code:
    Code:
        if thismove.pbTwoTurnAttack(self)
          # Beginning use of two-turn attack
          @effects[PBEffects::TwoTurnAttack]=thismove.id
          @currentMove=thismove.id
        else
          @effects[PBEffects::TwoTurnAttack]=0 # Cancel use of two-turn attack
        end
    [COLOR=Red]    if pbHasType?(thismove.type) && thismove.pbIsSpecial?(thismove.type) &&
           hasWorkingItem(:FLASHWEED)
          if pbCanIncreaseStatStage?(PBStats::SPATK)
            @pokemon.itemInitial=0 if @pokemon.itemInitial==@item
            @item=0
            pbIncreaseStat(PBStats::SPATK,1,false,true)
            @battle.pbDisplay(_INTL("The {2} raised {1}'s Special Attack!",
               pbThis,PBItems.getName(@item)))
          end
        end
    [/COLOR]    # "X used Y!" message
        case thismove.pbDisplayUseMessage(self)
     
    Back
    Top