Guest User

YEM: Victory Aftermath

a guest
Dec 7th, 2012
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.28 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Yanfly Engine Melody - Victory Aftermath
  4. # Last Date Updated: 2010.05.28
  5. # Level: Normal, Hard, Lunatic
  6. #
  7. # The victory aftermath scene after battles are finished hardly display any
  8. # data at all for the player. All that's generally mentioned is how much EXP
  9. # they've acquired, who levels up, and what items are dropped in only a message
  10. # box window. Now, the whole process is more visual and will contain lists to
  11. # show the player what changes have been made as far as the victory portion is
  12. # concerned. The item drop list will also no longer go on and on forever with
  13. # the message windows, but instead, show them properly in a list window.
  14. #
  15. #===============================================================================
  16. # Updates
  17. # -----------------------------------------------------------------------------
  18. # o 2010.05.28 - Double EXP "gain" bugfix.
  19. # o 2010.05.22 - Compatibility Update with Custom Message Melody.
  20. # o 2010.05.20 - Converted to Yanfly Engine Melody.
  21. #===============================================================================
  22. # Instructions
  23. # -----------------------------------------------------------------------------
  24. # To install this script, open up your script editor and copy/paste this script
  25. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  26. #===============================================================================
  27.  
  28. $imported = {} if $imported == nil
  29. $imported["VictoryAftermath"] = true
  30.  
  31. module YEM
  32. module VICTORY
  33.  
  34. #===========================================================================
  35. # Section I. General Settings
  36. # --------------------------------------------------------------------------
  37. # The following below will adjust the basic settings and vocabulary that
  38. # will display throughout the script. These settings will also determine
  39. # which windows you would like to have appear. Change them as you see fit.
  40. #===========================================================================
  41.  
  42. # This is how many frames to wait before displaying the victory aftermath
  43. # scene on the screen.
  44. WAIT = 60
  45.  
  46. # The following adjusts the two switches that are associated with this
  47. # script so bind them accordingly. Bypassing the BGM will cause no BGM
  48. # change from battle start to end. Skip victory switch will cause the
  49. # victory display portion to be ignored (but gaining EXP and such will
  50. # still occur).
  51. BYPASS_BGM_SWITCH = 61
  52. SKIP_VICTORY_SWITCH = 62
  53.  
  54. # This hash adjusts the vocabulary used throughout the script.
  55. VOCAB ={
  56. :top_message => "Battle Results",
  57. :gold_found => "Found %s Gold",
  58. :exp_receive => "Earned %s EXP",
  59. :percent_exp => "%1.2f%%",
  60. :next_level => "To Level %s",
  61. :max_level => "Max Level",
  62. :next_exp => "%s EXP",
  63. :level_up => "LEVEL UP!",
  64. :to_level => "to Level %s",
  65. :level_msg => "%s has reached level %s!",
  66. :next_stat => "→",
  67. :new_skills => "Skills Acquired",
  68. :spoils => "Victory Spoils",
  69. :no_items => "No items were found.",
  70. :found_items => "%s has found items!",
  71. :item_amount => "×%2d",
  72. } # Do not remove this.
  73.  
  74. # This determines the gauge information for the victory screens.
  75. FACE_OPACITY = 200 # This adjusts the opacity of the actor's faces
  76. EXP_TICKS = 10 # This is how many ticks it takes to fill the gauge.
  77. EXP_GAUGE_1 = 28 # Experience gauge colour 1 for non-leveled characters.
  78. EXP_GAUGE_2 = 29 # Experience gauge colour 2 for non-leveled characters.
  79. EXP_FONT_SIZE = 18 # Font size used for experience gauge.
  80. LVL_COLOUR = 6 # Text colour used for leveling up.
  81. LVL_GAUGE_1 = 20 # Experience gauge colour 1 for leveled characters.
  82. LVL_GAUGE_2 = 21 # Experience gauge colour 2 for leveled characters.
  83.  
  84. # These constants determine which series of windows will appear. By default
  85. # all of the windows will show up. The EXP windows will appear if there
  86. # are no drop items present.
  87. SHOW_EXP_WINDOWS = true
  88. SHOW_LEVEL_WINDOWS = true
  89. SHOW_ITEM_WINDOWS = true
  90.  
  91. #===========================================================================
  92. # Section II. Experience Settings
  93. # --------------------------------------------------------------------------
  94. # The following below allows you to adjust the amount of experience each
  95. # actor will earn and the rules that govern the experience gained.
  96. #===========================================================================
  97.  
  98. # If any allies are dead, are they allowed to gain EXP?
  99. DEAD_ALLY_EXP = false
  100.  
  101. # Do you want the game to scale the experience based on how many actors are
  102. # in the party? This means actors can earn more or less.
  103. PARTY_SPLIT_EXP = false
  104. PARTY_SIZE_SCALING ={
  105. 1 => 1.000, # If one actor is active.
  106. 2 => 0.500, # If two actors are active.
  107. 3 => 0.334, # If three actors are active.
  108. 4 => 0.250, # If four actors are active.
  109. 5 => 0.200, # If five actors are active.
  110. 6 => 0.167, # If six actors are active.
  111. 7 => 0.143, # If seven actors are active.
  112. 8 => 0.125, # If eight actors are active.
  113. } # Do not remove this.
  114.  
  115. #===========================================================================
  116. # Section III. Level Settings
  117. # --------------------------------------------------------------------------
  118. # The following below allows you to adjust the amount of experience each
  119. # actor will earn and the rules that govern the experience gained.
  120. #===========================================================================
  121.  
  122. # The following array determines which stats will be shown with level up
  123. # increases and also what order. Only the following can be used.
  124. # :maxhp, :maxmp, :atk, :def, :spi, :res, :dex, :agi
  125. SHOWN_STATS = [:maxhp, :maxmp, :atk, :def, :spi, :res, :dex, :agi]
  126.  
  127. # The following hash adjusts the colours used to display each of the
  128. # various objects inside of the level window.
  129. LEVEL_COLOURS ={
  130. :stat_name => 4, # The stat's name.
  131. :arrow => 4, # Arrow in between the old and new stats.
  132. :old_stat => 5, # The older unleveled stat.
  133. :new_stat => 6, # The newer leveled stat.
  134. } # Do not remove this.
  135.  
  136. # Changing the following value to an icon ID will change the → arrow to use
  137. # an icon instead. i.e. ARROW_ICON = 142
  138. ARROW_ICON = nil
  139.  
  140. # Changing the following below will show the change in stat difference from
  141. # the old stat to the new stat rather than just showing the new stat.
  142. SHOW_DIFFERENCE = false
  143.  
  144. # The following will determine how HP and MP recovery is calculated upon
  145. # leveling up. 0 - no change. 1 - difference from max. 2 - full recovery.
  146. HP_RECOVERY = 1 # Adjusts HP Recovery Style
  147. MP_RECOVERY = 1 # Adjusts MP Recovery Style
  148.  
  149. #===========================================================================
  150. # Section IV. Audio Settings
  151. # --------------------------------------------------------------------------
  152. # This part of the module adjusts everything that's audio related. Be sure
  153. # to modify them accordingly.
  154. #===========================================================================
  155.  
  156. # This victory BGM will play once the fanfare finishes.
  157. BGM = RPG::BGM.new("Field1", 100, 100)
  158.  
  159. # This sound adjusts the ticking noise that occurs as the experience bar
  160. # goes upward. Adjust it accordingly.
  161. TICK_SOUND = RPG::SE.new("Decision1", 80, 100)
  162.  
  163. # The following adjusts how long to play the Victory ME after finishing
  164. # battle in milliseconds (if it is still continuing).
  165. FANFARE_FADE = 1000
  166.  
  167. # This is the level up sound that plays when an actor levels up.
  168. LEVEL_SOUND = RPG::SE.new("Flash1", 100, 100)
  169.  
  170. # This is the sound that will play if items were found.
  171. ITEM_SOUND = RPG::SE.new("Item1", 80, 100)
  172.  
  173. end # VICTORY
  174. end # YEM
  175.  
  176. #===============================================================================
  177. # Lunatic Mode - Victory Aftermath
  178. # -----------------------------------------------------------------------------
  179. # This mode allows you to add in a bit more of a personal touch to your game by
  180. # adding in victory battle quotes. If they're on, actors who were participating
  181. # in battle can brief the victory spoils and whatnot.
  182. #
  183. # To use this mode, bind each actor to a common event ID. Those common events
  184. # will play out the messages written for them. However, to distinguish when to
  185. # display each message, use conditional branches with a script value check.
  186. # Insert the following into your script value checks:
  187. #
  188. # victory_quote("Main") Occurs at the first page of victory.
  189. # victory_quote("Level") Occurs when leveling up your character.
  190. # victory_quote("Skill") Occurs when leveling up and learning a skill.
  191. # victory_quote("Nothing") Occurs when no drops are found.
  192. # victory_quote("Drops") Occurs if the enemy has left drops.
  193. #
  194. # When displaying the message events, a few new text shortcuts should be taken
  195. # note of. They are the two following:
  196. #
  197. # \VN This displays the talking actor's name.
  198. # \VF This displays the talking actor's face.
  199. #
  200. # Anything else in the common event will run normally.
  201. #===============================================================================
  202.  
  203. module YEM::VICTORY
  204.  
  205. # If this is enabled, victory quotes will occur instead of the typical
  206. # battle end messages.
  207. ENABLE_QUOTES = true
  208.  
  209. # The following hash determines which common event ID's are bound to which
  210. # actors when their victory quotes are to be launched.
  211. ACTOR_QUOTES ={ # Actor 0 is the actor used for unlisted actors.
  212. # ActorID => Common Event ID
  213. 0 => 20, # Common Victory Quotes
  214. 1 => 21, # Ralph's Victory Quotes
  215. 2 => 22, # Ulrika's Victory Quotes
  216. 3 => 23, # Bennett's Victory Quotes
  217. 4 => 24, # Ylva's Victory Quotes
  218. 5 => 25, # Lawrence's Victory Quotes
  219. 6 => 26, # Oscar's Victory Quotes
  220. 7 => 27, # Vera's Victory Quotes
  221. 8 => 28, # Elmer's Victory Quotes
  222. } # Do not remove this.
  223.  
  224. end # YEM::VICTORY
  225.  
  226. #===============================================================================
  227. # Editting anything past this point may potentially result in causing computer
  228. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  229. # Therefore, edit at your own risk.
  230. #===============================================================================
  231.  
  232. #===============================================================================
  233. # module Icon
  234. #===============================================================================
  235. if !$imported["BattleEngineMelody"] and !$imported["IconModuleLibrary"]
  236. module Icon
  237.  
  238. #--------------------------------------------------------------------------
  239. # self.stat
  240. #--------------------------------------------------------------------------
  241. def self.stat(actor, item); return 0; end
  242.  
  243. end # Icon
  244. end # !$imported["BattleEngineMelody"] and !$imported["IconModuleLibrary"]
  245.  
  246. #===============================================================================
  247. # Game_Temp
  248. #===============================================================================
  249.  
  250. class Game_Temp
  251.  
  252. #--------------------------------------------------------------------------
  253. # public instance variables
  254. #--------------------------------------------------------------------------
  255. attr_accessor :victory_actor
  256. attr_accessor :victory_quote
  257. attr_accessor :victory_clone
  258.  
  259. end # Game_Temp
  260.  
  261. #===============================================================================
  262. # Game_Actor
  263. #===============================================================================
  264.  
  265. class Game_Actor < Game_Battler
  266.  
  267. #--------------------------------------------------------------------------
  268. # new method: learned_skills
  269. #--------------------------------------------------------------------------
  270. def learned_skills
  271. result = []
  272. for i in @skills
  273. result.push($data_skills[i])
  274. end
  275. return result
  276. end
  277.  
  278. #--------------------------------------------------------------------------
  279. # new method: now_exp
  280. #--------------------------------------------------------------------------
  281. def now_exp
  282. return @exp - @exp_list[@level]
  283. end
  284.  
  285. #--------------------------------------------------------------------------
  286. # new method: next_exp
  287. #--------------------------------------------------------------------------
  288. def next_exp
  289. return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  290. end
  291.  
  292. end # Game_Actor
  293.  
  294. #==============================================================================
  295. # Game_Interpreter
  296. #==============================================================================
  297.  
  298. class Game_Interpreter
  299.  
  300. #--------------------------------------------------------------------------
  301. # victory_quote
  302. #--------------------------------------------------------------------------
  303. def victory_quote(text)
  304. return false unless $game_temp.in_battle and $scene.is_a?(Scene_Battle)
  305. return false if $game_temp.victory_quote == nil
  306. return true if text.upcase == $game_temp.victory_quote
  307. return false
  308. end
  309.  
  310. end # Game_Interpreter
  311.  
  312. #===============================================================================
  313. # Window_Message
  314. #===============================================================================
  315.  
  316. class Window_Message < Window_Selectable
  317.  
  318. #--------------------------------------------------------------------------
  319. # alias method: convert_special_characters
  320. #--------------------------------------------------------------------------
  321. unless $imported["CustomMessageMelody"]
  322. alias convert_special_characters_va convert_special_characters unless $@
  323. def convert_special_characters
  324. @text.gsub!(/\\VF/i) { victory_face_art }
  325. @text.gsub!(/\\VN/i) { victory_actor_name }
  326. convert_special_characters_va
  327. end
  328. end # $imported["CustomMessageMelody"]
  329.  
  330. #--------------------------------------------------------------------------
  331. # new method: victory_actor_name
  332. #--------------------------------------------------------------------------
  333. def victory_actor_name
  334. return "" unless $scene.is_a?(Scene_Battle)
  335. return $scene.victory_actor.name
  336. end
  337.  
  338. #--------------------------------------------------------------------------
  339. # new method: victory_face_art
  340. #--------------------------------------------------------------------------
  341. def victory_face_art
  342. return "" unless $scene.is_a?(Scene_Battle)
  343. $game_message.face_name = $scene.victory_actor.face_name
  344. $game_message.face_index = $scene.victory_actor.face_index
  345. return ""
  346. end
  347.  
  348. end # Window_Message
  349.  
  350. #===============================================================================
  351. # Window_Party_Exp_Back
  352. #===============================================================================
  353.  
  354. class Window_Party_Exp_Back < Window_Base
  355.  
  356. #--------------------------------------------------------------------------
  357. # initialize
  358. #--------------------------------------------------------------------------
  359. def initialize
  360. super(0, 112, 544, 176)
  361. refresh
  362. end
  363.  
  364. #--------------------------------------------------------------------------
  365. # refresh
  366. #--------------------------------------------------------------------------
  367. def refresh
  368. self.contents.clear
  369. sw = self.width - 32
  370. dy = 0
  371. dx = (sw/2) - $game_party.members.size*60
  372. for actor in $game_party.members
  373. opacity = YEM::VICTORY::FACE_OPACITY
  374. draw_party_face(actor, dx+12, dy, opacity)
  375. self.contents.draw_text(dx+12, dy, 96, WLH, actor.name, 1)
  376. dx += 120
  377. end
  378. end
  379.  
  380. #--------------------------------------------------------------------------
  381. # Draw Party Face
  382. #--------------------------------------------------------------------------
  383. def draw_party_face(actor, x, y, opacity = 255, size = 96)
  384. face_name = actor.face_name
  385. face_index = actor.face_index
  386. bitmap = Cache.face(face_name)
  387. rect = Rect.new(0, 0, 0, 0)
  388. rect.x = face_index % 4 * 96 + (96 - size) / 2
  389. rect.y = face_index / 4 * 96 + (96 - size) / 2
  390. rect.width = size
  391. rect.height = size
  392. self.contents.blt(x, y, bitmap, rect, opacity)
  393. bitmap.dispose
  394. end
  395.  
  396. end # Window_Party_Exp_Back
  397.  
  398. #===============================================================================
  399. # Window_Party_Exp_Front
  400. #===============================================================================
  401.  
  402. class Window_Party_Exp_Front < Window_Base
  403.  
  404. #--------------------------------------------------------------------------
  405. # public instance variables
  406. #--------------------------------------------------------------------------
  407. attr_accessor :full_actors
  408.  
  409. #--------------------------------------------------------------------------
  410. # initialize
  411. #--------------------------------------------------------------------------
  412. def initialize
  413. super(0, 112, 544, 176)
  414. self.opacity = 0
  415. @extra_per = 0
  416. @increase = 100 / YEM::VICTORY::EXP_TICKS
  417. refresh
  418. end
  419.  
  420. #--------------------------------------------------------------------------
  421. # refresh
  422. #--------------------------------------------------------------------------
  423. def refresh(extra_per = 0)
  424. @full = true if extra_per >= 100
  425. self.contents.clear
  426. @full_actors = 0
  427. sw = self.width - 32
  428. dy = WLH*4
  429. dx = (sw/2) - $game_party.members.size*60
  430. for actor in $game_party.members
  431. self.contents.font.color = normal_color
  432. self.contents.font.size = Font.default_size
  433. draw_exp_gauge(actor, dx, dy, extra_per)
  434. draw_exp_text(actor, dx, dy+WLH, extra_per)
  435. dx += 120
  436. end
  437. end
  438.  
  439. #--------------------------------------------------------------------------
  440. # draw_exp_gauge
  441. #--------------------------------------------------------------------------
  442. def draw_exp_gauge(actor, dx, dy, extra_per)
  443. self.contents.font.size = YEM::VICTORY::EXP_FONT_SIZE
  444. gc1 = text_color(YEM::VICTORY::EXP_GAUGE_1)
  445. gc2 = text_color(YEM::VICTORY::EXP_GAUGE_2)
  446. if actor.level > $game_temp.victory_clone[actor.id].level
  447. gc1 = text_color(YEM::VICTORY::LVL_GAUGE_1)
  448. gc2 = text_color(YEM::VICTORY::LVL_GAUGE_2)
  449. gw = 96
  450. self.contents.font.color = text_color(YEM::VICTORY::LVL_COLOUR)
  451. text = YEM::VICTORY::VOCAB[:level_up]
  452. elsif actor.next_exp != 0
  453. gw = 96 * (actor.now_exp + exp_gained(extra_per, actor))
  454. gw /= actor.next_exp
  455. gw = [[gw, 96].min, 0].max
  456. text = sprintf(YEM::VICTORY::VOCAB[:next_level], actor.level + 1)
  457. if gw == 96
  458. self.contents.font.color = text_color(YEM::VICTORY::LVL_COLOUR)
  459. gc1 = text_color(YEM::VICTORY::LVL_GAUGE_1)
  460. gc2 = text_color(YEM::VICTORY::LVL_GAUGE_2)
  461. text = YEM::VICTORY::VOCAB[:level_up]
  462. end
  463. else
  464. gw = 96
  465. text = YEM::VICTORY::VOCAB[:max_level]
  466. end
  467. if $imported["CoreFixesUpgradesMelody"] and YEM::UPGRADE::OUTLINE
  468. self.contents.fill_rect(dx + 12, dy - 8, 96, 8, gauge_back_color)
  469. self.contents.gradient_fill_rect(dx + 13, dy - 7, gw-2, 6, gc1, gc2)
  470. else
  471. self.contents.fill_rect(dx + 12, dy - 6, 96, 6, gauge_back_color)
  472. self.contents.gradient_fill_rect(dx + 12, dy - 6, gw, 6, gc1, gc2)
  473. end
  474. self.contents.draw_text(dx, dy, 120, WLH, text, 1)
  475. self.contents.font.color = normal_color
  476. end
  477.  
  478. #--------------------------------------------------------------------------
  479. # draw_exp_text
  480. #--------------------------------------------------------------------------
  481. def draw_exp_text(actor, dx, dy, extra_per)
  482. if actor.level > $game_temp.victory_clone[actor.id].level
  483. exp_percent = 100.0
  484. text1 = sprintf(YEM::VICTORY::VOCAB[:percent_exp], exp_percent)
  485. text2 = sprintf(YEM::VICTORY::VOCAB[:to_level], actor.level)
  486. elsif actor.next_exp != 0
  487. exp_percent = (actor.now_exp + exp_gained(extra_per, actor)) * 100.0
  488. exp_percent /= actor.next_exp
  489. exp_percent = [[exp_percent, 100.0].min, 0].max
  490. @full_actors += 1 if exp_percent >= 100.0
  491. value = [actor.next_rest_exp_s - exp_gained(extra_per, actor), 0].max
  492. text1 = sprintf(YEM::VICTORY::VOCAB[:percent_exp], exp_percent)
  493. text2 = sprintf(YEM::VICTORY::VOCAB[:next_exp], value)
  494. else
  495. exp_percent = 100.0
  496. @full_actors += 1
  497. text1 = sprintf(YEM::VICTORY::VOCAB[:percent_exp], exp_percent)
  498. text2 = ""
  499. end
  500. self.contents.draw_text(dx, dy - WLH * 2, 120, WLH, text1, 1)
  501. self.contents.draw_text(dx, dy, 120, WLH, text2, 1)
  502. end
  503.  
  504. #--------------------------------------------------------------------------
  505. # exp_gained
  506. #--------------------------------------------------------------------------
  507. def exp_gained(extra_per, actor)
  508. return 0 if actor.dead?
  509. extra_per = 100 if extra_per > 100
  510. exp = $game_troop.exp_total
  511. members = $game_party.members.size
  512. if YEM::VICTORY::PARTY_SPLIT_EXP
  513. size = YEM::VICTORY::DEAD_ALLY_EXP ?
  514. $game_party.members.size : $game_party.existing_members.size
  515. exp = Integer(exp * YEM::VICTORY::PARTY_SIZE_SCALING[size])
  516. end
  517. exp *= 2 if actor.double_exp_gain
  518. exp *= extra_per
  519. exp /= 100
  520. return exp
  521. end
  522.  
  523. end # Window_Party_Exp_Front
  524.  
  525. #===============================================================================
  526. # Window_New_Skills
  527. #===============================================================================
  528.  
  529. class Window_New_Skills < Window_Selectable
  530.  
  531. #--------------------------------------------------------------------------
  532. # initialize
  533. #--------------------------------------------------------------------------
  534. def initialize(new_skills)
  535. @new_skills = new_skills
  536. super(316, 80, 228, 208)
  537. self.index = -1
  538. self.opacity = 0
  539. refresh
  540. end
  541.  
  542. #--------------------------------------------------------------------------
  543. # skill
  544. #--------------------------------------------------------------------------
  545. def skill; return @data[self.index]; end
  546.  
  547. #--------------------------------------------------------------------------
  548. # refresh
  549. #--------------------------------------------------------------------------
  550. def refresh
  551. @data = []
  552. for skill in @new_skills
  553. @data.push(skill)
  554. end
  555. @item_max = @data.size
  556. create_contents
  557. for i in 0..(@item_max-1)
  558. draw_item(i)
  559. end
  560. end
  561.  
  562. #--------------------------------------------------------------------------
  563. # draw_item
  564. #--------------------------------------------------------------------------
  565. def draw_item(index)
  566. rect = item_rect(index)
  567. self.contents.clear_rect(rect)
  568. skill = @data[index]
  569. return if skill == nil
  570. draw_item_name(skill, rect.x, rect.y)
  571. end
  572.  
  573. #--------------------------------------------------------------------------
  574. # update_help
  575. #--------------------------------------------------------------------------
  576. def update_help
  577. @help_window.set_text(skill == nil ? "" : skill.description)
  578. end
  579.  
  580. end # Window_New_Skills
  581.  
  582. #===============================================================================
  583. # Window_BattleDrops
  584. #===============================================================================
  585.  
  586. class Window_BattleDrops < Window_Selectable
  587.  
  588. #--------------------------------------------------------------------------
  589. # initialize
  590. #--------------------------------------------------------------------------
  591. def initialize(drop_items)
  592. super(0, 56, 544, 232)
  593. @drop_items = drop_items
  594. @column_max = 2
  595. self.index = -1
  596. refresh
  597. end
  598.  
  599. #--------------------------------------------------------------------------
  600. # item
  601. #--------------------------------------------------------------------------
  602. def item; return @data[self.index]; end
  603.  
  604. #--------------------------------------------------------------------------
  605. # refrehs
  606. #--------------------------------------------------------------------------
  607. def refresh
  608. @items = {}; @weapons = {}; @armours = {}; @goods = {}; @data = []
  609. for item in @drop_items
  610. case item
  611. when RPG::Item
  612. @items[item] = 0 if @items[item] == nil
  613. @items[item] += 1
  614. when RPG::Weapon
  615. @weapons[item] = 0 if @weapons[item] == nil
  616. @weapons[item] += 1
  617. when RPG::Armor
  618. @armours[item] = 0 if @armours[item] == nil
  619. @armours[item] += 1
  620. end
  621. end
  622. @items = @items.sort { |a,b| a[0].id <=> b[0].id }
  623. @weapons = @weapons.sort { |a,b| a[0].id <=> b[0].id }
  624. @armours = @armours.sort { |a,b| a[0].id <=> b[0].id }
  625. for key in @items; @goods[key[0]] = key[1]; @data.push(key[0]); end
  626. for key in @weapons; @goods[key[0]] = key[1]; @data.push(key[0]); end
  627. for key in @armours; @goods[key[0]] = key[1]; @data.push(key[0]); end
  628. @item_max = @data.size
  629. create_contents
  630. for i in 0..(@item_max-1); draw_item(i); end
  631. end
  632.  
  633. #--------------------------------------------------------------------------
  634. # draw_item
  635. #--------------------------------------------------------------------------
  636. def draw_item(index)
  637. rect = item_rect(index)
  638. self.contents.clear_rect(rect)
  639. item = @data[index]
  640. return if item == nil
  641. number = @goods[item]
  642. rect.width -= 4
  643. self.contents.font.size = Font.default_size
  644. self.contents.font.color = normal_color
  645. draw_item_name(item, rect.x, rect.y)
  646. if $imported["BattleEngineMelody"]
  647. text = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:text]
  648. self.contents.font.size = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:size]
  649. colour = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:colour]
  650. self.contents.font.color = text_color(colour)
  651. self.contents.draw_text(rect, sprintf(text, number), 2)
  652. else
  653. text = YEM::VICTORY::VOCAB[:item_amount]
  654. self.contents.draw_text(rect, sprintf(text, number), 2)
  655. end
  656. end
  657.  
  658. #--------------------------------------------------------------------------
  659. # update_help
  660. #--------------------------------------------------------------------------
  661. def update_help
  662. @help_window.set_text(item == nil ? "" : item.description)
  663. end
  664.  
  665. end # Window_BattleDrops
  666.  
  667. #===============================================================================
  668. # Window_Level_Up
  669. #===============================================================================
  670.  
  671. class Window_Level_Up < Window_Base
  672.  
  673. #--------------------------------------------------------------------------
  674. # initialize
  675. #--------------------------------------------------------------------------
  676. def initialize(actor, dx, dy, dw, dh)
  677. super(dx, dy, dw, dh)
  678. @actor = actor
  679. @clone = $game_temp.victory_clone[actor.id]
  680. refresh
  681. end
  682.  
  683. #--------------------------------------------------------------------------
  684. # refresh
  685. #--------------------------------------------------------------------------
  686. def refresh
  687. self.contents.clear
  688. sw = self.width - 32
  689. dy = 0; dx = sw/2 - 210/2
  690. draw_stats(dx, dy)
  691. end
  692.  
  693. #--------------------------------------------------------------------------
  694. # draw_stats
  695. #--------------------------------------------------------------------------
  696. def draw_stats(dx, dy)
  697. arrow = YEM::VICTORY::VOCAB[:next_stat]
  698. colours = YEM::VICTORY::LEVEL_COLOURS
  699. @actor.clear_battle_cache if $imported["BattleEngineMelody"]
  700. for stat in YEM::VICTORY::SHOWN_STATS
  701. case stat
  702. when :maxhp
  703. text = Vocab.hp
  704. value1 = @clone.maxhp
  705. value2 = @actor.maxhp
  706. when :maxmp
  707. text = Vocab.mp
  708. value1 = @clone.maxmp
  709. value2 = @actor.maxmp
  710. when :atk
  711. text = Vocab.atk
  712. value1 = @clone.atk
  713. value2 = @actor.atk
  714. when :def
  715. text = Vocab.def
  716. value1 = @clone.def
  717. value2 = @actor.def
  718. when :spi
  719. text = Vocab.spi
  720. value1 = @clone.spi
  721. value2 = @actor.spi
  722. when :agi
  723. text = Vocab.agi
  724. value1 = @clone.agi
  725. value2 = @actor.agi
  726. when :dex
  727. next unless $imported["DEX Stat"]
  728. text = Vocab.dex
  729. value1 = @clone.dex
  730. value2 = @actor.dex
  731. when :res
  732. next unless $imported["RES Stat"]
  733. text = Vocab.res
  734. value1 = @clone.res
  735. value2 = @actor.res
  736. else; next
  737. end
  738. icon = Icon.stat(@actor, stat)
  739. icon = 0 if icon == nil
  740. value2 = sprintf("%+d", value2 - value1) if YEM::VICTORY::SHOW_DIFFERENCE
  741. draw_icon(icon, dx, dy)
  742. self.contents.font.color = text_color(colours[:stat_name])
  743. self.contents.draw_text(dx+24, dy, 60, WLH, text, 0)
  744. self.contents.font.color = text_color(colours[:old_stat])
  745. self.contents.draw_text(dx+84, dy, 60, WLH, value1, 2)
  746. if YEM::VICTORY::ARROW_ICON.is_a?(Integer)
  747. draw_icon(YEM::VICTORY::ARROW_ICON, dx+147, dy)
  748. else
  749. self.contents.font.color = text_color(colours[:arrow])
  750. self.contents.draw_text(dx+144, dy, 30, WLH, arrow, 1)
  751. end
  752. self.contents.font.color = text_color(colours[:new_stat])
  753. self.contents.draw_text(dx+174, dy, 60, WLH, value2, 0)
  754. dy += WLH
  755. end
  756. end
  757.  
  758. end # Window_Level_Up
  759.  
  760. #===============================================================================
  761. # Scene Map
  762. #===============================================================================
  763.  
  764. class Scene_Map < Scene_Base
  765.  
  766. #--------------------------------------------------------------------------
  767. # alias method: call battle
  768. #--------------------------------------------------------------------------
  769. alias call_battle_va call_battle unless $@
  770. def call_battle
  771. if $game_switches[YEM::VICTORY::BYPASS_BGM_SWITCH]
  772. @spriteset.update
  773. Graphics.update
  774. $game_player.make_encounter_count
  775. $game_player.straighten
  776. $game_temp.map_bgm = RPG::BGM.last
  777. $game_temp.map_bgs = RPG::BGS.last
  778. Sound.play_battle_start
  779. $game_temp.next_scene = nil
  780. $scene = Scene_Battle.new
  781. else
  782. call_battle_va
  783. end
  784. end
  785.  
  786. end # Scene Map
  787.  
  788. #===============================================================================
  789. # Scene_Battle
  790. #===============================================================================
  791.  
  792. class Scene_Battle < Scene_Base
  793.  
  794. #--------------------------------------------------------------------------
  795. # alias method: terminate
  796. #--------------------------------------------------------------------------
  797. alias terminate_va terminate unless $@
  798. def terminate
  799. @top_window.dispose if @top_window != nil
  800. @exp_window.dispose if @exp_window != nil
  801. @gold_window.dispose if @gold_window != nil
  802. @exp_back_window.dispose if @exp_back_window != nil
  803. @exp_front_window.dispose if @exp_front_window != nil
  804. @drops_window.dispose if @drops_window != nil
  805. terminate_va
  806. end
  807.  
  808. #--------------------------------------------------------------------------
  809. # overwrite method: process_victory
  810. #--------------------------------------------------------------------------
  811. def process_victory
  812. if $imported["BattleEngineMelody"]
  813. @judge_win_loss = true
  814. pause_atb(true, true)
  815. @enemy_gauge_window.dispose if @enemy_gauge_window != nil
  816. @hide_battlecursor = true
  817. @party_input_flag = true
  818. end
  819. wait_for_deaths if $imported["FancyDeaths"]
  820. unless $game_switches[YEM::VICTORY::BYPASS_BGM_SWITCH]
  821. RPG::BGM.stop
  822. $game_system.battle_end_me.play
  823. YEM::VICTORY::BGM.play unless YEM::VICTORY::BGM == nil
  824. end
  825. if $imported["BattleEngineMelody"]
  826. start_victory_poses
  827. @spriteset.update_dtb_order
  828. @spriteset.update_ctb_order
  829. end
  830. wait(YEM::VICTORY::WAIT, true)
  831. @info_viewport.visible = false
  832. if $imported["BattleEngineMelody"]
  833. @message_window.dispose
  834. @message_window = Window_BattleMessage.new
  835. elsif $imported["VictoryCompatibility"]
  836. @message_window.dispose
  837. @message_window = Window_BattleMessageCompatible.new
  838. end
  839. @message_window.visible = true
  840. create_victory_clones
  841. create_victory_actor
  842. display_exp_and_gold
  843. display_level_up
  844. display_drop_items
  845. battle_end(0)
  846. $game_temp.victory_actor = nil
  847. $game_temp.victory_clone = nil
  848. victory_me = Thread.new {
  849. time = YEM::VICTORY::FANFARE_FADE
  850. RPG::ME.fade(time)
  851. sleep(time / 1000.0)
  852. RPG::ME.stop }
  853. battle_end(0)
  854. end
  855.  
  856. #--------------------------------------------------------------------------
  857. # overwrite method: display_exp_and_gold
  858. #--------------------------------------------------------------------------
  859. def display_exp_and_gold
  860. unless $game_switches[YEM::VICTORY::SKIP_VICTORY_SWITCH]
  861. show_exp_and_gold
  862. else
  863. @exp = $game_troop.exp_total
  864. if YEM::VICTORY::PARTY_SPLIT_EXP
  865. size = YEM::VICTORY::DEAD_ALLY_EXP ?
  866. $game_party.members.size : $game_party.existing_members.size
  867. @exp = Integer(@exp * YEM::VICTORY::PARTY_SIZE_SCALING[size])
  868. end
  869. $game_party.gain_gold($game_troop.gold_total)
  870. end
  871. end
  872.  
  873. #--------------------------------------------------------------------------
  874. # overwrite method: display_level_up
  875. #--------------------------------------------------------------------------
  876. def display_level_up
  877. unless $game_switches[YEM::VICTORY::SKIP_VICTORY_SWITCH]
  878. show_level_up
  879. else
  880. group = YEM::VICTORY::DEAD_ALLY_EXP ?
  881. $game_party.members : $game_party.existing_members
  882. for actor in group
  883. last_level = actor.level
  884. last_skills = actor.learned_skills.clone
  885. actor.gain_exp(@exp, false)
  886. end
  887. end
  888. end
  889.  
  890. #--------------------------------------------------------------------------
  891. # overwrite method: display_drop_items
  892. #--------------------------------------------------------------------------
  893. def display_drop_items
  894. @active_battler = nil
  895. unless $game_switches[YEM::VICTORY::SKIP_VICTORY_SWITCH]
  896. show_drop_items
  897. else
  898. drop_items = $game_troop.make_drop_items
  899. for item in drop_items; $game_party.gain_item(item, 1); end
  900. end
  901. end
  902.  
  903. #--------------------------------------------------------------------------
  904. # new method: create_victory_clones
  905. #--------------------------------------------------------------------------
  906. def create_victory_clones
  907. $game_temp.victory_clone = {}
  908. $game_temp.in_battle = false
  909. for actor in $game_party.members
  910. $game_temp.victory_clone[actor.id] = actor.clone
  911. end
  912. $game_temp.in_battle = true
  913. end
  914.  
  915. #--------------------------------------------------------------------------
  916. # new method: create_victory_actor
  917. #--------------------------------------------------------------------------
  918. def create_victory_actor
  919. $game_temp.victory_actor = nil
  920. @original_victory_actor = victory_actor
  921. end
  922.  
  923. #--------------------------------------------------------------------------
  924. # new method: victory_actor
  925. #--------------------------------------------------------------------------
  926. def victory_actor
  927. if $game_temp.victory_actor == nil
  928. roulette = []
  929. for actor in $game_party.existing_members; roulette.push(actor); end
  930. $game_temp.victory_actor = roulette.size > 0 ?
  931. roulette[rand(roulette.size)] : nil
  932. end
  933. return $game_temp.victory_actor
  934. end
  935.  
  936. #--------------------------------------------------------------------------
  937. # new method: victory_actor_quote
  938. #--------------------------------------------------------------------------
  939. def victory_actor_quote(value)
  940. $game_temp.victory_quote = value
  941. if YEM::VICTORY::ACTOR_QUOTES.include?(victory_actor.id)
  942. $game_temp.common_event_id = YEM::VICTORY::ACTOR_QUOTES[victory_actor.id]
  943. else
  944. $game_temp.common_event_id = YEM::VICTORY::ACTOR_QUOTES[0]
  945. end
  946. @message_window.visible = true
  947. process_victory_event
  948. end
  949.  
  950. #--------------------------------------------------------------------------
  951. # new method: process_victory_event
  952. #--------------------------------------------------------------------------
  953. def process_victory_event
  954. loop do
  955. $game_troop.interpreter.update
  956. $game_troop.setup_battle_event
  957. wait_for_message
  958. return unless $game_troop.interpreter.running?
  959. update_basic
  960. end
  961. end
  962.  
  963. #--------------------------------------------------------------------------
  964. # new method: show_exp_and_gold
  965. #--------------------------------------------------------------------------
  966. def show_exp_and_gold
  967. #--- Draw Victory Message
  968. @top_window = Window_Help.new
  969. text = YEM::VICTORY::VOCAB[:top_message]
  970. @top_window.set_text(text, 1)
  971. #--- Draw EXP Window
  972. @exp = $game_troop.exp_total
  973. if YEM::VICTORY::PARTY_SPLIT_EXP
  974. size = YEM::VICTORY::DEAD_ALLY_EXP ?
  975. $game_party.members.size : $game_party.existing_members.size
  976. @exp = Integer(@exp * YEM::VICTORY::PARTY_SIZE_SCALING[size])
  977. end
  978. @exp_window = Window_Base.new(272, 56, 272, 56)
  979. text = sprintf(YEM::VICTORY::VOCAB[:exp_receive], @exp)
  980. @exp_window.contents.draw_text(0, 0, 240, 24, text, 1)
  981. #--- Draw Gold Window
  982. @gold = $game_troop.gold_total
  983. $game_party.gain_gold(@gold)
  984. @gold_window = Window_Base.new(0, 56, 272, 56)
  985. text = sprintf(YEM::VICTORY::VOCAB[:gold_found], @gold)
  986. @gold_window.contents.draw_text(0, 0, 240, 24, text, 1)
  987. #--- Draw Party EXP Windows
  988. @exp_back_window = Window_Party_Exp_Back.new
  989. @exp_front_window = Window_Party_Exp_Front.new
  990. if $imported["BattleEngineMelody"]
  991. @top_window.viewport = @spriteset.viewportC
  992. @exp_window.viewport = @spriteset.viewportC
  993. @gold_window.viewport = @spriteset.viewportC
  994. @exp_back_window.viewport = @spriteset.viewportC
  995. @exp_front_window.viewport = @spriteset.viewportC
  996. end
  997. if !YEM::VICTORY::SHOW_EXP_WINDOWS
  998. @top_window.visible = false
  999. @exp_window.visible = false
  1000. @gold_window.visible = false
  1001. @exp_back_window.visible = false
  1002. @exp_front_window.refresh(100)
  1003. @exp_front_window.visible = false
  1004. return
  1005. end
  1006. fill_exp_gauge
  1007. #--- Battle Quotes
  1008. if YEM::VICTORY::ENABLE_QUOTES
  1009. victory_actor_quote("MAIN")
  1010. else
  1011. text = sprintf(Vocab::Victory, $game_party.name)
  1012. $game_message.texts.push(text)
  1013. wait_for_message
  1014. end
  1015. end
  1016.  
  1017. #--------------------------------------------------------------------------
  1018. # new method: fill_exp_gauge
  1019. #--------------------------------------------------------------------------
  1020. def fill_exp_gauge
  1021. ticks = 0
  1022. percent = 0
  1023. increase = 100 / YEM::VICTORY::EXP_TICKS
  1024. until ticks > YEM::VICTORY::EXP_TICKS
  1025. ticks += 1
  1026. percent += increase
  1027. @exp_front_window.refresh(percent)
  1028. if @exp_front_window.full_actors != $game_party.existing_members.size
  1029. YEM::VICTORY::TICK_SOUND.play if YEM::VICTORY::TICK_SOUND != nil
  1030. end
  1031. update_basic
  1032. end
  1033. end
  1034.  
  1035. #--------------------------------------------------------------------------
  1036. # new method: show_level_up
  1037. #--------------------------------------------------------------------------
  1038. def show_level_up
  1039. return unless YEM::VICTORY::SHOW_LEVEL_WINDOWS
  1040. @top_window.visible = true
  1041. @exp_window.visible = false
  1042. @gold_window.visible = false
  1043. @exp_back_window.visible = false
  1044. @exp_front_window.visible = false
  1045. group = YEM::VICTORY::DEAD_ALLY_EXP ?
  1046. $game_party.members : $game_party.existing_members
  1047. for actor in group
  1048. last_level = actor.level
  1049. last_skills = actor.learned_skills.clone
  1050. actor.gain_exp(@exp, false)
  1051. create_level_up_windows(actor, last_skills) if actor.level > last_level
  1052. end
  1053. wait_for_message
  1054. end
  1055.  
  1056. #--------------------------------------------------------------------------
  1057. # new method: create_level_up_windows
  1058. #--------------------------------------------------------------------------
  1059. def create_level_up_windows(actor, last_skills)
  1060. @active_battler = actor
  1061. #--- Basic Settings
  1062. YEM::VICTORY::LEVEL_SOUND.play if YEM::VICTORY::LEVEL_SOUND != nil
  1063. $game_temp.victory_actor = actor
  1064. new_skills = actor.learned_skills - last_skills
  1065. @top_window.contents.clear
  1066. text = sprintf(YEM::VICTORY::VOCAB[:level_msg], actor.name, actor.level)
  1067. @top_window.set_text(text, 1)
  1068. #--- HP and MP Recovery
  1069. case YEM::VICTORY::HP_RECOVERY
  1070. when 1; actor.hp += actor.maxhp - $game_temp.victory_clone[actor.id].maxhp
  1071. when 2; actor.hp = actor.maxhp
  1072. end
  1073. case YEM::VICTORY::MP_RECOVERY
  1074. when 1; actor.mp += actor.maxmp - $game_temp.victory_clone[actor.id].maxmp
  1075. when 2; actor.mp = actor.maxmp
  1076. end
  1077. #--- Create Windows
  1078. if new_skills != []
  1079. @levelup_window = Window_Level_Up.new(actor, 0, 56, 316, 232)
  1080. @skill_back_window = Window_Base.new(316, 56, 228, 232)
  1081. @skill_back_window.contents.font.color = @skill_back_window.system_color
  1082. text = YEM::VICTORY::VOCAB[:new_skills]
  1083. @skill_back_window.contents.draw_text(0, 0, 196, 24, text, 1)
  1084. @skill_list_window = Window_New_Skills.new(new_skills)
  1085. else
  1086. @levelup_window = Window_Level_Up.new(actor, 0, 56, 544, 232)
  1087. end
  1088. if $imported["BattleEngineMelody"]
  1089. @levelup_window.viewport = @spriteset.viewportC
  1090. if @skill_back_window != nil
  1091. @skill_back_window.viewport = @spriteset.viewportC
  1092. @skill_list_window.viewport = @spriteset.viewportC
  1093. end
  1094. end
  1095. if YEM::VICTORY::ENABLE_QUOTES
  1096. value = (last_skills != actor.learned_skills) ? "SKILL" : "LEVEL"
  1097. victory_actor_quote(value)
  1098. else
  1099. text = sprintf(Vocab::LevelUp, actor.name, Vocab::level, actor.level)
  1100. $game_message.new_page
  1101. $game_message.texts.push(text)
  1102. if new_skills != []
  1103. for skill in new_skills
  1104. text = sprintf(Vocab::ObtainSkill, skill.name)
  1105. $game_message.texts.push(text)
  1106. end
  1107. end
  1108. wait_for_message
  1109. end
  1110. #--- Skill Window Scrolling
  1111. if new_skills.size > 7
  1112. @skill_list_window.index = 0
  1113. @skill_list_window.active = true
  1114. @skill_list_window.help_window = @top_window
  1115. loop do
  1116. update_basic
  1117. @skill_list_window.update
  1118. if Input.trigger?(Input::C)
  1119. Sound.play_decision; break
  1120. elsif Input.trigger?(Input::B)
  1121. Sound.play_cancel; break
  1122. elsif Input.press?(Input::A)
  1123. break
  1124. end
  1125. end
  1126. end
  1127. #--- Disposal of Windows
  1128. @levelup_window.dispose if @levelup_window != nil
  1129. @levelup_window = nil
  1130. @skill_back_window.dispose if @skill_back_window != nil
  1131. @skill_back_window = nil
  1132. @skill_list_window.dispose if @skill_list_window != nil
  1133. @skill_list_window = nil
  1134. end
  1135.  
  1136. #--------------------------------------------------------------------------
  1137. # new method: show_drop_items
  1138. #--------------------------------------------------------------------------
  1139. def show_drop_items
  1140. @drop_items = $game_troop.make_drop_items
  1141. for item in @drop_items; $game_party.gain_item(item, 1); end
  1142. return unless YEM::VICTORY::SHOW_ITEM_WINDOWS
  1143. @top_window.visible = true
  1144. if @drop_items != []
  1145. @top_window.set_text(YEM::VICTORY::VOCAB[:spoils],1)
  1146. YEM::VICTORY::ITEM_SOUND.play if YEM::VICTORY::ITEM_SOUND != nil
  1147. @drops_window = Window_BattleDrops.new(@drop_items)
  1148. if $imported["BattleEngineMelody"]
  1149. @drops_window.viewport = @spriteset.viewportC
  1150. end
  1151. else
  1152. @top_window.set_text(YEM::VICTORY::VOCAB[:no_items],1)
  1153. @exp_window.visible = true
  1154. @gold_window.visible = true
  1155. @exp_back_window.visible = true
  1156. @exp_front_window.visible = true
  1157. end
  1158. if YEM::VICTORY::ENABLE_QUOTES
  1159. $game_temp.victory_actor = @original_victory_actor
  1160. value = (@drop_items == []) ? "NOTHING" : "DROPS"
  1161. victory_actor_quote(value)
  1162. else
  1163. if @drop_items == []
  1164. text = YEM::VICTORY::VOCAB[:no_items]
  1165. else
  1166. text = sprintf(YEM::VICTORY::VOCAB[:found_items], $game_party.name)
  1167. end
  1168. $game_message.texts.push(text)
  1169. wait_for_message
  1170. end
  1171. if @drop_items != [] and @drops_window.item_max > 16
  1172. @drops_window.index = 0
  1173. @drops_window.active = true
  1174. @drops_window.help_window = @top_window
  1175. loop do
  1176. update_basic
  1177. @drops_window.update
  1178. if Input.trigger?(Input::C)
  1179. Sound.play_decision; break
  1180. elsif Input.trigger?(Input::B)
  1181. Sound.play_cancel; break
  1182. elsif Input.press?(Input::A)
  1183. break
  1184. end
  1185. end
  1186. end
  1187. end
  1188.  
  1189. end # Scene_Battle
  1190.  
  1191. #===============================================================================
  1192. #
  1193. # END OF FILE
  1194. #
  1195. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment