Advertisement
Guest User

Untitled

a guest
Jan 17th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 64.42 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Yanfly Engine Zealous - Party Selection System
  4. # Last Date Updated: 2010.01.21
  5. # Level: Normal, Hard, Lunatic
  6. #
  7. # By default, RPG Maker VX lacks a menu that allows for party switching. If a
  8. # player reaches four members, any newer members added would be simply ignored
  9. # unless the player has enough members and re-run the event again. With this
  10. # script, players will finally be able to adjust the party the way they want.
  11. #
  12. #===============================================================================
  13. # Updates
  14. # -----------------------------------------------------------------------------
  15. # o 2010.01.21 - Scrolling efficiency update.
  16. # o 2010.01.03 - Victory Aftermath Compatibility.
  17. # o 2010.01.02 - Variable Control Bugfix.
  18. #              - Moved playtime up in the save window.
  19. # o 2010.01.01 - Shop display fixed to show only battle members.
  20. # o 2009.12.31 - Reserve party members now have their states updated.
  21. # o 2009.12.27 - All Dead-Party Bugfix.
  22. #              - Efficiency update.
  23. # o 2009.12.24 - Script finished.
  24. # o 2009.12.22 - Started Script.
  25. #===============================================================================
  26. # Instructions
  27. # -----------------------------------------------------------------------------
  28. # To install this script, open up your script editor and copy/paste this script
  29. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  30. #
  31. # -----------------------------------------------------------------------------
  32. # Module Edit Requirements
  33. # -----------------------------------------------------------------------------
  34. # Search for ENABLE_SWITCH and BATTLE_SWITCH. Bind these two constants to the
  35. # proper switch ID's you wish to associate them with.
  36. #
  37. # -----------------------------------------------------------------------------
  38. # Script Commands - These are used with the Event Editor's Script command.
  39. # -----------------------------------------------------------------------------
  40. # $game_party.fix_actor(n)
  41. # Makes it so that the actor cannot be taken out of the party. Requires the
  42. # actor to be in the party already.
  43. #
  44. # $game_party.unfix_actor(n)
  45. # Allows the actor to be taken out of the party again. Requires the actor to
  46. # be in the party already.
  47. #
  48. # $game_party.set_battlers(n1, n2, n3, n4)
  49. # Allows you to set a party the way you want it to. Actors must have joined
  50. # or else no changes will be made to that slot.
  51. #
  52. #===============================================================================
  53. # Compatibility
  54. # -----------------------------------------------------------------------------
  55. # - Works With: YEZ Battle Engine Zealous, YEZ Main Menu Zealous
  56. # -----------------------------------------------------------------------------
  57. # Note: This script may not work with former Yanfly Engine ReDux scripts.
  58. #       Use Yanfly Engine Zealous scripts to work with this if available.
  59. # Thanks to KGC Software for a lot of reference work.
  60. #===============================================================================
  61.  
  62. $imported = {} if $imported == nil
  63. $imported["PartySelectionSystem"] = true
  64.  
  65. module YEZ
  66.   module PARTY
  67.    
  68.     #===========================================================================
  69.     # Basic Settings
  70.     # -------------------------------------------------------------------------
  71.     # This here allows you to adjust the basic settings that govern the overall
  72.     # party changing scene. Change them as you see fitting.
  73.     #===========================================================================
  74.    
  75.     # These two items adjust how the party command appears in your main menu.
  76.     TITLE = "Party"
  77.     ICON = 85
  78.    
  79.     # This switch needs to be on before the party change option will appear in
  80.     # the main menu. Bind it properly to use it.
  81.     ENABLE_SWITCH = 42
  82.     BATTLE_SWITCH = 43
  83.     BATTLE_DEFAULT = false  # Set to true to have it on by default.
  84.    
  85.     # This is mostly used for eventing and determining which members are in the
  86.     # party by storing their ID's inside of these following variables. Adjusted
  87.     # whenever the player refreshes (quite often).
  88.     VAR_PARTY_MEM1  = 41
  89.     VAR_PARTY_MEM2  = 42
  90.     VAR_PARTY_MEM3  = 43
  91.     VAR_PARTY_MEM4  = 44
  92.    
  93.     # This variable is used for setting a focused character to be visible when
  94.     # traveling on the field for story purposes. Whatever this variable equals,
  95.     # that character will be displayed instead of whoever is the party leader.
  96.     VAR_FOCUSED = 45
  97.    
  98.     # This is the maximum number of members that can be in your active party
  99.     # at once. Going over this number will result in a bitmap error that can't
  100.     # be corrected by scripts alone.
  101.     MAXIMUM_MEMBERS = 3
  102.    
  103.     # Setting this to true will cause status effects to update and take effect
  104.     # for actors in the battle reserve.
  105.     RESERVE_STATES_EFFECT = true
  106.    
  107.     # Determines what percentage of the EXP won is given to non-participating
  108.     # party members. 0.50 means 50%.
  109.     BATTLE_RESERVE_EXP = 0.25
  110.    
  111.     # This will show the level up messages for characters in the reserve if
  112.     # they did indeed level.
  113.     RESERVE_LEVEL_UP = true
  114.    
  115.     #===========================================================================
  116.     # Party Switching Settings
  117.     # -------------------------------------------------------------------------
  118.     # The following settings adjust what appears within the party switching
  119.     # scene from the various ways to sort actors to the vocabulary used.
  120.     #===========================================================================
  121.    
  122.     # The following adjusts the assort menu. The default list consists as such.
  123.     # :story, :name, :class, :level, :hp, :mp, :atk, :def, :spi, :res,
  124.     # :dex, :agi, :hit, :eva, :cri, :dur, :luk, :odds
  125.     ASSORT_COMMANDS =[
  126.       :name, :story, :class, :level, :hp, :mp, :atk, :def, :spi, :res,
  127.       :dex, :agi, :hit, :eva, :cri, :dur, :luk, :odds
  128.     ] # Do not remove this.
  129.    
  130.     # This little array here allows you to set certain actors as higher
  131.     # priority for story sorting than other actors. Unlisted actors will have
  132.     # their positions unchanged other than being lower on the list than the
  133.     # story priority characters.
  134.     STORY_SORTING = [1..4, 6]
  135.    
  136.     # The following hash adjusts the vocabulary used for all of the party
  137.     # switching scene. Adjust the vocabulary as you see fit.
  138.     VOCAB ={
  139.       :clear     => "Remove",
  140.       :empty     => "Empty",
  141.       :nodata    => "No Data",
  142.       :c_battler => "Change",
  143.       :b_battler => "Finish",
  144.       :a_battler => "Remove",
  145.       :x_battler => "Revert",
  146.       :c_actors  => "Select",
  147.       :b_actors  => "Cancel",
  148.       :a_actors  => "Assort",
  149.       :x_actors  => "Revert",
  150.       :sort_by   => "Sort Actors...",
  151.       :story     => "By Story",
  152.       :name      => "By Name",
  153.       :class     => "By Class",
  154.       :level     => "By Level",
  155.       :stat      => "By %s",
  156.     } # Do not remove this.
  157.    
  158.     # The following determines how the game displays the keys inside of the
  159.     # help window. %s will be the instruction following.
  160.     KEYS ={
  161.       :a => "A:%s",
  162.       :b => "B:%s",
  163.       :c => "C:%s",
  164.       :x => "X:%s",
  165.     } # Do not remove this.
  166.    
  167.     # This here is a list of the stats shown in the status window. Certain stats
  168.     # will not appear unless certain scripts are installed. The order you place
  169.     # these stats will be the order they appear in the window.
  170.     # :atk, :def, :spi, :res, :dex, :agi, :hit, :eva, :cri, :dur, :luk, :odds
  171.     SHOWN_STATS = [:atk, :def, :spi, :res, :dex, :agi,
  172.                    :hit, :eva, :cri, :dur, :luk, :odds]
  173.    
  174.     # These are the misc visual adjustments you can make the scene.
  175.     FACE_OPACITY  = 255      # Face opacity for battler window.
  176.     SPRITE_OFFSET = 12       # Sprite offset for party list.
  177.     ACTIVE_COLOUR = 6        # Highlighted Name Colour
  178.     CLEAR_ICON    = 98       # This is used for clearing an actor.
  179.     UP_ICON       = 142      # These are the icons used when stats are higher
  180.     DN_ICON       = 143      # or lower than their base amounts.
  181.     LOCKED_ICON   = 80       # Icon used for locked actors.
  182.    
  183.     #===========================================================================
  184.     # Menu Status Window
  185.     # -------------------------------------------------------------------------
  186.     # When viewing the main menu, the status window will now host the extra
  187.     # party members that aren't participating in battle.
  188.     #===========================================================================
  189.    
  190.     # This adjusts the back colour opacity for non-battle members inside of
  191.     # the main menu's party window.
  192.     BACK_OPACITY = 64
  193.    
  194.     # This adjusts the way EXP bars are displayed inside the main menu status
  195.     # window. Adjust it as you see fit.
  196.     EXP_TEXT      = "EXP"      # Text used for EXP
  197.     PERCENT_EXP   = "%1.2f%%"  # Text format used for EXP percentage
  198.     EXP_GAUGE_1   = 28         # Colour 1 for the EXP Gauge
  199.     EXP_GAUGE_2   = 29         # Colour 2 for the EXP Gauge
  200.    
  201.   end # PARTY
  202. end # YEZ
  203.  
  204. #===============================================================================
  205. # Editting anything past this point may potentially result in causing computer
  206. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  207. # Therefore, edit at your own risk.
  208. #===============================================================================
  209.  
  210. module YEZ::PARTY
  211.   module_function
  212.   #--------------------------------------------------------------------------
  213.   # convert_integer_array
  214.   #--------------------------------------------------------------------------
  215.   def convert_integer_array(array)
  216.     result = []
  217.     array.each { |i|
  218.       case i
  219.       when Range; result |= i.to_a
  220.       when Integer; result |= [i]
  221.       end }
  222.     return result
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # story_sorting_list
  226.   #--------------------------------------------------------------------------
  227.   STORY_SORTING_LIST = convert_integer_array(STORY_SORTING)
  228. end # YEZ::PARTY
  229.  
  230. module Vocab
  231.   def self.hit; return "HIT"; end
  232.   def self.eva; return "EVA"; end
  233.   def self.cri; return "CRI"; end
  234.   def self.odds;return "AGR"; end
  235. end # Vocab
  236.  
  237. #===============================================================================
  238. # Game_Party
  239. #===============================================================================
  240.  
  241. class Game_Party < Game_Unit
  242.  
  243.   #--------------------------------------------------------------------------
  244.   # constants
  245.   #--------------------------------------------------------------------------
  246.   MAX_MEMBERS = [[YEZ::PARTY::MAXIMUM_MEMBERS, 99].min, 1].max
  247.   BATTLE_MAX = 4
  248.  
  249.   #--------------------------------------------------------------------------
  250.   # public instance variables
  251.   #--------------------------------------------------------------------------
  252.   attr_accessor :actors
  253.   attr_accessor :battlers
  254.   attr_accessor :fixed_actors
  255.  
  256.   #--------------------------------------------------------------------------
  257.   # alias method: members
  258.   #--------------------------------------------------------------------------
  259.   alias members_pss members unless $@
  260.   def members
  261.     if $game_temp.in_battle or $scene.is_a?(Scene_Shop)
  262.       return battle_members
  263.     else
  264.       result = []
  265.       for member in battle_members
  266.         result.push(member)
  267.       end
  268.       for member in all_members
  269.         result.push(member) unless result.include?(member)
  270.       end
  271.       return result
  272.     end
  273.   end
  274.  
  275.   #--------------------------------------------------------------------------
  276.   # new method: all_members
  277.   #--------------------------------------------------------------------------
  278.   def all_members; return members_pss.uniq; end
  279.    
  280.   #--------------------------------------------------------------------------
  281.   # new method: reserve_members
  282.   #--------------------------------------------------------------------------
  283.   def reserve_members; return (members_pss - battle_members).uniq; end
  284.    
  285.   #--------------------------------------------------------------------------
  286.   # new method: battle_members
  287.   #--------------------------------------------------------------------------
  288.   def battle_members
  289.     if @battlers == nil
  290.       @battlers = [0, 0, 0, 0]
  291.       for i in 0..([@actors.size, BATTLE_MAX].min - 1)
  292.         @battlers[i] = @actors[i]
  293.       end
  294.     end
  295.     result = []
  296.     for id in @battlers
  297.       result.push($game_actors[id]) unless $game_actors[id] == nil
  298.     end
  299.     return result
  300.   end
  301.  
  302.   #--------------------------------------------------------------------------
  303.   # new method: set_battlers
  304.   #--------------------------------------------------------------------------
  305.   def set_battlers(n1 = 0, n2 = 0, n3 = 0, n4 = 0)
  306.     battle_members if @battlers == nil
  307.     n1 = @battlers[0] unless @actors.include?(n1)
  308.     n2 = @battlers[1] unless @actors.include?(n2)
  309.     n3 = @battlers[2] unless @actors.include?(n3)
  310.     n4 = @battlers[3] unless @actors.include?(n4)
  311.     @battlers = [n1, n2, n3, n4]
  312.     $game_player.refresh
  313.   end
  314.  
  315.   #--------------------------------------------------------------------------
  316.   # new method: fixed_members
  317.   #--------------------------------------------------------------------------
  318.   def fixed_members
  319.     result = []
  320.     @fixed_actors = [] if @fixed_actors == nil
  321.     for id in @fixed_actors
  322.       result.push($game_actors[id]) unless $game_actors[id] == nil
  323.     end
  324.     return result
  325.   end
  326.  
  327.   #--------------------------------------------------------------------------
  328.   # new method: fix_actor
  329.   #--------------------------------------------------------------------------
  330.   def fix_actor(actor_id)
  331.     @fixed_actors = [] if @fixed_actors == nil
  332.     battle_members if @battlers == nil
  333.     return unless @battlers.include?(actor_id)
  334.     @fixed_actors.push(actor_id)
  335.   end
  336.  
  337.   #--------------------------------------------------------------------------
  338.   # new method: unfix_actor
  339.   #--------------------------------------------------------------------------
  340.   def unfix_actor(actor_id)
  341.     @fixed_actors = [] if @fixed_actors == nil
  342.     return unless @battlers.include?(actor_id)
  343.     @fixed_actors.delete(actor_id)
  344.   end
  345.  
  346.   #--------------------------------------------------------------------------
  347.   # alias method: setup_starting_members
  348.   #--------------------------------------------------------------------------
  349.   alias setup_starting_members_pss setup_starting_members unless $@
  350.   def setup_starting_members
  351.     setup_starting_members_pss
  352.     $game_switches[YEZ::PARTY::ENABLE_SWITCH] = true
  353.     $game_switches[YEZ::PARTY::BATTLE_SWITCH] = YEZ::PARTY::BATTLE_DEFAULT
  354.   end
  355.  
  356.   #--------------------------------------------------------------------------
  357.   # alias method: add_actor
  358.   #--------------------------------------------------------------------------
  359.   alias add_actor_pss add_actor unless $@
  360.   def add_actor(actor_id)
  361.     last_size = @actors.size
  362.     add_actor_pss(actor_id)
  363.     if last_size < @actors.size
  364.       battle_members if @battlers == nil
  365.       for i in 0..(@battlers.size-1)
  366.         if @battlers[i] == 0
  367.           @battlers[i] = actor_id
  368.           break
  369.         end
  370.       end
  371.     end
  372.   end
  373.  
  374.   #--------------------------------------------------------------------------
  375.   # alias method: remove_actor
  376.   #--------------------------------------------------------------------------
  377.   alias remove_actor_pss remove_actor unless $@
  378.   def remove_actor(actor_id)
  379.     battle_members if @battlers == nil
  380.     @battlers[@battlers.index(actor_id)] = 0 if @battlers.include?(actor_id)
  381.     remove_actor_pss(actor_id)
  382.   end
  383.  
  384. end # Game_Party
  385.  
  386. #===============================================================================
  387. # Game_Player
  388. #===============================================================================
  389.  
  390. class Game_Player < Game_Character
  391.  
  392.   #--------------------------------------------------------------------------
  393.   # alias method: refresh
  394.   #--------------------------------------------------------------------------
  395.   alias refresh_player_pss refresh unless $@
  396.   def refresh
  397.     refresh_player_pss
  398.     if $game_variables[YEZ::PARTY::VAR_FOCUSED] > 0
  399.       actor = $game_actors[$game_variables[YEZ::PARTY::VAR_FOCUSED]]
  400.       @character_name = actor.character_name
  401.       @character_index = actor.character_index
  402.     end
  403.     return if $game_party.members.size == 0
  404.     bat = $game_party.battle_members
  405.     $game_variables[YEZ::PARTY::VAR_PARTY_MEM1] = bat.size > 0 ? bat[0].id : 0
  406.     $game_variables[YEZ::PARTY::VAR_PARTY_MEM2] = bat.size > 1 ? bat[1].id : 0
  407.     $game_variables[YEZ::PARTY::VAR_PARTY_MEM3] = bat.size > 2 ? bat[2].id : 0
  408.     $game_variables[YEZ::PARTY::VAR_PARTY_MEM4] = bat.size > 3 ? bat[3].id : 0
  409.   end
  410.  
  411. end # Game_Player
  412.  
  413. #===============================================================================
  414. # Game_Interpreter
  415. #===============================================================================
  416.  
  417. class Game_Interpreter
  418.  
  419.   #--------------------------------------------------------------------------
  420.   # alias method: control variable
  421.   #--------------------------------------------------------------------------
  422.   alias command_122_pss command_122 unless $@
  423.   def command_122
  424.     n = command_122_pss
  425.     $game_player.refresh if @params[0] == YEZ::PARTY::VAR_FOCUSED
  426.     return n
  427.   end
  428.  
  429. end # Game_Interpreter
  430.  
  431. #===============================================================================
  432. # Scene_Menu
  433. #===============================================================================
  434.  
  435. class Scene_Menu < Scene_Base
  436.  
  437.   #--------------------------------------------------------------------------
  438.   # alias method: create_command_window
  439.   #--------------------------------------------------------------------------
  440.   alias create_command_window_pss create_command_window unless $@
  441.   def create_command_window
  442.     create_command_window_pss
  443.     return if $imported["CustomMenuCommand"]
  444.     if $game_switches[YEZ::PARTY::ENABLE_SWITCH] and
  445.     $game_party.all_members.size > 1
  446.       title = YEZ::PARTY::TITLE
  447.       @command_party = @command_window.add_command(title)
  448.       if @command_window.oy > 0
  449.         @command_window.oy -= Window_Base::WLH
  450.       end
  451.     end
  452.     @command_window.index = @menu_index
  453.   end
  454.  
  455.   #--------------------------------------------------------------------------
  456.   # alias method: update_command_selection
  457.   #--------------------------------------------------------------------------
  458.   alias update_command_selection_pss update_command_selection unless $@
  459.   def update_command_selection
  460.     call_yez_command = 0
  461.     if Input.trigger?(Input::C)
  462.       case @command_window.index
  463.       when @command_party
  464.         Sound.play_decision
  465.         $scene = Scene_Party.new(@command_window.index, Scene_Party::HOST_MENU)
  466.         return
  467.       end
  468.     end
  469.     update_command_selection_pss
  470.   end
  471.  
  472. end # Scene Menu
  473.  
  474. #===============================================================================
  475. # Scene_Battle
  476. #===============================================================================
  477.  
  478. class Scene_Battle < Scene_Base
  479.  
  480.   if YEZ::PARTY::RESERVE_STATES_EFFECT
  481.   #--------------------------------------------------------------------------
  482.   # alias method: start_main
  483.   #--------------------------------------------------------------------------
  484.   if $imported["CustomStatusPropertiesZeal"]
  485.   alias start_main_pss start_main unless $@
  486.   def start_main
  487.     start_main_pss
  488.     for member in $game_party.reserve_members
  489.       for state in member.states;
  490.         member.custom_status_effects(state, "BEGIN")
  491.       end
  492.     end
  493.   end
  494.   end
  495.  
  496.   #--------------------------------------------------------------------------
  497.   # alias method: turn_end
  498.   #--------------------------------------------------------------------------
  499.   alias turn_end_pss turn_end unless $@
  500.   def turn_end
  501.     for member in $game_party.reserve_members
  502.       member.slip_damage_effect
  503.       member.do_auto_recovery
  504.       member.remove_states_auto
  505.     end
  506.     turn_end_pss
  507.   end
  508.   end # YEZ::PARTY::RESERVE_STATES_EFFECT
  509.  
  510.   #--------------------------------------------------------------------------
  511.   # alias method: display_level_up
  512.   #--------------------------------------------------------------------------
  513.   unless $imported["VictoryAftermath"]
  514.   alias display_level_up_pss display_level_up unless $@
  515.   def display_level_up
  516.     display_level_up_pss
  517.     exp = Integer($game_troop.exp_total * YEZ::PARTY::BATTLE_RESERVE_EXP)
  518.     for actor in $game_party.reserve_members
  519.       actor.gain_exp(exp, YEZ::PARTY::RESERVE_LEVEL_UP) if actor.exist?
  520.     end
  521.     wait_for_message
  522.   end
  523.   end
  524.  
  525.   #--------------------------------------------------------------------------
  526.   # alias method: battle_end
  527.   #--------------------------------------------------------------------------
  528.   alias battle_end_pss battle_end unless $@
  529.   def battle_end(result)
  530.     battle_end_pss(result)
  531.     for member in $game_party.reserve_members
  532.       member.remove_states_battle
  533.     end
  534.   end
  535.  
  536. end # Scene_Battle
  537.  
  538. #===============================================================================
  539. # Scene_Party
  540. #===============================================================================
  541.  
  542. class Scene_Party < Scene_Base
  543.  
  544.   #--------------------------------------------------------------------------
  545.   # constants
  546.   #--------------------------------------------------------------------------
  547.   HOST_MENU   = 0
  548.   HOST_MAP    = 1
  549.   HOST_BATTLE = 2
  550.  
  551.   #--------------------------------------------------------------------------
  552.   # initialize
  553.   #--------------------------------------------------------------------------
  554.   def initialize(menu_index = 0, host_menu = HOST_MENU)
  555.     @menu_index = menu_index
  556.     @host_menu = host_menu
  557.   end
  558.  
  559.   #--------------------------------------------------------------------------
  560.   # start
  561.   #--------------------------------------------------------------------------
  562.   def start
  563.     super
  564.     create_menu_background
  565.     @battlers_window = Window_PartyBattlers.new
  566.     @actors_window = Window_PartyActors.new
  567.     @help_window = Window_PartyHelp.new
  568.     @status_window = Window_PartyStatus.new
  569.     @status_window.refresh(@battlers_window.item)
  570.     create_assort_back_window
  571.     @assort_window = Window_PartyAssort.new
  572.     @original_party = $game_party.battlers.clone
  573.     @original_order = $game_party.actors.clone
  574.     @last_battler_index = 0
  575.     @last_actor_index = 0
  576.   end
  577.  
  578.   #--------------------------------------------------------------------------
  579.   # create_assort_back_window
  580.   #--------------------------------------------------------------------------
  581.   def create_assort_back_window
  582.     @assort_back = Window_Base.new(160, 128, 384, 288)
  583.     @assort_back.contents.clear
  584.     text = YEZ::PARTY::VOCAB[:sort_by]
  585.     @assort_back.contents.draw_text(0, 0, 344, 36, text, 1)
  586.     @assort_back.visible = false
  587.   end
  588.  
  589.   #--------------------------------------------------------------------------
  590.   # terminate
  591.   #--------------------------------------------------------------------------
  592.   def terminate
  593.     super
  594.     dispose_menu_background
  595.     @battlers_window.dispose if @battlers_window != nil
  596.     @actors_window.dispose if @actors_window != nil
  597.     @help_window.dispose if @help_window != nil
  598.     @status_window.dispose if @status_window != nil
  599.     @assort_window.dispose if @assort_window != nil
  600.     @assort_back.dispose if @assort_back != nil
  601.   end
  602.  
  603.   #--------------------------------------------------------------------------
  604.   # return_scene
  605.   #--------------------------------------------------------------------------
  606.   def return_scene
  607.     case @host_menu
  608.     when HOST_MAP
  609.       $scene = Scene_Map.new
  610.     when HOST_BATTLE
  611.       $scene = Scene_Battle.new
  612.     when HOST_MENU
  613.       if $imported["CustomMenuCommand"] and
  614.       $game_temp.menu_command_index.has_key?(:party)
  615.         $scene = Scene_Menu.new($game_temp.menu_command_index[:party])
  616.       else
  617.       $scene = Scene_Menu.new(@menu_index)
  618.       end
  619.     end
  620.     $game_player.refresh
  621.   end
  622.  
  623.   #--------------------------------------------------------------------------
  624.   # update
  625.   #--------------------------------------------------------------------------
  626.   def update
  627.     super
  628.     update_menu_background
  629.     if @battlers_window.active
  630.       update_battlers_window
  631.     elsif @actors_window.active
  632.       update_actors_window
  633.     elsif @assort_window.active
  634.       update_assort_window
  635.     end
  636.   end
  637.  
  638.   #--------------------------------------------------------------------------
  639.   # refresh
  640.   #--------------------------------------------------------------------------
  641.   def refresh
  642.     @battlers_window.refresh
  643.     @actors_window.refresh
  644.     if @battlers_window.active
  645.       @status_window.refresh(@battlers_window.item) if @battlers_window.item !=
  646.       @status_window.item
  647.     elsif @actors_window.active
  648.       @status_window.refresh(@actors_window.item) if @actors_window.item !=
  649.       @status_window.item
  650.     end
  651.     $game_player.refresh
  652.   end
  653.  
  654.   #--------------------------------------------------------------------------
  655.   # update_battlers_window
  656.   #--------------------------------------------------------------------------
  657.   def update_battlers_window
  658.     @battlers_window.update
  659.     @help_window.refresh(1) if @help_window.type != 1
  660.     if @last_battler_index != @battlers_window.index
  661.       @last_battler_index = @battlers_window.index
  662.       @status_window.refresh(@battlers_window.item) if @battlers_window.item !=
  663.       @status_window.item
  664.     end
  665.     if Input.trigger?(Input::B)
  666.       if @battlers_window.selected_index == nil
  667.         if $game_party.battle_members == []
  668.           Sound.play_buzzer
  669.         elsif $game_party.all_dead?
  670.           Sound.play_buzzer
  671.         else
  672.           for actor in $game_party.fixed_members
  673.             next if $game_party.battle_members.include?(actor)
  674.             Sound.play_buzzer
  675.             return
  676.           end
  677.           Sound.play_cancel
  678.           return_scene
  679.         end
  680.       else
  681.         @battlers_window.selected_index = nil
  682.         refresh
  683.       end
  684.     elsif Input.trigger?(Input::A)
  685.       id = @battlers_window.item
  686.       if id != 0 and $game_party.fixed_members.include?($game_actors[id])
  687.         Sound.play_buzzer
  688.         return
  689.       end
  690.       Sound.play_equip
  691.       index = @battlers_window.index
  692.       $game_party.battlers[index] = 0
  693.       refresh
  694.     elsif Input.trigger?(Input::X)
  695.       Sound.play_equip
  696.       $game_party.battlers = @original_party.clone
  697.       refresh
  698.     elsif Input.trigger?(Input::L)
  699.       Sound.play_equip
  700.       index1 = @battlers_window.index
  701.       index2 = index1 - 1
  702.       temp = $game_party.battlers[index1]
  703.       $game_party.battlers[index1] = $game_party.battlers[index2]
  704.       $game_party.battlers[index2] = temp
  705.       @battlers_window.index -= 1
  706.       @battlers_window.index = 3 if @battlers_window.index < 0
  707.       refresh
  708.     elsif Input.trigger?(Input::R)
  709.       Sound.play_equip
  710.       index1 = @battlers_window.index
  711.       index2 = index1 - 3
  712.       temp = $game_party.battlers[index1]
  713.       $game_party.battlers[index1] = $game_party.battlers[index2]
  714.       $game_party.battlers[index2] = temp
  715.       @battlers_window.index += 1
  716.       @battlers_window.index = 0 if @battlers_window.index > 3
  717.       refresh
  718.     elsif Input.trigger?(Input::C)
  719.       id = @battlers_window.item
  720.       if id != 0 and $game_party.fixed_members.include?($game_actors[id])
  721.         Sound.play_buzzer
  722.         return
  723.       end
  724.       if @battlers_window.selected_index == nil
  725.         Sound.play_decision
  726.         @battlers_window.selected_index = @battlers_window.index
  727.         @battlers_window.draw_item(@battlers_window.index)
  728.         @battlers_window.active = false
  729.         @actors_window.active = true
  730.         @actors_window.index = @last_actor_index
  731.         @status_window.refresh(@actors_window.item)
  732.       else
  733.         Sound.play_equip
  734.         actor_id = @battlers_window.item
  735.         temp_id = @battlers_window.selected_item
  736.         $game_party.battlers[@battlers_window.index] = temp_id
  737.         $game_party.battlers[@battlers_window.selected_index] = actor_id
  738.         @battlers_window.selected_index = nil
  739.         refresh
  740.       end
  741.     elsif Input.trigger?(Input::DOWN) and @battlers_window.selected_index == nil
  742.       Sound.play_cursor
  743.       @battlers_window.active = false
  744.       @battlers_window.index = -1
  745.       @actors_window.active = true
  746.       @actors_window.index = @last_actor_index
  747.       @status_window.refresh(@actors_window.item)
  748.     end
  749.   end
  750.  
  751.   #--------------------------------------------------------------------------
  752.   # update_actors_window
  753.   #--------------------------------------------------------------------------
  754.   def update_actors_window
  755.     @help_window.refresh(2) if @help_window.type != 2
  756.     if @last_actor_index != @actors_window.index
  757.       @last_actor_index = @actors_window.index
  758.       @status_window.refresh(@actors_window.item)
  759.     end
  760.     if Input.trigger?(Input::B)
  761.       Sound.play_cancel
  762.       if @actors_window.selected_index != nil
  763.         @actors_window.selected_index = nil
  764.         @actors_window.refresh
  765.       else
  766.         @battlers_window.active = true
  767.         @actors_window.active = false
  768.         @battlers_window.index = @last_battler_index
  769.         @battlers_window.selected_index = nil
  770.         @battlers_window.draw_item(@battlers_window.index)
  771.         @status_window.refresh(@battlers_window.item)
  772.       end
  773.     elsif Input.repeat?(Input::UP) and @actors_window.selected_index == nil and
  774.     @actors_window.index == 0 and @battlers_window.selected_index == nil
  775.       Sound.play_cursor
  776.       @battlers_window.active = true
  777.       @actors_window.active = false
  778.       @battlers_window.index = @last_battler_index
  779.       @battlers_window.selected_index = nil
  780.       @battlers_window.draw_item(@battlers_window.index)
  781.       @status_window.refresh(@battlers_window.item)
  782.     elsif Input.trigger?(Input::A) and @actors_window.selected_index == nil
  783.       Sound.play_decision
  784.       @assort_window.active = true
  785.       @assort_window.visible = true
  786.       @assort_back.visible = true
  787.       @actors_window.active = false
  788.       @status_window.visible = false
  789.     elsif Input.trigger?(Input::X)
  790.       Sound.play_equip
  791.       $game_party.actors = @original_order.clone
  792.       refresh
  793.     elsif Input.trigger?(Input::C)
  794.       actor_id = @actors_window.item
  795.       if @battlers_window.selected_index != nil
  796.         Sound.play_equip
  797.         if $game_party.battlers.include?(actor_id) and actor_id != 0
  798.           ix = $game_party.battlers.index(actor_id)
  799.           jx = @battlers_window.selected_index
  800.           $game_party.battlers[ix] = $game_party.battlers[jx]
  801.         end
  802.         $game_party.battlers[@battlers_window.selected_index] = actor_id
  803.         @battlers_window.selected_index = nil
  804.         @battlers_window.active = true
  805.         @actors_window.active = false
  806.         @battlers_window.index = @last_battler_index
  807.         refresh
  808.       elsif @actors_window.selected_index == nil and actor_id > 0
  809.         Sound.play_equip
  810.         @actors_window.selected_index = @actors_window.index
  811.         @actors_window.refresh
  812.       elsif actor_id > 0
  813.         Sound.play_equip
  814.         ix = $game_party.actors.index(actor_id)
  815.         jx = @actors_window.selected_index
  816.         $game_party.actors[ix] = $game_party.actors[jx]
  817.         $game_party.actors[@actors_window.selected_index] = actor_id
  818.         @actors_window.selected_index = nil
  819.         @actors_window.refresh
  820.         @status_window.refresh(@actors_window.item)
  821.       end
  822.     end
  823.     @actors_window.update
  824.   end
  825.  
  826.   #--------------------------------------------------------------------------
  827.   # update_assort_window
  828.   #--------------------------------------------------------------------------
  829.   def update_assort_window
  830.     @assort_window.update
  831.     if Input.trigger?(Input::B)
  832.       Sound.play_cancel
  833.       @assort_window.active = false
  834.       @assort_window.visible = false
  835.       @assort_back.visible = false
  836.       @actors_window.active = true
  837.       @status_window.visible = true
  838.     elsif Input.trigger?(Input::C) or Input.trigger?(Input::A)
  839.       if Input.trigger?(Input::C)
  840.         @assort_window.active = false
  841.         @assort_window.visible = false
  842.         @assort_back.visible = false
  843.         @actors_window.active = true
  844.         @status_window.visible = true
  845.       end
  846.       Sound.play_equip
  847.       #---
  848.       result = $game_party.all_members
  849.       case @assort_window.command
  850.       when :story
  851.         priority = []
  852.         for id in YEZ::PARTY::STORY_SORTING_LIST
  853.           priority.push($game_actors[id]) if $game_party.actors.include?(id)
  854.         end
  855.         priority.sort! { |a,b| a.id <=> b.id }
  856.         result = (priority + result).uniq
  857.       when :name; result.sort! { |a,b| a.name <=> b.name }
  858.       when :class; result.sort! { |a,b| a.class.name <=> b.class.name }
  859.       when :level; result.sort! { |a,b| b.level <=> a.level }
  860.       when :hp; result.sort! { |a,b| b.maxhp <=> a.maxhp }
  861.       when :mp; result.sort! { |a,b| b.maxhp <=> a.maxhp }
  862.       when :atk; result.sort! { |a,b| b.atk <=> a.atk }
  863.       when :def; result.sort! { |a,b| b.def <=> a.def }
  864.       when :spi; result.sort! { |a,b| b.spi <=> a.spi }
  865.       when :res; result.sort! { |a,b| b.res <=> a.res }
  866.       when :dex; result.sort! { |a,b| b.dex <=> a.dex }
  867.       when :agi; result.sort! { |a,b| b.agi <=> a.agi }
  868.       when :hit; result.sort! { |a,b| b.hit <=> a.hit }
  869.       when :eva; result.sort! { |a,b| b.eva <=> a.eva }
  870.       when :cri; result.sort! { |a,b| b.cri <=> a.cri }
  871.       when :dur; result.sort! { |a,b| b.max_dur <=> a.max_dur }
  872.       when :luk; result.sort! { |a,b| b.luk <=> a.luk }
  873.       when :odds; result.sort! { |a,b| b.odds <=> a.odds }
  874.       end
  875.       #---
  876.       $game_party.actors = []
  877.       for actor in result
  878.         next if actor == nil
  879.         next if $game_party.actors.include?(actor.id)
  880.         $game_party.actors.push(actor.id)
  881.       end
  882.       refresh
  883.       @status_window.refresh(@actors_window.item)
  884.     end
  885.   end
  886.  
  887. end # Scene_Party
  888.  
  889. #==============================================================================
  890. # Window_Command (imported from KGC)
  891. #==============================================================================
  892.  
  893. class Window_Command < Window_Selectable
  894. unless method_defined?(:add_command)
  895.   #--------------------------------------------------------------------------
  896.   # add command
  897.   #--------------------------------------------------------------------------
  898.   def add_command(command)
  899.     @commands << command
  900.     @item_max = @commands.size
  901.     item_index = @item_max - 1
  902.     refresh_command
  903.     draw_item(item_index)
  904.     return item_index
  905.   end
  906.   #--------------------------------------------------------------------------
  907.   # refresh command
  908.   #--------------------------------------------------------------------------
  909.   def refresh_command
  910.     buf = self.contents.clone
  911.     self.height = [self.height, row_max * WLH + 32].max
  912.     create_contents
  913.     self.contents.blt(0, 0, buf, buf.rect)
  914.     buf.dispose
  915.   end
  916.   #--------------------------------------------------------------------------
  917.   # insert command
  918.   #--------------------------------------------------------------------------
  919.   def insert_command(index, command)
  920.     @commands.insert(index, command)
  921.     @item_max = @commands.size
  922.     refresh_command
  923.     refresh
  924.   end
  925.   #--------------------------------------------------------------------------
  926.   # remove command
  927.   #--------------------------------------------------------------------------
  928.   def remove_command(command)
  929.     @commands.delete(command)
  930.     @item_max = @commands.size
  931.     refresh
  932.   end
  933. end
  934. end
  935.  
  936. #===============================================================================
  937. # Window_Command_Centered
  938. #===============================================================================
  939.  
  940. class Window_Command_Centered < Window_Command
  941.  
  942.   #--------------------------------------------------------------------------
  943.   # draw_item
  944.   #--------------------------------------------------------------------------
  945.   def draw_item(index, enabled = true)
  946.     rect = item_rect(index)
  947.     rect.x += 4
  948.     rect.width -= 8
  949.     self.contents.clear_rect(rect)
  950.     self.contents.font.color = normal_color
  951.     self.contents.font.color.alpha = enabled ? 255 : 128
  952.     self.contents.draw_text(rect, @commands[index], 1)
  953.   end
  954.  
  955. end # Window_Command_Centered
  956.  
  957. #===============================================================================
  958. # Window_SaveFile
  959. #===============================================================================
  960.  
  961. class Window_SaveFile < Window_Base
  962.  
  963.   #--------------------------------------------------------------------------
  964.   # alias method: draw_playtime
  965.   #--------------------------------------------------------------------------
  966.   alias draw_playtime_pss draw_playtime unless $@
  967.   def draw_playtime(x, y, width, align)
  968.     draw_playtime_pss(x, 0, width, align)
  969.   end
  970.  
  971. end # Window_SaveFile
  972.  
  973. #==============================================================================
  974. # Window_MenuStatus
  975. #==============================================================================
  976.  
  977. class Window_MenuStatus < Window_Selectable
  978.  
  979.   #--------------------------------------------------------------------------
  980.   # overwrite method: refresh
  981.   #--------------------------------------------------------------------------
  982.   def refresh
  983.     @item_max = $game_party.members.size
  984.     create_contents
  985.     colour_non_battler_background
  986.     for i in 0..$game_party.members.size
  987.       draw_item(i)
  988.     end
  989.   end
  990.  
  991.   #--------------------------------------------------------------------------
  992.   # overwrite method: create_contents
  993.   #--------------------------------------------------------------------------
  994.   def create_contents
  995.     self.contents.dispose
  996.     self.contents = Bitmap.new(width - 32, [height - 32, row_max * 96].max)
  997.     self.contents.font.color = normal_color
  998.   end
  999.  
  1000.   #--------------------------------------------------------------------------
  1001.   # draw_item
  1002.   #--------------------------------------------------------------------------
  1003.   def draw_item(index)
  1004.     actor = $game_party.members[index]
  1005.     return if actor == nil
  1006.     draw_actor_face(actor, 2, index * 96 + 2, 92)
  1007.     x = 104
  1008.     y = index * 96
  1009.     draw_actor_name(actor, x, y)
  1010.     draw_actor_class(actor, x + 120, y)
  1011.     draw_actor_level(actor, x, y + WLH * 1)
  1012.     draw_actor_state(actor, x, y + WLH * 2)
  1013.     draw_stun_indicator(x, y + WLH * 3, actor) if $imported["ClassStatDUR"]
  1014.     draw_actor_hp(actor, x + 120, y + WLH * 1, 120)
  1015.     draw_actor_mp(actor, x + 120, y + WLH * 2, 120)
  1016.     draw_menu_exp(actor, x + 120, y + WLH * 3, 120)
  1017.   end
  1018.  
  1019.   #--------------------------------------------------------------------------
  1020.   # new method: draw_menu_exp
  1021.   #--------------------------------------------------------------------------
  1022.   def draw_menu_exp(actor, x, y, size = 120)
  1023.     if actor.next_exp != 0
  1024.       gw = size * actor.now_exp
  1025.       gw /= actor.next_exp
  1026.     else
  1027.       gw = size
  1028.     end
  1029.     gc1 = text_color(YEZ::PARTY::EXP_GAUGE_1)
  1030.     gc2 = text_color(YEZ::PARTY::EXP_GAUGE_2)
  1031.     self.contents.fill_rect(x, y + WLH - 8, size, 6, gauge_back_color)
  1032.     self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
  1033.     self.contents.font.color = system_color
  1034.     self.contents.draw_text(x, y, 40, WLH, YEZ::PARTY::EXP_TEXT)
  1035.     self.contents.font.color = normal_color
  1036.     if actor.next_exp != 0
  1037.       expercent = actor.now_exp * 100.0
  1038.       expercent /= actor.next_exp
  1039.     else
  1040.       expercent = 100.0
  1041.     end
  1042.     expercent = 100.0 if expercent > 100.0
  1043.     text = sprintf(YEZ::PARTY::PERCENT_EXP, expercent)
  1044.     self.contents.draw_text(x, y, size, WLH, text, 2)
  1045.   end
  1046.  
  1047.   #--------------------------------------------------------------------------
  1048.   # new method: colour_non_battler_background
  1049.   #--------------------------------------------------------------------------
  1050.   def colour_non_battler_background
  1051.     color = Color.new(0, 0, 0, YEZ::PARTY::BACK_OPACITY)
  1052.     dy = $game_party.battle_members.size * 96
  1053.     dh = $game_party.reserve_members.size * 96
  1054.     self.contents.fill_rect(0, dy, self.width - 32, dh, color) if dh > 0
  1055.   end
  1056.  
  1057.   #--------------------------------------------------------------------------
  1058.   # overwrite method: top_row
  1059.   #--------------------------------------------------------------------------
  1060.   def top_row; return self.oy / 96; end
  1061.  
  1062.   #--------------------------------------------------------------------------
  1063.   # overwrite method: top_row=
  1064.   #--------------------------------------------------------------------------
  1065.   def top_row=(row); super(row); self.oy = self.oy / WLH * 96; end
  1066.  
  1067.   #--------------------------------------------------------------------------
  1068.   # overwrite method: page_row_max
  1069.   #--------------------------------------------------------------------------
  1070.   def page_row_max; return (self.height - 32) / 96; end
  1071.    
  1072.   #--------------------------------------------------------------------------
  1073.   # overwrite method: item_rect
  1074.   #--------------------------------------------------------------------------
  1075.   def item_rect(index)
  1076.     rect = super(index)
  1077.     rect.height = 96
  1078.     rect.y = index / @column_max * 96
  1079.     return rect
  1080.   end
  1081.  
  1082.   #--------------------------------------------------------------------------
  1083.   # overwrite method: update_cursor
  1084.   #--------------------------------------------------------------------------
  1085.   def update_cursor
  1086.     if @index < 0
  1087.       self.cursor_rect.empty
  1088.     elsif @index < @item_max
  1089.       super
  1090.     elsif @index >= 100
  1091.       self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
  1092.     else
  1093.       self.cursor_rect.set(0, 0, contents.width, @item_max * 96)
  1094.     end
  1095.   end
  1096.  
  1097. end # Window_MenuStatus
  1098.  
  1099. #===============================================================================
  1100. # Window_PartyBattlers
  1101. #===============================================================================
  1102.  
  1103. class Window_PartyBattlers < Window_Selectable
  1104.  
  1105.   #--------------------------------------------------------------------------
  1106.   # public instance variables
  1107.   #--------------------------------------------------------------------------
  1108.   attr_accessor :selected_index
  1109.  
  1110.   #--------------------------------------------------------------------------
  1111.   # initialize
  1112.   #--------------------------------------------------------------------------
  1113.   def initialize
  1114.     super(0, 0, 416, 128)
  1115.     @column_max = 4
  1116.     @spacing = 0
  1117.     refresh
  1118.     self.index = 0
  1119.     self.active = true
  1120.   end
  1121.  
  1122.   #--------------------------------------------------------------------------
  1123.   # new method: item
  1124.   #--------------------------------------------------------------------------
  1125.   def item; return @data[self.index]; end
  1126.    
  1127.   #--------------------------------------------------------------------------
  1128.   # new method: selected_item
  1129.   #--------------------------------------------------------------------------
  1130.   def selected_item; return @data[@selected_index]; end
  1131.  
  1132.   #--------------------------------------------------------------------------
  1133.   # overwrite method: create_contents
  1134.   #--------------------------------------------------------------------------
  1135.   def create_contents
  1136.     self.contents.dispose
  1137.     self.contents = Bitmap.new(width - 32, [height - 32, row_max * 96].max)
  1138.   end
  1139.  
  1140.   #--------------------------------------------------------------------------
  1141.   # refresh
  1142.   #--------------------------------------------------------------------------
  1143.   def refresh
  1144.     $game_party.battle_members if $game_party.battlers == nil
  1145.     @data = []
  1146.     for id in $game_party.battlers; @data.push(id); end
  1147.     @item_max = @data.size
  1148.     create_contents
  1149.     for i in 0..(@item_max-1); draw_item(i); end
  1150.   end
  1151.  
  1152.   #--------------------------------------------------------------------------
  1153.   # draw_item
  1154.   #--------------------------------------------------------------------------
  1155.   def draw_item(index)
  1156.     actor = $game_actors[@data[index]]
  1157.     rect = item_rect(index)
  1158.     self.contents.clear_rect(rect)
  1159.     self.contents.font.color = normal_color
  1160.     if actor == nil
  1161.       color = Color.new(0, 0, 0, YEZ::PARTY::BACK_OPACITY)
  1162.       self.contents.fill_rect(rect.x+2, rect.y+2, rect.width-4, rect.height-4, color)
  1163.       if @selected_index != nil and @selected_index == index
  1164.         self.contents.font.color = text_color(YEZ::PARTY::ACTIVE_COLOUR)
  1165.       else
  1166.         self.contents.font.color = system_color
  1167.       end
  1168.       text = YEZ::PARTY::VOCAB[:empty]
  1169.       self.contents.draw_text(rect.x, WLH*3/2, rect.width, WLH, text, 1)
  1170.       return
  1171.     end
  1172.     draw_actor_face(actor, rect.x+2, rect.y+2, 92)
  1173.     draw_actor_name(actor, rect.x, rect.y)
  1174.     if $game_party.fixed_members.include?(actor)
  1175.       draw_icon(YEZ::PARTY::LOCKED_ICON, rect.x, rect.y + WLH*3)
  1176.     end
  1177.   end
  1178.  
  1179.   #--------------------------------------------------------------------------
  1180.   # draw_actor_face
  1181.   #--------------------------------------------------------------------------
  1182.   def draw_actor_face(actor, x, y, size = 96)
  1183.     opacity = YEZ::PARTY::FACE_OPACITY
  1184.     face_name = actor.face_name
  1185.     face_index = actor.face_index
  1186.     bitmap = Cache.face(face_name)
  1187.     rect = Rect.new(0, 0, 0, 0)
  1188.     rect.x = face_index % 4 * 96 + (96 - size) / 2
  1189.     rect.y = face_index / 4 * 96 + (96 - size) / 2
  1190.     rect.width = size
  1191.     rect.height = size
  1192.     self.contents.blt(x, y, bitmap, rect, opacity)
  1193.     bitmap.dispose
  1194.   end
  1195.  
  1196.   #--------------------------------------------------------------------------
  1197.   # draw_actor_name
  1198.   #--------------------------------------------------------------------------
  1199.   def draw_actor_name(actor, dx, dy)
  1200.     dx += 4; dw = 88
  1201.     if @selected_index != nil and @selected_index == actor.index
  1202.       self.contents.font.color = text_color(YEZ::PARTY::ACTIVE_COLOUR)
  1203.     else
  1204.       self.contents.font.color = hp_color(actor)
  1205.     end
  1206.     self.contents.draw_text(dx, dy, dw, WLH, actor.name, 0)
  1207.   end
  1208.  
  1209.   #--------------------------------------------------------------------------
  1210.   # overwrite method: top_row
  1211.   #--------------------------------------------------------------------------
  1212.   def top_row; return self.oy / 96; end
  1213.  
  1214.   #--------------------------------------------------------------------------
  1215.   # overwrite method: top_row=
  1216.   #--------------------------------------------------------------------------
  1217.   def top_row=(row); super(row); self.oy = self.oy / WLH * 96; end
  1218.  
  1219.   #--------------------------------------------------------------------------
  1220.   # overwrite method: page_row_max
  1221.   #--------------------------------------------------------------------------
  1222.   def page_row_max; return (self.height - 32) / 96; end
  1223.    
  1224.   #--------------------------------------------------------------------------
  1225.   # overwrite method: item_rect
  1226.   #--------------------------------------------------------------------------
  1227.   def item_rect(index)
  1228.     rect = Rect.new(0, 0, 96, 96)
  1229.     rect.x = index % @column_max * (rect.width + @spacing)
  1230.     rect.y = index / @column_max * 96
  1231.     return rect
  1232.   end
  1233.  
  1234.   #--------------------------------------------------------------------------
  1235.   # overwrite method: update_cursor
  1236.   #--------------------------------------------------------------------------
  1237.   def update_cursor
  1238.     if @index < 0
  1239.       self.cursor_rect.empty
  1240.     elsif @index < @item_max
  1241.       super
  1242.     elsif @index >= 100
  1243.       self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
  1244.     else
  1245.       self.cursor_rect.set(0, 0, contents.width, @item_max * 96)
  1246.     end
  1247.   end
  1248.  
  1249. end # Window_PartyBattlers
  1250.  
  1251. #===============================================================================
  1252. # Window_PartyActors
  1253. #===============================================================================
  1254.  
  1255. class Window_PartyActors < Window_Selectable
  1256.  
  1257.   #--------------------------------------------------------------------------
  1258.   # public instance variables
  1259.   #--------------------------------------------------------------------------
  1260.   attr_accessor :selected_index
  1261.  
  1262.   #--------------------------------------------------------------------------
  1263.   # initialize
  1264.   #--------------------------------------------------------------------------
  1265.   def initialize
  1266.     super(0, 128, 160, 288)
  1267.     self.index = -1
  1268.     refresh
  1269.   end
  1270.  
  1271.   #--------------------------------------------------------------------------
  1272.   # new method: item
  1273.   #--------------------------------------------------------------------------
  1274.   def item; return @data[self.index]; end
  1275.    
  1276.   #--------------------------------------------------------------------------
  1277.   # new method: selected_item
  1278.   #--------------------------------------------------------------------------
  1279.   def selected_item; return @data[@selected_index]; end
  1280.  
  1281.   #--------------------------------------------------------------------------
  1282.   # refresh
  1283.   #--------------------------------------------------------------------------
  1284.   def refresh
  1285.     @data = []
  1286.     for actor in $game_party.all_members; @data.push(actor.id); end
  1287.     @data = @data + [0]
  1288.     @item_max = @data.size
  1289.     create_contents
  1290.     for i in 0..(@item_max-1); draw_item(i); end
  1291.   end
  1292.  
  1293.   #--------------------------------------------------------------------------
  1294.   # draw_item
  1295.   #--------------------------------------------------------------------------
  1296.   def draw_item(index)
  1297.     rect = item_rect(index)
  1298.     actor = $game_actors[@data[index]]
  1299.     self.contents.clear_rect(rect)
  1300.     self.contents.font.color = normal_color
  1301.     if actor == nil
  1302.       draw_icon(YEZ::PARTY::CLEAR_ICON, rect.x+6, rect.y)
  1303.       rect.x += 32; rect.width -= 34
  1304.       text = YEZ::PARTY::VOCAB[:clear]
  1305.       self.contents.draw_text(rect.x, rect.y, rect.width, WLH, text)
  1306.       return
  1307.     end
  1308.     offset = YEZ::PARTY::SPRITE_OFFSET
  1309.     draw_actor_graphic(actor, rect.x + 16, rect.y + rect.height + offset)
  1310.     rect.x += 32
  1311.     rect.width -= 34
  1312.     self.contents.font.color = hp_color(actor)
  1313.     enabled = !$game_party.battle_members.include?(actor)
  1314.     self.contents.font.color.alpha = enabled ? 255 : 128
  1315.     if @selected_index != nil and @selected_index == index
  1316.       self.contents.font.color = text_color(YEZ::PARTY::ACTIVE_COLOUR)
  1317.     end
  1318.     self.contents.draw_text(rect.x, rect.y, rect.width, WLH, actor.name)
  1319.   end
  1320.  
  1321. end # Window_PartyActors
  1322.  
  1323. #===============================================================================
  1324. # Window_PartyHelp
  1325. #===============================================================================
  1326.  
  1327. class Window_PartyHelp < Window_Base
  1328.  
  1329.   #--------------------------------------------------------------------------
  1330.   # public instance variables
  1331.   #--------------------------------------------------------------------------
  1332.   attr_accessor :type
  1333.  
  1334.   #--------------------------------------------------------------------------
  1335.   # initialize
  1336.   #--------------------------------------------------------------------------
  1337.   def initialize
  1338.     super(416, 0, 128, 128)
  1339.     refresh
  1340.   end
  1341.  
  1342.   #--------------------------------------------------------------------------
  1343.   # refresh
  1344.   #--------------------------------------------------------------------------
  1345.   def refresh(type = 1)
  1346.     self.contents.clear
  1347.     @type = type
  1348.     vocab = YEZ::PARTY::VOCAB
  1349.     keys = YEZ::PARTY::KEYS
  1350.     buttons = YEZ::ICONS[:buttons] if $imported["Icons"]
  1351.     dx = 4; dw = 120
  1352.     if @type == 1
  1353.       text1 = vocab[:c_battler]
  1354.       text2 = vocab[:b_battler]
  1355.       text3 = vocab[:a_battler]
  1356.       text4 = vocab[:x_battler]
  1357.       if $imported["Icons"]
  1358.         draw_icon(buttons[:c], 0, WLH*0)
  1359.         draw_icon(buttons[:b], 0, WLH*1)
  1360.         draw_icon(buttons[:a], 0, WLH*2)
  1361.         draw_icon(buttons[:x], 0, WLH*3)
  1362.         dx = 24; dw = 100
  1363.       else
  1364.         text1 = sprintf(keys[:c], text1)
  1365.         text2 = sprintf(keys[:b], text2)
  1366.         text3 = sprintf(keys[:a], text3)
  1367.         text4 = sprintf(keys[:x], text4)
  1368.       end
  1369.     elsif @type == 2
  1370.       text1 = vocab[:c_actors]
  1371.       text2 = vocab[:b_actors]
  1372.       text3 = vocab[:a_actors]
  1373.       text4 = vocab[:x_actors]
  1374.       if $imported["Icons"]
  1375.         draw_icon(buttons[:c], 0, WLH*0)
  1376.         draw_icon(buttons[:b], 0, WLH*1)
  1377.         draw_icon(buttons[:a], 0, WLH*2)
  1378.         draw_icon(buttons[:x], 0, WLH*3)
  1379.         dx = 24; dw = 100
  1380.       else
  1381.         text1 = sprintf(keys[:c], text1)
  1382.         text2 = sprintf(keys[:b], text2)
  1383.         text3 = sprintf(keys[:a], text3)
  1384.         text4 = sprintf(keys[:x], text4)
  1385.       end
  1386.     end
  1387.     self.contents.draw_text(dx, WLH*0, dw, WLH, text1)
  1388.     self.contents.draw_text(dx, WLH*1, dw, WLH, text2)
  1389.     self.contents.draw_text(dx, WLH*2, dw, WLH, text3)
  1390.     self.contents.draw_text(dx, WLH*3, dw, WLH, text4)
  1391.   end
  1392.  
  1393. end # Window_PartyHelp
  1394.  
  1395. #===============================================================================
  1396. # Window_PartyStatus
  1397. #===============================================================================
  1398.  
  1399. class Window_PartyStatus < Window_Base
  1400.  
  1401.   #--------------------------------------------------------------------------
  1402.   # initialize
  1403.   #--------------------------------------------------------------------------
  1404.   def initialize
  1405.     super(160, 128, 384, 288)
  1406.   end
  1407.  
  1408.   #--------------------------------------------------------------------------
  1409.   # item
  1410.   #--------------------------------------------------------------------------
  1411.   def item; return @actor; end
  1412.  
  1413.   #--------------------------------------------------------------------------
  1414.   # refresh
  1415.   #--------------------------------------------------------------------------
  1416.   def refresh(actor_id)
  1417.     self.contents.clear
  1418.     if actor_id <= 0
  1419.       color = Color.new(0, 0, 0, YEZ::PARTY::BACK_OPACITY)
  1420.       self.contents.fill_rect(0, 0, self.width, self.height, color)
  1421.       self.contents.font.color = system_color
  1422.       text = YEZ::PARTY::VOCAB[:nodata]
  1423.       self.contents.draw_text(0, self.height/2-24, self.width-40, WLH, text, 1)
  1424.       return
  1425.     end
  1426.     actor = $game_actors[actor_id]
  1427.     @actor = actor
  1428.     draw_actor_face(actor, 0, 0, size = 96)
  1429.     x = 104
  1430.     y = 0
  1431.     draw_actor_name(actor, x, y)
  1432.     draw_actor_class(actor, x + 120, y)
  1433.     draw_actor_level(actor, x, y + WLH * 1)
  1434.     draw_actor_state(actor, x, y + WLH * 2)
  1435.     draw_stun_indicator(x, y + WLH * 3, actor) if $imported["ClassStatDUR"]
  1436.     draw_actor_hp(actor, x + 120, y + WLH * 1, 120)
  1437.     draw_actor_mp(actor, x + 120, y + WLH * 2, 120)
  1438.     draw_actor_exp(actor, x + 120, y + WLH * 3, 120)
  1439.     draw_actor_stats(actor, 0, y + WLH * 9/2)
  1440.   end
  1441.  
  1442.   #--------------------------------------------------------------------------
  1443.   # draw_actor_exp
  1444.   #--------------------------------------------------------------------------
  1445.   def draw_actor_exp(actor, x, y, size = 120)
  1446.     if actor.next_exp != 0
  1447.       gw = size * actor.now_exp
  1448.       gw /= actor.next_exp
  1449.     else
  1450.       gw = size
  1451.     end
  1452.     gc1 = text_color(YEZ::PARTY::EXP_GAUGE_1)
  1453.     gc2 = text_color(YEZ::PARTY::EXP_GAUGE_2)
  1454.     self.contents.fill_rect(x, y + WLH - 8, size, 6, gauge_back_color)
  1455.     self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
  1456.     self.contents.font.color = system_color
  1457.     self.contents.draw_text(x, y, 40, WLH, YEZ::PARTY::EXP_TEXT)
  1458.     self.contents.font.color = normal_color
  1459.     if actor.next_exp != 0
  1460.       expercent = actor.now_exp * 100.0
  1461.       expercent /= actor.next_exp
  1462.     else
  1463.       expercent = 100.0
  1464.     end
  1465.     expercent = 100.0 if expercent > 100.0
  1466.     text = sprintf(YEZ::PARTY::PERCENT_EXP, expercent)
  1467.     self.contents.draw_text(x, y, size, WLH, text, 2)
  1468.   end
  1469.  
  1470.   #--------------------------------------------------------------------------
  1471.   # draw_actor_stats
  1472.   #--------------------------------------------------------------------------
  1473.   def draw_actor_stats(actor, dx, dy)
  1474.     fx = dx; fy = dy
  1475.     cw = calc_width
  1476.     for stat in YEZ::PARTY::SHOWN_STATS
  1477.       icon = 0; up_icon = YEZ::PARTY::UP_ICON; dn_icon = YEZ::PARTY::DN_ICON
  1478.       case stat
  1479.       when :atk
  1480.         up_icon = YEZ::ICONS[:upatk] if $imported["Icons"]
  1481.         dp_icon = YEZ::ICONS[:dnatk] if $imported["Icons"]
  1482.         icon = $imported["Icons"] ? YEZ::ICONS[:atk] : 0
  1483.         icon = up_icon if actor.atk > actor.base_atk
  1484.         icon = dn_icon if actor.atk < actor.base_atk
  1485.         name = Vocab.atk
  1486.         value = actor.atk
  1487.       when :def
  1488.         up_icon = YEZ::ICONS[:updef] if $imported["Icons"]
  1489.         dp_icon = YEZ::ICONS[:dndef] if $imported["Icons"]
  1490.         icon = $imported["Icons"] ? YEZ::ICONS[:def] : 0
  1491.         icon = up_icon if actor.def > actor.base_def
  1492.         icon = dn_icon if actor.def < actor.base_def
  1493.         name = Vocab.def
  1494.         value = actor.def
  1495.       when :spi
  1496.         up_icon = YEZ::ICONS[:upspi] if $imported["Icons"]
  1497.         dp_icon = YEZ::ICONS[:dnspi] if $imported["Icons"]
  1498.         icon = $imported["Icons"] ? YEZ::ICONS[:spi] : 0
  1499.         icon = up_icon if actor.spi > actor.base_spi
  1500.         icon = dn_icon if actor.spi < actor.base_spi
  1501.         name = Vocab.spi
  1502.         value = actor.spi
  1503.       when :agi
  1504.         up_icon = YEZ::ICONS[:upagi] if $imported["Icons"]
  1505.         dp_icon = YEZ::ICONS[:dnagi] if $imported["Icons"]
  1506.         icon = $imported["Icons"] ? YEZ::ICONS[:agi] : 0
  1507.         icon = up_icon if actor.agi > actor.base_agi
  1508.         icon = dn_icon if actor.agi < actor.base_agi
  1509.         name = Vocab.agi
  1510.         value = actor.agi
  1511.       when :hit
  1512.         icon = $imported["Icons"] ? YEZ::ICONS[:hit] : 0
  1513.         value = sprintf("%d%%",[[actor.hit, 0].max, 99].min)
  1514.         name = Vocab.hit
  1515.       when :eva
  1516.         icon = $imported["Icons"] ? YEZ::ICONS[:eva] : 0
  1517.         value = sprintf("%d%%",[[actor.eva, 0].max, 99].min)
  1518.         name = Vocab.eva
  1519.       when :cri
  1520.         icon = $imported["Icons"] ? YEZ::ICONS[:cri] : 0
  1521.         value = sprintf("%d%%",[[actor.cri, 0].max, 99].min)
  1522.         name = Vocab.cri
  1523.       when :odds
  1524.         icon = $imported["Icons"] ? YEZ::ICONS[:odds] : 0
  1525.         value = actor.odds
  1526.         name = Vocab.odds
  1527.       when :res
  1528.         next unless $imported["BattlerStatRES"]
  1529.         up_icon = YEZ::ICONS[:upres] if $imported["Icons"]
  1530.         dp_icon = YEZ::ICONS[:dnres] if $imported["Icons"]
  1531.         icon = $imported["Icons"] ? YEZ::ICONS[:res] : 0
  1532.         icon = up_icon if actor.res > actor.base_res
  1533.         icon = dn_icon if actor.res < actor.base_res
  1534.         value = actor.res
  1535.         name = Vocab.res
  1536.       when :dex
  1537.         next unless $imported["BattlerStatDEX"]
  1538.         up_icon = YEZ::ICONS[:updex] if $imported["Icons"]
  1539.         dp_icon = YEZ::ICONS[:dndex] if $imported["Icons"]
  1540.         icon = $imported["Icons"] ? YEZ::ICONS[:dex] : 0
  1541.         icon = up_icon if actor.dex > actor.base_dex
  1542.         icon = dn_icon if actor.dex < actor.base_dex
  1543.         value = actor.dex
  1544.         name = Vocab.dex
  1545.       when :luk
  1546.         next unless $imported["ClassStatLUK"]
  1547.         up_icon = YEZ::ICONS[:upluk] if $imported["Icons"]
  1548.         dp_icon = YEZ::ICONS[:dnluk] if $imported["Icons"]
  1549.         icon = $imported["Icons"] ? YEZ::ICONS[:luk] : 0
  1550.         icon = up_icon if actor.luk > actor.base_luk
  1551.         icon = dn_icon if actor.luk < actor.base_luk
  1552.         value = actor.luk
  1553.         name = Vocab.luk
  1554.       when :dur
  1555.         next unless $imported["ClassStatDUR"]
  1556.         icon = $imported["Icons"] ? YEZ::ICONS[:dur] : 0
  1557.         value = actor.max_dur
  1558.         name = Vocab.dur
  1559.       else; next
  1560.       end
  1561.       draw_icon(icon, dx, dy)
  1562.       self.contents.font.color = system_color
  1563.       self.contents.draw_text(dx+24, dy, 60, WLH, name, 0)
  1564.       self.contents.font.color = normal_color
  1565.       self.contents.draw_text(dx+84, dy, cw, WLH, value, 2)
  1566.       dx = dx == fx ? dx + (self.width-32)/2 : fx
  1567.       dy = dx == fx ? dy + WLH : dy
  1568.       break if dy + 24 > self.height - 32
  1569.     end
  1570.   end
  1571.  
  1572.   #--------------------------------------------------------------------------
  1573.   # calc_width
  1574.   #--------------------------------------------------------------------------
  1575.   def calc_width
  1576.     return @calc_width if @calc_width != nil
  1577.     n = 0
  1578.     for actor in $game_party.members
  1579.       for item in YEZ::PARTY::SHOWN_STATS
  1580.         text = ""
  1581.         case item
  1582.         when :atk;  text = actor.atk
  1583.         when :def;  text = actor.def
  1584.         when :spi;  text = actor.spi
  1585.         when :agi;  text = actor.agi
  1586.         when :res;  text = actor.res if $imported["BattlerStatRES"]
  1587.         when :dex;  text = actor.dex if $imported["BattlerStatDEX"]
  1588.         when :hit;  text = sprintf("%d%%", [[actor.hit, 0].max, 99].min)
  1589.         when :eva;  text = sprintf("%d%%", [[actor.eva, 0].max, 99].min)
  1590.         when :cri;  text = sprintf("%d%%", [[actor.cri, 0].max, 99].min)
  1591.         when :dur;  text = actor.dur if $imported["ClassStatDUR"]
  1592.         when :luk;  text = actor.luk if $imported["BattlerStatLUK"]
  1593.         when :odds; text = actor.odds
  1594.         else; next
  1595.         end
  1596.         n = [n, contents.text_size(text).width].max
  1597.       end
  1598.     end
  1599.     @calc_width = n
  1600.     return n
  1601.   end
  1602.  
  1603. end # Window_PartyStatus
  1604.  
  1605. #===============================================================================
  1606. # Window_PartyAssort
  1607. #===============================================================================
  1608.  
  1609. class Window_PartyAssort < Window_Selectable
  1610.  
  1611.   #--------------------------------------------------------------------------
  1612.   # initialize
  1613.   #--------------------------------------------------------------------------
  1614.   def initialize
  1615.     super(160, 164, 384, 264)
  1616.     @column_max = 2
  1617.     @spacing = 0
  1618.     self.opacity = 0
  1619.     self.index = 0
  1620.     self.visible = false
  1621.     self.active = false
  1622.     refresh
  1623.   end
  1624.  
  1625.   #--------------------------------------------------------------------------
  1626.   # command
  1627.   #--------------------------------------------------------------------------
  1628.   def command; return @data[self.index]; end
  1629.  
  1630.   #--------------------------------------------------------------------------
  1631.   # refresh
  1632.   #--------------------------------------------------------------------------
  1633.   def refresh
  1634.     @data = []; @vocab = []
  1635.     for command in YEZ::PARTY::ASSORT_COMMANDS
  1636.       case command
  1637.       when :story, :name, :class, :level; @vocab.push(YEZ::PARTY::VOCAB[command])
  1638.       when :hp; @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.hp))
  1639.       when :mp; @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.mp))
  1640.       when :atk; @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.atk))
  1641.       when :def; @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.def))
  1642.       when :spi; @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.spi))
  1643.       when :agi; @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.agi))
  1644.       when :hit; @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.hit))
  1645.       when :eva; @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.eva))
  1646.       when :cri; @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.cri))
  1647.       when :odds; @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.odds))
  1648.       when :res
  1649.         next unless $imported["BattlerStatRES"]
  1650.         @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.res))
  1651.       when :dex
  1652.         next unless $imported["BattlerStatDEX"]
  1653.         @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.dex))
  1654.       when :dur
  1655.         next unless $imported["ClassStatDUR"]
  1656.         @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.dur))
  1657.       when :luk
  1658.         next unless $imported["ClassStatLUK"]
  1659.         @vocab.push(sprintf(YEZ::PARTY::VOCAB[:stat], Vocab.luk))
  1660.       else; next
  1661.       end
  1662.       @data.push(command)
  1663.     end
  1664.     @item_max = @data.size
  1665.     create_contents
  1666.     for i in 0..(@item_max-1); draw_item(i); end
  1667.   end
  1668.    
  1669.   #--------------------------------------------------------------------------
  1670.   # draw_item
  1671.   #--------------------------------------------------------------------------
  1672.   def draw_item(index)
  1673.     rect = item_rect(index)
  1674.     self.contents.clear_rect(rect)
  1675.     text = @vocab[index]
  1676.     return if text == nil
  1677.     icon = YEZ::PARTY::CLEAR_ICON
  1678.     if $imported["Icons"] and YEZ::ICONS.include?(@data[index])
  1679.       icon = YEZ::ICONS[@data[index]]
  1680.     end
  1681.     draw_icon(icon, rect.x, rect.y)
  1682.     rect.x += 24
  1683.     rect.width -= 28
  1684.     self.contents.draw_text(rect, text, 0)
  1685.   end
  1686.  
  1687. end # Window_PartyAssort
  1688.  
  1689. #===============================================================================
  1690. #
  1691. # END OF FILE
  1692. #
  1693. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement