pigu_6

Yanfly|Party System

Nov 24th, 2012
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.10 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Party System v1.04
  4. # -- Last Updated: 2011.12.26
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-PartySystem"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2011.12.26 - Compatibility Update: New Game+
  17. # 2011.12.17 - Updated Spriteset_Battle to have updated sprite counts.
  18. # 2011.12.13 - Updated to provide better visual display when more than 5 pieces
  19. # of equipment are equipped on an actor at a time.
  20. # 2011.12.05 - Added functionality to display faces in the Party Select Window.
  21. # - Fixed bug that doesn't refresh the caterpillar when new members
  22. # join the party.
  23. # 2011.12.04 - Started Script and Finished.
  24. #
  25. #==============================================================================
  26. # ▼ Introduction
  27. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  28. # RPG Maker VX Ace comes with a very nice party system. However, changing the
  29. # maximum number of members isn't possible without the aid of a script. This
  30. # script enables you the ability to change the maximum number of party members,
  31. # change EXP rates, and/or open up a separate party menu (if desired). In
  32. # addition to that, you can lock the position of actors within a party and
  33. # require other actors to be in the active party before continuing.
  34. #
  35. #==============================================================================
  36. # ▼ Instructions
  37. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  38. # To install this script, open up your script editor and copy/paste this script
  39. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  40. #
  41. # -----------------------------------------------------------------------------
  42. # Script Calls - These commands are used with script calls.
  43. # -----------------------------------------------------------------------------
  44. # *IMPORTANT* These script calls require the new party menu to be enabled to
  45. # use them. Otherwise, nothing will happen.
  46. #
  47. # lock_actor(x)
  48. # unlock_actor(x)
  49. # This will lock actor x in its current position in the party if the actor is
  50. # in the current party. The actor is unable to switch position and must remain
  51. # in that position until the lock is removed. Use the unlock script call to
  52. # remove the locked status. This script requires the actor to have joined and
  53. # in the current party before the script call will work.
  54. #
  55. # require_actor(x)
  56. # unrequire_actor(x)
  57. # This will cause the party to require actor x in order to continue. If the
  58. # actor isn't in the current party but is in the reserve party, the party menu
  59. # will open up and prompt the player to add the required actor into the party
  60. # before being able to continue. This script call will not function unless the
  61. # specific actor has joined the party, whether it is in the current or reserve.
  62. #
  63. # call_party_menu
  64. # This will open up the party menu. This script call requires for the party
  65. # menu to be enabled to use.
  66. #
  67. #==============================================================================
  68. # ▼ Compatibility
  69. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  70. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  71. # it will run with RPG Maker VX without adjusting.
  72. #
  73. #==============================================================================
  74.  
  75. module YEA
  76. module PARTY
  77.  
  78. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  79. # - General Party Settings -
  80. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  81. # In this section, you can adjust the general party settings for your game
  82. # such as the maximum amount of members and whatnot, the EXP rate for
  83. # party members in the reserve, etc.
  84. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  85. MAX_BATTLE_MEMBERS = 5 # Maximum party members. Default: 4
  86. SPLIT_EXP = false # Splits EXP with more members in the party.
  87. RESERVE_EXP_RATE = 0.50 # Reserve EXP Rate. Default: 1.00
  88.  
  89. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  90. # - Party Menu Settings -
  91. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  92. # This section contains various menu settings for those who wish to use a
  93. # menu separate for the party system. Here, adjust the menu command order,
  94. # icons used, and other settings.
  95. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  96. ENABLE_MENU = true # Enables party menu. Default: false
  97. COMMANDS =[ # The order at which the menu items are shown.
  98. # [:command, "Display"],
  99. [ :change, "Change",],
  100. [ :remove, "Remove",],
  101. [ :revert, "Revert",],
  102. [ :finish, "Finish",],
  103. ] # Do not remove this.
  104. COMMAND_ALIGN = 1 # 0:Left Align, 1:Center Align, 2:Right Align
  105.  
  106. # These settings here are used for the upper right window: the Party Select
  107. # window where the player selects a member to swap out or remove.
  108. PARTY_FONT_SIZE = 20 # Font size used for party member names.
  109. LOCK_FIRST_ACTOR = false # Lock the first actor by default?
  110. LOCKED_ICON = 125 # Icon used for locked members.
  111. REQUIRED_ICON = 126 # Icon used for required members.
  112. EMPTY_TEXT = "-Empty-" # Text used when a member isn't present.
  113. DISPLAY_FACE = false # Display faces instead of sprites?
  114.  
  115. # These settings here are used for the lower left window: the Party List
  116. # window where the player selects a member to replace.
  117. REMOVE_ICON = 185 # Icon used for removing members.
  118. REMOVE_TEXT = "-Remove-" # Text used for remove member command.
  119. ACTOR_Y_BUFFER = 12 # Amount the actor graphic be adjusted by.
  120.  
  121. # These settings here are used for the lower right window: the Party Status
  122. # window where info about a selected actor is shown.
  123. NO_DATA = "- No Data -" # Text used for when no actor is shown.
  124. IN_PARTY_COLOUR = 6 # Text colour used for in party members.
  125. STAT_FONT_SIZE = 20 # Font size used for stats.
  126. EQUIP_TEXT = "Equipment" # Text used to display equipment.
  127.  
  128. end # PARTY
  129. end # YEA
  130.  
  131. #==============================================================================
  132. # ▼ Editting anything past this point may potentially result in causing
  133. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  134. # halitosis so edit at your own risk.
  135. #==============================================================================
  136.  
  137. #==============================================================================
  138. # ■ Icon
  139. #==============================================================================
  140.  
  141. module Icon
  142.  
  143. #--------------------------------------------------------------------------
  144. # self.locked_party
  145. #--------------------------------------------------------------------------
  146. def self.locked_party; return YEA::PARTY::LOCKED_ICON; end
  147.  
  148. #--------------------------------------------------------------------------
  149. # self.required_party
  150. #--------------------------------------------------------------------------
  151. def self.required_party; return YEA::PARTY::REQUIRED_ICON; end
  152.  
  153. #--------------------------------------------------------------------------
  154. # self.remove_party
  155. #--------------------------------------------------------------------------
  156. def self.remove_party; return YEA::PARTY::REMOVE_ICON; end
  157.  
  158. end # Icon
  159.  
  160. #==============================================================================
  161. # ■ Numeric
  162. #==============================================================================
  163.  
  164. class Numeric
  165.  
  166. #--------------------------------------------------------------------------
  167. # new method: group_digits
  168. #--------------------------------------------------------------------------
  169. unless $imported["YEA-CoreEngine"]
  170. def group; return self.to_s; end
  171. end # $imported["YEA-CoreEngine"]
  172.  
  173. end # Numeric
  174.  
  175. #==============================================================================
  176. # ■ Game_Actor
  177. #==============================================================================
  178.  
  179. class Game_Actor < Game_Battler
  180.  
  181. #--------------------------------------------------------------------------
  182. # public instance variables
  183. #--------------------------------------------------------------------------
  184. attr_accessor :locked
  185. attr_accessor :required
  186.  
  187. #--------------------------------------------------------------------------
  188. # alias method: setup
  189. #--------------------------------------------------------------------------
  190. alias game_actor_setup_ps setup
  191. def setup(actor_id)
  192. game_actor_setup_ps(actor_id)
  193. @locked = false
  194. @required = false
  195. end
  196.  
  197. #--------------------------------------------------------------------------
  198. # overwrite method: final_exp_rate
  199. #--------------------------------------------------------------------------
  200. def final_exp_rate
  201. n = exr * (battle_member? ? 1 : reserve_members_exp_rate)
  202. if $game_party.in_battle
  203. n /= [$game_party.battle_members.size, 1].max if YEA::PARTY::SPLIT_EXP
  204. end
  205. return n
  206. end
  207.  
  208. #--------------------------------------------------------------------------
  209. # overwrite method: reserve_members_exp_rate
  210. #--------------------------------------------------------------------------
  211. def reserve_members_exp_rate
  212. $data_system.opt_extra_exp ? YEA::PARTY::RESERVE_EXP_RATE : 0
  213. end
  214.  
  215. end # Game_Actor
  216.  
  217. #==============================================================================
  218. # ■ Game_Party
  219. #==============================================================================
  220.  
  221. class Game_Party < Game_Unit
  222.  
  223. #--------------------------------------------------------------------------
  224. # public instance variables
  225. #--------------------------------------------------------------------------
  226. attr_accessor :battle_members_array
  227.  
  228. #--------------------------------------------------------------------------
  229. # alias method: initialize
  230. #--------------------------------------------------------------------------
  231. alias game_party_initialize_ps initialize
  232. def initialize
  233. game_party_initialize_ps
  234. @battle_members_array = nil
  235. end
  236.  
  237. #--------------------------------------------------------------------------
  238. # overwrite method: max_battle_members
  239. #--------------------------------------------------------------------------
  240. def max_battle_members; return YEA::PARTY::MAX_BATTLE_MEMBERS; end
  241.  
  242. #--------------------------------------------------------------------------
  243. # alias method: setup_starting_members
  244. #--------------------------------------------------------------------------
  245. alias setup_starting_members_ps setup_starting_members
  246. def setup_starting_members
  247. setup_starting_members_ps
  248. initialize_battle_members
  249. return unless YEA::PARTY::LOCK_FIRST_ACTOR
  250. return if members[0].nil?
  251. members[0].locked = true
  252. end
  253.  
  254. #--------------------------------------------------------------------------
  255. # alias method: setup_battle_test_members
  256. #--------------------------------------------------------------------------
  257. alias setup_battle_test_members_ps setup_battle_test_members
  258. def setup_battle_test_members
  259. setup_battle_test_members_ps
  260. return unless YEA::PARTY::LOCK_FIRST_ACTOR
  261. return if members[0].nil?
  262. members[0].locked = true
  263. end
  264.  
  265. #--------------------------------------------------------------------------
  266. # overwrite method: battle_members
  267. #--------------------------------------------------------------------------
  268. def battle_members
  269. initialize_battle_members if @battle_members_array.nil?
  270. array = []
  271. for actor_id in @battle_members_array
  272. break if array.size > max_battle_members
  273. next if actor_id.nil?
  274. next if $game_actors[actor_id].nil?
  275. array.push($game_actors[actor_id])
  276. end
  277. return array
  278. end
  279.  
  280. #--------------------------------------------------------------------------
  281. # new method: initialize_battle_members
  282. #--------------------------------------------------------------------------
  283. def initialize_battle_members
  284. @battle_members_array = []
  285. for i in 0...max_battle_members
  286. @battle_members_array.push(@actors[i]) unless @actors[i].nil?
  287. @battle_members_array.push(0) if @actors[i].nil?
  288. end
  289. end
  290.  
  291. #--------------------------------------------------------------------------
  292. # alias method: add_actor
  293. #--------------------------------------------------------------------------
  294. alias game_party_add_actor_ps add_actor
  295. def add_actor(actor_id)
  296. game_party_add_actor_ps(actor_id)
  297. return if @battle_members_array.include?(actor_id)
  298. return unless @battle_members_array.include?(0)
  299. index = @battle_members_array.index(0)
  300. @battle_members_array[index] = actor_id
  301. $game_player.refresh
  302. $game_map.need_refresh = true
  303. end
  304.  
  305. #--------------------------------------------------------------------------
  306. # alias method: remove_actor
  307. #--------------------------------------------------------------------------
  308. alias game_party_remove_actor_ps remove_actor
  309. def remove_actor(actor_id)
  310. game_party_remove_actor_ps(actor_id)
  311. return unless @battle_members_array.include?(actor_id)
  312. index = @battle_members_array.index(actor_id)
  313. @battle_members_array[index] = 0
  314. $game_player.refresh
  315. $game_map.need_refresh = true
  316. end
  317.  
  318. #--------------------------------------------------------------------------
  319. # new method: rearrange_actors
  320. #--------------------------------------------------------------------------
  321. def rearrange_actors
  322. initialize_battle_members if @battle_members_array.nil?
  323. array = []
  324. for actor_id in @battle_members_array
  325. next if [0, nil].include?(actor_id)
  326. next if $game_actors[actor_id].nil?
  327. array.push(actor_id)
  328. end
  329. for actor_id in @actors
  330. next if array.include?(actor_id)
  331. next if $game_actors[actor_id].nil?
  332. array.push(actor_id)
  333. end
  334. @actors = array
  335. end
  336.  
  337. end # Game_Party
  338.  
  339. #==============================================================================
  340. # ■ Game_Interpreter
  341. #==============================================================================
  342.  
  343. class Game_Interpreter
  344.  
  345. #--------------------------------------------------------------------------
  346. # new method: lock_actor
  347. #--------------------------------------------------------------------------
  348. def lock_actor(actor_id)
  349. return unless YEA::PARTY::ENABLE_MENU
  350. actor = $game_actors[actor_id]
  351. return unless $game_party.battle_members.include?(actor.id)
  352. actor.locked = true
  353. end
  354.  
  355. #--------------------------------------------------------------------------
  356. # new method: unlock_actor
  357. #--------------------------------------------------------------------------
  358. def unlock_actor(actor_id)
  359. return unless YEA::PARTY::ENABLE_MENU
  360. actor = $game_actors[actor_id]
  361. return unless $game_party.battle_members.include?(actor.id)
  362. actor.locked = false
  363. end
  364.  
  365. #--------------------------------------------------------------------------
  366. # new method: require_actor
  367. #--------------------------------------------------------------------------
  368. def require_actor(actor_id)
  369. return unless YEA::PARTY::ENABLE_MENU
  370. return if $game_system.formation_disabled
  371. actor = $game_actors[actor_id]
  372. return unless $game_party.all_members.include?(actor)
  373. actor.required = true
  374. call_party_menu unless $game_party.battle_members.include?(actor)
  375. end
  376.  
  377. #--------------------------------------------------------------------------
  378. # new method: unrequire_actor
  379. #--------------------------------------------------------------------------
  380. def unrequire_actor(actor_id)
  381. return unless YEA::PARTY::ENABLE_MENU
  382. return if $game_system.formation_disabled
  383. actor = $game_actors[actor_id]
  384. return unless $game_party.all_members.include?(actor)
  385. actor.required = false
  386. call_party_menu unless $game_party.battle_members.include?(actor)
  387. end
  388.  
  389. #--------------------------------------------------------------------------
  390. # new method: call_party_menu
  391. #--------------------------------------------------------------------------
  392. def call_party_menu
  393. return unless YEA::PARTY::ENABLE_MENU
  394. return if $game_system.formation_disabled
  395. SceneManager.call(Scene_Party)
  396. end
  397.  
  398. end # Game_Interpreter
  399.  
  400. #==============================================================================
  401. # ■ Spriteset_Battle
  402. #==============================================================================
  403.  
  404. class Spriteset_Battle
  405.  
  406. #--------------------------------------------------------------------------
  407. # overwrite method: create_actors
  408. #--------------------------------------------------------------------------
  409. def create_actors
  410. total = $game_party.max_battle_members
  411. @actor_sprites = Array.new(total) { Sprite_Battler.new(@viewport1) }
  412. end
  413.  
  414. end # Spriteset_Battle
  415.  
  416. #==============================================================================
  417. # ■ Window_PartyMenuCommand
  418. #==============================================================================
  419.  
  420. class Window_PartyMenuCommand < Window_Command
  421.  
  422. #--------------------------------------------------------------------------
  423. # window_width
  424. #--------------------------------------------------------------------------
  425. def window_width; return 160; end
  426.  
  427. #--------------------------------------------------------------------------
  428. # visible_line_number
  429. #--------------------------------------------------------------------------
  430. def visible_line_number; 4; end
  431.  
  432. #--------------------------------------------------------------------------
  433. # alignment
  434. #--------------------------------------------------------------------------
  435. def alignment
  436. return Menu.command_window_align if $imported["YEA-AceMenuEngine"]
  437. return YEA::PARTY::COMMAND_ALIGN
  438. end
  439.  
  440. #--------------------------------------------------------------------------
  441. # scene
  442. #--------------------------------------------------------------------------
  443. def scene; return SceneManager.scene; end
  444.  
  445. #--------------------------------------------------------------------------
  446. # make_command_list
  447. #--------------------------------------------------------------------------
  448. def make_command_list
  449. for command in YEA::PARTY::COMMANDS
  450. case command[0]
  451. when :change, :remove, :revert
  452. add_command(command[1], command[0])
  453. when :finish
  454. add_command(command[1], command[0], enable_cancel?)
  455. else; next
  456. end
  457. end
  458. end
  459.  
  460. #--------------------------------------------------------------------------
  461. # process_cancel
  462. #--------------------------------------------------------------------------
  463. def process_cancel
  464. unless enable_cancel?
  465. Sound.play_buzzer
  466. return
  467. end
  468. super
  469. end
  470.  
  471. #--------------------------------------------------------------------------
  472. # in_party?
  473. #--------------------------------------------------------------------------
  474. def in_party?(actor)
  475. return $game_party.battle_members.include?(actor)
  476. end
  477.  
  478. #--------------------------------------------------------------------------
  479. # enable_cancel?
  480. #--------------------------------------------------------------------------
  481. def enable_cancel?
  482. return false if $game_party.battle_members.size <= 0
  483. for actor in $game_party.all_members
  484. next if in_party?(actor)
  485. return false if actor.required
  486. return false if actor.locked
  487. end
  488. return true
  489. end
  490.  
  491. end # Window_PartyMenuCommand
  492.  
  493. #==============================================================================
  494. # ■ Window_PartySelect
  495. #==============================================================================
  496.  
  497. class Window_PartySelect < Window_Selectable
  498.  
  499. #--------------------------------------------------------------------------
  500. # initialize
  501. #-------------------------------------------------------------------------
  502. def initialize(command_window)
  503. @command_window = command_window
  504. super(160, 0, window_width, fitting_height(visible_line_number))
  505. select(0)
  506. deactivate
  507. refresh
  508. end
  509.  
  510. #--------------------------------------------------------------------------
  511. # col_max
  512. #--------------------------------------------------------------------------
  513. def col_max; return YEA::PARTY::MAX_BATTLE_MEMBERS; end
  514.  
  515. #--------------------------------------------------------------------------
  516. # item_max
  517. #--------------------------------------------------------------------------
  518. def item_max; return YEA::PARTY::MAX_BATTLE_MEMBERS; end
  519.  
  520. #--------------------------------------------------------------------------
  521. # window_width
  522. #--------------------------------------------------------------------------
  523. def window_width; return Graphics.width - 160; end
  524.  
  525. #--------------------------------------------------------------------------
  526. # visible_line_number
  527. #--------------------------------------------------------------------------
  528. def visible_line_number; 4; end
  529.  
  530. #--------------------------------------------------------------------------
  531. # item_rect
  532. #--------------------------------------------------------------------------
  533. def item_rect(index)
  534. rect = Rect.new
  535. rect.width = contents.width / item_max
  536. rect.height = contents.height
  537. rect.x = index * rect.width
  538. rect.y = 0
  539. return rect
  540. end
  541.  
  542. #--------------------------------------------------------------------------
  543. # refresh
  544. #--------------------------------------------------------------------------
  545. def refresh
  546. make_item_list
  547. create_contents
  548. draw_all_items
  549. end
  550.  
  551. #--------------------------------------------------------------------------
  552. # make_item_list
  553. #--------------------------------------------------------------------------
  554. def make_item_list
  555. @data = $game_party.battle_members_array.clone
  556. end
  557.  
  558. #--------------------------------------------------------------------------
  559. # draw_item
  560. #--------------------------------------------------------------------------
  561. def draw_item(index)
  562. actor = $game_actors[@data[index]]
  563. rect = item_rect(index)
  564. if actor.nil?
  565. draw_empty(rect.clone)
  566. return
  567. end
  568. dx = rect.width / 2
  569. dy = rect.height - 16
  570. draw_actor_face(actor, rect.x, rect.y) if display_face?
  571. draw_actor_graphic(actor, rect.x + dx, rect.y + dy) unless display_face?
  572. draw_actor_name(actor, rect)
  573. draw_locked_icon(actor, rect)
  574. draw_required_icon(actor, rect)
  575. end
  576.  
  577. #--------------------------------------------------------------------------
  578. # display_face?
  579. #--------------------------------------------------------------------------
  580. def display_face?
  581. return YEA::PARTY::DISPLAY_FACE
  582. end
  583.  
  584. #--------------------------------------------------------------------------
  585. # draw_empty
  586. #--------------------------------------------------------------------------
  587. def draw_empty(rect)
  588. colour = Color.new(0, 0, 0, translucent_alpha/2)
  589. rect.x += 2
  590. rect.y += 2
  591. rect.width -= 4
  592. rect.height -= 4
  593. contents.fill_rect(rect, colour)
  594. reset_font_settings
  595. change_color(system_color)
  596. text = YEA::PARTY::EMPTY_TEXT
  597. draw_text(rect, text, 1)
  598. reset_font_settings
  599. end
  600.  
  601. #--------------------------------------------------------------------------
  602. # draw_actor_name
  603. #--------------------------------------------------------------------------
  604. def draw_actor_name(actor, rect)
  605. contents.font.size = YEA::PARTY::PARTY_FONT_SIZE
  606. draw_text(rect.x+4, rect.y, rect.width-8, line_height, actor.name, 1)
  607. end
  608.  
  609. #--------------------------------------------------------------------------
  610. # draw_face
  611. #--------------------------------------------------------------------------
  612. def draw_face(face_name, face_index, dx, dy, enabled = true)
  613. bitmap = Cache.face(face_name)
  614. dw = [96, item_rect(0).width-4].min
  615. rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, dw, 92)
  616. contents.blt(dx+2, dy+2, bitmap, rect, enabled ? 255 : translucent_alpha)
  617. bitmap.dispose
  618. end
  619.  
  620. #--------------------------------------------------------------------------
  621. # draw_locked_icon
  622. #--------------------------------------------------------------------------
  623. def draw_locked_icon(actor, rect)
  624. return unless actor_locked?(actor)
  625. draw_icon(Icon.locked_party, rect.x+rect.width-26, rect.height - 26)
  626. end
  627.  
  628. #--------------------------------------------------------------------------
  629. # draw_required_icon
  630. #--------------------------------------------------------------------------
  631. def draw_required_icon(actor, rect)
  632. return if actor_locked?(actor)
  633. return unless actor_required?(actor)
  634. draw_icon(Icon.required_party, rect.x+rect.width-26, rect.height - 26)
  635. end
  636.  
  637. #--------------------------------------------------------------------------
  638. # actor_locked?
  639. #--------------------------------------------------------------------------
  640. def actor_locked?(actor); return actor.locked; end
  641.  
  642. #--------------------------------------------------------------------------
  643. # actor_required?
  644. #--------------------------------------------------------------------------
  645. def actor_required?(actor)
  646. return false if actor.locked
  647. return actor.required
  648. end
  649.  
  650. #--------------------------------------------------------------------------
  651. # current_item_enabled?
  652. #--------------------------------------------------------------------------
  653. def current_item_enabled?; enable?(@data[index]); end
  654.  
  655. #--------------------------------------------------------------------------
  656. # enable?
  657. #--------------------------------------------------------------------------
  658. def enable?(item)
  659. case @command_window.current_symbol
  660. when :change
  661. return true if item.nil?
  662. return true if item == 0
  663. when :remove
  664. return false if item.nil?
  665. return false if item == 0
  666. end
  667. actor = $game_actors[item]
  668. return false if actor.locked
  669. return false if actor.required
  670. return true
  671. end
  672.  
  673. #--------------------------------------------------------------------------
  674. # process_handling
  675. #--------------------------------------------------------------------------
  676. def process_handling
  677. return unless open? && active
  678. return process_ok if ok_enabled? && Input.trigger?(:C)
  679. return process_cancel if cancel_enabled? && Input.trigger?(:B)
  680. return process_pagedown if handle?(:pagedown) && Input.repeat?(:R)
  681. return process_pageup if handle?(:pageup) && Input.repeat?(:L)
  682. end
  683.  
  684. #--------------------------------------------------------------------------
  685. # cur_actor
  686. #--------------------------------------------------------------------------
  687. def cur_actor
  688. actor_id = @data[index]
  689. return $game_actors[actor_id]
  690. end
  691.  
  692. #--------------------------------------------------------------------------
  693. # prev_actor
  694. #--------------------------------------------------------------------------
  695. def prev_actor
  696. id = index == 0 ? @data.size - 1 : index - 1
  697. actor_id = @data[id]
  698. return $game_actors[actor_id]
  699. end
  700.  
  701. #--------------------------------------------------------------------------
  702. # next_actor
  703. #--------------------------------------------------------------------------
  704. def next_actor
  705. id = index == @data.size - 1 ? 0 : index + 1
  706. actor_id = @data[id]
  707. return $game_actors[actor_id]
  708. end
  709.  
  710. #--------------------------------------------------------------------------
  711. # process_pageup
  712. #--------------------------------------------------------------------------
  713. def process_pageup
  714. allow = true
  715. allow = false if !prev_actor.nil? && prev_actor.locked
  716. allow = false if !cur_actor.nil? && cur_actor.locked
  717. Sound.play_buzzer unless allow
  718. if allow
  719. super
  720. activate
  721. select(index == 0 ? @data.size - 1 : index - 1)
  722. end
  723. end
  724.  
  725. #--------------------------------------------------------------------------
  726. # process_pagedown
  727. #--------------------------------------------------------------------------
  728. def process_pagedown
  729. allow = true
  730. allow = false if !next_actor.nil? && next_actor.locked
  731. allow = false if !cur_actor.nil? && cur_actor.locked
  732. Sound.play_buzzer unless allow
  733. if allow
  734. super
  735. activate
  736. select(index == @data.size - 1 ? 0 : index + 1)
  737. end
  738. end
  739.  
  740. #--------------------------------------------------------------------------
  741. # item
  742. #--------------------------------------------------------------------------
  743. def item; return @data[index]; end
  744.  
  745. end # Window_PartySelect
  746.  
  747. #==============================================================================
  748. # ■ Window_PartyList
  749. #==============================================================================
  750.  
  751. class Window_PartyList < Window_Selectable
  752.  
  753. #--------------------------------------------------------------------------
  754. # initialize
  755. #-------------------------------------------------------------------------
  756. def initialize(party_window)
  757. super(0, fitting_height(4), window_width, window_height)
  758. @party_window = party_window
  759. select(1)
  760. deactivate
  761. refresh
  762. end
  763.  
  764. #--------------------------------------------------------------------------
  765. # window_width
  766. #--------------------------------------------------------------------------
  767. def window_width; return 200; end
  768.  
  769. #--------------------------------------------------------------------------
  770. # window_height
  771. #--------------------------------------------------------------------------
  772. def window_height; return Graphics.height - fitting_height(4); end
  773.  
  774. #--------------------------------------------------------------------------
  775. # item_max
  776. #--------------------------------------------------------------------------
  777. def item_max; return @data ? @data.size : 1; end
  778.  
  779. #--------------------------------------------------------------------------
  780. # refresh
  781. #--------------------------------------------------------------------------
  782. def refresh
  783. make_item_list
  784. create_contents
  785. draw_all_items
  786. end
  787.  
  788. #--------------------------------------------------------------------------
  789. # make_item_list
  790. #--------------------------------------------------------------------------
  791. def make_item_list
  792. @data = [0]
  793. for member in $game_party.all_members
  794. next if member.nil?
  795. @data.push(member.id)
  796. end
  797. @data.push(0)
  798. end
  799.  
  800. #--------------------------------------------------------------------------
  801. # draw_item
  802. #--------------------------------------------------------------------------
  803. def draw_item(index)
  804. clear_item(index)
  805. rect = item_rect(index)
  806. if @data[index] == 0
  807. draw_remove(rect)
  808. return
  809. end
  810. actor = $game_actors[@data[index]]
  811. draw_actor(actor, rect)
  812. draw_actor_locked(actor, rect)
  813. draw_actor_required(actor, rect)
  814. end
  815.  
  816. #--------------------------------------------------------------------------
  817. # draw_remove
  818. #--------------------------------------------------------------------------
  819. def draw_remove(rect)
  820. reset_font_settings
  821. draw_icon(Icon.remove_party, rect.x+4, rect.y)
  822. text = YEA::PARTY::REMOVE_TEXT
  823. draw_text(rect.x+32, rect.y, rect.width-32, line_height, text)
  824. end
  825.  
  826. #--------------------------------------------------------------------------
  827. # draw_actor
  828. #--------------------------------------------------------------------------
  829. def draw_actor(actor, rect)
  830. buffer = YEA::PARTY::ACTOR_Y_BUFFER
  831. draw_actor_graphic(actor, rect.x + 16, rect.y + rect.height + buffer)
  832. text = actor.name
  833. change_color(list_colour(actor), enabled?(actor))
  834. draw_text(rect.x+32, rect.y, rect.width-32, line_height, text)
  835. end
  836.  
  837. #--------------------------------------------------------------------------
  838. # list_colour
  839. #--------------------------------------------------------------------------
  840. def list_colour(actor)
  841. return text_color(YEA::PARTY::IN_PARTY_COLOUR) if in_party?(actor)
  842. return normal_color
  843. end
  844.  
  845. #--------------------------------------------------------------------------
  846. # draw_actor_locked
  847. #--------------------------------------------------------------------------
  848. def draw_actor_locked(actor, rect)
  849. return unless actor.locked
  850. draw_icon(Icon.locked_party, rect.width-24, rect.y)
  851. end
  852.  
  853. #--------------------------------------------------------------------------
  854. # draw_actor_required
  855. #--------------------------------------------------------------------------
  856. def draw_actor_required(actor, rect)
  857. return if actor.locked
  858. return unless actor.required
  859. draw_icon(Icon.required_party, rect.width-24, rect.y)
  860. end
  861.  
  862. #--------------------------------------------------------------------------
  863. # enabled?
  864. #--------------------------------------------------------------------------
  865. def enabled?(actor)
  866. return false if actor.locked
  867. return false if actor.required && in_party?(actor)
  868. return true
  869. end
  870.  
  871. #--------------------------------------------------------------------------
  872. # in_party?
  873. #--------------------------------------------------------------------------
  874. def in_party?(actor); return $game_party.battle_members.include?(actor); end
  875.  
  876. #--------------------------------------------------------------------------
  877. # current_item_enabled?
  878. #--------------------------------------------------------------------------
  879. def current_item_enabled?
  880. actor = $game_actors[item]
  881. replace = $game_actors[@party_window.item]
  882. unless actor.nil?
  883. return false if actor.locked && in_party?(actor)
  884. return false if actor.required && in_party?(actor)
  885. end
  886. return true if replace.nil?
  887. return false if replace.locked
  888. return false if replace.required
  889. return true
  890. end
  891.  
  892. #--------------------------------------------------------------------------
  893. # item
  894. #--------------------------------------------------------------------------
  895. def item; return @data[index]; end
  896.  
  897. end # Window_PartyList
  898.  
  899. #==============================================================================
  900. # ** Window_PartyStatus
  901. #==============================================================================
  902.  
  903. class Window_PartyStatus < Window_Base
  904.  
  905. #--------------------------------------------------------------------------
  906. # initialize
  907. #--------------------------------------------------------------------------
  908. def initialize(party_window, list_window)
  909. super(200, fitting_height(4), window_width, window_height)
  910. @party_window = party_window
  911. @list_window = list_window
  912. @actor = active_actor
  913. refresh
  914. end
  915.  
  916. #--------------------------------------------------------------------------
  917. # window_width
  918. #--------------------------------------------------------------------------
  919. def window_width; Graphics.width - 200; end
  920.  
  921. #--------------------------------------------------------------------------
  922. # window_height
  923. #--------------------------------------------------------------------------
  924. def window_height; Graphics.height - fitting_height(4); end
  925.  
  926. #--------------------------------------------------------------------------
  927. # update
  928. #--------------------------------------------------------------------------
  929. def update
  930. super
  931. refresh if @actor != active_actor
  932. end
  933.  
  934. #--------------------------------------------------------------------------
  935. # active_actor
  936. #--------------------------------------------------------------------------
  937. def active_actor
  938. if @list_window.active
  939. actor = @list_window.item
  940. else
  941. actor = @party_window.item
  942. end
  943. return nil if [0, nil].include?(actor)
  944. return actor
  945. end
  946.  
  947. #--------------------------------------------------------------------------
  948. # refresh
  949. #--------------------------------------------------------------------------
  950. def refresh
  951. contents.clear
  952. @actor = active_actor
  953. reset_font_settings
  954. if @actor.nil?
  955. draw_nil_actor
  956. return
  957. end
  958. actor = $game_actors[@actor]
  959. draw_actor_face(actor, 0, 0)
  960. draw_actor_name(actor, 108, 0)
  961. draw_actor_class(actor, 228, 0, contents.width-232)
  962. draw_actor_level(actor, 108, line_height)
  963. draw_actor_icons(actor, 228, line_height, contents.width-232)
  964. draw_actor_hp(actor, 108, line_height*2, contents.width-112)
  965. draw_actor_mp(actor, 108, line_height*3, contents.width-112)
  966. draw_actor_parameters(actor, 0, line_height*4 + line_height/2)
  967. draw_equipments(actor, contents.width/2, line_height*4 + line_height/2)
  968. end
  969.  
  970. #--------------------------------------------------------------------------
  971. # draw_nil_actor
  972. #--------------------------------------------------------------------------
  973. def draw_nil_actor
  974. colour = Color.new(0, 0, 0, translucent_alpha/2)
  975. rect = Rect.new(0, 0, contents.width, contents.height)
  976. contents.fill_rect(rect, colour)
  977. change_color(system_color)
  978. text = YEA::PARTY::NO_DATA
  979. draw_text(rect, text, 1)
  980. end
  981.  
  982. #--------------------------------------------------------------------------
  983. # draw_actor_parameters
  984. #--------------------------------------------------------------------------
  985. def draw_actor_parameters(actor, dx, dy)
  986. dw = contents.width/2 - 4
  987. rect = Rect.new(dx+1, dy+1, dw - 2, line_height - 2)
  988. contents.font.size = YEA::PARTY::STAT_FONT_SIZE
  989. colour = Color.new(0, 0, 0, translucent_alpha/2)
  990. array = [:atk, :def, :mat, :mdf, :agi, :luk]
  991. cx = 4
  992. for stat in array
  993. case stat
  994. when :atk
  995. param = Vocab::param(2)
  996. value = actor.atk.group
  997. when :def
  998. param = Vocab::param(3)
  999. value = actor.def.group
  1000. when :mat
  1001. param = Vocab::param(4)
  1002. value = actor.mat.group
  1003. when :mdf
  1004. param = Vocab::param(5)
  1005. value = actor.mdf.group
  1006. when :agi
  1007. param = Vocab::param(6)
  1008. value = actor.agi.group
  1009. when :luk
  1010. param = Vocab::param(7)
  1011. value = actor.luk.group
  1012. else; next
  1013. end
  1014. contents.fill_rect(rect, colour)
  1015. change_color(system_color)
  1016. draw_text(rect.x + cx, rect.y, rect.width-cx*2, line_height, param, 0)
  1017. change_color(normal_color)
  1018. draw_text(rect.x + cx, rect.y, rect.width-cx*2, line_height, value, 2)
  1019. rect.y += line_height
  1020. end
  1021. reset_font_settings
  1022. end
  1023.  
  1024. #--------------------------------------------------------------------------
  1025. # draw_equipments
  1026. #--------------------------------------------------------------------------
  1027. def draw_equipments(actor, dx, dy)
  1028. text = YEA::PARTY::EQUIP_TEXT
  1029. change_color(system_color)
  1030. draw_text(dx, dy, contents.width - dx, line_height, text, 1)
  1031. dy += line_height
  1032. if actor.equips.size <= 5
  1033. actor.equips.each_with_index do |item, i|
  1034. draw_item_name(item, dx, dy + line_height * i)
  1035. end
  1036. else
  1037. orig_x = dx
  1038. actor.equips.each_with_index do |item, i|
  1039. next if item.nil?
  1040. draw_icon(item.icon_index, dx, dy)
  1041. dy += line_height if dx + 48 > contents.width
  1042. dx = dx + 48 > contents.width ? orig_x : dx + 24
  1043. end
  1044. end
  1045. end
  1046.  
  1047. end # Window_PartyStatus
  1048.  
  1049. #==============================================================================
  1050. # ■ Scene_Menu
  1051. #==============================================================================
  1052.  
  1053. class Scene_Menu < Scene_MenuBase
  1054.  
  1055. #--------------------------------------------------------------------------
  1056. # overwrite method: command_formation
  1057. #--------------------------------------------------------------------------
  1058. if YEA::PARTY::ENABLE_MENU
  1059. def command_formation
  1060. SceneManager.call(Scene_Party)
  1061. end
  1062. end # YEA::PARTY::ENABLE_MENU
  1063.  
  1064. end # Scene_Menu
  1065.  
  1066. #==============================================================================
  1067. # ■ Scene_Party
  1068. #==============================================================================
  1069.  
  1070. class Scene_Party < Scene_MenuBase
  1071.  
  1072. #--------------------------------------------------------------------------
  1073. # start
  1074. #--------------------------------------------------------------------------
  1075. def start
  1076. super
  1077. @former_party = $game_party.battle_members_array.clone
  1078. create_command_window
  1079. create_party_window
  1080. create_list_window
  1081. create_status_window
  1082. end
  1083.  
  1084. #--------------------------------------------------------------------------
  1085. # create_command_window
  1086. #--------------------------------------------------------------------------
  1087. def create_command_window
  1088. @command_window = Window_PartyMenuCommand.new(0, 0)
  1089. @command_window.set_handler(:change, method(:adjust_members))
  1090. @command_window.set_handler(:remove, method(:adjust_members))
  1091. @command_window.set_handler(:revert, method(:revert_party))
  1092. @command_window.set_handler(:finish, method(:return_scene))
  1093. @command_window.set_handler(:cancel, method(:return_scene))
  1094. end
  1095.  
  1096. #--------------------------------------------------------------------------
  1097. # create_party_window
  1098. #--------------------------------------------------------------------------
  1099. def create_party_window
  1100. @party_window = Window_PartySelect.new(@command_window)
  1101. @party_window.set_handler(:ok, method(:on_party_ok))
  1102. @party_window.set_handler(:cancel, method(:on_party_cancel))
  1103. @party_window.set_handler(:pageup, method(:on_party_pageup))
  1104. @party_window.set_handler(:pagedown, method(:on_party_pagedown))
  1105. end
  1106.  
  1107. #--------------------------------------------------------------------------
  1108. # create_list_window
  1109. #--------------------------------------------------------------------------
  1110. def create_list_window
  1111. @list_window = Window_PartyList.new(@party_window)
  1112. @list_window.set_handler(:ok, method(:on_list_ok))
  1113. @list_window.set_handler(:cancel, method(:on_list_cancel))
  1114. end
  1115.  
  1116. #--------------------------------------------------------------------------
  1117. # create_status_window
  1118. #--------------------------------------------------------------------------
  1119. def create_status_window
  1120. @status_window = Window_PartyStatus.new(@party_window, @list_window)
  1121. end
  1122.  
  1123. #--------------------------------------------------------------------------
  1124. # adjust_members
  1125. #--------------------------------------------------------------------------
  1126. def adjust_members
  1127. @party_window.activate
  1128. end
  1129.  
  1130. #--------------------------------------------------------------------------
  1131. # window_refresh
  1132. #--------------------------------------------------------------------------
  1133. def window_refresh
  1134. $game_party.rearrange_actors
  1135. @command_window.refresh
  1136. @party_window.refresh
  1137. @list_window.refresh
  1138. $game_player.refresh
  1139. $game_map.need_refresh = true
  1140. end
  1141.  
  1142. #--------------------------------------------------------------------------
  1143. # revert_party
  1144. #--------------------------------------------------------------------------
  1145. def revert_party
  1146. @command_window.activate
  1147. $game_party.battle_members_array = @former_party.clone
  1148. window_refresh
  1149. end
  1150.  
  1151. #--------------------------------------------------------------------------
  1152. # on_party_ok
  1153. #--------------------------------------------------------------------------
  1154. def on_party_ok
  1155. case @command_window.current_symbol
  1156. when :change
  1157. @list_window.activate
  1158. when :remove
  1159. index = @party_window.index
  1160. actor = $game_actors[$game_party.battle_members_array[index]]
  1161. Sound.play_equip
  1162. $game_party.battle_members_array[index] = 0
  1163. window_refresh
  1164. @party_window.activate
  1165. end
  1166. end
  1167.  
  1168. #--------------------------------------------------------------------------
  1169. # on_party_cancel
  1170. #--------------------------------------------------------------------------
  1171. def on_party_cancel
  1172. @command_window.activate
  1173. end
  1174.  
  1175. #--------------------------------------------------------------------------
  1176. # on_party_pageup
  1177. #--------------------------------------------------------------------------
  1178. def on_party_pageup
  1179. Sound.play_equip
  1180. actor_id1 = @party_window.item
  1181. actor_id2 = @party_window.prev_actor.nil? ? 0 : @party_window.prev_actor.id
  1182. max = @party_window.item_max-1
  1183. index1 = @party_window.index
  1184. index2 = @party_window.index == 0 ? max : index1-1
  1185. $game_party.battle_members_array[index1] = actor_id2
  1186. $game_party.battle_members_array[index2] = actor_id1
  1187. window_refresh
  1188. end
  1189.  
  1190. #--------------------------------------------------------------------------
  1191. # on_party_pagedown
  1192. #--------------------------------------------------------------------------
  1193. def on_party_pagedown
  1194. Sound.play_equip
  1195. actor_id1 = @party_window.item
  1196. actor_id2 = @party_window.next_actor.nil? ? 0 : @party_window.next_actor.id
  1197. max = @party_window.item_max-1
  1198. index1 = @party_window.index
  1199. index2 = @party_window.index == max ? 0 : index1+1
  1200. $game_party.battle_members_array[index1] = actor_id2
  1201. $game_party.battle_members_array[index2] = actor_id1
  1202. window_refresh
  1203. end
  1204.  
  1205. #--------------------------------------------------------------------------
  1206. # on_list_cancel
  1207. #--------------------------------------------------------------------------
  1208. def on_list_cancel
  1209. @party_window.activate
  1210. end
  1211.  
  1212. #--------------------------------------------------------------------------
  1213. # on_list_ok
  1214. #--------------------------------------------------------------------------
  1215. def on_list_ok
  1216. Sound.play_equip
  1217. replace = $game_actors[@party_window.item]
  1218. actor = $game_actors[@list_window.item]
  1219. index1 = @party_window.index
  1220. actor_id1 = actor.nil? ? 0 : actor.id
  1221. if actor.nil?
  1222. $game_party.battle_members_array[index1] = 0
  1223. window_refresh
  1224. @party_window.activate
  1225. return
  1226. end
  1227. actor_id2 = replace.nil? ? 0 : replace.id
  1228. if $game_party.battle_members_array.include?(actor_id1)
  1229. index2 = $game_party.battle_members_array.index(actor_id1)
  1230. $game_party.battle_members_array[index2] = actor_id2
  1231. end
  1232. $game_party.battle_members_array[index1] = actor_id1
  1233. window_refresh
  1234. @party_window.activate
  1235. end
  1236.  
  1237. end # Scene_Party
  1238.  
  1239. #==============================================================================
  1240. #
  1241. # ▼ End of File
  1242. #
  1243. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment