• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Dawn, Gloria, Juliana, or Summer - 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.

[Scripting Question] Totem Pokémon Boost

  • 37
    Posts
    4
    Years
    • Seen Aug 14, 2020
    I found a couple of threads, but none of them were resolved. Is there a way to have a totem Pokémon and/or ultra beast have a "The totem _____'s aura flared to life! Its stats rose!" message, and have the Pokémon's stats actually raise to a customizable level, so that I could choose which stats to raise and how much?
     
    Ok, I've trimmed you a function from my own implementation of this that I completed (which is pretty safe for the most part).
    For the first part, what you want to do is add the following at the very end of the conditional in PokeBattle_Battle which initializes wild battlers in single battle:
    Code:
    @scene.raiseSpeciesStats
    Anywhere in the class PokeBattle_Scene, define the following function:
    Code:
    def raiseSpeciesStats
      # cancels if opposing trainer or double wild battle
      return if @battle.opponent || @battle.party2.length > 1
      # put some method of fetching stat raises here
      stats = $game_variables[X]
      # cancels if no stat raise queued
      return if stats.nil? || !stats.is_a?(Array) || stats.length < 2
      battler = @battle.battlers[1]; s = nil; succeed = false; avg = 0
      # iterates through each stat raise
      for i in 0...stats.length
        next if i%2 == 1
        stat = getConst(PBStats, stats[i])
        # failsafe to check whether stat raise can be applied
        next if stat.nil? || (!stats[i+1] && !stats[i+1].is_a?(Numeric))
        # gets proper id and value for stat raise
        s = PBStats.getName(stat) if stats.length <= 2
        inc = stats[i+1]; avg += inc
        # applies stat raise
        battler.pbIncreaseStatBasic(stat, inc, nil, false, true)
        succeed = true
      end
      # failsafe for stat raise
      return if !succeed
      # add a call to play your common animation here
      # pbCommonAnimation(anim)
      # additional formatting for text (to display per stages)
      rsm = [_INTL("increased"),_INTL("rose sharply"),_INTL("increased drastically")]
      j = (2*avg)/stats.length - 1; j = 0 if j < 0; j = 2 if j > 2
      # displays message of stat(s) raised
      pbDisplayPausedMessage(_INTL("{1}'s Aura flared to life!\nIts {2} {3}!", battler.pokemon.name, (s.nil? ? "stats" : s), rsm[j]))
      # don't forget to reset your variable
      $game_variables[X] = nil
    end
    Actually triggering the code to get the stat raise in battle would be very simple. You'd just have to add the appropriate stat names, and the factor you're increasing them by, to the defined variable in the code before you trigger the wild battle from your event like this:
    Code:
    $game_variables[X] = [:ATTACK, 2, :SPEED, 2]
    Where the entries come in pairs: first the symbolic stat name, then the factor, then the symbolic stat name, then the factor, and so on for however many stats you want to raise ...
    You need to specify at least 1 symbolic status name and 1 numeric factor by which you're raising it.
    Please go through the code first, I've left some comments on some additional stuff you'd have to configure for extra flare. And don't forget to replace the X in the $game_variables[X] instances to an actual variable ID. This is as plug and play as it gets.
     
    Last edited:
    Ok, I've trimmed you a function from my own implementation of this that I completed (which is pretty safe for the most part).
    For the first part, what you want to do is add the following at the very end of the conditional in PokeBattle_Battle which initializes wild battlers in single battle:
    Code:
    @scene.raiseSpeciesStats
    Anywhere in the class PokeBattle_Scene, define the following function:
    Code:
    def raiseSpeciesStats
      # cancels if opposing trainer or double wild battle
      return if @battle.opponent || @battle.party2.length > 1
      # put some method of fetching stat raises here
      stats = $game_variabes[X]
      # cancels if no stat raise queued
      return if stats.nil? || !stats.is_a?(Array) || stats.length < 2
      battler = @battle.battlers[1]; s = nil; succeed = false; avg = 0
      # iterates through each stat raise
      for i in 0...stats.length
        next if i%2 == 1
        stat = getConst(PBStats, stats[i])
        # failsafe to check whether stat raise can be applied
        next if stat.nil? || (!stats[i+1] && !stats[i+1].is_a?(Numeric))
        # gets proper id and value for stat raise
        s = PBStats.getName(stat) if stats.length <= 2
        inc = stats[i+1]; avg += inc
        # applies stat raise
        battler.pbIncreaseStatBasic(stat, inc, nil, false, true)
        succeed = true
      end
      # failsafe for stat raise
      return if !succeed
      # add a call to play your common animation here
      # pbCommonAnimation(anim)
      # additional formatting for text (to display per stages)
      rsm = [_INTL("increased"),_INTL("rose sharply"),_INTL("increased drastically")]
      j = (2*avg)/stats.length - 1; j = 0 if j < 0; j = 2 if j > 2
      # displays message of stat(s) raised
      pbDisplayPausedMessage(_INTL("{1}'s Aura flared to life!\nIts {2} {3}!", battler.pokemon.name, (s.nil? ? "stats" : s), rsm[j]))
      # don't forget to reset your variable
      $game_variabes[X] = nil
    end
    Actually triggering the code to get the stat raise in battle would be very simple. You'd just have to add the appropriate stat names, and the factor you're increasing them by, to the defined variable in the code before you trigger the wild battle from your event like this:
    Code:
    $game_variables[X] = [:ATTACK, 2, :SPEED, 2]
    Where the entries come in pairs: first the symbolic stat name, then the factor, then the symbolic stat name, then the factor, and so on for however many stats you want to raise ...
    You need to specify at least 1 symbolic status name and 1 numeric factor by which you're raising it.
    Please go through the code first, I've left some comments on some additional stuff you'd have to configure for extra flare. And don't forget to replace the X in the $game_variabes[X] instances to an actual variable ID. This is as plug and play as it gets.

    Thank you very much! You're right, this is super convenient, thank you.
     
    Wait hold on I found the part where it says "Initialize wild Pokémon" but where exactly do I put the "@scene.raiseSpeciesStats"?
     
    Also, (sorry stupid question but I'm new at this) where do I put the " $game_variables[X] = [:ATTACK, 2, :SPEED, 2]" again?
     
    Wait hold on I found the part where it says "Initialize wild Pokémon" but where exactly do I put the "@scene.raiseSpeciesStats"?
    As I said, at the end of the part where wild battlers are initialized in single battle. I.e. after
    Code:
    pbDisplayPaused(_INTL("Wild {1} appeared!",wildpoke.name))
    Should be obvious.
    Also, (sorry stupid question but I'm new at this) where do I put the " $game_variables[X] = [:ATTACK, 2, :SPEED, 2]" again?
    Like I said ... in your event just before you start your wild battle.
     
    Last edited:
    But what kind of event command do I put the " $game_variables[X] = [:ATTACK, 2, :SPEED, 2]" in? I'm putting in an event command just before the pbWildBattle
     
    I get
    ---------------------------
    Pokemon Essentials GS
    ---------------------------
    Exception: RuntimeError

    Message: Script error within event 3, map 87 (FARADAY ISLAND):

    Exception: NoMethodError

    Message: Section078:5:in `raiseSpeciesStats'undefined method `[]' for nil:NilClass

    ***Full script:

    pbWildBattle(PBSpecies::MEW,30,1)


    Interpreter:243:in `pbExecuteScript'

    PokeBattle_Battle:2313:in `pbStartBattleCore'

    PokeBattle_Battle:2284:in `pbStartBattle'

    PokemonField:1019:in `pbWildBattle'

    PokemonField:1018:in `pbSceneStandby'

    PokemonField:1020:in `pbWildBattle'

    PokemonField:1017:in `pbBattleAnimation'

    PokemonField:1017:in `pbWildBattle'

    (eval):1:in `pbExecuteScript'

    Interpreter:1600:in `eval'



    Interpreter:276:in `pbExecuteScript'

    Interpreter:1600:in `command_355'

    Interpreter:494:in `execute_command'

    Interpreter:193:in `update'

    Interpreter:106:in `loop'

    Interpreter:198:in `update'

    Scene_Map:103:in `update'

    Scene_Map:101:in `loop'

    Scene_Map:114:in `update'

    Scene_Map:68:in `main'
     
    I'm not going to give a bunch of scripts and such but give a brief overview of what you should do:
    Make a new property in pokebattle_pokemon called totemflag
    Make a check to see if it is totem like this
    Code:
    def isTotem?
      return @totemflag
    end
    Make a battle call pbBattleTotem(POKEMON)
    That initialises a totem battle.
    You will have to use {OPPONENT OBJECT}.totemflag = true in it.
    Also note that you add the boosts in the pbBattleTotem(POKEMON) code.
     
    That makes sense, create a new battle script for totem Pokémon only. Should I just copy the regular Pokémon wild battle script and put it in the totem one, then add the things you said?
     
    I get
    ~~ error code ~~

    That's a typo on my end. I wrote $game_variabes instead of $game_variables (the 'l' is missing). Replace all the typos in the context and you'll have it working:
    [PokeCommunity.com] Totem Pokémon Boost
     
    Like I said ... in your event just before you start your wild battle.

    I've been trying to get this to work for AGES now and I just figured it out, I'm so dumb. For anyone else as dumb as me that wants to put this in their game: just like Luka said, put the $game_variables and then your values in a script event command right before the "pbWildBattle:(yourpokemonnamehere) in your event, and replace the [x] with [yourgamevariable], like he said. Sorry Luka for being so incompetent.
     
    Back
    Top