WolfHeretic

CharacterCust_Main

Sep 3rd, 2020 (edited)
9,295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.30 KB | None | 0 0
  1. #===============================================================================
  2. # * Character Costumization by Wolf Heretic
  3. # * Based Heavily on a script by shiney570
  4. # Version: 2.0.0
  5. #===============================================================================
  6. #
  7. # NOTES:
  8. # - Do not name two different items the same name. (Ie. If I have a headgear item
  9. # called Ring and an accessory called Ring, this will lead to undefined behavior
  10. # and could make your game crash)
  11. # - You cannot lock all of the items for some bodypart. This will cause the game
  12. # to crash in the characterization screen.
  13. # - This script alters how a character's metadata is called and how the game loads
  14. # and saves data. Be aware of this ifyou're using other scripts which edit these
  15. # aspects of default essentials.
  16. # - pbChooseBaseGraphic should only be called after the player's character (In
  17. # default essentials gender) and name are defined.
  18. #
  19. # Set to false to disable the Character Customization.
  20. CHARACTER_CUSTOMIZATION = true
  21. # Set to false to lock the Character Customization to unlock it manually at a
  22. # point later in the game.
  23. UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT = true
  24. # whether to also fusion the base graphic or not. Remember:
  25. USE_BASE_GRAPHIC = true
  26.  
  27. =begin
  28. ROUGH EXPLANATION FOR CLOTHING ARRAYS:
  29. When setting up the arrays below, its important to note the following structure
  30. of the arrays representing the possible costumes a player can equip.
  31.  
  32. 1. The initial array describes the Bodypart (ie. Hair, Top, Accessories).
  33. It is an array which is made up of multiple "Items", or subarrays representing
  34. each item that can be equipped by the player.
  35.  
  36. 2. The second layer describes each item (Ie. For Headgear, the items could be
  37. glasses, a tophat, and a helmet). Each item is an array with two entries, the
  38. "Names" of the item for each character(in default essentials each gender) and
  39. either a "Variant" array representing the different types/colors of the item the
  40. player can equip or a boolean representing whether the item is unlocked by default.
  41. a. Names: An array of strings representing the names of an item for different
  42. characters. The number of names in this array should equal the number
  43. of characters your game has. In default essentials, there are two characters (Male character
  44. & female), so if you haven't changed that there should be two names in this array.
  45. b. Variant: Is optional. If the player only wants one version of the item, instead
  46. of writing an array they should write either true or false for whether they want
  47. the item initially unlocked. Variant is explained in more detail next.
  48.  
  49. 3. The third layer describes each variant of the previous item, if there is more
  50. than one (Ie. If the item selected was a T-shirt, then the variants could be Blue,
  51. Red, Yellow, etc. for each color of the T-shirt). Each variant array consists of
  52. the name of the variant and a boolean representing whether the variant of that
  53. item is unlocked by default.
  54. a. Name: The name of the variant (ie. "Orange"). Should be a string.
  55. b. Unlocked?: A true or false value representing whether or not this specific
  56. variant should be unlocked initially.
  57.  
  58. Also here's a diagram for what everything all of the items consist of
  59.  
  60. [ Bodypart ]
  61. ||
  62. \/
  63. [Item[0], Item[1],...]
  64. ||
  65. \/
  66. [Names, Variants(Optional)]
  67. || ||
  68. \/ \/
  69. [BoyName,GirlName] [Variant[0], Variant[1],...]
  70. (Default Essentials) ||
  71. \/
  72. [Name, Unlocked?]
  73.  
  74. Hope this helped! If not then maybe you can get something from the initial
  75. arrays down below.
  76.  
  77. =end
  78.  
  79. # Names of the hairstyles in order. (true= unlocked by default, false=locked by default)
  80. HAIR_ITEMS=[
  81. [["Bald", "Bald"], true],
  82. [["Spiky","Long"], [["Blonde",true],["Hazel",true],["Brown",true],["Black",true],
  83. ["Grey",false],["Red",false],["Purple",false]]],
  84. [["Combed","Ponytail"], [["Blonde",true],["Hazel",true],["Brown",true],["Black",true],
  85. ["Grey",false],["Red",false],["Purple",false]]],
  86. [["Bowlcut","Bangs"], [["Blonde",true],["Hazel",true],["Brown",true],["Black",true],
  87. ["Grey",false],["Red",false],["Purple",false]]],
  88. [["Short","Short"], [["Blonde",true],["Hazel",true],["Brown",true],["Black",true],
  89. ["Grey",false],["Red",false],["Purple",false]]]
  90. ]
  91.  
  92. # Names of the top items in order. (true= unlocked by default, false=locked by default)
  93. TOP_ITEMS=[
  94. [["No Top","No Top"],true],
  95. [["Shirt", "Shirt"], [["Red", true], ["Orange",true], ["Yellow",true],["Green",true],
  96. ["Blue",true],["Purple",true]]],
  97. [["Sweater","Sweater"], true],
  98. [["Suit Top", "Dress"], [["Red", false],["Blue", false],["Green", false]]],
  99. [["Classic Top", "Classic Top"], [["Gen 1 Top", true], ["Gen 2 Top", false],
  100. ["Gen 3 Top", true], ["Gen 4 Top", false]]]
  101. ]
  102.  
  103. # Names of the bottoms in order. (true= unlocked by default, false=locked by default)
  104. BOTTOM_ITEMS=[
  105. [["No Bottom","No Bottom"],true],
  106. [["Sweatpants","Sweatpants"],[["Red", true], ["Orange",true], ["Yellow",true],["Green",true],
  107. ["Blue",true],["Purple",true]]],
  108. [["Jeans","Jeans"],true],
  109. [["Suit Bottom", "Tights & Shoes"], false],
  110. [["Classic Bottoms", "Classic Bottoms"], [["Gen 1 Bottom", true],
  111. ["Gen 2 Bottom", false], ["Gen 3 Bottom", true], ["Gen 4 Bottom", false]]]
  112. ]
  113.  
  114. # Names of the headgear in order. (true= unlocked by default, false=locked by default)
  115. HEADGEAR_ITEMS=[
  116. [["No Headgear", "No Headgear"], true],
  117. [["Glasses", "Glasses"], [["Black",true],["Red",true],["Blue",true]]],
  118. [["Classic Hat", "Classic Hat"], [["Gen 1 Hat", true], ["Gen 2 Hat", false],
  119. ["Gen 3 Hat", true], ["Gen 4 Hat", false]]],
  120. [["Hiker Hat", "Hiker Hat"], true],
  121. [["Headband", "Headband"], false]
  122. ]
  123.  
  124. # Names of the accessories in order. (true= unlocked by default, false=locked by default)
  125. ACCESSORY_ITEMS=[
  126. [["No Accessory", "No Accessory"],true],
  127. [["Book Bag", "Book Bag"],true],
  128. [["Satchel", "Satchel"], true],
  129. [["Fanny Pack", "Fanny Pack"], true]
  130. ]
  131.  
  132. #==================================================================================
  133. #This section defines the Base graphic names with a double array. Each item in the
  134. # initial array represents each base, while the number of items in those base arrays
  135. # is the base name for each character (In default essentials, for boy and girl).
  136. BASE_GRAPHICS=[
  137. ["Pale","Pale"],
  138. ["Fair","Fair"],
  139. ["Tanned","Tanned"],
  140. ["Dark","Dark"]
  141. ]
  142.  
  143. #==================================================================================
  144.  
  145. #This hash specifies which folders certain character sprites will be retrieved from
  146. # when making new character sprites.
  147. #Update this whenever the player has added another sprite sheet for a character
  148. # (ie. if a player had a specific swimming sprite sheet)
  149. SPRITE_CONVERT_HASH = { "trchar000" => "overworld walk",
  150. "boy_bike" => "overworld bike",
  151. "boy_surf" => "overworld surf", #changed for V17.2
  152. "boy_run" => "overworld run",
  153. "boy_dive_offset" => "overworld dive",
  154. "boy_fish_offset" => "overworld fish",
  155. "boy_fishsurf_offset" => "overworld fishsurf",
  156. "trback000" => "trainer back",
  157. "introBoy" => "trainer front",
  158. "mapPlayer000" => "trainer map",
  159. "trchar001" => "overworld walk",
  160. "girl_bike" => "overworld bike",
  161. "girl_surf" => "overworld surf", #changed for V17.2
  162. "girl_run" => "overworld run",
  163. "girl_dive_offset" => "overworld dive",
  164. "girl_fish_offset" => "overworld fish",
  165. "girl_fishsurf_offset" => "overworld fishsurf",
  166. "trback001" => "trainer back",
  167. "introGirl" => "trainer front",
  168. "mapPlayer001" => "trainer map"}
  169.  
  170. WALK_FOLDER = SPRITE_CONVERT_HASH["trchar000"]
  171.  
  172. #==================================================================================
  173. # * Useful methods that the Game Designer can call
  174. #==================================================================================
  175.  
  176. #Checks whether or not a trainer has been defined.
  177. def pbTrainerNotDefined
  178. if !defined?($Trainer)
  179. if $DEBUG
  180. 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.")
  181. end
  182. return true
  183. else
  184. return false
  185. end
  186. end
  187.  
  188. #Character Customization Script game designer can use
  189. def pbCustomizeCharacter
  190. CharacterCustomizationScene.new
  191. end
  192.  
  193. #Script in which the player can choose the base graphic they will use for their
  194. # character.
  195. #Can be used to choose your player's skin tone.
  196. #Should be used after the player selects their name and gender (or character).
  197. def pbChooseBaseGraphic
  198. ChooseBase.new
  199. end
  200.  
  201. # Method for changing a certain item. Used by game designer
  202. # item: String representing item player will put on.
  203. # variant (Use when accessory has variants): The variant of the item to be put on.
  204. def pbDressAccessory(item,variant=nil)
  205. dressAccessory(item,variant)
  206. end
  207.  
  208. # Gives the player randomized clothes (e.g good thing for randomizer challenges)
  209. def pbRandomizeOutfit
  210. return false if pbTrainerNotDefined
  211. for i in 0...5 #0 to Number of bodyparts (change if adding/deleting bodyparts)
  212. randomizeOutfitHelper(i)
  213. end
  214. saveAllCustomizedBitmapsToFolder
  215. updateTrainerOutfit
  216. $PokemonTemp.savedoutfit = false
  217. end
  218.  
  219. # Method for checking whether the player wears a certain item.
  220. # item: String representing the item that the player will be checked for.
  221. # variant (Use when accessory has variants): The variant of the item checked for.
  222. def pbWearingItem?(item,variant=nil)
  223. wearingAccessory?(item,variant)
  224. end
  225.  
  226. # Method for unlocking clothes.
  227. # item: String representing item player will unlock.
  228. # variant (Use when accessory has variants): The variant unlocked for the item.
  229. def pbUnlockItem(item,variant=nil)
  230. unlockAccessory(item,variant)
  231. end
  232.  
  233. # Unlocks all the variants of a specific item.
  234. # Only use for accessories with variants.
  235. # item: String representing item player will unlock all the variants of.
  236. def pbUnlockEntireItem(item)
  237. return false if pbTrainerNotDefined
  238. return false if !item.is_a?(String)
  239. arr=retArrayAndNumber(item,false)
  240. return false if !(arr[0])
  241. bodypart=arr[1]-1
  242. for i in 0...arr[0].length
  243. index=i if arr[0][i][0][$PokemonGlobal.playerID]==item
  244. end
  245. (if $DEBUG; p "There was an issue unlocking the item."; end; return) if !index
  246. return false if checkAccessory(arr[0],index)
  247. for i in 0...arr[0][index][1].length
  248. $Trainer.clothesUnlocking[bodypart][index][i]=true
  249. end
  250. end
  251.  
  252. # Method for locking clothes.
  253. # Only use for accessories with variants.
  254. # variant (Use when accessory has variants): The variant unlocked for the item.
  255. def pbLockItem(item,variant=nil)
  256. lockAccessory(item,variant)
  257. end
  258.  
  259. # Locks all the variants of a specific item.
  260. # Only use for accessories with variants
  261. # item: String representing item player will lock all the variants of.
  262. def pbLockEntireItem(item)
  263. return false if pbTrainerNotDefined
  264. return false if !item.is_a?(String)
  265. arr=retArrayAndNumber(item,false)
  266. bodypart=arr[1]
  267. (if $DEBUG; p "There was an issue locking the item."; end; return) if !(arr[0])
  268. for i in 0...arr[0].length
  269. index=i if arr[0][i][0][$PokemonGlobal.playerID]==item
  270. end
  271. if checkAccessory(arr[0],index)
  272. (if $DEBUG; p "There was an issue locking the item."; end; return)
  273. end
  274. for i in 0...arr[0][index][1].length
  275. lockAccessory(item,arr[0][index][1][i][0])
  276. end
  277. end
  278.  
  279. #==================================================================================
  280. # * Complete code of methods game designer calls
  281. #==================================================================================
  282.  
  283. # This method updates the trainer outfit
  284. def updateTrainerOutfit
  285. next_id=($PokemonGlobal.playerID==1 ? 0 : 1)
  286. id=$PokemonGlobal.playerID
  287. pbChangePlayer(next_id)
  288. pbWait(1)
  289. pbChangePlayer(id)
  290. end
  291.  
  292. # Method for changing a certain accessory.
  293. def dressAccessory(accessory,variant=nil)
  294. return false if pbTrainerNotDefined
  295. return false if characterizationException
  296. return false if !accessory.is_a?(String)
  297. return false if !variant.is_a?(String) && !(variant.nil?)
  298. arr=retArrayAndNumber(accessory,false)
  299. (if $DEBUG; p "Could not find entered accessory."; end; return false) if !arr[0]
  300. bodypart=arr[0]; var=arr[1]
  301. for i in 0...bodypart.length
  302. if bodypart[i][0][$PokemonGlobal.playerID]==accessory
  303. if variant.nil?
  304. if checkAccessory(bodypart,i)
  305. $Trainer.hair=[i,-1] if var==1
  306. $Trainer.top=[i,-1] if var==2
  307. $Trainer.bottom=[i,-1] if var==3
  308. $Trainer.headgear=[i,-1] if var==4
  309. $Trainer.accessory=[i,-1] if var==5
  310. saveAllCustomizedBitmapsToFolder
  311. updateTrainerOutfit
  312. return
  313. elsif $DEBUG
  314. p "Cannot dress accessory. Array is multidimensional, entered single value."
  315. end
  316. return
  317. else
  318. if !checkAccessory(bodypart,i,false)
  319. if $DEBUG
  320. p "Cannot dress accessory. Array is singledimensional, entered multiple values."
  321. end
  322. return
  323. end
  324. secondvalue=nil
  325. for j in 0...bodypart[i][1].length
  326. if bodypart[i][1][j][0]==variant
  327. secondvalue=j
  328. end
  329. end
  330. if secondvalue.nil?
  331. if $DEBUG
  332. p "Could not find variant specified."
  333. end
  334. return
  335. else
  336. $Trainer.hair=[i,secondvalue] if var==1
  337. $Trainer.top=[i,secondvalue] if var==2
  338. $Trainer.bottom=[i,secondvalue] if var==3
  339. $Trainer.headgear=[i,secondvalue] if var==4
  340. $Trainer.accessory=[i,secondvalue] if var==5
  341. saveAllCustomizedBitmapsToFolder
  342. updateTrainerOutfit
  343. $PokemonTemp.savedoutfit = false
  344. return
  345. end
  346. end
  347. end
  348. end
  349. return
  350. end
  351.  
  352. def wearingAccessory?(accessory,variant=nil)
  353. return false if pbTrainerNotDefined
  354. return false if characterizationException
  355. arr=retArrayAndNumber(accessory,false)
  356. clothes=arr[0]; bodypart=arr[1]
  357. current=$Trainer.hair if bodypart==1
  358. current=$Trainer.top if bodypart==2
  359. current=$Trainer.bottom if bodypart==3
  360. current=$Trainer.headgear if bodypart==4
  361. current=$Trainer.accessory if bodypart==5
  362. return false if !clothes || !current
  363. if accessory.is_a?(String)
  364. for i in 0...clothes.length
  365. if clothes[i][0][$PokemonGlobal.playerID]==accessory
  366. if variant.nil?
  367. return (accessory==clothes[current[0]][0][$PokemonGlobal.playerID])
  368. elsif variant.is_a?(String) && accessory==clothes[current[0]][0][$PokemonGlobal.playerID]
  369. return false if checkAccessory(clothes,i)
  370. for j in 0...clothes[i][1].length
  371. if clothes[i][1][j][0]==variant
  372. return (variant==clothes[i][1][current[0]][0])
  373. end
  374. end
  375. else
  376. return false
  377. end
  378. end
  379. end
  380. end
  381. return false
  382. end
  383.  
  384. def unlockAccessory(accessory,variant=nil)
  385. return false if pbTrainerNotDefined
  386. return false if !accessory.is_a?(String)
  387. arr=retArrayAndNumber(accessory,false)
  388. return false if !(arr[0])
  389. bodypart=arr[1]-1
  390. for i in 0...arr[0].length
  391. index=i if arr[0][i][0][$PokemonGlobal.playerID]==accessory
  392. end
  393. (if $DEBUG; p "There was an issue unlocking the accessory."; end; return) if !index
  394. if !variant.nil?
  395. return false if !variant.is_a?(String)
  396. return false if checkAccessory(arr[0],index)
  397. for j in 0...arr[0][index][1].length
  398. index2=j if arr[0][index][1][j][0]==variant
  399. end
  400. (if $DEBUG; p "There was an issue unlocking the accessory."; end; return) if !index2
  401. $Trainer.clothesUnlocking[bodypart][index][index2]=true
  402. else
  403. return false if checkAccessory(arr[0],index,false)
  404. $Trainer.clothesUnlocking[bodypart][index]=true
  405. end
  406. end
  407.  
  408. # Method for locking clothes
  409. def lockAccessory(accessory,variant=nil)
  410. return false if pbTrainerNotDefined
  411. return false if !accessory.is_a?(String)
  412. arr=retArrayAndNumber(accessory,false)
  413. bodypart=arr[1]
  414. (current=$Trainer.hair; name="Hair") if bodypart==1
  415. (current=$Trainer.top; name="Top") if bodypart==2
  416. (current=$Trainer.bottom; name="Bottom") if bodypart==3
  417. (current=$Trainer.headgear; name="Headgear")if bodypart==4
  418. (current=$Trainer.accessory; name="Accessory")if bodypart==5
  419. # Checking if player wears the accessory to lock
  420. (if $DEBUG; p "There was an issue locking the accessory"; end; return) if !(arr[0])
  421. for i in 0...arr[0].length
  422. if arr[0][i][0][$PokemonGlobal.playerID]==accessory
  423. index=i
  424. if variant.nil?
  425. if checkAccessory(arr[0],index,false)
  426. (if $DEBUG; p "There was an issue locking the accessory"; end; return)
  427. end
  428. #p i; p current
  429. if i==current[0]
  430. if checkAccessory(arr[0],0)
  431. sv=-1
  432. else
  433. sv=0
  434. end
  435. Kernel.pbMessage("#{$Trainer.name} misses the #{accessory} #{name} and puts on the #{arr[0][0][0][$PokemonGlobal.playerID]} one instead.")
  436. $Trainer.hair=[0,sv] if bodypart==1
  437. $Trainer.top=[0,sv] if bodypart==2
  438. $Trainer.bottom=[0,sv] if bodypart==3
  439. $Trainer.headgear=[0,sv] if bodypart==4
  440. $Trainer.accessory=[0,sv] if bodypart==5
  441. end
  442. else
  443. if checkAccessory(arr[0],index) || !variant.is_a?(String)
  444. (if $DEBUG; p "There was an issue locking the accessory"; end; return)
  445. end
  446. for j in 0...arr[0][i][1].length
  447. if arr[0][i][1][j][0]==variant
  448. index2=j
  449. end
  450. if i==current[0] && j==current[1]
  451. if checkAccessory(arr[0],0)
  452. sv=-1
  453. else
  454. sv=0
  455. end
  456. Kernel.pbMessage("#{$Trainer.name} misses the #{accessory} #{name} and puts on the #{arr[0][0][0][$PokemonGlobal.playerID]} one instead.")
  457. $Trainer.hair=[0,sv] if bodypart==1
  458. $Trainer.top=[0,sv] if bodypart==2
  459. $Trainer.bottom=[0,sv] if bodypart==3
  460. $Trainer.headgear=[0,sv] if bodypart==4
  461. $Trainer.accessory=[0,sv] if bodypart==5
  462. end
  463. end
  464. end
  465. end
  466. end
  467. (if $DEBUG; p "There was an issue locking the accessory"; end; return) if !index
  468. if !variant.nil? && !index2
  469. (if $DEBUG; p "There was an issue locking the accessory"; end; return)
  470. elsif !variant.nil?
  471. $Trainer.clothesUnlocking[bodypart-1][index][index2]=false
  472. else
  473. $Trainer.clothesUnlocking[bodypart-1][index]=false
  474. end
  475. saveAllCustomizedBitmapsToFolder
  476. updateTrainerOutfit
  477. $PokemonTemp.savedoutfit = false
  478. end
  479.  
  480. #==================================================================================
  481. # * Initializing class PokeBattle_Trainer objects.
  482. #==================================================================================
  483.  
  484. class PokeBattle_Trainer
  485. attr_accessor :character_customization
  486. attr_accessor :hair
  487. attr_accessor :top
  488. attr_accessor :bottom
  489. attr_accessor :headgear
  490. attr_accessor :accessory
  491. attr_accessor :clothesUnlocking
  492.  
  493. def character_customization
  494. if !@character_customization
  495. @character_customization=UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT
  496. end
  497. return @character_customization
  498. end
  499.  
  500. def character_customization=(boolean)
  501. if boolean != true && boolean != false # Determining if object is a boolean
  502. if $DEBUG
  503. p "only $Trainer.character_customization = true/false is valid!"
  504. end
  505. return
  506. end
  507. @character_customization=boolean
  508. end
  509.  
  510. def hair
  511. if !@hair
  512. if ((HAIR_ITEMS[0][1] == true) || (HAIR_ITEMS[0][1] == false))
  513. @hair=[0,-1]
  514. else
  515. @hair=[0,0]
  516. end
  517. end
  518. return @hair
  519. end
  520.  
  521. def hair=(values)
  522. fvalue=values[0]; svalue=values[1]
  523. if fvalue<0 || fvalue>(HAIR_ITEMS.length-1)
  524. if $DEBUG
  525. p "the first value for $Trainer.hair is out of range!"
  526. end
  527. return
  528. end
  529. if ((HAIR_ITEMS[fvalue][1] == true) || (HAIR_ITEMS[fvalue][1] == false))
  530. @hair=[fvalue, -1]
  531. else
  532. if svalue<0 || svalue>(HAIR_ITEMS[fvalue][1].length-1)
  533. if $DEBUG
  534. p "the second value for $Trainer.hair is out of range!"
  535. end
  536. return
  537. end
  538. @hair=[fvalue, svalue]
  539. end
  540. end
  541.  
  542. def top
  543. if !@top
  544. if ((TOP_ITEMS[0][1] == true) || (TOP_ITEMS[0][1] == false))
  545. @top=[0,-1]
  546. else
  547. @top=[0,0]
  548. end
  549. end
  550. return @top
  551. end
  552.  
  553. def top=(values)
  554. fvalue=values[0]; svalue=values[1]
  555. if fvalue<0 || fvalue>(TOP_ITEMS.length-1)
  556. if $DEBUG
  557. p "the first value for $Trainer.top is out of range!"
  558. end
  559. return
  560. end
  561. if ((TOP_ITEMS[fvalue][1] == true) || (TOP_ITEMS[fvalue][1] == false))
  562. @top=[fvalue, -1]
  563. else
  564. if svalue<0 || svalue>(TOP_ITEMS[fvalue][1].length-1)
  565. if $DEBUG
  566. p "the second value for $Trainer.top is out of range!"
  567. end
  568. return
  569. end
  570. @top=[fvalue, svalue]
  571. end
  572. end
  573.  
  574. def bottom
  575. if !@bottom
  576. if ((BOTTOM_ITEMS[0][1] == true) || (BOTTOM_ITEMS[0][1] == false))
  577. @bottom=[0,-1]
  578. else
  579. @bottom=[0,0]
  580. end
  581. end
  582. return @bottom
  583. end
  584.  
  585. def bottom=(values)
  586. fvalue=values[0]; svalue=values[1]
  587. if fvalue<0 || fvalue>(BOTTOM_ITEMS.length-1)
  588. if $DEBUG
  589. p "the first value for $Trainer.bottom is out of range!"
  590. end
  591. return
  592. end
  593. if ((BOTTOM_ITEMS[fvalue][1] == true) || (BOTTOM_ITEMS[fvalue][1] == false))
  594. @bottom=[fvalue, -1]
  595. else
  596. if svalue<0 || svalue>(BOTTOM_ITEMS[fvalue][1].length-1)
  597. if $DEBUG
  598. p "the second value for $Trainer.bottom is out of range!"
  599. end
  600. return
  601. end
  602. @bottom=[fvalue, svalue]
  603. end
  604. end
  605.  
  606. def headgear
  607. if !@headgear
  608. if ((HEADGEAR_ITEMS[0][1] == true) || (HEADGEAR_ITEMS[0][1] == false))
  609. @headgear=[0,-1]
  610. else
  611. @headgear=[0,0]
  612. end
  613. end
  614. return @headgear
  615. end
  616.  
  617. def headgear=(values)
  618. fvalue=values[0]; svalue=values[1]
  619. if fvalue<0 || fvalue>(HEADGEAR_ITEMS.length-1)
  620. if $DEBUG
  621. p "the first value for $Trainer.headgear is out of range!"
  622. end
  623. return
  624. end
  625. if ((HEADGEAR_ITEMS[fvalue][1] == true) || (HEADGEAR_ITEMS[fvalue][1] == false))
  626. @headgear=[fvalue, -1]
  627. else
  628. if svalue<0 || svalue>(HEADGEAR_ITEMS[fvalue][1].length-1)
  629. if $DEBUG
  630. p "the second value for $Trainer.headgear is out of range!"
  631. end
  632. return
  633. end
  634. @headgear=[fvalue, svalue]
  635. end
  636. end
  637.  
  638. def accessory
  639. if !@accessory
  640. if ((ACCESSORY_ITEMS[0][1] == true) || (ACCESSORY_ITEMS[0][1] == false))
  641. @accessory=[0,-1]
  642. else
  643. @accessory=[0,0]
  644. end
  645. end
  646. return @accessory
  647. end
  648.  
  649. def accessory=(values)
  650. fvalue=values[0]; svalue=values[1]
  651. if fvalue<0 || fvalue>(ACCESSORY_ITEMS.length-1)
  652. if $DEBUG
  653. p "the first value for $Trainer.accessory is out of range!"
  654. end
  655. return
  656. end
  657. if ((ACCESSORY_ITEMS[fvalue][1] == true) || (ACCESSORY_ITEMS[fvalue][1] == false))
  658. @accessory=[fvalue, -1]
  659. else
  660. if svalue<0 || svalue>(ACCESSORY_ITEMS[fvalue][1].length-1)
  661. if $DEBUG
  662. p "the second value for $Trainer.accessory is out of range!"
  663. end
  664. return
  665. end
  666. @accessory=[fvalue, svalue]
  667. end
  668. end
  669.  
  670. def clothesUnlocking
  671. if !@clothesUnlocking
  672. @clothesUnlocking=[]
  673. @clothesUnlocking.push cnvrtBoolArr(HAIR_ITEMS)
  674. @clothesUnlocking.push cnvrtBoolArr(TOP_ITEMS)
  675. @clothesUnlocking.push cnvrtBoolArr(BOTTOM_ITEMS)
  676. @clothesUnlocking.push cnvrtBoolArr(HEADGEAR_ITEMS)
  677. @clothesUnlocking.push cnvrtBoolArr(ACCESSORY_ITEMS)
  678. end
  679. return @clothesUnlocking
  680. end
  681.  
  682. end
  683.  
  684. #==================================================================================
  685. # * Character Customization Scene
  686. #==================================================================================
  687.  
  688. class CharacterCustomizationScene
  689.  
  690. def initialize
  691. @savegetup = true
  692. if !defined?($Trainer.clothesUnlocking) # Checks if the Script is functional.
  693. 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.")
  694. if Kernel.pbConfirmMessage("Would you like to save the game now?")
  695. if !$Trainer
  696. 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.")
  697. else
  698. pbSave
  699. Kernel.pbMessage("The game was saved, try again now.")
  700. end
  701. end
  702. return
  703. end
  704. if $PokemonTemp.savedoutfit == false
  705. $PokemonTemp.savedoutfit = true
  706. @savegetup = false
  707. end
  708. return if !addNecessaryFiles
  709. if @savegetup == false
  710. $PokemonTemp.savedoutfit = false
  711. end
  712. @index=0
  713. @index2=0
  714. @indexR=-1
  715. @new_val=2
  716. @firstSelection=true
  717. @secondSelection=true
  718. @selectionChange=false
  719. @sprites={}
  720. @accessoryNames=["hair","tops","bottoms","headgear","accessories"]
  721. @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  722. @viewport.z=99999
  723. @sprites["window"]=SpriteWindow_Base.new(Graphics.width/2-64,Graphics.height/2-128,128,128)
  724. @sprites["window2"]=SpriteWindow_Base.new(Graphics.width/2-64,Graphics.height/2,128,128)
  725. @sprites["window2"].visible=false
  726. @sprites["player"]=TrainerWalkingCharSprite.new($game_player.character_name,@viewport)
  727. @sprites["player"].x=Graphics.width/2-@sprites["player"].bitmap.width/8
  728. @sprites["player"].y=Graphics.height/2-@sprites["player"].bitmap.height/8 -64
  729. @sprites["player"].z=9999999
  730. $PokemonTemp.savedoutfit = true
  731. temp="/"+WALK_FOLDER+"/"+@accessoryNames[1]+"/"+"0A"
  732. @sprites["playerAccessory"]=TrainerWalkingCharSprite.new(temp,@viewport)
  733. @sprites["playerAccessory"].x=Graphics.width/2-@sprites["playerAccessory"].bitmap.width/8
  734. @sprites["playerAccessory"].y=Graphics.height/2-@sprites["playerAccessory"].bitmap.height/8 +64
  735. @sprites["playerAccessory"].z=9999999
  736. @sprites["playerAccessory"].ox+=@sprites["playerAccessory"].bitmap.width/16
  737. @sprites["playerAccessory"].oy+=@sprites["playerAccessory"].bitmap.height/16
  738. @sprites["playerAccessory"].zoom_x=2
  739. @sprites["playerAccessory"].zoom_y=2
  740. @sprites["playerAccessory"].visible=false
  741. @playerAccessory=@sprites["playerAccessory"]
  742. charheight=@sprites["player"].bitmap.height
  743. @y=[charheight/4*2,0,charheight/4,charheight/4*3]
  744. @sprites["heading1"]=Window_CommandPokemonEx.new(["BODYPART"])
  745. @sprites["heading1"].viewport=@viewport
  746. @sprites["heading1"].index=1
  747. @sprites["heading2"]=Window_CommandPokemonEx.new(["HAIR"])
  748. @sprites["heading2"].viewport=@viewport
  749. @sprites["heading2"].index=1
  750. @sprites["heading2"].x=Graphics.width-@sprites["heading2"].width
  751. #Version 17.2 Difference Below
  752. @commands=CommandMenuList.new
  753. @commands.add("main","hair",_INTL("Hair"))
  754. @commands.add("main","tops",_INTL("Tops"))
  755. @commands.add("main","bottoms",_INTL("Bottoms"))
  756. @commands.add("main","headgear",_INTL("Headgear"))
  757. @commands.add("main","accessories",_INTL("Accessories"))
  758. #Version 17.2 Difference Above
  759. @sprites["cmdwindow"]=Window_CommandPokemonEx.new(@commands.list)
  760. @sprites["cmdwindow"].viewport=@viewport
  761. @sprites["cmdwindow"].y=@sprites["heading1"].height
  762. @sprites["cmdwindow2"]=Window_CommandPokemonEx.new(retListCmdBox2)
  763. @sprites["cmdwindow2"].viewport=@viewport
  764. @sprites["cmdwindow2"].y=@sprites["heading2"].height
  765. @sprites["cmdwindow2"].x=Graphics.width-@sprites["cmdwindow2"].width
  766. @sprites["cmdwindow2"].z-=1
  767. @sprites["cmdwindow2"].index=-1
  768. @cmdwindow2=@sprites["cmdwindow2"]
  769. @selectionMade=false
  770. update
  771. end
  772.  
  773. def addNecessaryFiles
  774. files=[]
  775. basefiles=[]
  776. # Pushing all files that could possibly be missing into the files array.
  777. individualArrayFiles(files,HAIR_ITEMS,"hair")
  778. individualArrayFiles(files,BOTTOM_ITEMS,"bottoms")
  779. individualArrayFiles(files,TOP_ITEMS,"tops")
  780. individualArrayFiles(files,HEADGEAR_ITEMS,"headgear")
  781. individualArrayFiles(files,ACCESSORY_ITEMS,"accessories")
  782. if USE_BASE_GRAPHIC
  783. metadata=pbLoadMetadata
  784. filenames=metadata[0][MetadataPlayerA+$PokemonGlobal.playerID]
  785. for i in 0...filenames.length
  786. if filenames[i].is_a?(String) && !(filenames[i]=="xxx")
  787. basefiles.push("Graphics/Characters/"+filenames[i]+"_base")
  788. end
  789. end
  790. # Trainer backsprite
  791. basefiles.push("Graphics/Trainers/trback00#{$PokemonGlobal.playerID}_base")
  792. # Intro Image/Trainercard Image
  793. filepath="Graphics/Pictures/"
  794. filepath+= $Trainer.isFemale? ? "introGirl" : "introBoy"
  795. basefiles.push(filepath+"_base")
  796. # Map Player
  797. basefiles.push("Graphics/Pictures/mapPlayer00#{$PokemonGlobal.playerID}_base")
  798. end
  799. # Creating a blank bitmap
  800. files_to_add=[]
  801. for i in 0...basefiles.length
  802. if !File.exists?(basefiles[i]+".png")
  803. files_to_add.push(basefiles[i]+".png")
  804. end
  805. end
  806. size_check=Bitmap.new("Graphics/Characters/#{$game_player.character_name}")
  807. blank_bitmap=Bitmap.new(size_check.width,size_check.height)
  808. # Pushing non existent files into the files_to_add array.
  809. for i in 0...files.length
  810. if !File.exists?("Graphics/Characters/overworld walk/#{files[i]}"+".png")
  811. files_to_add.push("Graphics/Characters/overworld walk/#{files[i]}"+".png")
  812. end
  813. end
  814. if !files_to_add.empty?
  815. Kernel.pbMessage("The game is missing one or more graphic files for the Character Customization.")
  816. ret=Kernel.pbConfirmMessage("Would you like to add these files as blank placeholder sprites in order to let this Script work properly?")
  817. if ret
  818. files_to_add.length.times {|i| blank_bitmap.saveToPng(files_to_add[i])}
  819. Kernel.pbMessage("The missing files were added to the Graphics/Characters/ folder. The script will continue working as supposed now.")
  820. else
  821. Kernel.pbMessage("The script stopped running until these neccessary files were added:")
  822. files_to_add.length.times{|i| Kernel.pbMessage(files_to_add[i])}
  823. end
  824. return ret
  825. end
  826. return true
  827. end
  828.  
  829.  
  830. # returns the index of the item in the actual list.
  831. def getAccessoryIndex(index)
  832. if @secondSelection
  833. item=@list[index]
  834. else
  835. item=@list2[index]
  836. end
  837. arr=HAIR_ITEMS if @accessoryNames[@index]=="hair"
  838. arr=TOP_ITEMS if @accessoryNames[@index]=="tops"
  839. arr=BOTTOM_ITEMS if @accessoryNames[@index]=="bottoms"
  840. arr=HEADGEAR_ITEMS if @accessoryNames[@index]=="headgear"
  841. arr=ACCESSORY_ITEMS if @accessoryNames[@index]=="accessories"
  842. arr=cnvrtStrArr(arr)
  843. for i in 0...arr.length
  844. return i if arr[i]==item
  845. end
  846. end
  847.  
  848. # updates the Accessory bitmap
  849. def updateAccessoryBitmap
  850. @sprites["playerAccessory"].bitmap.clear
  851. endname=(getAccessoryIndex(@cmdwindow2.index)).to_s+($PokemonGlobal.playerID+65).chr
  852. name="overworld walk/"+@accessoryNames[@index]+"/"+endname
  853. if File.exists?("Graphics/Characters/"+name+".png")
  854. @sprites["playerAccessory"].charset=name
  855. end
  856. end
  857.  
  858. # returns the index of the variant in the actual list.
  859. def getAccessoryIndex2
  860. item=@list[@cmdwindow2.index]
  861. arr=HAIR_ITEMS if @accessoryNames[@index]=="hair"
  862. arr=TOP_ITEMS if @accessoryNames[@index]=="tops"
  863. arr=BOTTOM_ITEMS if @accessoryNames[@index]=="bottoms"
  864. arr=HEADGEAR_ITEMS if @accessoryNames[@index]=="headgear"
  865. arr=ACCESSORY_ITEMS if @accessoryNames[@index]=="accessories"
  866. arr2=arr[getAccessoryIndex(@indexR)][1]
  867. for i in 0...arr2.length
  868. return i if arr2[i][0]==item
  869. end
  870. end
  871.  
  872. # Another method for updating the Accessory bitmap
  873. def updateAccessoryBitmap2
  874. @sprites["playerAccessory"].bitmap.clear
  875. frontname="overworld walk/"+@accessoryNames[@index]+"/"+(getAccessoryIndex(@indexR)).to_s
  876. name=frontname+"/"+(getAccessoryIndex2).to_s+($PokemonGlobal.playerID+65).chr
  877. if File.exists?("Graphics/Characters/"+name+".png")
  878. @sprites["playerAccessory"].charset=name
  879. end
  880. end
  881.  
  882. # returns the list of the right hand command box.
  883. def retListCmdBox2
  884. @list=HAIR_ITEMS if @index==0
  885. @list=TOP_ITEMS if @index==1
  886. @list=BOTTOM_ITEMS if @index==2
  887. @list=HEADGEAR_ITEMS if @index==3
  888. @list=ACCESSORY_ITEMS if @index==4
  889. if @secondSelection==true
  890. @list=retUnlockedAccessoryArray(cnvrtStrArr(@list))
  891. @list=["---NONE---"] if !@list
  892. @list.push("Back") if [email protected]?("Back")
  893. else
  894. @list2=retUnlockedAccessoryArray(cnvrtStrArr(@list))
  895. @list2=["---NONE---"] if !@list2
  896. @list2.push("Back") if [email protected]?("Back")
  897. @list=retUnlockedAccessoryArray2(cnvrtStrArr(@list),getAccessoryIndex(@indexR))
  898. @list=["---NONE---"] if !@list
  899. @list.push("Back") if [email protected]?("Back")
  900. end
  901. return @list
  902. end
  903.  
  904. #checks whether or not the currently selected item within the list has any variants
  905. def hasVariants
  906. ret=false
  907. name=@list[@cmdwindow2.index]
  908. #Get name of item that is current hovered over
  909. arr=retArrayAndNumber(name,false)
  910. bodypart=arr[0]
  911. #Access original array to check whether or not item has variants.
  912. for i in 0...bodypart.length
  913. if bodypart[i][0][$PokemonGlobal.playerID]==name
  914. ret=((bodypart[i][1] == true) || (bodypart[i][1] == false))
  915. end
  916. end
  917. return !ret
  918. end
  919.  
  920. # this updates the heading. since there is no command for updating
  921. # command boxes it'll always create a new fresh command box sprite.
  922. def updateHeading2
  923. @sprites["heading#{@new_val}"].dispose
  924. @sprites["cmdwindow#{@new_val}"].dispose
  925. @new_val+=1
  926. @sprites["heading#{@new_val}"]=Window_CommandPokemonEx.new([@commands.list[@index].upcase])
  927. @sprites["heading#{@new_val}"].viewport=@viewport
  928. @sprites["heading#{@new_val}"].index=1
  929. @sprites["heading#{@new_val}"].x=Graphics.width-@sprites["heading#{@new_val}"].width
  930. @sprites["heading#{@new_val}"].z-=1
  931. @sprites["cmdwindow#{@new_val}"]=Window_CommandPokemonEx.new(retListCmdBox2)
  932. @cmdwindow2=@sprites["cmdwindow#{@new_val}"]
  933. @cmdwindow2.viewport=@viewport
  934. @cmdwindow2.y=@sprites["heading#{@new_val}"].height
  935. @cmdwindow2.x=Graphics.width-@sprites["cmdwindow#{@new_val}"].width
  936. @cmdwindow2.index= -1
  937. end
  938.  
  939. # checks whether the index of the left command box has changed or not.
  940. def indexChanged
  941. if @index2 != @index
  942. @index2=@index
  943. return true
  944. end
  945. return false
  946. end
  947.  
  948. # checks whether the index or the right command box has changed or not.
  949. def cmdWindow2IndexChanged
  950. if !@cmdWindow2Index
  951. return false
  952. elsif @cmdWindow2Index != @cmdwindow2.index
  953. return true
  954. end
  955. return false
  956. end
  957.  
  958. # updates the scene.
  959. def update
  960. frame=0
  961. @dir=0
  962. loop do
  963. frame+=1
  964. pos=0
  965. Graphics.update
  966. Input.update
  967. @sprites["player"].update
  968. @sprites["playerAccessory"].update
  969. if @firstSelection
  970. @sprites["cmdwindow"].update
  971. @index=@sprites["cmdwindow"].index
  972. else
  973. @cmdwindow2.update
  974. end
  975. if indexChanged
  976. updateHeading2
  977. end
  978. if @selectionChange
  979. updateHeading2
  980. if @secondSelection
  981. @cmdwindow2.index=@indexR
  982. else
  983. @cmdwindow2.index=0
  984. end
  985. @selectionChange=false
  986. end
  987. if @secondSelection
  988. if cmdWindow2IndexChanged && @cmdwindow2.index != -1
  989. if !(@cmdwindow2.index==(@cmdwindow2.itemCount-1)) && !hasVariants
  990. @sprites["window2"].visible=true
  991. @sprites["playerAccessory"].visible=true
  992. $PokemonTemp.savedoutfit = true
  993. updateAccessoryBitmap #if @cmdwindow2.index != @cmdwindow2.
  994. $PokemonTemp.savedoutfit = false
  995. else
  996. @sprites["window2"].visible=false
  997. @sprites["playerAccessory"].visible=false
  998. end
  999. end
  1000. elsif cmdWindow2IndexChanged && @cmdwindow2.index != -1
  1001. if !(@cmdwindow2.index==(@cmdwindow2.itemCount-1))
  1002. @sprites["window2"].visible=true
  1003. @sprites["playerAccessory"].visible=true
  1004. $PokemonTemp.savedoutfit = true
  1005. updateAccessoryBitmap2 #if @cmdwindow2.index != @cmdwindow2.
  1006. $PokemonTemp.savedoutfit = false
  1007. else
  1008. @sprites["window2"].visible=false
  1009. @sprites["playerAccessory"].visible=false
  1010. end
  1011. end
  1012. if Input.trigger?(Input::C)
  1013. # Pressing C on the left command box.
  1014. if @firstSelection
  1015. @cmdwindow2.index=0
  1016. @firstSelection=false
  1017. if !hasVariants
  1018. @sprites["window2"].visible=true
  1019. @sprites["playerAccessory"].visible=true
  1020. end
  1021. elsif @secondSelection
  1022. # Pressing C on the right command box, first choice
  1023. if @cmdwindow2.index==(@cmdwindow2.itemCount-1) # Cancel
  1024. @cmdwindow2.index=-1; @cmdwindow2.update
  1025. @firstSelection=true
  1026. @sprites["window2"].visible=false
  1027. @sprites["playerAccessory"].visible=false
  1028. elsif !hasVariants
  1029. $PokemonTemp.savedoutfit = true
  1030. changeClothes
  1031. $PokemonTemp.savedoutfit = false
  1032. @sprites["player"].bitmap.clear
  1033. @sprites["player"].charset=$game_player.character_name
  1034. @selectionMade=true
  1035. else
  1036. @secondSelection=false
  1037. @selectionChange=true
  1038. @sprites["window2"].visible=true
  1039. @sprites["playerAccessory"].visible=true
  1040. end
  1041. # Pressing C on the left command box, second choice
  1042. else
  1043. if @cmdwindow2.index==(@cmdwindow2.itemCount-1) # Cancel
  1044. @cmdwindow2.index=@indexR; @cmdwindow2.update
  1045. @secondSelection=true
  1046. @selectionChange=true
  1047. @sprites["window2"].visible=false
  1048. @sprites["playerAccessory"].visible=false
  1049. else
  1050. $PokemonTemp.savedoutfit = true
  1051. changeClothes
  1052. $PokemonTemp.savedoutfit = false
  1053. @sprites["player"].bitmap.clear
  1054. @sprites["player"].charset=$game_player.character_name
  1055. @selectionMade=true
  1056. end
  1057. end
  1058. end
  1059.  
  1060. if Input.trigger?(Input::B)
  1061. # cancels the scene.
  1062. if @firstSelection && Kernel.pbConfirmMessage("Have you finished?")
  1063. updateTrainerOutfit
  1064. if @savegetup == true && @selectionMade == false
  1065. $PokemonTemp.savedoutfit = true
  1066. else
  1067. $PokemonTemp.savedoutfit = false
  1068. end
  1069. pbDisposeSpriteHash(@sprites)
  1070. break
  1071. # goes back to the left command box.
  1072. elsif !@firstSelection && @secondSelection
  1073. @cmdwindow2.index=-1; @cmdwindow2.update
  1074. @firstSelection=true
  1075. @sprites["window2"].visible=false
  1076. @sprites["playerAccessory"].visible=false
  1077. elsif !@firstSelection && !@secondSelection
  1078. @cmdwindow2.index=@indexR; @cmdwindow2.update
  1079. @secondSelection=true
  1080. @selectionChange=true
  1081. @sprites["window2"].visible=false
  1082. @sprites["playerAccessory"].visible=false
  1083. end
  1084. end
  1085. # updates the walking sprite.
  1086. if frame%120==0
  1087. @dir+=1
  1088. @sprites["player"].src_rect.y=@y[@dir%4]
  1089. @sprites["playerAccessory"].src_rect.y=@sprites["player"].src_rect.y
  1090. end
  1091. end
  1092. end
  1093.  
  1094. # updates the outfit as well as the variables which are responsable for it.
  1095. def changeClothes
  1096. if @secondSelection
  1097. dressAccessory(@list[@cmdwindow2.index])
  1098. else
  1099. dressAccessory(@list2[@indexR],@list[@cmdwindow2.index])
  1100. end
  1101. #done
  1102. case @sprites["cmdwindow"].index
  1103. when 0
  1104. if @secondSelection
  1105. $Trainer.hair=[getAccessoryIndex(@cmdwindow2.index), -1]
  1106. else
  1107. $Trainer.hair=[getAccessoryIndex(@indexR), getAccessoryIndex2]
  1108. end
  1109. when 1
  1110. if @secondSelection
  1111. $Trainer.top=[getAccessoryIndex(@cmdwindow2.index), -1]
  1112. else
  1113. $Trainer.top=[getAccessoryIndex(@indexR), getAccessoryIndex2]
  1114. end
  1115. when 2
  1116. if @secondSelection
  1117. $Trainer.bottom=[getAccessoryIndex(@cmdwindow2.index), -1]
  1118. else
  1119. $Trainer.bottom=[getAccessoryIndex(@indexR), getAccessoryIndex2]
  1120. end
  1121. when 3
  1122. if @secondSelection
  1123. $Trainer.headgear=[getAccessoryIndex(@cmdwindow2.index), -1]
  1124. else
  1125. $Trainer.headgear=[getAccessoryIndex(@indexR), getAccessoryIndex2]
  1126. end
  1127. when 4
  1128. if @secondSelection
  1129. $Trainer.accessory=[getAccessoryIndex(@cmdwindow2.index), -1]
  1130. else
  1131. $Trainer.accessory=[getAccessoryIndex(@indexR), getAccessoryIndex2]
  1132. end
  1133. end
  1134. end
  1135.  
  1136. end
  1137.  
  1138. #===============================================================================
  1139. # Creates a method which chooses which Base Graphic to build their character on top of
  1140. #===============================================================================
  1141.  
  1142. class ChooseBase
  1143.  
  1144. def initialize
  1145. if !$PokemonTemp.savedoutfit
  1146. (if $DEBUG; p "Cannot pick base if outfit has already been edited"; end; return)
  1147. end
  1148. #Version 17.2 Difference Below
  1149. @commands=CommandMenuList.new
  1150. for i in 0...BASE_GRAPHICS.length
  1151. temp=BASE_GRAPHICS[i][$PokemonGlobal.playerID]
  1152. @commands.add("main",temp.downcase,_INTL(temp))
  1153. end
  1154. #Version 17.2 Difference Above
  1155. return false if !addBaseFiles
  1156. @index=0
  1157. @sprites={}
  1158. @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  1159. @viewport.z=99999
  1160. @sprites["window"]=SpriteWindow_Base.new(8,8,128,192)
  1161. @sprites["window2"]=SpriteWindow_Base.new(8,208,128,128)
  1162. @sprites["window"].z=1000
  1163. @sprites["window2"].z=1000
  1164. temp="/examples/0"+($PokemonGlobal.playerID+65).chr
  1165. @sprites["baseRep"]= IconSprite.new(0,0,@viewport)
  1166. @sprites["baseRep"].setBitmap("Graphics/Characters/base graphics"+temp)
  1167. @sprites["baseRep"].x=@sprites["window"].width/2-@sprites["baseRep"].bitmap.width/2 +8
  1168. @sprites["baseRep"].y=@sprites["window"].height/2-@sprites["baseRep"].bitmap.height/2 +8
  1169. @sprites["baseRep"].z=9999999
  1170. temp="/"+WALK_FOLDER+"/0"+($PokemonGlobal.playerID+65).chr
  1171. @sprites["walkSprite"]=TrainerWalkingCharSprite.new("base graphics"+temp,@viewport)
  1172. @sprites["walkSprite"].x=@sprites["window2"].width/2-@sprites["walkSprite"].bitmap.width/2 +8
  1173. @sprites["walkSprite"].y=@sprites["window2"].height/2-@sprites["walkSprite"].bitmap.height/2 +208
  1174. @sprites["walkSprite"].ox-=@sprites["walkSprite"].bitmap.width/8
  1175. @sprites["walkSprite"].oy-=@sprites["walkSprite"].bitmap.height/8
  1176. @sprites["walkSprite"].z=9999999
  1177. @sprites["walkSprite"].zoom_x=2
  1178. @sprites["walkSprite"].zoom_y=2
  1179. @sprites["heading"]=Window_CommandPokemonEx.new(["SKIN TONES"])
  1180. @sprites["heading"].viewport=@viewport
  1181. @sprites["heading"].index=1
  1182. @sprites["heading"].x=Graphics.width-@sprites["heading"].width-8
  1183. charheight=@sprites["walkSprite"].bitmap.height
  1184. @y=[charheight/4*2,0,charheight/4,charheight/4*3]
  1185. @sprites["cmdwindow"]=Window_CommandPokemonEx.new(@commands.list)
  1186. @sprites["cmdwindow"].viewport=@viewport
  1187. @sprites["cmdwindow"].x=Graphics.width-@sprites["cmdwindow"].width
  1188. @sprites["cmdwindow"].y=@sprites["heading"].height+8
  1189. @sprites["cmdwindow"].z=999999
  1190. @sprites["cmdwindow"].index=0
  1191. looping
  1192. end
  1193.  
  1194. def addBaseFiles
  1195. files=[]
  1196. metadata=pbLoadMetadata
  1197. filenames=metadata[0][MetadataPlayerA+$PokemonGlobal.playerID]
  1198. root="Graphics/Characters/base graphics/"
  1199. # Trainer backsprite
  1200. name=SPRITE_CONVERT_HASH["#{$game_player.character_name}"]
  1201. files.push(root+name+"/#{j}"+($PokemonGlobal.playerID+65).chr)
  1202. end
  1203. # Creating a blank bitmap
  1204. size_check=Bitmap.new("Graphics/Characters/#{$game_player.character_name}")
  1205. blank_bitmap=Bitmap.new(size_check.width,size_check.height)
  1206. # Pushing non existent files into the files_to_add array.
  1207. files_to_add=[]
  1208. for i in 0...files.length
  1209. if !File.exists?(files[i]+".png")
  1210. files_to_add.push(files[i]+".png")
  1211. end
  1212. end
  1213. if !files_to_add.empty?
  1214. Kernel.pbMessage("The game is missing one or more graphic files for the Character Customization.")
  1215. ret=Kernel.pbConfirmMessage("Would you like to add these files as blank placeholder sprites in order to let this Script work properly?")
  1216. if ret
  1217. files_to_add.length.times {|i| blank_bitmap.saveToPng(files_to_add[i])}
  1218. Kernel.pbMessage("The missing files were added to the Graphics/Characters/base graphics/ folder. The script will continue working as supposed now.")
  1219. else
  1220. Kernel.pbMessage("The script stopped running until these neccessary files were added:")
  1221. files_to_add.length.times{|i| Kernel.pbMessage(files_to_add[i])}
  1222. end
  1223. return ret
  1224. end
  1225. return true
  1226. end
  1227.  
  1228. def saveBase(filepath,folder)
  1229. return if !$Trainer
  1230. return if !filepath.is_a?(String) || !folder.is_a?(String)
  1231. name="Graphics/Characters/base graphics/"+folder+"/"+(@sprites["cmdwindow"].index).to_s
  1232. if File.exists?(name+($PokemonGlobal.playerID+65).chr+".png")
  1233. bmp=Bitmap.new(name+($PokemonGlobal.playerID+65).chr)
  1234. else
  1235. # Creating a blank bitmap
  1236. size_check=Bitmap.new("Graphics/Characters/#{$game_player.character_name}")
  1237. bmp=Bitmap.new(size_check.width,size_check.height)
  1238. end
  1239. # Safety Copy
  1240. if !File.exists?(filepath+"_safetyCopy"+".png") && $DEBUG
  1241. safetyCopy=Bitmap.new(filepath)
  1242. safetyCopy.saveToPng(filepath+"_safetyCopy"+".png")
  1243. end
  1244. bmp.saveToPng(filepath+".png")
  1245. bmp.saveToPng(filepath+"_base.png")
  1246. end
  1247.  
  1248. def saveAllBases
  1249. return if !$Trainer
  1250. # Trainer charsets
  1251. metadata=pbLoadMetadata
  1252. filenames=metadata[0][MetadataPlayerA+$PokemonGlobal.playerID]
  1253. for i in 0...filenames.length
  1254. if filenames[i].is_a?(String) && !(filenames[i]=="xxx")
  1255. filepath="Graphics/Characters/#{filenames[i]}"
  1256. folder=SPRITE_CONVERT_HASH[filenames[i]]
  1257. saveBase(filepath,folder)
  1258. end
  1259. end
  1260. # Trainer backsprite
  1261. helpr="trback00#{$PokemonGlobal.playerID}"
  1262. filepath="Graphics/Trainers/"
  1263. folder=SPRITE_CONVERT_HASH[helpr]
  1264. saveBase(filepath+helpr,folder)
  1265. # Intro Image/Trainercard Image
  1266. filepath="Graphics/Pictures/"
  1267. helpr=$Trainer.isFemale? ? "introGirl" : "introBoy" #Modify this line if you want more than two characters.
  1268. folder=SPRITE_CONVERT_HASH[helpr]
  1269. saveBase(filepath+helpr,folder)
  1270. # Map Player
  1271. helpr="mapPlayer00#{$PokemonGlobal.playerID}"
  1272. folder=SPRITE_CONVERT_HASH[helpr]
  1273. saveBase(filepath+helpr,folder)
  1274. end
  1275.  
  1276. def looping
  1277. frame=0
  1278. @dir=0
  1279. loop do
  1280. frame+=1
  1281. pos=0
  1282. Graphics.update
  1283. Input.update
  1284. @sprites["baseRep"].update
  1285. @sprites["walkSprite"].update
  1286. @sprites["cmdwindow"].update
  1287. if @sprites["cmdwindow"].index != @index
  1288. @index=@sprites["cmdwindow"].index
  1289. newname="examples/"+(@sprites["cmdwindow"].index).to_s+($PokemonGlobal.playerID+65).chr
  1290. if File.exists?("Graphics/Characters/base graphics/"+newname+".png")
  1291. @sprites["baseRep"].name=("Graphics/Characters/base graphics/"+newname)
  1292. end
  1293. newname=WALK_FOLDER+"/"+(@sprites["cmdwindow"].index).to_s+($PokemonGlobal.playerID+65).chr
  1294. if File.exists?("Graphics/Characters/base graphics/"+newname+".png")
  1295. @sprites["walkSprite"].charset=("base graphics/"+newname)
  1296. end
  1297. end
  1298. if Input.trigger?(Input::C) && Kernel.pbConfirmMessage("So you're choosing #{@commands.list[@index]}?")
  1299. saveAllBases
  1300. pbDisposeSpriteHash(@sprites)
  1301. updateTrainerOutfit
  1302. break
  1303. end
  1304. if frame%120==0
  1305. @dir+=1
  1306. @sprites["walkSprite"].src_rect.y=@y[@dir%4]
  1307. end
  1308. end
  1309. end
  1310. end
Add Comment
Please, Sign In to add comment