赞 | 189 |
VIP | 627 |
好人卡 | 188 |
积分 | 95 |
经验 | 171230 |
最后登录 | 2024-7-3 |
在线时间 | 5073 小时 |
Lv4.逐梦者 (版主)
- 梦石
- 0
- 星屑
- 9532
- 在线时间
- 5073 小时
- 注册时间
- 2013-6-21
- 帖子
- 3580
|
本帖最后由 RyanBern 于 2015-9-12 20:08 编辑
#============================================================================= # 队伍系统 Ver 2.0 #----------------------------------------------------------------------------- # 类似于 Aveyond 的队伍系统(根据阿月系列的游戏产生的灵感) # By :RyanBern #----------------------------------------------------------------------------- # 功能特色: #----------------------------------------------------------------------------- # 1.更改队伍中成员的最大数量,有四名出战队员,但是替补队员可以有很多个。 # 2.对 Game_Party 的队员设置和 Scene_Battle 的部分方法有较大改动,可能造成脚本 # 冲突。 # 3.为队伍增加“领队”角色,作为“领队”的成员在地图上显示他的图形。 # 4.在战斗命令中增添“换人”命令,可以将替补队员换上场。 # 5.如果队伍的出战队员全部阵亡,则直接判定玩家全灭,不管有无替补队员。但是如果 # 在地图上,则是所有队员阵亡才会被判定全灭。 # 6.事件编译器中,对全体同伴的处理均包括对替补队员的处理。 #----------------------------------------------------------------------------- # 使用方法: #----------------------------------------------------------------------------- # 1.粘贴到默认脚本后面,Main组前面即可。 # 2.在菜单中,左侧窗口被激活时,按 A 键可以改变领队(leader)的设置,按 S 键 # 可以改变出战的队员。 (要按空格来切换) # 3.为队员设置“无法出战”的状态,即该队员不能被设置为出战队员。具体方法是 # 使用事件脚本,例如,让 1 号角色无法出战: # $game_actors[1].battle_disabled = true # 让 1 号角色恢复可以出战的状态: # $game_actors[1].battle_disabled = false # ### # 4.可在下方设置替补队员在战斗胜利之后是否获得 EXP 奖励。 #============================================================================= module RB end module RB::Party # “换人”命令的术语 Words_Swap = "换人" # 替补队员是否能在战斗胜利后获得 EXP 奖励,设置为 true 时可以获得奖励,设置 # 为 false 时则不能。 Get_Exp_Reserve = true end class Game_Temp attr_accessor :gain_exp_flag attr_accessor :battle_swap end class Game_Party attr_reader :leader attr_reader :battle_actors alias old_ini initialize def initialize @leader = nil @battle_actors = [] old_ini end def leader=(leader) @leader = leader $game_player.refresh $game_map.need_refresh = true end def set_leader(actor_id) self.leader = $game_actors[actor_id] end def actors all_flag = !$game_temp.in_battle || (RB::Party::Get_Exp_Reserve && $game_temp.gain_exp_flag) return all_flag ? @actors : @battle_actors end def all_actors return @actors end #-------------------------------------------------------------------------- # ● 加入同伴 # actor_id : 角色 ID #-------------------------------------------------------------------------- def add_actor(actor_id) # 获取角色 actor = $game_actors[actor_id] # 同伴人数未满 4 人、本角色不在队伍中的情况下 unless @actors.include?(actor) # 添加角色 @actors.push(actor) @battle_actors.push(actor) if @battle_actors.size < 4 self.leader = actor if self.leader.nil? # 还原主角 $game_player.refresh end end #-------------------------------------------------------------------------- # ● 角色离开 # actor_id : 角色 ID #-------------------------------------------------------------------------- def remove_actor(actor_id) actor = $game_actors[actor_id] # 删除角色 @actors.delete(actor) @battle_actors.delete(actor) self.leader = self.actors[0] if self.leader == actor # 还原主角 $game_player.refresh end #-------------------------------------------------------------------------- # ● 设置初期同伴 #-------------------------------------------------------------------------- def setup_starting_members @actors = [] @battle_actors = [] for i in $data_system.party_members @actors.push($game_actors[i]) @battle_actors.push($game_actors[i]) if @battle_actors.size < 4 end self.leader = @actors[0] end #-------------------------------------------------------------------------- # ● 设置战斗测试用同伴 #-------------------------------------------------------------------------- def setup_battle_test_members @actors = [] @battle_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 @actors.push(actor) @battle_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 #-------------------------------------------------------------------------- # ● 同伴成员的还原 #-------------------------------------------------------------------------- def refresh # 游戏数据载入后角色对像直接从 $game_actors # 分离。 # 回避由于载入造成的角色再设置的问题。 new_actors = [] new_battle_actors = [] @actors.each do |actor| if $data_actors[actor.id] != nil new_actors.push($game_actors[actor.id]) end end @battle_actors ||= [] @battle_actors.each do |actor| if $data_actors[actor.id] != nil new_battle_actors.push($game_actors[actor.id]) end end @actors = new_actors @battle_actors = new_battle_actors end #-------------------------------------------------------------------------- # ● 全灭判定 #-------------------------------------------------------------------------- def all_dead? # 同伴人数为 0 的情况下 if self.actors.size == 0 return false end # 同伴中无人 HP 在 0 以上 for actor in self.actors if actor.hp > 0 return false end end # 全灭 return true end #-------------------------------------------------------------------------- # ● 对像角色的随机确定 # hp0 : 限制为 HP 0 的角色 #-------------------------------------------------------------------------- def random_target_actor(hp0 = false) # 初始化轮流 roulette = [] # 循环 for actor in @battle_actors # 符合条件的场合 if (not hp0 and actor.exist?) or (hp0 and actor.hp0?) # 获取角色职业的位置 [位置] position = $data_classes[actor.class_id].position # 前卫的话 n = 4、中卫的话 n = 3、后卫的话 n = 2 n = 4 - position # 添加角色的轮流 n 回 n.times do roulette.push(actor) end end end # 轮流大小为 0 的情况 if roulette.size == 0 return nil end # 转轮盘赌,决定角色 return roulette[rand(roulette.size)] end #-------------------------------------------------------------------------- # ● 对像角色的顺序确定 # actor_index : 角色索引 #-------------------------------------------------------------------------- def smooth_target_actor(actor_index) # 取得对像 actor = @battle_actors[actor_index] # 对像存在的情况下 if actor != nil and actor.exist? return actor end # 循环 for actor in @actors # 对像存在的情况下 if actor.exist? return actor end end end end class Game_Actor attr_reader :battle_disabled def leader? return self == $game_party.leader end def active return $game_party.battle_actors.include?(self) end def battle_disabled=(bool) @battle_disabled = bool $game_party.battle_actors.delete(self) if bool end end class Game_BattleAction attr_accessor :reserved_actor_id unless method_defined? :rb_clear_20150422 alias rb_clear_20150422 clear def clear rb_clear_20150422 @reserved_actor_id = 0 end end end class Window_Base < Window def draw_actor_battle_position(actor, x, y) color = disabled_color if actor.battle_disabled text = "无法出战" elsif actor.active text = "出战" color = normal_color else text = "待机" end self.contents.font.color = color self.contents.draw_text(x, y, 120, 32, text) end end #============================================================================== # ■ Window_Selectable #------------------------------------------------------------------------------ # 拥有光标的移动以及滚动功能的窗口类。 #============================================================================== class Window_Selectable < Window_Base #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_accessor :row_height # 行高 #-------------------------------------------------------------------------- # ● 初始画对像 # x : 窗口的 X 坐标 # y : 窗口的 Y 坐标 # width : 窗口的宽 # height : 窗口的高 # row_height : 行高 默认是32 #-------------------------------------------------------------------------- alias rb_initialize_20150421 initialize def initialize(x, y, width, height, row_height = 32) @row_height = row_height rb_initialize_20150421(x, y, width, height) end #-------------------------------------------------------------------------- # ● 获取开头行 #-------------------------------------------------------------------------- def top_row # 将窗口内容的传送源 Y 坐标、1 行的高 @row_height 等分 return self.oy / @row_height end #-------------------------------------------------------------------------- # ● 设置开头行 # row : 显示开头的行 #-------------------------------------------------------------------------- def top_row=(row) # row 未满 0 的场合更正为 0 if row < 0 row = 0 end # row 超过 row_max - 1 的情况下更正为 row_max - 1 if row > row_max - 1 row = row_max - 1 end # row 1 行高的 @row_height 倍、窗口内容的传送源 Y 坐标 self.oy = row * @row_height end #-------------------------------------------------------------------------- # ● 获取 1 页可以显示的行数 #-------------------------------------------------------------------------- def page_row_max # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 @row_height return (self.height - 32) / @row_height end #-------------------------------------------------------------------------- # ● 更新光标举行 #-------------------------------------------------------------------------- def update_cursor_rect # 光标位置不满 0 的情况下 if @index < 0 self.cursor_rect.empty return end # 获取当前的行 row = @index / @column_max # 当前行被显示开头行前面的情况下 if row < self.top_row # 从当前行向开头行滚动 self.top_row = row end # 当前行被显示末尾行之后的情况下 if row > self.top_row + (self.page_row_max - 1) # 从当前行向末尾滚动 self.top_row = row - (self.page_row_max - 1) end # 计算光标的宽 cursor_width = self.width / @column_max - 32 # 计算光标坐标 x = @index % @column_max * (cursor_width + 32) y = @index / @column_max * @row_height - self.oy # 更新国标矩形 self.cursor_rect.set(x, y, cursor_width, @row_height) end end class Window_MenuStatus def initialize super(0, 0, 480, 480, 112) refresh self.active = false self.index = -1 end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @item_max = $game_party.actors.size self.contents = Bitmap.new(width - 32, @item_max == 0 ? 32 : @item_max * 112) for i in 0...$game_party.actors.size x = 64 y = i * 112 actor = $game_party.actors[i] draw_actor_graphic(actor, x - 40, y + 80) 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) draw_actor_battle_position(actor, x + 236, y) end end def update_cursor_rect super end end class Window_Target def initialize super(0, 0, 336, 480, 112) self.z += 10 @item_max = $game_party.actors.size self.contents = Bitmap.new(width - 32, @item_max == 0 ? 32 : @item_max * 112) refresh end def update_cursor_rect super end end class Window_ReservedActors < Window_Selectable def initialize super(0, 64, 640, 256, 112) self.opacity = 160 self.index = 0 self.active = true @column_max = 2 refresh end def actor return @data[self.index] end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] $game_party.all_actors.each do |actor| @data << actor unless actor.active || actor.battle_disabled end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new (width - 32, (@item_max + 1) / 2 * 128) @data.each_with_index do |actor, index| x = 4 + index % 2 * (288 + 32) y = index / 2 * 112 draw_actor_graphic(actor, x + 16, y + 80) draw_actor_hp(actor, x + 48, y + 20) draw_actor_sp(actor, x + 48, y + 52) end end end def update_help # 帮助窗口显示角色的状态 self.actor == nil ? @help_window.set_text("") : @help_window.set_actor(self.actor) end end class Scene_Menu unless method_defined? :rb_update_command_20150421 alias rb_update_command_20150421 update_command def update_command if Input.trigger?(Input::Y) $game_system.se_play($data_system.decision_se) @command_window.active = false @status_window.active = true @status_window.index = 0 @battler_adjust = true return end rb_update_command_20150421 end end unless method_defined? :rb_update_status_20150421 alias rb_update_status_20150421 update_status def update_status if @battler_adjust update_battler return end rb_update_status_20150421 end end def update_battler if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @battler_adjust = false @status_window.active = false @status_window.index = -1 @command_window.active = true return end if Input.trigger?(Input::C) actor = $game_party.actors[@status_window.index] if actor == nil || actor.battle_disabled || (actor.active && $game_party.battle_actors.size == 1) || (!actor.active && $game_party.battle_actors.size == 4) $game_system.se_play($data_system.buzzer_se) else $game_system.se_play($data_system.decision_se) actor.active ? $game_party.battle_actors.delete(actor) : $game_party.battle_actors.push(actor) @status_window.refresh end end end end class Scene_Battle def generate_modified_command_window if @actor_command_window != nil @actor_command_window.dispose @actor_command_window = nil end s1 = $data_system.words.attack s2 = $data_system.words.skill s3 = $data_system.words.guard s4 = $data_system.words.item s5 = RB::Party::Words_Swap @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5]) @actor_command_window.y = 128 @actor_command_window.back_opacity = 160 @actor_command_window.active = false @actor_command_window.visible = false @modified_generated = true end unless method_defined? :rb_phase3_setup_command_window_20150422 alias rb_phase3_setup_command_window_20150422 phase3_setup_command_window def phase3_setup_command_window generate_modified_command_window unless @modified_generated rb_phase3_setup_command_window_20150422 end end def update_phase3_basic_command # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 转向前一个角色的指令输入 phase3_prior_actor return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 角色指令窗口光标位置分之 case @actor_command_window.index when 0 # 攻击 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 # 开始选择敌人 start_enemy_select when 1 # 特技 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_battler.current_action.kind = 1 # 开始选择特技 start_skill_select when 2 # 防御 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 1 # 转向下一位角色的指令输入 phase3_next_actor when 3 # 物品 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_battler.current_action.kind = 2 # 开始选择物品 start_item_select when 4 # 换人 $game_system.se_play($data_system.decision_se) @active_battler.current_action.kind = 3 start_reserved_actor_select end return end end unless method_defined? :rb_update_phase3_20150422 alias rb_update_phase3_20150422 update_phase3 def update_phase3 if @actor_window != nil update_phase3_reserved_actor_select return end rb_update_phase3_20150422 end end def start_reserved_actor_select # 生成特技窗口 @actor_window = Window_ReservedActors.new # 关联帮助窗口 @actor_window.help_window = @help_window @help_window.visible = true # 无效化角色指令窗口 @actor_command_window.active = false @actor_command_window.visible = false end def end_reserved_actor_select # 释放特技窗口 @actor_window.dispose @actor_window = nil # 隐藏帮助窗口 @help_window.visible = false # 有效化角色指令窗口 @actor_command_window.active = true @actor_command_window.visible = true end def update_phase3_reserved_actor_select @actor_window.visible = true # 刷新特技窗口 @actor_window.update # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 结束特技选择 end_reserved_actor_select return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 获取特技选择窗口现在选择的特技的数据 @reserved_actor = @actor_window.actor # 无法使用的情况下 if @reserved_actor == nil # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_battler.current_action.reserved_actor_id = @reserved_actor.id # 设置特技窗口为不可见状态 @actor_window.visible = false end_reserved_actor_select phase3_next_actor return end end def update_phase4_step2 # 如果不是强制行动 unless @active_battler.current_action.forcing # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下 if @active_battler.restriction == 2 or @active_battler.restriction == 3 # 设置行动为攻击 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 end # 限制为 [不能行动] 的情况下 if @active_battler.restriction == 4 # 清除行动强制对像的战斗者 $game_temp.forcing_battler = nil # 移至步骤 1 @phase4_step = 1 return end end # 清除对像战斗者 @target_battlers = [] # 行动种类分支 case @active_battler.current_action.kind when 0 # 基本 make_basic_action_result when 1 # 特技 make_skill_action_result when 2 # 物品 make_item_action_result when 3 # 换人 make_swap_action_result end # 移至步骤 3 if @phase4_step == 2 @phase4_step = 3 end end def make_swap_action_result # 获取角色 @reserved_actor = $game_actors[@active_battler.current_action.reserved_actor_id] # 无法替换的情况下 if @reserved_actor == nil || @reserved_actor.active # 移至步骤 1 @phase4_step = 1 return end # 在帮助窗口显示文字 text = "与#{@reserved_actor.name}交换" @help_window.set_text(text, 1) # 设置动画 ID @animation1_id = 0 index = $game_party.actors.index(@active_battler) $game_party.actors[index] = @reserved_actor # 设置战斗交换标志 $game_temp.battle_swap = true end unless method_defined? :rb_start_phase5_20150422 alias rb_start_phase5_20150422 start_phase5 def start_phase5 $game_temp.gain_exp_flag = true rb_start_phase5_20150422 $game_temp.gain_exp_flag = false end end end
#=============================================================================
# 队伍系统 Ver 2.0
#-----------------------------------------------------------------------------
# 类似于 Aveyond 的队伍系统(根据阿月系列的游戏产生的灵感)
# By :RyanBern
#-----------------------------------------------------------------------------
# 功能特色:
#-----------------------------------------------------------------------------
# 1.更改队伍中成员的最大数量,有四名出战队员,但是替补队员可以有很多个。
# 2.对 Game_Party 的队员设置和 Scene_Battle 的部分方法有较大改动,可能造成脚本
# 冲突。
# 3.为队伍增加“领队”角色,作为“领队”的成员在地图上显示他的图形。
# 4.在战斗命令中增添“换人”命令,可以将替补队员换上场。
# 5.如果队伍的出战队员全部阵亡,则直接判定玩家全灭,不管有无替补队员。但是如果
# 在地图上,则是所有队员阵亡才会被判定全灭。
# 6.事件编译器中,对全体同伴的处理均包括对替补队员的处理。
#-----------------------------------------------------------------------------
# 使用方法:
#-----------------------------------------------------------------------------
# 1.粘贴到默认脚本后面,Main组前面即可。
# 2.在菜单中,左侧窗口被激活时,按 A 键可以改变领队(leader)的设置,按 S 键
# 可以改变出战的队员。 (要按空格来切换)
# 3.为队员设置“无法出战”的状态,即该队员不能被设置为出战队员。具体方法是
# 使用事件脚本,例如,让 1 号角色无法出战:
# $game_actors[1].battle_disabled = true
# 让 1 号角色恢复可以出战的状态:
# $game_actors[1].battle_disabled = false
# ###
# 4.可在下方设置替补队员在战斗胜利之后是否获得 EXP 奖励。
#=============================================================================
module RB
end
module RB::Party
# “换人”命令的术语
Words_Swap = "换人"
# 替补队员是否能在战斗胜利后获得 EXP 奖励,设置为 true 时可以获得奖励,设置
# 为 false 时则不能。
Get_Exp_Reserve = true
end
class Game_Temp
attr_accessor :gain_exp_flag
attr_accessor :battle_swap
end
class Game_Party
attr_reader :leader
attr_reader :battle_actors
alias old_ini initialize
def initialize
@leader = nil
@battle_actors = []
old_ini
end
def leader=(leader)
@leader = leader
$game_player.refresh
$game_map.need_refresh = true
end
def set_leader(actor_id)
self.leader = $game_actors[actor_id]
end
def actors
all_flag = !$game_temp.in_battle || (RB::Party::Get_Exp_Reserve && $game_temp.gain_exp_flag)
return all_flag ? @actors : @battle_actors
end
def all_actors
return @actors
end
#--------------------------------------------------------------------------
# ● 加入同伴
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def add_actor(actor_id)
# 获取角色
actor = $game_actors[actor_id]
# 同伴人数未满 4 人、本角色不在队伍中的情况下
unless @actors.include?(actor)
# 添加角色
@actors.push(actor)
@battle_actors.push(actor) if @battle_actors.size < 4
self.leader = actor if self.leader.nil?
# 还原主角
$game_player.refresh
end
end
#--------------------------------------------------------------------------
# ● 角色离开
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def remove_actor(actor_id)
actor = $game_actors[actor_id]
# 删除角色
@actors.delete(actor)
@battle_actors.delete(actor)
self.leader = self.actors[0] if self.leader == actor
# 还原主角
$game_player.refresh
end
#--------------------------------------------------------------------------
# ● 设置初期同伴
#--------------------------------------------------------------------------
def setup_starting_members
@actors = []
@battle_actors = []
for i in $data_system.party_members
@actors.push($game_actors[i])
@battle_actors.push($game_actors[i]) if @battle_actors.size < 4
end
self.leader = @actors[0]
end
#--------------------------------------------------------------------------
# ● 设置战斗测试用同伴
#--------------------------------------------------------------------------
def setup_battle_test_members
@actors = []
@battle_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
@actors.push(actor)
@battle_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
#--------------------------------------------------------------------------
# ● 同伴成员的还原
#--------------------------------------------------------------------------
def refresh
# 游戏数据载入后角色对像直接从 $game_actors
# 分离。
# 回避由于载入造成的角色再设置的问题。
new_actors = []
new_battle_actors = []
@actors.each do |actor|
if $data_actors[actor.id] != nil
new_actors.push($game_actors[actor.id])
end
end
@battle_actors ||= []
@battle_actors.each do |actor|
if $data_actors[actor.id] != nil
new_battle_actors.push($game_actors[actor.id])
end
end
@actors = new_actors
@battle_actors = new_battle_actors
end
#--------------------------------------------------------------------------
# ● 全灭判定
#--------------------------------------------------------------------------
def all_dead?
# 同伴人数为 0 的情况下
if self.actors.size == 0
return false
end
# 同伴中无人 HP 在 0 以上
for actor in self.actors
if actor.hp > 0
return false
end
end
# 全灭
return true
end
#--------------------------------------------------------------------------
# ● 对像角色的随机确定
# hp0 : 限制为 HP 0 的角色
#--------------------------------------------------------------------------
def random_target_actor(hp0 = false)
# 初始化轮流
roulette = []
# 循环
for actor in @battle_actors
# 符合条件的场合
if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
# 获取角色职业的位置 [位置]
position = $data_classes[actor.class_id].position
# 前卫的话 n = 4、中卫的话 n = 3、后卫的话 n = 2
n = 4 - position
# 添加角色的轮流 n 回
n.times do
roulette.push(actor)
end
end
end
# 轮流大小为 0 的情况
if roulette.size == 0
return nil
end
# 转轮盘赌,决定角色
return roulette[rand(roulette.size)]
end
#--------------------------------------------------------------------------
# ● 对像角色的顺序确定
# actor_index : 角色索引
#--------------------------------------------------------------------------
def smooth_target_actor(actor_index)
# 取得对像
actor = @battle_actors[actor_index]
# 对像存在的情况下
if actor != nil and actor.exist?
return actor
end
# 循环
for actor in @actors
# 对像存在的情况下
if actor.exist?
return actor
end
end
end
end
class Game_Actor
attr_reader :battle_disabled
def leader?
return self == $game_party.leader
end
def active
return $game_party.battle_actors.include?(self)
end
def battle_disabled=(bool)
@battle_disabled = bool
$game_party.battle_actors.delete(self) if bool
end
end
class Game_BattleAction
attr_accessor :reserved_actor_id
unless method_defined? :rb_clear_20150422
alias rb_clear_20150422 clear
def clear
rb_clear_20150422
@reserved_actor_id = 0
end
end
end
class Window_Base < Window
def draw_actor_battle_position(actor, x, y)
color = disabled_color
if actor.battle_disabled
text = "无法出战"
elsif actor.active
text = "出战"
color = normal_color
else
text = "待机"
end
self.contents.font.color = color
self.contents.draw_text(x, y, 120, 32, text)
end
end
#==============================================================================
# ■ Window_Selectable
#------------------------------------------------------------------------------
# 拥有光标的移动以及滚动功能的窗口类。
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :row_height # 行高
#--------------------------------------------------------------------------
# ● 初始画对像
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
# width : 窗口的宽
# height : 窗口的高
# row_height : 行高 默认是32
#--------------------------------------------------------------------------
alias rb_initialize_20150421 initialize
def initialize(x, y, width, height, row_height = 32)
@row_height = row_height
rb_initialize_20150421(x, y, width, height)
end
#--------------------------------------------------------------------------
# ● 获取开头行
#--------------------------------------------------------------------------
def top_row
# 将窗口内容的传送源 Y 坐标、1 行的高 @row_height 等分
return self.oy / @row_height
end
#--------------------------------------------------------------------------
# ● 设置开头行
# row : 显示开头的行
#--------------------------------------------------------------------------
def top_row=(row)
# row 未满 0 的场合更正为 0
if row < 0
row = 0
end
# row 超过 row_max - 1 的情况下更正为 row_max - 1
if row > row_max - 1
row = row_max - 1
end
# row 1 行高的 @row_height 倍、窗口内容的传送源 Y 坐标
self.oy = row * @row_height
end
#--------------------------------------------------------------------------
# ● 获取 1 页可以显示的行数
#--------------------------------------------------------------------------
def page_row_max
# 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 @row_height
return (self.height - 32) / @row_height
end
#--------------------------------------------------------------------------
# ● 更新光标举行
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = self.width / @column_max - 32
# 计算光标坐标
x = @index % @column_max * (cursor_width + 32)
y = @index / @column_max * @row_height - self.oy
# 更新国标矩形
self.cursor_rect.set(x, y, cursor_width, @row_height)
end
end
class Window_MenuStatus
def initialize
super(0, 0, 480, 480, 112)
refresh
self.active = false
self.index = -1
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@item_max = $game_party.actors.size
self.contents = Bitmap.new(width - 32, @item_max == 0 ? 32 : @item_max * 112)
for i in 0...$game_party.actors.size
x = 64
y = i * 112
actor = $game_party.actors[i]
draw_actor_graphic(actor, x - 40, y + 80)
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)
draw_actor_battle_position(actor, x + 236, y)
end
end
def update_cursor_rect
super
end
end
class Window_Target
def initialize
super(0, 0, 336, 480, 112)
self.z += 10
@item_max = $game_party.actors.size
self.contents = Bitmap.new(width - 32, @item_max == 0 ? 32 : @item_max * 112)
refresh
end
def update_cursor_rect
super
end
end
class Window_ReservedActors < Window_Selectable
def initialize
super(0, 64, 640, 256, 112)
self.opacity = 160
self.index = 0
self.active = true
@column_max = 2
refresh
end
def actor
return @data[self.index]
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
$game_party.all_actors.each do |actor|
@data << actor unless actor.active || actor.battle_disabled
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new (width - 32, (@item_max + 1) / 2 * 128)
@data.each_with_index do |actor, index|
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 112
draw_actor_graphic(actor, x + 16, y + 80)
draw_actor_hp(actor, x + 48, y + 20)
draw_actor_sp(actor, x + 48, y + 52)
end
end
end
def update_help
# 帮助窗口显示角色的状态
self.actor == nil ? @help_window.set_text("") : @help_window.set_actor(self.actor)
end
end
class Scene_Menu
unless method_defined? :rb_update_command_20150421
alias rb_update_command_20150421 update_command
def update_command
if Input.trigger?(Input::Y)
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
@battler_adjust = true
return
end
rb_update_command_20150421
end
end
unless method_defined? :rb_update_status_20150421
alias rb_update_status_20150421 update_status
def update_status
if @battler_adjust
update_battler
return
end
rb_update_status_20150421
end
end
def update_battler
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@battler_adjust = false
@status_window.active = false
@status_window.index = -1
@command_window.active = true
return
end
if Input.trigger?(Input::C)
actor = $game_party.actors[@status_window.index]
if actor == nil || actor.battle_disabled ||
(actor.active && $game_party.battle_actors.size == 1) ||
(!actor.active && $game_party.battle_actors.size == 4)
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
actor.active ? $game_party.battle_actors.delete(actor) : $game_party.battle_actors.push(actor)
@status_window.refresh
end
end
end
end
class Scene_Battle
def generate_modified_command_window
if @actor_command_window != nil
@actor_command_window.dispose
@actor_command_window = nil
end
s1 = $data_system.words.attack
s2 = $data_system.words.skill
s3 = $data_system.words.guard
s4 = $data_system.words.item
s5 = RB::Party::Words_Swap
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
@actor_command_window.y = 128
@actor_command_window.back_opacity = 160
@actor_command_window.active = false
@actor_command_window.visible = false
@modified_generated = true
end
unless method_defined? :rb_phase3_setup_command_window_20150422
alias rb_phase3_setup_command_window_20150422 phase3_setup_command_window
def phase3_setup_command_window
generate_modified_command_window unless @modified_generated
rb_phase3_setup_command_window_20150422
end
end
def update_phase3_basic_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 转向前一个角色的指令输入
phase3_prior_actor
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 角色指令窗口光标位置分之
case @actor_command_window.index
when 0 # 攻击
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置行动
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
# 开始选择敌人
start_enemy_select
when 1 # 特技
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置行动
@active_battler.current_action.kind = 1
# 开始选择特技
start_skill_select
when 2 # 防御
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置行动
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 1
# 转向下一位角色的指令输入
phase3_next_actor
when 3 # 物品
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置行动
@active_battler.current_action.kind = 2
# 开始选择物品
start_item_select
when 4 # 换人
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 3
start_reserved_actor_select
end
return
end
end
unless method_defined? :rb_update_phase3_20150422
alias rb_update_phase3_20150422 update_phase3
def update_phase3
if @actor_window != nil
update_phase3_reserved_actor_select
return
end
rb_update_phase3_20150422
end
end
def start_reserved_actor_select
# 生成特技窗口
@actor_window = Window_ReservedActors.new
# 关联帮助窗口
@actor_window.help_window = @help_window
@help_window.visible = true
# 无效化角色指令窗口
@actor_command_window.active = false
@actor_command_window.visible = false
end
def end_reserved_actor_select
# 释放特技窗口
@actor_window.dispose
@actor_window = nil
# 隐藏帮助窗口
@help_window.visible = false
# 有效化角色指令窗口
@actor_command_window.active = true
@actor_command_window.visible = true
end
def update_phase3_reserved_actor_select
@actor_window.visible = true
# 刷新特技窗口
@actor_window.update
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 结束特技选择
end_reserved_actor_select
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取特技选择窗口现在选择的特技的数据
@reserved_actor = @actor_window.actor
# 无法使用的情况下
if @reserved_actor == nil
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置行动
@active_battler.current_action.reserved_actor_id = @reserved_actor.id
# 设置特技窗口为不可见状态
@actor_window.visible = false
end_reserved_actor_select
phase3_next_actor
return
end
end
def update_phase4_step2
# 如果不是强制行动
unless @active_battler.current_action.forcing
# 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
if @active_battler.restriction == 2 or @active_battler.restriction == 3
# 设置行动为攻击
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
end
# 限制为 [不能行动] 的情况下
if @active_battler.restriction == 4
# 清除行动强制对像的战斗者
$game_temp.forcing_battler = nil
# 移至步骤 1
@phase4_step = 1
return
end
end
# 清除对像战斗者
@target_battlers = []
# 行动种类分支
case @active_battler.current_action.kind
when 0 # 基本
make_basic_action_result
when 1 # 特技
make_skill_action_result
when 2 # 物品
make_item_action_result
when 3 # 换人
make_swap_action_result
end
# 移至步骤 3
if @phase4_step == 2
@phase4_step = 3
end
end
def make_swap_action_result
# 获取角色
@reserved_actor = $game_actors[@active_battler.current_action.reserved_actor_id]
# 无法替换的情况下
if @reserved_actor == nil || @reserved_actor.active
# 移至步骤 1
@phase4_step = 1
return
end
# 在帮助窗口显示文字
text = "与#{@reserved_actor.name}交换"
@help_window.set_text(text, 1)
# 设置动画 ID
@animation1_id = 0
index = $game_party.actors.index(@active_battler)
$game_party.actors[index] = @reserved_actor
# 设置战斗交换标志
$game_temp.battle_swap = true
end
unless method_defined? :rb_start_phase5_20150422
alias rb_start_phase5_20150422 start_phase5
def start_phase5
$game_temp.gain_exp_flag = true
rb_start_phase5_20150422
$game_temp.gain_exp_flag = false
end
end
end
#============================================================================== # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息 #============================================================================== # ———————————————————————————————————— # ▼▲▼ XRXS_BP 7. バトルステータス?クリアデザイン ver.1.03 ▼▲▼ # by 桜雅 在土 #============================================================================== # ■ Window_BattleStatus #============================================================================== class Window_BattleStatus < Window_Base #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :update_cp_only # CPメーターのみの更新 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias xrxs_bp7_initialize initialize def initialize # 初期化 @previous_hp = [] @previous_sp = [] # 呼び戻す xrxs_bp7_initialize ##############################修改############################################ @sta_back = [] create_heads ##############################修改############################################ # ↓Full-Viewの場合は下二行の # を消してください。 #self.opacity = 0 #self.back_opacity = 0 ##############################修改############################################ refresh ##############################修改############################################ end ##############################修改############################################ def dispose super @sta_back.each do |sprite| next if sprite.nil? sprite.bitmap.dispose sprite.dispose end end ##############################修改############################################ def create_heads (0...$game_party.actors.size).each do |i| if @sta_back[i] != nil @sta_back[i].bitmap.dispose @sta_back[i].dispose end actor = $game_party.actors[i] @sta_back[i] = Sprite.new @sta_back[i].bitmap = Bitmap.new("Graphics/Characters/Heads/"+ actor.name + ".png") @sta_back[i].x = i * 160 - 5 #在这里调整图片x坐标 @sta_back[i].y = 243#在这里调整图片y坐标 @sta_back[i].z = self.z + 1#在这里调整图片优先级 end end def update super if $game_temp.battle_swap create_heads $game_temp.battle_swap = false end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- alias xrxs_bp7_refresh refresh def refresh # CPメーターの更新のみ の場合 if @update_cp_only xrxs_bp7_refresh return end # 変更するものがない場合、飛ばす @item_max = $game_party.actors.size bool = false for i in 0...@item_max actor = $game_party.actors[i] if (@previous_hp[i] != actor.hp) or (@previous_sp[i] != actor.sp) bool = true end end return if bool == false # 描写を開始 self.contents.clear for i in 0...@item_max actor = $game_party.actors[i] actor_x = i * 160 + 29 # 歩行キャラグラフィックの描写 #draw_actor_graphic(actor, actor_x - 9, 116) # HP/SPメーターの描写 draw_actor_hp_meter_line(actor, actor_x, 47, 96, 12) draw_actor_sp_meter_line(actor, actor_x, 79, 96, 12) # HP数値の描写 self.contents.font.size = 24 # HP/SP数値の文字の大きさ self.contents.font.color = Color.new(0,0,0,192) self.contents.draw_text(actor_x, 35, 96, 24, actor.hp.to_s, 2) self.contents.font.color = actor.hp == 0 ? knockout_color : actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color self.contents.draw_text(actor_x-2, 33, 96, 24, actor.hp.to_s, 2) # SP数値の描写 self.contents.font.color = Color.new(0,0,0,192) self.contents.draw_text(actor_x, 72, 96, 24, actor.sp.to_s, 2) self.contents.font.color = actor.sp == 0 ? knockout_color : actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color self.contents.draw_text(actor_x-2, 70, 96, 24, actor.sp.to_s, 2) # 用語「HP」と用語「SP」の描写 self.contents.font.size = 20 # 用語「HP/SP」の文字の大きさ draw_actor_name(actor, actor_x ,3 ) self.contents.font.color = Color.new(0,0,0,192) self.contents.draw_text(actor_x+2, 27, 196, 24, $data_system.words.hp) self.contents.draw_text(actor_x+2, 59, 196, 24, $data_system.words.sp) self.contents.font.color = system_color # 用語「HP/SP」の文字の色 self.contents.draw_text(actor_x, 25, 196, 24, $data_system.words.hp) self.contents.draw_text(actor_x, 57, 196, 24, $data_system.words.sp) draw_actor_state(actor, actor_x, 100) # 値を更新 @previous_hp[i] = actor.hp @previous_hp[i] = actor.hp end end end #============================================================================== # ■ Window_Base #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ● HPメーター の描画 #-------------------------------------------------------------------------- def draw_actor_hp_meter_line(actor, x, y, width = 156, height = 4) w = width * actor.hp / [actor.maxhp,1].max hp_color_1 = Color.new(255, 0, 0, 192) hp_color_2 = Color.new(255, 255, 0, 192) self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128)) draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2) x -= 1 y += (height/4).floor self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128)) draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2) x -= 1 y += (height/4).ceil self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128)) draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2) x -= 1 y += (height/4).ceil self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128)) draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2) end #-------------------------------------------------------------------------- # ● SPメーター の描画 #-------------------------------------------------------------------------- def draw_actor_sp_meter_line(actor, x, y, width = 156, height = 4) w = width * actor.sp / [actor.maxsp,1].max hp_color_1 = Color.new( 0, 0, 255, 192) hp_color_2 = Color.new( 0, 255, 255, 192) self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128)) draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2) x -= 1 y += (height/4).floor self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128)) draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2) x -= 1 y += (height/4).ceil self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128)) draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2) x -= 1 y += (height/4).ceil self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128)) draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2) end #-------------------------------------------------------------------------- # ● 名前の描画 #-------------------------------------------------------------------------- alias xrxs_bp7_draw_actor_name draw_actor_name def draw_actor_name(actor, x, y) xrxs_bp7_draw_actor_name(actor, x, y) if @draw_ban != true end #-------------------------------------------------------------------------- # ● ステートの描画 #-------------------------------------------------------------------------- alias xrxs_bp7_draw_actor_state draw_actor_state def draw_actor_state(actor, x, y, width = 120) xrxs_bp7_draw_actor_state(actor, x, y, width) if @draw_ban != true end #-------------------------------------------------------------------------- # ● HP の描画 #-------------------------------------------------------------------------- alias xrxs_bp7_draw_actor_hp draw_actor_hp def draw_actor_hp(actor, x, y, width = 144) xrxs_bp7_draw_actor_hp(actor, x, y, width) if @draw_ban != true end #-------------------------------------------------------------------------- # ● SP の描画 #-------------------------------------------------------------------------- alias xrxs_bp7_draw_actor_sp draw_actor_sp def draw_actor_sp(actor, x, y, width = 144) xrxs_bp7_draw_actor_sp(actor, x, y, width) if @draw_ban != true end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias xrxs_bp7_update update def update xrxs_bp7_update # メッセージウィンドウ表示中の場合 if $game_temp.message_window_showing @status_window.update_cp_only = true else @status_window.update_cp_only = false end end end #============================================================================== # ◇ 外部ライブラリ #============================================================================== class Window_Base #-------------------------------------------------------------------------- # ● ライン描画 軽量版 by 桜雅 在土 #-------------------------------------------------------------------------- def draw_lineght(start_x, start_y, end_x, end_y, start_color) # 描写距離の計算。大きめに直角時の長さ。 distance = (start_x - end_x).abs + (start_y - end_y).abs # 描写開始 for i in 1..distance x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i self.contents.set_pixel(x, y, start_color) end end #-------------------------------------------------------------------------- # ● ライン描画 by 桜雅 在土 #-------------------------------------------------------------------------- def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color) # 描写距離の計算。大きめに直角時の長さ。 distance = (start_x - end_x).abs + (start_y - end_y).abs # 描写開始 if end_color == start_color for i in 1..distance x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i if width == 1 self.contents.set_pixel(x, y, start_color) else self.contents.fill_rect(x, y, width, width, start_color) end end else for i in 1..distance x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i r = start_color.red * (distance-i)/distance + end_color.red * i/distance g = start_color.green * (distance-i)/distance + end_color.green * i/distance b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance if width == 1 self.contents.set_pixel(x, y, Color.new(r, g, b, a)) else self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a)) end end end end end #============================================================================== # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息 #==============================================================================
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
# ————————————————————————————————————
# ▼▲▼ XRXS_BP 7. バトルステータス?クリアデザイン ver.1.03 ▼▲▼
# by 桜雅 在土
#==============================================================================
# ■ Window_BattleStatus
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :update_cp_only # CPメーターのみの更新
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias xrxs_bp7_initialize initialize
def initialize
# 初期化
@previous_hp = []
@previous_sp = []
# 呼び戻す
xrxs_bp7_initialize
##############################修改############################################
@sta_back = []
create_heads
##############################修改############################################
# ↓Full-Viewの場合は下二行の # を消してください。
#self.opacity = 0
#self.back_opacity = 0
##############################修改############################################
refresh
##############################修改############################################
end
##############################修改############################################
def dispose
super
@sta_back.each do |sprite|
next if sprite.nil?
sprite.bitmap.dispose
sprite.dispose
end
end
##############################修改############################################
def create_heads
(0...$game_party.actors.size).each do |i|
if @sta_back[i] != nil
@sta_back[i].bitmap.dispose
@sta_back[i].dispose
end
actor = $game_party.actors[i]
@sta_back[i] = Sprite.new
@sta_back[i].bitmap = Bitmap.new("Graphics/Characters/Heads/"+ actor.name + ".png")
@sta_back[i].x = i * 160 - 5 #在这里调整图片x坐标
@sta_back[i].y = 243#在这里调整图片y坐标
@sta_back[i].z = self.z + 1#在这里调整图片优先级
end
end
def update
super
if $game_temp.battle_swap
create_heads
$game_temp.battle_swap = false
end
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
alias xrxs_bp7_refresh refresh
def refresh
# CPメーターの更新のみ の場合
if @update_cp_only
xrxs_bp7_refresh
return
end
# 変更するものがない場合、飛ばす
@item_max = $game_party.actors.size
bool = false
for i in 0...@item_max
actor = $game_party.actors[i]
if (@previous_hp[i] != actor.hp) or (@previous_sp[i] != actor.sp)
bool = true
end
end
return if bool == false
# 描写を開始
self.contents.clear
for i in 0...@item_max
actor = $game_party.actors[i]
actor_x = i * 160 + 29
# 歩行キャラグラフィックの描写
#draw_actor_graphic(actor, actor_x - 9, 116)
# HP/SPメーターの描写
draw_actor_hp_meter_line(actor, actor_x, 47, 96, 12)
draw_actor_sp_meter_line(actor, actor_x, 79, 96, 12)
# HP数値の描写
self.contents.font.size = 24 # HP/SP数値の文字の大きさ
self.contents.font.color = Color.new(0,0,0,192)
self.contents.draw_text(actor_x, 35, 96, 24, actor.hp.to_s, 2)
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(actor_x-2, 33, 96, 24, actor.hp.to_s, 2)
# SP数値の描写
self.contents.font.color = Color.new(0,0,0,192)
self.contents.draw_text(actor_x, 72, 96, 24, actor.sp.to_s, 2)
self.contents.font.color = actor.sp == 0 ? knockout_color :
actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
self.contents.draw_text(actor_x-2, 70, 96, 24, actor.sp.to_s, 2)
# 用語「HP」と用語「SP」の描写
self.contents.font.size = 20 # 用語「HP/SP」の文字の大きさ
draw_actor_name(actor, actor_x ,3 )
self.contents.font.color = Color.new(0,0,0,192)
self.contents.draw_text(actor_x+2, 27, 196, 24, $data_system.words.hp)
self.contents.draw_text(actor_x+2, 59, 196, 24, $data_system.words.sp)
self.contents.font.color = system_color # 用語「HP/SP」の文字の色
self.contents.draw_text(actor_x, 25, 196, 24, $data_system.words.hp)
self.contents.draw_text(actor_x, 57, 196, 24, $data_system.words.sp)
draw_actor_state(actor, actor_x, 100)
# 値を更新
@previous_hp[i] = actor.hp
@previous_hp[i] = actor.hp
end
end
end
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● HPメーター の描画
#--------------------------------------------------------------------------
def draw_actor_hp_meter_line(actor, x, y, width = 156, height = 4)
w = width * actor.hp / [actor.maxhp,1].max
hp_color_1 = Color.new(255, 0, 0, 192)
hp_color_2 = Color.new(255, 255, 0, 192)
self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
x -= 1
y += (height/4).floor
self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
x -= 1
y += (height/4).ceil
self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
x -= 1
y += (height/4).ceil
self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
end
#--------------------------------------------------------------------------
# ● SPメーター の描画
#--------------------------------------------------------------------------
def draw_actor_sp_meter_line(actor, x, y, width = 156, height = 4)
w = width * actor.sp / [actor.maxsp,1].max
hp_color_1 = Color.new( 0, 0, 255, 192)
hp_color_2 = Color.new( 0, 255, 255, 192)
self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
x -= 1
y += (height/4).floor
self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
x -= 1
y += (height/4).ceil
self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
x -= 1
y += (height/4).ceil
self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
end
#--------------------------------------------------------------------------
# ● 名前の描画
#--------------------------------------------------------------------------
alias xrxs_bp7_draw_actor_name draw_actor_name
def draw_actor_name(actor, x, y)
xrxs_bp7_draw_actor_name(actor, x, y) if @draw_ban != true
end
#--------------------------------------------------------------------------
# ● ステートの描画
#--------------------------------------------------------------------------
alias xrxs_bp7_draw_actor_state draw_actor_state
def draw_actor_state(actor, x, y, width = 120)
xrxs_bp7_draw_actor_state(actor, x, y, width) if @draw_ban != true
end
#--------------------------------------------------------------------------
# ● HP の描画
#--------------------------------------------------------------------------
alias xrxs_bp7_draw_actor_hp draw_actor_hp
def draw_actor_hp(actor, x, y, width = 144)
xrxs_bp7_draw_actor_hp(actor, x, y, width) if @draw_ban != true
end
#--------------------------------------------------------------------------
# ● SP の描画
#--------------------------------------------------------------------------
alias xrxs_bp7_draw_actor_sp draw_actor_sp
def draw_actor_sp(actor, x, y, width = 144)
xrxs_bp7_draw_actor_sp(actor, x, y, width) if @draw_ban != true
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias xrxs_bp7_update update
def update
xrxs_bp7_update
# メッセージウィンドウ表示中の場合
if $game_temp.message_window_showing
@status_window.update_cp_only = true
else
@status_window.update_cp_only = false
end
end
end
#==============================================================================
# ◇ 外部ライブラリ
#==============================================================================
class Window_Base
#--------------------------------------------------------------------------
# ● ライン描画 軽量版 by 桜雅 在土
#--------------------------------------------------------------------------
def draw_lineght(start_x, start_y, end_x, end_y, start_color)
# 描写距離の計算。大きめに直角時の長さ。
distance = (start_x - end_x).abs + (start_y - end_y).abs
# 描写開始
for i in 1..distance
x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
self.contents.set_pixel(x, y, start_color)
end
end
#--------------------------------------------------------------------------
# ● ライン描画 by 桜雅 在土
#--------------------------------------------------------------------------
def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color)
# 描写距離の計算。大きめに直角時の長さ。
distance = (start_x - end_x).abs + (start_y - end_y).abs
# 描写開始
if end_color == start_color
for i in 1..distance
x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
if width == 1
self.contents.set_pixel(x, y, start_color)
else
self.contents.fill_rect(x, y, width, width, start_color)
end
end
else
for i in 1..distance
x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
r = start_color.red * (distance-i)/distance + end_color.red * i/distance
g = start_color.green * (distance-i)/distance + end_color.green * i/distance
b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance
a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance
if width == 1
self.contents.set_pixel(x, y, Color.new(r, g, b, a))
else
self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a))
end
end
end
end
end
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
注:以上脚本直接替换原来的脚本,未测试。
个人感觉改的应该是队伍跟随脚本,而不是队伍脚本[领队]的功能,但是我已经把领队功能去掉了。
新战斗头像脚本更改头像坐标的语句移动到了create_heads的方法里面。 |
|