#==============================================================================
# ■ P叔的动作列表
#------------------------------------------------------------------------------
# 请设定动作列表保留的最大行数:
Line_Max = 999
# 三点注意事项:
# 1、需要保留动作的文章,在文章开头打上符号 \+
# 2、不需要保留动作的文章,直接打字即可
# 3、文章不要太长,一般不要超过一行,不然会显示不全
# 4、对于颜色显示、队员名称显示、变量显示都支持
#------------------------------------------------------------------------------
# 请注明脚本来源:
# 本脚本来自[url]www.66rpg.com[/url]
#==============================================================================
#==============================================================================
# ■ Game_Message
#------------------------------------------------------------------------------
# 处理讯息窗口状态、执行文字显示、选项等的类。 本类的实例请参考 $game_message。
#==============================================================================
class Game_Message
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :action_table # 行动列表
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
@action_table = [] if @action_table.nil?
clear
@visible = false
end
end
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
# 显示文章的信息窗口。
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# ● 转换特殊符号
#--------------------------------------------------------------------------
def convert_special_characters
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
@text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
@text.gsub!(/\\G/) { "\x02" }
@text.gsub!(/\\\./) { "\x03" }
@text.gsub!(/\\\|/) { "\x04" }
@text.gsub!(/\\!/) { "\x05" }
@text.gsub!(/\\>/) { "\x06" }
@text.gsub!(/\\</) { "\x07" }
@text.gsub!(/\\\^/) { "\x08" }
@text.gsub!(/\\\\/) { "\\" }
@text.gsub!(/\\\+/) { "" }
end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
# 执行事件命令的解释器。本类在 Game_Map 类、Game_Troop 类、与
# Game_Event 类的内部使用。
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 显示文章
#--------------------------------------------------------------------------
def command_101
unless $game_message.busy
$game_message.face_name = @params[0]
$game_message.face_index = @params[1]
$game_message.background = @params[2]
$game_message.position = @params[3]
text = ""
@index += 1
while @list[@index].code == 401 # 文章数据
$game_message.texts.push(@list[@index].parameters[0])
@index += 1
end
for i in 0...2
text += $game_message.texts[i] unless $game_message.texts[i].nil?
end
text = convert_special_characters(text)
$game_message.action_table.push(text) if text.include?("\x09")
if $game_message.action_table.size > 999
$game_message.action_table.delete_at(0)
end
if @list[@index].code == 102 # 显示选择项
setup_choices(@list[@index].parameters)
elsif @list[@index].code == 103 # 数值输入处理
setup_num_input(@list[@index].parameters)
end
set_message_waiting # 设置等待信息结束
end
return false
end
#--------------------------------------------------------------------------
# ● 转换特殊符号
#--------------------------------------------------------------------------
def convert_special_characters(texts)
text = texts.dup
text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
text.gsub!(/\\G/) { "" }
text.gsub!(/\\\./) { "" }
text.gsub!(/\\\|/) { "" }
text.gsub!(/\\!/) { "" }
text.gsub!(/\\>/) { "" }
text.gsub!(/\\</) { "" }
text.gsub!(/\\\^/) { "" }
text.gsub!(/\\\\/) { "\\" }
text.gsub!(/\\\+/) { "\x09" }
return text
end
end
#==============================================================================
# ■ Window_Action
#------------------------------------------------------------------------------
# 显示行动列表的窗口。
#==============================================================================
class Window_Action < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# x : 窗口 X 座标
# y : 窗口 Y 座标
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 544, 416)
@self_index = 0
@contents_x = 4
refresh
end
def update
max = $game_message.action_table.size
max = 999 if max > 999
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.repeat?(Input::UP)
if @self_index < max - 16
@self_index += 1
refresh
else
Sound.play_buzzer
end
elsif Input.repeat?(Input::DOWN)
if @self_index > 0
@self_index -= 1
refresh
else
Sound.play_buzzer
end
elsif Input.repeat?(Input::L)
if @self_index < max - 16
@self_index += 16
@self_index = max - 16 if @self_index > max - 16
refresh
else
Sound.play_buzzer
end
elsif Input.repeat?(Input::R)
if @self_index > 0
@self_index -= 16
@self_index = 0 if @self_index < 0
refresh
else
Sound.play_buzzer
end
end
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
max = $game_message.action_table.size
max = 16 if max > 16
action_table = $game_message.action_table
for i in 0...max
text = action_table[action_table.size - i - @self_index - 1]
update_message(text, i)
end
end
def update_message(text, i)
dupped_text = text.dup
@contents_x = 4
join = false
loop do
c = dupped_text.slice!(/./m) # 获取一个文字
case c
when nil # 无法获取文字时
break
when "\n" # 新行
when "\x01" # \C[n](文字变色)
dupped_text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
next
when "\x09" # \+(需要加入动作)
join = true
else
if join
contents.draw_text(@contents_x, WLH * (15 - i), 544, WLH, c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
end
end
end
end
#==============================================================================
# ■ Scene_Action
#------------------------------------------------------------------------------
# 处理战斗画面的类。
#==============================================================================
class Scene_Action < Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
@action_window = Window_Action.new(0, 0)
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def terminate
super
@action_window.dispose
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
@action_window.update
end
end