KyoNewParty XP
version 1.0.1
by Kyonides-Arkanthos
alias Kyonides, Shadowball
Features
Just a simple menu where you can select any hero from your actors database. You cannot make a party bigger or larger than 4.
(See Constant MAXSIZE found in line 27 to edit this size limit at will)
You can also exclude some actors / heroes from the actors database if you like.
Instructions
See script comments.
KyoNewParty XP Script
Code:
=begin
* KyoNewParty XP
by Kyonides-Arkanthos alias Kyonides, Shadowball
version 1.0.1 - 03.17.2010
Plug & Play Script
*** INSTRUCTIONS ***
You can begin a new journey with your party right after you press ENTER or
INTRO IF you have at least a single member.
Remember you cannot have more than the party members maximum size.
(See Constant MAXSIZE in KyoParty module - line 30)
The instance variable @hidden (an Array) stores all the actors or heroes you
don't want the player to choose at the beginning of the game for any reason.
*** KEYS ***
ESCAPE or Q - Exits party scene
SHIFT - Chooses a Hero
ENTER or INTRO - Finishes Hero selection, a new game begins
=end
module KyoParty
Files = File.exist?('Game.rxproj') ? RPG::Cache : Cache
MAXSIZE = 4
@members = []
@hidden = [2,4]
@all_actors = load_data('Data/Actors.rxdata').compact
@actors = []
@all_actors.each {|actor| @actors << actor if !@hidden.include? actor.id}
def self.members; @members end
def self.hidden_members; @hidden end
def self.actors; @actors end
end
module Coordinates
def x=(value); @x, self.viewport.rect.x = value, value end
def y=(value); @y, self.viewport.rect.y = value, value end
def x_y(value1, value2)
@x, self.viewport.rect.x = value1, value1
@y, self.viewport.rect.y = value2, value2
end
end
class Window_Base
def x_y(value1, value2); self.x, self.y = value1, value2 end
end
class Array
def now; return if @pos.nil?; return self[@pos] end
def now=(value); @pos = value end
def index_now; return !@pos.nil? ? @pos : 0 ; end
def next
@pos = (@pos.nil? or @pos == self.size-1) ? 0 : @pos+1
return self[@pos]
end
alias :succ :next
def reset_pos!; @pos = nil if !@pos.nil?; end
def next=(value); return self[@pos] = value; end
def prev
@pos = (@pos.nil? or @pos == 0) ? self.size-1 : @pos-1
return self[@pos]
end
alias :previous :prev
def prev=(value); return self[@pos] = value; end
end
class Game_Party
def setup_starting_members
@actors = []
for i in KyoParty.members
@actors.push($game_actors[i])
end
end
end
class Sprite_KyoNewHero < Sprite
include Coordinates
def initialize(index)
super(Viewport.new(16,220,612,300))
viewport.z = 200
actor = KyoParty.actors[index]
self.bitmap = Bitmap.new(28, 48)
bitmap = KyoParty::Files.character actor.character_name, actor.character_hue
self.bitmap.blt(0, 0, bitmap, Rect.new(0,0,28,48))
self.ox, self.oy = 0, 0
end
end
def update
x_y(@pos_x.prev, @pos_y.prev) if Input.trigger?(Input::LEFT)
if Input.trigger?(Input::RIGHT) or @pos_x.now.nil?
x_y(@pos_x.next, @pos_y.next)
end
end
end
class Window_Base
def show_actor_name(actor, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 160, 24, 'Nombre:')
self.contents.font.color = normal_color
self.contents.draw_text(x+80, y, 160, 24, actor.name)
end
def show_actor_class(actor, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 216, 24, 'Clase:')
self.contents.font.color = normal_color
self.contents.draw_text(x+80, y, 216, 24, actor.class_name)
end
end
class Window_KyoHelp < Window_Base
def initialize
super(0, 0, 640, 56)
self.contents = Bitmap.new(width - 32, height - 32)
end
def set_text(text, align = 0)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 24, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
end
class Window_KyoCharacterInfo < Window_Base
attr_accessor :index
def initialize(x, y, index=0)
super(x, y, 256, 128)
self.contents = Bitmap.new(224, 96)
self.windowskin = KyoParty::Files.windowskin 'WS Black'
@index, self.visible = [], true
KyoParty.actors.each{|actor| @index.push Game_Actor.new(actor.id)}
@actor = @index.next
refresh
end
def refresh
if Input.trigger?(Input::RIGHT)# or Input.press?(Input::RIGHT)
@actor = @index.next
elsif Input.trigger?(Input::LEFT)# or Input.press?(Input::LEFT)
@actor = @index.prev
end
if @index.index_now != @index_now
self.contents.clear
show_actor_name(@actor, 0, 0)
show_actor_class(@actor, 0, 24)
draw_actor_hp(@actor, 0, 48)
draw_actor_sp(@actor, 0, 72)
@index_now = @index.index_now
end
end
def refresh_names_list(actor)
@actors << actor
if @actors.size > 0 and @actors.size != @size
self.contents.clear
@size, y = @actors.size, [0, 24, 48, 72]
@actors.each do |actor|
self.contents.draw_text(0, y.next, 160, 24, actor.name)
end
end
end
end
class Scene_Title
def command_new_game; $scene = Scene_KyoNewParty.new end
end
class Scene_Base
def main
start
Graphics.transition
loop do
Graphics.update
Input.update
update
break if $scene != self
end
Graphics.freeze
terminate
end
def update
@actor_window.refresh
@cursor_sprite.update
if @actor_window.index != @index_now
@index_now = @actor_window.index
@actors.each do |sprite|
sprite.opacity = same_index?(sprite) ? 255 : 140
end
end
$scene = Scene_Title.new if Input.trigger? Input::B
if Input.trigger? Input::SHIFT
actor = Game_Actor.new(KyoParty.actors[@actor_window.index].id)
@members_window.refresh_names_list(actor)
if KyoParty.members.size < KyoParty::MAXSIZE
KyoParty.members << KyoParty.actors[@actor_window.index].id
end
elsif Input.trigger? Input::C
switch_to_map if KyoParty.members.size > 0
end
end
def same_index?(sprite); @actors.index(sprite) == @actor_window.index end