Project1

标题: 想求一个同时显示敌人血条和蓝条的脚本 [打印本页]

作者: ohehehe    时间: 2016-4-20 01:46
标题: 想求一个同时显示敌人血条和蓝条的脚本
血条的有很多,貌似没见到有蓝条的,伸手一回
作者: Vortur    时间: 2016-4-20 03:49
这问题有点太水了,多花点时间实验一下吧
根据脚本的不同,血条大约分为两类:
1.图片素材,此类直接使用图像软件修改即可
2.脚本生成,此类在下一时忘记了。但是在预设脚本中全局搜索“HP”就有线索了,然后按照预设脚本中的设置方法,对照插件脚本来修改应该可以



作者: 黑崎一护    时间: 2016-4-20 10:15





RUBY 代码复制
  1. #==============================================================================
  2.     # 功能:战斗中显示敌人血和蓝于敌人脚下
  3.     # 适用:RMVX Ace
  4.     # 作者:殇殃 2012.3.10
  5.     # 使用方法:复制整个脚本插入到Main之前
  6.     # 注意:由于血条是显示在敌人脚下,所以敌群的位置不能太靠底部,不然会被挡住。
  7.     #       可以自行更改坐标修改显示位置、血条的颜色等。
  8.     #==============================================================================
  9.     # ■ Window_Base
  10.     #------------------------------------------------------------------------------
  11.     #  游戏中全部窗口的超级类。
  12.     #==============================================================================
  13.  
  14.     class Window_Base < Window
  15.       #--------------------------------------------------------------------------
  16.       # ● 描绘敌人HP
  17.       #--------------------------------------------------------------------------
  18.       def draw_enemy_hp(enemy, x, y, width = 80)
  19.         draw_gauge(x, y, width, enemy.hp_rate, hp_gauge_color1, hp_gauge_color2)
  20.         self.contents.font.color = system_color
  21.         self.contents.draw_text(x, y, 30, line_height, Vocab::hp_a)
  22.         self.contents.font.color = hp_color(enemy)
  23.         self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.hp, 2)
  24.         #一个数字占16像素
  25.       end
  26.       #--------------------------------------------------------------------------
  27.       # ● 绘制敌人MP
  28.       #--------------------------------------------------------------------------
  29.       def draw_enemy_mp(enemy, x, y, width = 80)
  30.         draw_gauge(x, y, width, enemy.mp_rate, mp_gauge_color1, mp_gauge_color2)
  31.         self.contents.font.color = system_color
  32.         self.contents.draw_text(x, y, 30, line_height, Vocab::mp_a)
  33.         self.contents.font.color = mp_color(enemy)
  34.         self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.mp, 2)
  35.       end
  36.     end
  37.     #==============================================================================
  38.     # ■ Sprite_Battler
  39.     #------------------------------------------------------------------------------
  40.     #  战斗显示用活动块。Game_Battler 类的实例监视、
  41.     # 活动块的状态的监视、活动块状态自动变化。
  42.     #==============================================================================
  43.  
  44.     class Sprite_Battler < Sprite_Base
  45.       #--------------------------------------------------------------------------
  46.       # ● 初始化对象
  47.       #     viewport : 视区
  48.       #     battler  : 战斗者 (Game_Battler)
  49.       #--------------------------------------------------------------------------
  50.       def initialize(viewport, battler = nil)
  51.         super(viewport)
  52.         @battler = battler
  53.         @battler_visible = false
  54.         @effect_type = nil      
  55.         @effect_duration = 0   
  56.         if @battler.is_a?(Game_Enemy)
  57.           width = 24 + 80 #边距12*2+血条的长度(在draw_enemy_hp中定义)
  58.           height = 24 + 24*2 #边距12*2+line_height*2
  59.           x = @battler.screen_x - width/2 #screen_x是怪物图片水平方向上的中点位置
  60.           y = @battler.screen_y - 12 #边距12,显示HP/MP的窗口无边框
  61.           @enemy_hpmp_window = Window_Base.new(x, y, width, height)
  62.           @enemy_hpmp_window.opacity = 0
  63.           @enemy_hpmp_window.contents = Bitmap.new(width - 24, height - 24)#位图比窗口小24像素取消边框
  64.           @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 0)
  65.           @old_hp = -1
  66.           @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 24)
  67.           @old_mp = -1
  68.         end
  69.       end
  70.       #--------------------------------------------------------------------------
  71.       # ● 释放
  72.       #--------------------------------------------------------------------------
  73.       def dispose
  74.         if self.bitmap != nil
  75.           self.bitmap.dispose
  76.           @enemy_hpmp_window.dispose
  77.         end
  78.         super
  79.       end
  80.       #--------------------------------------------------------------------------
  81.       # ● 更新画面
  82.       #--------------------------------------------------------------------------
  83.       def update
  84.         super
  85.         if @battler == nil
  86.           self.bitmap = nil
  87.         else
  88.           @use_sprite = @battler.use_sprite?
  89.           if @use_sprite
  90.             update_bitmap
  91.             update_origin
  92.             update_position
  93.           end
  94.           setup_new_effect
  95.           setup_new_animation
  96.           update_effect
  97.           if @enemy_hpmp_window != nil and (@old_hp != @battler.hp or @old_mp != @battler.mp)
  98.             if @battler.hp == 0
  99.               @enemy_hpmp_window.hide
  100.             else
  101.               @enemy_hpmp_window.contents.clear
  102.               @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 0)
  103.               @old_hp = @battler.hp
  104.               @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 24)
  105.               @old_mp = @battler.mp
  106.               @enemy_hpmp_window.show #怪物死后再被复活
  107.             end #if battler.hp == 0
  108.           end
  109.         end #if @battler == nil
  110.       end
  111.  
  112.     end





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1