• 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.

[Question] Pokémon icon party

4
Posts
4
Years
    • Seen Mar 29, 2020
    Hi!

    I am trying to add the icons like the image and they do not appear to me, they are in the Graphics / Pictures / Party folder.

    The code is in reliccastle.com/resources/256/ (I can't post links yet)

    Mr. Gela credits

    p44WzoJ.png


    Could sb help me?

    Thanks!
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • Inside item.txt, check if each mega stone haves number 12 into its code, the final number.
    '0,0,12,'
    Because 12, the script will recognizes like Mega Stone.
     
    4
    Posts
    4
    Years
    • Seen Mar 29, 2020
    Inside item.txt, check if each mega stone haves number 12 into its code, the final number.
    '0,0,12,'
    Because 12, the script will recognizes like Mega Stone.

    Yes, for example my gyaradosite has 0,0,12,

    Edit: All mega stones have 0,0,12, and the same.

    I'm using a new Pokemon Essentials

    But its item.txt or items.txt?
     
    Last edited:
    4
    Posts
    4
    Years
    • Seen Mar 29, 2020
    This is PokeBattle_Pokemon script:

    Code:
    # This class stores data on each Pokémon. Refer to $Trainer.party for an array
    # of each Pokémon in the Trainer's current party.
    class PokeBattle_Pokemon
      attr_accessor :special
    end
    
    class PokeBattle_Battler
      attr_accessor :special
      
      def isSpecial?
        if @pokemon
          return (@pokemon.special rescue false)
        end
        return false
      end
    end
    
    class PokeBattle_Pokemon
      attr_reader(:totalhp)       # Current Total HP
      attr_reader(:attack)        # Current Attack stat
      attr_reader(:defense)       # Current Defense stat
      attr_reader(:speed)         # Current Speed stat
      attr_reader(:spatk)         # Current Special Attack stat
      attr_reader(:spdef)         # Current Special Defense stat
      attr_accessor(:iv)          # Array of 6 Individual Values for HP, Atk, Def,
                                  #    Speed, Sp Atk, and Sp Def
      attr_accessor(:wake)                          
      attr_accessor(:ev)          # Effort Values
      attr_accessor(:species)     # Species (National Pokedex number)
      attr_accessor(:personalID)  # Personal ID
      attr_accessor(:trainerID)   # 32-bit Trainer ID (the secret ID is in the upper
                                  #    16 bits)
      attr_reader(:hp)            # Current HP
      attr_writer(:pokerus)       # Pokérus strain and infection time
      attr_accessor(:item)        # Held item
      attr_accessor(:itemRecycle) # Consumed held item (used in battle only)
      attr_accessor(:itemInitial) # Resulting held item (used in battle only)
      attr_accessor(:belch)       # Whether Pokémon can use Belch (used in battle only)
      attr_accessor(:mail)        # Mail
      attr_accessor(:fused)       # The Pokémon fused into this one
      attr_accessor(:name)        # Nickname
      attr_accessor(:exp)         # Current experience points
      attr_accessor(:happiness)   # Current happiness
      attr_accessor(:status)      # Status problem (PBStatuses) 
      attr_accessor(:statusCount) # Sleep count/Toxic flag
      attr_accessor(:eggsteps)    # Steps to hatch egg, 0 if Pokémon is not an egg
      attr_accessor(:moves)       # Moves (PBMove)
      attr_accessor(:firstmoves)  # The moves known when this Pokémon was obtained
      attr_accessor(:ballused)    # Ball used
      attr_accessor(:markings)    # Markings
      attr_accessor(:obtainMode)  # Manner obtained:
                                  #    0 - met, 1 - as egg, 2 - traded,
                                  #    4 - fateful encounter
      attr_accessor(:obtainMap)   # Map where obtained
      attr_accessor(:obtainText)  # Replaces the obtain map's name if not nil
      attr_accessor(:obtainLevel) # Level obtained
      attr_accessor(:hatchedMap)  # Map where an egg was hatched
      attr_accessor(:language)    # Language
      attr_accessor(:ot)          # Original Trainer's name 
      attr_accessor(:otgender)    # Original Trainer's gender:
                                  #    0 - male, 1 - female, 2 - mixed, 3 - unknown
                                  #    For information only, not used to verify
                                  #    ownership of the Pokémon
      attr_accessor(:abilityflag) # Forces the first/second/hidden (0/1/2) ability
      attr_accessor(:genderflag)  # Forces male (0) or female (1)
      attr_accessor(:natureflag)  # Forces a particular nature
      attr_accessor(:shinyflag)   # Forces the shininess (true/false)
      attr_accessor(:ribbons)     # Array of ribbons
      attr_accessor :cool,:beauty,:cute,:smart,:tough,:sheen   # Contest stats
    
      EVLIMIT     = 510   # Max total EVs
      EVSTATLIMIT = 252   # Max EVs that a single stat can have
      NAMELIMIT   = 10    # Maximum length a Pokémon's nickname can be
    
    ################################################################################
    # Ownership, obtained information
    ################################################################################
    # Returns the gender of this Pokémon's original trainer (2=unknown).
      def otgender
        @otgender=2 if !@otgender
        return @otgender
      end
    
    # Returns whether the specified Trainer is NOT this Pokémon's original trainer.
      def isForeign?(trainer)
        return @trainerID!=trainer.id || @ot!=trainer.name
      end
    
    # Returns the public portion of the original trainer's ID.
      def publicID
        return @trainerID&0xFFFF
      end
    
    # Returns this Pokémon's level when this Pokémon was obtained.
      def obtainLevel
        @obtainLevel=0 if !@obtainLevel
        return @obtainLevel
      end
    
    # Returns the time when this Pokémon was obtained.
      def timeReceived
        return @timeReceived ? Time.at(@timeReceived) : Time.gm(2000)
      end
    
    # Sets the time when this Pokémon was obtained.
      def timeReceived=(value)
        # Seconds since Unix epoch
        if value.is_a?(Time)
          @timeReceived=value.to_i
        else
          @timeReceived=value
        end
      end
    
    # Returns the time when this Pokémon hatched.
      def timeEggHatched
        if obtainMode==1
          return @timeEggHatched ? Time.at(@timeEggHatched) : Time.gm(2000)
        else
          return Time.gm(2000)
        end
      end
    
    # Sets the time when this Pokémon hatched.
      def timeEggHatched=(value)
        # Seconds since Unix epoch
        if value.is_a?(Time)
          @timeEggHatched=value.to_i
        else
          @timeEggHatched=value
        end
      end
    
    ################################################################################
    # Level
    ################################################################################
    # Returns this Pokémon's level.
      def level
        return PBExperience.pbGetLevelFromExperience(@exp,self.growthrate)
      end
    
    # Sets this Pokémon's level by changing its Exp. Points.
      def level=(value)
        if value<1 || value>PBExperience::MAXLEVEL
          raise ArgumentError.new(_INTL("The level number ({1}) is invalid.",value))
        end
        self.exp=PBExperience.pbGetStartExperience(value,self.growthrate) 
      end
    
    # Returns whether this Pokémon is an egg.
      def egg?
        return @eggsteps>0
      end
    
      alias isEgg? egg?
    
    # Returns this Pokémon's growth rate.
      def growthrate
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,@species,20)
        ret=dexdata.fgetb
        dexdata.close
        return ret
      end
    
    # Returns this Pokémon's base Experience value.
      def baseExp
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,38)
        ret=dexdata.fgetw
        dexdata.close
        return ret
      end
    
    ################################################################################
    # Gender
    ################################################################################
    # Returns this Pokémon's gender. 0=male, 1=female, 2=genderless
      def gender
        return @genderflag if @genderflag!=nil
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,@species,18)
        genderbyte=dexdata.fgetb
        dexdata.close
        case genderbyte
        when 255
          return 2 # genderless
        when 254
          return 1 # always female
        else
          lowbyte=@personalID&0xFF
          return PokeBattle_Pokemon.isFemale(lowbyte,genderbyte) ? 1 : 0
        end
      end
    
    # Helper function that determines whether the input values would make a female.
      def self.isFemale(b,genderRate)
        return true if genderRate==254    # AlwaysFemale
        return false if genderRate==255   # Genderless
        return b<=genderRate
      end
    
    # Returns whether this Pokémon species is restricted to only ever being one
    # gender (or genderless).
      def isSingleGendered?
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,@species,18)
        genderbyte=dexdata.fgetb
        dexdata.close
        return genderbyte==255 || genderbyte==254 || genderbyte==0
      end
    
    # Returns whether this Pokémon is male.
      def isMale?
        return self.gender==0
      end
    
    # Returns whether this Pokémon is female.
      def isFemale?
        return self.gender==1
      end
    
    # Returns whether this Pokémon is genderless.
      def isGenderless?
        return self.gender==2
      end
    
    # Sets this Pokémon's gender to a particular gender (if possible).
      def setGender(value)
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,@species,18)
        genderbyte=dexdata.fgetb
        dexdata.close
        if genderbyte!=255 && genderbyte!=0 && genderbyte!=254
          @genderflag=value
        end
      end
    
      def makeMale; setGender(0); end
      def makeFemale; setGender(1); end
    
    ################################################################################
    # Ability
    ################################################################################
    # Returns the index of this Pokémon's ability.
      def abilityIndex
        abil=@abilityflag!=nil ? @abilityflag : (@personalID&1)
        return abil
      end
    
    # Returns the ID of this Pokémon's ability.
      def ability
        abil=abilityIndex
        abils=getAbilityList
        ret1=0; ret2=0
        for i in 0...abils.length
          next if !abils[i][0] || abils[i][0]<=0
          return abils[i][0] if abils[i][1]==abil
          ret1=abils[i][0] if abils[i][1]==0
          ret2=abils[i][0] if abils[i][1]==1
        end
        abil=(@personalID&1) if abil>=2
        return ret2 if abil==1 && ret2>0
        return ret1
      end
    
    # Returns whether this Pokémon has a particular ability.
      def hasAbility?(value=0)
        if value==0
          return self.ability>0
        else
          if value.is_a?(String) || value.is_a?(Symbol)
            value=getID(PBAbilities,value)
          end
          return self.ability==value
        end
        return false
      end
    
    # Sets this Pokémon's ability to a particular ability (if possible).
      def setAbility(value)
        @abilityflag=value
      end
    
      def hasHiddenAbility?
        abil=abilityIndex
        return abil!=nil && abil>=2
      end
    
    # Returns the list of abilities this Pokémon can have.
      def getAbilityList
        abils=[]; ret=[]
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,2)
        abils.push(dexdata.fgetw)
        abils.push(dexdata.fgetw)
        pbDexDataOffset(dexdata,self.fSpecies,40)
        abils.push(dexdata.fgetw)
        abils.push(dexdata.fgetw)
        abils.push(dexdata.fgetw)
        abils.push(dexdata.fgetw)
        dexdata.close
        for i in 0...abils.length
          next if !abils[i] || abils[i]<=0
          ret.push([abils[i],i])
        end
        return ret
      end
    
    ################################################################################
    # Nature
    ################################################################################
    # Returns the ID of this Pokémon's nature.
      def nature
        return @natureflag if @natureflag!=nil
        return @personalID%25
      end
    
    # Returns whether this Pokémon has a particular nature.
      def hasNature?(value=-1)
        if value<0
          return self.nature>=0
        else
          if value.is_a?(String) || value.is_a?(Symbol)
            value=getID(PBNatures,value)
          end
          return self.nature==value
        end
        return false
      end
    
    # Sets this Pokémon's nature to a particular nature.
      def setNature(value)
        if value.is_a?(String) || value.is_a?(Symbol)
          value=getID(PBNatures,value)
        end
        @natureflag=value
        self.calcStats
      end
    
    ################################################################################
    # Shininess
    ################################################################################
    # Returns whether this Pokémon is shiny (differently colored).
      def isShiny?
        return @shinyflag if @shinyflag!=nil
        a=@personalID^@trainerID
        b=a&0xFFFF
        c=(a>>16)&0xFFFF
        d=b^c
        return (d<SHINYPOKEMONCHANCE)
      end
    
    # Makes this Pokémon shiny.
      def makeShiny
        @shinyflag=true
      end
    
    # Makes this Pokémon not shiny.
      def makeNotShiny
        @shinyflag=false
      end
    
    ################################################################################
    # Pokérus
    ################################################################################
    # Returns the full value of this Pokémon's Pokérus.
      def pokerus
        return @pokerus
      end
    
    # Returns the Pokérus infection stage for this Pokémon.
      def pokerusStrain
        return @pokerus/16
      end
    
    # Returns the Pokérus infection stage for this Pokémon.
      def pokerusStage
        return 0 if !@pokerus || @pokerus==0        # Not infected
        return 2 if @pokerus>0 && (@pokerus%16)==0  # Cured
        return 1                                    # Infected
      end
    
    # Gives this Pokémon Pokérus (either the specified strain or a random one).
      def givePokerus(strain=0)
        return if self.pokerusStage==2 # Can't re-infect a cured Pokémon
        if strain<=0 || strain>=16
          strain=1+rand(15)
        end
        time=1+(strain%4)
        @pokerus=time
        @pokerus|=strain<<4
      end
    
    # Resets the infection time for this Pokémon's Pokérus (even if cured).
      def resetPokerusTime
        return if @pokerus==0
        strain=@pokerus%16
        time=1+(strain%4)
        @pokerus=time
        @pokerus|=strain<<4
      end
    
    # Reduces the time remaining for this Pokémon's Pokérus (if infected).
      def lowerPokerusCount
        return if self.pokerusStage!=1
        @pokerus-=1
      end
    
    ################################################################################
    # Types
    ################################################################################
    # Returns whether this Pokémon has the specified type.
      def hasType?(type)
        if type.is_a?(String) || type.is_a?(Symbol)
          return isConst?(self.type1,PBTypes,type) || isConst?(self.type2,PBTypes,type)
        else
          return self.type1==type || self.type2==type
        end
      end
    
    # Returns this Pokémon's first type.
      def type1
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,8)
        ret=dexdata.fgetb
        dexdata.close
        return ret
      end
    
    # Returns this Pokémon's second type.
      def type2
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,9)
        ret=dexdata.fgetb
        dexdata.close
        return ret
      end
    
    ################################################################################
    # Moves
    ################################################################################
    # Returns the number of moves known by the Pokémon.
      def numMoves
        ret=0
        for i in 0...4
          ret+=1 if @moves[i].id!=0
        end
        return ret
      end
    
    # Returns true if the Pokémon knows the given move.
      def hasMove?(move)
        if move.is_a?(String) || move.is_a?(Symbol)
          move=getID(PBMoves,move)
        end
        return false if !move || move<=0
        for i in 0...4
          return true if @moves[i].id==move
        end
        return false
      end
    
      def knowsMove?(move); return self.hasMove?(move); end
    
    # Returns the list of moves this Pokémon can learn by levelling up.
      def getMoveList
        movelist=[]
        atkdata=pbRgssOpen("Data/attacksRS.dat","rb")
        offset=atkdata.getOffset(self.fSpecies-1)
        length=atkdata.getLength(self.fSpecies-1)>>1
        atkdata.pos=offset
        for k in 0..length-1
          level=atkdata.fgetw
          move=atkdata.fgetw
          movelist.push([level,move])
        end
        atkdata.close
        return movelist
      end
    
    # Sets this Pokémon's movelist to the default movelist it originally had.
      def resetMoves
        moves=self.getMoveList
        movelist=[]
        for i in moves
          if i[0]<=self.level
            movelist[movelist.length]=i[1]
          end
        end
        movelist|=[] # Remove duplicates
        listend=movelist.length-4
        listend=0 if listend<0
        j=0
        for i in listend...listend+4
          moveid=(i>=movelist.length) ? 0 : movelist[i]
          @moves[j]=PBMove.new(moveid)
          j+=1
        end
      end
    
    # Silently learns the given move. Will erase the first known move if it has to.
      def pbLearnMove(move)
        if move.is_a?(String) || move.is_a?(Symbol)
          move=getID(PBMoves,move)
        end
        return if move<=0
        for i in 0...4
          if @moves[i].id==move
            j=i+1; while j<4
              break if @moves[j].id==0
              tmp=@moves[j]
              @moves[j]=@moves[j-1]
              @moves[j-1]=tmp
              j+=1
            end
            return
          end
        end
        for i in 0...4
          if @moves[i].id==0
            @moves[i]=PBMove.new(move)
            return
          end
        end
        @moves[0]=@moves[1]
        @moves[1]=@moves[2]
        @moves[2]=@moves[3]
        @moves[3]=PBMove.new(move)
      end
    
    # Deletes the given move from the Pokémon.
      def pbDeleteMove(move)
        if move.is_a?(String) || move.is_a?(Symbol)
          move=getID(PBMoves,move)
        end
        return if !move || move<=0
        newmoves=[]
        for i in 0...4
          newmoves.push(@moves[i]) if @moves[i].id!=move
        end
        newmoves.push(PBMove.new(0))
        for i in 0...4
          @moves[i]=newmoves[i]
        end
      end
    
    # Deletes the move at the given index from the Pokémon.
      def pbDeleteMoveAtIndex(index)
        newmoves=[]
        for i in 0...4
          newmoves.push(@moves[i]) if i!=index
        end
        newmoves.push(PBMove.new(0))
        for i in 0...4
          @moves[i]=newmoves[i]
        end
      end
    
    # Deletes all moves from the Pokémon.
      def pbDeleteAllMoves
        for i in 0...4
          @moves[i]=PBMove.new(0)
        end
      end
    
    # Copies currently known moves into a separate array, for Move Relearner.
      def pbRecordFirstMoves
        @firstmoves=[]
        for i in 0...4
          @firstmoves.push(@moves[i].id) if @moves[i].id>0
        end
      end
    
      def pbAddFirstMove(move)
        move = getID(PBMoves,move) if !move.is_a?(Integer)
        @firstmoves.push(move) if move>0 && [email protected]?(move)
      end
    
      def pbRemoveFirstMove(move)
        move = getID(PBMoves,move) if !move.is_a?(Integer)
        @firstmoves.delete(move) if move>0
      end
    
      def pbClearFirstMoves
        @firstmoves = []
      end
    
      def isCompatibleWithMove?(move)
        return pbSpeciesCompatible?(self.species,move)
      end
    
    ################################################################################
    # Contest attributes, ribbons
    ################################################################################
      def cool; @cool ? @cool : 0; end
      def beauty; @beauty ? @beauty : 0; end
      def cute; @cute ? @cute : 0; end
      def smart; @smart ? @smart : 0; end
      def tough; @tough ? @tough : 0; end
      def sheen; @sheen ? @sheen : 0; end
    
    # Returns the number of ribbons this Pokémon has.
      def ribbonCount
        @ribbons=[] if !@ribbons
        return @ribbons.length
      end
    
    # Returns whether this Pokémon has the specified ribbon.
      def hasRibbon?(ribbon) 
        @ribbons=[] if !@ribbons
        ribbon=getID(PBRibbons,ribbon) if !ribbon.is_a?(Integer)
        return false if ribbon==0
        return @ribbons.include?(ribbon)
      end
    
    # Gives this Pokémon the specified ribbon.
      def giveRibbon(ribbon)
        @ribbons=[] if !@ribbons
        ribbon=getID(PBRibbons,ribbon) if !ribbon.is_a?(Integer)
        return if ribbon==0
        @ribbons.push(ribbon) if [email protected]?(ribbon)
      end
    
    # Replaces one ribbon with the next one along, if possible.
      def upgradeRibbon(*arg)
        @ribbons=[] if !@ribbons
        for i in 0...arg.length-1
          for j in [email protected]
            thisribbon=(arg[i].is_a?(Integer)) ? arg[i] : getID(PBRibbons,arg[i])
            if @ribbons[j]==thisribbon
              nextribbon=(arg[i+1].is_a?(Integer)) ? arg[i+1] : getID(PBRibbons,arg[i+1])
              @ribbons[j]=nextribbon
              return nextribbon
            end
          end
        end
        if !hasRibbon?(arg[arg.length-1])
          firstribbon=(arg[0].is_a?(Integer)) ? arg[0] : getID(PBRibbons,arg[0])
          giveRibbon(firstribbon)
          return firstribbon
        end
        return 0
      end
    
    # Removes the specified ribbon from this Pokémon.
      def takeRibbon(ribbon)
        return if !@ribbons
        ribbon=getID(PBRibbons,ribbon) if !ribbon.is_a?(Integer)
        return if ribbon==0
        for i in [email protected]
          if @ribbons[i]==ribbon
            @ribbons[i]=nil; break
          end
        end
        @ribbons.compact!
      end
    
    # Removes all ribbons from this Pokémon.
      def clearAllRibbons
        @ribbons=[]
      end
    
    ################################################################################
    # Items
    ################################################################################
    # Returns whether this Pokémon has a hold item.
      def hasItem?(value=0)
        if value==0
          return self.item>0
        else
          if value.is_a?(String) || value.is_a?(Symbol)
            value=getID(PBItems,value)
          end
          return self.item==value
        end
        return false
      end
    
    # Sets this Pokémon's item. Accepts symbols.
      def setItem(value)
        if value.is_a?(String) || value.is_a?(Symbol)
          value=getID(PBItems,value)
        end
        self.item=value
      end
    
    # Returns the items this species can be found holding in the wild.
      def wildHoldItems
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,48)
        itemcommon=dexdata.fgetw
        itemuncommon=dexdata.fgetw
        itemrare=dexdata.fgetw
        dexdata.close
        return [itemcommon || 0,itemuncommon || 0,itemrare || 0]
      end
    
    # Returns this Pokémon's mail.
      def mail
        return nil if !@mail
        if @mail.item==0 || !self.hasItem? || @mail.item!=self.item
          @mail=nil
          return nil
        end
        return @mail
      end
    
    ################################################################################
    # Other
    ################################################################################
    # Returns the species name of this Pokémon.
      def speciesName
        return PBSpecies.getName(@species)
      end
    
    # Returns this Pokémon's language.
      def language; @language ? @language : 0; end
    
    # Returns the markings this Pokémon has.
      def markings
        @markings=0 if !@markings
        return @markings
      end
    
    # Returns a string stating the Unown form of this Pokémon.
      def unownShape
        return "ABCDEFGHIJKLMNOPQRSTUVWXYZ?!"[@form,1]
      end
    
    # Returns the height of this Pokémon.
      def height
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,33)
        height=dexdata.fgetw
        dexdata.close
        return height
      end
    
    # Returns the weight of this Pokémon.
      def weight
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,35)
        weight=dexdata.fgetw
        dexdata.close
        return weight
      end
    
    # Returns the EV yield of this Pokémon.
      def evYield
        ret=[]
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,23)
        for i in 0...6
          v=dexdata.fgetb
          v=0 if !v
          ret.push(v)
        end
        dexdata.close
        return ret
      end
    
    # Sets this Pokémon's HP.
      def hp=(value)
        value=0 if value<0
        @hp=value
        if @hp==0
          @status=0
          @statusCount=0
        end
      end
    
      def fainted?
        return !egg? && @hp<=0
      end
    
      alias isFainted? fainted?
    
    # Heals all HP of this Pokémon.
      def healHP
        return if egg?
        @hp=@totalhp
      end
    
    # Heals the status problem of this Pokémon.
      def healStatus
        return if egg?
        @status=0
        @statusCount=0
      end
    
    # Heals all PP of this Pokémon.
      def healPP(index=-1)
        return if egg?
        if index>=0
          @moves[index].pp=@moves[index].totalpp
        else
          for i in 0...4
            @moves[i].pp=@moves[i].totalpp
          end
        end
      end
    
    # Heals all HP, PP, and status problems of this Pokémon.
      def heal
        return if egg?
        healHP
        healStatus
        healPP
      end
    
    # Changes the happiness of this Pokémon depending on what happened to change it.
      def changeHappiness(method)
        gain=0; luxury=false
        case method
        when "walking"
          gain=1
          gain+=1 if @happiness<200
          gain+=1 if @obtainMap==$game_map.map_id
          luxury=true
        when "levelup"
          gain=2
          gain=3 if @happiness<200
          gain=5 if @happiness<100
          luxury=true
        when "groom"
          gain=4
          gain=10 if @happiness<200
          luxury=true
        when "faint"
          gain=-1
        when "vitamin"
          gain=2
          gain=3 if @happiness<200
          gain=5 if @happiness<100
        when "evberry"
          gain=2
          gain=5 if @happiness<200
          gain=10 if @happiness<100
        when "powder"
          gain=-10
          gain=-5 if @happiness<200
        when "energyroot"
          gain=-15
          gain=-10 if @happiness<200
        when "revivalherb"
          gain=-20
          gain=-15 if @happiness<200
        else
          Kernel.pbMessage(_INTL("Unknown happiness-changing method."))
        end
        gain+=1 if luxury && self.ballused==pbGetBallType(:LUXURYBALL)
        if isConst?(self.item,PBItems,:SOOTHEBELL) && gain>0
          gain=(gain*1.5).floor
        end
        @happiness+=gain
        @happiness=[[255,@happiness].min,0].max
      end
    
    ################################################################################
    # Stat calculations, Pokémon creation
    ################################################################################
    # Returns this Pokémon's base stats.  An array of six values.
      def baseStats
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,10)
        ret=[
           dexdata.fgetb, # HP
           dexdata.fgetb, # Attack
           dexdata.fgetb, # Defense
           dexdata.fgetb, # Speed
           dexdata.fgetb, # Special Attack
           dexdata.fgetb  # Special Defense
        ]
        dexdata.close
        return ret
      end
    
    # Returns the maximum HP of this Pokémon.
      def calcHP(base,level,iv,ev)
        return 1 if base==1
        return ((base*2+iv+(ev>>2))*level/100).floor+level+10
      end
    
    # Returns the specified stat of this Pokémon (not used for total HP).
      def calcStat(base,level,iv,ev,pv)
        return ((((base*2+iv+(ev>>2))*level/100).floor+5)*pv/100).floor
      end
    
    # Recalculates this Pokémon's stats.
      def calcStats
        nature=self.nature
        stats=[]
        pvalues=[100,100,100,100,100]
        nd5=(nature/5).floor
        nm5=(nature%5).floor
        if nd5!=nm5
          pvalues[nd5]=110
          pvalues[nm5]=90
        end
        level=self.level
        bs=self.baseStats
        for i in 0..5
          if @wake[i]!=0 
            # overwrite IVs in calcStats formula
            for j in 0..5
            base=bs[i]
              if i==PBStats::HP
                stats[i]=calcHP(base,level,@wake[j],@ev[i])
              else
                stats[i]=calcStat(base,level,@wake[j],@ev[i],pvalues[i-1])
              end
            end
          else
            for j in 0..5
            base=bs[i]
              if i==PBStats::HP
                stats[i]=calcHP(base,level,@iv[j],@ev[i])
              else
                stats[i]=calcStat(base,level,@iv[j],@ev[i],pvalues[i-1])
              end
            end
          end
        end
        diff=@totalhp-@hp
        @totalhp=stats[0]
        @hp=@totalhp-diff
        @hp=0 if @hp<=0
        @hp=@totalhp if @hp>@totalhp
        @attack=stats[1]
        @defense=stats[2]
        @speed=stats[3]
        @spatk=stats[4]
        @spdef=stats[5]
      end
    
    # Creates a new Pokémon object.
    #    species   - Pokémon species.
    #    level     - Pokémon level.
    #    player    - PokeBattle_Trainer object for the original trainer.
    #    withMoves - If false, this Pokémon has no moves.
      def initialize(species,level,player=nil,withMoves=true)
        if species.is_a?(String) || species.is_a?(Symbol)
          species = getID(PBSpecies,species)
        end
        cname = getConstantName(PBSpecies,species) rescue nil
        if !species || species<1 || species>PBSpecies.maxValue || !cname
          raise ArgumentError.new(_INTL("The species number (no. {1} of {2}) is invalid.",species,PBSpecies.maxValue))
          return nil
        end
        # Ditto
        @special       = false
        @species       = species
        @name          = PBSpecies.getName(@species)
        @personalID    = rand(256)
        @personalID    |= rand(256)<<8
        @personalID    |= rand(256)<<16
        @personalID    |= rand(256)<<24
        @hp            = 1
        @totalhp       = 1
        @ev            = [0,0,0,0,0,0]
        @iv            = []
        for i in 0...6
          @iv[i]       = rand(32)
        end
        @wake          = [0,0,0,0,0,0]
        @moves         = []
        @status        = 0
        @statusCount   = 0
        @item          = 0
        @mail          = nil
        @fused         = nil
        @ribbons       = []
        @ballused      = 0
        @eggsteps      = 0
        if player
          @trainerID   = player.id
          @ot          = player.name
          @otgender    = player.gender
          @language    = player.language
        else
          @trainerID   = 0
          @ot          = ""
          @otgender    = 2
        end
        if $game_map
          @obtainMap   = $game_map.map_id
          @obtainText  = nil
          @obtainLevel = level
        else
          @obtainMap   = 0
          @obtainText  = nil
          @obtainLevel = level
        end
        @obtainMode    = 0   # Met
        @obtainMode    = 4 if $game_switches && $game_switches[FATEFUL_ENCOUNTER_SWITCH]
        @hatchedMap    = 0
        @timeReceived  = pbGetTimeNow.to_i
        self.level     = level
        calcStats
        @hp            = @totalhp
        dexdata = pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,19)
        @happiness     = dexdata.fgetb
        dexdata.close
        if withMoves
          self.resetMoves
        else
          for i in 0...4
            @moves[i] = PBMove.new(0)
          end
        end
      end
    end
    
    
    
    def pbGenPkmn(species,level,owner=nil)
      owner = $Trainer if !owner
      return PokeBattle_Pokemon.new(species,level,owner)
    end
    
    def pbGenPoke(species,level,owner=nil); return pbGenPkmn(species,level,owner); end



    And Party Script:
    Code:
    #===============================================================================
    # Heart symbol for starter Pokémon (used in the party screen)
    #===============================================================================
    class StarterIconSprite < SpriteWrapper
      def initialize(x,y,pokemon,viewport=nil)
        super(viewport)
        self.x = x
        self.y = y
        @pokemon = pokemon
        @special = 0
        self.special = @pokemon.special
      end
    
      def pokemon=(value)
        @pokemon = value
        self.special = @pokemon.special
      end
    
      def special=(value)
        return if @special==value
        @special = value
        @animbitmap.dispose if @animbitmap
        @animbitmap = nil
        if @special && @special==true
          @animbitmap = AnimatedBitmap.new(pbStarterIconFile)
          self.bitmap = @animbitmap.bitmap
        else
          self.bitmap = nil
        end
      end
    
      def dispose
        @animbitmap.dispose if @animbitmap
        super
      end
    
      def update
        super
        self.special = @pokemon.special
        if @animbitmap
          @animbitmap.update
          self.bitmap = @animbitmap.bitmap
        end
      end
    end
    
    def pbStarterIconFile   # Used in the party screen
      bitmapFileName = sprintf("Graphics/Pictures/Party/icon_heart")
      return bitmapFileName
    end
    
    def pbHeldItemIconFile(item)   # Used in the party screen
      return nil if !item || item==0
      if pbIsMail?(item)
        namebase = "mail"
      elsif pbIsMegaStone?(item)
        namebase = "mega"
      # Uncomment this part if using Amethyst's Z-Move add-on
      #elsif pbIsZCrystal?(item) || pbIsZCrystal2?(item)
      #  namebase = "z_crystal"
      else
        namebase = "item"
      end
      bitmapFileName = sprintf("Graphics/Pictures/Party/icon_%s_%s",namebase,getConstantName(PBItems,item)) rescue nil
      if !pbResolveBitmap(bitmapFileName)
        bitmapFileName = sprintf("Graphics/Pictures/Party/icon_%s_%03d",namebase,item)
        if !pbResolveBitmap(bitmapFileName)
          bitmapFileName = sprintf("Graphics/Pictures/Party/icon_%s",namebase)
        end
      end
      return bitmapFileName
    end
    
    def easyItemType(item)
      type=0
      type=1 if pbIsMail?(item)
      type=2 if pbIsMegaStone?(item)
      # Uncomment this part if using Amethyst's Z-Move add-on
      #type=3 if pbIsZCrystal?(item) || pbIsZCrystal2?(item)
      return type
    end
    
    #===============================================================================
    # Item held icon (used in the party screen)
    #===============================================================================
    class HeldItemIconSprite < SpriteWrapper
      def initialize(x,y,pokemon,viewport=nil)
        super(viewport)
        self.x = x
        self.y = y
        @pokemon = pokemon
        @item = 0
        self.item = @pokemon.item
        @mode = 0 # 0=item; 1=mail; 2=mega; 3=zcrystal
        @mode=easyItemType(@pokemon.item)
      end
      
      def mode
        return @mode
      end
    
      def pokemon=(value)
        @pokemon = value
        self.item = @pokemon.item
      end
    
      def item=(value)
        return if @item==value
        @item = value
        @animbitmap.dispose if @animbitmap
        @animbitmap = nil
        if @item && @item>0
          @animbitmap = AnimatedBitmap.new(pbHeldItemIconFile(value))
          self.bitmap = @animbitmap.bitmap
        else
          self.bitmap = nil
        end
      end
    
      def dispose
        @animbitmap.dispose if @animbitmap
        super
      end
    
      def update
        super
        self.item = @pokemon.item
        if @animbitmap
          @animbitmap.update
          self.bitmap = @animbitmap.bitmap
        end
      end
    end
    #===============================================================================
    # Pokémon party buttons and menu
    #===============================================================================
    class PokemonPartyConfirmCancelSprite < SpriteWrapper
      attr_reader :selected
    
      def initialize(text,x,y,narrowbox=false,viewport=nil)
        super(viewport)
        @refreshBitmap = true
        @bgsprite = ChangelingSprite.new(0,0,viewport)
        if narrowbox
          @bgsprite.addBitmap("desel","Graphics/Pictures/Party/icon_cancel_narrow")
          @bgsprite.addBitmap("sel","Graphics/Pictures/Party/icon_cancel_narrow_sel")
        else
          @bgsprite.addBitmap("desel","Graphics/Pictures/Party/icon_cancel")
          @bgsprite.addBitmap("sel","Graphics/Pictures/Party/icon_cancel_sel")
        end
        @bgsprite.changeBitmap("desel")
        @overlaysprite = BitmapSprite.new(@bgsprite.bitmap.width,@bgsprite.bitmap.height,viewport)
        @overlaysprite.z = self.z+1
        pbSetSystemFont(@overlaysprite.bitmap)
        @yoffset = 8
        textpos = [[text,56,(narrowbox) ? 2 : 8,2,Color.new(248,248,248),Color.new(40,40,40)]]
        pbDrawTextPositions(@overlaysprite.bitmap,textpos)
        self.x = x
        self.y = y
      end
    
      def dispose
        @bgsprite.dispose
        @overlaysprite.bitmap.dispose
        @overlaysprite.dispose
        super
      end
    
      def viewport=(value)
        super
        refresh
      end
    
      def x=(value)
        super
        refresh
      end
    
      def y=(value)
        super
        refresh
      end
    
      def color=(value)
        super
        refresh
      end
    
      def selected=(value)
        if @selected!=value
          @selected = value
          refresh
        end
      end
    
      def refresh
        if @bgsprite && [email protected]?
          @bgsprite.changeBitmap((@selected) ? "sel" : "desel")
          @bgsprite.x     = self.x
          @bgsprite.y     = self.y
          @bgsprite.color = self.color
        end
        if @overlaysprite && [email protected]?
          @overlaysprite.x     = self.x
          @overlaysprite.y     = self.y
          @overlaysprite.color = self.color
        end
      end
    end
    
    
    
    class PokemonPartyCancelSprite < PokemonPartyConfirmCancelSprite
      def initialize(viewport=nil)
        super(_INTL("CANCEL"),398,328,false,viewport)
      end
    end
    
    
    
    class PokemonPartyConfirmSprite < PokemonPartyConfirmCancelSprite
      def initialize(viewport=nil)
        super(_INTL("CONFIRM"),398,308,true,viewport)
      end
    end
    
    
    
    class PokemonPartyCancelSprite2 < PokemonPartyConfirmCancelSprite
      def initialize(viewport=nil)
        super(_INTL("CANCEL"),398,346,true,viewport)
      end
    end
    
    
    
    class Window_CommandPokemonColor < Window_CommandPokemon
      def initialize(commands,width=nil)
        @colorKey = []
        for i in 0...commands.length
          if commands[i].is_a?(Array)
            @colorKey[i] = commands[i][1]
            commands[i] = commands[i][0]
          end
        end
        super(commands,width)
      end
    
      def drawItem(index,count,rect)
        pbSetSystemFont(self.contents) if @starting
        rect = drawCursor(index,rect)
        base   = self.baseColor
        shadow = self.shadowColor
        if @colorKey[index] && @colorKey[index]==1
          base   = Color.new(0,80,160)
          shadow = Color.new(128,192,240)
        end
        pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,@commands[index],base,shadow)
      end
    end
    
    
    
    #===============================================================================
    # Pokémon party panels
    #===============================================================================
    class PokemonPartyBlankPanel < SpriteWrapper
      attr_accessor :text
    
      def initialize(pokemon,index,viewport=nil)
        super(viewport)
        self.x = [0,256,0,256,0,256][index]
        self.y = [0,16,96,112,192,208][index]
        @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/panel_blank")
        self.bitmap = @panelbgsprite.bitmap
        @text = nil
      end
    
      def dispose
        @panelbgsprite.dispose
        super
      end
    
      def selected; return false; end
      def selected=(value); end
      def preselected; return false; end
      def preselected=(value); end
      def switching; return false; end
      def switching=(value); end
      def refresh; end
    end
    
    
    
    class PokemonPartyPanel < SpriteWrapper
      attr_reader :pokemon
      attr_reader :active
      attr_reader :selected
      attr_reader :preselected
      attr_reader :switching
      attr_accessor :text
    
      def initialize(pokemon,index,viewport=nil)
        super(viewport)
        @pokemon = pokemon
        @active = (index==0)   # true = rounded panel, false = rectangular panel
        @refreshing = true
        self.x = [0,256,0,256,0,256][index]
        self.y = [0,16,96,112,192,208][index]
        @panelbgsprite = ChangelingSprite.new(0,0,viewport)
        @panelbgsprite.z = self.z
        if @active   # Rounded panel
          @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/panel_round")
          @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/panel_round_sel")
          @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/panel_round_faint")
          @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/panel_round_faint_sel")
          @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/panel_round_swap")
          @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/panel_round_swap_sel")
          @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/panel_round_swap_sel2")
        else   # Rectangular panel
          @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/panel_rect")
          @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/panel_rect_sel")
          @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/panel_rect_faint")
          @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/panel_rect_faint_sel")
          @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/panel_rect_swap")
          @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/panel_rect_swap_sel")
          @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/panel_rect_swap_sel2")
        end
        @hpbgsprite = ChangelingSprite.new(0,0,viewport)
        @hpbgsprite.z = self.z+1
        @hpbgsprite.addBitmap("able","Graphics/Pictures/Party/overlay_hp_back")
        @hpbgsprite.addBitmap("fainted","Graphics/Pictures/Party/overlay_hp_back_faint")
        @hpbgsprite.addBitmap("swap","Graphics/Pictures/Party/overlay_hp_back_swap")
        @ballsprite = ChangelingSprite.new(0,0,viewport)
        @ballsprite.z = self.z+1
    #   @ballsprite.addBitmap("desel","Graphics/Pictures/Party/icon_ball")
    #   @ballsprite.addBitmap("sel","Graphics/Pictures/Party/icon_ball_sel")
        #===========================================================================
        # New Party Balls
        #===========================================================================
        @ballsprite.addBitmap("pokeballdesel","Graphics/Pictures/PartyBall/partyBallBasic")
        @ballsprite.addBitmap("pokeballsel","Graphics/Pictures/PartyBall/partyBallSelBasic")
        @ballsprite.addBitmap("greatballdesel","Graphics/Pictures/PartyBall/partyBallGreat")
        @ballsprite.addBitmap("greatballsel","Graphics/Pictures/PartyBall/partyBallSelGreat")
        @ballsprite.addBitmap("safariballdesel","Graphics/Pictures/PartyBall/partyBallSafari")
        @ballsprite.addBitmap("safariballsel","Graphics/Pictures/PartyBall/partyBallSelSafari")
        @ballsprite.addBitmap("ultraballdesel","Graphics/Pictures/PartyBall/partyBallUltra")
        @ballsprite.addBitmap("ultraballsel","Graphics/Pictures/PartyBall/partyBallSelUltra")
        @ballsprite.addBitmap("masterballdesel","Graphics/Pictures/PartyBall/partyBallMaster")
        @ballsprite.addBitmap("masterballsel","Graphics/Pictures/PartyBall/partyBallSelMaster")
        @ballsprite.addBitmap("netballdesel","Graphics/Pictures/PartyBall/partyBallNet")
        @ballsprite.addBitmap("netballsel","Graphics/Pictures/PartyBall/partyBallSelNet")
        @ballsprite.addBitmap("diveballdesel","Graphics/Pictures/PartyBall/partyBallDive")
        @ballsprite.addBitmap("diveballsel","Graphics/Pictures/PartyBall/partyBallSelDive")
        @ballsprite.addBitmap("nestballdesel","Graphics/Pictures/PartyBall/partyBallNest")
        @ballsprite.addBitmap("nestballsel","Graphics/Pictures/PartyBall/partyBallSelNest")
        @ballsprite.addBitmap("repeatballdesel","Graphics/Pictures/PartyBall/partyBallRepeat")
        @ballsprite.addBitmap("repeatballsel","Graphics/Pictures/PartyBall/partyBallSelRepeat")
        @ballsprite.addBitmap("timerballdesel","Graphics/Pictures/PartyBall/partyBallTimer")
        @ballsprite.addBitmap("timerballsel","Graphics/Pictures/PartyBall/partyBallSelTimer")
        @ballsprite.addBitmap("luxuryballdesel","Graphics/Pictures/PartyBall/partyBallLuxury")
        @ballsprite.addBitmap("luxuryballsel","Graphics/Pictures/PartyBall/partyBallSelLuxury")
        @ballsprite.addBitmap("premierballdesel","Graphics/Pictures/PartyBall/partyBallPremier")
        @ballsprite.addBitmap("premierballsel","Graphics/Pictures/PartyBall/partyBallSelPremier")
        @ballsprite.addBitmap("duskballdesel","Graphics/Pictures/PartyBall/partyBallDusk")
        @ballsprite.addBitmap("duskballsel","Graphics/Pictures/PartyBall/partyBallSelDusk")
        @ballsprite.addBitmap("healballdesel","Graphics/Pictures/PartyBall/partyBallHeal")
        @ballsprite.addBitmap("healballsel","Graphics/Pictures/PartyBall/partyBallSelHeal")
        @ballsprite.addBitmap("quickballdesel","Graphics/Pictures/PartyBall/partyBallQuick")
        @ballsprite.addBitmap("quickballsel","Graphics/Pictures/PartyBall/partyBallSelQuick")
        @ballsprite.addBitmap("cherishballdesel","Graphics/Pictures/PartyBall/partyBallCherish")
        @ballsprite.addBitmap("cherishballsel","Graphics/Pictures/PartyBall/partyBallSelCherish")
        @ballsprite.addBitmap("fastballdesel","Graphics/Pictures/PartyBall/partyBallFast")
        @ballsprite.addBitmap("fastballsel","Graphics/Pictures/PartyBall/partyBallSelFast")
        @ballsprite.addBitmap("levelballdesel","Graphics/Pictures/PartyBall/partyBallLevel")
        @ballsprite.addBitmap("levelballsel","Graphics/Pictures/PartyBall/partyBallSelLevel")
        @ballsprite.addBitmap("lureballdesel","Graphics/Pictures/PartyBall/partyBallLure")
        @ballsprite.addBitmap("lureballsel","Graphics/Pictures/PartyBall/partyBallSelLure")
        @ballsprite.addBitmap("heavyballdesel","Graphics/Pictures/PartyBall/partyBallHeavy")
        @ballsprite.addBitmap("heavyballsel","Graphics/Pictures/PartyBall/partyBallSelHeavy")
        @ballsprite.addBitmap("loveballdesel","Graphics/Pictures/PartyBall/partyBallLove")
        @ballsprite.addBitmap("loveballsel","Graphics/Pictures/PartyBall/partyBallSelLove")
        @ballsprite.addBitmap("friendballdesel","Graphics/Pictures/PartyBall/partyBallFriend")
        @ballsprite.addBitmap("friendballsel","Graphics/Pictures/PartyBall/partyBallSelFriend")
        @ballsprite.addBitmap("moonballdesel","Graphics/Pictures/PartyBall/partyBallMoon")
        @ballsprite.addBitmap("moonballsel","Graphics/Pictures/PartyBall/partyBallSelMoon")
        @ballsprite.addBitmap("sportballdesel","Graphics/Pictures/PartyBall/partyBallSport")
        @ballsprite.addBitmap("sportballsel","Graphics/Pictures/PartyBall/partyBallSelSport")
        @ballsprite.addBitmap("parkballsel","Graphics/Pictures/PartyBall/partyBallSelPark")
        @ballsprite.addBitmap("parkballdesel","Graphics/Pictures/PartyBall/partyBallPark")
        @ballsprite.addBitmap("dreamballsel","Graphics/Pictures/PartyBall/partyBallSelDream")
        @ballsprite.addBitmap("dreamballdesel","Graphics/Pictures/PartyBall/partyBallDream")
        #===========================================================================
        @pkmnsprite = PokemonIconSprite.new(pokemon,viewport)
        @pkmnsprite.active = @active
        @pkmnsprite.z      = self.z+2
        @helditemsprite = HeldItemIconSprite.new(0,0,@pokemon,viewport)
        @[email protected]
        @helditemsprite.z = self.z+3
        @overlaysprite = BitmapSprite.new(Graphics.width,Graphics.height,viewport)
        @overlaysprite.z = self.z+4
        # New
        @startersprite = StarterIconSprite.new(0,0,@pokemon,viewport)
        @startersprite.z = self.z+5
        
        @hpbar    = AnimatedBitmap.new("Graphics/Pictures/Party/overlay_hp")
        @statuses = AnimatedBitmap.new(_INTL("Graphics/Pictures/statuses"))
        @selected      = false
        @preselected   = false
        @switching     = false
        @text          = nil
        @refreshBitmap = true
        @refreshing    = false
        refresh
      end
    
      def dispose
        @panelbgsprite.dispose
        @hpbgsprite.dispose
        @ballsprite.dispose
        @pkmnsprite.dispose
        @helditemsprite.dispose
        @overlaysprite.bitmap.dispose
        @overlaysprite.dispose
      # @startersprite.bitmap.dispose
        @startersprite.dispose
        @hpbar.dispose
        @statuses.dispose
        super
      end
    
      def x=(value)
        super
        refresh
      end
    
      def y=(value)
        super
        refresh
      end
    
      def color=(value)
        super
        refresh
      end
    
      def text=(value)
        if @text!=value
          @text = value
          @refreshBitmap = true
          refresh
        end
      end
    
      def pokemon=(value)
        @pokemon = value
        @pkmnsprite.pokemon = value if @pkmnsprite && [email protected]?
        @helditemsprite.pokemon = value if @helditemsprite && [email protected]?
        @startersprite.pokemon = value if @startersprite && [email protected]?
        @refreshBitmap = true
        refresh
      end
    
      def selected=(value)
        if @selected!=value
          @selected = value
          refresh
        end
      end
    
      def preselected=(value)
        if @preselected!=value
          @preselected = value
          refresh
        end
      end
    
      def switching=(value)
        if @switching!=value
          @switching = value
          refresh
        end
      end
    
      def hp; return @pokemon.hp; end
    
      def refresh
        return if disposed?
        return if @refreshing
        @refreshing = true
        if @panelbgsprite && [email protected]?
          if self.selected
            if self.preselected;     @panelbgsprite.changeBitmap("swapsel2")
            elsif @switching;        @panelbgsprite.changeBitmap("swapsel")
            elsif @pokemon.fainted?; @panelbgsprite.changeBitmap("faintedsel")
            else;                    @panelbgsprite.changeBitmap("ablesel")
            end
          else
            if self.preselected;     @panelbgsprite.changeBitmap("swap")
            elsif @pokemon.fainted?; @panelbgsprite.changeBitmap("fainted")
            else;                    @panelbgsprite.changeBitmap("able")
            end
          end
          @panelbgsprite.x     = self.x
          @panelbgsprite.y     = self.y
          @panelbgsprite.color = self.color
        end
        if @hpbgsprite && [email protected]?
          @hpbgsprite.visible = ([email protected]? && !(@text && @text.length>0))
          if @hpbgsprite.visible
            if self.preselected || (self.selected && @switching); @hpbgsprite.changeBitmap("swap")
            elsif @pokemon.fainted?;                              @hpbgsprite.changeBitmap("fainted")
            else;                                                 @hpbgsprite.changeBitmap("able")
            end
            @hpbgsprite.x     = self.x+96
            @hpbgsprite.y     = self.y+50
            @hpbgsprite.color = self.color
          end
        end
        if @ballsprite && [email protected]?
    #     @ballsprite.changeBitmap((self.selected) ? "sel" : "desel")
          #=========================================================================
          # New Party Balls
          #=========================================================================
          if @pokemon.ballused==1
            @ballsprite.changeBitmap((self.selected) ? "greatballsel" : "greatballdesel")
          elsif @pokemon.ballused==2
            @ballsprite.changeBitmap((self.selected) ? "safariballsel" : "safariballdesel")
          elsif @pokemon.ballused==3
            @ballsprite.changeBitmap((self.selected) ? "ultraballsel" : "ultraballdesel")
          elsif @pokemon.ballused==4
            @ballsprite.changeBitmap((self.selected) ? "masterballsel" : "masterballdesel")
          elsif @pokemon.ballused==5
            @ballsprite.changeBitmap((self.selected) ? "netballsel" : "netballdesel")
          elsif @pokemon.ballused==6
            @ballsprite.changeBitmap((self.selected) ? "diveballsel" : "diveballdesel")
          elsif @pokemon.ballused==7
            @ballsprite.changeBitmap((self.selected) ? "nestballsel" : "nestballdesel")
          elsif @pokemon.ballused==8
            @ballsprite.changeBitmap((self.selected) ? "repeatballsel" : "repeatballdesel")
          elsif @pokemon.ballused==9
            @ballsprite.changeBitmap((self.selected) ? "timerballsel" : "timerballdesel")
          elsif @pokemon.ballused==10
            @ballsprite.changeBitmap((self.selected) ? "luxuryballsel" : "luxuryballdesel")
          elsif @pokemon.ballused==11
            @ballsprite.changeBitmap((self.selected) ? "premierballsel" : "premierballdesel")
          elsif @pokemon.ballused==12
            @ballsprite.changeBitmap((self.selected) ? "duskballsel" : "duskballdesel")
          elsif @pokemon.ballused==13
            @ballsprite.changeBitmap((self.selected) ? "healballsel" : "healballdesel")
          elsif @pokemon.ballused==14
            @ballsprite.changeBitmap((self.selected) ? "quickballsel" : "quickballdesel")
          elsif @pokemon.ballused==15
            @ballsprite.changeBitmap((self.selected) ? "cherishballsel" : "cherishballdesel")
          elsif @pokemon.ballused==16
            @ballsprite.changeBitmap((self.selected) ? "fastballsel" : "fastballdesel")
          elsif @pokemon.ballused==17
            @ballsprite.changeBitmap((self.selected) ? "levelballsel" : "levelballdesel")
          elsif @pokemon.ballused==18
            @ballsprite.changeBitmap((self.selected) ? "lureballsel" : "lureballdesel")
          elsif @pokemon.ballused==19
            @ballsprite.changeBitmap((self.selected) ? "heavyballsel" : "heavyballdesel")
          elsif @pokemon.ballused==20
            @ballsprite.changeBitmap((self.selected) ? "loveballsel" : "loveballdesel")
          elsif @pokemon.ballused==21
            @ballsprite.changeBitmap((self.selected) ? "friendballsel" : "friendballdesel")
          elsif @pokemon.ballused==22
            @ballsprite.changeBitmap((self.selected) ? "moonballsel" : "moonballdesel")
          elsif @pokemon.ballused==23
            @ballsprite.changeBitmap((self.selected) ? "sportballsel" : "sportballdesel")
          elsif @pokemon.ballused==24
            @ballsprite.changeBitmap((self.selected) ? "parkballsel" : "parkballdesel")
          elsif @pokemon.ballused==25
            @ballsprite.changeBitmap((self.selected) ? "dreamballsel" : "dreamballdesel")
          else
             @ballsprite.changeBitmap((self.selected) ? "pokeballsel" : "pokeballdesel")
          end
          #=========================================================================
          @ballsprite.x     = self.x+10
          @ballsprite.y     = self.y
          @ballsprite.color = self.color
        end
        if @pkmnsprite && [email protected]?
          @pkmnsprite.x        = self.x+28
          @pkmnsprite.y        = self.y
          @pkmnsprite.color    = self.color
          @pkmnsprite.selected = self.selected
        end
        if @helditemsprite && [email protected]?
          if @helditemsprite.visible
            if @mode==0 # item
              @helditemsprite.x     = self.x+62
              @helditemsprite.y     = self.y+48
            elsif @mode==1 # mail
              @helditemsprite.x     = self.x+62
              @helditemsprite.y     = self.y+48
            elsif @mode==2 # mega stone
              @helditemsprite.x     = self.x+62
              @helditemsprite.y     = self.y+48-4*2
            # Uncomment this part if using Amethyst's Z-Move add-on
            #elsif @mode==3 # z-crystal
              #@helditemsprite.x     = self.x+62
              #@helditemsprite.y     = self.y+48-2
            end
            @helditemsprite.color = self.color
          end
        end
        if @overlaysprite && [email protected]?
          @overlaysprite.x     = self.x
          @overlaysprite.y     = self.y
          @overlaysprite.color = self.color
        end
        if @startersprite && [email protected]?
          if @startersprite.visible
            @startersprite.x     = self.x+62-62+18*2
            @startersprite.y     = self.y+48-2*2
            @startersprite.color = self.color
          end
        end
        if @refreshBitmap
          @refreshBitmap = false
          @overlaysprite.bitmap.clear if @overlaysprite.bitmap
          basecolor   = Color.new(248,248,248)
          shadowcolor = Color.new(40,40,40)
          pbSetSystemFont(@overlaysprite.bitmap)
          textpos = []
          # Draw Pokémon name
          textpos.push([@pokemon.name,96,16,0,basecolor,shadowcolor])
          if [email protected]?
            if !@text || @text.length==0
              # Draw HP numbers
              textpos.push([sprintf("% 3d /% 3d",@pokemon.hp,@pokemon.totalhp),224,60,1,basecolor,shadowcolor])
              # Draw HP bar
              if @pokemon.hp>0
                hpzone = 0
                hpzone = 1 if @pokemon.hp<=(@pokemon.totalhp/2).floor
                hpzone = 2 if @pokemon.hp<=(@pokemon.totalhp/4).floor
                hprect = Rect.new(0,hpzone*8,[@pokemon.hp*96/@pokemon.totalhp,2].max,8)
                @overlaysprite.bitmap.blt(128,52,@hpbar.bitmap,hprect)
              end
              # Draw status
              status = -1
              status = 6 if @pokemon.pokerusStage==1
              status = @pokemon.status-1 if @pokemon.status>0
              status = 5 if @pokemon.hp<=0
              if status>=0
                statusrect = Rect.new(0,16*status,44,16)
                @overlaysprite.bitmap.blt(78,68,@statuses.bitmap,statusrect)
              end
            end
            # Draw gender icon
            if @pokemon.isMale?
              textpos.push([_INTL("♂"),224,16,0,Color.new(0,112,248),Color.new(120,184,232)])
            elsif @pokemon.isFemale?
              textpos.push([_INTL("♀"),224,16,0,Color.new(232,32,16),Color.new(248,168,184)])
            end
          end
          pbDrawTextPositions(@overlaysprite.bitmap,textpos)
          # Draw level text
          if [email protected]?
            pbDrawImagePositions(@overlaysprite.bitmap,[[
               "Graphics/Pictures/Party/overlay_lv",20,70,0,0,22,14]])
            pbSetSmallFont(@overlaysprite.bitmap)
            pbDrawTextPositions(@overlaysprite.bitmap,[
               [@pokemon.level.to_s,42,62,0,basecolor,shadowcolor]
            ])
          end
          # Draw annotation text
          if @text && @text.length>0
            pbSetSystemFont(@overlaysprite.bitmap)
            pbDrawTextPositions(@overlaysprite.bitmap,[
               [@text,96,58,0,basecolor,shadowcolor]
            ])
          end
        end
        @refreshing = false
      end
    
      def update
        super
        @panelbgsprite.update if @panelbgsprite && [email protected]?
        @hpbgsprite.update if @hpbgsprite && [email protected]?
        @ballsprite.update if @ballsprite && [email protected]?
        @pkmnsprite.update if @pkmnsprite && [email protected]?
        @helditemsprite.update if @helditemsprite && [email protected]?
        @startersprite.update if @startersprite && [email protected]?
      end
    end
    
    
    
    #===============================================================================
    # Pokémon party visuals
    #===============================================================================
    class PokemonParty_Scene
      def pbStartScene(party,starthelptext,annotations=nil,multiselect=false)
        @sprites = {}
        @party = party
        @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
        @viewport.z = 99999
        @multiselect = multiselect
        addBackgroundPlane(@sprites,"partybg","Party/bg",@viewport)
        @sprites["messagebox"] = Window_AdvancedTextPokemon.new("")
        @sprites["messagebox"].viewport       = @viewport
        @sprites["messagebox"].visible        = false
        @sprites["messagebox"].letterbyletter = true
        pbBottomLeftLines(@sprites["messagebox"],2)
        @sprites["helpwindow"] = Window_UnformattedTextPokemon.new(starthelptext)
        @sprites["helpwindow"].viewport = @viewport
        @sprites["helpwindow"].visible  = true
        pbBottomLeftLines(@sprites["helpwindow"],1)
        pbSetHelpText(starthelptext)
        # Add party Pokémon sprites
        for i in 0...6
          if @party[i]
            @sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i],i,@viewport)
          else
            @sprites["pokemon#{i}"] = PokemonPartyBlankPanel.new(@party[i],i,@viewport)
          end
          @sprites["pokemon#{i}"].text = annotations[i] if annotations
        end
        if @multiselect
          @sprites["pokemon6"] = PokemonPartyConfirmSprite.new(@viewport)
          @sprites["pokemon7"] = PokemonPartyCancelSprite2.new(@viewport)
        else
          @sprites["pokemon6"] = PokemonPartyCancelSprite.new(@viewport)
        end
        # Select first Pokémon
        @activecmd = 0
        @sprites["pokemon0"].selected = true
        pbFadeInAndShow(@sprites) { update }
      end
    
      def pbEndScene
        pbFadeOutAndHide(@sprites) { update }
        pbDisposeSpriteHash(@sprites)
        @viewport.dispose
      end
    
      def pbDisplay(text)
        @sprites["messagebox"].text    = text
        @sprites["messagebox"].visible = true
        @sprites["helpwindow"].visible = false
        pbPlayDecisionSE
        loop do
          Graphics.update
          Input.update
          self.update
          if @sprites["messagebox"].busy?
            if Input.trigger?(Input::C)
              pbPlayDecisionSE if @sprites["messagebox"].pausing?
              @sprites["messagebox"].resume
            end
          else
            if Input.trigger?(Input::B) || Input.trigger?(Input::C)
              break
            end
          end
        end
        @sprites["messagebox"].visible = false
        @sprites["helpwindow"].visible = true
      end
    
      def pbDisplayConfirm(text)
        ret = -1
        @sprites["messagebox"].text    = text
        @sprites["messagebox"].visible = true
        @sprites["helpwindow"].visible = false
        using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"),_INTL("No")])) {
          cmdwindow.visible = false
          pbBottomRight(cmdwindow)
          cmdwindow.y -= @sprites["messagebox"].height
          cmdwindow.z = @viewport.z+1
          loop do
            Graphics.update
            Input.update
            cmdwindow.visible = true if !@sprites["messagebox"].busy?
            cmdwindow.update
            self.update
            if !@sprites["messagebox"].busy?
              if Input.trigger?(Input::B)
                ret = false
                break
              elsif Input.trigger?(Input::C) && @sprites["messagebox"].resume
                ret = (cmdwindow.index==0)
                break
              end
            end
          end
        }
        @sprites["messagebox"].visible = false
        @sprites["helpwindow"].visible = true
        return ret
      end
    
      def pbShowCommands(helptext,commands,index=0)
        ret = -1
        helpwindow = @sprites["helpwindow"]
        helpwindow.visible = true
        using(cmdwindow = Window_CommandPokemonColor.new(commands)) {
          cmdwindow.z     = @viewport.z+1
          cmdwindow.index = index
          pbBottomRight(cmdwindow)
          helpwindow.resizeHeightToFit(helptext,Graphics.width-cmdwindow.width)
          helpwindow.text = helptext
          pbBottomLeft(helpwindow)
          loop do
            Graphics.update
            Input.update
            cmdwindow.update
            self.update
            if Input.trigger?(Input::B)
              pbPlayCancelSE
              ret = -1
              break
            elsif Input.trigger?(Input::C)
              pbPlayDecisionSE
              ret = cmdwindow.index
              break
            end
          end
        }
        return ret
      end
    
      def pbMessageFreeText(text,startMsg,maxlength)   # Unused
        return Kernel.pbMessageFreeText(
           _INTL("Please enter a message (max. {1} characters).",maxlength),
           startMsg,false,maxlength,Graphics.width) { update }
      end
    
      def pbSetHelpText(helptext)
        helpwindow = @sprites["helpwindow"]
        pbBottomLeftLines(helpwindow,1)
        helpwindow.text = helptext
        helpwindow.width = 398
        helpwindow.visible = true
      end
    
      def pbAnnotate(annot)
        for i in 0...6
          @sprites["pokemon#{i}"].text = (annot) ? annot[i] : nil
        end
      end
    
      def pbSelect(item)
        @activecmd = item
        numsprites = (@multiselect) ? 8 : 7
        for i in 0...numsprites
          @sprites["pokemon#{i}"].selected = (i==@activecmd)
        end
      end
    
      def pbPreSelect(item)
        @activecmd = item
      end
    
      def pbSwitchBegin(oldid,newid)
        oldsprite = @sprites["pokemon#{oldid}"]
        newsprite = @sprites["pokemon#{newid}"]
        16.times do
          oldsprite.x += (oldid&1)==0 ? -16 : 16
          newsprite.x += (newid&1)==0 ? -16 : 16
          Graphics.update
          Input.update
          self.update
        end
      end
      
      def pbSwitchEnd(oldid,newid)
        oldsprite = @sprites["pokemon#{oldid}"]
        newsprite = @sprites["pokemon#{newid}"]
        oldsprite.pokemon = @party[oldid]
        newsprite.pokemon = @party[newid]
        16.times do
          oldsprite.x -= (oldid&1)==0 ? -16 : 16
          newsprite.x -= (newid&1)==0 ? -16 : 16
          Graphics.update
          Input.update
          self.update
        end
        for i in 0...6
          @sprites["pokemon#{i}"].preselected = false
          @sprites["pokemon#{i}"].switching   = false
        end
        pbRefresh
      end
    
      def pbClearSwitching
        for i in 0...6
          @sprites["pokemon#{i}"].preselected = false
          @sprites["pokemon#{i}"].switching   = false
        end
      end
    
      def pbSummary(pkmnid)
        oldsprites = pbFadeOutAndHide(@sprites)
        scene = PokemonSummary_Scene.new
        screen = PokemonSummaryScreen.new(scene)
        screen.pbStartScreen(@party,pkmnid)
        pbFadeInAndShow(@sprites,oldsprites)
      end
    
      def pbChooseItem(bag)
        ret = 0
        pbFadeOutIn(99999){
          scene = PokemonBag_Scene.new
          screen = PokemonBagScreen.new(scene,bag)
          ret = screen.pbChooseItemScreen(Proc.new{|item| pbCanHoldItem?(item) })
        }
        return ret
      end
    
      def pbUseItem(bag,pokemon)
        ret = 0
        pbFadeOutIn(99999){
          scene = PokemonBag_Scene.new
          screen = PokemonBagScreen.new(scene,bag)
          ret = screen.pbChooseItemScreen(Proc.new{|item|
            next false if !pbCanUseOnPokemon?(item)
            if pbIsMachine?(item)
              move = pbGetMachine(item)
              next false if pokemon.hasMove?(move) || !pokemon.isCompatibleWithMove?(move)
            end
            next true
          })
        }
        return ret
      end
    
      def pbChoosePokemon(switching=false,initialsel=-1,canswitch=0)
        for i in 0...6
          @sprites["pokemon#{i}"].preselected = (switching && i==@activecmd)
          @sprites["pokemon#{i}"].switching   = switching
        end
        @activecmd = initialsel if initialsel>=0
        pbRefresh
        loop do
          Graphics.update
          Input.update
          self.update
          oldsel = @activecmd
          key = -1
          key = Input::DOWN if Input.repeat?(Input::DOWN)
          key = Input::RIGHT if Input.repeat?(Input::RIGHT)
          key = Input::LEFT if Input.repeat?(Input::LEFT)
          key = Input::UP if Input.repeat?(Input::UP)
          if key>=0
            @activecmd = pbChangeSelection(key,@activecmd)
          end
          if @activecmd!=oldsel # Changing selection
            pbPlayCursorSE
            numsprites = (@multiselect) ? 8 : 7
            for i in 0...numsprites
              @sprites["pokemon#{i}"].selected = (i==@activecmd)
            end
          end
          cancelsprite = (@multiselect) ? 7 : 6
          if Input.trigger?(Input::A) && canswitch==1 && @activecmd!=cancelsprite
            pbPlayDecisionSE
            return [1,@activecmd]
          elsif Input.trigger?(Input::A) && canswitch==2
            return -1
          elsif Input.trigger?(Input::B)
            return -1
          elsif Input.trigger?(Input::C)
            pbPlayDecisionSE
            return (@activecmd==cancelsprite) ? -1 : @activecmd
          end
        end
      end
    
      def pbChangeSelection(key,currentsel)
        numsprites = (@multiselect) ? 8 : 7 
        case key
        when Input::LEFT
          begin
            currentsel -= 1
          end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
          if currentsel>[email protected] && currentsel<6
            currentsel = @party.length-1
          end
          currentsel = numsprites-1 if currentsel<0
        when Input::RIGHT
          begin
            currentsel += 1
          end while currentsel<@party.length && !@party[currentsel]
          if [email protected]
            currentsel = 6
          elsif currentsel==numsprites
            currentsel = 0
          end
        when Input::UP
          if currentsel>=6
            begin
              currentsel -= 1
            end while currentsel>0 && !@party[currentsel]
          else
            begin
              currentsel -= 2
            end while currentsel>0 && !@party[currentsel]
          end
          if currentsel>[email protected] && currentsel<6
            currentsel = @party.length-1
          end
          currentsel = numsprites-1 if currentsel<0
        when Input::DOWN
          if currentsel>=5
            currentsel += 1
          else
            currentsel += 2
            currentsel = 6 if currentsel<6 && !@party[currentsel]
          end
          if currentsel>[email protected] && currentsel<6
            currentsel = 6
          elsif currentsel>=numsprites
            currentsel = 0
          end
        end
        return currentsel
      end
    
      def pbHardRefresh
        oldtext = []
        lastselected = -1
        for i in 0...6
          oldtext.push(@sprites["pokemon#{i}"].text)
          lastselected = i if @sprites["pokemon#{i}"].selected
          @sprites["pokemon#{i}"].dispose
        end
        lastselected = @party.length-1 if lastselected>[email protected]
        lastselected = 0 if lastselected<0
        for i in 0...6
          if @party[i]
            @sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i],i,@viewport)
          else
            @sprites["pokemon#{i}"] = PokemonPartyBlankPanel.new(@party[i],i,@viewport)
          end
          @sprites["pokemon#{i}"].text = oldtext[i]
        end
        pbSelect(lastselected)
      end
    
      def pbRefresh
        for i in 0...6
          sprite = @sprites["pokemon#{i}"]
          if sprite 
            if sprite.is_a?(PokemonPartyPanel)
              sprite.pokemon = sprite.pokemon
            else
              sprite.refresh
            end
          end
        end
      end
    
      def pbRefreshSingle(i)
        sprite = @sprites["pokemon#{i}"]
        if sprite 
          if sprite.is_a?(PokemonPartyPanel)
            sprite.pokemon = sprite.pokemon
          else
            sprite.refresh
          end
        end
      end
    
      def update
        pbUpdateSpriteHash(@sprites)
      end
    end
    
    
    
    #===============================================================================
    # Pokémon party mechanics
    #===============================================================================
    class PokemonPartyScreen
      attr_reader :scene
      attr_reader :party
    
      def initialize(scene,party)
        @scene = scene
        @party = party
      end
    
      def pbStartScene(helptext,doublebattle,annotations=nil)
        @scene.pbStartScene(@party,helptext,annotations)
      end
    
      def pbChoosePokemon(helptext=nil)
        @scene.pbSetHelpText(helptext) if helptext
        return @scene.pbChoosePokemon
      end
    
      def pbPokemonGiveScreen(item)
        @scene.pbStartScene(@party,_INTL("Give to which Pokémon?"))
        pkmnid = @scene.pbChoosePokemon
        ret = false
        if pkmnid>=0
          ret = pbGiveItemToPokemon(item,@party[pkmnid],self,pkmnid)
        end
        pbRefreshSingle(pkmnid)
        @scene.pbEndScene
        return ret
      end
    
      def pbPokemonGiveMailScreen(mailIndex)
        @scene.pbStartScene(@party,_INTL("Give to which Pokémon?"))
        pkmnid = @scene.pbChoosePokemon
        if pkmnid>=0
          pkmn = @party[pkmnid]
          if pkmn.hasItem? || pkmn.mail
            pbDisplay(_INTL("This Pokémon is holding an item. It can't hold mail."))
          elsif pkmn.egg?
            pbDisplay(_INTL("Eggs can't hold mail."))
          else
            pbDisplay(_INTL("Mail was transferred from the Mailbox."))
            pkmn.mail = $PokemonGlobal.mailbox[mailIndex]
            pkmn.setItem(pkmn.mail.item)
            $PokemonGlobal.mailbox.delete_at(mailIndex)
            pbRefreshSingle(pkmnid)
          end
        end
        @scene.pbEndScene
      end
    
      def pbEndScene
        @scene.pbEndScene
      end
    
      def pbUpdate
        @scene.update
      end
    
      def pbHardRefresh
        @scene.pbHardRefresh
      end
    
      def pbRefresh
        @scene.pbRefresh
      end
    
      def pbRefreshSingle(i)
        @scene.pbRefreshSingle(i)
      end
    
      def pbDisplay(text)
        @scene.pbDisplay(text)
      end
    
      def pbConfirm(text)
        return @scene.pbDisplayConfirm(text)
      end
    
      def pbShowCommands(helptext,commands,index=0)
        @scene.pbShowCommands(helptext,commands,index)
      end
    
      # Checks for identical species
      def pbCheckSpecies(array)   # Unused
        for i in 0...array.length
          for j in i+1...array.length
            return false if array[i].species==array[j].species
          end
        end
        return true
      end
    
      # Checks for identical held items
      def pbCheckItems(array)   # Unused
        for i in 0...array.length
          next if !array[i].hasItem?
          for j in i+1...array.length
            return false if array[i].item==array[j].item
          end
        end
        return true
      end
    
      def pbSwitch(oldid,newid)
        if oldid!=newid
          @scene.pbSwitchBegin(oldid,newid)
          tmp = @party[oldid]
          @party[oldid] = @party[newid]
          @party[newid] = tmp
          @scene.pbSwitchEnd(oldid,newid)
        end
      end
    
      def pbChooseMove(pokemon,helptext,index=0)
        movenames = []
        for i in pokemon.moves
          break if i.id==0
          if i.totalpp==0
            movenames.push(_INTL("{1} (PP: ---)",PBMoves.getName(i.id),i.pp,i.totalpp))
          else
            movenames.push(_INTL("{1} (PP: {2}/{3})",PBMoves.getName(i.id),i.pp,i.totalpp))
          end
        end
        return @scene.pbShowCommands(helptext,movenames,index)
      end
    
      def pbRefreshAnnotations(ableProc)   # For after using an evolution stone
        annot = []
        for pkmn in @party
          elig = ableProc.call(pkmn)
          annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE"))
        end
        @scene.pbAnnotate(annot)
      end
    
      def pbClearAnnotations
        @scene.pbAnnotate(nil)
      end
    
      def pbPokemonMultipleEntryScreenEx(ruleset)
        annot = []
        statuses = []
        ordinals = [
           _INTL("INELIGIBLE"),
           _INTL("NOT ENTERED"),
           _INTL("BANNED"),
           _INTL("FIRST"),
           _INTL("SECOND"),
           _INTL("THIRD"),
           _INTL("FOURTH"),
           _INTL("FIFTH"),
           _INTL("SIXTH")
        ]
        return nil if !ruleset.hasValidTeam?(@party)
        ret = nil
        addedEntry = false
        for i in [email protected]
          statuses[i] = (ruleset.isPokemonValid?(@party[i])) ? 1 : 2
        end
        for i in [email protected]
          annot[i] = ordinals[statuses[i]]
        end
        @scene.pbStartScene(@party,_INTL("Choose Pokémon and confirm."),annot,true)
        loop do
          realorder = []
          for i in [email protected]
            for j in [email protected]
              if statuses[j]==i+3
                realorder.push(j)
                break
              end
            end
          end
          for i in 0...realorder.length
            statuses[realorder[i]] = i+3
          end
          for i in [email protected]
            annot[i] = ordinals[statuses[i]]
          end
          @scene.pbAnnotate(annot)
          if realorder.length==ruleset.number && addedEntry
            @scene.pbSelect(6)
          end
          @scene.pbSetHelpText(_INTL("Choose Pokémon and confirm."))
          pkmnid = @scene.pbChoosePokemon
          addedEntry = false
          if pkmnid==6 # Confirm was chosen
            ret = []
            for i in realorder; ret.push(@party[i]); end
            error = []
            break if ruleset.isValid?(ret,error)
            pbDisplay(error[0])
            ret = nil
          end
          break if pkmnid<0 # Canceled
          cmdEntry   = -1
          cmdNoEntry = -1
          cmdSummary = -1
          commands = []
          if (statuses[pkmnid] || 0) == 1
            commands[cmdEntry = commands.length]   = _INTL("Entry")
          elsif (statuses[pkmnid] || 0) > 2
            commands[cmdNoEntry = commands.length] = _INTL("No Entry")
          end
          pkmn = @party[pkmnid]
          commands[cmdSummary = commands.length]   = _INTL("Summary")
          commands[commands.length]                = _INTL("Cancel")
          command = @scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands) if pkmn
          if cmdEntry>=0 && command==cmdEntry
            if realorder.length>=ruleset.number && ruleset.number>0
              pbDisplay(_INTL("No more than {1} Pokémon may enter.",ruleset.number))
            else
              statuses[pkmnid] = realorder.length+3
              addedEntry = true
              pbRefreshSingle(pkmnid)
            end
          elsif cmdNoEntry>=0 && command==cmdNoEntry
            statuses[pkmnid] = 1
            pbRefreshSingle(pkmnid)
          elsif cmdSummary>=0 && command==cmdSummary
            @scene.pbSummary(pkmnid)
          end
        end
        @scene.pbEndScene
        return ret
      end
    
      def pbChooseAblePokemon(ableProc,allowIneligible=false)
        annot = []
        eligibility = []
        for pkmn in @party
          elig = ableProc.call(pkmn)
          eligibility.push(elig)
          annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE"))
        end
        ret = -1
        @scene.pbStartScene(@party,
           (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."),annot)
        loop do
          @scene.pbSetHelpText(
             (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
          pkmnid = @scene.pbChoosePokemon
          break if pkmnid<0
          if !eligibility[pkmnid] && !allowIneligible
            pbDisplay(_INTL("This Pokémon can't be chosen."))
          else
            ret = pkmnid
            break
          end
        end
        @scene.pbEndScene
        return ret
      end
    
      def pbChooseTradablePokemon(ableProc,allowIneligible=false)
        annot = []
        eligibility = []
        for pkmn in @party
          elig = ableProc.call(pkmn)
          elig = false if pkmn.egg? || (pkmn.isShadow? rescue false)
          eligibility.push(elig)
          annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE"))
        end
        ret = -1
        @scene.pbStartScene(@party,
           (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."),annot)
        loop do
          @scene.pbSetHelpText(
             (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
          pkmnid = @scene.pbChoosePokemon
          break if pkmnid<0
          if !eligibility[pkmnid] && !allowIneligible
            pbDisplay(_INTL("This Pokémon can't be chosen."))
          else
            ret = pkmnid
            break
          end
        end
        @scene.pbEndScene
        return ret
      end
    
      def pbPokemonScreen
        @scene.pbStartScene(@party,
           (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."),nil)
        loop do
          @scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
          pkmnid = @scene.pbChoosePokemon(false,-1,1)
          break if (pkmnid.is_a?(Numeric) && pkmnid<0) || (pkmnid.is_a?(Array) && pkmnid[1]<0)
          if pkmnid.is_a?(Array) && pkmnid[0]==1   # Switch
            @scene.pbSetHelpText(_INTL("Move to where?"))
            oldpkmnid = pkmnid[1]
            pkmnid = @scene.pbChoosePokemon(true,-1,2)
            if pkmnid>=0 && pkmnid!=oldpkmnid
              pbSwitch(oldpkmnid,pkmnid)
            end
            next
          end
          pkmn = @party[pkmnid]
          commands   = []
          cmdSummary = -1
          cmdDebug   = -1
          cmdMoves   = [-1,-1,-1,-1]
          cmdSwitch  = -1
          cmdMail    = -1
          cmdItem    = -1
          # Build the commands
          commands[cmdSummary = commands.length]      = _INTL("Summary")
          commands[cmdDebug = commands.length]        = _INTL("Debug") if $DEBUG
          for i in 0...pkmn.moves.length
            move = pkmn.moves[i]
            # Check for hidden moves and add any that were found
            if !pkmn.egg? && (isConst?(move.id,PBMoves,:MILKDRINK) ||
                              isConst?(move.id,PBMoves,:SOFTBOILED) ||
                              HiddenMoveHandlers.hasHandler(move.id))
              commands[cmdMoves[i] = commands.length] = [PBMoves.getName(move.id),1]
            end
          end
          commands[cmdSwitch = commands.length]       = _INTL("Switch") if @party.length>1
          if !pkmn.egg?
            if pkmn.mail
              commands[cmdMail = commands.length]     = _INTL("Mail")
            else
              commands[cmdItem = commands.length]     = _INTL("Item")
            end
          end
          commands[commands.length]                   = _INTL("Cancel")
          command = @scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands)
          havecommand = false
          for i in 0...4
            if cmdMoves[i]>=0 && command==cmdMoves[i]
              havecommand = true
              if isConst?(pkmn.moves[i].id,PBMoves,:SOFTBOILED) ||
                 isConst?(pkmn.moves[i].id,PBMoves,:MILKDRINK)
                amt = [(pkmn.totalhp/5).floor,1].max
                if pkmn.hp<=amt
                  pbDisplay(_INTL("Not enough HP..."))
                  break
                end
                @scene.pbSetHelpText(_INTL("Use on which Pokémon?"))
                oldpkmnid = pkmnid
                loop do
                  @scene.pbPreSelect(oldpkmnid)
                  pkmnid = @scene.pbChoosePokemon(true,pkmnid)
                  break if pkmnid<0
                  newpkmn = @party[pkmnid]
                  movename = PBMoves.getName(pkmn.moves[i].id)
                  if pkmnid==oldpkmnid
                    pbDisplay(_INTL("{1} can't use {2} on itself!",pkmn.name,movename))
                  elsif newpkmn.egg?
                    pbDisplay(_INTL("{1} can't be used on an Egg!",movename))
                  elsif newpkmn.hp==0 || newpkmn.hp==newpkmn.totalhp
                    pbDisplay(_INTL("{1} can't be used on that Pokémon.",movename))
                  else
                    pkmn.hp -= amt
                    hpgain = pbItemRestoreHP(newpkmn,amt)
                    @scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.",newpkmn.name,hpgain))
                    pbRefresh
                  end
                  break if pkmn.hp<=amt
                end
                @scene.pbSelect(oldpkmnid)
                pbRefresh
                break
              elsif Kernel.pbCanUseHiddenMove?(pkmn,pkmn.moves[i].id)
                if Kernel.pbConfirmUseHiddenMove(pkmn,pkmn.moves[i].id)
                  @scene.pbEndScene
                  if isConst?(pkmn.moves[i].id,PBMoves,:FLY)
                    scene = PokemonRegionMap_Scene.new(-1,false)
                    screen = PokemonRegionMapScreen.new(scene)
                    ret = screen.pbStartFlyScreen
                    if ret
                      $PokemonTemp.flydata=ret
                      return [pkmn,pkmn.moves[i].id]
                    end
                    @scene.pbStartScene(@party,
                       (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
                    break
                  end
                  return [pkmn,pkmn.moves[i].id]
                end
              else
                break
              end
            end
          end
          next if havecommand
          if cmdSummary>=0 && command==cmdSummary
            @scene.pbSummary(pkmnid)
          elsif cmdDebug>=0 && command==cmdDebug
            pbPokemonDebug(pkmn,pkmnid)
          elsif cmdSwitch>=0 && command==cmdSwitch
            @scene.pbSetHelpText(_INTL("Move to where?"))
            oldpkmnid = pkmnid
            pkmnid = @scene.pbChoosePokemon(true)
            if pkmnid>=0 && pkmnid!=oldpkmnid
              pbSwitch(oldpkmnid,pkmnid)
            end
          elsif cmdMail>=0 && command==cmdMail
            command = @scene.pbShowCommands(_INTL("Do what with the mail?"),
               [_INTL("Read"),_INTL("Take"),_INTL("Cancel")])
            case command
            when 0 # Read
              pbFadeOutIn(99999){ pbDisplayMail(pkmn.mail,pkmn) }
            when 1 # Take
              if pbTakeItemFromPokemon(pkmn,self)
                pbRefreshSingle(pkmnid)
              end
            end
          elsif cmdItem>=0 && command==cmdItem
            itemcommands = []
            cmdUseItem   = -1
            cmdGiveItem  = -1
            cmdTakeItem  = -1
            cmdMoveItem  = -1
            # Build the commands
            itemcommands[cmdUseItem=itemcommands.length]  = _INTL("Use")
            itemcommands[cmdGiveItem=itemcommands.length] = _INTL("Give")
            itemcommands[cmdTakeItem=itemcommands.length] = _INTL("Take") if pkmn.hasItem?
            itemcommands[cmdMoveItem=itemcommands.length] = _INTL("Move") if pkmn.hasItem? && !pbIsMail?(pkmn.item)
            itemcommands[itemcommands.length]             = _INTL("Cancel")
            command = @scene.pbShowCommands(_INTL("Do what with an item?"),itemcommands)
            if cmdUseItem>=0 && command==cmdUseItem   # Use
              item = @scene.pbUseItem($PokemonBag,pkmn)
              if item>0
                pbUseItemOnPokemon(item,pkmn,self)
                pbRefreshSingle(pkmnid)
              end
            elsif cmdGiveItem>=0 && command==cmdGiveItem   # Give
              item = @scene.pbChooseItem($PokemonBag)
              if item>0
                if pbGiveItemToPokemon(item,pkmn,self,pkmnid)
                  pbRefreshSingle(pkmnid)
                end
              end
            elsif cmdTakeItem>=0 && command==cmdTakeItem   # Take
              if pbTakeItemFromPokemon(pkmn,self)
                pbRefreshSingle(pkmnid)
              end
            elsif cmdMoveItem>=0 && command==cmdMoveItem   # Move
              item = pkmn.item
              itemname = PBItems.getName(item)
              @scene.pbSetHelpText(_INTL("Move {1} to where?",itemname))
              oldpkmnid = pkmnid
              loop do
                @scene.pbPreSelect(oldpkmnid)
                pkmnid = @scene.pbChoosePokemon(true,pkmnid)
                break if pkmnid<0
                newpkmn = @party[pkmnid]
                if pkmnid==oldpkmnid
                  break
                elsif newpkmn.egg?
                  pbDisplay(_INTL("Eggs can't hold items."))
                elsif !newpkmn.hasItem?
                  newpkmn.setItem(item)
                  pkmn.setItem(0)
                  @scene.pbClearSwitching
                  pbRefresh
                  pbDisplay(_INTL("{1} was given the {2} to hold.",newpkmn.name,itemname))
                  break
                elsif pbIsMail?(newpkmn.item)
                  pbDisplay(_INTL("{1}'s mail must be removed before giving it an item.",newpkmn.name))
                else
                  newitem = newpkmn.item
                  newitemname = PBItems.getName(newitem)
                  if isConst?(newitem,PBItems,:LEFTOVERS)
                    pbDisplay(_INTL("{1} is already holding some {2}.\1",newpkmn.name,newitemname))
                  elsif ['a','e','i','o','u'].include?(newitemname[0,1].downcase)
                    pbDisplay(_INTL("{1} is already holding an {2}.\1",newpkmn.name,newitemname))
                  else
                    pbDisplay(_INTL("{1} is already holding a {2}.\1",newpkmn.name,newitemname))
                  end
                  if pbConfirm(_INTL("Would you like to switch the two items?"))
                    newpkmn.setItem(item)
                    pkmn.setItem(newitem)
                    @scene.pbClearSwitching
                    pbRefresh
                    pbDisplay(_INTL("{1} was given the {2} to hold.",newpkmn.name,itemname))
                    pbDisplay(_INTL("{1} was given the {2} to hold.",pkmn.name,newitemname))
                    break
                  end
                end
              end
            end
          end
        end
        @scene.pbEndScene
        return nil
      end  
    end
    
    
    
    def pbPokemonScreen
      return if !$Trainer
      pbFadeOutIn(99999){
        sscene = PokemonParty_Scene.new
        sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
        sscreen.pbPokemonScreen
      }
    end
    Example, show the special heart but no Megas (0,0,12,) in debug items recognize Mega Stone.

    My project: mega.nz/#!Jc8xhC6B!xIRvCj1NuOgN3pqZ0tKInh6ZGrwrggWNOZCvrsg_d-E

    If sb wants to help, thanks!!!
     

    Attachments

    • dm3FXGl.png
      dm3FXGl.png
      37.1 KB · Views: 7
    Last edited:
    4
    Posts
    4
    Years
    • Seen Mar 29, 2020
    Inside item.txt, check if each mega stone haves number 12 into its code, the final number.
    '0,0,12,'
    Because 12, the script will recognizes like Mega Stone.

    Sorry, could you help me by looking at my project? If you can, please and thanks.
     
    Back
    Top