• 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.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • 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] Aura Crystal Item

HeroesFightingFear

"The Champion of Alon"
  • 99
    Posts
    5
    Years
    I want to make an item called the Aura Crystal that checks if a Pokemon can evolve, and whether it evolves once or not, fetches the stats and learnset from the final evolution of that Pokemon and assigns them to the Pokemon holding the item.
    I have no clue how to go about this, but here is the item description.
    A crystal radiating a powerful aura. Unevolved Pokemon can supposedly tap into it.
     
    Hey there,
    this should kinda work as you wished. I excluded the Hp stat because I think it would enable weird shenanigans.
    In "def pbInitPokemon(pkmn,idxParty)" add this part right below "@speed = pkmn.speed":
    Code:
    if hasActiveItem?(:YOURITEM)
          stats = pkmn.calcEvolvedFormStats
          @attack = stats[PBStats::ATTACK]
          @defense = stats[PBStats::DEFENSE]
          @spatk = stats[PBStats::SPATK]
          @spdef = stats[PBStats::SPDEF]
          @speed = stats[PBStats::SPEED]
        end
    Do the same in "def pbUpdate(fullChange=false)" with this code:
    Code:
    if hasActiveItem?(:YOURITEM)
            stats = @pokemon.calcEvolvedFormStats
            @attack = stats[PBStats::ATTACK]
            @defense = stats[PBStats::DEFENSE]
            @spatk = stats[PBStats::SPATK]
            @spdef = stats[PBStats::SPDEF]
            @speed = stats[PBStats::SPEED]
          end
    Finally paste this method into the PokeBattle_Pokemon class, preferably above "def clone":
    Code:
    # Recalculates this Pokémon's evolved form's stats.
      def calcEvolvedFormStats
        pkmn = self.species
        evolution = pbGetEvolvedFormData(pkmn)
        loop do break if !evolution[0].is_a?(Array)
          pkmn = evolution[1]
        end
        pkmn = PokeBattle_Pokemon.new(pkmn,1,$Trainer,false)
        bs        = pkmn.baseStats
        usedLevel = self.level
        usedIV    = self.calcIV
        pValues   = PBNatures.getStatChanges(self.calcNature)
        stats = [0]
        PBStats.eachStat do |s|
          next if s==PBStats::HP
          stats[s] = calcStat(bs[s],usedLevel,usedIV[s],@ev[s],pValues[s])
        end
        return stats
      end
    I haven't tested it myself, so be sure to come back on me if you encounter any problems. :)
     
    It did work, sure, but it made any battle I tried lag out.
     
    It did work, sure, but it made any battle I tried lag out.
    Oops, I think the loop carries on forever.THis should fix it
    Code:
    # Recalculates this Pokémon's evolved form's stats.
      def calcEvolvedFormStats
        pkmn = self.species
        [B]loop do break if !pbGetEvolvedFormData(pkmn)[0].is_a?(Array)
          pkmn = pbGetEvolvedFormData(pkmn)[1][/B]
        end
        pkmn = PokeBattle_Pokemon.new(pkmn,1,$Trainer,false)
        bs        = pkmn.baseStats
        usedLevel = self.level
        usedIV    = self.calcIV
        pValues   = PBNatures.getStatChanges(self.calcNature)
        stats = [0]
        PBStats.eachStat do |s|
          next if s==PBStats::HP
          stats[s] = calcStat(bs[s],usedLevel,usedIV[s],@ev[s],pValues[s])
        end
        return stats
      end
     
    This time it straight up throws an error when trying to initiate a battle. The error seems to be related with how the method is structured, as it is causing interference with the evolution scripts.
     
    This time it straight up throws an error when trying to initiate a battle. The error seems to be related with how the method is structured, as it is causing interference with the evolution scripts.
    Could you add the error message? It would help me a lot, fixing this problem. :)
     
    [PokeCommunity.com] Aura Crystal Item
     
    To clarify, the trainer is one of my friends on Discord.
     
    Figured it out and tested it, should function without errors now. Sorry for the hassle. :)
    Code:
    loop do break if !pbGetEvolvedFormData(pkmn)[0].is_a?(Array)
          pkmn = pbGetEvolvedFormData(pkmn)[0][2]
        end
     
    It finally works, thanks man. I will be sure to credit you.
     
    Back
    Top