• 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] How to check a move type to display a different message for flinching?

3
Posts
42
Days
  • Seen Apr 28, 2024
Hello everyone!

I never usually ask for help on this thread, but this problem has just been a wall form me. I was trying to make a flinching move for Ariados so that it can be a bit more powerful Pokémon, but I wanted to change the text it displays once the flinch occurs, so that instead of "{1} flinched and couldn't move!" it displays something different. I thought I could do it if I check the type of the move, which is BUG, with
"if move.type == :BUG", but that doesn't seem to be working. I feel like there is a really simple solution to this problem, but I just can't seem to find it.

The flinching message is located in Battler_UseMove_SuccessChecks under def pbTryUseMove(choice,move,specialUsage,skipAccuracyCheck), in case that could also help out. I added the full code too in case it could help.

Help would be appreciated and thank you in advance!

Code:
if @effects[PBEffects::Flinch]
      if move.type == :BUG
      @battle.pbDisplay(_INTL("{1} bla bla bla bla!",pbThis))
    else
      @battle.pbDisplay(_INTL("{1} flinched and couldn't move!",pbThis))
      end
      if abilityActive?
        BattleHandlers.triggerAbilityOnFlinch(self.ability,self,@battle)
      end
      @lastMoveFailed = true
      return false
    end
 
1,681
Posts
8
Years
  • Age 24
  • Seen yesterday
So, unfortunately, in the spot you are checking, there's no way of knowing what the move type was that caused the flinch. That's because the flinch message only occurs when the flinchee attempts to use a move. So if we want to make this change @effects[PBEffects::Flinch] needs to store more than just a boolean of currently flinched.

One way I can see of resolving this is making @effects[PBEffects::Flinch] an integer, and the mon is currently flinched if it's greater than 0. This means you need to change the spot where it is initialized to be 0 instead of false, and def pbFlinch sets it to 1 instead, and it is reset to 0 at the end of the round.

But this is only one part of the puzzle, now we need to edit def pbFlinch to take another argument, the flinch variant. It'll default to 1 of course, and save the variant number to the variable. Now every place where pbFlinch is called by a move, we need to pass either a 1 or a 2 depending on the move type. You can make a convivence function that calculates this for you based on the passed move and any other relevant variables.

Finally we loop back around to the code block you identified, now you can do @effects[PBEffects::Flinch]==2 if it was a bug type flinch
 
3
Posts
42
Days
  • Seen Apr 28, 2024
Oh dang, that seems far more complicated than I thought it was going to be, but thank you for your answer! I'll see if I can make it work like this when I get around to it again
 
3
Posts
42
Days
  • Seen Apr 28, 2024
That totally worked
So, unfortunately, in the spot you are checking, there's no way of knowing what the move type was that caused the flinch. That's because the flinch message only occurs when the flinchee attempts to use a move. So if we want to make this change @effects[PBEffects::Flinch] needs to store more than just a boolean of currently flinched.

One way I can see of resolving this is making @effects[PBEffects::Flinch] an integer, and the mon is currently flinched if it's greater than 0. This means you need to change the spot where it is initialized to be 0 instead of false, and def pbFlinch sets it to 1 instead, and it is reset to 0 at the end of the round.

But this is only one part of the puzzle, now we need to edit def pbFlinch to take another argument, the flinch variant. It'll default to 1 of course, and save the variant number to the variable. Now every place where pbFlinch is called by a move, we need to pass either a 1 or a 2 depending on the move type. You can make a convivence function that calculates this for you based on the passed move and any other relevant variables.

Finally we loop back around to the code block you identified, now you can do @effects[PBEffects::Flinch]==2 if it was a bug type flinch
That totally worked! Thank you so much for your help! I will leave the codes here for anyone else who wants to try this out! I did end up just checking it that specific move is used, but I think it's even better that way. If anyone else is trying this out, don't forget to change the Flinch PBEffect to integer. The first code is in Battler_Statuses, while the second one is in Battler_UseMove_SuccessChecks.

Code:
def pbFlinch(_user=nil,user)
    return if hasActiveAbility?(:INNERFOCUS) && [email protected]
    if user.pbHasMove?(:"MOVE_NAME")
      @effects[PBEffects::Flinch] = 2
    else
    @effects[PBEffects::Flinch] = 1
    end
  end
Code:
if @effects[PBEffects::Flinch] == 1
      @battle.pbDisplay(_INTL("{1} flinched and couldn't move!",pbThis))
      if abilityActive?
        BattleHandlers.triggerAbilityOnFlinch(self.ability,self,@battle)
      end
      @lastMoveFailed = true
      return false
    end

 

    if @effects[PBEffects::Flinch] == 2
      @battle.pbDisplay(_INTL("{1} WHATEVER YOU'D LIKE THE MESSAGE TO BE!",pbThis))
      if abilityActive?
        BattleHandlers.triggerAbilityOnFlinch(self.ability,self,@battle)
      end
      @lastMoveFailed = true
      return false
    end
 
Back
Top