$imported = {} if $imported.nil?
$imported["Heirukichi_SortActorsFromation"] = true
module HSF
#=======================================================================
# Set this value to true if you want to sort actors alphabetically
# Set it to false if you want to sort them by ID.
# Default is true.
#-----------------------------------------------------------------------
# * NOTE
#-----------------------------------------------------------------------
# Sorting them alphabetically is more time-consuming than sorting
# them by ID so I strongly recommend sorting them in your database
# and then sorting them by ID.
#=======================================================================
SORT_ALPHABETICALLY = true
#=======================================================================
# Set this value to true if you want to sort actors more efficiently.
# It only works for alphabetical sorting. Default is true.
#=======================================================================
EFFICIENT_SORTING = true
#=======================================================================
# Do not modify after this point!
#=======================================================================
def self.compare(a, b)
return if (a.nil? || b.nil?)
return if ($data_actors[a].nil? || $data_actors[b].nil?)
EFFICIENT_SORTING ? pcompare(a, b) : $data_actors[a].name <=> $data_actors[b].name
end
def self.initialize_actors_priority
return unless @actors_priority.nil?
@actors_priority = Array.new($data_actors.length+1) {|i| i}
$data_actors.each.with_index do |a, i|
next if (i==0)
p = 0
$data_actors.each.with_index do |b, j|
next if (j==0)
next if (a==b)
p += 1 if a.name > b.name
end
@actors_priority[i] = p
end
end
def self.priority
@actors_priority
end
def self.pcompare(a, b)
return if (a.nil? || b.nil?)
return if ($data_actors[a].nil? || $data_actors[b].nil?)
initialize_actors_priority
priority[a] <=> priority[b]
end
end
if $imported["YEA-PartySystem"]
#===========================================================================
# * Game Party class
#===========================================================================
class Game_Party
alias hrk_rearrange_actors_old rearrange_actors
def rearrange_actors
hrk_rearrange_actors_old
sz = @battle_members_array.length
sorted = @actors.slice!(sz, @actors.length - sz)
if HSF::SORT_ALPHABETICALLY
@actors += sorted.sort {|a, b| HSF.compare(a, b)}
else
@actors += sorted.sort
end
end
end
#===========================================================================
# * Scene Party class
#===========================================================================
class Scene_Party
alias hrk_start_yep_old start
def start
hrk_start_yep_old
window_refresh
end
end
#===========================================================================
# * Scene Manu class
#===========================================================================
class Scene_Menu
alias hrk_start_old start
def start
hrk_start_old
HSF.initialize_actors_priority
end
end
end