赞 | 1 |
VIP | 392 |
好人卡 | 225 |
积分 | 46 |
经验 | 177731 |
最后登录 | 2020-12-8 |
在线时间 | 2037 小时 |
Lv3.寻梦者 虚空人形
- 梦石
- 0
- 星屑
- 4604
- 在线时间
- 2037 小时
- 注册时间
- 2011-8-11
- 帖子
- 3398
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 hcm 于 2013-4-14 23:04 编辑
如下,该脚本是在显示动画开始的同时就开始减血(经核实是因为附带了横版1.7的脚本,和显示敌人被打图片部分冲突),
是否可以在和横版1.7一起使用的前提下修改为动画结束后。
工程http://rpg.blue/forum.php?mod=attachment&aid=MTEwNDcxfDM2YTliMmIzfDEzNDE2MjQ3NTJ8MjM0ODQ2fDIzMTQyMQ%3D%3D- #==============================================================================
- # +++ MOG - Enemy HP Meter (v1.0) +++
- #==============================================================================
- # By Moghunter
- # http://www.atelier-rgss.com/
- #==============================================================================
- # Apresenta um medidor animado com o HP do inimigo.
- #==============================================================================
- # Para ocultar o HP do inimigo use a TAG abaixo na caixa de notas.
- #
- # <Hide HP>
- #
- #==============================================================================
- # Serão necessários as imagens.
- #
- # Battle_Enemy_HP_Layout.png
- # Battle_Enemy_HP_Meter.png
- #
- #==============================================================================
- module MOG_ENEMY_HP
- #Posição geral do medidor em relação ao battler.
- POSITION_CORRECTION = [0,0]
- #Posição do medidor de HP.
- HP_METER_POSITION = [2,4]
- #Prioridade do medidor na tela.
- PRIORITY_Z = 101
- end
- #==============================================================================
- # ■ Game Enemy
- #==============================================================================
- class Game_Enemy < Game_Battler
- attr_accessor :hp_meter_active
-
- #--------------------------------------------------------------------------
- # ● Initialize
- #--------------------------------------------------------------------------
- alias mog_enemy_hp_initialize initialize
- def initialize(index, enemy_id)
- mog_enemy_hp_initialize(index, enemy_id)
- hide = enemy.note =~ /<Hide HP>/i ? true : false
- @hp_meter_active = [false,hide]
- end
- end
- #==============================================================================
- # ■ Game_Battler
- #==============================================================================
- class Game_Battler < Game_BattlerBase
-
- #--------------------------------------------------------------------------
- # ● Item Apply
- #--------------------------------------------------------------------------
- alias mog_enemy_hp_item_apply item_apply
- def item_apply(user, item)
- mog_enemy_hp_item_apply(user, item)
- if self.is_a?(Game_Enemy)
- self.hp_meter_active[0] = true if @result.hp_damage != 0
- end
- end
- #--------------------------------------------------------------------------
- # ● Regenerate HP
- #--------------------------------------------------------------------------
- alias mog_enemy_hp_regenerate_hp regenerate_hp
- def regenerate_hp
- mog_enemy_hp_regenerate_hp
- if self.is_a?(Game_Enemy)
- self.hp_meter_active[0] = true if @result.hp_damage != 0
- end
- end
-
- end
-
- #==============================================================================
- # ■ Battle_Hud
- #==============================================================================
- class Enemy_HP
- include MOG_ENEMY_HP
-
- #--------------------------------------------------------------------------
- # ● Initialize
- #--------------------------------------------------------------------------
- def initialize(viewport = nil,enemy,image)
- @enemy = enemy
- @image = image
- @fade_time = -1
- create_layout
- create_hp_meter
- b_pos = [enemy.screen_x - (@layout.width / 2) + POSITION_CORRECTION[0], enemy.screen_y + POSITION_CORRECTION[1] - (@layout.height / 2)]
- @layout.opacity = 0
- @org_pos1 = [b_pos[0],b_pos[1]]
- @layout.x = @org_pos1[0]
- @layout.y = @org_pos1[1]
- @layout.visible = false
- @hp_meter.opacity = 0
- @hp_meter.visible = false
- @org_pos2 = [b_pos[0] + HP_METER_POSITION[0], b_pos[1] + HP_METER_POSITION[1]]
- @hp_meter.x = @org_pos2[0]
- @hp_meter.y = @org_pos2[1]
- @hp_meter.viewport = viewport
- @hp_meter.z = PRIORITY_Z
- @layout.viewport = viewport
- @layout.z = PRIORITY_Z
- @enemy.hp_meter_active[0] = false
- [url=home.php?mod=space&uid=94902]@Hide[/url] = @enemy.hp_meter_active[1]
- end
-
- #--------------------------------------------------------------------------
- # ● Create HP Meter
- #--------------------------------------------------------------------------
- def create_layout
- @layout = Sprite.new
- @layout.bitmap = @image[0]
- end
-
- #--------------------------------------------------------------------------
- # ● Create HP Meter
- #--------------------------------------------------------------------------
- def create_hp_meter
- @meter_cw = @image[1].width
- @meter_ch = @image[1].height / 2
- @hp_meter = Sprite.new
- @hp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
- @hp_width_old = @meter_cw * @enemy.hp / @enemy.mhp
- end
-
- #--------------------------------------------------------------------------
- # ● Hp Flow Update
- #--------------------------------------------------------------------------
- def update_hp_flow
- return if [email protected]
- hp_width = @meter_cw * @enemy.hp / @enemy.mhp
- @hp_meter.bitmap.clear
- execute_damage_flow(hp_width)
- hp_src_rect = Rect.new(0, 0,hp_width, @meter_ch)
- @hp_meter.bitmap.blt(0,0, @image[1], hp_src_rect)
- end
-
- #--------------------------------------------------------------------------
- # ● Execute Damage Flow
- #--------------------------------------------------------------------------
- def execute_damage_flow(hp_width)
- n = (@hp_width_old - hp_width).abs * 3 / 100
- damage_flow = [[n, 2].min,0.5].max
- @hp_width_old -= damage_flow
- if @hp_width_old <= hp_width
- @hp_width_old = hp_width
- end
- src_rect_old = Rect.new(0,@meter_ch,@hp_width_old, @meter_ch)
- @hp_meter.bitmap.blt(0,0, @image[1], src_rect_old)
- end
-
- #--------------------------------------------------------------------------
- # ● Dispose
- #--------------------------------------------------------------------------
- def dispose
- @layout.bitmap.dispose
- @layout.dispose
- @hp_meter.bitmap.dispose
- @hp_meter.dispose
- end
-
- #--------------------------------------------------------------------------
- # ● Update
- #--------------------------------------------------------------------------
- def update
- return if @hide
- update_fade
- update_visible
- update_hp_flow
- refresh if @enemy.hp_meter_active[0]
- end
-
- #--------------------------------------------------------------------------
- # ● Update Fade
- #--------------------------------------------------------------------------
- def update_fade
- @fade_time -= 1 if @fade_time > 0
- return if @fade_time != 0
- @layout.opacity -= 10
- @hp_meter.opacity -= 10
- @layout.x += 1
- @hp_meter.x += 1
- @fade_time = -1 if @layout.opacity == 0
- end
-
- #--------------------------------------------------------------------------
- # ● Update Visible
- #--------------------------------------------------------------------------
- def update_visible
- return if [email protected]
- vis = can_visible?
- @layout.visible = vis
- @hp_meter.visible = vis
- end
-
- #--------------------------------------------------------------------------
- # ● Refresh
- #--------------------------------------------------------------------------
- def refresh
- @enemy.hp_meter_active[0] = false
- @layout.opacity = 255
- @hp_meter.opacity = 255
- @layout.visible = true
- @hp_meter.visible = true
- @fade_time = 60
- @layout.x = @org_pos1[0]
- @layout.y = @org_pos1[1]
- @hp_meter.x = @org_pos2[0]
- @hp_meter.y = @org_pos2[1]
- hp_width = @meter_cw * @enemy.hp / @enemy.mhp
- @hp_width_old = hp_width if @hp_width_old < hp_width
- update_hp_flow
- end
-
- #--------------------------------------------------------------------------
- # ● Can Visible?
- #--------------------------------------------------------------------------
- def can_visible?
- return false if @layout.opacity == 0
- return true
- end
-
- end
- #==============================================================================
- # ■ Spriteset Battle
- #==============================================================================
- class Spriteset_Battle
-
- #--------------------------------------------------------------------------
- # ● Initialize
- #--------------------------------------------------------------------------
- alias mog_enemy_hp_initialize initialize
- def initialize
- mog_enemy_hp_initialize
- create_enemy_hp
- end
-
- #--------------------------------------------------------------------------
- # ● Create Battle Hud
- #--------------------------------------------------------------------------
- def create_enemy_hp
- ie1 = Cache.system("Battle_Enemy_HP_Layout")
- ie2 = Cache.system("Battle_Enemy_HP_Meter")
- @enemy_hp_images = [ie1,ie2]
- @enemy_hp = []
- for i in $game_troop.members
- @enemy_hp.push(Enemy_HP.new(@viewport1,i,@enemy_hp_images))
- end
- end
-
- #--------------------------------------------------------------------------
- # ● Dispose
- #--------------------------------------------------------------------------
- alias mog_enemy_hp_dispose dispose
- def dispose
- mog_enemy_hp_dispose
- dispose_enemy_hp
- end
-
- #--------------------------------------------------------------------------
- # ● Dispose Enemy HP
- #--------------------------------------------------------------------------
- def dispose_enemy_hp
- return if @enemy_hp_images == nil
- @enemy_hp_images.each {|sprite| sprite.dispose }
- @enemy_hp_images.clear
- @enemy_hp.each {|sprite| sprite.dispose }
- @enemy_hp.clear
- end
-
- #--------------------------------------------------------------------------
- # ● Update
- #--------------------------------------------------------------------------
- alias mog_enemy_hp_update update
- def update
- mog_enemy_hp_update
- update_enemy_hp
- end
-
- #--------------------------------------------------------------------------
- # ● Update Enemy HP
- #--------------------------------------------------------------------------
- def update_enemy_hp
- return if @enemy_hp_images == nil
- @enemy_hp.each {|sprite| sprite.update }
- end
- end
- $mog_rgss3_enemy_hp_meter = true
复制代码 |
|