- 注册时间
- 2005-1-31
- 最后登录
- 2006-1-15
⑥精研
梦境采集者
- 积分
- 1791
|

楼主 |
发表于 2005-2-4 21:01:30
|
显示全部楼层
Insert a new class after Scene_Debug and before Main. Name this class \"Scene_Switch\" and paste the following code into it.
#==============================================================================
# Scene_Switch class definition
#------------------------------------------------------------------------------
# This class represents the party switching sub-screen. It allows the player
# to switch in and out characters from the party. Characters that are not in
# the party but that are available are said \'in reserve\'.
#
# Characters available are those that exist in Game_Actors::data and whose
# property unavailable is set to false. In the default script, an actor is
# loaded in Game_Actors::data when s/he is added for the very first time in the
# party and is never deleted, unless it\'s done explicitly with scripts.
#
# This script requires you to create 2 additional attributes for the Game_Actor
# class: mandatory and unavailable. Both are boolean values.
#
# Mandatory is a boolean variable that, when set to true, means that the actor
# can\'t be switched out of the party. This is useful for main characters, that
# are in many RPGs required most of the time, if not always. The switch screen
# will display the word \"Mandatory\" in red above an actor that can\'t be put out
# of the party.
#
# Unavailable is another boolean variable that, when set to true, means that
# although the actor is defined in Game_Actors::data, won\'t appear in the
# reserve window. This is useful when a character leaves the party in the
# story, but you don\'t want to reset his stats and name when s/he comes back.
#
# Usage of this script requires the 3 other files: Window_SwitchParty,
# Window_SwitchReserve and Window_SwitchStatus, as well as a few modifications
# of the default scripts:
#
# 1 - In Game_Actor, add in the class definition (under \"class Game_Actor
# [...]\"):
# attr_reader :actor_id
# attr_accessor :mandatory
# attr_accessor :unavailable
#
# 2 - Again, in Game_Actor, add in the setup method (under \"def setup\"):
# mandatory = false
# unavailable = false
#
# 3 - In Game_Actors (with an \"s\"!) add in the class definition:
# attr_accessor :data
#
# 4 - In Game_Party, change:
# attr_reader :actors
# for
# attr_accessor :actors
#
# By exseiken, October 04, 2004
#==============================================================================
class Scene_Switch
#----------------------------------------------------------------------------
# Initialize the sub-screen. If it was called from the menu, it will return
# to the main menu when closed, otherwise, it will return to the map.
#
# Parameters:
# from_menu: Determines whether or not the scene was called from
# the menu or not [true|false]
# min_size: The minimum amount of characters that the new party
# must have [1; 4]
# max_size: The maximum amount of characters that the new party
# must have [min_size; 4]
#----------------------------------------------------------------------------
def initialize(from_menu, min_size = 1, max_size = 4)
# store the data telling whether or not the scene was called from the menu
@from_menu = from_menu
# store the array bounds for the max_size and min_size
@min_size = [[min_size, 1].max, 4].min
@max_size = [[max_size, @min_size].max, 4].min
end
#----------------------------------------------------------------------------
# The main routine, controlling the life of the object.
#----------------------------------------------------------------------------
def main
# create the window containing the current party members
@party_window = Window_SwitchParty.new
# create the window containing all available party members
@reserve_window = Window_SwitchReserve.new(10)
# create the window showing information about the selected character, be it
# from the party window or from the reserve window
@status_window = Window_SwitchStatus.new
# if the party is empty, the active window is reserve_window, otherwise
# it\'s the party window
if $game_party.actors.size == 0
@party_window.active = false
else
@reserve_window.active = false
end
# set this status window as the two other windows\' help window
@party_window.help_window = @status_window
@reserve_window.help_window = @status_window
# display the transition
Graphics.transition
# enter the main loop
loop do
# flip the screen
Graphics.update
# get the buttons pressed
Input.update
# update the sub-screen
update
# if the scene has changed, return
if $scene != self
break
end
end
# stop drawing graphics
Graphics.freeze
# destroy the sub-windows
@status_window.dispose
@reserve_window.dispose
@party_window.dispose
end
#----------------------------------------------------------------------------
# Method called on every frame: update the contents of the scene (the 3,
# windows) and read on the keyboard.
#----------------------------------------------------------------------------
def update
# update all sub-windows
@party_window.update
@reserve_window.update
@status_window.update
# if the active screen is party_window, update it, else update the reserve
# window
if @party_window.active
update_party
return
else
update_reserve
return
end
end
#----------------------------------------------------------------------------
# Called when the focus is on the party window. Read on the keyboard and
# update the state of the scene according to the buttons pressed. If the
# played pressed B while this mode is on, the new party will be set and
# the scene will close.
#----------------------------------------------------------------------------
def update_party
# if the B (back) button was pressed, return to the preceeding screen
if Input.trigger?(Input::B)
# remove all holes in the party
new_party = @party_window.new_party.compact
# get the number of party members
n = new_party.size
# if the party doesn\'t have an acceptable amount of party members, don\'t
# allow quitting the sub-screen
if n < @min_size or n > @max_size
# play the buzzer and exit
$game_system.se_play($data_system.buzzer_se)
return
end
# play the confirm sound
$game_system.se_play($data_system.decision_se)
# set the new party
$game_party.actors = new_party
# return to the calling scene
if @from_menu
$scene = Scene_Menu.new(5)
else
$scene = Scene_Map.new
end
# refresh the player\'s sprite
$game_player.refresh
# skip (optimizing)
return
# if the C (confirm) button was pressed, switch the control to the reserve
# window
elsif Input.trigger?(Input::C)
# if the selected character is not nil, and is unavailable, play the buzzer
if(@party_window.actor != nil and @party_window.actor.mandatory)
# play the buzzer
$game_system.se_play($data_system.buzzer_se)
else
# play the decision sound
$game_system.se_play($data_system.decision_se)
# unactivate the party window
@party_window.active = false
# activate the reserve window
@reserve_window.active = true
end
end
end
#----------------------------------------------------------------------------
# Called when the focus is on the reserve window. Read on the keyboard and
# update the state of the scene according to the buttons pressed.
#----------------------------------------------------------------------------
def update_reserve
# if the B (back) button was pressed, give back the focus to the party
# window
if Input.trigger?(Input::B)
# play the cancel sound
$game_system.se_play($data_system.decision_se)
# unactivate the reserve window
@reserve_window.active = false
# activate the party window
@party_window.active = true
# skip
return
# if the C (confirm) button was pressed, switch the party member in reserve
# with the one selected in the party
elsif Input.trigger?(Input::C)
# play the confirm sound
$game_system.se_play($data_system.decision_se)
# swap the 2 party members
@party_window.change_selection(@reserve_window.swap_characters(@party_window.actor))
# unactivate the reserve window
@reserve_window.active = false
# activate the party window
@party_window.active = true
end
end
end
|
|