Advertisement
Diego-Mertens

cambios

May 18th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.22 KB | None | 0 0
  1. #===============================================================================
  2. # * Character Costumization made for Pokemon Essentials by shiney570
  3. # Version: 1.3.2
  4. #===============================================================================
  5.  
  6. # Set to false to disable the Character Customization.
  7. CHARACTER_CUSTOMIZATION = true
  8. # Set to false to lock the Character Customization to unlock it manually at a
  9. # point later in the game.
  10. UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT = true
  11. # whether to also fusion the base graphic or not. Remember:
  12. USE_BASE_GRAPHIC = false
  13.  
  14.  
  15.  
  16.  
  17. #Names of the headgears in order (true= unlocked by default, false=locked by default)
  18. HEADGEAR_ITEMS=[
  19. ["Gorra","Gorra F",true],
  20. ["Gorra Playera","Gorra Playera F",true],
  21. ["Gorro Invierno","Gorro Invierno F",true],
  22. ["Gorro Pikachu","Gorro Pikachu F",false],
  23. ["Gorro Eevee","Gorro Eevee F",false]
  24. ]
  25. # Names of the heads in order. (true= unlocked by default, false=locked by default)
  26. HEAD_ITEMS=[
  27. ["O. Normales","O. Normales F",true],
  28. ["Brock","Brock F",true],
  29. ["Chibi","Chibi F",true],
  30. ["Saltones","Saltones F",false]
  31. ]
  32.  
  33. # Names of the upperbodies in order. (true= unlocked by default, false=locked by default)
  34. UPPERBODY_ITEMS=[
  35. ["R. Normal","R. Normal F",true],
  36. ["Veraniega","Veraniega F",true],
  37. ["Sudadera","Sudadera F",true],
  38. ["Estilo Red","Estilo Hoja",false]
  39. ]
  40. # Names of the lowerbodies in order. (true= unlocked by default, false=locked by default)
  41. LOWERBODY_ITEMS=[
  42. ["P. Normales","P. Normales F",true],
  43. ["Cortos","Cortos F",true],
  44. ["Invierno","Invierno F",true],
  45. ["Pink","Pink F",false]
  46. ]
  47. # Names of the shoes in order. (true= unlocked by default, false=locked by default)
  48. SHOE_ITEMS=[
  49. ["Blue & Red","Blue & Red F",true],
  50. ["Purple & Orange","Purple & Orange F",true],
  51. ["Red, Pink & Green","Red, Pink & Green F",true]
  52. ]
  53. # Names of the accessoires in order. (true= unlocked by default, false=locked by default)
  54. ACCESSOIRE_ITEMS=[
  55. ["Green Backpack","Green Backpack F",true],
  56. ["Blue Backpack","Blue Backpack F",true],
  57. ["Red Backpack","Red Backpack F",true]
  58. ]
  59.  
  60. COLOR_ITEMS=[
  61. ["Normal","Normal F",true],
  62. ["Rojo","Rojo F",true],
  63. ["Azul","Azul F",true],
  64. ["Amarillo","Amarillo F",true]
  65. ]
  66. #===============================================================================
  67. # * USEFUL METHODS
  68. #===============================================================================
  69. def pbTrainerNotDefined
  70. if !defined?($Trainer)
  71. if $DEBUG
  72. 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.")
  73. end
  74. return true
  75. else
  76. return false
  77. end
  78. end
  79.  
  80.  
  81.  
  82. # This method updates the trainer outfit
  83. def updateTrainerOutfit
  84. next_id=$Trainer.metaID==1 ? 0 : 1
  85. id=$Trainer.metaID
  86. pbChangePlayer(next_id)
  87. pbWait(1)
  88. pbChangePlayer(id)
  89. end
  90.  
  91. # Gives the player randomized clothes (e.g good thing for randomizer challenges)
  92. def randomizeOutfit
  93. return false if pbTrainerNotDefined
  94. $Trainer.headgear=rand(HEADGEAR_ITEMS.length)
  95. $Trainer.head=rand(HEAD_ITEMS.length)
  96. $Trainer.upperbody=rand(UPPERBODY_ITEMS.length)
  97. $Trainer.lowerbody=rand(LOWERBODY_ITEMS.length)
  98. $Trainer.shoe=rand(SHOE_ITEMS.length)
  99. $Trainer.accessoire=rand(ACCESSOIRE_ITEMS.length)
  100. saveAllCustomizedBitmapsToFolder
  101. updateTrainerOutfit
  102. end
  103.  
  104. # Method for changing a certain accessory.
  105. def dressAccessory(accessory,color=0,convertation=true)
  106. return false if pbTrainerNotDefined
  107. return false if characterizationException
  108. return false if !accessory.is_a?(String)
  109. arr=retArrayAndNumber(accessory,false)
  110. return false if !arr
  111. bodypart=arr[0]; var=arr[1]
  112. if bodypart[0][1]==(false || true) # Checking if the array is multidimensional
  113. bodypart=cnvrtStrArr(bodypart)
  114. end
  115. if !$game_switches[200]
  116. lastheadgear=0
  117. lasthead=0
  118. lastupper=0
  119. lastlower=0
  120. lastshoe=0
  121. lastacc=0
  122. $game_switches[200]=true
  123. end
  124. for i in 0...bodypart.length
  125. if bodypart[i][$Trainer.gender]==accessory
  126. case var
  127. when 1
  128. $Trainer.headgear=i
  129. @colorheadgear = color
  130. lastheadgear = color
  131. @colorhead = lasthead
  132. @colorupperbody = lastupper
  133. @colorlowerbody = lastlower
  134. @colorshoes = lastshoe
  135. @coloraccesoire = lastacc
  136. when 2
  137. $Trainer.head=i
  138. @colorhead = color
  139. lasthead = color
  140. @colorheadgear = lastheadgear
  141. @colorupperbody = lastupper
  142. @colorlowerbody = lastlower
  143. @colorshoes = lastshoe
  144. @coloraccesoire = lastacc
  145. when 3
  146. $Trainer.upperbody=i
  147. @colorupperbody = color
  148. lastupper = color
  149. @colorheadgear = lastheadgear
  150. @colorhead = lasthead
  151. @colorlowerbody = lastlower
  152. @colorshoes = lastshoe
  153. @coloraccesoire = lastacc
  154. when 4
  155. $Trainer.lowerbody=i
  156. @colorlowerbody = color
  157. lastlower = color
  158. @colorheadgear = lastheadgear
  159. @colorhead = lasthead
  160. @colorupperbody = lastupper
  161. @colorshoes = lastshoe
  162. @coloraccesoire = lastacc
  163. when 5
  164. $Trainer.shoe=i
  165. @colorshoes = color
  166. lastshoe = color
  167. @colorheadgear = lastheadgear
  168. @colorhead = lasthead
  169. @colorupperbody = lastupper
  170. @colorlowerbody = lastlower
  171. @coloraccesoire = lastacc
  172. when 6
  173. $Trainer.accessoire=i
  174. @coloraccesoire = color
  175. lastacc = color
  176. @colorheadgear = lastheadgear
  177. @colorhead = lasthead
  178. @colorupperbody = lastupper
  179. @colorlowerbody = lastlower
  180. @colorshoes = lastshoe
  181. end
  182. saveAllCustomizedBitmapsToFolder
  183. updateTrainerOutfit
  184. return
  185. end
  186. end
  187. end
  188.  
  189. # Method for checking whether the player wears a certain Accessory.
  190. def wearingAccessory?(accessory)
  191. return false if pbTrainerNotDefined
  192. return false if characterizationException
  193. arr=retArrayAndNumber(accessory)
  194. clothes=arr[0]; bodypart=arr[1]
  195. current=$Trainer.headgear if @accessoryNames[@index]=="headgear"
  196. current=$Trainer.head if @accessoryNames[@index]=="head"
  197. current=$Trainer.upperbody if @accessoryNames[@index]=="upperbody"
  198. current=$Trainer.lowerbody if @accessoryNames[@index]=="lowerbody"
  199. current=$Trainer.shoe if @accessoryNames[@index]=="shoe"
  200. current=$Trainer.accessoire if @accessoryNames[@index]=="accessoire"
  201. return false if !(clothes || current)
  202. if accessory.is_a?(String)
  203. for i in 0...clothes.length
  204. if clothes[i]==accessory
  205. return (accessory==clothes[current])
  206. end
  207. end
  208. end
  209. return false
  210. end
  211.  
  212. # Method for unlocking clothes.
  213. def unlockAccessory(accessory)
  214. return false if pbTrainerNotDefined
  215. arr=retArrayAndNumber(accessory)
  216. bodypart=arr[1]-1
  217. for i in 0...arr[0].length
  218. index=i if arr[0][i]==accessory
  219. end
  220. (if $DEBUG; p "There was an issue unlocking the accessory."; end; return) if !index
  221. $Trainer.clothesUnlocking[bodypart][index]=true
  222. end
  223.  
  224. # Method for locking clothes
  225. def lockAccessory(accessory)
  226. return false if pbTrainerNotDefined
  227. arr=retArrayAndNumber(accessory)
  228. bodypart=arr[1]
  229. (current=$Trainer.headgear; name="Headgear") if bodypart==1
  230. (current=$Trainer.head; name="Head") if bodypart==2
  231. (current=$Trainer.upperbody; name="Upperbody") if bodypart==3
  232. (current=$Trainer.lowerbody; name="Lowerbody") if bodypart==4
  233. (current=$Trainer.shoe; name="Shoe")if bodypart==5
  234. (current=$Trainer.accessoire; name="Accessoire")if bodypart==6
  235.  
  236. # Checking if player wears the accessory to lock
  237. for i in 0...arr[0].length
  238. if arr[0][i]==accessory
  239. index=i
  240. #p i; p current
  241. if i==current
  242. Kernel.pbMessage("#{$Trainer.name} misses the #{accessory} #{name} and puts on the #{arr[0][0]} one instead.")
  243. $Trainer.headgear=0 if bodypart==1
  244. $Trainer.head=0 if bodypart==2
  245. $Trainer.upperbody=0 if bodypart==3
  246. $Trainer.lowerbody=0 if bodypart==4
  247. $Trainer.shoe=0 if bodypart==5
  248. $Trainer.accessoire=0 if bodypart==6
  249. end
  250. end
  251. end
  252. (if $DEBUG; p "There was an issue locking the accessory"; end; return) if !index
  253. $Trainer.clothesUnlocking[bodypart][index]=false
  254. saveAllCustomizedBitmapsToFolder
  255. updateTrainerOutfit
  256. end
  257.  
  258.  
  259. def retArrayAndNumber(accessory,convertation=true)
  260. (bodypart=HEADGEAR_ITEMS; var=1) if cnvrtStrArr(HEADGEAR_ITEMS).include?(accessory)
  261. (bodypart=HEAD_ITEMS; var=2) if cnvrtStrArr(HEAD_ITEMS).include?(accessory)
  262. (bodypart=UPPERBODY_ITEMS; var=3) if cnvrtStrArr(UPPERBODY_ITEMS).include?(accessory)
  263. (bodypart=LOWERBODY_ITEMS; var=4) if cnvrtStrArr(LOWERBODY_ITEMS).include?(accessory)
  264. (bodypart=SHOE_ITEMS; var=5) if cnvrtStrArr(SHOE_ITEMS).include?(accessory)
  265. (bodypart=ACCESSOIRE_ITEMS; var=6) if cnvrtStrArr(ACCESSOIRE_ITEMS).include?(accessory)
  266. return [cnvrtStrArr(bodypart),var] if convertation
  267. return [bodypart,var]
  268. end
  269.  
  270. def characterizationException
  271. return true if CHARACTER_CUSTOMIZATION==false
  272. return true if UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT==false &&
  273. $Trainer.character_customization==false
  274. return true if !$Trainer
  275. return true if !$Trainer.headgear
  276. return false
  277. end
  278.  
  279. def cnvrtStrArr(array)
  280. ret=[]
  281. for i in 0...array.length
  282. ret.push(array[i][$Trainer.gender])
  283. end
  284. return ret
  285. end
  286.  
  287. def cnvrtBoolArr(array)
  288. ret=[]
  289. for i in 0...array.length
  290. ret.push(array[i][2])
  291. end
  292. return ret
  293. end
  294.  
  295. def retUnlockedAccessoryArray(clothes)
  296. arr=retArrayAndNumber(clothes[0])
  297. var=arr[1]
  298. ret=[]
  299. for i in 0...clothes.length
  300. ret.push clothes[i] if $Trainer.clothesUnlocking[var-1][i]==true
  301. end
  302. return ret
  303. end
  304. #===============================================================================
  305. # * Initializing class PokeBattle_Trainer objects.
  306. #===============================================================================
  307. class PokeBattle_Trainer
  308. attr_accessor :character_customization
  309. attr_accessor :headgear
  310. attr_accessor :head
  311. attr_accessor :upperbody
  312. attr_accessor :lowerbody
  313. attr_accessor :shoe
  314. attr_accessor :accessoire
  315. attr_accessor :colorheadgear
  316. attr_accessor :colorhead
  317. attr_accessor :colorupperbody
  318. attr_accessor :colorlowerbody
  319. attr_accessor :colorshoes
  320. attr_accessor :coloraccesoire
  321. attr_accessor :clothesUnlocking
  322.  
  323. def character_customization
  324. if !@character_customization
  325. @character_customization=UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT
  326. end
  327. return @character_customization
  328. end
  329.  
  330. def character_customization=(boolean)
  331. if boolean != true && boolean != false # Determining if object is a boolean
  332. if $DEBUG
  333. p "only $Trainer.character_customization = true/false is valid!"
  334. end
  335. return
  336. end
  337. @character_customization=boolean
  338. end
  339.  
  340. def headgear
  341. if !@headgear
  342. @headgear=0
  343. end
  344. return @headgear
  345. end
  346.  
  347. def headgear=(value)
  348. if value<0 || value>(HEADGEAR_ITEMS.length-1)
  349. if $DEBUG
  350. p "the value for $Trainer.headgear is out of range!"
  351. end
  352. return
  353. end
  354. @headgear=value
  355. end
  356.  
  357. def head
  358. if !@head
  359. @head=0
  360. end
  361. return @head
  362. end
  363.  
  364. def head=(value)
  365. if value<0 || value>(HEAD_ITEMS.length-1)
  366. if $DEBUG
  367. p "the value for $Trainer.head is out of range!"
  368. end
  369. return
  370. end
  371. @head=value
  372. end
  373.  
  374. def upperbody
  375. if !@upperbody
  376. @upperbody=0
  377. end
  378. return @upperbody
  379. end
  380.  
  381. def upperbody=(value)
  382. if value<0 || value>(UPPERBODY_ITEMS.length-1)
  383. if $DEBUG
  384. p "the value for $Trainer.upperbody is out of range!"
  385. end
  386. return
  387. end
  388. @upperbody=value
  389. end
  390.  
  391. def lowerbody
  392. if !@lowerbody
  393. @lowerbody=0
  394. end
  395. return @lowerbody
  396. end
  397.  
  398. def lowerbody=(value)
  399. if value<0 || value>(LOWERBODY_ITEMS.length-1)
  400. if $DEBUG
  401. p "the value for $Trainer.lowerbody is out of range!"
  402. end
  403. return
  404. end
  405. @lowerbody=value
  406. end
  407.  
  408. def shoe
  409. if !@shoe
  410. @shoe=0
  411. end
  412. return @shoe
  413. end
  414.  
  415. def shoe=(value)
  416. if value<0 || value>(SHOE_ITEMS.length-1)
  417. if $DEBUG
  418. p "the value for $Trainer.shoe is out of range!"
  419. end
  420. return
  421. end
  422. @shoe=value
  423. end
  424.  
  425. def accessoire
  426. if !@accessoire
  427. @accessoire=0
  428. end
  429. return @accessoire
  430. end
  431.  
  432. def accessoire=(value)
  433. if value<0 || value>(ACCESSOIRE_ITEMS.length-1)
  434. if $DEBUG
  435. p "the value for $Trainer.accessoire is out of range!"
  436. end
  437. return
  438. end
  439. @accessoire=value
  440. end
  441.  
  442. def colorheadgear=(value)
  443. if value==-1
  444. if $DEBUG
  445. p "the value for $Trainer.@colorcl is out of range!"
  446. end
  447. return
  448. end
  449. @colorheadgear=value
  450. end
  451. def colorhead=(value)
  452. if value==-1
  453. if $DEBUG
  454. p "the value for $Trainer.@colorcl is out of range!"
  455. end
  456. return
  457. end
  458. @colorhead=value
  459. end
  460. def colorupperbody=(value)
  461. if value==-1
  462. if $DEBUG
  463. p "the value for $Trainer.@colorcl is out of range!"
  464. end
  465. return
  466. end
  467. @colorupperbody=value
  468. end
  469. def colorlowerbody=(value)
  470. if value==-1
  471. if $DEBUG
  472. p "the value for $Trainer.@colorcl is out of range!"
  473. end
  474. return
  475. end
  476. @colorlowerbody=value
  477. end
  478. def colorshoes=(value)
  479. if value==-1
  480. if $DEBUG
  481. p "the value for $Trainer.@colorcl is out of range!"
  482. end
  483. return
  484. end
  485. @colorshoes=value
  486. end
  487. def colorcoloraccesoire=(value)
  488. if value==-1
  489. if $DEBUG
  490. p "the value for $Trainer.@colorcl is out of range!"
  491. end
  492. return
  493. end
  494. @colorcoloraccesoire=value
  495. end
  496.  
  497. def clothesUnlocking
  498. if !@clothesUnlocking
  499. @clothesUnlocking=[]
  500. @clothesUnlocking.push cnvrtBoolArr(HEADGEAR_ITEMS)
  501. @clothesUnlocking.push cnvrtBoolArr(HEAD_ITEMS)
  502. @clothesUnlocking.push cnvrtBoolArr(UPPERBODY_ITEMS)
  503. @clothesUnlocking.push cnvrtBoolArr(LOWERBODY_ITEMS)
  504. @clothesUnlocking.push cnvrtBoolArr(SHOE_ITEMS)
  505. @clothesUnlocking.push cnvrtBoolArr(ACCESSOIRE_ITEMS)
  506. end
  507. return @clothesUnlocking
  508. end
  509.  
  510. end
  511.  
  512. #===============================================================================
  513. # * Drawing the customized Bitmap
  514. #===============================================================================
  515. def drawCharacterCustomizedBitmap(filepath,bmp,trainerClass=$Trainer)
  516. return nil if !filepath.is_a?(String)
  517. return bitmap if !trainerClass
  518. return bitmap if CHARACTER_CUSTOMIZATION==false
  519. return bitmap if UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT==false &&
  520. trainerClass.character_customization==false
  521. addAdditionalBitmap(filepath+"_shoe"+(trainerClass.shoe).to_s+".png",bmp) if @colorshoes ==0
  522. addAdditionalBitmap(filepath+"_lowerbody"+(trainerClass.lowerbody).to_s+".png",bmp) if @colorlowerbody ==0
  523. addAdditionalBitmap(filepath+"_upperbody"+(trainerClass.upperbody).to_s+".png",bmp) if @colorupperbody ==0
  524. addAdditionalBitmap(filepath+"_head"+(trainerClass.head).to_s+".png",bmp) if @colorhead ==0
  525. addAdditionalBitmap(filepath+"_headgear"+(trainerClass.headgear).to_s+".png",bmp) if @colorheadgear ==0
  526. addAdditionalBitmap(filepath+"_accessoire"+(trainerClass.accessoire).to_s+".png",bmp) if @coloraccesoire ==0
  527. addAdditionalBitmap(filepath+"_shoe"+(trainerClass.shoe).to_s+(@colorshoes).to_s+".png",bmp) if @colorshoes !=0
  528. addAdditionalBitmap(filepath+"_lowerbody"+(trainerClass.lowerbody).to_s+"-"+(@colorlowerbody).to_s+".png",bmp) if @colorlowerbody !=0
  529. addAdditionalBitmap(filepath+"_upperbody"+(trainerClass.upperbody).to_s+"-"+(@colorupperbody).to_s+".png",bmp) if @colorupperbody !=0
  530. addAdditionalBitmap(filepath+"_head"+(trainerClass.head).to_s+"-"+(@colorhead).to_s+".png",bmp) if @colorhead !=0
  531. addAdditionalBitmap(filepath+"_headgear"+(trainerClass.headgear).to_s+"-"+(@colorheadgear).to_s+".png",bmp) if @colorheadgear !=0
  532. addAdditionalBitmap(filepath+"_accessoire"+(trainerClass.accessoire).to_s+"-"+(@coloraccesoire).to_s+".png",bmp) if @coloraccesoire !=0
  533.  
  534.  
  535. end
  536.  
  537. def saveAllCustomizedBitmapsToFolder
  538. return if !$Trainer
  539. # Trainer charsets
  540. metadata=pbLoadMetadata
  541. filenames=metadata[0][8+$Trainer.gender]
  542. for i in 0...filenames.length
  543. if filenames[i].is_a?(String)
  544. filepath="Graphics/Characters/trchar00#{$Trainer.gender}"
  545. saveCustomizedBitmapToFolder(filepath)
  546. end
  547. end
  548. # Trainer backsprite
  549. saveCustomizedBitmapToFolder("Graphics/Characters/trback00#{$Trainer.gender}")
  550. # Intro Image/Trainercard Image
  551. filepath="Graphics/Pictures/"
  552. filepath+= $Trainer.isFemale? ? "introGirl" : "introBoy"
  553. saveCustomizedBitmapToFolder(filepath)
  554. # Map Player
  555. saveCustomizedBitmapToFolder("Graphics/Pictures/mapPlayer00#{$Trainer.gender}")
  556. end
  557.  
  558. # saves the costumized bitmaps to the actual game folders.
  559. def saveCustomizedBitmapToFolder(filepath)
  560. return if !$Trainer
  561. return if !filepath.is_a?(String)
  562. bmp=Bitmap.new(filepath)
  563. # Safety Copy
  564. if !File.exists?(filepath+"_safetyCopy"+".png") && $DEBUG
  565. safetyCopy=Bitmap.new(filepath)
  566. safetyCopy.saveToPng(filepath+"_safetyCopy"+".png")
  567. end
  568. # Deleting old file
  569. if !USE_BASE_GRAPHIC
  570. bmp.clear
  571. end
  572. drawCharacterCustomizedBitmap(filepath,bmp)
  573. bmp.saveToPng(filepath+".png")
  574. end
  575.  
  576.  
  577.  
  578. # Method for add additional bitmaps to a bitmap.
  579. def addAdditionalBitmap(filepath,formerBitmap)
  580. if File.exists?(filepath)
  581. formerBitmap.blt(0,0,Bitmap.new(filepath),Rect.new(0,0,Graphics.width,Graphics.height))
  582. end
  583. end
  584. #===============================================================================
  585. # * Character Customization Scene
  586. #===============================================================================
  587. class CharacterCustomizationScene
  588.  
  589. def initialize
  590. # Checks if the Script is functional.
  591. if !defined?($Trainer.clothesUnlocking)
  592. 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.")
  593. if Kernel.pbConfirmMessage("Would you like to save the game now?")
  594. if !$Trainer
  595. 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.")
  596. else
  597. pbSave
  598. Kernel.pbMessage("The game was saved, try again now.")
  599. end
  600. end
  601. return
  602. end
  603. return if !addNecessaryFiles
  604. @index=0
  605. @index2=0
  606. @new_val=2
  607. @firstSelection=true
  608. @secondSelection=false
  609. @sprites={}
  610. @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  611. @viewport.z=99999
  612. @sprites["window"]=SpriteWindow_Base.new(Graphics.width/2-64,Graphics.height/2-128,128,128)
  613. @sprites["window2"]=SpriteWindow_Base.new(Graphics.width/2-64,Graphics.height/2,128,128)
  614. @sprites["window2"].visible=false
  615. @sprites["window3"]=SpriteWindow_Base.new(128,256,128,128)
  616. @sprites["window3"].visible=false
  617. @sprites["player"]=TrainerWalkingCharSprite.new($game_player.character_name,@viewport)
  618. @sprites["player"].x=Graphics.width/2-@sprites["player"].bitmap.width/8
  619. @sprites["player"].y=Graphics.height/2-@sprites["player"].bitmap.height/8 -64
  620. @sprites["player"].z=9999999
  621. @sprites["playerAccessory"]=TrainerWalkingCharSprite.new($game_player.character_name+"_headgear0",@viewport)
  622. @sprites["playerAccessory"].x=Graphics.width/2-@sprites["playerAccessory"].bitmap.width/8
  623. @sprites["playerAccessory"].y=Graphics.height/2-@sprites["playerAccessory"].bitmap.height/8 +64
  624. @sprites["playerAccessory"].z=9999999
  625. @sprites["playerAccessory"].ox+=@sprites["playerAccessory"].bitmap.width/16
  626. @sprites["playerAccessory"].oy+=@sprites["playerAccessory"].bitmap.height/16
  627. @sprites["playerAccessory"].zoom_x=2
  628. @sprites["playerAccessory"].zoom_y=2
  629. @sprites["playerAccessory"].visible=false
  630. @playerAccessory=@sprites["playerAccessory"]
  631. charheight=@sprites["player"].bitmap.height
  632. @y=[charheight/4*2,0,charheight/4,charheight/4*3]
  633. @sprites["heading1"]=Window_CommandPokemonEx.new(["BODYPART"])
  634. @sprites["heading1"].viewport=@viewport
  635. @sprites["heading1"].index=1
  636. @sprites["heading2"]=Window_CommandPokemonEx.new(["HEADGEAR"])
  637. @sprites["heading2"].viewport=@viewport
  638. @sprites["heading2"].index=1
  639. @sprites["heading2"].x=Graphics.width-@sprites["heading2"].width
  640. @sprites["heading3"]=Window_CommandPokemonEx.new(["COLOR"])
  641. @sprites["heading3"].viewport=@viewport
  642. @sprites["heading3"].index=1
  643. @sprites["heading3"].x=Graphics.width/2-(@sprites["heading3"].width*2)
  644. @commands = []
  645. @currentList = "main"
  646. lista = @currentList
  647. @commands=CommandMenuList.new
  648. @commands.add("main","headgear",_INTL("Headgear"))
  649. @commands.add("main","head",_INTL("Head"))
  650. @commands.add("main","upperbody",_INTL("Upperbody"))
  651. @commands.add("main","lowerbody",_INTL("Lowerbody"))
  652. @commands.add("main","accessoire",_INTL("Accessoire"))
  653. @commands.add("main","shoes",_INTL("Shoes"))
  654. @commands2 = []
  655. @currentList = "main"
  656. @commands2=CommandMenuList.new
  657. @commands2.add("main","normal",_INTL("Color 1"))
  658. @commands2.add("main","azul",_INTL("Color 2"))
  659. @commands2.add("main","rojo",_INTL("Color 3"))
  660. @sprites["cmdwindow"]=Window_CommandPokemonEx.new(@commands.list)
  661. @sprites["cmdwindow"].viewport=@viewport
  662. @sprites["cmdwindow"].y=@sprites["heading1"].height
  663. @sprites["cmdwindow2"]=Window_CommandPokemonEx.new(retListCmdBox2)
  664. @sprites["cmdwindow2"].viewport=@viewport
  665. @sprites["cmdwindow2"].y=@sprites["heading2"].height
  666. @sprites["cmdwindow2"].x=Graphics.width-@sprites["cmdwindow2"].width
  667. @sprites["cmdwindow2"].z-=1
  668. @sprites["cmdwindow2"].index=-1
  669. @sprites["cmdwindow3"]=Window_CommandPokemonEx.new(@commands2.list)
  670. @sprites["cmdwindow3"].viewport=@viewport
  671. @sprites["cmdwindow3"].y=256
  672. @sprites["cmdwindow3"].x=128
  673. @sprites["cmdwindow3"].z=99999
  674. @sprites["cmdwindow3"].index=-1
  675. @cmdwindow2=@sprites["cmdwindow2"]
  676. @cmdwindow3=@sprites["cmdwindow3"]
  677. @accessoryNames=["headgear","head","upperbody","lowerbody","shoe","accessoire"]
  678. @colorNames=["normal","azul","rojo"]
  679. update
  680. end
  681.  
  682. # Method for adding necessary missing graphic files.
  683. def addNecessaryFiles
  684. files=[]
  685. # Pushing all files that could possibly be missing into the files array.
  686. HEADGEAR_ITEMS.length.times{|i| files.push("_headgear#{i}")}
  687. HEAD_ITEMS.length.times{|i| files.push("_head#{i}")}
  688. UPPERBODY_ITEMS.length.times{|i| files.push("_upperbody#{i}")}
  689. LOWERBODY_ITEMS.length.times{|i| files.push("_lowerbody#{i}")}
  690. SHOE_ITEMS.length.times{|i| files.push("_shoe#{i}")}
  691. ACCESSOIRE_ITEMS.length.times{|i| files.push("_accessoire#{i}")}
  692. # Creating a blank bitmap
  693. size_check=Bitmap.new("Graphics/Characters/#{$game_player.character_name}")
  694. blank_bitmap=Bitmap.new(size_check.width,size_check.height)
  695. files_to_add=[]
  696. # Pushing non existent files into the files_to_add array.
  697. for i in 0...files.length
  698. if !File.exists?("Graphics/Characters/#{$game_player.character_name}#{files[i]}"+".png")
  699. files_to_add.push("Graphics/Characters/#{$game_player.character_name}#{files[i]}"+".png")
  700. end
  701. end
  702. if !files_to_add.empty?
  703. Kernel.pbMessage("The game is missing one or more graphic files for the Character Customization.")
  704. ret=Kernel.pbConfirmMessage("Would you like to add these files as blank placeholder sprites in order to let this Script work properly?")
  705. if ret
  706. files_to_add.length.times {|i| blank_bitmap.saveToPng(files_to_add[i])}
  707. Kernel.pbMessage("The missing files were added to the Graphics/Characters/ folder. The script will continue working as supposed now.")
  708. else
  709. Kernel.pbMessage("The script stopped running until these neccessary files were added:")
  710. files_to_add.length.times{|i| Kernel.pbMessage(files_to_add[i])}
  711. end
  712. return ret
  713. end
  714. return true
  715. end
  716.  
  717. # returns the index of the Accessory in the actual list.
  718. def getAccessoryIndex
  719. item=@list[@cmdwindow2.index]
  720. arr=HEADGEAR_ITEMS if @accessoryNames[@index]=="headgear"
  721. arr=HEAD_ITEMS if @accessoryNames[@index]=="head"
  722. arr=UPPERBODY_ITEMS if @accessoryNames[@index]=="upperbody"
  723. arr=LOWERBODY_ITEMS if @accessoryNames[@index]=="lowerbody"
  724. arr=SHOE_ITEMS if @accessoryNames[@index]=="shoe"
  725. arr=ACCESSOIRE_ITEMS if @accessoryNames[@index]=="accessoire"
  726. arr=cnvrtStrArr(arr)
  727. for i in 0...arr.length
  728. return i if arr[i]==item
  729. end
  730. end
  731.  
  732. def getColorIndex
  733. item=@list[@cmdwindow3.index]
  734. ropa=@accessoryNames[@index]
  735. @colorheadgear=0 if @colorNames[@index]=="normal"
  736. @colorheadgear=1 if @colorNames[@index]=="azul"
  737. @colorheadgear=2 if @colorNames[@index]=="rojo"
  738. @colorhead=0 if @colorNames[@index]=="normal"
  739. @colorhead=1 if @colorNames[@index]=="azul"
  740. @colorhead=2 if @colorNames[@index]=="rojo"
  741. @colorupperbody=0 if @colorNames[@index]=="normal"
  742. @colorupperbody=1 if @colorNames[@index]=="azul"
  743. @colorupperbody=2 if @colorNames[@index]=="rojo"
  744. @colorlowerbody=0 if @colorNames[@index]=="normal"
  745. @colorlowerbody=1 if @colorNames[@index]=="azul"
  746. @colorlowerbody=2 if @colorNames[@index]=="rojo"
  747. @colorshoes=0 if @colorNames[@index]=="normal"
  748. @colorshoes=1 if @colorNames[@index]=="azul"
  749. @colorshoes=2 if @colorNames[@index]=="rojo"
  750. @colorshoes=0 if @colorNames[@index]=="normal"
  751. @colorshoes=1 if @colorNames[@index]=="azul"
  752. @colorshoes=2 if @colorNames[@index]=="rojo"
  753. end
  754.  
  755. # updates the Accessory bitmap
  756. def updateAccessoryBitmap
  757. @sprites["playerAccessory"].bitmap.clear
  758. name=$game_player.character_name+"_"+@accessoryNames[@index]+(getAccessoryIndex).to_s
  759. if File.exists?("Graphics/Characters/"+name+".png") && @index2 != @cmdwindow2.itemCount
  760. @sprites["playerAccessory"].charset=name
  761. end
  762. end
  763. def updateColorBitmap
  764. @sprites["playerAccessory"].bitmap.clear
  765. name=$game_player.character_name+"_"+@accessoryNames[@index]+(getAccessoryIndex).to_s+"-"+(getColorIndex).to_s
  766. if File.exists?("Graphics/Characters/"+name+".png") && @index2 != @cmdwindow3.itemCount
  767. @sprites["playerAccessory"].charset=name
  768. end
  769. end
  770.  
  771. # returns the list of the right hand command box.
  772. def retListCmdBox2
  773. @list=HEADGEAR_ITEMS if @index==0
  774. @list=HEAD_ITEMS if @index==1
  775. @list=UPPERBODY_ITEMS if @index==2
  776. @list=LOWERBODY_ITEMS if @index==3
  777. @list=SHOE_ITEMS if @index==4
  778. @list=ACCESSOIRE_ITEMS if @index==5
  779. @list=retUnlockedAccessoryArray(cnvrtStrArr(@list))
  780. @list=["---NONE---"] if !@list
  781. @list.push("Back") if !@list.include?("Back")
  782. return @list
  783. end
  784.  
  785. # this updates the heading. since there is no command for updating
  786. # command boxes it'll always create a new fresh command box sprite.
  787. def updateHeading2
  788. @sprites["heading#{@new_val}"].dispose
  789. @sprites["cmdwindow#{@new_val}"].dispose
  790. @new_val+=1
  791. @sprites["heading#{@new_val}"]=Window_CommandPokemonEx.new([@commands.list[@index].upcase])
  792. @sprites["heading#{@new_val}"].viewport=@viewport
  793. @sprites["heading#{@new_val}"].index=1
  794. @sprites["heading#{@new_val}"].x=Graphics.width-@sprites["heading#{@new_val}"].width
  795. @sprites["heading#{@new_val}"].z-=1
  796. @sprites["cmdwindow#{@new_val}"]=Window_CommandPokemonEx.new(retListCmdBox2)
  797. @cmdwindow2=@sprites["cmdwindow#{@new_val}"]
  798. @cmdwindow2.viewport=@viewport
  799. @cmdwindow2.y=@sprites["heading#{@new_val}"].height
  800. @cmdwindow2.x=Graphics.width-@sprites["cmdwindow#{@new_val}"].width
  801. @cmdwindow2.index= -1
  802. end
  803.  
  804.  
  805. # checks whether the index of the left command box has changed or not.
  806. def indexChanged
  807. if @index2 != @index
  808. @index2=@index
  809. return true
  810. end
  811. return false
  812. end
  813.  
  814. # checks whether the index or the right command box has changed or not.
  815. def cmdWindow2IndexChanged
  816. if !@cmdWindow2Index
  817. @cmdWindow2Index=@cmdwindow2.index
  818. return false
  819. elsif @cmdWindow2Index != @cmdwindow2.index
  820. @cmdWindow2Index=@cmdwindow2.index
  821. return true
  822. end
  823. return false
  824. end
  825. def cmdWindow3IndexChanged
  826. if !@cmdWindow3Index
  827. @cmdWindow3Index=@cmdwindow3.index
  828. return false
  829. elsif @cmdWindow3Index != @cmdwindow3.index
  830. @cmdWindow3Index=@cmdwindow3.index
  831. return true
  832. end
  833. return false
  834. end
  835.  
  836.  
  837.  
  838.  
  839. # updates the scene.
  840. def update
  841. frame=0
  842. @dir=0
  843. loop do
  844. frame+=1
  845. pos=0
  846. Graphics.update
  847. Input.update
  848. @sprites["player"].update
  849. @sprites["playerAccessory"].update
  850. if @firstSelection
  851. @sprites["cmdwindow"].update
  852. @index=@sprites["cmdwindow"].index
  853. elsif @secondSelection
  854. @cmdwindow2.update
  855. else
  856. @cmdwindow3.update
  857. end
  858. if indexChanged
  859. updateHeading2
  860. end
  861. if cmdWindow2IndexChanged && @cmdwindow2.index != -1
  862. updateAccessoryBitmap #if @cmdwindow2.index != @cmdwindow2.
  863. end
  864. if cmdWindow3IndexChanged && @cmdwindow3.index != -1
  865. updateColorBitmap
  866. end
  867. if Input.trigger?(Input::C)
  868. # Pressing C on the left command box.
  869. if @firstSelection
  870. @cmdwindow2.index=0
  871. @firstSelection=false
  872. @secondSelection=true
  873. @sprites["playerAccessory"].visible=true
  874. elsif @secondSelection
  875. # Pressing C on the right command box.
  876. @cmdwindow3.index=0
  877. @sprites["heading3"].visible=true
  878. @sprites["heading1"].visible=false
  879. @secondSelection=false
  880. if @cmdwindow2.index==(@cmdwindow2.itemCount-1) # Cancel
  881. @cmdwindow2.index=-1; @cmdwindow2.update
  882. @secondSelection=false
  883. @firstSelection=true
  884. end
  885. else
  886. if @cmdwindow3.index==(@cmdwindow3.itemCount-1) # Cancel
  887. @cmdwindow3.index=-1; @cmdwindow3.update
  888. else
  889. changeClothes
  890. @sprites["player"].bitmap.clear
  891. @sprites["player"].charset=$game_player.character_name
  892. end
  893. end
  894. end
  895.  
  896. if Input.trigger?(Input::B)
  897. # cancels the scene.
  898. if @firstSelection && Kernel.pbConfirmMessage("Have you finished?")
  899. updateTrainerOutfit
  900. pbDisposeSpriteHash(@sprites)
  901. break
  902. # goes back to the left command box.
  903. elsif !@firstSelection && @secondSelection
  904. @cmdwindow2.index=-1; @cmdwindow2.update
  905. @firstSelection=true
  906. @sprites["window2"].visible=false
  907. @sprites["playerAccessory"].visible=false
  908. elsif !@firstSelection && !@secondSelection
  909. @secondSelection=true
  910. @sprites["playerAccessory"].visible=false
  911. @sprites["window3"].visible=false
  912. end
  913. end
  914. # updates the walking sprite.
  915. if frame%120==0
  916. @dir+=1
  917. @sprites["player"].src_rect.y=@y[@dir%4]
  918. @sprites["playerAccessory"].src_rect.y=@sprites["player"].src_rect.y
  919. end
  920. end
  921. end
  922.  
  923. # updates the outfit as well as the variables which are responsable for it.
  924. def changeClothes
  925. dressAccessory(@list[@cmdwindow2.index],false)
  926. case @sprites["cmdwindow"].index
  927. when 0
  928. $Trainer.headgear=getAccessoryIndex
  929. $Trainer.colorheadgear=getColorIndex
  930. when 1
  931. $Trainer.head=getAccessoryIndex
  932. $Trainer.colorhead=getColorIndex
  933. when 2
  934. $Trainer.upperbody=getAccessoryIndex
  935. $Trainer.colorupperbody=getColorIndex
  936. when 3
  937. $Trainer.lowerbody=getAccessoryIndex
  938. $Trainer.colorlowerbody=getColorIndex
  939. when 4
  940. $Trainer.shoe=getAccessoryIndex
  941. $Trainer.colorshoes=getColorIndex
  942. when 5
  943. $Trainer.accessoire=getAccessoryIndex
  944. $Trainer.coloraccessoire=getColorIndex
  945. end
  946. end
  947.  
  948. end
  949. #===============================================================================
  950. # * Edit to the class Game_Player to erase the .png extension in the name.
  951. #===============================================================================
  952. class Game_Player
  953. def character_name
  954. if !@defaultCharacterName
  955. @defaultCharacterName=""
  956. end
  957. if @defaultCharacterName!=""
  958. return @defaultCharacterName.gsub(/\0/,"v")#(/\.png/,"")
  959. end
  960. if !moving? && !@move_route_forcing && $PokemonGlobal
  961. meta=pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID)
  962. if $PokemonGlobal.playerID>=0 && meta &&
  963. !$PokemonGlobal.bicycle && !$PokemonGlobal.diving && !$PokemonGlobal.surfing
  964. if meta[4] && meta[4]!="" && Input.dir4!=0 && passable?(@x,@y,Input.dir4) && pbCanRun?
  965. # Display running character sprite
  966. @character_name=pbGetPlayerCharset(meta,4)
  967. else
  968. # Display normal character sprite
  969. @character_name=pbGetPlayerCharset(meta,1)
  970. end
  971. end
  972. end
  973. return @character_name.gsub(/\.png/,"")
  974. end
  975. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement