• 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] Adding Disable move function to an ability?

2
Posts
13
Years
    • Seen Apr 17, 2022
    (v19.1) I'm trying to add the disable function to the ability Anticipation.
    So the move that makes the anticipation "shudder" gets disabled for 5 turns.

    Here's the clean script of Anticipation:
    Spoiler:


    And here is Disable move function:
    Spoiler:


    I'm not advanced enough on the Essentials script to make this work and I believe the Anticipation script needs to be changes so it actually defines the move that triggers it. Thanks for the help in advance!
     
    1,682
    Posts
    8
    Years
    • Seen yesterday
    Didn't really test it, but give this a shot. since in ruby, every thing is truthy except nil and false, we can repurpose the found boolean into a nil/array for falsey truthy. The array stores the battle index of the triggering battler, and their move id, then it's just a matter of setting the values for disabling.

    Also, you don't really need to bump a thread when it hasn't been a day yet :)
    Code:
    BattleHandlers::AbilityOnSwitchIn.add(:ANTICIPATION,
      proc { |ability,battler,battle|
        next if !battler.pbOwnedByPlayer?
        battlerTypes = battler.pbTypes(true)
        type1 = battlerTypes[0]
        type2 = battlerTypes[1] || type1
        type3 = battlerTypes[2] || type2
        found = nil
        battle.eachOtherSideBattler(battler.index) do |b|
          b.eachMove do |m|
            next if m.statusMove?
            if type1
              moveType = m.type
              if Settings::MECHANICS_GENERATION >= 6 && m.function == "090"   # Hidden Power
                moveType = pbHiddenPower(b.pokemon)[0]
              end
              eff = Effectiveness.calculate(moveType,type1,type2,type3)
              next if Effectiveness.ineffective?(eff)
              next if !Effectiveness.super_effective?(eff) && m.function != "070"   # OHKO
            else
              next if m.function != "070"   # OHKO
            end
            found = [b.index,m.id]
            break
          end
          break if found
        end
        if found
          battle.pbShowAbilitySplash(battler)
          battle.pbDisplay(_INTL("{1} shuddered with anticipation!",battler.pbThis))
          battle.battlers[found[0]].effects[PBEffects::Disable] = 5
          battle.battlers[found[0]].effects[PBEffects::DisableMove] = found[1]
          battle.pbHideAbilitySplash(battler)
        end
      }
    )
     
    Back
    Top