$states_icon = {}
$data_states = load_data("Data/States.rxdata")
(0...$data_states.size).each{|i|$states_icon[i]=0}
#下面设置每个状态的图标
$states_icon[10]="050-State07"
#上面设置每个状态的图标
=begin
Date 01-01-2014
重定义类:Window_Base, Window_Help
脚本功能:
实现战斗中和菜单中用图标显示状态,代替原来的文字显示。
默认最多同时显示5个状态
设置方法:
一个状态对应的图标文件名为“状态的动画ID.png”
例如某状态的动画ID为50,那么它的图标就是“Icons\50.png”
如果找不到对应的文件,会报错 ◎_◎
=end
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
# 游戏中全部窗口的超级类。
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 描绘状态
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标的宽
#--------------------------------------------------------------------------
def draw_actor_state(actor, x, y, width = 160)
state_size = 0
for state in actor.states
# 图标数量超出宽度就中断循环
if state_size >= width / 40
break
end
# 此状态不带图标就跳过
if $states_icon[state]==""
next
end
bitmap = RPG::Cache.icon($states_icon[state] + ".png")
if actor.states_turn[state] >= $data_states[state].hold_turn/2
opacity = 255
else
opacity = 100
end
txt = actor.states_turn[state].to_s
# 这里的图标大小默认是24x24,要改就改下面那个Rect.new(0, 0, 24, 24)
ax = x + 2 * state_size * 20
self.contents.blt(ax, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
self.contents.font.color = text_color(6)
self.contents.draw_text(ax + 24, y, 24, 32, txt)
state_size += 1
end
end
end
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
# 特技及物品的说明、角色的状态显示的窗口。
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# ● 设置敌人
# enemy : 要显示名字和状态的敌人
#--------------------------------------------------------------------------
def set_enemy(enemy)
self.contents.clear
# 描绘状态图标
state_size = 0
for state in enemy.states
# 图标数量超出宽度就中断循环
if state_size >= width / 40
break
end
# 此状态不带图标就跳过
if $states_icon[state]==""
next
end
bitmap = RPG::Cache.icon($states_icon[state]+".png")
if enemy.states_turn[state] >= $data_states[state].hold_turn/2
opacity = 255
else
opacity = 100
end
txt = enemy.states_turn[state].to_s
ax = 70 + 40 * state_size
self.contents.blt(ax, 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
self.contents.font.color = text_color(6)
self.contents.draw_text(ax + 24, 0, 24, 32, txt)
state_size += 1
end
# 描绘敌人名字
set_text(enemy.name, 1)
end
end
class Game_Battler
attr_reader :states_turn # 声明状态剩余回合
end
#==============================================================================