Skip to content

Instantly share code, notes, and snippets.

@themaxhero
Last active March 8, 2018 00:25
Show Gist options
  • Save themaxhero/d05e964a1a98e042416e733cf0763857 to your computer and use it in GitHub Desktop.
Save themaxhero/d05e964a1a98e042416e733cf0763857 to your computer and use it in GitHub Desktop.
#===============================================================================
# Maxhero's Party Editor
#-------------------------------------------------------------------------------
=begin
Terms of Use:
—If use don't forget to quote my name in credits.
—You're free to modify and redistribute this script keeping this Header.
Instructios:
—Edit @REM_BLOCK to set the Party-Fixed Characters
—To enable actors in game use the command:
PartyManager.enable_actor(id)
—To disable actors in game use the command:
PartyManager.disable_actor(id)
—To lock a character in party use the command:
PartyManager.lock(id)
—To unlock a character in party use the command:
PartyManager.unlock(id)
replace "id" by the actor id in database
—To start the PartyManager with add mode,
create a event calling the Script:
SceneManager.call(Scene_PartyManager,:add)
—To start the PartyManager with remove mode, create a event calling the Script:
SceneManager.call(Scene_PartyManager,:remove)
=end
#===============================================================================
module PartyManager
extend self
@REM_BLOCK = [1]
@AVALIABLE_ACTORS = [2,3,4,5,6,7,8,9]
@TEXTS = [
"Which character you want to add?",
"Which character you want to remove?",
"You have all the avaliable characters.",
"There is no character to remove."
]
def blocked_actors
return @REM_BLOCK
end
def avaliable_actors
return @AVALIABLE_ACTORS
end
def enable_actor(id)
@AVALIABLE_ACTORS << id
end
def disable_actor(id)
@AVALIABLE_ACTORS.delete(id)
end
def lock(id)
@REM_BLOCK << id
end
def unlock(id)
@REM_BLOCK.delete(id)
end
def have_all_avaliable_chars_text
return @TEXTS[2]
end
def no_char_to_remove
return @TEXTS[3]
end
def add_help
return @TEXTS[0]
end
def remove_help
return @TEXTS[1]
end
def load_blocked_actors(array)
@REM_BLOCK = array
end
def load_avaliable_actors(array)
@AVALIABLE_ACTORS = array
end
end
#===============================================================================
# DataManager Mod
#===============================================================================
module DataManager
class << self
alias maxpm_msv make_save_contents
alias maxpm_esv extract_save_contents
def make_save_contents
contents = maxpm_msv
contents[:blocked_actors] = PartyManager.blocked_actors
contents[:avaliable_actors] = PartyManager.blocked_actors
contents
end
def extract_save_contents(contents)
maxpm_esv(contents)
PartyManager.load_blocked_actors(contents[:blocked_actors])
PartyManager.load_avaliable_actors(contents[:avaliable_actors])
end
end
end
#===============================================================================
# SceneManager Mod
#===============================================================================
module SceneManager
def self.call(scene_class, args=nil)
@stack.push(@scene)
@scene = scene_class.new(*args)
end
end
#===============================================================================
# Character Information Window
#===============================================================================
class Window_Char_Info < Window_Base
def initialize
super(160, 0, Graphics.width-160, Graphics.height)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
self.contents.clear
end
def draw_char_info(actor_id)
draw_actor_name($game_actors[actor_id], 0, 0)
draw_actor_level($game_actors[actor_id], 0, 40)
draw_actor_class($game_actors[actor_id], 0, 20)
draw_actor_face($game_actors[actor_id], 0, 60)
draw_actor_hp($game_actors[actor_id], 0, 156)
draw_actor_mp($game_actors[actor_id], 0, 176)
draw_actor_param($game_actors[actor_id], 0, 196, 0)
draw_actor_param($game_actors[actor_id], 0, 216, 1)
draw_actor_param($game_actors[actor_id], 0, 236, 2)
draw_actor_param($game_actors[actor_id], 0, 256, 3)
draw_actor_param($game_actors[actor_id], 0, 276, 4)
draw_actor_param($game_actors[actor_id], 0, 296, 5)
draw_actor_param($game_actors[actor_id], self.width/2,196,6)
draw_actor_param($game_actors[actor_id], self.width/2,216,7)
draw_equipments(170, 0, $game_actors[actor_id])
end
def draw_equipments(x, y, actor)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, 32, Vocab.equip)
for i in 0..4
draw_item_name(actor.equips[i], x + 16, y + 32 * (i + 1))
end
end
end
#===============================================================================
# Window_PMHelp
#===============================================================================
class Window_PMHelp < Window_Base
attr_accessor :host
def initialize(hostage)
super(0, 0, Graphics.width, 72)
@host = hostage
end
def set_text(text)
if text != @text
@text = text
refresh
end
end
def clear
set_text("")
end
def set_item(item)
set_text(item ? item.description : "")
end
def refresh
contents.clear
draw_text_ex(4, 0, @text)
end
def update
super
if Input.trigger?(:
@host.return_to_map
end
end
end
#===============================================================================
# Window_PMCommand
#===============================================================================
class Window_PMCommand < Window_Command
attr_accessor :current_actor,:behavior,:backsignal,:host
def initialize(hostage)
super(0, 32)
@host = hostage
@behavior = @host.behavior
@backsignal = false
party = []
$game_party.members.each{|item| party << item.id}
case @behavior
when :add
@actor_list = (PartyManager.avaliable_actors - party)
when :remove
@actor_list = (party - PartyManager.blocked_actors)
end
update_placement
self.openness = 0
open
end
def window_width
return 160
end
def getMyHeight
if (self.y+self.height) > Graphics.height
(line_height*14)+10
else
line_height*(@actor_list.size+1)
end
end
def update_placement
self.height =
self.x = (Graphics.width - width) / 2
self.y = (Graphics.height * 1.6 - height) / 2
end
def update
super
@current_actor = @actor_list[@index]
if Input.trigger?(:
@host.return_to_map
end
end
def common_handler
if @behavior == :add
$game_party.add_actor(@current_actor)
else
$game_party.remove_actor(@current_actor)
end
end
def make_command_list
#set_handler(symbol, method)
case @behavior
when :add
for i in @actor_list
actor = $game_actors[i]
add_command(actor.name, actor.name.to_sym)
unless actor.nil?
set_handler(actor.name.to_sym, Proc.new{@host.decision})
end
end
when :remove
for i in @actor_list
actor = $game_actors[i]
add_command(actor.name, actor.name.to_sym)
set_handler(actor.name.to_sym, Proc.new{@host.decision})
end
end
end
end
#===============================================================================
# Scene_PartyManager
#===============================================================================
class Scene_PartyManager < Scene_MenuBase
attr_accessor :behavior
def initialize(behavior)
@behavior = behavior
end
def start
super
@L = verification
unless @L
case @behavior
when :add;
create_add
when :remove;
create_remove
end
else
create_warn
end
end
def verification
party = $game_party.members.collect{|item| item.id}
x = (party - PartyManager.blocked_actors).empty?
y = (PartyManager.avaliable_actors - party).empty?
return true if (@behavior == :remove && x)
return true if (@behavior == :add && y)
return false
end
def create_add
@help_win = Window_Help.new
@com_win = Window_PMCommand.new(self)
@com_win.make_command_list
@help_win.set_text(PartyManager.add_help)
create_info_window
end
def create_remove
@help_win = Window_Help.new
@com_win = Window_PMCommand.new(self)
@com_win.make_command_list
@help_win.set_text(PartyManager.remove_help)
create_info_window
end
def decision
@com_win.common_handler
SceneManager.goto(Scene_Map)
end
def create_info_window
@info_win = Window_Char_Info.new
@info_win.height = Graphics.height-@help_win.height
@info_win.y = @help_win.height
@com_win.x = 0
@com_win.y = @help_win.height
end
def create_warn
@help_win = Window_PMHelp.new(self)
@help_win.y = (Graphics.height/2)-(@help_win.height/2)
@help_win.opacity = 0
case @behavior
when :add;
@help_win.set_text(PartyManager.have_all_avaliable_chars_text)
when :remove;
@help_win.set_text(PartyManager.no_char_to_remove)
end
end
def update_warn
@help_win.refresh
@help_win.update
end
def return_to_map;
SceneManager.goto(Scene_Map);
end
def update_main
@com_win.refresh
Input.update
@com_win.update
Input.update
@info_win.refresh
@info_win.draw_char_info(@com_win.current_actor)
end
def update
super
@L ? update_warn : update_main
end
def terminate
super
unless @L
@com_win.dispose
@info_win.dispose
end
@help_win.dispose
dispose_background
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment