#---------------------------------------------------------------
# PARTY CHANGING SCRIPT V2
# made by: Sir Edeon X
#---------------------------------------------------------------
MINIMUN_PARTY_SIZE_VARIABLE = 1
MAXIMUM_PARTY_SIZE_VARIABLE = 2
PARTY_OF_4 = true
RESERVE_OF_4 = false
ADD_TO_RESERVE_IF_PARTY_FULL = true
#---------------------------------------------------------------
# EXTENSION TO GAME_PARTY
# add member to reserve if party is full
#---------------------------------------------------------------
class Game_Party
#------------------------------------------------
attr_accessor :actors
#------------------------------------------------
def add_actor(actor_id)
actor = $game_actors[actor_id]
if @actors.size < $game_variables[MAXIMUM_PARTY_SIZE_VARIABLE] and not @actors.include?(actor)
@actors.push(actor)
$game_player.refresh
end
if @actors.size == $game_variables[MAXIMUM_PARTY_SIZE_VARIABLE] and not $game_system.reserve.include?(actor)
if ADD_TO_RESERVE_IF_PARTY_FULL and not @actors.include?(actor)
$game_system.reserve.push(actor)
end
end
end
end
#---------------------------------------------------------------
# EXTENSION TO GAME_SYSTEM
# saves reserve and mandatory members
#---------------------------------------------------------------
class Game_System
#------------------------------------------------
attr_reader :reserve
attr_reader :mandatory
#------------------------------------------------
alias initialize_Party initialize
def initialize
initialize_Party
@reserve = []
@mandatory = []
end
#------------------------------------------------
def lock_char(index)
actor = $game_actors[index]
if actor != nil and not @mandatory.include?(actor)
@mandatory.push(actor)
end
end
#------------------------------------------------
def unlock_char(index)
actor = $game_actors[index]
if actor != nil and @mandatory.include?(actor)
@mandatory.delete(actor)
end
end
#------------------------------------------------
def cant_leave(actor)
if @mandatory.include?(actor)
return true
end
return false
end
end
#---------------------------------------------------------------
# SCENE_PARTY
# switches party members
#---------------------------------------------------------------
class Scene_Party
#------------------------------------------------
def initialize
@party_max = $game_variables[MAXIMUM_PARTY_SIZE_VARIABLE]
@party_min = $game_variables[MINIMUN_PARTY_SIZE_VARIABLE]
end
#------------------------------------------------
def main
@spriteset = Spriteset_Map.new
@party_window = Window_Party.new
@reserve_window = Window_Reserve.new
if $game_party.actors.size == 0
@party_window.active = false
else
@reserve_window.active = false
end
@party_window.help_window = @status_window
@reserve_window.help_window = @status_window
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@reserve_window.dispose
@party_window.dispose
end
#------------------------------------------------
def update
@party_window.update
@reserve_window.update
if @party_window.active
update_party
return
end
if @reserve_window.active
update_reserve
return
end
end
#------------------------------------------------
def update_party
party_actor = @party_window.new_party[@party_window.index]
if Input.trigger?(Input::C)
if(party_actor != nil and $game_system.cant_leave(party_actor))
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
@party_window.active = false
@reserve_window.active = true
end
end
#------------------------
if Input.trigger?(Input::B)
new_party = @party_window.new_party
new_party.compact!
if new_party.size < @party_min or new_party.size >@party_max
$game_system.se_play($data_system.buzzer_se)
return
else
$game_system.se_play($data_system.decision_se)
$game_party.actors = new_party
$game_player.refresh
$scene = Scene_Menu.new(5)
end
end
end
#------------------------------------------------
def update_reserve
party_actor = @party_window.new_party[@party_window.index]
reserve_actor = @reserve_window.reserve[@reserve_window.index]
#------------------------
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@party_window.actor_change(reserve_actor)
@reserve_window.actor_change(party_actor)
@reserve_window.active = false
@party_window.active = true
end
#------------------------
if Input.trigger?(Input::B)
$game_system.se_play($data_system.decision_se)
@reserve_window.active = false
@party_window.active = true
return
end
end
end
#---------------------------------------------------------------
# WINDOW_PARTY
# shows party members
#---------------------------------------------------------------
class Window_Party < Window_Selectable
#------------------------------------------------
attr_reader :new_party
#------------------------------------------------
def initialize()
super(76, 7, 485, 466)
self.contents = Bitmap.new(width - 32, height - 32)
@new_party = $game_party.actors.clone
@item_max = 3
if PARTY_OF_4 == true
@item_max += 1
end
@index = 0
refresh
update_cursor_rect
end
#------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(0, -4, 140, 32, "In Party:")
if PARTY_OF_4 == true
aditive = 56
else
aditive = 106
end
for i in 0..@new_party.size - 1
actor = @new_party
if actor != nil
x = 100 * i + aditive
draw_actor_face(actor, x + 19, 121)
draw_actor_name(actor, x, 118)
draw_actor_level(actor, x - 10, 138)
draw_actor_hp_simple(actor, x - 21, 158)
if $game_system.cant_leave(actor)
self.contents.font.color = Color.new(255, 30, 0, 255)
self.contents.draw_text(x - 93, 178, 224, 32, "Can't switch", 1)
else
draw_actor_sp_simple(actor, x - 21, 178)
end
end
end
end
#------------------------------------------------
def actor_change(actor)
@new_party[@index] = actor
@new_party.compact!
refresh
end
#------------------------------------------------
def update_cursor_rect
if PARTY_OF_4 == true
aditive = 26
else
aditive = 76
end
self.cursor_rect.set(100 * @index + aditive, 24, 98, 180)
end
#------------------------------------------------
def update_help
@help_window.draw_actor_status(@new_party[@index])
end
#------------------------------------------------
def update
super
if self.active and @item_max > 0 and @index >= 0
if Input.repeat?(Input::RIGHT)
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
end
end
if Input.repeat?(Input::LEFT)
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
end
end
end
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end
end
#---------------------------------------------------------------
# WINDOW_RESERVE
# shows reserve members
#---------------------------------------------------------------
class Window_Reserve < Window_Selectable
#------------------------------------------------
attr_reader :reserve
#------------------------------------------------
def initialize
super(76, 233, 485, 240)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
@reserve = $game_system.reserve
@reserve.compact!
@item_max = 3
if RESERVE_OF_4 == true
@item_max += 1
end
@index = 0
self.active = false
refresh
update_cursor_rect
end
#------------------------------------------------
def refresh
self.contents.clear
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(0, -4, 160, 32, "In Reserve:")
if RESERVE_OF_4 == true
aditive = 56
else
aditive = 106
end
for i in 0..@reserve.size
actor = @reserve
if actor != nil
x = 100 * i + aditive
draw_actor_face(actor, x + 19, 121)
draw_actor_name(actor, x, 118)
draw_actor_level(actor, x - 10, 138)
draw_actor_hp_simple(actor, x - 21, 158)
if $game_system.cant_leave(actor)
self.contents.font.color = Color.new(255, 30, 0, 255)
self.contents.draw_text(x - 93, 178, 224, 32, "Can't switch", 1)
else
draw_actor_sp_simple(actor, x - 21, 178)
end
end
end
end
#------------------------------------------------
def update_cursor_rect
if not active
self.cursor_rect.empty
else
if RESERVE_OF_4 == true
aditive = 26
else
aditive = 76
end
self.cursor_rect.set(100 * @index + aditive, 24, 98, 180)
end
end
#------------------------------------------------
def actor_change(actor)
new_actor = @reserve[@index]
@reserve[@index] = actor
refresh
end
#------------------------------------------------
def update_help
@help_window.draw_actor_status(@reserve[@index])
end
#------------------------------------------------
def update
super
if self.active and @item_max > 0 and @index >= 0
if Input.repeat?(Input::RIGHT)
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
end
end
if Input.repeat?(Input::LEFT)
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
end
end
end
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end
end
#---------------------------------------------------------------
# WINDOW_BASE
# defines necessary functions
#---------------------------------------------------------------
class Window_Base < Window
def draw_actor_face(actor, x, y)
filename = "Graphics/Faces/" + actor.character_name + ".png"
bitmap = Bitmap.new(filename)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
#-----------------------------------------------------------
def draw_actor_hp_simple(actor, x, y, width = 144)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
if width - 32 >= 108
hp_x = x + width - 108
elsif width - 32 >= 48
hp_x = x + width - 48
end
hp_x -= 7
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
end
#-----------------------------------------------------------
def draw_actor_sp_simple(actor, x, y, width = 144)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
if width - 32 >= 108
sp_x = x + width - 108
elsif width - 32 >= 48
sp_x = x + width - 48
end
sp_x -= 7
self.contents.font.color = actor.sp == 0 ? knockout_color :
actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
end
end