#=============================================================================#
# ■ BFS - PartyTactics
#-----------------------------------------------------------------------------#
# 战术方面(预设5种战技)
#=============================================================================#
module BFS_Tactics
DATA = [["攻击模式", "BFS-attacker", "负责攻击,会使用攻击技能"],
["支援模式", "BFS-heal", "负责支援,会使用恢复技能"]]
# ["第二控制者", "BFS-controller", "使用ESDF控制上下左右移动,Y键进行攻击来控制装配有这个战技的队友"],
# ["坚守者", "BFS-defender", "呆在原地,用于启动机关,只攻击附近的怪物"],
# ["探路者", "BFS-seeker", "熟悉地形的战友会给你行进的帮助"]]
end
# 定义几个窗口和一个场景
# (主界面部分)
class Window_Tactics < Window_Selectable
def initialize
super(68, 240, 240, 160)
@item_max = BFS_Tactics::DATA.size
self.contents = Bitmap.new(width - 32, @item_max * 32)
self.opacity = 220
@column_max = 1
refresh
self.index = 0
self.z = 9999
@old_index = self.index
end
def update
super
if @old_index != self.index
@old_index = self.index
$scene.info_update(self.index)
end
end
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
def draw_item(index)
self.contents.font.color = normal_color
tactics_info = BFS_Tactics::DATA[index]
x = 4
y = index * 32
rect = Rect.new(x, y, self.width, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(tactics_info[1])
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), 255)
self.contents.draw_text(x + 28, y, 204, 32, tactics_info[0], 0)
end
end
class Window_Character_Change < Window_Base
attr_reader :index
def initialize
super(170, 100, 276, 128)
self.contents = Bitmap.new($game_party.actors.size * 32 + 100, height - 32)
self.opacity = 220
refresh
self.active = true
self.z = 9999
@index = 0
end
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64 * i + 22
y = 0
actor = $game_party.actors[i]
draw_actor_graphic(actor, x, y + 55)
draw_actor_tactics(actor, x, y + 90)
end
end
def update
super
if self.active and @index >= 0
if Input.repeat?(Input::RIGHT)
if Input.trigger?(Input::RIGHT) #or @index < @item_max
$game_system.se_play($data_system.cursor_se)
@index = (@index + 1) % @item_max
end
end
if Input.repeat?(Input::LEFT)
if Input.trigger?(Input::LEFT) #or @index >= 0
$game_system.se_play($data_system.cursor_se)
@index = (@index - 1 + @item_max) % @item_max
end
end
end
update_cursor_rect
end
def update_cursor_rect
self.cursor_rect.set(@index * 64 - 5, 0, (self.width - 32) / 4, self.height - 32)
end
def draw_actor_tactics(actor, x, y)
icon_name = (BFS_Tactics::DATA[actor.tactics_type])[1]
bitmap = RPG::Cache.icon(icon_name)
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x - bitmap.width / 2, y - bitmap.height, bitmap, src_rect)
end
end
class Window_Tactics_Info < Window_Base
def initialize
super(308, 240, 276, 160)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 220
self.z = 9999
refresh(0)
end
def refresh(index)
self.contents.clear
self.contents.font.color = normal_color
text = (BFS_Tactics::DATA[index])[2].clone
x = y = 0
loop do
cha_max = 11
now_text = text[0, cha_max * 3]
text.slice!(0, cha_max * 3)
break if now_text == ""
self.contents.draw_text(0, 32 * y, 300, 32, now_text)
x += cha_max * 3
y += 1
end
end
end
class Scene_Tactics
def main
@tactics_window = Window_Tactics.new
@character_window = Window_Character_Change.new
@tac_info_window = Window_Tactics_Info.new
@background = Spriteset_Map.new
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果切换画面就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@tactics_window.dispose
@character_window.dispose
@tac_info_window.dispose
@background.dispose
end
def info_update(index)
@tac_info_window.refresh(index)
end
def update
@tactics_window.update
@character_window.update
if Input.trigger?(Input::C)
$game_system.se_play($data_system.equip_se)
$game_party.actors[@character_window.index].tactics_type = @tactics_window.index
@character_window.refresh
end
if Input.trigger?(Input::B) or Kboard.trigger?(BFS_Setting::BUTTON_CALL_TACTICS)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
end
end
class Game_Friend < Game_Event
def bfs_move
return if @battler.tactics_type == 3
return move_follow if @battler.dead?
return if @stop_count < 0
return if @aimovement_stand_by
return move_follow if $game_temp.bfs_follow
case @battler.tactics_type
when 0 #攻击主力
attack_force
when 1 #支援主力
support_force
# when 2 #第二控制者
controlled_update
# when 3 #坚守者
# defend_force
# when 4 #探路者
# lead_way
end
end
# --------------------------------
# 攻击主力
# --------------------------------
def attack_force
update_sensor
if @enemy_in_range == nil
case rand(10)
when 1
move_random
when 2..4
@stop_count = 0
when 5..10
move_follow
end
else
case rand(10)
when 1..4
move_toward_event($game_map.events[@enemy_in_range])
return if moving?
@stop_count = -20
when 5..7
case rand(25)
when 0..17
attack_command
when 18..24
magic_command
end
@stop_count = -20
when 9..10
move_follow
end
end
end
def controlled_update
if Kboard.press?($R_Key_E)
return unless passable?(@x, @y, 8)
turn_up
@y -= 1
end
if Kboard.press?($R_Key_D)
return unless passable?(@x, @y, 2)
turn_down
@y += 1
end
if Kboard.press?($R_Key_S)
return unless passable?(@x, @y, 4)
turn_left
@x -= 1
end
if Kboard.press?($R_Key_F)
return unless passable?(@x, @y, 6)
turn_right
@x += 1
end
if Kboard.trigger?($R_Key_Y)
attack_command
end
end
# --------------------------------
# 支援主力
# --------------------------------
def support_force
case rand(6)
when 0..4
update_sensor
return move_follow if @enemy_in_range == nil
case rand(7)
when 0..4
move_toward_event($game_map.events[@enemy_in_range])
return if moving?
@stop_count = -20
when 5..7
attack_command
end
when 5
update_hp_sensor
return move_follow if @low_hp_characters == 0
#队友回血
if $game_party.actors[1].skill_learn?(BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)])
self.pop_damage_text(BFS_Setting::WORDS_CURE[rand(BFS_Setting::WORDS_CURE.size)])
self.shoot(BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)])
#但队伍人数等于2的时候
if $game_party.actors.size == 2
#1、2号人物受技能影响
$game_party.actors[0].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
$game_party.actors[1].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
end
if $game_party.actors.size == 3
$game_party.actors[0].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
$game_party.actors[1].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
$game_party.actors[2].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
end
if $game_party.actors.size == 4
$game_party.actors[0].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
$game_party.actors[1].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
$game_party.actors[2].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
$game_party.actors[3].skill_effect(self.battler, $data_skills[BFS_Setting::TAC_CURE_ID[rand(BFS_Setting::TAC_CURE_ID.size - 1)]])
end
end
#回血加血技能冷却
@stop_count = -100
end
end
def defend_force
update_sensor
return turn_toward_player if @enemy_in_range == nil
case rand(5)
when 0..2
turn_toward_event(@enemy_in_range)
when 3..5
attack_command
@stop_count = -20
end
end
def lead_way
return move_follow if self.battler.id != 4
return move_follow if $game_map.map_id != 5
lead_destination = $game_system.lead[$game_system.lead_step]
distance = (self.x - $game_player.x).abs + (self.y - $game_player.y).abs
if distance > 8
turn_toward_player
else
move_toward_cell(lead_destination[0],lead_destination[1])
if lead_destination[0] == self.x and lead_destination[1] == self.y
if $game_system.lead_step + 1 == $game_system.lead.size
turn_toward_player
else
$game_system.lead_step += 1
end
end
end
end
def d
#when 2 #自由
update_sensor
if @enemy_in_range == nil
move_follow
else
case rand(10)
when 1..4
move_toward_event($game_map.events[@enemy_in_range])
return if moving?
@stop_count = -20
when 5..7
attack_command
@stop_count = -20
when 9..10
move_follow
end
end
#when 3 # BOSS(特殊模式)
unless $game_switches[BFS_Setting::BOSS_MODE_SWITCH]
$game_temp.bfs_party_mode = 0
$boss_event_id = nil
return
end
case rand(46)
when 0..15
move_follow
when 16..25
move_toward_event($game_map.events[$boss_event_id])
return if moving?
@stop_count = -30
when 26..40
attack_command
@stop_count = -20
when 41..45
magic_command
@stop_count = -30
end
end
end