Selwyn @ HBGames.Org Mon Jun 19, 2006 Wrote:~~requested by Hitomi Kamimura~~
this allows you to make a party by selecting the characters that will be in it.
paste the script in a new section above main
SCREENSHOTS
SCRIPT
The Script
Code:
#==============================================================================
# ? Character Select Script
#------------------------------------------------------------------------------
# created by Selwyn
# selwyn@rmxp.ch
#
# released on the 19th of June 2006
#
# allows to set the initial party.
#
# $scene = Scene_CharSelect.new(IDS_OF_THE_HEROES, MAX_PARTY_SIZE)
#==============================================================================
class Scene_CharSelect
#--------------------------------------------------------------------------
# ? initialize
#--------------------------------------------------------------------------
def initialize(ids = [1, 2, 3, 4, 5, 6], party_size = 4)
@ids = ids
@party_size = party_size
end
#--------------------------------------------------------------------------
# ? main
#--------------------------------------------------------------------------
def main
@select_window = Window_CharSelect.new(@ids)
@name_window = Window_NameEnter.new
@help_window = Window_Help.new
@help_window.width = 320
@help_window.contents = Bitmap.new(288, 32)
@name_window.help_window = @help_window
@valid_window = Window_NameValid.new(nil)
@step = 0
@selected_indexes = []
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@select_window.dispose
@name_window.dispose
@help_window.dispose
@valid_window.dispose
end
#--------------------------------------------------------------------------
# ? update
#--------------------------------------------------------------------------
def update
if @select_window.active
case @step
when 0
@help_window.set_text("Choose the main Character.")
when 1
@help_window.set_text("Choose the first Partner")
when 2
@help_window.set_text("Choose the second Partner")
when 3
@help_window.set_text("Choose the third Partner")
end
end
@select_window.update
@name_window.update
@help_window.update
if @select_window.active
update_select
return
end
if @name_window.active
update_name
return
end
end
#--------------------------------------------------------------------------
# ? update_select
#--------------------------------------------------------------------------
def update_select
if Input.trigger?(Input::C)
if @select_window.selected?
$game_system.se_play($data_system.buzzer_se)
return
end
if @select_window.actor == nil
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@valid_window.actor = @select_window.actor
@select_window.active = false
@name_window.index = 0
@name_window.active = true
return
end
if Input.trigger?(Input::B)
if $game_party.actors.empty? or @step == 0
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.cancel_se)
@step -= 1
id = $game_party.actors[@step].id
$game_party.remove_actor(id)
@select_window.select(@selected_indexes[@step-1], false)
return
end
end
#--------------------------------------------------------------------------
# ? update_name
#--------------------------------------------------------------------------
def update_name
if Input.trigger?(Input::C)
if @name_window.index < 60
$game_system.se_play($data_system.decision_se)
@valid_window.add(@name_window.character)
elsif @name_window.index == 60
$game_system.se_play($data_system.cancel_se)
@valid_window.actor = nil
@select_window.active = true
@name_window.index = -1
@name_window.active = false
else
$game_system.se_play($data_system.decision_se)
@select_window.active = true
@select_window.select
@name_window.index = -1
@name_window.active = false
$game_party.add_actor(@select_window.actor.id)
$game_party.actors[@step].name = @valid_window.name
@selected_indexes.push(@select_window.index)
@step += 1
@valid_window.actor = nil
if @step == @party_size
$scene = Scene_Map.new
end
end
return
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@valid_window.back
return
end
end
end
HOW TO USE
first, you need to decide what characters you will display on the select screen, go in the database and write down the id of the characters you want.
(example : 1 arshes, 7 gloria, etc...)
once you have those number, use the call script command in an event, and write them in that way : (I took some other to have 6 characters)
Code:
ids = [1, 7, 5, 6, 4, 2]
then, you have to decide how many characters the player will be able to add to the party, let's say 4
so add this after the 'ids = ' thing :
I sorta love this script, but big problem I see...
when you want to choose from more than 6 IDs, the main window that "SHOULD" scroll down to show all the characters, does not. I also can't see why it can't Any reason why?
RE: Character Select Script - DerVVulfman - 02-26-2017
Because Selwyn did not include redesigned versions of the 'top_row', the 'top_row=' and 'page_row_max' methods within Window_CharSelect. Couple that with a incorrectly designed 'update_cursor_rect' because he DID neglect to include reference to the redesiged methods.
So.... add the following methods to Window_CharSelect:
Code:
#--------------------------------------------------------------------------
# * Get Top Row
#--------------------------------------------------------------------------
def top_row
# Divide y-coordinate of window contents transfer origin by 1 row
# height of 192
return self.oy / 192
end
#--------------------------------------------------------------------------
# * Set Top Row
# row : row shown on top
#--------------------------------------------------------------------------
def top_row=(row)
# If row is less than 0, change it to 0
if row < 0
row = 0
end
# If row exceeds row_max - 1, change it to row_max - 1
if row > row_max - 1
row = row_max - 1
end
# Multiply 1 row height by 32 for y-coordinate of window contents
# transfer origin
self.oy = row * 192
end
#--------------------------------------------------------------------------
# * Get Number of Rows Displayable on 1 Page
#--------------------------------------------------------------------------
def page_row_max
# Subtract a frame height of 32 from the window height, and divide it by
# 1 row height of 32
return (self.height - 32) / 192
end
And replace the 'update_cursor_rect' in the class with THIS one:
Code:
#--------------------------------------------------------------------------
# (>^_^)> update_cursor_rect
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
return
end
# Get current row
row = @index / @column_max
# If current row is before top row
if row < self.top_row
# Scroll so that current row becomes top row
self.top_row = row
end
# If current row is more to back than back row
if row > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = row - (self.page_row_max - 1)
end
# Calculate cursor width
cursor_width = self.width / @column_max - 32
# Calculate cursor coordinates
x = @index % @column_max * (148 + 1)
y = @index / @column_max * 192 - self.oy
# Update cursor rectangle
self.cursor_rect.set(x, y, 149, 192)
end