Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # * 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 = false
- #Names of the headgears in order (true= unlocked by default, false=locked by default)
- HEADGEAR_ITEMS=[
- ["Gorra","Gorra F",true],
- ["Gorra Playera","Gorra Playera F",true],
- ["Gorro Invierno","Gorro Invierno F",true],
- ["Gorro Pikachu","Gorro Pikachu F",false],
- ["Gorro Eevee","Gorro Eevee F",false]
- ]
- # Names of the heads in order. (true= unlocked by default, false=locked by default)
- HEAD_ITEMS=[
- ["O. Normales","O. Normales F",true],
- ["Brock","Brock F",true],
- ["Chibi","Chibi F",true],
- ["Saltones","Saltones F",false]
- ]
- # Names of the upperbodies in order. (true= unlocked by default, false=locked by default)
- UPPERBODY_ITEMS=[
- ["R. Normal","R. Normal F",true],
- ["Veraniega","Veraniega F",true],
- ["Sudadera","Sudadera F",true],
- ["Estilo Red","Estilo Hoja",false]
- ]
- # Names of the lowerbodies in order. (true= unlocked by default, false=locked by default)
- LOWERBODY_ITEMS=[
- ["P. Normales","P. Normales F",true],
- ["Cortos","Cortos F",true],
- ["Invierno","Invierno F",true],
- ["Pink","Pink F",false]
- ]
- # Names of the shoes in order. (true= unlocked by default, false=locked by default)
- SHOE_ITEMS=[
- ["Blue & Red","Blue & Red F",true],
- ["Purple & Orange","Purple & Orange F",true],
- ["Red, Pink & Green","Red, Pink & Green F",true]
- ]
- # Names of the accessoires in order. (true= unlocked by default, false=locked by default)
- ACCESSOIRE_ITEMS=[
- ["Green Backpack","Green Backpack F",true],
- ["Blue Backpack","Blue Backpack F",true],
- ["Red Backpack","Red Backpack F",true]
- ]
- COLOR_ITEMS=[
- ["Normal","Normal F",true],
- ["Rojo","Rojo F",true],
- ["Azul","Azul F",true],
- ["Amarillo","Amarillo F",true]
- ]
- #===============================================================================
- # * 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)
- saveAllCustomizedBitmapsToFolder
- updateTrainerOutfit
- end
- # Method for changing a certain accessory.
- def dressAccessory(accessory,color=0,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
- if !$game_switches[200]
- lastheadgear=0
- lasthead=0
- lastupper=0
- lastlower=0
- lastshoe=0
- lastacc=0
- $game_switches[200]=true
- end
- for i in 0...bodypart.length
- if bodypart[i][$Trainer.gender]==accessory
- case var
- when 1
- $Trainer.headgear=i
- @colorheadgear = color
- lastheadgear = color
- @colorhead = lasthead
- @colorupperbody = lastupper
- @colorlowerbody = lastlower
- @colorshoes = lastshoe
- @coloraccesoire = lastacc
- when 2
- $Trainer.head=i
- @colorhead = color
- lasthead = color
- @colorheadgear = lastheadgear
- @colorupperbody = lastupper
- @colorlowerbody = lastlower
- @colorshoes = lastshoe
- @coloraccesoire = lastacc
- when 3
- $Trainer.upperbody=i
- @colorupperbody = color
- lastupper = color
- @colorheadgear = lastheadgear
- @colorhead = lasthead
- @colorlowerbody = lastlower
- @colorshoes = lastshoe
- @coloraccesoire = lastacc
- when 4
- $Trainer.lowerbody=i
- @colorlowerbody = color
- lastlower = color
- @colorheadgear = lastheadgear
- @colorhead = lasthead
- @colorupperbody = lastupper
- @colorshoes = lastshoe
- @coloraccesoire = lastacc
- when 5
- $Trainer.shoe=i
- @colorshoes = color
- lastshoe = color
- @colorheadgear = lastheadgear
- @colorhead = lasthead
- @colorupperbody = lastupper
- @colorlowerbody = lastlower
- @coloraccesoire = lastacc
- when 6
- $Trainer.accessoire=i
- @coloraccesoire = color
- lastacc = color
- @colorheadgear = lastheadgear
- @colorhead = lasthead
- @colorupperbody = lastupper
- @colorlowerbody = lastlower
- @colorshoes = lastshoe
- end
- 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 @accessoryNames[@index]=="headgear"
- current=$Trainer.head if @accessoryNames[@index]=="head"
- current=$Trainer.upperbody if @accessoryNames[@index]=="upperbody"
- current=$Trainer.lowerbody if @accessoryNames[@index]=="lowerbody"
- current=$Trainer.shoe if @accessoryNames[@index]=="shoe"
- current=$Trainer.accessoire if @accessoryNames[@index]=="accessoire"
- 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
- # 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
- 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)
- 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 :colorheadgear
- attr_accessor :colorhead
- attr_accessor :colorupperbody
- attr_accessor :colorlowerbody
- attr_accessor :colorshoes
- attr_accessor :coloraccesoire
- attr_accessor :clothesUnlocking
- def character_customization
- if !@character_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 !@headgear
- @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 !@head
- @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 !@upperbody
- @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 !@lowerbody
- @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 !@shoe
- @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 !@accessoire
- @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 colorheadgear=(value)
- if value==-1
- if $DEBUG
- p "the value for $Trainer.@colorcl is out of range!"
- end
- return
- end
- @colorheadgear=value
- end
- def colorhead=(value)
- if value==-1
- if $DEBUG
- p "the value for $Trainer.@colorcl is out of range!"
- end
- return
- end
- @colorhead=value
- end
- def colorupperbody=(value)
- if value==-1
- if $DEBUG
- p "the value for $Trainer.@colorcl is out of range!"
- end
- return
- end
- @colorupperbody=value
- end
- def colorlowerbody=(value)
- if value==-1
- if $DEBUG
- p "the value for $Trainer.@colorcl is out of range!"
- end
- return
- end
- @colorlowerbody=value
- end
- def colorshoes=(value)
- if value==-1
- if $DEBUG
- p "the value for $Trainer.@colorcl is out of range!"
- end
- return
- end
- @colorshoes=value
- end
- def colorcoloraccesoire=(value)
- if value==-1
- if $DEBUG
- p "the value for $Trainer.@colorcl is out of range!"
- end
- return
- end
- @colorcoloraccesoire=value
- end
- def clothesUnlocking
- if !@clothesUnlocking
- @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)
- 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
- addAdditionalBitmap(filepath+"_shoe"+(trainerClass.shoe).to_s+".png",bmp) if @colorshoes ==0
- addAdditionalBitmap(filepath+"_lowerbody"+(trainerClass.lowerbody).to_s+".png",bmp) if @colorlowerbody ==0
- addAdditionalBitmap(filepath+"_upperbody"+(trainerClass.upperbody).to_s+".png",bmp) if @colorupperbody ==0
- addAdditionalBitmap(filepath+"_head"+(trainerClass.head).to_s+".png",bmp) if @colorhead ==0
- addAdditionalBitmap(filepath+"_headgear"+(trainerClass.headgear).to_s+".png",bmp) if @colorheadgear ==0
- addAdditionalBitmap(filepath+"_accessoire"+(trainerClass.accessoire).to_s+".png",bmp) if @coloraccesoire ==0
- addAdditionalBitmap(filepath+"_shoe"+(trainerClass.shoe).to_s+(@colorshoes).to_s+".png",bmp) if @colorshoes !=0
- addAdditionalBitmap(filepath+"_lowerbody"+(trainerClass.lowerbody).to_s+"-"+(@colorlowerbody).to_s+".png",bmp) if @colorlowerbody !=0
- addAdditionalBitmap(filepath+"_upperbody"+(trainerClass.upperbody).to_s+"-"+(@colorupperbody).to_s+".png",bmp) if @colorupperbody !=0
- addAdditionalBitmap(filepath+"_head"+(trainerClass.head).to_s+"-"+(@colorhead).to_s+".png",bmp) if @colorhead !=0
- addAdditionalBitmap(filepath+"_headgear"+(trainerClass.headgear).to_s+"-"+(@colorheadgear).to_s+".png",bmp) if @colorheadgear !=0
- addAdditionalBitmap(filepath+"_accessoire"+(trainerClass.accessoire).to_s+"-"+(@coloraccesoire).to_s+".png",bmp) if @coloraccesoire !=0
- 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/trchar00#{$Trainer.gender}"
- 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
- @secondSelection=false
- @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["window3"]=SpriteWindow_Base.new(128,256,128,128)
- @sprites["window3"].visible=false
- @sprites["player"]=TrainerWalkingCharSprite.new($game_player.character_name,@viewport)
- @sprites["player"].x=Graphics.width/2-@sprites["player"].bitmap.width/8
- @sprites["player"].y=Graphics.height/2-@sprites["player"].bitmap.height/8 -64
- @sprites["player"].z=9999999
- @sprites["playerAccessory"]=TrainerWalkingCharSprite.new($game_player.character_name+"_headgear0",@viewport)
- @sprites["playerAccessory"].x=Graphics.width/2-@sprites["playerAccessory"].bitmap.width/8
- @sprites["playerAccessory"].y=Graphics.height/2-@sprites["playerAccessory"].bitmap.height/8 +64
- @sprites["playerAccessory"].z=9999999
- @sprites["playerAccessory"].ox+=@sprites["playerAccessory"].bitmap.width/16
- @sprites["playerAccessory"].oy+=@sprites["playerAccessory"].bitmap.height/16
- @sprites["playerAccessory"].zoom_x=2
- @sprites["playerAccessory"].zoom_y=2
- @sprites["playerAccessory"].visible=false
- @playerAccessory=@sprites["playerAccessory"]
- charheight=@sprites["player"].bitmap.height
- @y=[charheight/4*2,0,charheight/4,charheight/4*3]
- @sprites["heading1"]=Window_CommandPokemonEx.new(["BODYPART"])
- @sprites["heading1"].viewport=@viewport
- @sprites["heading1"].index=1
- @sprites["heading2"]=Window_CommandPokemonEx.new(["HEADGEAR"])
- @sprites["heading2"].viewport=@viewport
- @sprites["heading2"].index=1
- @sprites["heading2"].x=Graphics.width-@sprites["heading2"].width
- @sprites["heading3"]=Window_CommandPokemonEx.new(["COLOR"])
- @sprites["heading3"].viewport=@viewport
- @sprites["heading3"].index=1
- @sprites["heading3"].x=Graphics.width/2-(@sprites["heading3"].width*2)
- @commands = []
- @currentList = "main"
- lista = @currentList
- @commands=CommandMenuList.new
- @commands.add("main","headgear",_INTL("Headgear"))
- @commands.add("main","head",_INTL("Head"))
- @commands.add("main","upperbody",_INTL("Upperbody"))
- @commands.add("main","lowerbody",_INTL("Lowerbody"))
- @commands.add("main","accessoire",_INTL("Accessoire"))
- @commands.add("main","shoes",_INTL("Shoes"))
- @commands2 = []
- @currentList = "main"
- @commands2=CommandMenuList.new
- @commands2.add("main","normal",_INTL("Color 1"))
- @commands2.add("main","azul",_INTL("Color 2"))
- @commands2.add("main","rojo",_INTL("Color 3"))
- @sprites["cmdwindow"]=Window_CommandPokemonEx.new(@commands.list)
- @sprites["cmdwindow"].viewport=@viewport
- @sprites["cmdwindow"].y=@sprites["heading1"].height
- @sprites["cmdwindow2"]=Window_CommandPokemonEx.new(retListCmdBox2)
- @sprites["cmdwindow2"].viewport=@viewport
- @sprites["cmdwindow2"].y=@sprites["heading2"].height
- @sprites["cmdwindow2"].x=Graphics.width-@sprites["cmdwindow2"].width
- @sprites["cmdwindow2"].z-=1
- @sprites["cmdwindow2"].index=-1
- @sprites["cmdwindow3"]=Window_CommandPokemonEx.new(@commands2.list)
- @sprites["cmdwindow3"].viewport=@viewport
- @sprites["cmdwindow3"].y=256
- @sprites["cmdwindow3"].x=128
- @sprites["cmdwindow3"].z=99999
- @sprites["cmdwindow3"].index=-1
- @cmdwindow2=@sprites["cmdwindow2"]
- @cmdwindow3=@sprites["cmdwindow3"]
- @accessoryNames=["headgear","head","upperbody","lowerbody","shoe","accessoire"]
- @colorNames=["normal","azul","rojo"]
- 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}")}
- # 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
- item=@list[@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=cnvrtStrArr(arr)
- for i in 0...arr.length
- return i if arr[i]==item
- end
- end
- def getColorIndex
- item=@list[@cmdwindow3.index]
- ropa=@accessoryNames[@index]
- @colorheadgear=0 if @colorNames[@index]=="normal"
- @colorheadgear=1 if @colorNames[@index]=="azul"
- @colorheadgear=2 if @colorNames[@index]=="rojo"
- @colorhead=0 if @colorNames[@index]=="normal"
- @colorhead=1 if @colorNames[@index]=="azul"
- @colorhead=2 if @colorNames[@index]=="rojo"
- @colorupperbody=0 if @colorNames[@index]=="normal"
- @colorupperbody=1 if @colorNames[@index]=="azul"
- @colorupperbody=2 if @colorNames[@index]=="rojo"
- @colorlowerbody=0 if @colorNames[@index]=="normal"
- @colorlowerbody=1 if @colorNames[@index]=="azul"
- @colorlowerbody=2 if @colorNames[@index]=="rojo"
- @colorshoes=0 if @colorNames[@index]=="normal"
- @colorshoes=1 if @colorNames[@index]=="azul"
- @colorshoes=2 if @colorNames[@index]=="rojo"
- @colorshoes=0 if @colorNames[@index]=="normal"
- @colorshoes=1 if @colorNames[@index]=="azul"
- @colorshoes=2 if @colorNames[@index]=="rojo"
- end
- # updates the Accessory bitmap
- def updateAccessoryBitmap
- @sprites["playerAccessory"].bitmap.clear
- name=$game_player.character_name+"_"+@accessoryNames[@index]+(getAccessoryIndex).to_s
- if File.exists?("Graphics/Characters/"+name+".png") && @index2 != @cmdwindow2.itemCount
- @sprites["playerAccessory"].charset=name
- end
- end
- def updateColorBitmap
- @sprites["playerAccessory"].bitmap.clear
- name=$game_player.character_name+"_"+@accessoryNames[@index]+(getAccessoryIndex).to_s+"-"+(getColorIndex).to_s
- if File.exists?("Graphics/Characters/"+name+".png") && @index2 != @cmdwindow3.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=retUnlockedAccessoryArray(cnvrtStrArr(@list))
- @list=["---NONE---"] if !@list
- @list.push("Back") if !@list.include?("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}"].viewport=@viewport
- @sprites["heading#{@new_val}"].index=1
- @sprites["heading#{@new_val}"].x=Graphics.width-@sprites["heading#{@new_val}"].width
- @sprites["heading#{@new_val}"].z-=1
- @sprites["cmdwindow#{@new_val}"]=Window_CommandPokemonEx.new(retListCmdBox2)
- @cmdwindow2=@sprites["cmdwindow#{@new_val}"]
- @cmdwindow2.viewport=@viewport
- @cmdwindow2.y=@sprites["heading#{@new_val}"].height
- @cmdwindow2.x=Graphics.width-@sprites["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
- @index2=@index
- return true
- end
- return false
- end
- # checks whether the index or the right command box has changed or not.
- def cmdWindow2IndexChanged
- if !@cmdWindow2Index
- @cmdWindow2Index=@cmdwindow2.index
- return false
- elsif @cmdWindow2Index != @cmdwindow2.index
- @cmdWindow2Index=@cmdwindow2.index
- return true
- end
- return false
- end
- def cmdWindow3IndexChanged
- if !@cmdWindow3Index
- @cmdWindow3Index=@cmdwindow3.index
- return false
- elsif @cmdWindow3Index != @cmdwindow3.index
- @cmdWindow3Index=@cmdwindow3.index
- 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
- @index=@sprites["cmdwindow"].index
- elsif @secondSelection
- @cmdwindow2.update
- else
- @cmdwindow3.update
- end
- if indexChanged
- updateHeading2
- end
- if cmdWindow2IndexChanged && @cmdwindow2.index != -1
- updateAccessoryBitmap #if @cmdwindow2.index != @cmdwindow2.
- end
- if cmdWindow3IndexChanged && @cmdwindow3.index != -1
- updateColorBitmap
- end
- if Input.trigger?(Input::C)
- # Pressing C on the left command box.
- if @firstSelection
- @cmdwindow2.index=0
- @firstSelection=false
- @secondSelection=true
- @sprites["playerAccessory"].visible=true
- elsif @secondSelection
- # Pressing C on the right command box.
- @cmdwindow3.index=0
- @sprites["heading3"].visible=true
- @sprites["heading1"].visible=false
- @secondSelection=false
- if @cmdwindow2.index==(@cmdwindow2.itemCount-1) # Cancel
- @cmdwindow2.index=-1; @cmdwindow2.update
- @secondSelection=false
- @firstSelection=true
- end
- else
- if @cmdwindow3.index==(@cmdwindow3.itemCount-1) # Cancel
- @cmdwindow3.index=-1; @cmdwindow3.update
- 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 !@firstSelection && @secondSelection
- @cmdwindow2.index=-1; @cmdwindow2.update
- @firstSelection=true
- @sprites["window2"].visible=false
- @sprites["playerAccessory"].visible=false
- elsif !@firstSelection && !@secondSelection
- @secondSelection=true
- @sprites["playerAccessory"].visible=false
- @sprites["window3"].visible=false
- end
- end
- # updates the walking sprite.
- if frame%120==0
- @dir+=1
- @sprites["player"].src_rect.y=@y[@dir%4]
- @sprites["playerAccessory"].src_rect.y=@sprites["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
- $Trainer.colorheadgear=getColorIndex
- when 1
- $Trainer.head=getAccessoryIndex
- $Trainer.colorhead=getColorIndex
- when 2
- $Trainer.upperbody=getAccessoryIndex
- $Trainer.colorupperbody=getColorIndex
- when 3
- $Trainer.lowerbody=getAccessoryIndex
- $Trainer.colorlowerbody=getColorIndex
- when 4
- $Trainer.shoe=getAccessoryIndex
- $Trainer.colorshoes=getColorIndex
- when 5
- $Trainer.accessoire=getAccessoryIndex
- $Trainer.coloraccessoire=getColorIndex
- end
- end
- end
- #===============================================================================
- # * Edit to the class Game_Player to erase the .png extension in the name.
- #===============================================================================
- class Game_Player
- def character_name
- if !@defaultCharacterName
- @defaultCharacterName=""
- end
- if @defaultCharacterName!=""
- return @defaultCharacterName.gsub(/\0/,"v")#(/\.png/,"")
- end
- if !moving? && !@move_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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement