• 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] Trying to make a custom move

2
Posts
7
Years
    • Seen Dec 1, 2016
    Hi guys.
    I'm completely new to Essentials, and I decided making a somewhat short game just to get my feet wet, but while I was able to create some maps and a couple sprites, I've failed quite epically on my first attempt to mess with the script.
    I want to create a move called Invisibility, which increases Evasion by 6 stages for three turns, and then reduces it by 6 stages. Here's what I did (using Essentials 16.2, by the way):
    1. Defined a move called Invisibility in PBS\moves.txt
    2. Added an effect to that move in PokéBattle_MoveEffects (code below)
    3. Added and effect for this move in PBEffects, below the last one.
    4. Finally, created a section for this move in the "End of Round" section of PokeBattle_Battle, right below Taunt.

    In PokéBattle_MoveEffects, after the last line:
    Code:
    #===============================================================================
    # NOTE: If you're inventing new move effects, use function code 159 and onwards.
    #===============================================================================
    ################################################################################
    # 159: Increases user's evasion by +6 for three turns. (Invisibility) #Custom
    ################################################################################
    class PokeBattle_Move_159 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        if opponent.effects[PBEffects::Invisibility]>0
          @battle.pbDisplay(_INTL("But it failed!"))
          return -1
        end
        if !opponent.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
          @battle.pbDisplay(_INTL("But it failed!"))
          return -1
        end
        if attacker.index!=opponent.index
          if (opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker)) || opponent.pbOwnSide.effects[PBEffects::CraftyShield]
            @battle.pbDisplay(_INTL("But it failed!"))
            return -1
          end
        end
        pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
        opponent.effects[PBEffects::Invisibility]=3
        opponent.pbIncreaseStat(PBStats::EVASION,6,attacker,false,self,showanim)
        @battle.pbCommonAnimation("StatUp",opponent,nil)
        @battle.pbDisplay(_INTL("{1} became invisible!",opponent.pbThis))
        return 0
      end
    end
    I tried to take bits of code from Acupressure, Double Team and Taunt for this. Acupressure because it's a stat raising move that can be targeted at the partner, Double Team because it can only raise Evasion, and Taunt because it creates a counter and reverts the effect after 3 turns.

    In PokéBattle_MoveEffects, after the last line:
    Code:
        # Invisibility - #Custom
        for i in priority
          next if i.isFainted?
          if i.effects[PBEffects::Invisibility]>0
            i.effects[PBEffects::Invisibility]-=1
            if i.effects[PBEffects::Invisibility]==0
              i.pbReduceStat(PBStats::EVASION,6,attacker,false,self,showanim)
              pbDisplay(_INTL("{1}'s invisibility wore off!",i.pbThis))
              PBDebug.log("[End of effect] #{i.pbThis} is no longer invisibile")
            end 
          end
        end
    The code here is almost copy/paste from Taunt, and is placed directly below it. I only added a line to reduce Evasion by 6 once the counter hits zero.

    In PBEffects, specifically battler effects:
    Code:
        WeightChange       = 104
        Wish               = 105
        WishAmount         = 106
        WishMaker          = 107
        Yawn               = 108
        Invisibility       = 109 #Custom

    I can teach Invisibility to a Pokémon through the Debug just fine, but as soon as I try to use it in battle, I get the following error:
    Code:
    ---------------------------
    Pokemon Essentials
    ---------------------------
    Exception: NoMethodError
    
    Message: undefined method `>' for nil:NilClass
    
    PokeBattle_MoveEffects:1257:in `pbEffect'
    
    PokeBattle_Battler:2728:in `pbProcessMoveAgainstTarget'
    
    PokeBattle_Battler:2684:in `each'
    
    PokeBattle_Battler:2684:in `pbProcessMoveAgainstTarget'
    
    PokeBattle_Battler:3160:in `pbUseMove'
    
    PokeBattle_Battler:3140:in `loop'
    
    PokeBattle_Battler:3163:in `pbUseMove'
    
    PokeBattle_Battler:3361:in `pbProcessTurn'
    
    PokeBattle_Battler:3360:in `logonerr'
    
    PokeBattle_Battler:3360:in `pbProcessTurn'

    Then, the battle proceeds - skipping my Pokémon's turn - and on the end of every turn, the following error shows up:
    Code:
    ---------------------------
    Pokemon Essentials
    ---------------------------
    Exception: NoMethodError
    
    Message: undefined method `>' for nil:NilClass
    
    PokeBattle_Battle:3463:in `__clauses__pbEndOfRoundPhase'
    
    PokeBattle_Battle:3461:in `each'
    
    PokeBattle_Battle:3461:in `__clauses__pbEndOfRoundPhase'
    
    PokeBattle_Clauses:42:in `pbEndOfRoundPhase'
    
    PokeBattle_Battle:2591:in `pbStartBattleCore'
    
    PokeBattle_Battle:2590:in `logonerr'
    
    PokeBattle_Battle:2590:in `pbStartBattleCore'
    
    PokeBattle_Battle:2572:in `loop'
    
    PokeBattle_Battle:2595:in `pbStartBattleCore'
    
    PokeBattle_Battle:2395:in `pbStartBattle'

    This continues even after my Pokémon has fainted, with the opponent attacking no target while the second error pops up every turn, not even giving me the choice to send another Pokémon or flee.

    Any tips?
     

    jdprager

    OH MY GOD I FREAKING LOVE HYDREIGON
    19
    Posts
    7
    Years
  • Is it a target only move, like heal pulse, or can it be used for the user as well? It seems like your move is a splice of Heal Pulse, Minimize/Double Team, and a passive Doom Desire style effect. I don't know actual scripting very well, but if you find these three codes, you should be able to combine the targeting of heal pulse with a stronger boost to double team. I think a doom desire effect would then be able to remove the evasiveness stats, although both for simplicity and to make it not gamebreaking, you could have it purely remove all positive stat boosts. I'm not really sure this is extremely helpful or even legitimately possible, but I can test this all out tonight.
    *Note: If you want the user to be a target option as well, heal pulse will not work, due to it's nature of only targeting Allies/opponents. You could always another basic double team effect to it, but I'm not sure that would work as an either/or, I think it would just raise both. Once again, most of this is just pure speculation.

    Seperately, the first error seems to be pertaining to the original effect, (Raising Evasiveness) while the second looks like the game failing to remove evasiveness during every turn. The second seems like the more pressing issue to start with.
     
    Last edited by a moderator:
    2
    Posts
    7
    Years
    • Seen Dec 1, 2016
    It's meant to be like Acupressure, in that you can use it on yourself or the partner. I tried to based my code around it to treat the target the same way that move does. I didn't think of using Future Sight/Doom Desire to remove the boost, though. I just tried to shove the Reduce Evasion effect in the Taunt code and go from there.

    As for game balance, I originally wanted to make it last only one turn, but that would make it strictly inferior to Protect (well, not a surprise, since Protect is the best move period in Doubles), even if you can target an ally, and since this is not meant to be a move that is well distributed, it should have at least some advantage to it.

    Anyway, I'll experiment with it tonight as well. If I find a solution, I'll make sure to post it here for anyone who may need it. Thanks a lot.
     

    jdprager

    OH MY GOD I FREAKING LOVE HYDREIGON
    19
    Posts
    7
    Years
  • It's meant to be like Acupressure, in that you can use it on yourself or the partner. I tried to based my code around it to treat the target the same way that move does. I didn't think of using Future Sight/Doom Desire to remove the boost, though. I just tried to shove the Reduce Evasion effect in the Taunt code and go from there.

    As for game balance, I originally wanted to make it last only one turn, but that would make it strictly inferior to Protect (well, not a surprise, since Protect is the best move period in Doubles), even if you can target an ally, and since this is not meant to be a move that is well distributed, it should have at least some advantage to it.

    Anyway, I'll experiment with it tonight as well. If I find a solution, I'll make sure to post it here for anyone who may need it. Thanks a lot.

    No problem. I totally forgot about acupressure, that actually works way better than heal pulse+minimize. Good Luck!
     
    188
    Posts
    9
    Years
    • Seen yesterday
    If the opponent uses Haze or Clear Smog during Invisibility, the attacker's evasion stat (as well as all the others) would be back to normal prematurely and when Invisibility ends, the attacker's evasion stat stage would be at –6. The use of other evasion-reducing moves will produce a similar less-extreme result. Would you want this to happen? If not, applying an accuracy multiplier of 0.33 and creating an Invisibility PBEffect would be a better way to go.
     
    Back
    Top