#============================================================================== 2 #
3 # ▼ Yanfly Engine Ace - Party System v1.08
4 # -- Last Updated: 2012.01.23
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 # 2012.01.23 - Bug fixed: Party members are now rearranged when newly added.
17 # 2012.01.14 - New Feature: Maximum Battle Members Variable added.
18 # 2012.01.07 - Bug fixed: Error with removing members.
19 # 2012.01.05 - Bug fixed: Escape skill/item effects no longer counts as death.
20 # 2011.12.26 - Compatibility Update: New Game+
21 # 2011.12.17 - Updated Spriteset_Battle to have updated sprite counts.
22 # 2011.12.13 - Updated to provide better visual display when more than 5 pieces
23 # of equipment are equipped on an actor at a time.
24 # 2011.12.05 - Added functionality to display faces in the Party Select Window.
25 # - Fixed bug that doesn't refresh the caterpillar when new members
26 # join the party.
27 # 2011.12.04 - Started Script and Finished.
28 #
29 #==============================================================================
# ▼ Introduction
31 # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
32 # RPG Maker VX Ace comes with a very nice party system. However, changing the
33 # maximum number of members isn't possible without the aid of a script. This
34 # script enables you the ability to change the maximum number of party members,
35 # change EXP rates, and/or open up a separate party menu (if desired). In
36 # addition to that, you can lock the position of actors within a party and
37 # require other actors to be in the active party before continuing.
38 #
39 #==============================================================================
40 # ▼ Instructions
41 # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
42 # To install this script, open up your script editor and copy/paste this script
43 # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
44 #
45 # -----------------------------------------------------------------------------
46 # Script Calls - These commands are used with script calls.
47 # -----------------------------------------------------------------------------
48 # *IMPORTANT* These script calls require the new party menu to be enabled to
49 # use them. Otherwise, nothing will happen.
50 #
51 # lock_actor(x)
52 # unlock_actor(x)
53 # This will lock actor x in its current position in the party if the actor is
54 # in the current party. The actor is unable to switch position and must remain
55 # in that position until the lock is removed. Use the unlock script call to
56 # remove the locked status. This script requires the actor to have joined and
57 # in the current party before the script call will work.
58 #
59 # require_actor(x)
60 # unrequire_actor(x)
61 # This will cause the party to require actor x in order to continue. If the
62 # actor isn't in the current party but is in the reserve party, the party menu
63 # will open up and prompt the player to add the required actor into the party
64 # before being able to continue. This script call will not function unless the
65 # specific actor has joined the party, whether it is in the current or reserve.
66 #
# call_party_menu
68 # This will open up the party menu. This script call requires for the party
69 # menu to be enabled to use.
70 #
71 #==============================================================================
72 # ▼ Compatibility
73 # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
74 # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
75 # it will run with RPG Maker VX without adjusting.
76 #
77 #==============================================================================
78
79 module YEA
80 module PARTY
81
82 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
83 # - General Party Settings -
84 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
85 # In this section, you can adjust the general party settings for your game
86 # such as the maximum amount of members and whatnot, the EXP rate for
87 # party members in the reserve, etc.
88 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
89 MAX_BATTLE_MEMBERS = 5 # Maximum party members. Default: 4
90 SPLIT_EXP = false # Splits EXP with more members in the party.
91 RESERVE_EXP_RATE = 0.50 # Reserve EXP Rate. Default: 1.00
92
93 # If you wish to be able to change the maximum number of battle members
94 # during the middle of your game, set this constant to a variable ID. If
95 # that variable ID is a number greater than 0, that variable will determine
96 # the current maximum number of battle members. Be cautious about using
97 # this during battle.
98 MAX_MEMBERS_VARIABLE = 0
99
100 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
101 # - Party Menu Settings -
102 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
103 # This section contains various menu settings for those who wish to use a
104 # menu separate for the party system. Here, adjust the menu command order,
105 # icons used, and other settings.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
107 ENABLE_MENU = true # Enables party menu. Default: false
108 COMMANDS =[ # The order at which the menu items are shown.
109 # [:command, "Display"],
110 [ :change, "Change",],
111 [ :remove, "Remove",],
112 [ :revert, "Revert",],
113 [ :finish, "Finish",],
114 ] # Do not remove this.
115 COMMAND_ALIGN = 1 # 0:Left Align, 1:Center Align, 2:Right Align
116
117 # These settings here are used for the upper right window: the Party Select
118 # window where the player selects a member to swap out or remove.
119 PARTY_FONT_SIZE = 20 # Font size used for party member names.
120 LOCK_FIRST_ACTOR = false # Lock the first actor by default?
121 LOCKED_ICON = 125 # Icon used for locked members.
122 REQUIRED_ICON = 126 # Icon used for required members.
123 EMPTY_TEXT = "-Empty-" # Text used when a member isn't present.
124 DISPLAY_FACE = false # Display faces instead of sprites?
125
126 # These settings here are used for the lower left window: the Party List
127 # window where the player selects a member to replace.
128 REMOVE_ICON = 185 # Icon used for removing members.
129 REMOVE_TEXT = "-Remove-" # Text used for remove member command.
130 ACTOR_Y_BUFFER = 12 # Amount the actor graphic be adjusted by.
131
132 # These settings here are used for the lower right window: the Party Status
133 # window where info about a selected actor is shown.
134 NO_DATA = "- No Data -" # Text used for when no actor is shown.
135 IN_PARTY_COLOUR = 6 # Text colour used for in party members.
136 STAT_FONT_SIZE = 20 # Font size used for stats.
137 EQUIP_TEXT = "Equipment" # Text used to display equipment.
139 end # PARTY
140 end # YEA
141
142 #==============================================================================
143 # ▼ Editting anything past this point may potentially result in causing
144 # computer damage, incontinence, explosion of user's head, coma, death, and/or
145 # halitosis so edit at your own risk.
146 #==============================================================================
147
148 #==============================================================================
149 # ■ Icon
150 #==============================================================================
151
152 module Icon
153
154 #--------------------------------------------------------------------------
155 # self.locked_party
156 #--------------------------------------------------------------------------
157 def self.locked_party; return YEA:

ARTY::LOCKED_ICON; end
158
159 #--------------------------------------------------------------------------
160 # self.required_party
161 #--------------------------------------------------------------------------
162 def self.required_party; return YEA:

ARTY::REQUIRED_ICON; end
163
164 #--------------------------------------------------------------------------
165 # self.remove_party
166 #--------------------------------------------------------------------------
167 def self.remove_party; return YEA:

ARTY::REMOVE_ICON; end
168
169 end # Icon
170
171 #==============================================================================
172 # ■ Variable
173 #==============================================================================
174
175 module Variable
177 #--------------------------------------------------------------------------
178 # self.max_battle_members
179 #--------------------------------------------------------------------------
180 def self.max_battle_members
181 default = YEA:

ARTY::MAX_BATTLE_MEMBERS
182 return default if YEA:

ARTY::MAX_MEMBERS_VARIABLE <= 0
183 return default if $game_variables[YEA:

ARTY::MAX_MEMBERS_VARIABLE] <= 0
184 return $game_variables[YEA:

ARTY::MAX_MEMBERS_VARIABLE]
185 end
186
187 end # Variable
188
189 #==============================================================================
190 # ■ Numeric
191 #==============================================================================
192
193 class Numeric
194
195 #--------------------------------------------------------------------------
196 # new method: group_digits
197 #--------------------------------------------------------------------------
198 unless $imported["YEA-CoreEngine"]
199 def group; return self.to_s; end
200 end # $imported["YEA-CoreEngine"]
201
202 end # Numeric
203
204 #==============================================================================
205 # ■ Game_Actor
206 #==============================================================================
207
208 class Game_Actor < Game_Battler
209
210 #--------------------------------------------------------------------------
211 # public instance variables
212 #--------------------------------------------------------------------------
213 attr_accessor :locked
214 attr_accessor :required
215
#--------------------------------------------------------------------------
217 # alias method: setup
218 #--------------------------------------------------------------------------
219 alias game_actor_setup_ps setup
220 def setup(actor_id)
221 game_actor_setup_ps(actor_id)
222 @locked = false
223 @required = false
224 end
225
226 #--------------------------------------------------------------------------
227 # overwrite method: final_exp_rate
228 #--------------------------------------------------------------------------
229 def final_exp_rate
230 n = exr * (battle_member? ? 1 : reserve_members_exp_rate)
231 if $game_party.in_battle
232 n /= [$game_party.battle_members.size, 1].max if YEA:

ARTY::SPLIT_EXP
233 end
234 return n
235 end
236
237 #--------------------------------------------------------------------------
238 # overwrite method: reserve_members_exp_rate
239 #--------------------------------------------------------------------------
240 def reserve_members_exp_rate
241 $data_system.opt_extra_exp ? YEA:

ARTY::RESERVE_EXP_RATE : 0
242 end
243
244 end # Game_Actor
245
246 #==============================================================================
247 # ■ Game_Party
248 #==============================================================================
class Game_Party < Game_Unit
251
252 #--------------------------------------------------------------------------
253 # public instance variables
254 #--------------------------------------------------------------------------
255 attr_accessor :battle_members_array
256
257 #--------------------------------------------------------------------------
258 # alias method: initialize
259 #--------------------------------------------------------------------------
260 alias game_party_initialize_ps initialize
261 def initialize
262 game_party_initialize_ps
263 @battle_members_array = nil
264 end
265
266 #--------------------------------------------------------------------------
267 # overwrite method: max_battle_members
268 #--------------------------------------------------------------------------
269 def max_battle_members; return Variable.max_battle_members; end
270
271 #--------------------------------------------------------------------------
272 # alias method: setup_starting_members
273 #--------------------------------------------------------------------------
274 alias setup_starting_members_ps setup_starting_members
275 def setup_starting_members
276 setup_starting_members_ps
277 initialize_battle_members
278 return unless YEA:

ARTY::LOCK_FIRST_ACTOR
279 return if members[0].nil?
280 members[0].locked = true
281 end
282
283 #--------------------------------------------------------------------------
284 # alias method: setup_battle_test_members
285 #--------------------------------------------------------------------------
286 alias setup_battle_test_members_ps setup_battle_test_members
287 def setup_battle_test_members
288 setup_battle_test_members_ps
289 return unless YEA:

ARTY::LOCK_FIRST_ACTOR
return if members[0].nil?
291 members[0].locked = true
292 end
293
294 #--------------------------------------------------------------------------
295 # overwrite method: battle_members
296 #--------------------------------------------------------------------------
297 def battle_members
298 initialize_battle_members if initialize_battle_members?
299 array = []
300 for actor_id in @battle_members_array
301 break if array.size > max_battle_members
302 next if actor_id.nil?
303 next if $game_actors[actor_id].nil?
304 next unless $game_actors[actor_id].exist?
305 array.push($game_actors[actor_id])
306 end
307 return array
308 end
309
310 #--------------------------------------------------------------------------
311 # new method: initialize_battle_members?
312 #--------------------------------------------------------------------------
313 def initialize_battle_members?
314 return true if @battle_members_array.nil?
315 return @battle_members_array.size != max_battle_members
316 end
317
318 #--------------------------------------------------------------------------
319 # new method: initialize_battle_members
320 #--------------------------------------------------------------------------
321 def initialize_battle_members
322 @battle_members_array = []
323 for i in 0...max_battle_members
324 @battle_members_array.push(@actors
) unless @actors.nil?
325 @battle_members_array.push(0) if @actors.nil?
326 end
327 $game_player.refresh
328 end
329
#--------------------------------------------------------------------------
331 # alias method: add_actor
332 #--------------------------------------------------------------------------
333 alias game_party_add_actor_ps add_actor
334 def add_actor(actor_id)
335 game_party_add_actor_ps(actor_id)
336 return if @battle_members_array.include?(actor_id)
337 return unless @battle_members_array.include?(0)
338 index = @battle_members_array.index(0)
339 @battle_members_array[index] = actor_id
340 $game_player.refresh
341 $game_map.need_refresh = true
342 rearrange_actors
343 end
344
345 #--------------------------------------------------------------------------
346 # alias method: remove_actor
347 #--------------------------------------------------------------------------
348 alias game_party_remove_actor_ps remove_actor
349 def remove_actor(actor_id)
350 game_party_remove_actor_ps(actor_id)
351 return unless @battle_members_array.include?(actor_id)
352 index = @battle_members_array.index(actor_id)
353 @battle_members_array[index] = 0
354 $game_player.refresh
355 $game_map.need_refresh = true
356 rearrange_actors
357 end
358
359 #--------------------------------------------------------------------------
360 # new method: rearrange_actors
361 #--------------------------------------------------------------------------
def rearrange_actors
363 initialize_battle_members if @battle_members_array.nil?
364 array = []
365 for actor_id in @battle_members_array
366 next if [0, nil].include?(actor_id)
367 next if $game_actors[actor_id].nil?
368 array.push(actor_id)
369 end
370 for actor_id in @actors
371 next if array.include?(actor_id)
372 next if $game_actors[actor_id].nil?
373 array.push(actor_id)
374 end
375 @actors = array
376 end
377
378 end # Game_Party
379
380 #==============================================================================
381 # ■ Game_Interpreter
382 #==============================================================================
383
384 class Game_Interpreter
385
386 #--------------------------------------------------------------------------
387 # new method: lock_actor
388 #--------------------------------------------------------------------------
389 def lock_actor(actor_id)
390 return unless YEA:
ARTY::ENABLE_MENU
391 actor = $game_actors[actor_id]
392 return unless $game_party.battle_members.include?(actor.id)
393 actor.locked = true
394 end
395
396 #--------------------------------------------------------------------------
397 # new method: unlock_actor
398 #--------------------------------------------------------------------------
399 def unlock_actor(actor_id)
400 return unless YEA:
ARTY::ENABLE_MENU
401 actor = $game_actors[actor_id]
402 return unless $game_party.battle_members.include?(actor.id)
403 actor.locked = false
404 end
405
#--------------------------------------------------------------------------
407 # new method: require_actor
408 #--------------------------------------------------------------------------
409 def require_actor(actor_id)
410 return unless YEA:
ARTY::ENABLE_MENU
411 return if $game_system.formation_disabled
412 actor = $game_actors[actor_id]
413 return unless $game_party.all_members.include?(actor)
414 actor.required = true
415 call_party_menu unless $game_party.battle_members.include?(actor)
416 end
417
418 #--------------------------------------------------------------------------
419 # new method: unrequire_actor
420 #--------------------------------------------------------------------------
421 def unrequire_actor(actor_id)
422 return unless YEA:
ARTY::ENABLE_MENU
423 return if $game_system.formation_disabled
424 actor = $game_actors[actor_id]
425 return unless $game_party.all_members.include?(actor)
426 actor.required = false
427 call_party_menu unless $game_party.battle_members.include?(actor)
428 end
429
430 #--------------------------------------------------------------------------
431 # new method: call_party_menu
432 #--------------------------------------------------------------------------
433 def call_party_menu
434 return unless YEA:
ARTY::ENABLE_MENU
435 return if $game_system.formation_disabled
436 SceneManager.call(Scene_Party)
437 end
438
439 end # Game_Interpreter
440
441 #==============================================================================
442 # ■ Spriteset_Battle
443 #==============================================================================
444
445 class Spriteset_Battle
446
447 #--------------------------------------------------------------------------
448 # overwrite method: create_actors
#--------------------------------------------------------------------------
450 def create_actors
451 total = $game_party.max_battle_members
452 @actor_sprites = Array.new(total) { Sprite_Battler.new(@viewport1) }
453 end
454
455 end # Spriteset_Battle
456
457 #==============================================================================
458 # ■ Window_PartyMenuCommand
459 #==============================================================================
460
461 class Window_PartyMenuCommand < Window_Command
462
463 #--------------------------------------------------------------------------
464 # window_width
465 #--------------------------------------------------------------------------
466 def window_width; return 160; end
467
468 #--------------------------------------------------------------------------
469 # visible_line_number
470 #--------------------------------------------------------------------------
471 def visible_line_number; 4; end
472
473 #--------------------------------------------------------------------------
474 # alignment
475 #--------------------------------------------------------------------------
476 def alignment
477 return Menu.command_window_align if $imported["YEA-AceMenuEngine"]
478 return YEA:
ARTY::COMMAND_ALIGN
479 end
480
481 #--------------------------------------------------------------------------
482 # scene
483 #--------------------------------------------------------------------------
484 def scene; return SceneManager.scene; end
485
486 #--------------------------------------------------------------------------
487 # make_command_list
488 #--------------------------------------------------------------------------
489 def make_command_list
490 for command in YEA:
ARTY::COMMANDS
491 case command[0]
when :change, :remove, :revert
493 add_command(command[1], command[0])
494 when :finish
495 add_command(command[1], command[0], enable_cancel?)
496 else; next
497 end
498 end
499 end
500
501 #--------------------------------------------------------------------------
502 # process_cancel
503 #--------------------------------------------------------------------------
504 def process_cancel
505 unless enable_cancel?
506 Sound.play_buzzer
507 return
508 end
509 super
510 end
511
512 #--------------------------------------------------------------------------
513 # in_party?
514 #--------------------------------------------------------------------------
515 def in_party?(actor)
516 return $game_party.battle_members.include?(actor)
517 end
518
519 #--------------------------------------------------------------------------
520 # enable_cancel?
521 #--------------------------------------------------------------------------
522 def enable_cancel?
523 return false if $game_party.battle_members.size <= 0
524 for actor in $game_party.all_members
525 next if in_party?(actor)
526 return false if actor.required
527 return false if actor.locked
528 end
529 return true
530 end
531
532 end # Window_PartyMenuCommand
533
534 #==============================================================================
535 # ■ Window_PartySelect
536 #==============================================================================
537
538 class Window_PartySelect < Window_Selectable
539
540 #--------------------------------------------------------------------------
541 # initialize
542 #-------------------------------------------------------------------------
543 def initialize(command_window)
544 @command_window = command_window
545 super(160, 0, window_width, fitting_height(visible_line_number))
546 select(0)
547 deactivate
548 refresh
549 end
550
551 #--------------------------------------------------------------------------
552 # col_max
553 #--------------------------------------------------------------------------
554 def col_max; return $game_party.max_battle_members; end
555
556 #--------------------------------------------------------------------------
557 # item_max
558 #--------------------------------------------------------------------------
559 def item_max; return $game_party.max_battle_members; end
560
561 #--------------------------------------------------------------------------
562 # window_width
563 #--------------------------------------------------------------------------
564 def window_width; return Graphics.width - 160; end
565
566 #--------------------------------------------------------------------------
567 # visible_line_number
568 #--------------------------------------------------------------------------
569 def visible_line_number; 4; end
570
571 #--------------------------------------------------------------------------
572 # item_rect
#--------------------------------------------------------------------------
574 def item_rect(index)
575 rect = Rect.new
576 rect.width = contents.width / item_max
577 rect.height = contents.height
578 rect.x = index * rect.width
579 rect.y = 0
580 return rect
581 end
582
583 #--------------------------------------------------------------------------
584 # refresh
585 #--------------------------------------------------------------------------
586 def refresh
587 make_item_list
588 create_contents
589 draw_all_items
590 end
591
592 #--------------------------------------------------------------------------
593 # make_item_list
594 #--------------------------------------------------------------------------
595 def make_item_list
596 @data = $game_party.battle_members_array.clone
597 end
598
599 #--------------------------------------------------------------------------
600 # draw_item
601 #--------------------------------------------------------------------------
602 def draw_item(index)
603 actor = $game_actors[@data[index]]
604 rect = item_rect(index)
605 if actor.nil?
606 draw_empty(rect.clone)
607 return
608 end
609 dx = rect.width / 2
610 dy = rect.height - 16
draw_actor_face(actor, rect.x, rect.y) if display_face?
612 draw_actor_graphic(actor, rect.x + dx, rect.y + dy) unless display_face?
613 draw_actor_name(actor, rect)
614 draw_locked_icon(actor, rect)
615 draw_required_icon(actor, rect)
616 end
617
618 #--------------------------------------------------------------------------
619 # display_face?
620 #--------------------------------------------------------------------------
621 def display_face?
622 return YEA:
ARTY:
ISPLAY_FACE
623 end
624
625 #--------------------------------------------------------------------------
626 # draw_empty
627 #--------------------------------------------------------------------------
628 def draw_empty(rect)
629 colour = Color.new(0, 0, 0, translucent_alpha/2)
630 rect.x += 2
631 rect.y += 2
632 rect.width -= 4
633 rect.height -= 4
634 contents.fill_rect(rect, colour)
635 reset_font_settings
636 change_color(system_color)
637 text = YEA:
ARTY::EMPTY_TEXT
638 draw_text(rect, text, 1)
639 reset_font_settings
640 end
641
642 #--------------------------------------------------------------------------
643 # draw_actor_name
644 #--------------------------------------------------------------------------
645 def draw_actor_name(actor, rect)
646 contents.font.size = YEA:
ARTY:
ARTY_FONT_SIZE
647 change_color(normal_color, actor.exist?)
648 draw_text(rect.x+4, rect.y, rect.width-8, line_height, actor.name, 1)
649 end
650
651 #--------------------------------------------------------------------------
652 # draw_face
653 #--------------------------------------------------------------------------
654 def draw_face(face_name, face_index, dx, dy, enabled = true
bitmap = Cache.face(face_name)
656 dw = [96, item_rect(0).width-4].min
657 rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, dw, 92)
658 contents.blt(dx+2, dy+2, bitmap, rect, enabled ? 255 : translucent_alpha)
659 bitmap.dispose
660 end
661
662 #--------------------------------------------------------------------------
663 # draw_locked_icon
664 #--------------------------------------------------------------------------
665 def draw_locked_icon(actor, rect)
666 return unless actor_locked?(actor)
667 draw_icon(Icon.locked_party, rect.x+rect.width-26, rect.height - 26)
668 end
669
670 #--------------------------------------------------------------------------
671 # draw_required_icon
672 #--------------------------------------------------------------------------
673 def draw_required_icon(actor, rect)
674 return if actor_locked?(actor)
675 return unless actor_required?(actor)
676 draw_icon(Icon.required_party, rect.x+rect.width-26, rect.height - 26)
677 end
678
679 #--------------------------------------------------------------------------
680 # actor_locked?
681 #--------------------------------------------------------------------------
682 def actor_locked?(actor); return actor.locked; end
683
684 #--------------------------------------------------------------------------
685 # actor_required?
686 #--------------------------------------------------------------------------
def actor_required?(actor)
688 return false if actor.locked
689 return actor.required
690 end
691
692 #--------------------------------------------------------------------------
693 # current_item_enabled?
694 #--------------------------------------------------------------------------
695 def current_item_enabled?; enable?(@data[index]); end
696
697 #--------------------------------------------------------------------------
698 # enable?
699 #--------------------------------------------------------------------------
700 def enable?(item)
701 case @command_window.current_symbol
702 when :change
703 return true if item.nil?
704 return true if item == 0
705 when :remove
706 return false if item.nil?
707 return false if item == 0
708 end
709 actor = $game_actors[item]
710 return false if actor.locked
711 return false if actor.required
712 return true
713 end
714
715 #--------------------------------------------------------------------------
716 # process_handling
717 #--------------------------------------------------------------------------
718 def process_handling
719 return unless open? && active
720 return process_ok if ok_enabled? && Input.trigger?
C)
721 return process_cancel if cancel_enabled? && Input.trigger?
722 return process_pagedown if handle?
pagedown) && Input.repeat?
R)
723 return process_pageup if handle?
pageup) && Input.repeat?
L)
724 end
725
726 #--------------------------------------------------------------------------
727 # cur_actor
728 #--------------------------------------------------------------------------
def cur_actor
730 actor_id = @data[index]
731 return $game_actors[actor_id]
732 end
733
734 #--------------------------------------------------------------------------
735 # prev_actor
736 #--------------------------------------------------------------------------
737 def prev_actor
738 id = index == 0 ? @data.size - 1 : index - 1
739 actor_id = @data[id]
740 return $game_actors[actor_id]
741 end
742
743 #--------------------------------------------------------------------------
744 # next_actor
745 #--------------------------------------------------------------------------
746 def next_actor
747 id = index == @data.size - 1 ? 0 : index + 1
748 actor_id = @data[id]
749 return $game_actors[actor_id]
750 end
751
752 #--------------------------------------------------------------------------
753 # process_pageup
754 #--------------------------------------------------------------------------
755 def process_pageup
756 allow = true
757 allow = false if !prev_actor.nil? && prev_actor.locked
758 allow = false if !cur_actor.nil? && cur_actor.locked
759 Sound.play_buzzer unless allow
760 if allow
761 super
762 activate
763 select(index == 0 ? @data.size - 1 : index - 1)
764 end
765 end
766
767 #--------------------------------------------------------------------------
768 # process_pagedown
769 #--------------------------------------------------------------------------
770 def process_pagedown
771 allow = true
allow = false if !next_actor.nil? && next_actor.locked
773 allow = false if !cur_actor.nil? && cur_actor.locked
774 Sound.play_buzzer unless allow
775 if allow
776 super
777 activate
778 select(index == @data.size - 1 ? 0 : index + 1)
779 end
780 end
781
782 #--------------------------------------------------------------------------
783 # item
784 #--------------------------------------------------------------------------
785 def item; return @data[index]; end
786
787 end # Window_PartySelect
788
789 #==============================================================================
790 # ■ Window_PartyList
791 #==============================================================================
792
793 class Window_PartyList < Window_Selectable
794
795 #--------------------------------------------------------------------------
796 # initialize
797 #-------------------------------------------------------------------------
798 def initialize(party_window)
799 super(0, fitting_height(4), window_width, window_height)
800 @party_window = party_window
801 select(1)
802 deactivate
803 refresh
804 end
805
806 #--------------------------------------------------------------------------
807 # window_width
808 #--------------------------------------------------------------------------
809 def window_width; return 200; end
810
811 #--------------------------------------------------------------------------
812 # window_height
813 #--------------------------------------------------------------------------
814 def window_height; return Graphics.height - fitting_height(4); end
816 #--------------------------------------------------------------------------
817 # item_max
818 #--------------------------------------------------------------------------
819 def item_max; return @data ? @data.size : 1; end
820
821 #--------------------------------------------------------------------------
822 # refresh
823 #--------------------------------------------------------------------------
824 def refresh
825 make_item_list
826 create_contents
827 draw_all_items
828 end
829
830 #--------------------------------------------------------------------------
831 # make_item_list
832 #--------------------------------------------------------------------------
833 def make_item_list
834 @data = [0]
835 for member in $game_party.all_members
836 next if member.nil?
837 @data.push(member.id)
838 end
839 @data.push(0)
840 end
841
842 #--------------------------------------------------------------------------
843 # draw_item
844 #--------------------------------------------------------------------------
845 def draw_item(index)
846 clear_item(index)
847 rect = item_rect(index)
848 if @data[index] == 0
849 draw_remove(rect)
850 return
851 end
852 actor = $game_actors[@data[index]]
853 draw_actor(actor, rect)
854 draw_actor_locked(actor, rect)
855 draw_actor_required(actor, rect)
856 end
857
#--------------------------------------------------------------------------
859 # draw_remove
860 #--------------------------------------------------------------------------
861 def draw_remove(rect)
862 reset_font_settings
863 draw_icon(Icon.remove_party, rect.x+4, rect.y)
864 text = YEA:
ARTY::REMOVE_TEXT
865 draw_text(rect.x+32, rect.y, rect.width-32, line_height, text)
866 end
867
868 #--------------------------------------------------------------------------
869 # draw_actor
870 #--------------------------------------------------------------------------
871 def draw_actor(actor, rect)
872 buffer = YEA:
ARTY::ACTOR_Y_BUFFER
873 draw_actor_graphic(actor, rect.x + 16, rect.y + rect.height + buffer)
874 text = actor.name
875 change_color(list_colour(actor), enabled?(actor))
876 draw_text(rect.x+32, rect.y, rect.width-32, line_height, text)
877 end
878
879 #--------------------------------------------------------------------------
880 # list_colour
881 #--------------------------------------------------------------------------
882 def list_colour(actor)
883 return text_color(YEA:
ARTY::IN_PARTY_COLOUR) if in_party?(actor)
884 return normal_color
885 end
886
887 #--------------------------------------------------------------------------
888 # draw_actor_locked
889 #--------------------------------------------------------------------------
890 def draw_actor_locked(actor, rect)
891 return unless actor.locked
892 draw_icon(Icon.locked_party, rect.width-24, rect.y)
893 end
894
895 #--------------------------------------------------------------------------
896 # draw_actor_required
897 #--------------------------------------------------------------------------
898 def draw_actor_required(actor, rect)
899 return if actor.locked
900 return unless actor.required
draw_icon(Icon.required_party, rect.width-24, rect.y)
902 end
903
904 #--------------------------------------------------------------------------
905 # enabled?
906 #--------------------------------------------------------------------------
907 def enabled?(actor)
908 return false if actor.locked
909 return false if actor.required && in_party?(actor)
910 return actor.exist?
911 end
912
913 #--------------------------------------------------------------------------
914 # in_party?
915 #--------------------------------------------------------------------------
916 def in_party?(actor); return $game_party.battle_members.include?(actor); end
917
918 #--------------------------------------------------------------------------
919 # current_item_enabled?
920 #--------------------------------------------------------------------------
921 def current_item_enabled?
922 actor = $game_actors[item]
923 replace = $game_actors[@party_window.item]
924 unless actor.nil?
925 return false if actor.locked && in_party?(actor)
926 return false if actor.required && in_party?(actor)
927 end
928 return true if replace.nil?
929 return false if replace.locked
930 return false if replace.required
931 return true if actor.nil?
932 return actor.exist?
933 end
934
935 #--------------------------------------------------------------------------
936 # item
937 #--------------------------------------------------------------------------
938 def item; return @data[index]; end
940 end # Window_PartyList
941
942 #==============================================================================
943 # ** Window_PartyStatus
944 #==============================================================================
945
946 class Window_PartyStatus < Window_Base
947
948 #--------------------------------------------------------------------------
949 # initialize
950 #--------------------------------------------------------------------------
951 def initialize(party_window, list_window)
952 super(200, fitting_height(4), window_width, window_height)
953 @party_window = party_window
954 @list_window = list_window
955 @actor = active_actor
956 refresh
957 end
958
959 #--------------------------------------------------------------------------
960 # window_width
961 #--------------------------------------------------------------------------
962 def window_width; Graphics.width - 200; end
963
964 #--------------------------------------------------------------------------
965 # window_height
966 #--------------------------------------------------------------------------
967 def window_height; Graphics.height - fitting_height(4); end
968
969 #--------------------------------------------------------------------------
970 # update
971 #--------------------------------------------------------------------------
972 def update
973 super
974 refresh if @actor != active_actor
975 end
977 #--------------------------------------------------------------------------
978 # active_actor
979 #--------------------------------------------------------------------------
980 def active_actor
981 if @list_window.active
982 actor = @list_window.item
983 else
984 actor = @party_window.item
985 end
986 return nil if [0, nil].include?(actor)
987 return actor
988 end
989
990 #--------------------------------------------------------------------------
991 # refresh
992 #--------------------------------------------------------------------------
993 def refresh
994 contents.clear
995 @actor = active_actor
996 reset_font_settings
997 if @actor.nil?
998 draw_nil_actor
999 return
1000 end
1001 actor = $game_actors[@actor]
1002 draw_actor_face(actor, 0, 0)
1003 draw_actor_name(actor, 108, 0)
1004 draw_actor_class(actor, 228, 0, contents.width-232)
1005 draw_actor_level(actor, 108, line_height)
1006 draw_actor_icons(actor, 228, line_height, contents.width-232)
1007 draw_actor_hp(actor, 108, line_height*2, contents.width-112)
1008 draw_actor_mp(actor, 108, line_height*3, contents.width-112)
1009 draw_actor_parameters(actor, 0, line_height*4 + line_height/2)
1010 draw_equipments(actor, contents.width/2, line_height*4 + line_height/2)
1011 end
1012
1013 #--------------------------------------------------------------------------
# draw_nil_actor
1015 #--------------------------------------------------------------------------
1016 def draw_nil_actor
1017 colour = Color.new(0, 0, 0, translucent_alpha/2)
1018 rect = Rect.new(0, 0, contents.width, contents.height)
1019 contents.fill_rect(rect, colour)
1020 change_color(system_color)
1021 text = YEA:
ARTY::NO_DATA
1022 draw_text(rect, text, 1)
1023 end
1024
1025 #--------------------------------------------------------------------------
1026 # draw_actor_parameters
1027 #--------------------------------------------------------------------------
1028 def draw_actor_parameters(actor, dx, dy)
1029 dw = contents.width/2 - 4
1030 rect = Rect.new(dx+1, dy+1, dw - 2, line_height - 2)
1031 contents.font.size = YEA:
ARTY::STAT_FONT_SIZE
1032 colour = Color.new(0, 0, 0, translucent_alpha/2)
1033 array = [:atk, :def, :mat, :mdf, :agi, :luk]
1034 cx = 4
1035 for stat in array
1036 case stat
1037 when :atk
1038 param = Vocab:
aram(2)
1039 value = actor.atk.group
1040 when :def
1041 param = Vocab:
aram(3)
1042 value = actor.def.group
1043 when :mat
1044 param = Vocab:
aram(4)
1045 value = actor.mat.group
1046 when :mdf
1047 param = Vocab:
aram(5)
1048 value = actor.mdf.group
1049 when :agi
1050 param = Vocab:
aram(6)
1051 value = actor.agi.group
when :luk
1053 param = Vocab:
aram(7)
1054 value = actor.luk.group
1055 else; next
1056 end
1057 contents.fill_rect(rect, colour)
1058 change_color(system_color)
1059 draw_text(rect.x + cx, rect.y, rect.width-cx*2, line_height, param, 0)
1060 change_color(normal_color)
1061 draw_text(rect.x + cx, rect.y, rect.width-cx*2, line_height, value, 2)
1062 rect.y += line_height
1063 end
1064 reset_font_settings
1065 end
1066
1067 #--------------------------------------------------------------------------
1068 # draw_equipments
1069 #--------------------------------------------------------------------------
1070 def draw_equipments(actor, dx, dy)
1071 text = YEA:
ARTY::EQUIP_TEXT
1072 change_color(system_color)
1073 draw_text(dx, dy, contents.width - dx, line_height, text, 1)
1074 dy += line_height
1075 if actor.equips.size <= 5
1076 actor.equips.each_with_index do |item, i|
1077 draw_item_name(item, dx, dy + line_height * i)
1078 end
1079 else
1080 orig_x = dx
1081 actor.equips.each_with_index do |item, i|
1082 next if item.nil?
1083 draw_icon(item.icon_index, dx, dy)
1084 dy += line_height if dx + 48 > contents.width
1085 dx = dx + 48 > contents.width ? orig_x : dx + 24
1086 end
1087 end
1088 end
1089
1090 end # Window_PartyStatus
1091
1092 #==============================================================================
1093 # ■ Scene_Menu
1094 #==============================================================================
1096 class Scene_Menu < Scene_MenuBase
1097
1098 #--------------------------------------------------------------------------
1099 # overwrite method: command_formation
1100 #--------------------------------------------------------------------------
1101 if YEA:
ARTY::ENABLE_MENU
1102 def command_formation
1103 SceneManager.call(Scene_Party)
1104 end
1105 end # YEA:
ARTY::ENABLE_MENU
1106
1107 end # Scene_Menu
1108
1109 #==============================================================================
1110 # ■ Scene_Party
1111 #==============================================================================
1112
1113 class Scene_Party < Scene_MenuBase
1114
1115 #--------------------------------------------------------------------------
1116 # start
1117 #--------------------------------------------------------------------------
1118 def start
1119 super
1120 @former_party = $game_party.battle_members_array.clone
1121 create_command_window
1122 create_party_window
1123 create_list_window
1124 create_status_window
1125 end
1126
1127 #--------------------------------------------------------------------------
1128 # create_command_window
1129 #--------------------------------------------------------------------------
1130 def create_command_window
1131 @command_window = Window_PartyMenuCommand.new(0, 0)
1132 @command_window.set_handler
change, method
adjust_members))
1133 @command_window.set_handler
remove, method
adjust_members))
1134 @command_window.set_handler
revert, method
revert_party))
1135 @command_window.set_handler
finish, method
return_scene))
1136 @command_window.set_handler
cancel, method
return_scene))
1137 end
1139 #--------------------------------------------------------------------------
1140 # create_party_window
1141 #--------------------------------------------------------------------------
1142 def create_party_window
1143 @party_window = Window_PartySelect.new(@command_window)
1144 @party_window.set_handler
ok, method
on_party_ok))
1145 @party_window.set_handler
cancel, method
on_party_cancel))
1146 @party_window.set_handler
pageup, method
on_party_pageup))
1147 @party_window.set_handler
pagedown, method
on_party_pagedown))
1148 end
1149
1150 #--------------------------------------------------------------------------
1151 # create_list_window
1152 #--------------------------------------------------------------------------
1153 def create_list_window
1154 @list_window = Window_PartyList.new(@party_window)
1155 @list_window.set_handler
ok, method
on_list_ok))
1156 @list_window.set_handler
cancel, method
on_list_cancel))
1157 end
1158
1159 #--------------------------------------------------------------------------
1160 # create_status_window
1161 #--------------------------------------------------------------------------
1162 def create_status_window
1163 @status_window = Window_PartyStatus.new(@party_window, @list_window)
1164 end
1165
1166 #--------------------------------------------------------------------------
1167 # adjust_members
1168 #--------------------------------------------------------------------------
1169 def adjust_members
1170 @party_window.activate
1171 end
1172
1173 #--------------------------------------------------------------------------
1174 # window_refresh
1175 #--------------------------------------------------------------------------
1176 def window_refresh
1177 $game_party.rearrange_actors
1178 @command_window.refresh
1179 @party_window.refresh
1180 @list_window.refresh
$game_player.refresh
1182 $game_map.need_refresh = true
1183 end
1184
1185 #--------------------------------------------------------------------------
1186 # revert_party
1187 #--------------------------------------------------------------------------
1188 def revert_party
1189 @command_window.activate
1190 $game_party.battle_members_array = @former_party.clone
1191 window_refresh
1192 end
1193
1194 #--------------------------------------------------------------------------
1195 # on_party_ok
1196 #--------------------------------------------------------------------------
1197 def on_party_ok
1198 case @command_window.current_symbol
1199 when :change
1200 @list_window.activate
1201 when :remove
1202 index = @party_window.index
1203 actor = $game_actors[$game_party.battle_members_array[index]]
1204 Sound.play_equip
1205 $game_party.battle_members_array[index] = 0
1206 window_refresh
1207 @party_window.activate
1208 end
1209 end
1210
1211 #--------------------------------------------------------------------------
1212 # on_party_cancel
1213 #--------------------------------------------------------------------------
def on_party_cancel
1215 @command_window.activate
1216 end
1217
1218 #--------------------------------------------------------------------------
1219 # on_party_pageup
1220 #--------------------------------------------------------------------------
1221 def on_party_pageup
1222 Sound.play_equip
1223 actor_id1 = @party_window.item
1224 actor_id2 = @party_window.prev_actor.nil? ? 0 : @party_window.prev_actor.id
1225 max = @party_window.item_max-1
1226 index1 = @party_window.index
1227 index2 = @party_window.index == 0 ? max : index1-1
1228 $game_party.battle_members_array[index1] = actor_id2
1229 $game_party.battle_members_array[index2] = actor_id1
1230 window_refresh
1231 end
1232
1233 #--------------------------------------------------------------------------
1234 # on_party_pagedown
1235 #--------------------------------------------------------------------------
1236 def on_party_pagedown
1237 Sound.play_equip
1238 actor_id1 = @party_window.item
1239 actor_id2 = @party_window.next_actor.nil? ? 0 : @party_window.next_actor.id
1240 max = @party_window.item_max-1
1241 index1 = @party_window.index
1242 index2 = @party_window.index == max ? 0 : index1+1
1243 $game_party.battle_members_array[index1] = actor_id2
1244 $game_party.battle_members_array[index2] = actor_id1
1245 window_refresh
1246 end
1247
1248 #--------------------------------------------------------------------------
1249 # on_list_cancel
1250 #--------------------------------------------------------------------------
1251 def on_list_cancel
1252 @party_window.activate
1253 end
1254
1255 #--------------------------------------------------------------------------
1256 # on_list_ok
#--------------------------------------------------------------------------
1258 def on_list_ok
1259 Sound.play_equip
1260 replace = $game_actors[@party_window.item]
1261 actor = $game_actors[@list_window.item]
1262 index1 = @party_window.index
1263 actor_id1 = actor.nil? ? 0 : actor.id
1264 if actor.nil?
1265 $game_party.battle_members_array[index1] = 0
1266 window_refresh
1267 @party_window.activate
1268 return
1269 end
1270 actor_id2 = replace.nil? ? 0 : replace.id
1271 if $game_party.battle_members_array.include?(actor_id1)
1272 index2 = $game_party.battle_members_array.index(actor_id1)
1273 $game_party.battle_members_array[index2] = actor_id2
1274 end
1275 $game_party.battle_members_array[index1] = actor_id1
1276 window_refresh
1277 @party_window.activate
1278 end
1279
1280 end # Scene_Party
1281
1282 #==============================================================================
1283 #
1284 # ▼ End of File
1285 #
1286 #==============================================================================