Advertisement
Diego-Mertens

fdas v2

May 16th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.47 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. ["Defecto","Defecto",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. ["Defecto","Defecto 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. ["Defecto","Defecto 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. # Method for changing a certain accessory.
  104. def dressAccessory(accessory,color=0,convertation=true)
  105. return false if pbTrainerNotDefined
  106. return false if characterizationException
  107. return false if !accessory.is_a?(String)
  108. arr=retArrayAndNumber(accessory,false)
  109. @colorcl = color
  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. for i in 0...bodypart.length
  116. if bodypart[i][$Trainer.gender]==accessory
  117. $Trainer.headgear=i if var==1
  118. $Trainer.head=i if var==2
  119. $Trainer.upperbody=i if var==3
  120. $Trainer.lowerbody=i if var==4
  121. $Trainer.shoe=i if var==5
  122. $Trainer.accessoire=i if var==6
  123. saveAllCustomizedBitmapsToFolder
  124. updateTrainerOutfit
  125. return
  126. end
  127. end
  128. end
  129.  
  130. # Method for checking whether the player wears a certain Accessory.
  131. def wearingAccessory?(accessory)
  132. return false if pbTrainerNotDefined
  133. return false if characterizationException
  134. arr=retArrayAndNumber(accessory)
  135. clothes=arr[0]; bodypart=arr[1]
  136. current=$Trainer.headgear if bodypart==1
  137. current=$Trainer.head if bodypart==2
  138. current=$Trainer.upperbody if bodypart==3
  139. current=$Trainer.lowerbody if bodypart==4
  140. current=$Trainer.shoe if bodypart==5
  141. current=$Trainer.accessoire if bodypart==6
  142. return false if !(clothes || current)
  143. if accessory.is_a?(String)
  144. for i in 0...clothes.length
  145. if clothes[i]==accessory
  146. return (accessory==clothes[current])
  147. end
  148. end
  149. end
  150. return false
  151. end
  152.  
  153. # Method for unlocking clothes.
  154. def unlockAccessory(accessory)
  155. return false if pbTrainerNotDefined
  156. arr=retArrayAndNumber(accessory)
  157. bodypart=arr[1]-1
  158. for i in 0...arr[0].length
  159. index=i if arr[0][i]==accessory
  160. end
  161. (if $DEBUG; p "There was an issue unlocking the accessory."; end; return) if !index
  162. $Trainer.clothesUnlocking[bodypart][index]=true
  163. end
  164.  
  165. # Method for locking clothes
  166. def lockAccessory(accessory)
  167. return false if pbTrainerNotDefined
  168. arr=retArrayAndNumber(accessory)
  169. bodypart=arr[1]
  170. (current=$Trainer.headgear; name="Headgear") if bodypart==1
  171. (current=$Trainer.head; name="Head") if bodypart==2
  172. (current=$Trainer.upperbody; name="Upperbody") if bodypart==3
  173. (current=$Trainer.lowerbody; name="Lowerbody") if bodypart==4
  174. (current=$Trainer.shoe; name="Shoe")if bodypart==5
  175. (current=$Trainer.accessoire; name="Accessoire")if bodypart==6
  176. # Checking if player wears the accessory to lock
  177. for i in 0...arr[0].length
  178. if arr[0][i]==accessory
  179. index=i
  180. #p i; p current
  181. if i==current
  182. Kernel.pbMessage("#{$Trainer.name} misses the #{accessory} #{name} and puts on the #{arr[0][0]} one instead.")
  183. $Trainer.headgear=0 if bodypart==1
  184. $Trainer.head=0 if bodypart==2
  185. $Trainer.upperbody=0 if bodypart==3
  186. $Trainer.lowerbody=0 if bodypart==4
  187. $Trainer.shoe=0 if bodypart==5
  188. $Trainer.accessoire=0 if bodypart==6
  189. end
  190. end
  191. end
  192. (if $DEBUG; p "There was an issue locking the accessory"; end; return) if !index
  193. $Trainer.clothesUnlocking[bodypart][index]=false
  194. saveAllCustomizedBitmapsToFolder
  195. updateTrainerOutfit
  196. end
  197.  
  198.  
  199. def retArrayAndNumber(accessory,convertation=true)
  200. (bodypart=HEADGEAR_ITEMS; var=1) if cnvrtStrArr(HEADGEAR_ITEMS).include?(accessory)
  201. (bodypart=HEAD_ITEMS; var=2) if cnvrtStrArr(HEAD_ITEMS).include?(accessory)
  202. (bodypart=UPPERBODY_ITEMS; var=3) if cnvrtStrArr(UPPERBODY_ITEMS).include?(accessory)
  203. (bodypart=LOWERBODY_ITEMS; var=4) if cnvrtStrArr(LOWERBODY_ITEMS).include?(accessory)
  204. (bodypart=SHOE_ITEMS; var=5) if cnvrtStrArr(SHOE_ITEMS).include?(accessory)
  205. (bodypart=ACCESSOIRE_ITEMS; var=6) if cnvrtStrArr(ACCESSOIRE_ITEMS).include?(accessory)
  206. return [cnvrtStrArr(bodypart),var] if convertation
  207. return [bodypart,var]
  208. end
  209.  
  210. def characterizationException
  211. return true if CHARACTER_CUSTOMIZATION==false
  212. return true if UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT==false &&
  213. $Trainer.character_customization==false
  214. return true if !$Trainer
  215. return true if !$Trainer.headgear
  216. return false
  217. end
  218.  
  219. def cnvrtStrArr(array)
  220. ret=[]
  221. for i in 0...array.length
  222. ret.push(array[i][$Trainer.gender])
  223. end
  224. return ret
  225. end
  226.  
  227. def cnvrtBoolArr(array)
  228. ret=[]
  229. for i in 0...array.length
  230. ret.push(array[i][2])
  231. end
  232. return ret
  233. end
  234.  
  235. def retUnlockedAccessoryArray(clothes)
  236. arr=retArrayAndNumber(clothes[0])
  237. var=arr[1]
  238. ret=[]
  239. for i in 0...clothes.length
  240. ret.push clothes[i] if $Trainer.clothesUnlocking[var-1][i]==true
  241. end
  242. return ret
  243. end
  244. #===============================================================================
  245. # * Initializing class PokeBattle_Trainer objects.
  246. #===============================================================================
  247. class PokeBattle_Trainer
  248. attr_accessor :character_customization
  249. attr_accessor :headgear
  250. attr_accessor :head
  251. attr_accessor :upperbody
  252. attr_accessor :lowerbody
  253. attr_accessor :shoe
  254. attr_accessor :accessoire
  255. attr_accessor :@colorcl
  256. attr_accessor :clothesUnlocking
  257.  
  258. def character_customization
  259. if !@character_customization
  260. @character_customization=UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT
  261. end
  262. return @character_customization
  263. end
  264.  
  265. def character_customization=(boolean)
  266. if boolean != true && boolean != false # Determining if object is a boolean
  267. if $DEBUG
  268. p "only $Trainer.character_customization = true/false is valid!"
  269. end
  270. return
  271. end
  272. @character_customization=boolean
  273. end
  274.  
  275. def headgear
  276. if !@headgear
  277. @headgear=0
  278. end
  279. return @headgear
  280. end
  281.  
  282. def headgear=(value)
  283. if value<0 || value>(HEADGEAR_ITEMS.length-1)
  284. if $DEBUG
  285. p "the value for $Trainer.headgear is out of range!"
  286. end
  287. return
  288. end
  289. @headgear=value
  290. end
  291.  
  292. def head
  293. if !@head
  294. @head=0
  295. end
  296. return @head
  297. end
  298.  
  299. def head=(value)
  300. if value<0 || value>(HEAD_ITEMS.length-1)
  301. if $DEBUG
  302. p "the value for $Trainer.head is out of range!"
  303. end
  304. return
  305. end
  306. @head=value
  307. end
  308.  
  309. def upperbody
  310. if !@upperbody
  311. @upperbody=0
  312. end
  313. return @upperbody
  314. end
  315.  
  316. def upperbody=(value)
  317. if value<0 || value>(UPPERBODY_ITEMS.length-1)
  318. if $DEBUG
  319. p "the value for $Trainer.upperbody is out of range!"
  320. end
  321. return
  322. end
  323. @upperbody=value
  324. end
  325.  
  326. def lowerbody
  327. if !@lowerbody
  328. @lowerbody=0
  329. end
  330. return @lowerbody
  331. end
  332.  
  333. def lowerbody=(value)
  334. if value<0 || value>(LOWERBODY_ITEMS.length-1)
  335. if $DEBUG
  336. p "the value for $Trainer.lowerbody is out of range!"
  337. end
  338. return
  339. end
  340. @lowerbody=value
  341. end
  342.  
  343. def shoe
  344. if !@shoe
  345. @shoe=0
  346. end
  347. return @shoe
  348. end
  349.  
  350. def shoe=(value)
  351. if value<0 || value>(SHOE_ITEMS.length-1)
  352. if $DEBUG
  353. p "the value for $Trainer.shoe is out of range!"
  354. end
  355. return
  356. end
  357. @shoe=value
  358. end
  359.  
  360. def accessoire
  361. if !@accessoire
  362. @accessoire=0
  363. end
  364. return @accessoire
  365. end
  366.  
  367. def accessoire=(value)
  368. if value<0 || value>(ACCESSOIRE_ITEMS.length-1)
  369. if $DEBUG
  370. p "the value for $Trainer.accessoire is out of range!"
  371. end
  372. return
  373. end
  374. @accessoire=value
  375. end
  376.  
  377. def colorcl=(value)
  378. if value==-1
  379. if $DEBUG
  380. p "the value for $Trainer.@colorcl is out of range!"
  381. end
  382. return
  383. end
  384. @colorcl=value
  385. end
  386.  
  387. def clothesUnlocking
  388. if !@clothesUnlocking
  389. @clothesUnlocking=[]
  390. @clothesUnlocking.push cnvrtBoolArr(HEADGEAR_ITEMS)
  391. @clothesUnlocking.push cnvrtBoolArr(HEAD_ITEMS)
  392. @clothesUnlocking.push cnvrtBoolArr(UPPERBODY_ITEMS)
  393. @clothesUnlocking.push cnvrtBoolArr(LOWERBODY_ITEMS)
  394. @clothesUnlocking.push cnvrtBoolArr(SHOE_ITEMS)
  395. @clothesUnlocking.push cnvrtBoolArr(ACCESSOIRE_ITEMS)
  396. @clothesUnlocking.push cnvrtBoolArr(COLOR_ITEMS)
  397. end
  398. return @clothesUnlocking
  399. end
  400.  
  401. end
  402.  
  403. #===============================================================================
  404. # * Drawing the customized Bitmap
  405. #===============================================================================
  406. def drawCharacterCustomizedBitmap(filepath,bmp,trainerClass=$Trainer)
  407. return nil if !filepath.is_a?(String)
  408. return bitmap if !trainerClass
  409. return bitmap if CHARACTER_CUSTOMIZATION==false
  410. return bitmap if UNLOCK_CHARACTER_CUSTOMIZATION_BY_DEFAULT==false &&
  411. trainerClass.character_customization==false
  412. if @colorcl == 0
  413. addAdditionalBitmap(filepath+"_shoe"+(trainerClass.shoe).to_s+".png",bmp)
  414. addAdditionalBitmap(filepath+"_lowerbody"+(trainerClass.lowerbody).to_s+".png",bmp)
  415. addAdditionalBitmap(filepath+"_upperbody"+(trainerClass.upperbody).to_s+".png",bmp)
  416. addAdditionalBitmap(filepath+"_head"+(trainerClass.head).to_s+".png",bmp)
  417. addAdditionalBitmap(filepath+"_headgear"+(trainerClass.headgear).to_s+".png",bmp)
  418. addAdditionalBitmap(filepath+"_accessoire"+(trainerClass.accessoire).to_s+".png",bmp)
  419. elsif @colorcl != 0
  420. addAdditionalBitmap(filepath+"_shoe"+(trainerClass.shoe).to_s+(@colorcl).to_s+".png",bmp)
  421. addAdditionalBitmap(filepath+"_lowerbody"+(trainerClass.lowerbody).to_s+"-"+(@colorcl).to_s+".png",bmp)
  422. addAdditionalBitmap(filepath+"_upperbody"+(trainerClass.upperbody).to_s+"-"+(@colorcl).to_s+".png",bmp)
  423. addAdditionalBitmap(filepath+"_head"+(trainerClass.head).to_s+"-"+(@colorcl).to_s+".png",bmp)
  424. addAdditionalBitmap(filepath+"_headgear"+(trainerClass.headgear).to_s+"-"+(@colorcl).to_s+".png",bmp)
  425. addAdditionalBitmap(filepath+"_accessoire"+(trainerClass.accessoire).to_s+"-"+(@colorcl).to_s+".png",bmp)
  426. end
  427. end
  428.  
  429. def saveAllCustomizedBitmapsToFolder
  430. return if !$Trainer
  431. # Trainer charsets
  432. metadata=pbLoadMetadata
  433. filenames=metadata[0][8+$Trainer.gender]
  434. for i in 0...filenames.length
  435. if filenames[i].is_a?(String)
  436. filepath="Graphics/Characters/trchar00#{$Trainer.gender}"
  437. saveCustomizedBitmapToFolder(filepath)
  438. end
  439. end
  440. # Trainer backsprite
  441. saveCustomizedBitmapToFolder("Graphics/Characters/trback00#{$Trainer.gender}")
  442. # Intro Image/Trainercard Image
  443. filepath="Graphics/Pictures/"
  444. filepath+= $Trainer.isFemale? ? "introGirl" : "introBoy"
  445. saveCustomizedBitmapToFolder(filepath)
  446. # Map Player
  447. saveCustomizedBitmapToFolder("Graphics/Pictures/mapPlayer00#{$Trainer.gender}")
  448. end
  449.  
  450. # saves the costumized bitmaps to the actual game folders.
  451. def saveCustomizedBitmapToFolder(filepath)
  452. return if !$Trainer
  453. return if !filepath.is_a?(String)
  454. bmp=Bitmap.new(filepath)
  455. # Safety Copy
  456. if !File.exists?(filepath+"_safetyCopy"+".png") && $DEBUG
  457. safetyCopy=Bitmap.new(filepath)
  458. safetyCopy.saveToPng(filepath+"_safetyCopy"+".png")
  459. end
  460. # Deleting old file
  461. if !USE_BASE_GRAPHIC
  462. bmp.clear
  463. end
  464. drawCharacterCustomizedBitmap(filepath,bmp)
  465. bmp.saveToPng(filepath+".png")
  466. end
  467.  
  468.  
  469.  
  470. # Method for add additional bitmaps to a bitmap.
  471. def addAdditionalBitmap(filepath,formerBitmap)
  472. if File.exists?(filepath)
  473. formerBitmap.blt(0,0,Bitmap.new(filepath),Rect.new(0,0,Graphics.width,Graphics.height))
  474. end
  475. end
  476. #===============================================================================
  477. # * Character Customization Scene
  478. #===============================================================================
  479. class CharacterCustomizationScene
  480.  
  481. def initialize
  482. # Checks if the Script is functional.
  483. if !defined?($Trainer.clothesUnlocking)
  484. 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.")
  485. if Kernel.pbConfirmMessage("Would you like to save the game now?")
  486. if !$Trainer
  487. 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.")
  488. else
  489. pbSave
  490. Kernel.pbMessage("The game was saved, try again now.")
  491. end
  492. end
  493. return
  494. end
  495. return if !addNecessaryFiles
  496. @index=0
  497. @index2=0
  498. @new_val=2
  499. @firstSelection=true
  500. @secondSelection=false
  501. @sprites={}
  502. @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  503. @viewport.z=99999
  504. @sprites["window"]=SpriteWindow_Base.new(Graphics.width/2-64,Graphics.height/2-128,128,128)
  505. @sprites["window2"]=SpriteWindow_Base.new(Graphics.width/2-64,Graphics.height/2,128,128)
  506. @sprites["window2"].visible=false
  507. @sprites["window3"]=SpriteWindow_Base.new(128,256,128,128)
  508. @sprites["window3"].visible=false
  509. @sprites["player"]=TrainerWalkingCharSprite.new($game_player.character_name,@viewport)
  510. @sprites["player"].x=Graphics.width/2-@sprites["player"].bitmap.width/8
  511. @sprites["player"].y=Graphics.height/2-@sprites["player"].bitmap.height/8 -64
  512. @sprites["player"].z=9999999
  513. @sprites["playerAccessory"]=TrainerWalkingCharSprite.new($game_player.character_name+"_headgear0",@viewport)
  514. @sprites["playerAccessory"].x=Graphics.width/2-@sprites["playerAccessory"].bitmap.width/8
  515. @sprites["playerAccessory"].y=Graphics.height/2-@sprites["playerAccessory"].bitmap.height/8 +64
  516. @sprites["playerAccessory"].z=9999999
  517. @sprites["playerAccessory"].ox+=@sprites["playerAccessory"].bitmap.width/16
  518. @sprites["playerAccessory"].oy+=@sprites["playerAccessory"].bitmap.height/16
  519. @sprites["playerAccessory"].zoom_x=2
  520. @sprites["playerAccessory"].zoom_y=2
  521. @sprites["playerAccessory"].visible=false
  522. @playerAccessory=@sprites["playerAccessory"]
  523. charheight=@sprites["player"].bitmap.height
  524. @y=[charheight/4*2,0,charheight/4,charheight/4*3]
  525. @sprites["heading1"]=Window_CommandPokemonEx.new(["BODYPART"])
  526. @sprites["heading1"].viewport=@viewport
  527. @sprites["heading1"].index=1
  528. @sprites["heading2"]=Window_CommandPokemonEx.new(["HEADGEAR"])
  529. @sprites["heading2"].viewport=@viewport
  530. @sprites["heading2"].index=1
  531. @sprites["heading2"].x=Graphics.width-@sprites["heading2"].width
  532. @sprites["heading3"]=Window_CommandPokemonEx.new(["COLOR"])
  533. @sprites["heading3"].viewport=@viewport
  534. @sprites["heading3"].index=1
  535. @sprites["heading3"].x=Graphics.width/2-(@sprites["heading3"].width*2)
  536. @commands = []
  537. @currentList = "main"
  538. lista = @currentList
  539. @commands=CommandMenuList.new
  540. @commands.add("main","headgear",_INTL("Headgear"))
  541. @commands.add("main","head",_INTL("Head"))
  542. @commands.add("main","upperbody",_INTL("Upperbody"))
  543. @commands.add("main","lowerbody",_INTL("Lowerbody"))
  544. @commands.add("main","accessoire",_INTL("Accessoire"))
  545. @commands.add("main","shoes",_INTL("Shoes"))
  546. @commands2 = []
  547. @currentList = "main"
  548. @commands2=CommandMenuList.new
  549. @commands2.add("main","normal",_INTL("Normal"))
  550. @commands2.add("main","azul",_INTL("Azul"))
  551. @commands2.add("main","rojo",_INTL("Rojo"))
  552. @commands2.add("main","amarillo",_INTL("Amarillo"))
  553. @sprites["cmdwindow"]=Window_CommandPokemonEx.new(@commands.list)
  554. @sprites["cmdwindow"].viewport=@viewport
  555. @sprites["cmdwindow"].y=@sprites["heading1"].height
  556. @sprites["cmdwindow2"]=Window_CommandPokemonEx.new(retListCmdBox2)
  557. @sprites["cmdwindow2"].viewport=@viewport
  558. @sprites["cmdwindow2"].y=@sprites["heading2"].height
  559. @sprites["cmdwindow2"].x=Graphics.width-@sprites["cmdwindow2"].width
  560. @sprites["cmdwindow2"].z-=1
  561. @sprites["cmdwindow2"].index=-1
  562. @sprites["cmdwindow3"]=Window_CommandPokemonEx.new(@commands2.list)
  563. @sprites["cmdwindow3"].viewport=@viewport
  564. @sprites["cmdwindow3"].y=256
  565. @sprites["cmdwindow3"].x=128
  566. @sprites["cmdwindow3"].z=99999
  567. @sprites["cmdwindow3"].index=-1
  568. @cmdwindow2=@sprites["cmdwindow2"]
  569. @cmdwindow3=@sprites["cmdwindow3"]
  570. @accessoryNames=["headgear","head","upperbody","lowerbody","shoe","accessoire"]
  571. @colorNames=["normal","azul","rojo","amarillo"]
  572. update
  573. end
  574.  
  575. # Method for adding necessary missing graphic files.
  576. def addNecessaryFiles
  577. files=[]
  578. # Pushing all files that could possibly be missing into the files array.
  579. HEADGEAR_ITEMS.length.times{|i| files.push("_headgear#{i}")}
  580. HEAD_ITEMS.length.times{|i| files.push("_head#{i}")}
  581. UPPERBODY_ITEMS.length.times{|i| files.push("_upperbody#{i}")}
  582. LOWERBODY_ITEMS.length.times{|i| files.push("_lowerbody#{i}")}
  583. SHOE_ITEMS.length.times{|i| files.push("_shoe#{i}")}
  584. ACCESSOIRE_ITEMS.length.times{|i| files.push("_accessoire#{i}")}
  585. # Creating a blank bitmap
  586. size_check=Bitmap.new("Graphics/Characters/#{$game_player.character_name}")
  587. blank_bitmap=Bitmap.new(size_check.width,size_check.height)
  588. files_to_add=[]
  589. # Pushing non existent files into the files_to_add array.
  590. for i in 0...files.length
  591. if !File.exists?("Graphics/Characters/#{$game_player.character_name}#{files[i]}"+".png")
  592. files_to_add.push("Graphics/Characters/#{$game_player.character_name}#{files[i]}"+".png")
  593. end
  594. end
  595. if !files_to_add.empty?
  596. Kernel.pbMessage("The game is missing one or more graphic files for the Character Customization.")
  597. ret=Kernel.pbConfirmMessage("Would you like to add these files as blank placeholder sprites in order to let this Script work properly?")
  598. if ret
  599. files_to_add.length.times {|i| blank_bitmap.saveToPng(files_to_add[i])}
  600. Kernel.pbMessage("The missing files were added to the Graphics/Characters/ folder. The script will continue working as supposed now.")
  601. else
  602. Kernel.pbMessage("The script stopped running until these neccessary files were added:")
  603. files_to_add.length.times{|i| Kernel.pbMessage(files_to_add[i])}
  604. end
  605. return ret
  606. end
  607. return true
  608. end
  609.  
  610. # returns the index of the Accessory in the actual list.
  611. def getAccessoryIndex
  612. item=@list[@cmdwindow2.index]
  613. arr=HEADGEAR_ITEMS if @accessoryNames[@index]=="headgear"
  614. arr=HEAD_ITEMS if @accessoryNames[@index]=="head"
  615. arr=UPPERBODY_ITEMS if @accessoryNames[@index]=="upperbody"
  616. arr=LOWERBODY_ITEMS if @accessoryNames[@index]=="lowerbody"
  617. arr=SHOE_ITEMS if @accessoryNames[@index]=="shoe"
  618. arr=ACCESSOIRE_ITEMS if @accessoryNames[@index]=="accessoire"
  619. arr=cnvrtStrArr(arr)
  620. for i in 0...arr.length
  621. return i if arr[i]==item
  622. end
  623. end
  624.  
  625. def getColorIndex
  626. item=@list[@cmdwindow3.index]
  627. @colorcl=0 if @colorNames[@index]=="normal"
  628. @colorcl=1 if @colorNames[@index]=="azul"
  629. @colorcl=2 if @colorNames[@index]=="rojo"
  630. @colorcl=3 if @colorNames[@index]=="amarillo"
  631. end
  632.  
  633. # updates the Accessory bitmap
  634. def updateAccessoryBitmap
  635. @sprites["playerAccessory"].bitmap.clear
  636. name=$game_player.character_name+"_"+@accessoryNames[@index]+(getAccessoryIndex).to_s
  637. if File.exists?("Graphics/Characters/"+name+".png") && @index2 != @cmdwindow2.itemCount
  638. @sprites["playerAccessory"].charset=name
  639. end
  640. end
  641. def updateColorBitmap
  642. @sprites["playerAccessory"].bitmap.clear
  643. name=$game_player.character_name+"_"+@accessoryNames[@index]+(getAccessoryIndex).to_s+"-"+(getColorIndex).to_s
  644. if File.exists?("Graphics/Characters/"+name+".png") && @index2 != @cmdwindow3.itemCount
  645. @sprites["playerAccessory"].charset=name
  646. end
  647. end
  648.  
  649. # returns the list of the right hand command box.
  650. def retListCmdBox2
  651. @list=HEADGEAR_ITEMS if @index==0
  652. @list=HEAD_ITEMS if @index==1
  653. @list=UPPERBODY_ITEMS if @index==2
  654. @list=LOWERBODY_ITEMS if @index==3
  655. @list=SHOE_ITEMS if @index==4
  656. @list=ACCESSOIRE_ITEMS if @index==5
  657. @list=retUnlockedAccessoryArray(cnvrtStrArr(@list))
  658. @list=["---NONE---"] if !@list
  659. @list.push("Back") if !@list.include?("Back")
  660. return @list
  661. end
  662.  
  663. # this updates the heading. since there is no command for updating
  664. # command boxes it'll always create a new fresh command box sprite.
  665. def updateHeading2
  666. @sprites["heading#{@new_val}"].dispose
  667. @sprites["cmdwindow#{@new_val}"].dispose
  668. @new_val+=1
  669. @sprites["heading#{@new_val}"]=Window_CommandPokemonEx.new([@commands.list[@index].upcase])
  670. @sprites["heading#{@new_val}"].viewport=@viewport
  671. @sprites["heading#{@new_val}"].index=1
  672. @sprites["heading#{@new_val}"].x=Graphics.width-@sprites["heading#{@new_val}"].width
  673. @sprites["heading#{@new_val}"].z-=1
  674. @sprites["cmdwindow#{@new_val}"]=Window_CommandPokemonEx.new(retListCmdBox2)
  675. @cmdwindow2=@sprites["cmdwindow#{@new_val}"]
  676. @cmdwindow2.viewport=@viewport
  677. @cmdwindow2.y=@sprites["heading#{@new_val}"].height
  678. @cmdwindow2.x=Graphics.width-@sprites["cmdwindow#{@new_val}"].width
  679. @cmdwindow2.index= -1
  680. end
  681.  
  682.  
  683. # checks whether the index of the left command box has changed or not.
  684. def indexChanged
  685. if @index2 != @index
  686. @index2=@index
  687. return true
  688. end
  689. return false
  690. end
  691.  
  692. # checks whether the index or the right command box has changed or not.
  693. def cmdWindow2IndexChanged
  694. if !@cmdWindow2Index
  695. @cmdWindow2Index=@cmdwindow2.index
  696. return false
  697. elsif @cmdWindow2Index != @cmdwindow2.index
  698. @cmdWindow2Index=@cmdwindow2.index
  699. return true
  700. end
  701. return false
  702. end
  703. def cmdWindow3IndexChanged
  704. if !@cmdWindow3Index
  705. @cmdWindow3Index=@cmdwindow3.index
  706. return false
  707. elsif @cmdWindow3Index != @cmdwindow3.index
  708. @cmdWindow3Index=@cmdwindow3.index
  709. return true
  710. end
  711. return false
  712. end
  713.  
  714.  
  715.  
  716.  
  717. # updates the scene.
  718. def update
  719. frame=0
  720. @dir=0
  721. loop do
  722. frame+=1
  723. pos=0
  724. Graphics.update
  725. Input.update
  726. @sprites["player"].update
  727. @sprites["playerAccessory"].update
  728. if @firstSelection
  729. @sprites["cmdwindow"].update
  730. @index=@sprites["cmdwindow"].index
  731. elsif @secondSelection
  732. @cmdwindow2.update
  733. else
  734. @cmdwindow3.update
  735. end
  736. if indexChanged
  737. updateHeading2
  738. end
  739. if cmdWindow2IndexChanged && @cmdwindow2.index != -1
  740. updateAccessoryBitmap #if @cmdwindow2.index != @cmdwindow2.
  741. end
  742. if cmdWindow3IndexChanged && @cmdwindow3.index != -1
  743. updateColorBitmap
  744. end
  745. if Input.trigger?(Input::C)
  746. # Pressing C on the left command box.
  747. if @firstSelection
  748. @cmdwindow2.index=0
  749. @firstSelection=false
  750. @secondSelection=true
  751. @sprites["playerAccessory"].visible=true
  752. elsif @secondSelection
  753. # Pressing C on the right command box.
  754. @cmdwindow3.index=0
  755. @sprites["heading3"].visible=true
  756. @sprites["heading1"].visible=false
  757. @secondSelection=false
  758. if @cmdwindow2.index==(@cmdwindow2.itemCount-1) # Cancel
  759. @cmdwindow2.index=-1; @cmdwindow2.update
  760. @secondSelection=false
  761. @firstSelection=true
  762. end
  763. else
  764. if @cmdwindow3.index==(@cmdwindow3.itemCount-1) # Cancel
  765. @cmdwindow3.index=-1; @cmdwindow3.update
  766. else
  767. changeClothes
  768. @sprites["player"].bitmap.clear
  769. @sprites["player"].charset=$game_player.character_name
  770. end
  771. end
  772. end
  773.  
  774. if Input.trigger?(Input::B)
  775. # cancels the scene.
  776. if @firstSelection && Kernel.pbConfirmMessage("Have you finished?")
  777. updateTrainerOutfit
  778. pbDisposeSpriteHash(@sprites)
  779. break
  780. # goes back to the left command box.
  781. elsif !@firstSelection && @secondSelection
  782. @cmdwindow2.index=-1; @cmdwindow2.update
  783. @firstSelection=true
  784. @sprites["window2"].visible=false
  785. @sprites["playerAccessory"].visible=false
  786. elsif !@firstSelection && !@secondSelection
  787. @secondSelection=true
  788. @sprites["playerAccessory"].visible=false
  789. @sprites["window3"].visible=false
  790. end
  791. end
  792. # updates the walking sprite.
  793. if frame%120==0
  794. @dir+=1
  795. @sprites["player"].src_rect.y=@y[@dir%4]
  796. @sprites["playerAccessory"].src_rect.y=@sprites["player"].src_rect.y
  797. end
  798. end
  799. end
  800.  
  801. # updates the outfit as well as the variables which are responsable for it.
  802. def changeClothes
  803. dressAccessory(@list[@cmdwindow2.index],false)
  804. case @sprites["cmdwindow"].index
  805. when 0
  806. $Trainer.headgear=getAccessoryIndex
  807. $Trainer.colorcl=getColorIndex
  808. when 1
  809. $Trainer.head=getAccessoryIndex
  810. $Trainer.colorcl=getColorIndex
  811. when 2
  812. $Trainer.upperbody=getAccessoryIndex
  813. $Trainer.colorcl=getColorIndex
  814. when 3
  815. $Trainer.lowerbody=getAccessoryIndex
  816. $Trainer.colorcl=getColorIndex
  817. when 4
  818. $Trainer.shoe=getAccessoryIndex
  819. $Trainer.colorcl=getColorIndex
  820. when 5
  821. $Trainer.accessoire=getAccessoryIndex
  822. $Trainer.colorcl=getColorIndex
  823. end
  824. end
  825.  
  826. end
  827. #===============================================================================
  828. # * Edit to the class Game_Player to erase the .png extension in the name.
  829. #===============================================================================
  830. class Game_Player
  831. def character_name
  832. if !@defaultCharacterName
  833. @defaultCharacterName=""
  834. end
  835. if @defaultCharacterName!=""
  836. return @defaultCharacterName.gsub(/\0/,"v")#(/\.png/,"")
  837. end
  838. if !moving? && !@move_route_forcing && $PokemonGlobal
  839. meta=pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID)
  840. if $PokemonGlobal.playerID>=0 && meta &&
  841. !$PokemonGlobal.bicycle && !$PokemonGlobal.diving && !$PokemonGlobal.surfing
  842. if meta[4] && meta[4]!="" && Input.dir4!=0 && passable?(@x,@y,Input.dir4) && pbCanRun?
  843. # Display running character sprite
  844. @character_name=pbGetPlayerCharset(meta,4)
  845. else
  846. # Display normal character sprite
  847. @character_name=pbGetPlayerCharset(meta,1)
  848. end
  849. end
  850. end
  851. return @character_name.gsub(/\.png/,"")
  852. end
  853. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement