#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
#============================================================================
# ■ events action system
#----------------------------------------------------------------------------
# By: 狱冥幻翼
# Date: 31/08/13
# Version 1.0
#============================================================================
#============================================================================
# 使用到的脚本
# 全键盘脚本 By: Cybersam
# MOG_Damage_Popup,MOG_Hud By: Moghunter
#============================================================================
#============================================================================
#此系统使用了100-126号开关,100-120号变量,41-55号公共事件,460-508号动画
#添加技能请修改第197-239行
#============================================================================
#============================================================================
# 全键盘脚本用法
# ★、Kboard.keyboard(键位) 返回是否按下这个键的判断。
# 比如条件分歧:Kboard.keyboard($R_Key_H)
# 则当按下键盘H键的时候条件分歧成立
#
# ★、Kboard.keyb(键位) == 1 当连续按住某键返回真,否则为false
# 比如条件分歧:Kboard.keyb($R_Key_U) == 1
# 则当持续按下键盘U的时候条件分歧成立
#
# ★、Kboard.key(键位,1) 似乎可以做开关用。按下一次变为true,再按变false
module Kboard
#==========================================================================
# 以下是全键盘按键列表
#--------------------------------------------------------------------------
$Rmouse_BUTTON_L = 0x01 # left mouse button
$Rmouse_BUTTON_R = 0x02 # right mouse button
$Rmouse_BUTTON_M = 0x04 # middle mouse button
$Rmouse_BUTTON_4 = 0x05 # 4th mouse button
$Rmouse_BUTTON_5 = 0x06 # 5th mouse button
#--------------------------------------------------------------------------
$R_Key_BACK = 0x08 # BACKSPACE key
$R_Key_TAB = 0x09 # TAB key
$R_Key_RETURN = 0x0D # ENTER key
$R_Key_SHIFT = 0x10 # SHIFT key
$R_Key_CTLR = 0x11 # CTLR key
$R_Key_ALT = 0x12 # ALT key
$R_Key_PAUSE = 0x13 # PAUSE key
$R_Key_CAPITAL = 0x14 # CAPS LOCK key
$R_Key_ESCAPE = 0x1B # ESC key
$R_Key_SPACE = 0x20 # SPACEBAR
$R_Key_PRIOR = 0x21 # PAGE UP key
$R_Key_NEXT = 0x22 # PAGE DOWN key
$R_Key_END = 0x23 # END key
$R_Key_HOME = 0x24 # HOME key
$R_Key_LEFT = 0x25 # LEFT ARROW key
$R_Key_UP = 0x26 # UP ARROW key
$R_Key_RIGHT = 0x27 # RIGHT ARROW key
$R_Key_DOWN = 0x28 # DOWN ARROW key
$R_Key_SELECT = 0x29 # SELECT key
$R_Key_PRINT = 0x2A # PRINT key
$R_Key_SNAPSHOT = 0x2C # PRINT SCREEN key
$R_Key_INSERT = 0x2D # INS key
$R_Key_DELETE = 0x2E # DEL key
#--------------------------------------------------------------------------
$R_Key_0 = 0x30 # 0 key
$R_Key_1 = 0x31 # 1 key
$R_Key_2 = 0x32 # 2 key
$R_Key_3 = 0x33 # 3 key
$R_Key_4 = 0x34 # 4 key
$R_Key_5 = 0x35 # 5 key
$R_Key_6 = 0x36 # 6 key
$R_Key_7 = 0x37 # 7 key
$R_Key_8 = 0x38 # 8 key
$R_Key_9 = 0x39 # 9 key
#--------------------------------------------------------------------------
$R_Key_A = 0x41 # A key
$R_Key_B = 0x42 # B key
$R_Key_C = 0x43 # C key
$R_Key_D = 0x44 # D key
$R_Key_E = 0x45 # E key
$R_Key_F = 0x46 # F key
$R_Key_G = 0x47 # G key
$R_Key_H = 0x48 # H key
$R_Key_I = 0x49 # I key
$R_Key_J = 0x4A # J key
$R_Key_K = 0x4B # K key
$R_Key_L = 0x4C # L key
$R_Key_M = 0x4D # M key
$R_Key_N = 0x4E # N key
$R_Key_O = 0x4F # O key
$R_Key_P = 0x50 # P key
$R_Key_Q = 0x51 # Q key
$R_Key_R = 0x52 # R key
$R_Key_S = 0x53 # S key
$R_Key_T = 0x54 # T key
$R_Key_U = 0x55 # U key
$R_Key_V = 0x56 # V key
$R_Key_W = 0x57 # W key
$R_Key_X = 0x58 # X key
$R_Key_Y = 0x59 # Y key
$R_Key_Z = 0x5A # Z key
#--------------------------------------------------------------------------
$R_Key_LWIN = 0x5B # Left Windows key (Microsoft Natural keyboard)
$R_Key_RWIN = 0x5C # Right Windows key (Natural keyboard)
$R_Key_APPS = 0x5D # Applications key (Natural keyboard)
#--------------------------------------------------------------------------
$R_Key_NUMPAD0 = 0x60 # Numeric keypad 0 key
$R_Key_NUMPAD1 = 0x61 # Numeric keypad 1 key
$R_Key_NUMPAD2 = 0x62 # Numeric keypad 2 key
$R_Key_NUMPAD3 = 0x63 # Numeric keypad 3 key
$R_Key_NUMPAD4 = 0x64 # Numeric keypad 4 key
$R_Key_NUMPAD5 = 0x65 # Numeric keypad 5 key
$R_Key_NUMPAD6 = 0x66 # Numeric keypad 6 key
$R_Key_NUMPAD7 = 0x67 # Numeric keypad 7 key
$R_Key_NUMPAD8 = 0x68 # Numeric keypad 8 key
$R_Key_NUMPAD9 = 0x69 # Numeric keypad 9 key
$R_Key_MULTIPLY = 0x6A # Multiply key (*)
$R_Key_ADD = 0x6B # Add key (+)
$R_Key_SEPARATOR = 0x6C # Separator key
$R_Key_SUBTRACT = 0x6D # Subtract key (-)
$R_Key_DECIMAL = 0x6E # Decimal key
$R_Key_DIVIDE = 0x6F # Divide key (/)
#--------------------------------------------------------------------------
$R_Key_F1 = 0x70 # F1 key
$R_Key_F2 = 0x71 # F2 key
$R_Key_F3 = 0x72 # F3 key
$R_Key_F4 = 0x73 # F4 key
$R_Key_F5 = 0x74 # F5 key
$R_Key_F6 = 0x75 # F6 key
$R_Key_F7 = 0x76 # F7 key
$R_Key_F8 = 0x77 # F8 key
$R_Key_F9 = 0x78 # F9 key
$R_Key_F10 = 0x79 # F10 key
$R_Key_F11 = 0x7A # F11 key
$R_Key_F12 = 0x7B # F12 key
#--------------------------------------------------------------------------
$R_Key_NUMLOCK = 0x90 # NUM LOCK key
$R_Key_SCROLL = 0x91 # SCROLL LOCK key
#--------------------------------------------------------------------------
$R_Key_LSHIFT = 0xA0 # Left SHIFT key
$R_Key_RSHIFT = 0xA1 # Right SHIFT key
$R_Key_LCONTROL = 0xA2 # Left CONTROL key
$R_Key_RCONTROL = 0xA3 # Right CONTROL key
$R_Key_L_ALT = 0xA4 # Left ALT key
$R_Key_R_ALT = 0xA5 # Right ALT key
#--------------------------------------------------------------------------
$R_Key_SEP = 0xBC # , key
$R_Key_DASH = 0xBD # - key
$R_Key_DOTT = 0xBE # . Key
#--------------------------------------------------------------------------
GetKeyState = Win32API.new("user32","GetAsyncKeyState",['I'],'I')
GetKeyboardState = Win32API.new("user32","GetKeyState",['I'],'I')
GetSetKeyState = Win32API.new("user32","SetKeyboardState",['I'],'I')
#--------------------------------------------------------------------------
module_function
#--------------------------------------------------------------------------
def keyb(rkey)
if GetKeyState.call(rkey) != 0
return 1
end
return 0
end
#--------------------------------------------------------------------------
def keyboard(rkey)
GetKeyState.call(rkey) & 0x01 == 1 #
end
#--------------------------------------------------------------------------
def key(rkey, key = 0)
GetKeyboardState.call(rkey) & 0x01 == key #
end
end
#四方向改二方向
class Game_CharacterBase
def set_direction(d)
if $game_switches[101] == true
@direction = d if !@direction_fix && d != 0|2 && d != 8
@stop_count = 0
else
@direction = d if !@direction_fix && d != 0
@stop_count = 0
end
end
end
#连击相关
class Scene_Map
alias hys_input_update update
def update
hys_input_update
if $game_switches[101] == true
if $game_variables[111] != 0
$game_variables[111] -= 1
end
end
end
end
class Game_Player
#--------------------------------------------------------------------------
# ● 判定是否跑步状态
#--------------------------------------------------------------------------
def dash?
return false if @move_route_forcing
return false if $game_map.disable_dash?
return false if vehicle
return !(Input.press?(:A))
end
end
#input_update
class Scene_Map
alias eas_input_update update
def update
eas_input_update
if $game_switches[101] == true
if Kboard.keyboard($R_Key_W)
$game_temp.reserve_common_event(42)
end
if Kboard.keyboard($R_Key_A)
if $game_switches[104] == false && $game_switches[106] == false
$game_temp.reserve_common_event(47)
end
end
if Kboard.keyboard($R_Key_S)
if $game_switches[104] == false && $game_switches[106] == false
$game_temp.reserve_common_event(48)
end
end
if Kboard.keyboard($R_Key_D)
if $game_switches[104] == false && $game_switches[106] == false
$game_temp.reserve_common_event(49)
end
end
if Kboard.keyboard($R_Key_Z)
if $game_switches[104] == false#判定是否施放技能
if $game_switches[106] == false#判定是否跳跃
$game_temp.reserve_common_event(53)
end
end
end
if Kboard.keyboard($R_Key_X)
if $game_switches[104] == false
if $game_switches[106] == false
$game_temp.reserve_common_event(54)
else
$easdiscuss = 1
end
end
end
end
end
end
#==============================================================================
# +++ MOG - DAMAGEPOPUP (v2.0) +++
#==============================================================================
module MOG_DAMAGEPOP
#Definição do espaço entre a palavra MP/TP e o numero de dano.
MP_TP_STRING_SPACE = 32
#Correção da posição do dano.
DAMAGE_POSITION_CORRECTION = [0 ,0]
#Apresentar a exp e ouro do inimigo.
EXP_POPUP = true
#Definição da prioridade do dano na tela.
DAMAGE_Z = 60
end
#==============================================================================
# ■ Damage Sprite
#==============================================================================
class Damage_Sprite < Sprite
include MOG_DAMAGEPOP
attr_accessor :duration
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(viewport = nil,x = 0,y = 0,value = 0,index)
super(viewport)
dispose
@image = Cache.system("Damage_Number")
@x = x
@y = y
@value = value[0]
@type = value[1]
@critical = (value[2] and @value.to_i >= 0) ? true : false
@state_index = value[3]
@duration = 80 + (10 * index)
@cw = @image.width / 10
@ch = @image.height / 7
@center_x = 0
@mp_space = (@type == "MP" or @type == "TP") ? MP_TP_STRING_SPACE : 0
if @value.is_a?(Numeric)
create_damage_number
elsif @value == "Missed" or @value == "Evaded"
create_damage_miss
else
create_damage_string
end
self.x = @x - (@center_x * (@cw / 2)) + DAMAGE_POSITION_CORRECTION[0]
self.y = @y + DAMAGE_POSITION_CORRECTION[1]
self.opacity = 1
zx = self.viewport != nil ? self.viewport.z : 0
self.z = DAMAGE_Z + zx
self.visible = false
damage_dir = rand(2)
@speed_x = straight_pop? ? 0 : damage_dir == 1 ? -rand(2) : rand(2)
@speed_y = 0
end
#--------------------------------------------------------------------------
# ● Straight Pop
#--------------------------------------------------------------------------
def straight_pop?
case @type
when "Gold"; return true
when "Exp"; return true
when "Level_UP"; return true
end
return false
end
#--------------------------------------------------------------------------
# ● Create Damage Number
#--------------------------------------------------------------------------
def create_damage_miss
dam = @value == "Missed" ? 5 : 6
self.bitmap = Bitmap.new(@cw * 5, @ch)
src_rect = Rect.new(0, dam * @ch, @cw * 10, @ch)
self.bitmap.blt(0, 0, @image, src_rect)
@center_x += 5
end
#--------------------------------------------------------------------------
# ● Create Damage Number
#--------------------------------------------------------------------------
def create_damage_number
dam = @critical ? @ch * 2 : @value >= 0 ? 0 : @ch
f = @value >= 0 ? 0 : 1
number_value = @value.to_s.split(//)
self.bitmap = Bitmap.new(@mp_space + (@cw * number_value.size),@ch * 4)
for r in f...number_value.size
number_value_abs = number_value[r].to_i
src_rect = Rect.new(@cw * number_value_abs, dam, @cw, @ch)
self.bitmap.blt(@mp_space + (@cw * r), 0, @image, src_rect)
@center_x += 1
end
if @type == "MP" or @type == "TP"
ty = @type == "MP" ? 3 : 4
src_rect = Rect.new(0, @ch * ty, @cw * 10, @ch)
self.bitmap.blt(0, 0, @image, src_rect)
@center_x += 2
end
@center_x += 1 if @value < 0
end
#--------------------------------------------------------------------------
# ● Create Damage String
#--------------------------------------------------------------------------
def create_damage_string
string_size = @value.to_s.split(//)
@stg_size = string_size.size > 0 ? ((1 + string_size.size) * 24) : 32
self.bitmap = Bitmap.new(@stg_size,32)
self.bitmap.font.size = 25
self.bitmap.font.bold = true
@center_x = 2 + (string_size.size / 2)
if @state_index != nil
draw_states
else
execute_font_color
damage_string = @value.to_s
self.bitmap.draw_text(0, 0, @stg_size, 32, damage_string,0)
end
end
#--------------------------------------------------------------------------
# ● Execute Font Color
#--------------------------------------------------------------------------
def execute_font_color
case @type
when "Gold"
@duration = 160
self.bitmap.font.color = Color.new(255,255,100)
when "Exp"
@duration = 120
self.bitmap.font.color = Color.new(0,255,100)
when "Level_UP"
self.bitmap.font.color = Color.new(50,155,255)
else
self.bitmap.font.color = Color.new(255,255,255)
end
end
#--------------------------------------------------------------------------
# ● Draw States
#--------------------------------------------------------------------------
def draw_states
icon_image = Cache.system("Iconset")
if @type == "States Plus"
self.bitmap.font.color = Color.new(200,150,50)
damage_string = "+ " + @value.to_s
elsif @type == "States Minus"
self.bitmap.font.color = Color.new(100,100,100)
damage_string = "- " + @value.to_s
end
rect = Rect.new(@state_index % 16 * 24, @state_index / 16 * 24, 24, 24)
self.bitmap.blt(0, 0, icon_image, rect)
self.bitmap.draw_text(26, 0, @stg_size - 24, 32, damage_string,0)
@center_x += 5
icon_image.dispose
icon_image = nil
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
return if @image == nil
@image.dispose
@image = nil
self.bitmap.dispose
self.bitmap = nil
@duration = -1
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
return if self.bitmap == nil
@duration -= 1 if @duration > 0
self.visible = @duration > 80 ? false : true
case @duration
when 65..80
self.opacity += 5
self.x += @speed_x
self.y -= 5
critical_effect(0.05)
when 50..65
self.opacity = 255
self.y -= 3
self.x += @speed_x
critical_effect(0.05)
when 35..50
self.opacity = 255
self.y += 3
critical_effect(-0.05)
when 0..35
self.opacity -= 7
self.y -= 1
critical_effect(-0.05)
end
dispose if self.opacity <= 0
end
#--------------------------------------------------------------------------
# ● Critical Effect
#--------------------------------------------------------------------------
def critical_effect(value)
return if !@critical
self.zoom_x += value
self.zoom_y = self.zoom_x
end
end
#==============================================================================
# ■ Game Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● damage Popup
#--------------------------------------------------------------------------
def damage_popup(value,type = nil, critical = false)
type = (type == nil and value.is_a?(Numeric)) ? "HP" : type
$game_map.events[@event_id].damage.push([value,type,critical]) if same_map? && @event_id > 0
end
end
#==============================================================================
# ■ Game Character
#==============================================================================
class Game_CharacterBase
attr_accessor :damage
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_damage_popup_initialize initialize
def initialize
@damage = []
mog_damage_popup_initialize
end
#--------------------------------------------------------------------------
# ● damage Popup
#--------------------------------------------------------------------------
def damage_popup(value,type = nil, critical = false)
type = (type == nil and value.is_a?(Numeric)) ? "HP" : type
@damage.push([value,type,critical])
end
end
#==============================================================================
# ■ Sprite Character
#==============================================================================
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_damage_popup_initialize initialize
def initialize(viewport, character = nil)
mog_damage_popup_initialize(viewport, character)
create_damage_sprite
end
#--------------------------------------------------------------------------
# ● Create Damage Sprite
#--------------------------------------------------------------------------
def create_damage_sprite
dispose_damage_sprite
@damage_sprites = []
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
alias mog_damage_popup_dispose dispose
def dispose
mog_damage_popup_dispose
dispose_damage_sprite
end
#--------------------------------------------------------------------------
# ● Dispose Damage Sprite
#--------------------------------------------------------------------------
def dispose_damage_sprite
return if @damage_sprites == nil
@damage_sprites.each {|sprite| sprite.dispose }
@damage_sprites.clear
@character.damage.clear
$game_temp.dispose_damage_sprite = false
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
alias mog_damage_popup_update update
def update
mog_damage_popup_update
update_damage_sprite
end
#--------------------------------------------------------------------------
# ● Create Damage
#--------------------------------------------------------------------------
def create_damage
index = 0
sx = self.x
sy = self.y + @ch
@damage_sprites = [] if @damage_sprites == nil
for i in @character.damage
@damage_sprites.push(Damage_Sprite.new(nil,sx,sy,i,index))
index += 1
end
@character.damage.clear
end
#--------------------------------------------------------------------------
# ● Update Damage Sprite
#--------------------------------------------------------------------------
def update_damage_sprite
return if @damage_sprites == nil
if @initial_damage == nil
@initial_damage = true
@character.damage.clear
return
end
create_damage if !@character.damage.empty?
if !@damage_sprites.empty?
clear = 0
for sprite in @damage_sprites
sprite.update
if sprite.duration == 0
sprite.dispose
end
clear += 1 if sprite.duration > 0
end
clear_damage if clear == 0
end
end
#--------------------------------------------------------------------------
# ● Update Damage Sprite
#--------------------------------------------------------------------------
def clear_damage
@damage_sprites.each {|sprite| sprite.dispose }
@damage_sprites.clear
@character.damage.clear
end
end
#=============================================================================
# ■ Game_Temp
#=============================================================================
class Game_Temp
attr_accessor :dispose_damage_sprite
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_dispose_damage_initialize initialize
def initialize
@dispose_damage_sprite = true
mog_dispose_damage_initialize
end
end
#=============================================================================
# ■ Scene Manager
#=============================================================================
class << SceneManager
#--------------------------------------------------------------------------
# ● Call
#--------------------------------------------------------------------------
alias mog_damage_pop_call call
def call(scene_class)
$game_temp.dispose_damage_sprite = true
mog_damage_pop_call(scene_class)
end
end
#=============================================================================
# ■ Scene Map
#=============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# ● Update Scene
#--------------------------------------------------------------------------
alias mog_dispose_damage_sprites_update update_scene
def update_scene
@spriteset.dispose_damage_sprites
mog_dispose_damage_sprites_update
end
end
#=============================================================================
# ■ Spriteset Map
#=============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# ● Dispose Damage Sprites
#--------------------------------------------------------------------------
def dispose_damage_sprites
return if !$game_temp.dispose_damage_sprite
return if @character_sprites == nil
@character_sprites.each {|sprite| sprite.dispose_damage_sprite }
$game_temp.dispose_damage_sprite = false
end
end
$mog_rgss3_damage_pop = true
module MOG_I_HUD
#Posição geral da HUD.
IHUD_POS = [10,345]
#Switch que desativa a HUD.
DISABLE_IHUD_SWITCH_ID = 5
#HP ------------------------------------
#Posição do ícone de HP.
HP_ICON_POS = [40,0]
#Posição do numero de HP.
H_NUMBER_POS = [0,10]
#Quantidade maxima de icones de HP.
ICON_HP_MAX = 12
#Espaço entre um icone e o outro.
ICON_HP_SPACE = 14
#SP -------------------------------------
#Posição do ícone de MP.
MP_ICON_POS = [50,32]
#Posição do numero de MP.
MP_NUMBER_POS = [65,48]
#Quantidade maxima de icones de MP.
ICON_MP_MAX = 8
#Espaço entre um icone e o outro.
ICON_MP_SPACE = 14
#Definição da prioridade da hud na tela.
HUD_Z = 105
end
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_System
attr_accessor :hud_visible
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias active_ihud_initialize initialize
def initialize
active_ihud_initialize
@hud_visible = true
end
end
#==============================================================================
# ■ Ihud
#==============================================================================
class Ihud
include MOG_I_HUD
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize
[url=home.php?mod=space&uid=95897]@actor[/url] = $game_party.members[0]
dispose
return if [url=home.php?mod=space&uid=95897]@actor[/url] == nil
@pre_leader_id = $game_party.members[0].id
create_layout
create_hp
create_hp_number
create_mp
create_mp_number
end
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def create_layout
@layout_sprite = Sprite.new
@layout_sprite.bitmap = Cache.system("IHud_Layout")
@layout_sprite.z = HUD_Z
@layout_sprite.x = IHUD_POS[0]
@layout_sprite.y = IHUD_POS[1]
end
#--------------------------------------------------------------------------
# ● Create HP
#--------------------------------------------------------------------------
def create_hp
@hp = @actor.hp
@maxhp = @actor.mhp
@hp_maxicon = ICON_HP_MAX
@hp_iconmax = ICON_HP_MAX
@hp_iconmax = 1 if @hp_iconmax <= 0
@hp2 = @actor.hp / @hp_iconmax
@hp_icon_image = Cache.system("IHud_HP")
@hp_icon_cw = @hp_icon_image.width / 2
@hp_icon_ch = @hp_icon_image.height
b_width = @hp_icon_cw * @hp_iconmax
@hp_icon_sprite = Sprite.new
@hp_icon_sprite.bitmap = Bitmap.new(b_width,@hp_icon_ch)
@hp_icon_sprite.z = 2 + HUD_Z
@hp_icon_sprite.x = HP_ICON_POS[0] + IHUD_POS[0]
@hp_icon_sprite.y = HP_ICON_POS[1] + IHUD_POS[1]
hp_refresh
end
#--------------------------------------------------------------------------
# ● Create HP Number
#--------------------------------------------------------------------------
def create_hp_number
@hp_number_image = Cache.system("Ihud_HP_Number")
@im_cw = @hp_number_image.width / 10
@im_ch = @hp_number_image.height
@hp_number_sprite = Sprite.new
@hp_number_sprite.bitmap = Bitmap.new(@hp_number_image.width,@hp_number_image.height)
@hp_number_sprite.z = 3 + HUD_Z
@hp_number_sprite.y = H_NUMBER_POS[1] + IHUD_POS[1]
hp_number_refresh
end
#--------------------------------------------------------------------------
# ● Create MP
#--------------------------------------------------------------------------
def create_mp
@mp = @actor.mp
@maxmp = @actor.mmp
@mp_maxicon = ICON_MP_MAX
@mp_iconmax = ICON_MP_MAX
@mp_iconmax = 1 if @mp_iconmax <= 0
@mp2 = @actor.hp / @mp_iconmax
@mp_icon_image = Cache.system("IHud_MP")
@mp_icon_cw = @mp_icon_image.width / 2
@mp_icon_ch = @mp_icon_image.height
b_width = @mp_icon_cw * @mp_iconmax
@mp_icon_sprite = Sprite.new
@mp_icon_sprite.bitmap = Bitmap.new(b_width,@mp_icon_ch)
@mp_icon_sprite.z = 2 + HUD_Z
@mp_icon_sprite.x = MP_ICON_POS[0] + IHUD_POS[0]
@mp_icon_sprite.y = MP_ICON_POS[1] + IHUD_POS[1]
mp_refresh
end
#--------------------------------------------------------------------------
# ● Create MP Number
#--------------------------------------------------------------------------
def create_mp_number
@mp_number_image = Cache.system("Ihud_MP_Number")
@im_cw2 = @mp_number_image.width / 10
@im_ch2 = @mp_number_image.height
@mp_number_sprite = Sprite.new
@mp_number_sprite.bitmap = Bitmap.new(@mp_number_image.width,@mp_number_image.height)
@mp_number_sprite.z = 3 + HUD_Z
@mp_number_sprite.y = MP_NUMBER_POS[1] + IHUD_POS[1]
mp_number_refresh
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
return if @layout_sprite == nil
@layout_sprite.bitmap.dispose
@layout_sprite.dispose
@layout_sprite = nil
@hp_icon_image.dispose
@hp_icon_sprite.bitmap.dispose
@hp_icon_sprite.dispose
@hp_number_image.dispose
@hp_number_sprite.bitmap.dispose
@hp_number_sprite.dispose
@mp_icon_image.dispose
@mp_icon_sprite.bitmap.dispose
@mp_icon_sprite.dispose
@mp_number_image.dispose
@mp_number_sprite.bitmap.dispose
@mp_number_sprite.dispose
end
#--------------------------------------------------------------------------
# ● refresh_actor
#--------------------------------------------------------------------------
def refresh_actor
dispose
initialize
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
if @actor == nil
refresh_actor if $game_party.members[0] != nil
return
end
update_visible
if can_refresh_hp?
hp_refresh
hp_number_refresh
end
if can_refresh_mp?
mp_refresh
mp_number_refresh
end
refresh_actor if can_refresh_hud?
end
#--------------------------------------------------------------------------
# ● Update Visible
#--------------------------------------------------------------------------
def update_visible
#Visible
if $game_message.visible or $game_system.hud_visible == false
vis = false
else
vis = true
end
@layout_sprite.visible = vis
@hp_icon_sprite.visible = vis
@hp_number_sprite.visible = vis
@mp_icon_sprite.visible = vis
@mp_number_sprite.visible = vis
end
#--------------------------------------------------------------------------
# ● Can Refresh HP?
#--------------------------------------------------------------------------
def can_refresh_hp?
return false if $game_party.members[0] == nil
return true if @hp != $game_party.members[0].hp
return true if @maxhp != $game_party.members[0].mhp
return false
end
#--------------------------------------------------------------------------
# ● Can Refresh MP?
#--------------------------------------------------------------------------
def can_refresh_mp?
return false if $game_party.members[0] == nil
return true if @mp != $game_party.members[0].mp
return true if @maxmp != $game_party.members[0].mmp
return false
end
#--------------------------------------------------------------------------
# ● HP Refresh
#--------------------------------------------------------------------------
def hp_refresh
@hp_icon_sprite.bitmap.clear
@hp = @actor.hp
@maxhp = @actor.mhp
@hp2 = @actor.hp / @hp_iconmax
@hp3 = @actor.hp - (@hp2 * @hp_iconmax)
for i in 0...@hp_iconmax
@hp_icon_src_rect = Rect.new(0,0, @hp_icon_cw, @hp_icon_ch)
@hp_icon_sprite.bitmap.blt(i * ICON_HP_SPACE , 0, @hp_icon_image, @hp_icon_src_rect)
end
@hp2 = @hp2 - 1 if @hp3 == 0 and @actor.hp > 0
@hp3 = @hp_iconmax if @hp3 == 0 and @actor.hp > 0
for i in 0...@hp3
@hp_icon_src_rect = Rect.new(@hp_icon_cw,0, @hp_icon_cw, @hp_icon_ch)
@hp_icon_sprite.bitmap.blt(i * ICON_HP_SPACE , 0, @hp_icon_image, @hp_icon_src_rect)
end
end
#--------------------------------------------------------------------------
# ● HP Number Refresh
#--------------------------------------------------------------------------
def hp_number_refresh
@hp_number_sprite.bitmap.clear
@hp_number_text = @hp2.abs.to_s.split(//)
ex = 0
for r in [email]0..@hp_number_text.size[/email] - 1
ex += 1
@hp_number_abs = @hp_number_text[r].to_i
@hp_src_rect = Rect.new(@im_cw * @hp_number_abs, 0, @im_cw, @im_ch)
@hp_number_sprite.bitmap.blt(@im_cw * r, 0, @hp_number_image, @hp_src_rect)
end
x_correction = (@im_cw / 2) * ex
@hp_number_sprite.x = MP_NUMBER_POS[0] + IHUD_POS[0] - x_correction
end
#--------------------------------------------------------------------------
# ● MP Refresh
#--------------------------------------------------------------------------
def mp_refresh
@mp_icon_sprite.bitmap.clear
@mp = @actor.mp
@maxmp = @actor.mmp
@mp2 = @actor.mp / @mp_iconmax
@mp3 = @actor.mp - (@mp2 * @mp_iconmax)
for i in 0...@mp_iconmax
@mp_icon_src_rect = Rect.new(0,0, @mp_icon_cw, @mp_icon_ch)
@mp_icon_sprite.bitmap.blt(i * ICON_MP_SPACE , 0, @mp_icon_image, @mp_icon_src_rect)
end
@mp2 = @mp2 - 1 if @mp3 == 0 and @actor.mp > 0
@mp3 = @mp_iconmax if @mp3 == 0 and @actor.mp > 0
for i in 0...@mp3
@mp_icon_src_rect = Rect.new(@mp_icon_cw,0, @mp_icon_cw, @mp_icon_ch)
@mp_icon_sprite.bitmap.blt(i * ICON_HP_SPACE , 0, @mp_icon_image, @mp_icon_src_rect)
end
end
#--------------------------------------------------------------------------
# ● MP Number Refresh
#--------------------------------------------------------------------------
def mp_number_refresh
@mp_number_sprite.bitmap.clear
@mp_number_text = @mp2.abs.to_s.split(//)
ex = 0
for r in [email]0..@mp_number_text.size[/email] - 1
ex += 1
@mp_number_abs = @mp_number_text[r].to_i
@mp_src_rect = Rect.new(@im_cw2 * @mp_number_abs, 0, @im_cw2, @im_ch2)
@mp_number_sprite.bitmap.blt(@im_cw2 * r, 0, @mp_number_image, @mp_src_rect)
end
x_correction = (@im_cw2 / 2) * ex
@mp_number_sprite.x = MP_NUMBER_POS[0] + IHUD_POS[0] - x_correction
end
#--------------------------------------------------------------------------
# ● Can Refresh Hud
#--------------------------------------------------------------------------
def can_refresh_hud?
if $game_party.members[0] == nil
return true if @pre_leader_id != nil
elsif $game_party.members[0] != nil
return true if @pre_leader_id == nil
return true if @pre_leader_id != $game_party.members[0].id
end
return false
end
end
#==============================================================================
# ■ Spriteset_Map
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
alias mog_ihud_initialize initialize
def initialize
@ihud = Ihud.new
mog_ihud_initialize
end
#--------------------------------------------------------------------------
# ● dispose
#--------------------------------------------------------------------------
alias mog_ihud_dispose dispose
def dispose
@ihud.dispose
mog_ihud_dispose
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
alias mog_ihud_update update
def update
@ihud.update
mog_ihud_update
end
end
$mog_rgss3_ihud = true
module MOG_S_HUD
#Posição geral da HUD.
S_HUD_POS = [0,-54]
#Posição do layout de HP
S_LAYOUT_HP_POS = [-22,3]
#Posição do medidor de HP
S_METER_HP_POS = [-20,5]
#Posição do layout de MP
S_LAYOUT_MP_POS = [-20,16]
#Posição do medidor de MP
S_METER_MP_POS = [-20,16]
#Velocidade da animação do medidor
METER_FLOW_SPEED = 2
#Prioridade da Hud na tela.
HUD_Z = 100
end
#==============================================================================
# ■ Game_System
#==============================================================================
class Game_System
attr_accessor :hud_visible
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias active_shud_initialize initialize
def initialize
active_shud_initialize
@hud_visible = false
end
end
#==============================================================================
# ■ S HUD
#==============================================================================
class S_HUD
include MOG_S_HUD
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize
@actor = $game_party.members[0]
dispose
return if @actor == nil
@pre_leader_id = $game_party.members[0].id
create_layout
create_hp
create_mp
update_position
end
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def create_layout
@layout_sprite = Sprite.new
@layout_sprite.bitmap = Cache.system("S_Hud_Layout")
@layout_sprite.z = HUD_Z
@layout_sprite2 = Sprite.new
@layout_sprite2.bitmap = Cache.system("S_Hud_Layout2")
@layout_sprite2.z = HUD_Z
end
#--------------------------------------------------------------------------
# ● Create HP
#--------------------------------------------------------------------------
def create_hp
@hp = @actor.hp
@hp_flow = 0
@hp_damage_flow = 0
@hp_old = @actor.hp
@hp_ref = @hp_old
@hp_image = Cache.system("S_Hud_HP_Meter")
@hp_range = @hp_image.width / 3
@hp_height = @hp_image.height / 2
@hp_width = @hp_range * @actor.hp / @actor.mhp
@hp_width_old = @hp_width
@hp_sprite = Sprite.new
@hp_sprite.bitmap = Bitmap.new(@hp_image.width,@hp_image.height)
@hp_sprite.z = HUD_Z + 2
update_hp
end
#--------------------------------------------------------------------------
# ● Create MP
#--------------------------------------------------------------------------
def create_mp
@mp = @actor.mp
@mp_flow = 0
@mp_damage_flow = 0
@mp_old = @actor.mp
@mp_ref = @mp_old
@mp_image = Cache.system("S_Hud_MP_Meter")
@mp_range = @mp_image.width / 3
@mp_height = @mp_image.height
@mp_width = @mp_range * @actor.mp / @actor.mhp
@mp_width_old = @mp_width
@mp_sprite = Sprite.new
@mp_sprite.bitmap = Bitmap.new(@mp_image.width,@mp_image.height)
@mp_sprite.z = HUD_Z + 2
update_mp
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
return if @layout_sprite == nil
@layout_sprite.bitmap.dispose
@layout_sprite.dispose
@layout_sprite = nil
@layout_sprite2.bitmap.dispose
@layout_sprite2.dispose
@hp_image.dispose
@hp_sprite.bitmap.dispose
@hp_sprite.dispose
@mp_image.dispose
@mp_sprite.bitmap.dispose
@mp_sprite.dispose
end
#--------------------------------------------------------------------------
# ● refresh_actor
#--------------------------------------------------------------------------
def refresh_actor
dispose
initialize
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
if @actor == nil
refresh_actor if $game_party.members[0] != nil
return
end
update_visible
update_position
update_hp
update_mp
refresh_actor if can_refresh_hud?
end
#--------------------------------------------------------------------------
# ● Update Position
#--------------------------------------------------------------------------
def update_position
px = $game_player.screen_x + S_HUD_POS[0]
py = $game_player.screen_y + S_HUD_POS[1]
@layout_sprite.x = px + S_LAYOUT_HP_POS[0]
@layout_sprite.y = py + S_LAYOUT_HP_POS[1]
@layout_sprite2.x = px + S_LAYOUT_MP_POS[0]
@layout_sprite2.y = py + S_LAYOUT_MP_POS[1]
@hp_sprite.x = px + S_METER_HP_POS[0]
@hp_sprite.y = py + S_METER_HP_POS[1]
@mp_sprite.x = px + S_METER_MP_POS[0]
@mp_sprite.y = py + S_METER_MP_POS[1]
end
#--------------------------------------------------------------------------
# ● Update Visible
#--------------------------------------------------------------------------
def update_visible
#Visible
if $game_message.visible or $game_system.hud_visible == false
vis = false
else
vis = true
end
@layout_sprite.visible = vis
@layout_sprite2.visible = vis
@hp_sprite.visible = vis
@mp_sprite.visible = vis
end
#--------------------------------------------------------------------------
# ● Update HP
#--------------------------------------------------------------------------
def update_hp
@hp_sprite.bitmap.clear
@hp_width = @hp_range * @actor.hp / @actor.mhp
#HP Damage---------------------------------
if @hp_width_old != @hp_width
valor = (@hp_width_old - @hp_width) * 3 / 100
valor = 0.5 if valor < 1
@hp_width_old -= valor if @hp_width_old > @hp_width
if @hp_width_old < @hp_width
@hp_width_old = @hp_width
end
@hp_src_rect_old = Rect.new(@hp_flow, @hp_height,@hp_width_old, @hp_height)
@hp_sprite.bitmap.blt(0,0, @hp_image, @hp_src_rect_old)
end
#HP Real------------------------------------
@hp_src_rect = Rect.new(@hp_flow, 0,@hp_width, @hp_height)
@hp_sprite.bitmap.blt(0,0, @hp_image, @hp_src_rect)
@hp_flow += METER_FLOW_SPEED
if @hp_flow >= @hp_image.width - @hp_range
@hp_flow = 0
end
end
#--------------------------------------------------------------------------
# ● Update MP
#--------------------------------------------------------------------------
def update_mp
@mp_sprite.bitmap.clear
@mp_width = @mp_range * @actor.mp / @actor.mmp rescue 1
@mp_src_rect = Rect.new(@mp_flow, 0,@mp_width, @mp_height)
@mp_sprite.bitmap.blt(0,0, @mp_image, @mp_src_rect)
@mp_flow += METER_FLOW_SPEED
if @mp_flow >= @mp_image.width - @mp_range
@mp_flow = 0
end
end
#--------------------------------------------------------------------------
# ● Can Refresh Hud
#--------------------------------------------------------------------------
def can_refresh_hud?
if $game_party.members[0] == nil
return true if @pre_leader_id != nil
elsif $game_party.members[0] != nil
return true if @pre_leader_id == nil
return true if @pre_leader_id != $game_party.members[0].id
end
return false
end
end
#==============================================================================
# ■ Spriteset_Map
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
alias mog_shud_initialize initialize
def initialize
@shud = S_HUD.new
mog_shud_initialize
end
#--------------------------------------------------------------------------
# ● dispose
#--------------------------------------------------------------------------
alias mog_shud_dispose dispose
def dispose
@shud.dispose
mog_shud_dispose
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
alias mog_shud_update update
def update
@shud.update
mog_shud_update
end
end
$mog_rgss3_s_hud = true