赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 932 |
最后登录 | 2015-2-10 |
在线时间 | 5 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 5 小时
- 注册时间
- 2015-2-4
- 帖子
- 5
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
#==============================================================================
# +++ MOG VX - Unit Meter V.1.0 +++
#==============================================================================
module MOG_UNIT_METER
#Posição do layout. (X,Y)
UNIT_METER_POS = [0,0]
#敌人血槽位置. (X,Y)
TROOP_METER_POS = [133,13]
#我方人员坐标. (X,Y)
PARTY_METER_POS = [605,13] #305,13
#火球位置. (X,Y)
FIRE_POS = [305,0]
#Prioridade dos medidores.
PRIORITY = 50
end
#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party < Game_Unit
attr_accessor :hpa
attr_accessor :hpa_max
attr_accessor :mpa
attr_accessor :mpa_max
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
alias mog_party_hpmp_initialize initialize
def initialize
mog_party_hpmp_initialize
@hpa = 0
@hpa_max = 1
@mpa = 0
@mpa_max = 1
end
#--------------------------------------------------------------------------
# ● hpa_max
#--------------------------------------------------------------------------
def hpa_max
n = 0
for i in $game_party.members
n += i.maxhp
end
@hpa_max = n
end
#--------------------------------------------------------------------------
# ● hpa
#--------------------------------------------------------------------------
def hpa
n = 0
for i in $game_party.members
n += i.hp
end
n2 = [[n, 0].max, @hpa_max].min
@hpa = n2
end
#--------------------------------------------------------------------------
# ● mpa_max
#--------------------------------------------------------------------------
def mpa_max
n = 0
for i in $game_party.members
n += i.maxmp
end
@mpa_max = n
end
#--------------------------------------------------------------------------
# ● mpa
#--------------------------------------------------------------------------
def mpa
n = 0
for i in $game_party.members
n += i.mp
end
n2 = [[n, 0].max, @mpa_max].min
@mpa = n2
end
end
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
attr_accessor :troop_hp
attr_accessor :troop_maxhp
attr_accessor :troop_mp
attr_accessor :troop_maxmp
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
alias mog_hpmp_troop_initialize initialize
def initialize
mog_hpmp_troop_initialize
@troop_hp = 0
@troop_maxhp = 1
@troop_mp = 0
@troop_maxmp = 1
end
#--------------------------------------------------------------------------
# ● Troop_maxhp
#--------------------------------------------------------------------------
def troop_maxhp
n = 0
for enemy in members
n += enemy.maxhp
end
@troop_maxhp = n
end
#--------------------------------------------------------------------------
# ● Troop_hp
#--------------------------------------------------------------------------
def troop_hp
n = 0
for enemy in members
n += enemy.hp
end
n2 = [[n, 0].max, @troop_maxhp].min
@troop_hp = n2
end
#--------------------------------------------------------------------------
# ● Troop_maxmp
#--------------------------------------------------------------------------
def troop_maxmp
n = 0
for enemy in members
n += enemy.maxmp
end
@troop_maxmp = n
end
#--------------------------------------------------------------------------
# ● Troop_mp
#--------------------------------------------------------------------------
def troop_mp
n = 0
for enemy in members
n += enemy.mp
end
n2 = [[n, 0].max, @troop_maxmp].min
@troop_mp = n2
end
end
#===============================================================================
# ■ Unit_Meter_Sprite
#===============================================================================
class Unit_Meter_Sprite < Sprite
include MOG_UNIT_METER
attr_accessor :fade
attr_accessor :party_shake
attr_accessor :troop_shake
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize
super
@fade = false
@troop_shake = 0
# @party_shake = 0
create_layout
create_troop_meter
create_party_meter
create_fire #刷新火球图案
end
#--------------------------------------------------------------------------
# ● Create Troop Meter 血槽图案
#--------------------------------------------------------------------------
def create_layout
@layout = Sprite.new
@layout.bitmap = Cache.system("Unit_Layout")
@layout.z = 1 + PRIORITY
@layout.x = UNIT_METER_POS[0]
@layout.y = UNIT_METER_POS[1]
end
#--------------------------------------------------------------------------
# ● Create Troop Meter 敌人血量图案
#--------------------------------------------------------------------------
def create_troop_meter
@troop_flow = 0
@troop_damage_flow = 0
@troop_image = Cache.system("Unit_Meter")
@troop_bitmap = Bitmap.new(@troop_image.width,@troop_image.height)
@troop_range = @troop_image.width / 2 #3 血量图长度除以3
@troop_width = @troop_range * ($game_troop.troop_hp / $game_troop.troop_maxhp)
# @troop_width = 113*12000/12000
@troop_width_old = @troop_width
@troop_height = @troop_image.height / 2
@troop_src_rect = Rect.new(@troop_range , 0, @troop_width , @troop_height)
#@troop_range = 113,@troop_width = 0,@troop_height = 6
@troop_bitmap.blt(0,0, @troop_image, @troop_src_rect)
@troop_sprite = Sprite.new
@troop_sprite.bitmap = @troop_bitmap
@troop_sprite.mirror = true
@troop_sprite.x =(-@troop_range )+ TROOP_METER_POS[0] + UNIT_METER_POS[0]
# @troop_range = 113
# TROOP_METER_POS[0] = 113
# UNIT_METER_POS[0] = 0
# (-@troop_range * 2)+
@troop_pre_y = TROOP_METER_POS[1] + UNIT_METER_POS[1]
@troop_sprite.y = @troop_pre_y
@troop_sprite.z = 2 + PRIORITY
update_flow_troop_meter
end
#--------------------------------------------------------------------------
# ● Create Troop Meter 人物血量图案
#--------------------------------------------------------------------------
def create_party_meter
@party_flow = 0
@party_damage_flow = 0
@party_image = Cache.system("Unit_Meter")
@party_bitmap = Bitmap.new(@party_image.width,@party_image.height)
@party_range = @party_image.width / 3
@party_width = @party_range * $game_party.hpa / $game_party.hpa_max
@party_width_old = @party_width
@party_height = @party_image.height / 2
@party_src_rect = Rect.new(@party_range, 0, @party_width, @party_height)
@party_bitmap.blt(0,0, @party_image, @party_src_rect)
@party_sprite = Sprite.new
@party_sprite.bitmap = @party_bitmap
@party_sprite.x = PARTY_METER_POS[0] + UNIT_METER_POS[0]
@party_pre_y = PARTY_METER_POS[1] + UNIT_METER_POS[1]
@party_sprite.y = @party_pre_y
@party_sprite.z = 2 + PRIORITY
update_flow_party_meter
end
#--------------------------------------------------------------------------
# ● create_fire 火球动画
#--------------------------------------------------------------------------
def create_fire
@fire_flow = 0
@fire_flow_speed = 0
@fire_image = Cache.system("Unit_Fire")
@fire_bitmap = Bitmap.new(@fire_image.width,@fire_image.height)
@fire_width = @fire_image.width / 4
@fire_src_rect_back = Rect.new(0, 0,@fire_width, @fire_image.height)
@fire_bitmap.blt(0,0, @fire_image, @fire_src_rect_back)
@fire_sprite = Sprite.new
@fire_sprite.bitmap = @fire_bitmap
@fire_sprite.z = 3 + PRIORITY
@fire_pre_x = FIRE_POS[0] + UNIT_METER_POS[0]
@fire_sprite.x = @fire_pre_x
@fire_sprite.y = FIRE_POS[1] + UNIT_METER_POS[1]
update_fire
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
@layout.bitmap.dispose
@layout.dispose
@troop_sprite.bitmap.dispose
@troop_sprite.dispose
@troop_bitmap.dispose
# @party_sprite.bitmap.dispose
# @party_sprite.dispose
# @party_bitmap.dispose
@fire_sprite.bitmap.dispose
@fire_sprite.dispose
@fire_bitmap.dispose
super
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
super
update_flow_troop_meter unless $game_troop.troop_maxhp == 0
# update_flow_party_meter unless $game_party.hpa_max == 0
update_fade if @fade == true
update_fire
update_fire_x
update_shake if @fade == false
end
#--------------------------------------------------------------------------
# ● update_fire_x
#--------------------------------------------------------------------------
def update_fire_x
if @troop_shake != 0 or @party_shake != 0
case @troop_shake
when 11..20
@fire_sprite.x -= 4
@fire_sprite.zoom_x += 0.09
@fire_sprite.zoom_y += 0.02
when 1..10
@fire_sprite.x += 4
@fire_sprite.zoom_x -= 0.09
@fire_sprite.zoom_y -= 0.02
end
case @party_shake
when 11..20
@fire_sprite.x += 2
@fire_sprite.zoom_x += 0.09
@fire_sprite.zoom_y += 0.02
when 1..10
@fire_sprite.x -= 2
@fire_sprite.zoom_x -= 0.09
@fire_sprite.zoom_y -= 0.02
end
else
clear_fire
end
end
#--------------------------------------------------------------------------
# ● clear_fire
#--------------------------------------------------------------------------
def clear_fire
@fire_sprite.x = @fire_pre_x
@fire_sprite.zoom_x = 1.00
@fire_sprite.zoom_y = 1.00
end
#--------------------------------------------------------------------------
# ● update_shake
#--------------------------------------------------------------------------
def update_shake
if @troop_shake > 0
@troop_shake -= 1
@troop_sprite.y = @troop_pre_y + rand(5)
else
@troop_sprite.y = @troop_pre_y
end
# if @party_shake > 0
# @party_shake -= 1
# @party_sprite.y = @party_pre_y + rand(5)
# else
# @party_sprite.y = @party_pre_y
# end
end
#--------------------------------------------------------------------------
# ● update_fade
#--------------------------------------------------------------------------
def update_fade
if @layout.opacity > 0
@troop_sprite.opacity -= 4
# @party_sprite.opacity -= 4
@fire_sprite.opacity -= 4
@layout.opacity -= 4
@troop_sprite.y -= 1
# @party_sprite.y -= 1
@layout.y -= 1
@fire_sprite.y -= 1
end
end
#--------------------------------------------------------------------------
# ● Update_flow_troop_meter
#--------------------------------------------------------------------------
def update_flow_troop_meter
@troop_sprite.bitmap.clear
@troop_width = @troop_range * $game_troop.troop_hp / $game_troop.troop_maxhp
#troop Damage---------------------------------
valor = (@troop_width_old - @troop_width) * 3 / 100
valor = 0.5 if valor < 1
if @troop_width_old != @troop_width
@troop_width_old -= valor if @troop_width_old > @troop_width
if @troop_width_old < @troop_width
@troop_width_old = @troop_width
end
@troop_src_rect_old = Rect.new(@troop_flow, @troop_height,@troop_width_old, @troop_height)
@troop_bitmap.blt(0,0, @troop_image, @troop_src_rect_old)
end
@troop_src_rect = Rect.new(@troop_flow, 0,@troop_width, @troop_height)
@troop_bitmap.blt(0,0, @troop_image, @troop_src_rect)
@troop_flow += 3
if @troop_flow >= @troop_image.width - @troop_range
@troop_flow = 0
end
end
#--------------------------------------------------------------------------
# ● Update_flow_party_meter
#--------------------------------------------------------------------------
def update_flow_party_meter
@party_sprite.bitmap.clear
@party_width = @party_range * $game_party.hpa / $game_party.hpa_max
#party Damage---------------------------------
valor = (@party_width_old - @party_width) * 3 / 100
valor = 0.5 if valor < 1
if @party_width_old != @party_width
@party_width_old -= valor if @party_width_old > @party_width
if @party_width_old < @party_width
@party_width_old = @party_width
end
@party_src_rect_old = Rect.new(@party_flow, @party_height,@party_width_old, @party_height)
@party_bitmap.blt(0,0, @party_image, @party_src_rect_old)
end
@party_src_rect = Rect.new(@party_flow, 0,@party_width, @party_height)
@party_bitmap.blt(0,0, @party_image, @party_src_rect)
@party_flow += 3
if @party_flow >= @party_image.width - @party_range
@party_flow = 0
end
end
#--------------------------------------------------------------------------
# ● Fire Update 火球图案刷新
#--------------------------------------------------------------------------
def update_fire
@fire_sprite.bitmap.clear
@fire_flow_speed += 1
if @fire_flow_speed > 6
@fire_flow += 1
@fire_flow_speed = 0
end
@fire_flow = 0 if @fire_flow >= 4
@fire_src_rect_back = Rect.new(@fire_width * @fire_flow, 0,@fire_width, @fire_image.height)
@fire_bitmap.blt(0,0, @fire_image, @fire_src_rect_back)
end
end
#===============================================================================
# ■ Scene_Battle
#===============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● start
#--------------------------------------------------------------------------
alias mog_unit_meter_start start
def start
create_unit_meter_sprite
mog_unit_meter_start
end
#--------------------------------------------------------------------------
# ● create_unit_meter_sprite
#--------------------------------------------------------------------------
def create_unit_meter_sprite
@unit_meter = Unit_Meter_Sprite.new
end
#--------------------------------------------------------------------------
# ● dispose_info_viewport
#--------------------------------------------------------------------------
alias mog_unit_meter_dispose_info_viewport dispose_info_viewport
def dispose_info_viewport
mog_unit_meter_dispose_info_viewport
@unit_meter.dispose
end
#--------------------------------------------------------------------------
# ● update_basic
#--------------------------------------------------------------------------
alias mog_unit_meter_update_basic update_basic
def update_basic(main = false)
mog_unit_meter_update_basic(main)
@unit_meter.update
end
#--------------------------------------------------------------------------
# ● display_hp_damage
#--------------------------------------------------------------------------
alias mog_unit_meter_display_hp_damage display_hp_damage
def display_hp_damage(target, obj = nil)
if target.is_a?(Game_Actor) and target.hp_damage > 0
# @unit_meter.party_shake = 20
@unit_meter.clear_fire
else
if target.hp_damage > 0
@unit_meter.troop_shake = 20
@unit_meter.clear_fire
end
end
mog_unit_meter_display_hp_damage(target, obj)
end
#--------------------------------------------------------------------------
# ● process_victory
#--------------------------------------------------------------------------
alias mog_unit_meter_process_victory process_victory
def process_victory
@unit_meter.fade = true
@unit_meter.troop_shake = 0
# @unit_meter.party_shake = 0
mog_unit_meter_process_victory
end
end
$mog_rgssvx_unit_meter = true |
|