- 3
- Posts
- 4
- Years
- Seen Apr 25, 2024
Code:
#Script 1
#===============================================================================
# * Character Costumization by Wolf Heretic
# * Based Heavily on a script by shiney570
# Version: 2.0.0
#===============================================================================
#
# NOTES:
# - Do not name two different items the same name. (Ie. If I have a headgear item
# called Ring and an accessory called Ring, this will lead to undefined behavior
# and could make your game crash)
# - You cannot lock all of the items for some bodypart. This will cause the game
# to crash in the characterization screen.
# - This script alters how a character's metadata is called and how the game loads
# and saves data. Be aware of this ifyou're using other scripts which edit these
# aspects of default essentials.
# - pbChooseBaseGraphic should only be called after the player's character (In
# default essentials gender) and name are defined.
#
# 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
=begin
ROUGH EXPLANATION FOR CLOTHING ARRAYS:
When setting up the arrays below, its important to note the following structure
of the arrays representing the possible costumes a player can equip.
1. The initial array describes the Bodypart (ie. Hair, Top, Accessories).
It is an array which is made up of multiple "Items", or subarrays representing
each item that can be equipped by the player.
2. The second layer describes each item (Ie. For Headgear, the items could be
glasses, a tophat, and a helmet). Each item is an array with two entries, the
"Names" of the item for each character(in default essentials each gender) and
either a "Variant" array representing the different types/colors of the item the
player can equip or a boolean representing whether the item is unlocked by default.
a. Names: An array of strings representing the names of an item for different
characters. The number of names in this array should equal the number
of characters your game has. In default essentials, there are two characters (Male character
& female), so if you haven't changed that there should be two names in this array.
b. Variant: Is optional. If the player only wants one version of the item, instead
of writing an array they should write either true or false for whether they want
the item initially unlocked. Variant is explained in more detail next.
3. The third layer describes each variant of the previous item, if there is more
than one (Ie. If the item selected was a T-shirt, then the variants could be Blue,
Red, Yellow, etc. for each color of the T-shirt). Each variant array consists of
the name of the variant and a boolean representing whether the variant of that
item is unlocked by default.
a. Name: The name of the variant (ie. "Orange"). Should be a string.
b. Unlocked?: A true or false value representing whether or not this specific
variant should be unlocked initially.
Also here's a diagram for what everything all of the items consist of
[ Bodypart ]
||
\/
[Item[0], Item[1],...]
||
\/
[Names, Variants(Optional)]
|| ||
\/ \/
[BoyName,GirlName] [Variant[0], Variant[1],...]
(Default Essentials) ||
\/
[Name, Unlocked?]
Hope this helped! If not then maybe you can get something from the initial
arrays down below.
=end
# Names of the hairstyles in order. (true= unlocked by default, false=locked by default)
HAIR_ITEMS=[
[["Bald", "Bald"], true],
[["Spikey","Long"], [["Black",true],["Blond",true],["Blue",true],["Brown",true],
["Cyan",true],["Ginger",true],["Green",true],["Pink",true],["Purple",true],["Red",true],["White",true]]],
[["Short","Short"], [["Black",true],["Blond",true],["Blue",true],["Brown",true],
["Cyan",true],["Ginger",true],["Green",true],["Pink",true],["Purple",true],["Red",true],["White",true]]],
[["Medium","Medium"], [["Black",true],["Blond",true],["Blue",true],["Brown",true],
["Cyan",true],["Ginger",true],["Green",true],["Pink",true],["Purple",true],["Red",true],["White",true]]],
[["Slicked Back","Ponytail"], [["Black",true],["Blond",true],["Blue",true],["Brown",true],
["Cyan",true],["Ginger",true],["Green",true],["Pink",true],["Purple",true],["Red",true],["White",true]]]
]
# Names of the top items in order. (true= unlocked by default, false=locked by default)
TOP_ITEMS=[
[["No Top", "No Top"],true],
[["Beach Pend","Beach Top"], [["Black",true],["Blue",true],["Green",true],["Pink",true],
["Red",true]]],
[["Classy","Classy"], [["Beige",true],["Black",true],["Grey",true],
["Navy",true], ["Wine",true]]],
[["Collared","Collared"], [["Black",true], ["Light Blue",true], ["Navy",true],
["White",true], ["Wine",true]]],
[["Formal T.","Formal T."], [["Black",true], ["Beige",true], ["Blue",true],
["Pink",true], ["Red",true]]],
[["Hoodie","Hoodie"], [["Black",true], ["Blue",true], ["Green",true], ["Purple",true],
["Red",true]]],
[["Jumpsuit T.","Jumpsuit T."], [["Black",true], ["Blue",true], ["Green",true],
["Red",true], ["Yellow",true]]],
[["Jumpsuit T.2","Jumpsuit T.2"], [["Blue",true],["Green",true],
["Red",true], ["Black",true], ["Yellow",true]]],
[["Lord Suit T.","Lord Suit T."], [["Purple",true], ["Red",true]]],
[["Open Jacket","Open Jacket"], [["Blue",true], ["Green",true], ["Orange",true],
["Pink",true], ["Red",true]]],
[["Scarf Shirt","Scarf Shirt"], [["Black",true], ["Blue",true], ["Brown",true],
["Red",true], ["Yellow",true]]],
[["Schoolboy T.","Schoolgirl T."], [["Light",true], ["Dark",true]]],
[["Shirt Combo","Shirt Combo"], [["Black",true], ["Blue",true], ["Red",true],
["White",true], ["Wine",true]]],
[["Tank","Tank"], [["Black",true], ["Green",true], ["Navy",true],
["Pink",true], ["Red",true]]],
[["Trenchcoat","Trenchcoat"], [["Beige",true], ["Black",true], ["Navy",true],
["Purple",true], ["Red",true]]],
[["T-Shirt","T-Shirt"], [["Black",true], ["Blue",true], ["Green",true], ["Red",true],
["White",true]]],
[["Turtleneck","Turtleneck"], [["Beige",true], ["Black",true], ["Green",true],
["White",true], ["Wine",true]]],
[["Vest","Vest"], [["Black",true], ["Blue",true], ["Brown",true], ["Grey",true],
["Wine",true]]],
[["V-Neck","V-Neck"], [["Black",true], ["Green",true], ["Orange",true], ["Purple",true],
["Yellow",true]]],
[["Top Flower","Top Flower"], [["Blue",true],["Brown",true],["Cyan",true],
["Green",true], ["Orange",true], ["Purple",true], ["Red",true], ["Yellow",true], ["Black",true]]]
]
# Names of the bottoms in order. (true= unlocked by default, false=locked by default)
BOTTOM_ITEMS=[
[["No Bottom", "No Bottom"],true],
[["Beach Bt.","Beach Bt."], [["Black",true],["Blue",true],["Green",true],
["Pink",true], ["Red",true]]],
[["Capris","Capris"], [["Aqua",true], ["Beige",true], ["Black",true], ["Green",true],
["Navy",true]]],
[["Classy Bt.","Classy Bt."], [["Beige",true],["Black",true],["Grey",true],
["Navy",true], ["Wine",true]]],
[["Formal B.","Formal B."], [["Black",true], ["Blue",true], ["Brown",true],
["Grey",true], ["Pink",true]]],
[["Jeans","Jeans"], [["Aqua",true], ["Black",true], ["Grey",true], ["Light Blue",true],
["Navy",true]]],
[["Jumpsuit B.","Jumpsuit B."], [["Black",true], ["Blue",true], ["Green",true],
["Red",true], ["Yellow",true]]],
[["Jumpsuit B.2","Jumpsuit B.2"], [["Blue",true],
["Green",true], ["Red",true], ["Black",true], ["Yellow",true]]],
[["Long Skirt","Long Skirt"], [["Black",true], ["Blue",true], ["Green",true],
["Pink",true], ["Purple",true]]],
[["Lord Suit","Lord Suit"], true],
[["Normal","Normal"], [["Beige",true], ["Black",true], ["Grey",true],
["Light Blue",true], ["Navy",true]]],
[["Pencil Skirt","Pencil Skirt"], [["Black",true], ["Green",true], ["Grey",true],
["Navy",true], ["Wine",true]]],
[["Ribbon Skirt","Ribbon Skirt"], [["Blue",true], ["Green",true], ["Pink",true],
["Red",true], ["Black",true]]],
[["Schoolboy B.","Schoolgirl B."], [["Light",true],["Dark",true]]],
[["Shorts","Shorts"], [["Black",true], ["Blue",true], ["Green",true],
["Red",true], ["White",true]]],
[["Underwear","Underwear"],true],
[["Bottom Flower","Bottom Flower"], [["Blue",true],["Brown",true],["Cyan",true],
["Green",true], ["Orange",true], ["Purple",true], ["Red",true], ["Yellow",true], ["Black",true]]]
]
# Names of the eyewear in order. (true= unlocked by default, false=locked by default)
EYEWEAR_ITEMS=[
[["No Eyewear", "No Eyewear"], true],
[["Glasses","Glasses"],[["Blue",true],["Red",true]]]
]
# Names of the headgear in order. (true= unlocked by default, false=locked by default)
HEADGEAR_ITEMS=[
[["No Hat", "No Hat"], true],
[["Beanie","Beanie"], [["Black",true],["Purple",true]]],
[["Beret","Beret"],true],
[["Bonnet","Bonnet"],true],
[["Cat","Cat"],true],
[["Crown","Crown"], [["Gold",true],["Silver",true]]],
[["Devil","Devil"],true],
[["Feather Hat","Feather Hat"],true],
[["Fedora","Fedora"],true],
[["Flower","Flower"], [["Blue",true],["Red",true]]],
[["Glasses (old)","Glasses (old)"],[["Blue",true],["Red",true]]],
[["Hair Band","Hair Band"],true],
[["Head Band","Head Band"],true],
[["Miner Helmet","Miner Helmet"],true],
[["Poop","Poop"],true],
[["Ribbon","Ribbon"],true],
[["Straw Hat","Straw Hat"],true],
[["Sun Hat","Sun Hat"],true],
[["HGSS Cap","HGSS Cap"],[["Blue",true],["Yellow",true]]]
]
# Names of the accessories in order. (true= unlocked by default, false=locked by default)
ACCESSORY_ITEMS=[
[["No Bag", "No Bag"],true],
[["Bag","Bag"], [["Black",true], ["Blue",true], ["Green",true], ["Magenta",true],
["Orange",true], ["Purple",true], ["Red",true], ["White",true], ["Yellow",true]]],
[["Rucksack","Rucksack"], [["Black",true], ["Blue",true], ["Green",true], ["Magenta",true],
["Orange",true], ["Purple",true], ["Red",true], ["White",true], ["Yellow",true]]],
[["Sporty Bag","Sporty Bag"], [["Black",true], ["Blue",true], ["Green",true],
["Magenta",true], ["Orange",true], ["Purple",true], ["Red",true], ["White",true],
["Yellow",true]]]
]
# Names of the shoes in order. (true= unlocked by default, false=locked by default)
SHOE_ITEMS=[
[["No Footwear","No Footwear"],true],
[["Flip Flops","Flip Flops"], [["Blue",true],["Brown",true],["Cyan",true],
["Green",true], ["Orange",true], ["Purple",true], ["Red",true], ["Yellow",true], ["Black",true]]],
[["Capri S.","Capri S."], [["Aqua",true], ["Beige",true], ["Black",true], ["Green",true],
["Navy",true]]],
[["Classy S.","Classy S."], [["Beige",true],["Black",true],["Grey",true],
["Navy",true], ["Wine",true]]],
[["Formal S.","Formal S."], [["Black",true], ["Blue",true], ["Brown",true],
["Grey",true], ["Pink",true]]],
[["Jean S.","Jean S."], [["Aqua",true], ["Black",true], ["Grey",true], ["Light Blue",true],
["Navy",true]]],
[["Jumpsuit S.","Jumpsuit S."], [["Black",true], ["Blue",true], ["Green",true],
["Red",true], ["Yellow",true]]],
[["Jumpsuit S.2","Jumpsuit S.2"], [["Blue",true],
["Green",true], ["Red",true], ["Black",true], ["Yellow",true]]],
[["Skirt S.","Skirt S."], [["Black",true], ["Blue",true], ["Green",true],
["Pink",true], ["Purple",true]]],
[["Lord Suit S.","Lord Suit S."], true],
[["Boots","Boots"], [["Beige",true], ["Black",true], ["Grey",true],
["Light Blue",true], ["Navy",true]]],
[["Pencil S.","Pencil S."], [["Black",true], ["Green",true], ["Grey",true],
["Navy",true], ["Wine",true]]],
[["Ribbon S.","Ribbon S."], [["Blue",true], ["Green",true], ["Pink",true],
["Red",true], ["Black",true]]],
[["Schoolboy S.","Schoolgirl S."], [["Light",true],["Dark",true]]],
[["S.","S."], [["Black",true], ["Blue",true], ["Green",true],
["Red",true], ["White",true]]]
]
#==================================================================================
#This section defines the Base graphic names with a double array. Each item in the
# initial array represents each base, while the number of items in those base arrays
# is the base name for each character (In default essentials, for boy and girl).
BASE_GRAPHICS=[
[["Pale","Pale"],true],
[["Light","Light"],true],
[["Tanned","Tanned"],true],
[["Dark","Dark"],true]
]
#==================================================================================
#This hash specifies which folders certain character sprites will be retrieved from
# when making new character sprites.
#Update this whenever the player has added another sprite sheet for a character
# (ie. if a player had a specific swimming sprite sheet)
SPRITE_CONVERT_HASH = { "trchar000" => "overworld walk",
"boy_bike" => "overworld bike",
"boy_surf" => "overworld surf", #changed for V17.2
"boy_run" => "overworld run",
"boy_dive_offset" => "overworld dive",
"boy_fish_offset" => "overworld fish",
"boy_fishsurf_offset" => "overworld fishsurf",
"trainer000" => "trainer front male",
"trback000" => "trainer back male",
"introBoy" => "trainer front male",
"mapPlayer000" => "tr map",
"trchar001" => "overworld walk",
"girl_bike" => "overworld bike",
"girl_surf" => "overworld surf", #changed for V17.2
"girl_run" => "overworld run",
"girl_dive_offset" => "overworld dive",
"girl_fish_offset" => "overworld fish",
"girl_fishsurf_offset" => "overworld fishsurf",
"trainer001" => "trainer front female",
"trback001" => "trainer back female",
"introGirl" => "trainer front female",
"mapPlayer001" => "tr map"}
WALK_FOLDER = SPRITE_CONVERT_HASH["trchar000"]
def pbPrintSpriteConvertHash
pbMessage(_INTL("{1}",SPRITE_CONVERT_HASH))
end
#==================================================================================
# * Custom Scripts
#==================================================================================
def reloadOverworldSprites
if pbWearingItem?("Pale")
pbDressAccessory("Light")
pbDressAccessory("Pale")
end
if pbWearingItem?("Light")
pbDressAccessory("Pale")
pbDressAccessory("Light")
end
if pbWearingItem?("Tanned")
pbDressAccessory("Light")
pbDressAccessory("Tanned")
end
if pbWearingItem?("Dark")
pbDressAccessory("Light")
pbDressAccessory("Dark")
end
end
def dressDefaultOutfit
pbDressAccessory("Hoodie","Blue")
pbDressAccessory("Shorts","Black")
pbDressAccessory("No Bag")
if $Trainer.isFemale?
pbDressAccessory("Long","Brown")
else
pbDressAccessory("Short","Brown")
end
pbDressAccessory("Flip Flops","Blue")
pbDressAccessory("Pale")
pbDressAccessory("No Hat")
pbDressAccessory("No Eyewear")
pbSave
end
#Puts on the default clothing for the male character
def defaultClothingMale
pbChangePlayer(0)
pbDressAccessory("Hoodie","Blue")
pbDressAccessory("Shorts","Black")
pbDressAccessory("No Bag")
pbDressAccessory("Short","Brown")
pbDressAccessory("Flip Flops","Blue")
pbDressAccessory("Pale")
pbDressAccessory("No Hat")
pbDressAccessory("No Eyewear")
pbSave
end
#Puts on the default clothing for the female character
def defaultClothingFemale
pbChangePlayer(1)
pbDressAccessory("Hoodie","Blue")
pbDressAccessory("Shorts","Black")
pbDressAccessory("No Bag")
pbDressAccessory("Long","Brown")
pbDressAccessory("Flip Flops","Blue")
pbDressAccessory("Pale")
pbDressAccessory("No Hat")
pbDressAccessory("No Eyewear")
pbSave
end
#==================================================================================
# * Useful methods that the Game Designer can call
#==================================================================================
#Checks whether or not a trainer has been defined.
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
#Character Customization Script game designer can use
def pbCustomizeCharacter
CharacterCustomizationScene.new
end
#Script in which the player can choose the base graphic they will use for their
# character.
#Can be used to choose your player's skin tone.
#Should be used after the player selects their name and gender (or character).
def pbChooseBaseGraphic
ChooseBase.new
end
# Method for changing a certain item. Used by game designer
# item: String representing item player will put on.
# variant (Use when accessory has variants): The variant of the item to be put on.
def pbDressAccessory(item,variant=nil)
return false if pbTrainerNotDefined
dressAccessory(item,variant)
updateTrainerOutfit
saveAllCustomizedBitmapsToFolder
$PokemonTemp.savedoutfit = false
end
# Gives the player randomized clothes (e.g good thing for randomizer challenges)
def pbRandomizeOutfit
return false if pbTrainerNotDefined
for i in 0...8 #0 to Number of bodyparts (change if adding/deleting bodyparts)
randomizeOutfitHelper(i)
end
saveAllCustomizedBitmapsToFolder
updateTrainerOutfit
$PokemonTemp.savedoutfit = false
pbSave
end
# Method for checking whether the player wears a certain item.
# item: String representing the item that the player will be checked for.
# variant (Use when accessory has variants): The variant of the item checked for.
def pbWearingItem?(item,variant=nil)
wearingAccessory?(item,variant)
end
# Method for unlocking clothes.
# item: String representing item player will unlock.
# variant (Use when accessory has variants): The variant unlocked for the item.
def pbUnlockItem(item,variant=nil)
unlockAccessory(item,variant)
end
# Unlocks all the variants of a specific item.
# Only use for accessories with variants.
# item: String representing item player will unlock all the variants of.
def pbUnlockEntireItem(item)
return false if pbTrainerNotDefined
return false if !item.is_a?(String)
arr=retArrayAndNumber(item,false)
return false if !(arr[0])
bodypart=arr[1]-1
for i in 0...arr[0].length
index=i if arr[0][i][0][$PokemonGlobal.playerID]==item
end
(if $DEBUG; p "There was an issue unlocking the item."; end; return) if !index
return false if checkAccessory(arr[0],index)
for i in 0...arr[0][index][1].length
$Trainer.clothesUnlocking[bodypart][index][i]=true
end
end
# Method for locking clothes.
# Only use for accessories with variants.
# variant (Use when accessory has variants): The variant unlocked for the item.
def pbLockItem(item,variant=nil)
lockAccessory(item,variant)
end
# Locks all the variants of a specific item.
# Only use for accessories with variants
# item: String representing item player will lock all the variants of.
def pbLockEntireItem(item)
return false if pbTrainerNotDefined
return false if !item.is_a?(String)
arr=retArrayAndNumber(item,false)
bodypart=arr[1]
(if $DEBUG; p "There was an issue locking the item."; end; return) if !(arr[0])
for i in 0...arr[0].length
index=i if arr[0][i][0][$PokemonGlobal.playerID]==item
end
if checkAccessory(arr[0],index)
(if $DEBUG; p "There was an issue locking the item."; end; return)
end
for i in 0...arr[0][index][1].length
lockAccessory(item,arr[0][index][1][i][0])
end
end
#==================================================================================
# * Complete code of methods game designer calls
#==================================================================================
# This method updates the trainer outfit
def updateTrainerOutfit
next_id=($PokemonGlobal.playerID==1 ? 0 : 1)
id=$PokemonGlobal.playerID
pbChangePlayer(next_id)
pbWait(1)
pbChangePlayer(id)
end
# Method for changing a certain accessory.
def dressAccessory(accessory,variant=nil)
return false if pbTrainerNotDefined
return false if characterizationException
return false if !accessory.is_a?(String)
return false if !variant.is_a?(String) && !(variant.nil?)
arr=retArrayAndNumber(accessory,false)
(if $DEBUG; p "Could not find entered accessory."; end; return false) if !arr[0]
bodypart=arr[0]; var=arr[1]
for i in 0...bodypart.length
if bodypart[i][0][$PokemonGlobal.playerID]==accessory
#pbMessage(_INTL("{1}",[i][0][$PokemonGlobal.playerID]))
if variant.nil?
if checkAccessory(bodypart,i)
$Trainer.skin=[i,-1] if var==1
$Trainer.hair=[i,-1] if var==2
$Trainer.top=[i,-1] if var==3
$Trainer.footwear=[i,-1] if var==4
$Trainer.bottom=[i,-1] if var==5
$Trainer.eyewear=[i,-1] if var==6
$Trainer.headgear=[i,-1] if var==7
$Trainer.accessory=[i,-1] if var==8
saveAllCustomizedBitmapsToFolder
updateTrainerOutfit
return
elsif $DEBUG
p "Cannot dress accessory. Array is multidimensional, entered single value."
end
return
else
if !checkAccessory(bodypart,i,false)
if $DEBUG
p "Cannot dress accessory. Array is singledimensional, entered multiple values."
end
return
end
secondvalue=nil
for j in 0...bodypart[i][1].length
if bodypart[i][1][j][0]==variant
secondvalue=j
end
end
if secondvalue.nil?
if $DEBUG
p "Could not find variant specified."
end
return
else
$Trainer.skin=[i,secondvalue] if var==1
$Trainer.hair=[i,secondvalue] if var==2
$Trainer.top=[i,secondvalue] if var==3
$Trainer.footwear=[i,secondvalue] if var==4
$Trainer.bottom=[i,secondvalue] if var==5
$Trainer.eyewear=[i,secondvalue] if var==6
$Trainer.headgear=[i,secondvalue] if var==7
$Trainer.accessory=[i,secondvalue] if var==8
saveAllCustomizedBitmapsToFolder
updateTrainerOutfit
$PokemonTemp.savedoutfit = false
return
end
end
end
end
return
end
def wearingAccessory?(accessory,variant=nil)
return false if pbTrainerNotDefined
return false if characterizationException
arr=retArrayAndNumber(accessory,false)
clothes=arr[0]; bodypart=arr[1]
current=$Trainer.skin if bodypart==1
current=$Trainer.hair if bodypart==2
current=$Trainer.top if bodypart==3
current=$Trainer.footwear if bodypart==4
current=$Trainer.bottom if bodypart==5
current=$Trainer.eyewear if bodypart==6
current=$Trainer.headgear if bodypart==7
current=$Trainer.accessory if bodypart==8
return false if !clothes || !current
if accessory.is_a?(String)
for i in 0...clothes.length
if clothes[i][0][$PokemonGlobal.playerID]==accessory
if variant.nil?
return (accessory==clothes[current[0]][0][$PokemonGlobal.playerID])
elsif variant.is_a?(String) && accessory==clothes[current[0]][0][$PokemonGlobal.playerID]
return false if checkAccessory(clothes,i)
for j in 0...clothes[i][1].length
if clothes[i][1][j][0]==variant
return (variant==clothes[i][1][current[0]][0])
end
end
else
return false
end
end
end
end
return false
end
def unlockAccessory(accessory,variant=nil)
return false if pbTrainerNotDefined
return false if !accessory.is_a?(String)
arr=retArrayAndNumber(accessory,false)
return false if !(arr[0])
bodypart=arr[1]-1
for i in 0...arr[0].length
index=i if arr[0][i][0][$PokemonGlobal.playerID]==accessory
end
(if $DEBUG; p "There was an issue unlocking the accessory."; end; return) if !index
if !variant.nil?
return false if !variant.is_a?(String)
return false if checkAccessory(arr[0],index)
for j in 0...arr[0][index][1].length
index2=j if arr[0][index][1][j][0]==variant
end
(if $DEBUG; p "There was an issue unlocking the accessory."; end; return) if !index2
$Trainer.clothesUnlocking[bodypart][index][index2]=true
else
return false if checkAccessory(arr[0],index,false)
$Trainer.clothesUnlocking[bodypart][index]=true
end
end
# Method for locking clothes
def lockAccessory(accessory,variant=nil)
return false if pbTrainerNotDefined
return false if !accessory.is_a?(String)
arr=retArrayAndNumber(accessory,false)
bodypart=arr[1]
(current=$Trainer.skin; name="Skin")if bodypart==1
(current=$Trainer.hair; name="Hair") if bodypart==2
(current=$Trainer.top; name="Top") if bodypart==3
(current=$Trainer.footwear; name="Footwear")if bodypart==4
(current=$Trainer.bottom; name="Bottom") if bodypart==5
(current=$Trainer.eyewear; name="Eyewear")if bodypart==6
(current=$Trainer.headgear; name="Headgear")if bodypart==7
(current=$Trainer.accessory; name="Accessory")if bodypart==8
# Checking if player wears the accessory to lock
(if $DEBUG; p "There was an issue locking the accessory"; end; return) if !(arr[0])
for i in 0...arr[0].length
if arr[0][i][0][$PokemonGlobal.playerID]==accessory
index=i
if variant.nil?
if checkAccessory(arr[0],index,false)
(if $DEBUG; p "There was an issue locking the accessory"; end; return)
end
#p i; p current
if i==current[0]
if checkAccessory(arr[0],0)
sv=-1
else
sv=0
end
Kernel.pbMessage("#{$Trainer.name} misses the #{accessory} #{name} and puts on the #{arr[0][0][0][$PokemonGlobal.playerID]} one instead.")
$Trainer.skin=[0,sv] if bodypart==1
$Trainer.hair=[0,sv] if bodypart==2
$Trainer.top=[0,sv] if bodypart==3
$Trainer.footwear=[0,sv] if bodypart==4
$Trainer.bottom=[0,sv] if bodypart==5
$Trainer.eyewear=[0,sv] if bodypart==6
$Trainer.headgear=[0,sv] if bodypart==7
$Trainer.accessory=[0,sv] if bodypart==8
end
else
if checkAccessory(arr[0],index) || !variant.is_a?(String)
(if $DEBUG; p "There was an issue locking the accessory"; end; return)
end
for j in 0...arr[0][i][1].length
if arr[0][i][1][j][0]==variant
index2=j
end
if i==current[0] && j==current[1]
if checkAccessory(arr[0],0)
sv=-1
else
sv=0
end
Kernel.pbMessage("#{$Trainer.name} misses the #{accessory} #{name} and puts on the #{arr[0][0][0][$PokemonGlobal.playerID]} one instead.")
$Trainer.skin=[0,sv] if bodypart==1
$Trainer.hair=[0,sv] if bodypart==2
$Trainer.top=[0,sv] if bodypart==3
$Trainer.footwear=[0,sv] if bodypart==4
$Trainer.bottom=[0,sv] if bodypart==5
$Trainer.eyewear=[0,sv] if bodypart==6
$Trainer.headgear=[0,sv] if bodypart==7
$Trainer.accessory=[0,sv] if bodypart==8
end
end
end
end
end
(if $DEBUG; p "There was an issue locking the accessory"; end; return) if !index
if !variant.nil? && !index2
(if $DEBUG; p "There was an issue locking the accessory"; end; return)
elsif !variant.nil?
$Trainer.clothesUnlocking[bodypart-1][index][index2]=false
else
$Trainer.clothesUnlocking[bodypart-1][index]=false
end
saveAllCustomizedBitmapsToFolder
updateTrainerOutfit
$PokemonTemp.savedoutfit = false
end
#==================================================================================
# * Initializing class PokeBattle_Trainer objects.
#==================================================================================
class PokeBattle_Trainer
attr_accessor :character_customization
attr_accessor :skin
attr_accessor :hair
attr_accessor :top
attr_accessor :footwear
attr_accessor :bottom
attr_accessor :eyewear
attr_accessor :headgear
attr_accessor :accessory
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 skin
if !@skin
if ((BASE_GRAPHICS[0][1] == true) || (BASE_GRAPHICS[0][1] == false))
@skin=[0,-1]
else
@skin=[0,0]
end
end
return @skin
end
def skin=(values)
fvalue=values[0]; svalue=values[1]
if fvalue<0 || fvalue>(BASE_GRAPHICS.length-1)
if $DEBUG
p "the first value for $Trainer.accessory is out of range!"
end
return
end
if ((BASE_GRAPHICS[fvalue][1] == true) || (BASE_GRAPHICS[fvalue][1] == false))
@skin=[fvalue, -1]
else
if svalue<0 || svalue>(BASE_GRAPHICS[fvalue][1].length-1)
if $DEBUG
p "the second value for $Trainer.accessory is out of range!"
end
return
end
@skin=[fvalue, svalue]
end
end
def hair
if !@hair
if ((HAIR_ITEMS[0][1] == true) || (HAIR_ITEMS[0][1] == false))
@hair=[0,-1]
else
@hair=[0,0]
end
end
return @hair
end
def hair=(values)
fvalue=values[0]; svalue=values[1]
if fvalue<0 || fvalue>(HAIR_ITEMS.length-1)
if $DEBUG
p "the first value for $Trainer.hair is out of range!"
end
return
end
if ((HAIR_ITEMS[fvalue][1] == true) || (HAIR_ITEMS[fvalue][1] == false))
@hair=[fvalue, -1]
else
if svalue<0 || svalue>(HAIR_ITEMS[fvalue][1].length-1)
if $DEBUG
p "the second value for $Trainer.hair is out of range!"
end
return
end
@hair=[fvalue, svalue]
end
end
def top
if !@top
if ((TOP_ITEMS[0][1] == true) || (TOP_ITEMS[0][1] == false))
@top=[0,-1]
else
@top=[0,0]
end
end
return @top
end
def top=(values)
fvalue=values[0]; svalue=values[1]
if fvalue<0 || fvalue>(TOP_ITEMS.length-1)
if $DEBUG
p "the first value for $Trainer.top is out of range!"
end
return
end
if ((TOP_ITEMS[fvalue][1] == true) || (TOP_ITEMS[fvalue][1] == false))
@top=[fvalue, -1]
else
if svalue<0 || svalue>(TOP_ITEMS[fvalue][1].length-1)
if $DEBUG
p "the second value for $Trainer.top is out of range!"
end
return
end
@top=[fvalue, svalue]
end
end
def bottom
if !@bottom
if ((BOTTOM_ITEMS[0][1] == true) || (BOTTOM_ITEMS[0][1] == false))
@bottom=[0,-1]
else
@bottom=[0,0]
end
end
return @bottom
end
def bottom=(values)
fvalue=values[0]; svalue=values[1]
if fvalue<0 || fvalue>(BOTTOM_ITEMS.length-1)
if $DEBUG
p "the first value for $Trainer.bottom is out of range!"
end
return
end
if ((BOTTOM_ITEMS[fvalue][1] == true) || (BOTTOM_ITEMS[fvalue][1] == false))
@bottom=[fvalue, -1]
else
if svalue<0 || svalue>(BOTTOM_ITEMS[fvalue][1].length-1)
if $DEBUG
p "the second value for $Trainer.bottom is out of range!"
end
return
end
@bottom=[fvalue, svalue]
end
end
def eyewear
if !@eyewear
if ((EYEWEAR_ITEMS[0][1] == true) || (EYEWEAR_ITEMS[0][1] == false))
@eyewear=[0,-1]
else
@eyewear=[0,0]
end
end
return @eyewear
end
def eyewear=(values)
fvalue=values[0]; svalue=values[1]
if fvalue<0 || fvalue>(EYEWEAR_ITEMS.length-1)
if $DEBUG
p "the first value for $Trainer.eyewear is out of range!"
end
return
end
if ((EYEWEAR_ITEMS[fvalue][1] == true) || (EYEWEAR_ITEMS[fvalue][1] == false))
@eyewear=[fvalue, -1]
else
if svalue<0 || svalue>(EYEWEAR_ITEMS[fvalue][1].length-1)
if $DEBUG
p "the second value for $Trainer.eyewear is out of range!"
end
return
end
@eyewear=[fvalue, svalue]
end
end
def headgear
if !@headgear
if ((HEADGEAR_ITEMS[0][1] == true) || (HEADGEAR_ITEMS[0][1] == false))
@headgear=[0,-1]
else
@headgear=[0,0]
end
end
return @headgear
end
def headgear=(values)
fvalue=values[0]; svalue=values[1]
if fvalue<0 || fvalue>(HEADGEAR_ITEMS.length-1)
if $DEBUG
p "the first value for $Trainer.headgear is out of range!"
end
return
end
if ((HEADGEAR_ITEMS[fvalue][1] == true) || (HEADGEAR_ITEMS[fvalue][1] == false))
@headgear=[fvalue, -1]
else
if svalue<0 || svalue>(HEADGEAR_ITEMS[fvalue][1].length-1)
if $DEBUG
p "the second value for $Trainer.headgear is out of range!"
end
return
end
@headgear=[fvalue, svalue]
end
end
def accessory
if !@accessory
if ((ACCESSORY_ITEMS[0][1] == true) || (ACCESSORY_ITEMS[0][1] == false))
@accessory=[0,-1]
else
@accessory=[0,0]
end
end
return @accessory
end
def accessory=(values)
fvalue=values[0]; svalue=values[1]
if fvalue<0 || fvalue>(ACCESSORY_ITEMS.length-1)
if $DEBUG
p "the first value for $Trainer.accessory is out of range!"
end
return
end
if ((ACCESSORY_ITEMS[fvalue][1] == true) || (ACCESSORY_ITEMS[fvalue][1] == false))
@accessory=[fvalue, -1]
else
if svalue<0 || svalue>(ACCESSORY_ITEMS[fvalue][1].length-1)
if $DEBUG
p "the second value for $Trainer.accessory is out of range!"
end
return
end
@accessory=[fvalue, svalue]
end
end
def footwear
if !@footwear
if ((SHOE_ITEMS[0][1] == true) || (SHOE_ITEMS[0][1] == false))
@footwear=[0,-1]
else
@footwear=[0,0]
end
end
return @footwear
end
def footwear=(values)
fvalue=values[0]; svalue=values[1]
if fvalue<0 || fvalue>(SHOE_ITEMS.length-1)
if $DEBUG
p "the first value for $Trainer.accessory is out of range!"
end
return
end
if ((SHOE_ITEMS[fvalue][1] == true) || (SHOE_ITEMS[fvalue][1] == false))
@footwear=[fvalue, -1]
else
if svalue<0 || svalue>(SHOE_ITEMS[fvalue][1].length-1)
if $DEBUG
p "the second value for $Trainer.accessory is out of range!"
end
return
end
@footwear=[fvalue, svalue]
end
end
def clothesUnlocking
if !@clothesUnlocking
@clothesUnlocking=[]
@clothesUnlocking.push cnvrtBoolArr(BASE_GRAPHICS)
@clothesUnlocking.push cnvrtBoolArr(HAIR_ITEMS)
@clothesUnlocking.push cnvrtBoolArr(TOP_ITEMS)
@clothesUnlocking.push cnvrtBoolArr(SHOE_ITEMS)
@clothesUnlocking.push cnvrtBoolArr(BOTTOM_ITEMS)
@clothesUnlocking.push cnvrtBoolArr(EYEWEAR_ITEMS)
@clothesUnlocking.push cnvrtBoolArr(HEADGEAR_ITEMS)
@clothesUnlocking.push cnvrtBoolArr(ACCESSORY_ITEMS)
end
return @clothesUnlocking
end
end
#==================================================================================
# * Character Customization Scene
#==================================================================================
class CharacterCustomizationScene
def initialize
@savegetup = true
if !defined?($Trainer.clothesUnlocking) # Checks if the Script is functional.
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
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
pbMessage("The game was saved, try again now.")
end
end
return
end
if $PokemonTemp.savedoutfit == false
$PokemonTemp.savedoutfit = true
@savegetup = false
end
return if !addNecessaryFiles
if @savegetup == false
$PokemonTemp.savedoutfit = false
end
@index=0
@index2=0
@indexR=-1
@new_val=2
@firstSelection=true
@secondSelection=true
@selectionChange=false
@sprites={}
@accessoryNames=["skin","hair","tops","footwear","bottoms","eyewear","headgear","accessories"]
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height*2)
@viewport.z=99999
("Graphics/Trainers/trback00#{$PokemonGlobal.playerID}_base")
@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/2-@sprites["player"].bitmap.width/8
@sprites["player"].y=Graphics.height/2-@sprites["player"].bitmap.height/8 -64
@sprites["player"].z=9999999
$PokemonTemp.savedoutfit = true
temp="/"+WALK_FOLDER+"/"+@accessoryNames[1]+"/"+"0A"
@sprites["playerAccessory"]=TrainerWalkingCharSprite.new(temp,@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(["SKIN"])
@sprites["heading2"].viewport=@viewport
@sprites["heading2"].index=1
@sprites["heading2"].x=Graphics.width-@sprites["heading2"].width
#Version 17.2 Difference Below
@commands=CommandMenuList.new
@commands.add("main","skin",_INTL("Skin"))
@commands.add("main","hair",_INTL("Hair"))
@commands.add("main","tops",_INTL("Tops"))
@commands.add("main","footwear",_INTL("Footwear"))
@commands.add("main","bottoms",_INTL("Bottoms"))
@commands.add("main","eyewear",_INTL("Eyewear"))
@commands.add("main","headgear",_INTL("Headgear"))
@commands.add("main","accessories",_INTL("Accessories"))
#Version 17.2 Difference Above
@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"].y=0
@sprites["cmdwindow2"].x=Graphics.width-@sprites["cmdwindow2"].width
@sprites["cmdwindow2"].z-=1
@sprites["cmdwindow2"].index=-1
@cmdwindow2=@sprites["cmdwindow2"]
@selectionMade=false
update
end
def addNecessaryFiles
files=[]
basefiles=[]
# Pushing all files that could possibly be missing into the files array.
individualArrayFiles(files,BASE_GRAPHICS,"skin")
individualArrayFiles(files,HAIR_ITEMS,"hair")
individualArrayFiles(files,TOP_ITEMS,"tops")
individualArrayFiles(files,SHOE_ITEMS,"footwear")
individualArrayFiles(files,BOTTOM_ITEMS,"bottoms")
individualArrayFiles(files,EYEWEAR_ITEMS,"eyewear")
individualArrayFiles(files,HEADGEAR_ITEMS,"headgear")
individualArrayFiles(files,ACCESSORY_ITEMS,"accessories")
if USE_BASE_GRAPHIC
metadata=pbLoadMetadata
filenames=metadata[0][MetadataPlayerA+$PokemonGlobal.playerID]
for i in 0...filenames.length
if filenames[i].is_a?(String) && !(filenames[i]=="xxx")
basefiles.push("Graphics/Characters/"+filenames[i]+"_base")
end
end
# Trainer frontsprite
basefiles.push("Graphics/Trainers/trainer00#{$PokemonGlobal.playerID}_base")
# Trainer backsprite
basefiles.push("Graphics/Trainers/trback00#{$PokemonGlobal.playerID}_base")
# Intro Image/Trainercard Image
filepath="Graphics/Pictures/"
filepath+= $Trainer.isFemale? ? "introGirl" : "introBoy"
basefiles.push(filepath+"_base")
# Map Player
basefiles.push("Graphics/Pictures/mapPlayer00#{$PokemonGlobal.playerID}_base")
end
# Creating a blank bitmap
files_to_add=[]
for i in 0...basefiles.length
if !File.exists?(basefiles[i]+".png")
files_to_add.push(basefiles[i]+".png")
end
end
size_check=Bitmap.new("Graphics/Characters/#{$game_player.character_name}")
blank_bitmap=Bitmap.new(size_check.width,size_check.height)
# Pushing non existent files into the files_to_add array.
for i in 0...files.length
if !File.exists?("Graphics/Characters/overworld walk/#{files[i]}"+".png")
files_to_add.push("Graphics/Characters/overworld walk/#{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 item in the actual list.
def getAccessoryIndex(index)
if @secondSelection
item=@list[index]
else
item=@list2[index]
end
arr=BASE_GRAPHICS if @accessoryNames[@index]=="skin"
arr=HAIR_ITEMS if @accessoryNames[@index]=="hair"
arr=TOP_ITEMS if @accessoryNames[@index]=="tops"
arr=SHOE_ITEMS if @accessoryNames[@index]=="footwear"
arr=BOTTOM_ITEMS if @accessoryNames[@index]=="bottoms"
arr=EYEWEAR_ITEMS if @accessoryNames[@index]=="eyewear"
arr=HEADGEAR_ITEMS if @accessoryNames[@index]=="headgear"
arr=ACCESSORY_ITEMS if @accessoryNames[@index]=="accessories"
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
endname=(getAccessoryIndex(@cmdwindow2.index)).to_s+($PokemonGlobal.playerID+65).chr
name="overworld walk/"+@accessoryNames[@index]+"/"+endname
if File.exists?("Graphics/Characters/"+name+".png")
@sprites["playerAccessory"].charset=name
end
end
# returns the index of the variant in the actual list.
def getAccessoryIndex2
item=@list[@cmdwindow2.index]
arr=BASE_GRAPHICS if @accessoryNames[@index]=="skin"
arr=HAIR_ITEMS if @accessoryNames[@index]=="hair"
arr=TOP_ITEMS if @accessoryNames[@index]=="tops"
arr=SHOE_ITEMS if @accessoryNames[@index]=="footwear"
arr=BOTTOM_ITEMS if @accessoryNames[@index]=="bottoms"
arr=EYEWEAR_ITEMS if @accessoryNames[@index]=="eyewear"
arr=HEADGEAR_ITEMS if @accessoryNames[@index]=="headgear"
arr=ACCESSORY_ITEMS if @accessoryNames[@index]=="accessories"
arr2=arr[getAccessoryIndex(@indexR)][1]
for i in 0...arr2.length
return i if arr2[i][0]==item
end
end
# Another method for updating the Accessory bitmap
def updateAccessoryBitmap2
@sprites["playerAccessory"].bitmap.clear
frontname="overworld walk/"+@accessoryNames[@index]+"/"+(getAccessoryIndex(@indexR)).to_s
name=frontname+"/"+(getAccessoryIndex2).to_s+($PokemonGlobal.playerID+65).chr
if File.exists?("Graphics/Characters/"+name+".png")
@sprites["playerAccessory"].charset=name
end
end
# returns the list of the right hand command box.
def retListCmdBox2
@list=BASE_GRAPHICS if @index==0
@list=HAIR_ITEMS if @index==1
@list=TOP_ITEMS if @index==2
@list=SHOE_ITEMS if @index==3
@list=BOTTOM_ITEMS if @index==4
@list=EYEWEAR_ITEMS if @index==5
@list=HEADGEAR_ITEMS if @index==6
@list=ACCESSORY_ITEMS if @index==7
if @secondSelection==true
@list=retUnlockedAccessoryArray(cnvrtStrArr(@list))
@list=["---NONE---"] if !@list
@list.push("Back") if [email protected]?("Back")
else
@list2=retUnlockedAccessoryArray(cnvrtStrArr(@list))
@list2=["---NONE---"] if !@list2
@list2.push("Back") if [email protected]?("Back")
@list=retUnlockedAccessoryArray2(cnvrtStrArr(@list),getAccessoryIndex(@indexR))
@list=["---NONE---"] if !@list
@list.push("Back") if [email protected]?("Back")
end
return @list
end
#checks whether or not the currently selected item within the list has any variants
def hasVariants
ret=false
name=@list[@cmdwindow2.index]
#Get name of item that is current hovered over
arr=retArrayAndNumber(name,false)
bodypart=arr[0]
#Access original array to check whether or not item has variants.
for i in 0...bodypart.length
if bodypart[i][0][$PokemonGlobal.playerID]==name
ret=((bodypart[i][1] == true) || (bodypart[i][1] == false))
end
end
return !ret
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.y=0
@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
@[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
@index=@sprites["cmdwindow"].index
else
@cmdwindow2.update
end
if indexChanged
updateHeading2
end
if @selectionChange
updateHeading2
if @secondSelection
@cmdwindow2.index=@indexR
else
@cmdwindow2.index=0
end
@selectionChange=false
end
if @secondSelection
if cmdWindow2IndexChanged && @cmdwindow2.index != -1
if !(@cmdwindow2.index==(@cmdwindow2.itemCount-1)) && !hasVariants
@sprites["window2"].visible=true
@sprites["playerAccessory"].visible=true
$PokemonTemp.savedoutfit = true
updateAccessoryBitmap #if @cmdwindow2.index != @cmdwindow2.
$PokemonTemp.savedoutfit = false
else
@sprites["window2"].visible=false
@sprites["playerAccessory"].visible=false
end
end
elsif cmdWindow2IndexChanged && @cmdwindow2.index != -1
if !(@cmdwindow2.index==(@cmdwindow2.itemCount-1))
@sprites["window2"].visible=true
@sprites["playerAccessory"].visible=true
$PokemonTemp.savedoutfit = true
updateAccessoryBitmap2 #if @cmdwindow2.index != @cmdwindow2.
$PokemonTemp.savedoutfit = false
else
@sprites["window2"].visible=false
@sprites["playerAccessory"].visible=false
end
end
if Input.trigger?(Input::C)
# Pressing C on the left command box.
if @firstSelection
@cmdwindow2.index=0
@firstSelection=false
if !hasVariants
@sprites["window2"].visible=true
@sprites["playerAccessory"].visible=true
end
elsif @secondSelection
# Pressing C on the right command box, first choice
if @cmdwindow2.index==(@cmdwindow2.itemCount-1) # Cancel
@cmdwindow2.index=-1; @cmdwindow2.update
@firstSelection=true
@sprites["window2"].visible=false
@sprites["playerAccessory"].visible=false
elsif !hasVariants
$PokemonTemp.savedoutfit = true
changeClothes
$PokemonTemp.savedoutfit = false
@sprites["player"].bitmap.clear
@sprites["player"].charset=$game_player.character_name
@selectionMade=true
else
@[email protected]
@secondSelection=false
@selectionChange=true
@sprites["window2"].visible=true
@sprites["playerAccessory"].visible=true
end
# Pressing C on the left command box, second choice
else
if @cmdwindow2.index==(@cmdwindow2.itemCount-1) # Cancel
@cmdwindow2.index=@indexR; @cmdwindow2.update
@secondSelection=true
@selectionChange=true
@sprites["window2"].visible=false
@sprites["playerAccessory"].visible=false
else
$PokemonTemp.savedoutfit = true
changeClothes
$PokemonTemp.savedoutfit = false
@sprites["player"].bitmap.clear
@sprites["player"].charset=$game_player.character_name
@selectionMade=true
end
end
end
if Input.trigger?(Input::B)
# cancels the scene.
if @firstSelection && Kernel.pbConfirmMessage("Have you finished? (The game will be saved)")
if pbSave
updateTrainerOutfit
pbSave
pbCommonEvent(7)
#pbMessage("You will need to run or reopen the game for the walking sprite to update.")
else
pbMessage("Outfit Trainer picture update failed.")
pbMessage("The walking sprites look normal, but some other sprites haven't been updated correctly.")
end
if @savegetup == true && @selectionMade == false
$PokemonTemp.savedoutfit = true
else
$PokemonTemp.savedoutfit = false
end
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
@cmdwindow2.index=@indexR; @cmdwindow2.update
@secondSelection=true
@selectionChange=true
@sprites["window2"].visible=false
@sprites["playerAccessory"].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
if @secondSelection
dressAccessory(@list[@cmdwindow2.index])
else
dressAccessory(@list2[@indexR],@list[@cmdwindow2.index])
end
#done
case @sprites["cmdwindow"].index
when 0
if @secondSelection
$Trainer.skin=[getAccessoryIndex(@cmdwindow2.index), -1]
else
$Trainer.skin=[getAccessoryIndex(@indexR), getAccessoryIndex2]
end
when 1
if @secondSelection
$Trainer.hair=[getAccessoryIndex(@cmdwindow2.index), -1]
else
$Trainer.hair=[getAccessoryIndex(@indexR), getAccessoryIndex2]
end
when 2
if @secondSelection
$Trainer.top=[getAccessoryIndex(@cmdwindow2.index), -1]
else
$Trainer.top=[getAccessoryIndex(@indexR), getAccessoryIndex2]
end
when 3
if @secondSelection
$Trainer.footwear=[getAccessoryIndex(@cmdwindow2.index), -1]
else
$Trainer.footwear=[getAccessoryIndex(@indexR), getAccessoryIndex2]
end
when 4
if @secondSelection
$Trainer.bottom=[getAccessoryIndex(@cmdwindow2.index), -1]
else
$Trainer.bottom=[getAccessoryIndex(@indexR), getAccessoryIndex2]
end
when 5
if @secondSelection
$Trainer.eyewear=[getAccessoryIndex(@cmdwindow2.index), -1]
else
$Trainer.eyewear=[getAccessoryIndex(@indexR), getAccessoryIndex2]
end
when 6
if @secondSelection
$Trainer.headgear=[getAccessoryIndex(@cmdwindow2.index), -1]
else
$Trainer.headgear=[getAccessoryIndex(@indexR), getAccessoryIndex2]
end
when 7
if @secondSelection
$Trainer.accessory=[getAccessoryIndex(@cmdwindow2.index), -1]
else
$Trainer.accessory=[getAccessoryIndex(@indexR), getAccessoryIndex2]
end
end
end
end
#===============================================================================
# Creates a method which chooses which Base Graphic to build their character on top of
#===============================================================================
class ChooseBase
def initialize
if !$PokemonTemp.savedoutfit
(if $DEBUG; p "Cannot pick base if outfit has already been edited"; end; return)
end
#Version 17.2 Difference Below
@commands=CommandMenuList.new
for i in 0...BASE_GRAPHICS.length
temp=BASE_GRAPHICS[i][$PokemonGlobal.playerID]
@commands.add("main",temp.downcase,_INTL(temp))
end
#Version 17.2 Difference Above
return false if !addBaseFiles
@index=0
@sprites={}
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites["window"]=SpriteWindow_Base.new(8,8,128,192)
@sprites["window2"]=SpriteWindow_Base.new(8,208,128,128)
@sprites["window"].z=1000
@sprites["window2"].z=1000
temp="/examples/0"+($PokemonGlobal.playerID+65).chr
@sprites["baseRep"]= IconSprite.new(0,0,@viewport)
@sprites["baseRep"].setBitmap("Graphics/Characters/base graphics"+temp)
@sprites["baseRep"].x=@sprites["window"].width/2-@sprites["baseRep"].bitmap.width/2 +8
@sprites["baseRep"].y=@sprites["window"].height/2-@sprites["baseRep"].bitmap.height/2 +8
@sprites["baseRep"].z=9999999
temp="/"+WALK_FOLDER+"/0"+($PokemonGlobal.playerID+65).chr
@sprites["walkSprite"]=TrainerWalkingCharSprite.new("base graphics"+temp,@viewport)
@sprites["walkSprite"].x=@sprites["window2"].width/2-@sprites["walkSprite"].bitmap.width/2 +8
@sprites["walkSprite"].y=@sprites["window2"].height/2-@sprites["walkSprite"].bitmap.height/2 +208
@sprites["walkSprite"].ox-=@sprites["walkSprite"].bitmap.width/8
@sprites["walkSprite"].oy-=@sprites["walkSprite"].bitmap.height/8
@sprites["walkSprite"].z=9999999
@sprites["walkSprite"].zoom_x=2
@sprites["walkSprite"].zoom_y=2
@sprites["heading"]=Window_CommandPokemonEx.new(["SKIN"])
@sprites["heading"].viewport=@viewport
@sprites["heading"].index=1
@sprites["heading"].x=Graphics.width-@sprites["heading"].width-8
charheight=@sprites["walkSprite"].bitmap.height
@y=[charheight/4*2,0,charheight/4,charheight/4*3]
@sprites["cmdwindow"]=Window_CommandPokemonEx.new(@commands.list)
@sprites["cmdwindow"].viewport=@viewport
@sprites["cmdwindow"].x=Graphics.width-@sprites["cmdwindow"].width
@sprites["cmdwindow"].y=@sprites["heading"].height+8
@sprites["cmdwindow"].z=999999
@sprites["cmdwindow"].index=0
looping
end
def addBaseFiles
files=[]
metadata=pbLoadMetadata
filenames=metadata[0][MetadataPlayerA+$PokemonGlobal.playerID]
root="Graphics/Characters/base graphics/"
# Trainer backsprite
for j in [email protected]
name=SPRITE_CONVERT_HASH["#{$game_player.character_name}"]
files.push(root+name+"/#{j}"+($PokemonGlobal.playerID+65).chr)
end
# Creating a blank bitmap
size_check=Bitmap.new("Graphics/Characters/#{$game_player.character_name}")
blank_bitmap=Bitmap.new(size_check.width,size_check.height)
size_check=Bitmap.new("Graphics/Pictures/#{$game_player.character_name}g")
blank_bitmap=Bitmap.new(size_check.width,size_check.height)
# Pushing non existent files into the files_to_add array.
files_to_add=[]
for i in 0...files.length
if !File.exists?(files[i]+".png")
files_to_add.push(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/base graphics/ 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
def saveBase(filepath,folder)
return if !$Trainer
return if !filepath.is_a?(String) || !folder.is_a?(String)
name="Graphics/Characters/base graphics/"+folder+"/"+(@sprites["cmdwindow"].index).to_s
if File.exists?(name+($PokemonGlobal.playerID+65).chr+".png")
bmp=Bitmap.new(name+($PokemonGlobal.playerID+65).chr)
else
# Creating a blank bitmap
size_check=Bitmap.new("Graphics/Characters/#{$game_player.character_name}")
bmp=Bitmap.new(size_check.width,size_check.height)
end
# Safety Copy
if !File.exists?(filepath+"_safetyCopy"+".png") && $DEBUG
safetyCopy=Bitmap.new(filepath)
safetyCopy.saveToPng(filepath+"_safetyCopy"+".png")
end
bmp.saveToPng(filepath+".png")
bmp.saveToPng(filepath+"_base.png")
end
def saveAllBases
return if !$Trainer
# Trainer charsets
metadata=pbLoadMetadata
filenames=metadata[0][MetadataPlayerA+$PokemonGlobal.playerID]
for i in 0...filenames.length
if filenames[i].is_a?(String) && !(filenames[i]=="xxx")
filepath="Graphics/Characters/#{filenames[i]}"
folder=SPRITE_CONVERT_HASH[filenames[i]]
saveBase(filepath,folder)
end
end
# Trainer frontsprite
helpr="trainer00#{$PokemonGlobal.playerID}"
filepath="Graphics/Trainers/"
folder=SPRITE_CONVERT_HASH[helpr]
saveBase(filepath+helpr,folder)
# Trainer backsprite
helpr="trback00#{$PokemonGlobal.playerID}"
filepath="Graphics/Trainers/"
folder=SPRITE_CONVERT_HASH[helpr]
saveBase(filepath+helpr,folder)
# Intro Image/Trainercard Image
filepath="Graphics/Pictures/"
helpr=$Trainer.isFemale? ? "introGirl" : "introBoy" #Modify this line if you want more than two characters.
folder=SPRITE_CONVERT_HASH[helpr]
saveBase(filepath+helpr,folder)
# Map Player
helpr="mapPlayer00#{$PokemonGlobal.playerID}"
folder=SPRITE_CONVERT_HASH[helpr]
saveBase(filepath+helpr,folder)
end
def looping
frame=0
@dir=0
loop do
frame+=1
pos=0
Graphics.update
Input.update
@sprites["baseRep"].update
@sprites["walkSprite"].update
@sprites["cmdwindow"].update
if @sprites["cmdwindow"].index != @index
@index=@sprites["cmdwindow"].index
newname="examples/"+(@sprites["cmdwindow"].index).to_s+($PokemonGlobal.playerID+65).chr
if File.exists?("Graphics/Characters/base graphics/"+newname+".png")
@sprites["baseRep"].name=("Graphics/Characters/base graphics/"+newname)
end
newname=WALK_FOLDER+"/"+(@sprites["cmdwindow"].index).to_s+($PokemonGlobal.playerID+65).chr
if File.exists?("Graphics/Characters/base graphics/"+newname+".png")
@sprites["walkSprite"].charset=("base graphics/"+newname)
end
end
if Input.trigger?(Input::C) && Kernel.pbConfirmMessage("So you're choosing #{@commands.list[@index]}?")
saveAllBases
pbDisposeSpriteHash(@sprites)
updateTrainerOutfit
break
end
if frame%120==0
@dir+=1
@sprites["walkSprite"].src_rect.y=@y[@dir%4]
end
end
end
end
#Script 2
#===============================================================================
# * Character Costumization by Wolf Heretic
# * Based Heavily on a script by shiney570
# Version: 2.0.0
#===============================================================================
# This part of the script focuses mostly on how outfits customized are saved as
# well as various functions used throughout the script. Includes (In Order):
# - Utility methods
# - Initial saving of outfit
# - Permanent Save of outfit when player saves game
# - Edits how metadata is called to help distinguish between saved and non-saved
# outfits.
# - Edits png extention
#
#
#==================================================================================
# *Utility Methods used throughout this script
#==================================================================================
# Given a string and a bool, returns an array and a var representing the array number.
# accessory: A string representing an item in the array that the user wants to access.
# convertation: A Bool which determines whether or not the names specific to a
# players gender are returned (true), or the entire array (false).
def retArrayAndNumber(accessory,convertation=true)
(bodypart=BASE_GRAPHICS; var=1) if cnvrtStrArr(BASE_GRAPHICS).include?(accessory)
(bodypart=HAIR_ITEMS; var=2) if cnvrtStrArr(HAIR_ITEMS).include?(accessory)
(bodypart=TOP_ITEMS; var=3) if cnvrtStrArr(TOP_ITEMS).include?(accessory)
(bodypart=SHOE_ITEMS; var=4) if cnvrtStrArr(SHOE_ITEMS).include?(accessory)
(bodypart=BOTTOM_ITEMS; var=5) if cnvrtStrArr(BOTTOM_ITEMS).include?(accessory)
(bodypart=EYEWEAR_ITEMS; var=6) if cnvrtStrArr(EYEWEAR_ITEMS).include?(accessory)
(bodypart=HEADGEAR_ITEMS; var=7) if cnvrtStrArr(HEADGEAR_ITEMS).include?(accessory)
(bodypart=ACCESSORY_ITEMS; var=8) if cnvrtStrArr(ACCESSORY_ITEMS).include?(accessory)
return [cnvrtStrArr(bodypart),var] if convertation
return [bodypart,var]
end
# Returns a boolean indicating if the character can be customized given settings
# set by the creator and the player's current state.
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.hair
return false
end
# Creates a new array from the items specific to the player's gender.
# array: An array representing the options for a specific component of the outfit
# characterization of the character (ie. HAIR_ITEMS)
def cnvrtStrArr(array)
ret=[]
for i in 0...array.length
ret.push(array[i][0][$PokemonGlobal.playerID])
end
return ret
end
#cnvrtBoolArr: Creates a new array with only the booleans which define the items within the array.
#array: An array representing the options for a specific component of the outfit characterization of the character (ie. HAIR_ITEMS)
#output: A boolean array representing which items within the component array are locked and unlocked; represented by booleans.
def cnvrtBoolArr(array)
ret=[]
for i in 0...array.length
if ((array[i][1] == true) || (array[i][1] == false))
ret.push(array[i][1])
else
ret[i]=[]
for j in 0...array[i][1].length
ret[i].push(array[i][1][j][1])
end
end
end
return ret
end
#Creates a new array with only the unlocked elements of the given array.
#clothes: One of the arrays defining the gendered items and properties for
# a specific attribute (ie. cnvrtStrArr(HEADGEAR_ITEMS))
def retUnlockedAccessoryArray(clothes)
arr=retArrayAndNumber(clothes[0])
var=arr[1]
ret=[]
for i in 0...clothes.length
if ($Trainer.clothesUnlocking[var-1][i]==false || $Trainer.clothesUnlocking[var-1][i]==true)
ret.push clothes[i] if $Trainer.clothesUnlocking[var-1][i]==true
else
check=false
for j in 0...$Trainer.clothesUnlocking[var-1][i].length
check=(check||$Trainer.clothesUnlocking[var-1][i][j])
end
ret.push clothes[i] if check
end
end
return ret
end
#Creates a new array with only the unlocked elements of the given array.
#clothes: One of the arrays defining the gendered items and properties for
# a specific attribute (ie. cnvrtStrArr(HEADGEAR_ITEMS))
def retUnlockedAccessoryArray2(clothes,itemnum)
arr=retArrayAndNumber(clothes[0],false)
pbMessage(_INTL("{1}",arr))
pbMessage(_INTL("{1}",arr[0][itemnum][1]))
var=arr[1]
ret=[]
for i in 0...arr[0][itemnum][1].length
if $Trainer.clothesUnlocking[var-1][itemnum][i]
ret.push arr[0][itemnum][1][i][0]
end
end
return ret
end
#Fetches the file names corresponding to a given array.
#files: An array where all the file names will be stored. Should be the empty array initially
#array: An array of clothing items (ie. HAIR_ITEMS)
#folder: The folder from which these file names will correspond to.
def individualArrayFiles(files,array,folder)
for i in 0...array.length
if ((array[i][1] == true) || (array[i][1] == false))
files.push(folder+"/#{i}"+($PokemonGlobal.playerID+65).chr)
else
for j in 0...array[i][1].length
files.push(folder+"/#{i}/#{j}"+($PokemonGlobal.playerID+65).chr)
end
end
end
end
# checks whether or not an inputed array is multi-dimensional at a given index.
# arr: An array of clothing items (ie. HAIR_ITEMS)
# num: The index numberof a specific item in the array.
# single(optional): if true, checks if index at given array is singular, otherwise
# checks if not singular.
def checkAccessory(arr,num,single=true)
if (arr[num][1]==true)||(arr[num][1]==false)
return (false^single)
else
return (true^single)
end
end
# helperfunction for randomizing outfit.
# bodypart: number corresponding to the specific bodypart array desired.
def randomizeOutfitHelper(bodypart)
arr=BASE_GRAPHICS if bodypart==0
arr=HAIR_ITEMS if bodypart==1
arr=TOP_ITEMS if bodypart==2
arr=SHOE_ITEMS if bodypart==3
arr=BOTTOM_ITEMS if bodypart==4
arr=EYEWEAR_ITEMS if bodypart==5
arr=HEADGEAR_ITEMS if bodypart==6
arr=ACCESSORY_ITEMS if bodypart==7
fv=rand(arr.length)
if checkAccessory(arr,fv)
case bodypart
when 0
$Trainer.skin=[fv, -1]
when 1
$Trainer.hair=[fv, -1]
when 2
$Trainer.top=[fv, -1]
when 3
$Trainer.footwear=[fv, -1]
when 4
$Trainer.bottom=[fv, -1]
when 5
$Trainer.eyewear=[fv, -1]
when 6
$Trainer.headgear=[fv, -1]
when 7
$Trainer.accessory=[fv, -1]
end
else
case bodypart
when 0
$Trainer.skin=[fv, rand(arr[fv][1].length)]
when 1
$Trainer.hair=[fv, rand(arr[fv][1].length)]
when 2
$Trainer.top=[fv, rand(arr[fv][1].length)]
when 3
$Trainer.footwear=[fv, rand(arr[fv][1].length)]
when 4
$Trainer.bottom=[fv, rand(arr[fv][1].length)]
when 5
$Trainer.eyewear=[fv, rand(arr[fv][1].length)]
when 6
$Trainer.headgear=[fv, rand(arr[fv][1].length)]
when 7
$Trainer.accessory=[fv, rand(arr[fv][1].length)]
end
end
end
#===============================================================================
# * Drawing the customized Bitmap
#===============================================================================
# Method to add an additional bitmap to another 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
#Draws a specific bitmap for the player sprite.
def drawCharacterCustomizedBitmap(folder,bmp,trainerClass=$Trainer)
return nil if !folder.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
oldfilepath = "Graphics/Characters/"+folder+"/"
# Adding Skin Bitmap
if trainerClass.skin[1] == -1
addAdditionalBitmap(oldfilepath+"skin/"+(trainerClass.skin[0]).to_s+
($PokemonGlobal.playerID+65).chr+".png",bmp)
else
addAdditionalBitmap(oldfilepath+"skin/"+(trainerClass.skin[0]).to_s+
"/"+(trainerClass.skin[1]).to_s+($PokemonGlobal.playerID+65).chr+".png",bmp)
end
# Adding Footwear Bitmap
if trainerClass.footwear[1] == -1
addAdditionalBitmap(oldfilepath+"footwear/"+(trainerClass.footwear[0]).to_s+
($PokemonGlobal.playerID+65).chr+".png",bmp)
else
addAdditionalBitmap(oldfilepath+"footwear/"+(trainerClass.footwear[0]).to_s+
"/"+(trainerClass.footwear[1]).to_s+($PokemonGlobal.playerID+65).chr+".png",bmp)
end
# Adding Bottom Bitmap
if trainerClass.bottom[1] == -1
addAdditionalBitmap(oldfilepath+"bottoms/"+(trainerClass.bottom[0]).to_s+
($PokemonGlobal.playerID+65).chr+".png",bmp)
else
addAdditionalBitmap(oldfilepath+"bottoms/"+(trainerClass.bottom[0]).to_s+
"/"+(trainerClass.bottom[1]).to_s+($PokemonGlobal.playerID+65).chr+".png",bmp)
end
# Adding Top Bitmap
if trainerClass.top[1] == -1
addAdditionalBitmap(oldfilepath+"tops/"+(trainerClass.top[0]).to_s+
($PokemonGlobal.playerID+65).chr+".png",bmp)
else
addAdditionalBitmap(oldfilepath+"tops/"+(trainerClass.top[0]).to_s+
"/"+(trainerClass.top[1]).to_s+($PokemonGlobal.playerID+65).chr+".png",bmp)
end
# Adding Accessory Bitmap
if trainerClass.accessory[1] == -1
addAdditionalBitmap(oldfilepath+"accessories/"+(trainerClass.accessory[0]).to_s+
($PokemonGlobal.playerID+65).chr+".png",bmp)
else
addAdditionalBitmap(oldfilepath+"accessories/"+(trainerClass.accessory[0]).to_s+
"/"+(trainerClass.accessory[1]).to_s+($PokemonGlobal.playerID+65).chr+".png",bmp)
end
# Adding Hair Bitmap
if trainerClass.hair[1] == -1
addAdditionalBitmap(oldfilepath+"hair/"+(trainerClass.hair[0]).to_s+
($PokemonGlobal.playerID+65).chr+".png",bmp)
else
addAdditionalBitmap(oldfilepath+"hair/"+(trainerClass.hair[0]).to_s+
"/"+(trainerClass.hair[1]).to_s+($PokemonGlobal.playerID+65).chr+".png",bmp)
end
# Adding eyewear Bitmap
if trainerClass.eyewear[1] == -1
addAdditionalBitmap(oldfilepath+"eyewear/"+(trainerClass.eyewear[0]).to_s+
($PokemonGlobal.playerID+65).chr+".png",bmp)
else
addAdditionalBitmap(oldfilepath+"eyewear/"+(trainerClass.eyewear[0]).to_s+
"/"+(trainerClass.eyewear[1]).to_s+($PokemonGlobal.playerID+65).chr+".png",bmp)
end
# Adding Headgear Bitmap
if trainerClass.headgear[1] == -1
addAdditionalBitmap(oldfilepath+"headgear/"+(trainerClass.headgear[0]).to_s+
($PokemonGlobal.playerID+65).chr+".png",bmp)
else
addAdditionalBitmap(oldfilepath+"headgear/"+(trainerClass.headgear[0]).to_s+
"/"+(trainerClass.headgear[1]).to_s+($PokemonGlobal.playerID+65).chr+".png",bmp)
end
end
# saves a specific bitmap to a given folder.
def saveCustomizedBitmapToFolder(filepath,folder)
return if !$Trainer
return if !filepath.is_a?(String) || !folder.is_a?(String)
if !USE_BASE_GRAPHIC
bmp=Bitmap.new(filepath)
else
bmp=Bitmap.new(filepath+"_base")
end
# 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(folder,bmp)
bmp.saveToPng(filepath+"_curr.png")
end
# saves the costumized bitmaps to the actual game folders.
def saveAllCustomizedBitmapsToFolder
return if !$Trainer
# Trainer charsets
metadata=pbLoadMetadata
filenames=metadata[0][MetadataPlayerA+$PokemonGlobal.playerID]
#pbMessage(_INTL("{1}",filenames))
for i in 0...filenames.length
if filenames[i].is_a?(String) && !(filenames[i]=="xxx")
filepath="Graphics/Characters/#{filenames[i]}"
folder=SPRITE_CONVERT_HASH[filenames[i]]
saveCustomizedBitmapToFolder(filepath,folder)
end
end
# Trainer frontsprite
helpr="trainer00#{$PokemonGlobal.playerID}"
filepath="Graphics/Trainers/"
folder=SPRITE_CONVERT_HASH[helpr]
saveCustomizedBitmapToFolder(filepath+helpr,folder)
# Trainer backsprite
helpr="trback00#{$PokemonGlobal.playerID}"
filepath="Graphics/Trainers/"
folder=SPRITE_CONVERT_HASH[helpr]
saveCustomizedBitmapToFolder(filepath+helpr,folder)
# Intro Image/Trainercard Image
filepath="Graphics/Pictures/"
helpr=$Trainer.isFemale? ? "introGirl" : "introBoy" #Modify this line if you want more than two characters.
folder=SPRITE_CONVERT_HASH[helpr]
saveCustomizedBitmapToFolder(filepath+helpr,folder)
# Map Player
helpr="mapPlayer00#{$PokemonGlobal.playerID}"
folder=SPRITE_CONVERT_HASH[helpr]
saveCustomizedBitmapToFolder(filepath+helpr,folder)
end
#===============================================================================
# Creates a method which saves a character's outfit permanently when the game is saved.
#===============================================================================
#Saves a specific outfit when pbSave is called.
def saveOutfit(filepath)
if (File.exists?(filepath+".png") && File.exists?(filepath+"_curr.png"))
File.delete(filepath+".png")
bmp=Bitmap.new(filepath+"_curr.png")
bmp.saveToPng(filepath+".png")
else
if $DEBUG
p "ERROR: Unable to save file at #{filepath}"
end
end
return
end
#Saves all of the outfits when pbSave is called.
def saveAllOutfits
return if !$Trainer
$PokemonTemp.savedoutfit = true
if !reqFilesExist
if $DEBUG
p "Unable to replace files. One of the neccessary files does not exist"
end
$PokemonTemp.savedoutfit = false
return
end
metadata=pbLoadMetadata
filepath="Graphics/Characters/"
filenames=metadata[0][MetadataPlayerA+$PokemonGlobal.playerID]
for i in 0...filenames.length
if filenames[i].is_a?(String) && !(filenames[i]=="xxx")
saveOutfit(filepath+filenames[i])
end
end
# Trainer frontsprite
saveOutfit("Graphics/Trainers/trainer00#{$PokemonGlobal.playerID}")
# Trainer backsprite
saveOutfit("Graphics/Trainers/trback00#{$PokemonGlobal.playerID}")
# Intro Image/Trainercard Image
filepath="Graphics/Pictures/"
filepath+= $Trainer.isFemale? ? "introGirl" : "introBoy"
saveOutfit(filepath)
# Map Player
saveOutfit("Graphics/Pictures/mapPlayer00#{$PokemonGlobal.playerID}")
return
end
#Checks to see if all of the required files exist before trying to save all of the outfits.
def reqFilesExist
# Trainer charsets
metadata=pbLoadMetadata
filenames=metadata[0][MetadataPlayerA+$PokemonGlobal.playerID]
for i in 0...filenames.length
if filenames[i].is_a?(String) && !(filenames[i]=="xxx")
if !File.exists?("Graphics/Characters/#{filenames[i]}.png")
return false
end
if !File.exists?("Graphics/Characters/#{filenames[i]}"+"_curr.png")
return false
end
end
end
# Trainer frontsprite
filepath="Graphics/Trainers/trainer00#{$PokemonGlobal.playerID}"
if (!File.exists?(filepath+".png") || !File.exists?(filepath+"_curr.png"))
return false
end
# Trainer backsprite
filepath="Graphics/Trainers/trback00#{$PokemonGlobal.playerID}"
if (!File.exists?(filepath+".png") || !File.exists?(filepath+"_curr.png"))
return false
end
# Intro Image/Trainercard Image
filepath="Graphics/Pictures/"
filepath+= $Trainer.isFemale? ? "introGirl" : "introBoy"
if (!File.exists?(filepath+".png") || !File.exists?(filepath+"_curr.png"))
return false
end
# Map Player
filepath="Graphics/Pictures/mapPlayer00#{$PokemonGlobal.playerID}"
if (!File.exists?(filepath+".png") || !File.exists?(filepath+"_curr.png"))
return false
end
return true
end
#==============================================================================================
# Influences how the metadata is called so that an outfit is temporarily stored when changed.
#==============================================================================================
def pbGetMetadata(mapid,metadataType)
meta=pbLoadMetadata
if (mapid == 0) && (metadataType >= MetadataPlayerA) && (metadataType < MetadataPlayerA+7) && ($PokemonTemp.savedoutfit == false)
ret=[]
ret.push(meta[mapid][metadataType][0])
for i in 1...meta[mapid][metadataType].length
ret.push(meta[mapid][metadataType][i]+"_curr")
end
return ret
else
return meta[mapid][metadataType] if meta[mapid]
return nil
end
end
def pbTrainerHeadFile(type)
return nil if !type
bitmapFileName = sprintf("Graphics/Pictures/mapPlayer%s",getConstantName(PBTrainers,type)) rescue nil
if !pbResolveBitmap(bitmapFileName) && $PokemonTemp.savedoutfit
bitmapFileName = sprintf("Graphics/Pictures/mapPlayer%03d",type)
elsif !pbResolveBitmap(bitmapFileName)
sprintf("Graphics/Pictures/mapPlayer%03d_curr",type)
end
return bitmapFileName
end
def pbTrainerSpriteFile(type)
return nil if !type
bitmapFileName = sprintf("Graphics/Trainers/trainer%s",getConstantName(PBTrainers,type)) rescue nil
if !pbResolveBitmap(bitmapFileName) && $PokemonTemp.savedoutfit
bitmapFileName = sprintf("Graphics/Trainers/trainer%03d",type)
elsif !pbResolveBitmap(bitmapFileName)
bitmapFileName = sprintf("Graphics/Trainers/trainer%03d_curr",type)
end
return bitmapFileName
end
def pbTrainerSpriteBackFile(type)
return nil if !type
bitmapFileName = sprintf("Graphics/Trainers/trback%s",getConstantName(PBTrainers,type)) rescue nil
if !pbResolveBitmap(bitmapFileName) && $PokemonTemp.savedoutfit
bitmapFileName = sprintf("Graphics/Trainers/trback%03d",type)
elsif !pbResolveBitmap(bitmapFileName)
bitmapFileName = sprintf("Graphics/Trainers/trback%03d_curr",type)
end
return bitmapFileName
end
#===============================================================================
# * Edit to the pbSave function to make sure outfit is saved for future load.
#===============================================================================
def pbSave(safesave=false)
$Trainer.metaID=$PokemonGlobal.playerID
if $PokemonTemp.savedoutfit == false #ADDED CODE
saveAllOutfits #ADDED CODE
end
begin
File.open(RTP.getSaveFileName("Game#{checkSaveSlot}.rxdata"),"wb"){|f|#danbacondude
Marshal.dump($Trainer,f)
Marshal.dump(Graphics.frame_count,f)
if $data_system.respond_to?("magic_number")
$game_system.magic_number = $data_system.magic_number
else
$game_system.magic_number = $data_system.version_id
end
$game_system.save_count+=1
Marshal.dump($game_system,f)
Marshal.dump($PokemonSystem,f)
Marshal.dump($game_map.map_id,f)
Marshal.dump($game_switches,f)
Marshal.dump($game_variables,f)
Marshal.dump($game_self_switches,f)
Marshal.dump($game_screen,f)
Marshal.dump($MapFactory,f)
Marshal.dump($game_player,f)
$PokemonGlobal.safesave=safesave
Marshal.dump($PokemonGlobal,f)
Marshal.dump($PokemonMap,f)
Marshal.dump($PokemonBag,f)
Marshal.dump($PokemonStorage,f)
}
Graphics.frame_reset
rescue
return false
end
return true
end
#===============================================================================
# * Edit to the class Game_Player to erase the .png extension in the name.
#===============================================================================
=begin
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
=end