ГлавнаяФорумRPG MakerСкрипты/ПлагиныRPG Maker XPУлучшающие или добавляющее новое скриптыНеограниченная партия [XP]
Войти на сайт
×
ТЕМА: Неограниченная партия [XP]
Неограниченная партия [XP] 10 года 3 мес. назад #71897
|
После долгой работы с Ace и возвращения к XP я понял, что мне очень не хватает возможностей неограниченной партии, реализованной там. Немного курения мануалов, шаманства с имеющимися скриптами, и вот вам результат
Скрипт позволяет добавлять в партию сколько угодно персонажей, при этом сражаться из них будут только четверо, поставленных первыми. Изменение порядка достигается так: открываем окно статуса и жмём пробел или Enter - персонаж становится лидером (к сожалению, более удачного способа я не подобрал). В отличие от Ace, опыт получают только четверо реально участвовавших в бою: это сделано для совместимости с боёвками (чтобы не переписывать фазу боя). Собственно, скрипт: =begin
Скрипт, реализующий партию в стиле Ace: с неограниченным количеством
участников и выбором из них четырёх боевых единиц.
Автор - Cerberus.
Благодарность caveman за помощь с отладкой.
=end
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :real_actors
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def actors
@real_actors[0, 4]
end
def initialize
# Create actor array
@real_actors = []
# Initialize amount of gold and steps
@gold = 0
@steps = 0
# Create amount in possession hash for items, weapons, and armor
@items = {}
@weapons = {}
@armors = {}
end
#--------------------------------------------------------------------------
# * Initial Party Setup
#--------------------------------------------------------------------------
def setup_starting_members
@real_actors = []
for i in $data_system.party_members
@real_actors.push($game_actors[i])
end
end
#--------------------------------------------------------------------------
# * Battle Test Party Setup
#--------------------------------------------------------------------------
def setup_battle_test_members
@real_actors = []
for battler in $data_system.test_battlers
actor = $game_actors[battler.actor_id]
actor.level = battler.level
gain_weapon(battler.weapon_id, 1)
gain_armor(battler.armor1_id, 1)
gain_armor(battler.armor2_id, 1)
gain_armor(battler.armor3_id, 1)
gain_armor(battler.armor4_id, 1)
actor.equip(0, battler.weapon_id)
actor.equip(1, battler.armor1_id)
actor.equip(2, battler.armor2_id)
actor.equip(3, battler.armor3_id)
actor.equip(4, battler.armor4_id)
actor.recover_all
@real_actors.push(actor)
end
@items = {}
for i in 1...$data_items.size
if $data_items[i].name != ""
occasion = $data_items[i].occasion
if occasion == 0 or occasion == 1
@items[i] = 99
end
end
end
end
#--------------------------------------------------------------------------
# * Refresh Party Members
#--------------------------------------------------------------------------
def refresh
# Actor objects split from $game_actors right after loading game data
# Avoid this problem by resetting the actors each time data is loaded.
new_actors = []
for i in 0...@real_actors.size
if $data_actors[@real_actors[i].id] != nil
new_actors.push($game_actors[@real_actors[i].id])
end
end
@real_actors = new_actors
end
#--------------------------------------------------------------------------
# * Getting Maximum Level
#--------------------------------------------------------------------------
def max_level
# If 0 members are in the party
if @real_actors.size == 0
return 0
end
# Initialize local variable: level
level = 0
# Get maximum level of party members
for actor in @real_actors
if level < actor.level
level = actor.level
end
end
return level
end
#--------------------------------------------------------------------------
# * Add an Actor
# actor_id : actor ID
#--------------------------------------------------------------------------
def add_actor(actor_id)
# Get actor
actor = $game_actors[actor_id]
# If this actor is not in the party
if not @real_actors.include?(actor)
# Add actor
@real_actors.push(actor)
# Refresh player
$game_player.refresh
end
end
#--------------------------------------------------------------------------
# * Remove Actor
# actor_id : actor ID
#--------------------------------------------------------------------------
def remove_actor(actor_id)
# Delete actor
@real_actors.delete($game_actors[actor_id])
# Refresh player
$game_player.refresh
end
#--------------------------------------------------------------------------
# * Clear All Member Actions
#--------------------------------------------------------------------------
def clear_actions
# Clear All Member Actions
for actor in @real_actors
actor.current_action.clear
end
end
#--------------------------------------------------------------------------
# * Determine if Command is Inputable
#--------------------------------------------------------------------------
def inputable?
# Return true if input is possible for one person as well
for actor in @real_actors
if actor.inputable?
return true
end
end
return false
end
#--------------------------------------------------------------------------
# * Determine Everyone is Dead
#--------------------------------------------------------------------------
def all_dead?
# If number of party members is 0
if $game_party.actors.size == 0
return false
end
# If an actor is in the party with 0 or more HP
for actor in @real_actors
if actor.hp > 0
return false
end
end
# All members dead
return true
end
#--------------------------------------------------------------------------
# * Slip Damage Check (for map)
#--------------------------------------------------------------------------
def check_map_slip_damage
for actor in @real_actors
if actor.hp > 0 and actor.slip_damage?
actor.hp -= [actor.maxhp / 100, 1].max
if actor.hp == 0
$game_system.se_play($data_system.actor_collapse_se)
end
$game_screen.start_flash(Color.new(255,0,0,128), 4)
$game_temp.gameover = $game_party.all_dead?
end
end
end
#--------------------------------------------------------------------------
# * Random Selection of Target Actor
# hp0 : limited to actors with 0 HP
#--------------------------------------------------------------------------
def random_target_actor(hp0 = false)
# Initialize roulette
roulette = []
# Loop
for actor in actors
# If it fits the conditions
if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
# Get actor class [position]
position = $data_classes[actor.class_id].position
# Front guard: n = 4; Mid guard: n = 3; Rear guard: n = 2
n = 4 - position
# Add actor to roulette n times
n.times do
roulette.push(actor)
end
end
end
# If roulette size is 0
if roulette.size == 0
return nil
end
# Spin the roulette, choose an actor
return roulette[rand(roulette.size)]
end
#--------------------------------------------------------------------------
# * Random Selection of Target Actor (HP 0)
#--------------------------------------------------------------------------
def random_target_actor_hp0
return random_target_actor(true)
end
#--------------------------------------------------------------------------
# * Smooth Selection of Target Actor
# actor_index : actor index
#--------------------------------------------------------------------------
def smooth_target_actor(actor_index)
# Get an actor
actor = @real_actors[actor_index]
# If an actor exists
if actor != nil and actor.exist?
return actor
end
# Loop
for actor in actors
# If an actor exists
if actor.exist?
return actor
end
end
end
end
#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
# This window displays party member status on the menu screen.
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@item_max = $game_party.real_actors.size
self.contents = Bitmap.new(width - 32, @item_max * 116)
for i in 0...@item_max
x = 64
y = i * 116
actor = $game_party.real_actors[i]
draw_actor_graphic(actor, x - 40, y + 80, (i >= 4 ? false : true))
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x, y + 32)
draw_actor_state(actor, x + 90, y + 32)
draw_actor_exp(actor, x, y + 64)
draw_actor_hp(actor, x + 236, y + 32)
draw_actor_sp(actor, x + 236, y + 64)
end
end
def top_row
return self.oy / 116
end
def top_row=(row)
if row < 0
row = 0
end
if row > row_max - 1
row = row_max - 1
end
self.oy = row * 116
end
def page_row_max
return 4
end
def update_cursor_rect
if @index < self.top_row
self.top_row = @index
end
# If current row is more to back than back row
if @index > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = @index - (self.page_row_max - 1)
end
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116 - self.oy, self.width - 32, 96)
end
end
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
when 5 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
return
end
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 1 # skill
# If this actor's action limit is 2 or more
if $game_party.real_actors[@status_window.index].restriction >= 2
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to skill screen
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@status_window.index)
return
end
end
end
end
#==============================================================================
# ** Scene_Status
#------------------------------------------------------------------------------
# This class performs status screen processing.
#==============================================================================
class Scene_Status
#--------------------------------------------------------------------------
# * Object Initialization
# actor_index : actor index
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get actor
@actor = $game_party.real_actors[@actor_index]
# Make status window
@status_window = Window_Status.new(@actor)
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@status_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(3)
return
end
# If R button was pressed
if Input.trigger?(Input::R)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To next actor
@actor_index += 1
@actor_index %= $game_party.real_actors.size
# Switch to different status screen
$scene = Scene_Status.new(@actor_index)
return
end
# If L button was pressed
if Input.trigger?(Input::L)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To previous actor
@actor_index += $game_party.real_actors.size - 1
@actor_index %= $game_party.real_actors.size
# Switch to different status screen
$scene = Scene_Status.new(@actor_index)
return
end
# If C button was pressed - make this character the leader
if Input.trigger?(Input::C)
@actor_index = 0
$game_party.remove_actor(@actor.id)
$game_party.real_actors.unshift(@actor)
$game_player.refresh
$scene = Scene_Status.new(@actor_index)
end
end
end
#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
# This class performs equipment screen processing.
#==============================================================================
class Scene_Equip
#--------------------------------------------------------------------------
# * Object Initialization
# actor_index : actor index
# equip_index : equipment index
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
@equip_index = equip_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get actor
@actor = $game_party.real_actors[@actor_index]
# Make windows
@help_window = Window_Help.new
@left_window = Window_EquipLeft.new(@actor)
@right_window = Window_EquipRight.new(@actor)
@item_window1 = Window_EquipItem.new(@actor, 0)
@item_window2 = Window_EquipItem.new(@actor, 1)
@item_window3 = Window_EquipItem.new(@actor, 2)
@item_window4 = Window_EquipItem.new(@actor, 3)
@item_window5 = Window_EquipItem.new(@actor, 4)
# Associate help window
@right_window.help_window = @help_window
@item_window1.help_window = @help_window
@item_window2.help_window = @help_window
@item_window3.help_window = @help_window
@item_window4.help_window = @help_window
@item_window5.help_window = @help_window
# Set cursor position
@right_window.index = @equip_index
refresh
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@help_window.dispose
@left_window.dispose
@right_window.dispose
@item_window1.dispose
@item_window2.dispose
@item_window3.dispose
@item_window4.dispose
@item_window5.dispose
end
#--------------------------------------------------------------------------
# * Frame Update (when right window is active)
#--------------------------------------------------------------------------
def update_right
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(2)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If equipment is fixed
if @actor.equip_fix?(@right_window.index)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Activate item window
@right_window.active = false
@item_window.active = true
@item_window.index = 0
return
end
# If R button was pressed
if Input.trigger?(Input::R)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To next actor
@actor_index += 1
@actor_index %= $game_party.real_actors.size
# Switch to different equipment screen
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
# If L button was pressed
if Input.trigger?(Input::L)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To previous actor
@actor_index += $game_party.real_actors.size - 1
@actor_index %= $game_party.real_actors.size
# Switch to different equipment screen
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
end
end
#==============================================================================
# ** Scene_Save
#------------------------------------------------------------------------------
# This class performs save screen processing.
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# * Write Save Data
# file : write file object (opened)
#--------------------------------------------------------------------------
def write_save_data(file)
# Make character data for drawing save file
characters = []
for i in 0...$game_party.real_actors.size
actor = $game_party.real_actors[i]
characters.push([actor.character_name, actor.character_hue])
end
# Write character data for drawing save file
Marshal.dump(characters, file)
# Wrire frame count for measuring play time
Marshal.dump(Graphics.frame_count, file)
# Increase save count by 1
$game_system.save_count += 1
# Save magic number
# (A random value will be written each time saving with editor)
$game_system.magic_number = $data_system.magic_number
# Write each type of game object
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
end
end
class Scene_Skill
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get actor
@actor = $game_party.real_actors[@actor_index]
# Make help window, status window, and skill window
@help_window = Window_Help.new
@status_window = Window_SkillStatus.new(@actor)
@skill_window = Window_Skill.new(@actor)
# Associate help window
@skill_window.help_window = @help_window
# Make target window (set to invisible / inactive)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@help_window.dispose
@status_window.dispose
@skill_window.dispose
@target_window.dispose
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This class is for all in-game windows.
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# * Draw Graphic
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y, active = true)
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
if (active == false)
tmpbmp = Bitmap.new(bitmap.width, bitmap.height)
tmpbmp.blt(0, 0, bitmap, bitmap.rect, 128)
bitmap = tmpbmp
end
cw = bitmap.width / 4
ch = bitmap.height / 4
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
end |
Жуть болотная, на лапках, в тапках и с пулемётом...
Последнее редактирование: 10 года 3 мес. назад от Cerberus.
Администратор запретил публиковать записи гостям.
|
Неограниченная партия [XP] 10 года 3 мес. назад #71936
|
Столкнулся с вылетом, подправил скрипт.
|
Жуть болотная, на лапках, в тапках и с пулемётом...
Администратор запретил публиковать записи гостям.
|
Модераторы: NeKotZima
Время создания страницы: 0.239 секунд