Seen 6 Hours Ago
Posted 3 Days Ago
230 posts
3.3 Years
so ages ago i brought up getting into shiney's old character customization (https://www.pokecommunity.com/showthread.php?t=418129) now it worked fine for me but even testing now, when trying to set customization on non-dev versions it has the wait time but doesnt change, when on mine it does....
basically when i press the c input (So enter, c space etc.) on the right menu it should work, but it doesnt.
heres the entire script page, i do encrypt my stuff so might be that? because i tested with the non-debug version while using the same dev files and it worked fine.
Spoiler:

#===============================================================================
# * Character Costumization made for Pokemon Essentials by shiney570
#   Version: 1.3.2
#===============================================================================

# Set to false to disable the Character Customization.
CHARACTER_CUSTOMIZATION                   = true
# Set to false to lock the Character Customization to unlock it manually at a
# point later in the game.
UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT = true
# whether to also fusion the base graphic or not. Remember:
USE_BASE_GRAPHIC                          = true

#Names of the headgears in order (true= unlocked by default, false=locked by default)
HEADGEAR_ITEMS=[
["None","None F",true], 
["Dad's Hat","Dad's Hat F",false]
]
# Names of the heads in order. (true= unlocked by default, false=locked by default)
HEAD_ITEMS=[
["Pale","Pale F",true],
["Tanned","Tanned F",true],
["Caramel","Caramel F",true],
["Hazelnut","Hazelnut F",true]
]

# Names of the upperbodies in order. (true= unlocked by default, false=locked by default)
UPPERBODY_ITEMS=[
["White Short","White Short F",true],
["Black Short","Black Short F",false],
["Blue Short","Blue Short F",false],
["Pink Short","Pink Short F",false],
["White Long","White Long F",true],
["Black Long","Black Long F",false],
["Blue Long","Blue Long F",false],
["Pink Long","Pink Long F",false],
["Urban Top","Urban Top F",false],
["Wild Top","Wild Top F",false],
["Night Hood","Night Hood F",false],
["Pack Jacket","Pack Jacket",false]
]
# Names of the lowerbodies in order. (true= unlocked by default, false=locked by default)
LOWERBODY_ITEMS=[
["Blue Jeans","Blue Jeans F",true],
["Black Jeans","Black Jeans F",false],
["Blue Shorts","Blue Shorts F",true],
["Yellow Shorts","Yellow Shorts F",false],
["Blue Shorts Stockings","Blue Shorts Stockings F",false],
["Yellow Shorts Stockings","Yellow Shorts F",false],
["Ripped Black Jeans","Ripped Black Jeans F",false],
["Ripped Red Jeans","Ripped Red Jeans F",false],
["Urban Jeans","Urban Jeans F",false],
["Wild Jeans","Wild Jeans F",false],
["Jagged Shorts","Jagged Shorts F",false],
["Torn Jeans","Torn Jeans F",false]
]
# Names of the shoes in order. (true= unlocked by default, false=locked by default)
SHOE_ITEMS=[
["White & Yellow","White & Yellow F",true],
["Black & Yellow","Black & Yellow F",false],
["White & Blue","White & Blue F",false],
["Black & Blue","Black & Blue F",false],
["White & Pink","White & Pink F",false],
["Black & Pink","Black & Pink F",false],
["Urban Shoes","Urban Shoes F",false],
["Wild Shoes","Wild Shoes F",false],
["Black Boots","Black Boots F",false],
["Old Trainers","Old Trainers F",false]
]
# Names of the accessoires in order. (true= unlocked by default, false=locked by default)
ACCESSOIRE_ITEMS=[
["Black & Blue Pack","Black & Blue Pack F",true],
["Black & Pink Pack","Black & Pink Pack F",false],
["White & Blue Pack","White & Blue Pack F",false],
["White & Pink Pack","White & Pink Pack F",false]
]
#Names of the headgears in order (true= unlocked by default, false=locked by default)
HAIR_ITEMS=[
["Brown","Brunette",true],
["Black","Black F",true],
["Blond","Blonde",true],
["Ginger","Ginger F",true],
["Blue","Blue F",false],
["Red","Red F",false],
["Pink","Pink F",false],
["Green","Green F",false],
["White","White F",false],
["Urban Dye","Urban Dye F",false],
["Wild Dye","Wild Dye F",false]
]

#===============================================================================
# * USEFUL METHODS
#===============================================================================
def pbTrainerNotDefined
  if !defined?($Trainer)
    if $DEBUG
      Kernel.pbMessage("The player is not a Trainer at this point. Implement the script into your game after you call the script pbTrainerName in your intro event.")
    end
    return true
  else 
    return false
  end
end



# This method updates the trainer outfit
def updateTrainerOutfit
  next_id=$Trainer.metaID==1 ? 0 : 1
  id=$Trainer.metaID
  pbChangePlayer(next_id)
  pbWait(1)
  pbChangePlayer(id)
end

# Gives the player randomized clothes (e.g good thing for randomizer challenges)
def randomizeOutfit
  return false if pbTrainerNotDefined
  $Trainer.headgear=rand(HEADGEAR_ITEMS.length)
  $Trainer.head=rand(HEAD_ITEMS.length)
  $Trainer.upperbody=rand(UPPERBODY_ITEMS.length)
  $Trainer.lowerbody=rand(LOWERBODY_ITEMS.length)
  $Trainer.shoe=rand(SHOE_ITEMS.length)
  $Trainer.accessoire=rand(ACCESSOIRE_ITEMS.length)
  $Trainer.hair=rand(HAIR_ITEMS.length)
  saveAllCustomizedBitmapsToFolder
  updateTrainerOutfit
end

# Method for changing a certain accessory.
def dressAccessory(accessory,convertation=true)
  return false if pbTrainerNotDefined
  return false if characterizationException
  return false if !accessory.is_a?(String)
  arr=retArrayAndNumber(accessory,false)
  return false if !arr
  bodypart=arr[0]; var=arr[1]
  if bodypart[0][1]==(false || true) # Checking if the array is multidimensional
    bodypart=cnvrtStrArr(bodypart)
  end
  for i in 0...bodypart.length
    if bodypart[i][$Trainer.gender]==accessory
      $Trainer.headgear=i if var==1
      $Trainer.head=i if var==2
      $Trainer.upperbody=i if var==3
      $Trainer.lowerbody=i if var==4
      $Trainer.shoe=i if var==5
      $Trainer.accessoire=i if var==6
      $Trainer.hair=i if var==7
      saveAllCustomizedBitmapsToFolder
      updateTrainerOutfit
      return
    end
  end
end

# Method for checking whether the player wears a certain Accessory.
def wearingAccessory?(accessory)
  return false if pbTrainerNotDefined
  return false if characterizationException
  arr=retArrayAndNumber(accessory)
  clothes=arr[0]; bodypart=arr[1]
  current=$Trainer.headgear if bodypart==1
  current=$Trainer.head if bodypart==2
  current=$Trainer.upperbody if bodypart==3
  current=$Trainer.lowerbody if bodypart==4
  current=$Trainer.shoe if bodypart==5
  current=$Trainer.accessoire if bodypart==6
  current=$Trainer.hair if bodypart==7
  return false if !(clothes || current)
  if accessory.is_a?(String)
    for i in 0...clothes.length
      if clothes[i]==accessory
        return (accessory==clothes[current])
      end
    end
  end
  return false
end

# Method for unlocking clothes.
def unlockAccessory(accessory)
  return false if pbTrainerNotDefined
  arr=retArrayAndNumber(accessory)
  bodypart=arr[1]-1
  for i in 0...arr[0].length
    index=i if arr[0][i]==accessory
  end
  (if $DEBUG; p "There was an issue unlocking the accessory."; end; return) if !index
  $Trainer.clothesUnlocking[bodypart][index]=true
end

# Method for locking clothes
def lockAccessory(accessory)
  return false if pbTrainerNotDefined
  arr=retArrayAndNumber(accessory)
  bodypart=arr[1]
  (current=$Trainer.headgear; name="Headgear") if bodypart==1
  (current=$Trainer.head; name="Head") if bodypart==2
  (current=$Trainer.upperbody; name="Upperbody") if bodypart==3
  (current=$Trainer.lowerbody; name="Lowerbody") if bodypart==4
  (current=$Trainer.shoe; name="Shoe")if bodypart==5
  (current=$Trainer.accessoire; name="Accessoire")if bodypart==6
  (current=$Trainer.hair; name="Hair") if bodypart==7
  # Checking if player wears the accessory to lock
  for i in 0...arr[0].length
    if arr[0][i]==accessory
      index=i
      #p i; p current
      if i==current
        Kernel.pbMessage("#{$Trainer.name} misses the #{accessory} #{name} and puts on the #{arr[0][0]} one instead.")
        $Trainer.headgear=0 if bodypart==1
        $Trainer.head=0 if bodypart==2
        $Trainer.upperbody=0 if bodypart==3
        $Trainer.lowerbody=0 if bodypart==4
        $Trainer.shoe=0 if bodypart==5
        $Trainer.accessoire=0 if bodypart==6
        $Trainer.hair=0 if bodypart==7
      end
    end
  end
  (if $DEBUG; p "There was an issue locking the accessory"; end; return) if !index
  $Trainer.clothesUnlocking[bodypart][index]=false
  saveAllCustomizedBitmapsToFolder
  updateTrainerOutfit
end


def retArrayAndNumber(accessory,convertation=true)
  (bodypart=HEADGEAR_ITEMS; var=1) if cnvrtStrArr(HEADGEAR_ITEMS).include?(accessory)
  (bodypart=HEAD_ITEMS; var=2) if cnvrtStrArr(HEAD_ITEMS).include?(accessory)
  (bodypart=UPPERBODY_ITEMS; var=3) if cnvrtStrArr(UPPERBODY_ITEMS).include?(accessory)
  (bodypart=LOWERBODY_ITEMS; var=4) if cnvrtStrArr(LOWERBODY_ITEMS).include?(accessory)
  (bodypart=SHOE_ITEMS; var=5) if cnvrtStrArr(SHOE_ITEMS).include?(accessory)
  (bodypart=ACCESSOIRE_ITEMS; var=6) if cnvrtStrArr(ACCESSOIRE_ITEMS).include?(accessory)
  (bodypart=HAIR_ITEMS; var=7) if cnvrtStrArr(HAIR_ITEMS).include?(accessory)
  return [cnvrtStrArr(bodypart),var] if convertation
  return [bodypart,var]
end

def characterizationException
  return true if CHARACTER_CUSTOMIZATION==false
  return true if UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT==false &&
                 $Trainer.character_customization==false
  return true if !$Trainer
  return true if !$Trainer.headgear
  return false
end

def cnvrtStrArr(array)
  ret=[]
  for i in 0...array.length
    ret.push(array[i][$Trainer.gender])
  end
  return ret
end

def cnvrtBoolArr(array)
  ret=[]
  for i in 0...array.length
    ret.push(array[i][2])
  end
  return ret
end

def retUnlockedAccessoryArray(clothes)
  arr=retArrayAndNumber(clothes[0])
  var=arr[1]
  ret=[]
  for i in 0...clothes.length
    ret.push clothes[i] if $Trainer.clothesUnlocking[var-1][i]==true
  end
  return ret
end
#===============================================================================
# * Initializing class PokeBattle_Trainer objects.
#===============================================================================
class PokeBattle_Trainer
  attr_accessor :character_customization 
  attr_accessor :headgear
  attr_accessor :head
  attr_accessor :upperbody
  attr_accessor :lowerbody
  attr_accessor :shoe
  attr_accessor :accessoire
  attr_accessor :hair
  attr_accessor :clothesUnlocking
  
  def character_customization
    if [email protected]_customization
      @character_customization=UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT
    end
    return @character_customization
  end
  
  def character_customization=(boolean)
    if boolean != true && boolean != false # Determining if object is a boolean
      if $DEBUG
        p "only $Trainer.character_customization = true/false is valid!"
      end
      return
    end
    @character_customization=boolean
  end
  
  def headgear
    if [email protected]
      @headgear=0
    end
    return @headgear
  end
  
  def headgear=(value)
    if value<0 || value>(HEADGEAR_ITEMS.length-1)
      if $DEBUG
        p "the value for $Trainer.headgear is out of range!"
      end
      return
    end
    @headgear=value
  end
  
  def head
    if [email protected]
      @head=0
    end
    return @head
  end
  
  def head=(value)
    if value<0 || value>(HEAD_ITEMS.length-1)
      if $DEBUG
        p "the value for $Trainer.head is out of range!"
      end
      return
    end
    @head=value
  end
  
  def upperbody
    if [email protected]
      @upperbody=0
    end
    return @upperbody
  end
  
  def upperbody=(value)
    if value<0 || value>(UPPERBODY_ITEMS.length-1)
      if $DEBUG
        p "the value for $Trainer.upperbody is out of range!"
      end
      return
    end
    @upperbody=value
  end
  
  def lowerbody
    if [email protected]
      @lowerbody=0
    end
    return @lowerbody
  end
  
  def lowerbody=(value)
    if value<0 || value>(LOWERBODY_ITEMS.length-1)
      if $DEBUG
        p "the value for $Trainer.lowerbody is out of range!"
      end
      return
    end
    @lowerbody=value
  end
  
  def shoe
    if [email protected]
      @shoe=0
    end
    return @shoe
  end
  
  def shoe=(value)
    if value<0 || value>(SHOE_ITEMS.length-1)
      if $DEBUG
        p "the value for $Trainer.shoe is out of range!"
      end
      return
    end
    @shoe=value
  end
  
  def accessoire
    if [email protected]
      @accessoire=0
    end
    return @accessoire
  end
  
  def accessoire=(value)
    if value<0 || value>(ACCESSOIRE_ITEMS.length-1)
      if $DEBUG
        p "the value for $Trainer.accessoire is out of range!"
      end
      return
    end
    @accessoire=value
  end
  
  def hair
    if [email protected]
      @hair=0
    end
    return @hair
  end
  
  def hair=(value)
    if value<0 || value>(HAIR_ITEMS.length-1)
      if $DEBUG
        p "the value for $Trainer.hair is out of range!"
      end
      return
    end
    @hair=value
  end
  
  def clothesUnlocking
    if [email protected]
      @clothesUnlocking=[]
      @clothesUnlocking.push cnvrtBoolArr(HEADGEAR_ITEMS)
      @clothesUnlocking.push cnvrtBoolArr(HEAD_ITEMS)
      @clothesUnlocking.push cnvrtBoolArr(UPPERBODY_ITEMS)
      @clothesUnlocking.push cnvrtBoolArr(LOWERBODY_ITEMS)
      @clothesUnlocking.push cnvrtBoolArr(SHOE_ITEMS)
      @clothesUnlocking.push cnvrtBoolArr(ACCESSOIRE_ITEMS)
      @clothesUnlocking.push cnvrtBoolArr(HAIR_ITEMS)
    end
    return @clothesUnlocking
  end
  
end

#===============================================================================
# * Drawing the customized Bitmap
#===============================================================================
def drawCharacterCustomizedBitmap(filepath,bmp,trainerClass=$Trainer)
  return nil if !filepath.is_a?(String)
  return bitmap if !trainerClass
  return bitmap if CHARACTER_CUSTOMIZATION==false 
  return bitmap if UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT==false &&
                   trainerClass.character_customization==false
  # Adding Head Bitmap
  addAdditionalBitmap(filepath+"_head"+(trainerClass.head).to_s+".png",bmp)
  # Adding Shoe Bitmap
  addAdditionalBitmap(filepath+"_shoe"+(trainerClass.shoe).to_s+".png",bmp)
  # Adding Lowerbody Bitmap
  addAdditionalBitmap(filepath+"_lowerbody"+(trainerClass.lowerbody).to_s+".png",bmp)
  # Adding Upperbody Bitmap
  addAdditionalBitmap(filepath+"_upperbody"+(trainerClass.upperbody).to_s+".png",bmp)
  # Adding Hair Bitmap
  addAdditionalBitmap(filepath+"_hair"+(trainerClass.hair).to_s+".png",bmp)
  # Adding Headgear Bitmap
  addAdditionalBitmap(filepath+"_headgear"+(trainerClass.headgear).to_s+".png",bmp)
  # Adding Accessoire Bitmap
  addAdditionalBitmap(filepath+"_accessoire"+(trainerClass.accessoire).to_s+".png",bmp)
end

def saveAllCustomizedBitmapsToFolder
  return if !$Trainer
  # Trainer charsets
  metadata=pbLoadMetadata
  filenames=metadata[0][8+$Trainer.gender]
  for i in 0...filenames.length
    if filenames[i].is_a?(String)
      filepath="Graphics/Characters/#{filenames[i]}"
      saveCustomizedBitmapToFolder(filepath)
    end
  end
  # Trainer backsprite
  saveCustomizedBitmapToFolder("Graphics/Characters/trback00#{$Trainer.gender}")
  # Intro Image/Trainercard Image
  filepath="Graphics/Pictures/"
  filepath+= $Trainer.isFemale? ? "introGirl" : "introBoy"
  saveCustomizedBitmapToFolder(filepath)
  # Map Player
  saveCustomizedBitmapToFolder("Graphics/Pictures/mapPlayer00#{$Trainer.gender}")
end

# saves the costumized bitmaps to the actual game folders.
def saveCustomizedBitmapToFolder(filepath)
  return if !$Trainer
  return if !filepath.is_a?(String)
  bmp=Bitmap.new(filepath)
  # Safety Copy
  if !File.exists?(filepath+"_safetyCopy"+".png") && $DEBUG
    safetyCopy=Bitmap.new(filepath)
    safetyCopy.saveToPng(filepath+"_safetyCopy"+".png")
  end
  # Deleting old file
  if !USE_BASE_GRAPHIC
    bmp.clear
  end
  drawCharacterCustomizedBitmap(filepath,bmp)
  bmp.saveToPng(filepath+".png")
end

# Method for add additional bitmaps to a bitmap.
def addAdditionalBitmap(filepath,formerBitmap)
  if File.exists?(filepath)
     formerBitmap.blt(0,0,Bitmap.new(filepath),Rect.new(0,0,Graphics.width,Graphics.height))
  end
end
#===============================================================================
# * Character Customization Scene
#===============================================================================
class CharacterCustomizationScene
  
  def initialize
    # Checks if the Script is functional.
    if !defined?($Trainer.clothesUnlocking)
      Kernel.pbMessage("Your game is missing some Variables of the Character Costumization Script. In order to fix this you'll need to save the game.")
      if Kernel.pbConfirmMessage("Would you like to save the game now?")
        if !$Trainer
          Kernel.pbMessage("Unable to save the game since the player is not a trainer at this point. Do not use the CharacterCustomization Script before you call the script pbTrainerName in your intro event.")
        else
          pbSave
          Kernel.pbMessage("The game was saved, try again now.")
        end
      end
      return
    end
    return if !addNecessaryFiles
    @index=0
    @index2=0
    @new_val=2
    @firstSelection=true
    @sprites={}
    @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z=99999
    @sprites["window"]=SpriteWindow_Base.new(Graphics.width/2-64,Graphics.height/2-128,128,128)
    @sprites["window2"]=SpriteWindow_Base.new(Graphics.width/2-64,Graphics.height/2,128,128)
    @sprites["window2"].visible=false
    @sprites["player"]=TrainerWalkingCharSprite.new($game_player.character_name,@viewport)
    @sprites["player"].x=Graphics.width/[email protected]["player"].bitmap.width/8
    @sprites["player"].y=Graphics.height/[email protected]["player"].bitmap.height/8 -64
    @sprites["player"].z=9999999
    @sprites["playerAccessory"]=TrainerWalkingCharSprite.new($game_player.character_name+"_headgear0",@viewport)
    @sprites["playerAccessory"].x=Graphics.width/[email protected]["playerAccessory"].bitmap.width/8
    @sprites["playerAccessory"].y=Graphics.height/[email protected]["playerAccessory"].bitmap.height/8 +64
    @sprites["playerAccessory"].z=9999999
    @sprites["playerAccessory"][email protected]["playerAccessory"].bitmap.width/16
    @sprites["playerAccessory"][email protected]["playerAccessory"].bitmap.height/16    
    @sprites["playerAccessory"].zoom_x=2
    @sprites["playerAccessory"].zoom_y=2
    @sprites["playerAccessory"].visible=false
    @[email protected]["playerAccessory"]
    [email protected]["player"].bitmap.height
    @y=[charheight/4*2,0,charheight/4,charheight/4*3]
    @sprites["heading1"]=Window_CommandPokemonEx.new(["BODYPART"])
    @sprites["heading1"][email protected]
    @sprites["heading1"].index=1    
    @sprites["heading2"]=Window_CommandPokemonEx.new(["HEADGEAR"])
    @sprites["heading2"][email protected]
    @sprites["heading2"].index=1
    @sprites["heading2"][email protected]["heading2"].width
    @commands=CommandList.new
    @commands.add("headgear",_INTL("Headgear"))
    @commands.add("head",_INTL("Head"))
    @commands.add("upperbody",_INTL("Upperbody"))
    @commands.add("lowerbody",_INTL("Lowerbody"))
    @commands.add("shoes",_INTL("Shoes"))
    @commands.add("accessoire",_INTL("Accessoire"))
    @commands.add("hair",_INTL("Hair"))
    @sprites["cmdwindow"]=Window_CommandPokemonEx.new(@commands.list)
    @sprites["cmdwindow"][email protected]
    @sprites["cmdwindow"][email protected]["heading1"].height
    @sprites["cmdwindow2"]=Window_CommandPokemonEx.new(retListCmdBox2)
    @sprites["cmdwindow2"][email protected]
    @sprites["cmdwindow2"][email protected]["heading2"].height
    @sprites["cmdwindow2"][email protected]["cmdwindow2"].width
    @sprites["cmdwindow2"].z-=1
    @sprites["cmdwindow2"].index=-1
    @[email protected]["cmdwindow2"]
    @accessoryNames=["headgear","head","upperbody","lowerbody","shoe","accessoire","hair"]
    update
  end
  
  # Method for adding necessary missing graphic files.
  def addNecessaryFiles
    files=[]
    # Pushing all files that could possibly be missing into the files array.
    HEADGEAR_ITEMS.length.times{|i| files.push("_headgear#{i}")}
    HEAD_ITEMS.length.times{|i| files.push("_head#{i}")}  
    UPPERBODY_ITEMS.length.times{|i| files.push("_upperbody#{i}")}  
    LOWERBODY_ITEMS.length.times{|i| files.push("_lowerbody#{i}")}
    SHOE_ITEMS.length.times{|i| files.push("_shoe#{i}")} 
    ACCESSOIRE_ITEMS.length.times{|i| files.push("_accessoire#{i}")}  
    HAIR_ITEMS.length.times{|i| files.push("_hair#{i}")}  
    # Creating a blank bitmap
    size_check=Bitmap.new("Graphics/Characters/#{$game_player.character_name}")
    blank_bitmap=Bitmap.new(size_check.width,size_check.height)
    files_to_add=[]
    # Pushing non existent files into the files_to_add array.
    for i in 0...files.length
      if !File.exists?("Graphics/Characters/#{$game_player.character_name}#{files[i]}"+".png")
        files_to_add.push("Graphics/Characters/#{$game_player.character_name}#{files[i]}"+".png")
      end
    end
    if !files_to_add.empty?
      Kernel.pbMessage("The game is missing one or more graphic files for the Character Customization.")
      ret=Kernel.pbConfirmMessage("Would you like to add these files as blank placeholder sprites in order to let this Script work properly?")
      if ret
        files_to_add.length.times {|i| blank_bitmap.saveToPng(files_to_add[i])} 
        Kernel.pbMessage("The missing files were added to the Graphics/Characters/ folder. The script will continue working as supposed now.")
      else
        Kernel.pbMessage("The script stopped running until these neccessary files were added:")
        files_to_add.length.times{|i| Kernel.pbMessage(files_to_add[i])}
      end
      return ret
    end
    return true
  end
  
  # returns the index of the Accessory in the actual list.
  def getAccessoryIndex
    [email protected][@cmdwindow2.index]
    arr=HEADGEAR_ITEMS if @accessoryNames[@index]=="headgear"
    arr=HEAD_ITEMS if @accessoryNames[@index]=="head"
    arr=UPPERBODY_ITEMS if @accessoryNames[@index]=="upperbody"
    arr=LOWERBODY_ITEMS if @accessoryNames[@index]=="lowerbody"
    arr=SHOE_ITEMS if @accessoryNames[@index]=="shoe"
    arr=ACCESSOIRE_ITEMS if @accessoryNames[@index]=="accessoire"
    arr=HAIR_ITEMS if @accessoryNames[@index]=="hair"
    arr=cnvrtStrArr(arr)
    for i in 0...arr.length
      return i if arr[i]==item
    end
  end
  
  # updates the Accessory bitmap
  def updateAccessoryBitmap 
    @sprites["playerAccessory"].bitmap.clear
    name=$game_player.character_name+"_"[email protected][@index]+(getAccessoryIndex).to_s
    if File.exists?("Graphics/Characters/"+name+".png") && @index2 != @cmdwindow2.itemCount
      @sprites["playerAccessory"].charset=name
    end
  end
  
  # returns the list of the right hand command box.
  def retListCmdBox2
    @list=HEADGEAR_ITEMS if @index==0
    @list=HEAD_ITEMS if @index==1
    @list=UPPERBODY_ITEMS if @index==2
    @list=LOWERBODY_ITEMS if @index==3
    @list=SHOE_ITEMS if @index==4
    @list=ACCESSOIRE_ITEMS if @index==5
    @list=HAIR_ITEMS if @index==6
    @list=retUnlockedAccessoryArray(cnvrtStrArr(@list))
    @list=["---NONE---"] if [email protected]
    @list.push("Back") if [email protected]?("Back")
    return @list
  end
  
  # this updates the heading. since there is no command for updating 
  # command boxes it'll always create a new fresh command box sprite.
  def updateHeading2
    @sprites["heading#{@new_val}"].dispose
    @sprites["cmdwindow#{@new_val}"].dispose
    @new_val+=1
    @sprites["heading#{@new_val}"]=Window_CommandPokemonEx.new([@commands.list[@index].upcase])
    @sprites["heading#{@new_val}"][email protected]
    @sprites["heading#{@new_val}"].index=1
    @sprites["heading#{@new_val}"][email protected]["heading#{@new_val}"].width
    @sprites["heading#{@new_val}"].z-=1
    @sprites["cmdwindow#{@new_val}"]=Window_CommandPokemonEx.new(retListCmdBox2)
    @c[email protected]["cmdwindow#{@new_val}"]
    @[email protected]
    @[email protected]["heading#{@new_val}"].height
    @[email protected]["cmdwindow#{@new_val}"].width
    @cmdwindow2.index= -1
  end
  
  # checks whether the index of the left command box has changed or not.
  def indexChanged
    if @index2 != @index
      @[email protected]
      return true
    end
    return false
  end
  
  # checks whether the index or the right command box has changed or not.
  def cmdWindow2IndexChanged
    if [email protected]
      @[email protected]
      return false
    elsif @cmdWindow2Index != @cmdwindow2.index
      @[email protected]
      return true
    end
    return false
  end
  
  # updates the scene.
  def update
    frame=0
    @dir=0
    loop do
      frame+=1
      pos=0
      Graphics.update
      Input.update
      @sprites["player"].update
      @sprites["playerAccessory"].update
      if @firstSelection
        @sprites["cmdwindow"].update
        @[email protected]["cmdwindow"].index
      else
        @cmdwindow2.update
      end
      if indexChanged
        updateHeading2
      end
      if cmdWindow2IndexChanged && @cmdwindow2.index != -1
        updateAccessoryBitmap #if @cmdwindow2.index != @cmdwindow2.
      end      
      if Input.trigger?(Input::C)
        # Pressing C on the left command box.
        if @firstSelection
          @cmdwindow2.index=0
          @firstSelection=false
          @sprites["window2"].visible=true
          @sprites["playerAccessory"].visible=true
        else
        # Pressing C on the right command box.
          if @cmdwindow2.index==(@cmdwindow2.itemCount-1) # Cancel
            @cmdwindow2.index=-1; @cmdwindow2.update
            @firstSelection=true
            @sprites["window2"].visible=false
            @sprites["playerAccessory"].visible=false
          else
            changeClothes
            @sprites["player"].bitmap.clear
            @sprites["player"].charset=$game_player.character_name
          end
        end
      end

      if Input.trigger?(Input::B)
        # cancels the scene.
        if @firstSelection && Kernel.pbConfirmMessage("Have you finished?")
          updateTrainerOutfit
          pbDisposeSpriteHash(@sprites)
          break
        # goes back to the left command box.
        elsif [email protected]
          @cmdwindow2.index=-1; @cmdwindow2.update
          @firstSelection=true
          @sprites["window2"].visible=false
          @sprites["playerAccessory"].visible=false
        end
      end
      # updates the walking sprite.
      if frame%120==0
        @dir+=1
        @sprites["player"][email protected][@dir%4]
        @sprites["playerAccessory"][email protected]["player"].src_rect.y
      end      
    end
  end
  
  # updates the outfit as well as the variables which are responsable for it.
  def changeClothes
    dressAccessory(@list[@cmdwindow2.index],false)
    case @sprites["cmdwindow"].index
    when 0
      $Trainer.headgear=getAccessoryIndex
    when 1
      $Trainer.head=getAccessoryIndex
    when 2
      $Trainer.upperbody=getAccessoryIndex
    when 3
      $Trainer.lowerbody=getAccessoryIndex
    when 4
      $Trainer.shoe=getAccessoryIndex
    when 5
      $Trainer.accessoire=getAccessoryIndex
    when 6
      $Trainer.hair=getAccessoryIndex
    end
  end
  
end
#===============================================================================
# * Edit to the class Game_Player to erase the .png extension in the name.
#===============================================================================
class Game_Player
  def character_name
    if [email protected]
      @defaultCharacterName=""
    end
    if @defaultCharacterName!=""
      return @defaultCharacterName.gsub(/\0/,"v")#(/\.png/,"")
    end
    if !moving? && [email protected]_route_forcing && $PokemonGlobal
      meta=pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID)
      if $PokemonGlobal.playerID>=0 && meta && 
         !$PokemonGlobal.bicycle && !$PokemonGlobal.diving && !$PokemonGlobal.surfing
        if meta[4] && meta[4]!="" && Input.dir4!=0 && passable?(@x,@y,Input.dir4) && pbCanRun?
          # Display running character sprite
          @character_name=pbGetPlayerCharset(meta,4)
        else
          # Display normal character sprite 
          @character_name=pbGetPlayerCharset(meta,1)
        end
      end
    end
    return @character_name.gsub(/\.png/,"")
  end
end


so edit: it does fix if i dont encrypt it but that is something i'd prefer to avoid, if i can.
Seen 1 Day Ago
Posted 4 Days Ago
1 posts
4 Days
I'll admit I don't have the best knowledge of coding in Ruby or encryption. But just from running shiney570's original code, I think the problem is that whenever the character tries to change their outfit, the code basically replaces the "tchar00*" sprite in the "Graphics/Characters/" folder with an entirely new image. The code might not be able to create an new image in that folder if it's encrypted, although again I'm not 100% sure.
Male
Seen 8 Hours Ago
Posted 1 Day Ago
68 posts
1.5 Years
I don't know if this would be causing the issue or not, but based on the Ruby docs for the File class (https://ruby-doc.org/core-2.5.0/File.html#method-c-exists-3F), the method "File.exists?" should no longer be used to check if a file exists. I'd recommend replacing any instance of
File.exists?(filename)
in your script with the following Essentials function:
safeExists?(filename)