![]()

Autor: Ayene [ Ten adres pocztowy jest chroniony przed spamowaniem. Aby go zobaczyć, konieczne jest włączenie obsługi JavaScript. ]

Kompatybilność:
RPG Maker VX

Krótki opis:
Skrypt pozwala na wybór klasy na początku gry. Może mieć również zastosowanie przy wyborze więcej niż jednego bohatera (maksymalnie tyle, ile może liczyć drużyna). Dodaje również opcje wyświetlenia dużego obrazka postaci oraz jej opisu.

Instrukcja:
Na początku gry wywołaj za pomocą polecenia "Script" w zdarzeniu:
$scene = Scene_CharacterSelect.new

Skrypt:
#===================================================================
# Wybór postaci II [VX]
# by Ayene
# 13.05.2011 ver 1.0
# www.ultimateam.pl
#===================================================================
# Opis:
# Skrypt pozwala na wybór klasy na początku gry. Może mieć również
# zastosowanie przy wyborze więcej niż jednego bohatera (maksymalnie tyle,
# ile może liczyć drużyna).
#===================================================================
# Instrukcja:
#===================================================================
# Na początku gry wywołaj za pomocą polecenia "Script" w zdarzeniu:
# $scene = Scene_CharacterSelect.new
#
#===================================================================
# Konfiguracja:
#===================================================================
module Ayene
module CharSel
# Tekst pomocy
HELP_TEXT = "Wybierz postać (SHIFT - opis postaci)"
# ID żeńskich postaci
GENDER_FEMALE = [2,4,7]
# ID męskich postaci
GENDER_MALE = [1,3,5,6,8]
# Nazwy podstawowych statystyk
STATS = ["Atak", "Obrona", "Wola", "Szybkość"]
# Wyświetlenie obrazka postaci. Obrazek o nazwie klasy postaci
# należy umieścić w folderze Graphics/Pictures, np. nazwa klasy to
# "gnom", wówczas do folderu trzeba wrzucić plik "gnom.png".
ACTOR_BATTLER = true
# Opis bohatera
ACTOR_DESCRIPTION = { # <-nie usuwać
# ID postaci => "Opis bohatera"
1 => "Tutaj |opis bohatera. |Kreska pionowa to przejście |do następnej linijki",
2 => "Tutaj |opis bohatera. |Kreska pionowa to przejście |do następnej linijki",
3 => "Tutaj |opis bohatera. |Kreska pionowa to przejście |do następnej linijki",
4 => "Tutaj |opis bohatera. |Kreska pionowa to przejście |do następnej linijki",
5 => "Tutaj |opis bohatera. |Kreska pionowa to przejście |do następnej linijki",
# By przejść do następnej linijki wystarczy użyć znaku |
# Maksymalnie 12 linijek tekstu.
} # <-nie usuwać
end
end
#--------------------------------------------------------------------------
# Window_Gender_Choose
#--------------------------------------------------------------------------
class Window_Choose_Gender < Window_Command
def initialize
commands = ["Mężczyźni", "Kobiety"]
width = 300
super(width, commands, 2, 0)
self.x = 267 - (width / 2)
@commands = commands
draw_item(0)
draw_item(1)
self.index = 0
end
def draw_item(index)
self.contents.font.color = normal_color
self.contents.draw_text(8 + index * 150, -5, 100, 32, @commands[index], 1)
end
end
#--------------------------------------------------------------------------
# Window_Choose_Character
#--------------------------------------------------------------------------
class Window_Choose_Character < Window_Selectable
include Ayene::CharSel
def initialize
super(0, 56, 544, 360)
self.index = 0
self.visible = false
end
def create_contents(gender=0)
self.contents.dispose
@data = []
case gender
when 0
item_max = GENDER_MALE.size
for i in 0...item_max
actor_id = $data_actors[GENDER_MALE[i]].id
if !$game_party.actors.include?(actor_id)
@data.push(actor_id)
end
end
when 1
item_max = GENDER_FEMALE.size
for i in 0...item_max
actor_id = $data_actors[GENDER_FEMALE[i]].id
if !$game_party.actors.include?(actor_id)
@data.push(actor_id)
end
end
end
@item_max = @data.size
self.contents = Bitmap.new(width - 32, @item_max * 110 - 5)
end
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
def draw_item(index)
self.contents.font.color = normal_color
actor = $data_actors[@data[index]]
draw_actor_face(actor, 8, 6 + index * 110 - self.oy)
draw_actor_class(actor, 128, 6 + index * 110 - self.oy)
draw_actor_basis_hp_sp(actor, 128, WLH + 6 + index * 110 - self.oy)
draw_actor_stats(actor, 348, 6 + index * 110 - self.oy)
draw_actor_graphic(actor, 298, 68 + index * 110 - self.oy)
end
def draw_actor_class(actor, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 108, WLH, $data_classes[actor.class_id].name)
end
def draw_actor_basis_hp_sp(actor, x, y)
gc1 = hp_gauge_color1
gc2 = hp_gauge_color2
self.contents.gradient_fill_rect(x, y + WLH - 8, 120, 6, gc1, gc2)
gc1 = mp_gauge_color1
gc2 = mp_gauge_color2
self.contents.gradient_fill_rect(x, y + WLH * 2 - 8, 120, 6, gc1, gc2)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, WLH, "HP")
self.contents.draw_text(x, y + WLH, 32, WLH, "MP")
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 108, WLH, actor.parameters[0, actor.initial_level], 2)
self.contents.draw_text(x, y + WLH, 108, WLH, actor.parameters[1, actor.initial_level], 2)
end
def draw_actor_stats(actor, x, y)
self.contents.font.color = system_color
for i in 0...STATS.size
self.contents.draw_text(x, y + WLH * i, 84, WLH, STATS[i])
end
self.contents.font.color = normal_color
for i in 2...6
self.contents.draw_text(x + 32, y + WLH * (i - 2), 108, WLH, actor.parameters[i, actor.initial_level], 2)
end
end
def update_cursor
row = @index / @column_max
if @index < 0
self.cursor_rect.empty
return
elsif row < self.top_row
self.top_row = row
elsif row > self.top_row + (self.page_row_max - 1)
self.top_row = row - (self.page_row_max - 1)
end
if @index < @item_max
self.cursor_rect.set(0, @index * 110 - self.oy, contents.width, 110)
else
self.top_row = 0
self.cursor_rect.set(0, 0, contents.width, self.page_row_max * 110)
end
end
def page_row_max
return 3
end
def top_row
return self.oy / 110
end
def top_row=(row)
row = 0 if row < 0
row = row_max - 1 if row > row_max - 1
self.oy = row * 110
end
end
#--------------------------------------------------------------------------
# Window_Character_Info
#--------------------------------------------------------------------------
class Window_Character_Info < Window_Base
include Ayene::CharSel
def initialize
super(0, 56, 544, 360)
end
def refresh(actor_id)
self.contents.clear
actor = $data_actors[actor_id]
actor_class = $data_classes[actor.class_id]
self.contents.draw_text(40, 22, 108, WLH, actor_class.name,1)
draw_actor_battler(actor_class, 0, 0) if ACTOR_BATTLER rescue nil
draw_actor_description(actor_id) rescue nil
end
def draw_actor_battler(actor_class, x, y)
bitmap = Cache.picture(actor_class.name)
rect = Rect.new(0, 0, bitmap.width, bitmap.height)
y = 160 - bitmap.height / 2
self.contents.blt(x, y, bitmap, rect)
bitmap.dispose
end
def draw_actor_description(actor_id)
text = ACTOR_DESCRIPTION[actor_id].split(/\|/)
for i in 0...text.size
self.contents.font.color = normal_color
self.contents.draw_text(200, 22 + i * 24, self.width - 40, WLH, text[i])
break if (i * WLH) > (self.height - 100)
end
end
end
#--------------------------------------------------------------------------
# Scene_CharacterSelect
#--------------------------------------------------------------------------
class Scene_CharacterSelect < Scene_Base
include Ayene::CharSel
def start
super
create_menu_background
@help_window = Window_Help.new
@help_window.set_text(HELP_TEXT, 1)
@help_window.visible = false
@gender_window = Window_Choose_Gender.new
@character_window = Window_Choose_Character.new
@info_window = Window_Character_Info.new
@info_window.visible = false
end
def terminate
super
dispose_menu_background
@help_window.dispose
@gender_window.dispose
@character_window.dispose
@info_window.dispose
end
def return_scene
$scene = Scene_Map.new
end
def update
super
update_menu_background
@help_window.update
if @gender_window.active
update_gender_selection
elsif @character_window.active
update_character_selection
elsif @info_window.active
update_info_window
end
end
def update_gender_selection
@gender_window.update
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::C)
Sound.play_decision
show_character_window(@gender_window.index)
end
end
def show_character_window(index)
@gender_window.active = false
@gender_window.visible = false
@help_window.visible = true
@character_window.visible = true
@character_window.active = true
@character_window.create_contents(index)
@character_window.refresh
end
def update_character_selection
@character_window.update
if Input.trigger?(Input::B)
Sound.play_cancel
hide_character_window
elsif Input.trigger?(Input::C)
determine_character
if $game_party.members.size < $game_party.party_size
Sound.play_decision
$game_party.add_actor(@actor_id)
return_scene
else
Sound.play_buzzer
end
elsif Input.trigger?(Input::A)
determine_character
Sound.play_decision
@character_window.active = false
@character_window.visible = false
@info_window.refresh(@actor_id)
@info_window.visible = true
@info_window.active = true
end
end
def determine_character
actor_index = @character_window.index
data = []
case @gender_window.index
when 0
item_max = GENDER_MALE.size
for i in 0...item_max
actor_id = $data_actors[GENDER_MALE[i]].id
if !$game_party.actors.include?(actor_id)
data.push(actor_id)
end
end
when 1
item_max = GENDER_FEMALE.size
for i in 0...item_max
actor_id = $data_actors[GENDER_FEMALE[i]].id
if !$game_party.actors.include?(actor_id)
data.push(actor_id)
end
end
end
@actor_id = $data_actors[data[actor_index]].id
end
def hide_character_window
@gender_window.active = true
@gender_window.visible = true
@help_window.visible = false
@character_window.visible = false
@character_window.active = false
@character_window.index = 0
end
def update_info_window
@info_window.update
if Input.trigger?(Input::B) or Input.trigger?(Input::A)
Sound.play_cancel
@info_window.visible = false
@info_window.active = false
@character_window.visible = true
@character_window.active = true
end
end
end
#--------------------------------------------------------------------------
# Game_Party
#--------------------------------------------------------------------------
class Game_Party < Game_Unit
attr_reader :actors
def party_size
return MAX_MEMBERS
end
end

Dodatkowe informacje:
1. Wklej skrypt nad "Main" w Edytorze Skryptu.
2. Reszta instrukcji znajduje się w treści skryptu.