设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 387|回复: 2
打印 上一主题 下一主题

[有事请教] 大佬们,求一个显示敌人血量的插件

[复制链接]

Lv1.梦旅人

梦石
0
星屑
49
在线时间
7 小时
注册时间
2024-4-13
帖子
1
跳转到指定楼层
1
发表于 2024-4-16 11:44:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
如题,第一次发帖,有什么不对的,请指教一下

Lv3.寻梦者

梦石
0
星屑
3841
在线时间
1966 小时
注册时间
2013-1-3
帖子
9536
2
发表于 2024-4-18 15:18:09 | 只看该作者
请搜索一下“血条”、“血量”等关键词
大体思路是在window类里显示一个值
《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1262
在线时间
163 小时
注册时间
2019-10-4
帖子
220
3
发表于 3 天前 | 只看该作者
这三个都得都在RMXP天干宝典里面
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================

  4. #==============================================================================
  5. # ■ Window_Help
  6. #------------------------------------------------------------------------------
  7. # 重新定义的内容,可以显示敌人的HP\MP百分比
  8. # 你可以改脚本的开头部分定义生命、精神描述词。只和敌人描述有关,可随意修改
  9. #==============================================================================

  10. class Window_Help < Window_Base
  11.   def set_enemy(actor)  
  12.     #--------------------------------------------------------------------
  13.     # 在这里修改描述文字,比如@生命描述词="敌人生命"
  14.     #--------------------------------------------------------------------
  15.    
  16.     @生命描述词 = $data_system.words.hp
  17.     @精神描述词 = $data_system.words.sp
  18.    
  19.     #--------------------------------------------------------------------
  20.     #--------------------------------------------------------------------
  21.     self.contents.clear
  22.     draw_actor_name(actor, 4, 0)
  23.     draw_actor_state(actor, 140, 0)
  24.     carol3_draw_hp_bar(actor, 284, 12)
  25.     carol3_draw_sp_bar(actor, 460, 12)
  26.     @text = nil
  27.     self.visible = true
  28.   end
  29.   def carol3_draw_hp_bar(actor, x, y, width = 128, height = 14) #宽度可调
  30.     w = width * actor.hp / [actor.maxhp,1].max
  31.     hp_color_1 = Color.new(255, 0, 0, 192)
  32.     hp_color_2 = Color.new(255, 255, 0, 192)
  33.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  34.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  35.     x -= 1
  36.     y += (height/4).floor
  37.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  38.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  39.     x -= 1
  40.     y += (height/4).ceil
  41.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  42.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  43.     x -= 1
  44.     y += (height/4).ceil
  45.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  46.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  47.     self.contents.font.color = Color.new(0,0,0,255)
  48.     self.contents.draw_text(x+2,-3,128,32,@生命描述词,1)
  49.     self.contents.font.color = Color.new(255,255,255,255)
  50.     self.contents.draw_text(x,-4,128,32,@生命描述词,1)
  51.   end
  52.   def carol3_draw_sp_bar(actor, x, y, width = 128, height=14)
  53.     w = width * actor.sp / [actor.maxsp,1].max
  54.     hp_color_1 = Color.new( 0, 0, 255, 192)
  55.     hp_color_2 = Color.new( 0, 255, 255, 192)
  56.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  57.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  58.     x -= 1
  59.     y += (height/4).floor
  60.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  61.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  62.     x -= 1
  63.     y += (height/4).ceil
  64.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  65.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  66.     x -= 1
  67.     y += (height/4).ceil
  68.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  69.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  70.     self.contents.font.color = Color.new(0,0,0,255)
  71.     self.contents.draw_text(x+2,-3,128,32,@精神描述词,1)
  72.     self.contents.font.color = Color.new(255,255,255,255)
  73.     self.contents.draw_text(x,-4,128,32,@精神描述词,1)
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● ライン描画 by 桜雅 在土
  77.   #--------------------------------------------------------------------------
  78.   def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color)
  79.     # 描写距離の計算。大きめに直角時の長さ。
  80.     distance = (start_x - end_x).abs + (start_y - end_y).abs
  81.     # 描写開始
  82.     if end_color == start_color
  83.       for i in 1..distance
  84.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  85.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  86.         if width == 1
  87.           self.contents.set_pixel(x, y, start_color)
  88.         else
  89.           self.contents.fill_rect(x, y, width, width, start_color)
  90.         end
  91.       end
  92.     else
  93.       for i in 1..distance
  94.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  95.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  96.         r = start_color.red * (distance-i)/distance + end_color.red * i/distance
  97.         g = start_color.green * (distance-i)/distance + end_color.green * i/distance
  98.         b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance
  99.         a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance
  100.         if width == 1
  101.           self.contents.set_pixel(x, y, Color.new(r, g, b, a))
  102.         else
  103.           self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a))
  104.         end
  105.       end
  106.     end
  107.   end
  108. end

  109. #==============================================================================
  110. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  111. #==============================================================================
复制代码
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================

  4. #==============================================================================
  5. # ■ Window_Help
  6. #------------------------------------------------------------------------------
  7. # 重新定义的内容,可以显示敌人的HP\MP百分比
  8. # 作者:carol3_柳柳
  9. #==============================================================================

  10. class Window_Help < Window_Base
  11.   def set_enemy(actor)
  12.     self.contents.clear
  13.     draw_actor_name(actor, 4, 0)
  14.     draw_actor_state(actor, 140, 0)
  15.     carol3_draw_hp_bar(actor, 284, 0)
  16.     carol3_draw_sp_bar(actor, 460, 0)
  17.     @text = nil
  18.     self.visible = true
  19.   end
  20.   def carol3_draw_hp_bar(actor, x, y, width = 128) #宽度可调
  21.     self.contents.font.color = system_color
  22.     self.contents.fill_rect(x-1, y+17, width+2,6, Color.new(0, 0, 0, 255))
  23.     w = width * actor.hp / [actor.maxhp,1].max
  24.     self.contents.fill_rect(x, y+18, w,1, Color.new(255, 96, 96, 255))
  25.     self.contents.fill_rect(x, y+19, w,1, Color.new(255, 0, 0, 255))
  26.     self.contents.fill_rect(x, y+20, w,1, Color.new(128, 0, 0, 255))
  27.     self.contents.fill_rect(x, y+21, w,1, Color.new(0, 0, 0, 255))
  28.     self.contents.draw_text(x,y,128,32,$data_system.words.hp,1)
  29.     self.contents.font.color = normal_color
  30.   end
  31.   def carol3_draw_sp_bar(actor, x, y, width = 128)
  32.     self.contents.font.color = system_color
  33.     self.contents.fill_rect(x-1, y+17, width+2,6, Color.new(0, 0, 0, 255))
  34.     w = width * actor.sp / [actor.maxsp,1].max
  35.     self.contents.fill_rect(x, y+18, w,1, Color.new(128, 255, 255, 255))
  36.     self.contents.fill_rect(x, y+19, w,1, Color.new(0, 255, 255, 255))
  37.     self.contents.fill_rect(x, y+20, w,1, Color.new(0, 192, 192, 255))
  38.     self.contents.fill_rect(x, y+21, w,1, Color.new(0, 128, 128, 255))
  39.     self.contents.draw_text(x,y,128,32,$data_system.words.sp,1)
  40.     self.contents.font.color = normal_color
  41.   end
  42. end

  43. #==============================================================================
  44. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  45. #==============================================================================
复制代码
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================
  4. # ■ エネミーHP&SP(ver 0.98)

  5. # □ カスタマイズポイント
  6. #==============================================================================
  7. module PLAN_HPSP_DRAW
  8.   FONT_NAME         = ["黑体", "楷体", "宋体"]    # フォント
  9.   FONT_SIZE         =  14                               # フォントサイズ
  10.   FONT_BOLD         = true                              # 太字
  11.   FONT_ITALIC       = true                              # 斜体

  12.   DRAW_NAME         = true                              # 名前の描画
  13.   DRAW_HP           = true                              # HP の描画
  14.   DRAW_SP           = true                              # SP の描画

  15.   DRAW_WIDTH        =  80                               # 描画幅
  16.   DRAW_HEIGHT       = 3 * 32                            # 描画高さ
  17.   DRAW_SPACE        =   0                               # 行間
  18.   DRAW_Y            =  24                               # Y 座標修正値
  19. end


  20. #==============================================================================
  21. # ■ Sprite_Battler
  22. #==============================================================================

  23. class Sprite_Battler < RPG::Sprite
  24.   #--------------------------------------------------------------------------
  25.   # ● オブジェクト初期化
  26.   #--------------------------------------------------------------------------
  27.   alias plan_enemy_hpsp_draw_initialize initialize
  28.   def initialize(viewport, battler = nil)
  29.     # 元のメソッドに戻す
  30.     plan_enemy_hpsp_draw_initialize(viewport, battler)
  31.     # エネミーの場合
  32.     if @battler.is_a?(Game_Enemy)
  33.       width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  34.       height = PLAN_HPSP_DRAW::DRAW_HEIGHT + 32
  35.       x = @battler.screen_x - width / 2
  36.       y = @battler.screen_y - height + 32 + PLAN_HPSP_DRAW::DRAW_Y
  37.       @enemy_hpsp_window = Window_Base.new(x, y, width, height)
  38.       @enemy_hpsp_window.contents = Bitmap.new(width - 32, height - 32)
  39.       @enemy_hpsp_window.contents.font.name = PLAN_HPSP_DRAW::FONT_NAME
  40.       @enemy_hpsp_window.contents.font.size = PLAN_HPSP_DRAW::FONT_SIZE
  41.       @enemy_hpsp_window.contents.font.bold = PLAN_HPSP_DRAW::FONT_BOLD
  42.       @enemy_hpsp_window.contents.font.italic = PLAN_HPSP_DRAW::FONT_ITALIC
  43.       y = 0
  44.       @old_enemy_hpsp = []
  45.       one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
  46.       if PLAN_HPSP_DRAW::DRAW_NAME
  47.         @enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32)
  48.         y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  49.         @old_enemy_hpsp.push(@battler.name)
  50.       end
  51.       if PLAN_HPSP_DRAW::DRAW_HP
  52.         @enemy_hpsp_window.draw_actor_hp(@battler, 0, y, width - 32)
  53.         y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  54.         @old_enemy_hpsp.push(@battler.hp)
  55.       end
  56.       if PLAN_HPSP_DRAW::DRAW_SP
  57.         @enemy_hpsp_window.draw_actor_sp(@battler, 0, y, width - 32)
  58.         @old_enemy_hpsp.push(@battler.sp)
  59.       end
  60.       @enemy_hpsp_window.opacity = 0
  61.       @enemy_hpsp_window.contents_opacity = 0
  62.       @enemy_hpsp_window.z = -2
  63.     end
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 解放
  67.   #--------------------------------------------------------------------------
  68.   alias plan_enemy_hpsp_draw_dispose dispose
  69.   def dispose
  70.     # エネミーの場合
  71.     if @battler.is_a?(Game_Enemy)
  72.       @enemy_hpsp_window.dispose
  73.     end
  74.     # 元のメソッドに戻す
  75.     plan_enemy_hpsp_draw_dispose
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # ● フレーム更新
  79.   #--------------------------------------------------------------------------
  80.   alias plan_enemy_hpsp_draw_update update
  81.   def update
  82.     # 元のメソッドに戻す
  83.     plan_enemy_hpsp_draw_update
  84.     # エネミーの場合
  85.     if @battler.is_a?(Game_Enemy)
  86.       @enemy_hpsp_window.visible = @battler_visible
  87.     # スプライトの座標を設定
  88.       width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  89.       @enemy_hpsp_window.x = self.x - width / 2
  90.       @now_enemy_hpsp = []
  91.       if PLAN_HPSP_DRAW::DRAW_NAME
  92.         @now_enemy_hpsp.push(@battler.name)
  93.       end
  94.       if PLAN_HPSP_DRAW::DRAW_HP
  95.         @now_enemy_hpsp.push(@battler.hp)
  96.       end
  97.       if PLAN_HPSP_DRAW::DRAW_SP
  98.         @now_enemy_hpsp.push(@battler.sp)
  99.       end
  100.       if @old_enemy_hpsp != @now_enemy_hpsp and $game_temp.enemy_hpsp_refresh
  101.         @old_enemy_hpsp = @now_enemy_hpsp
  102.         @enemy_hpsp_window.contents.clear
  103.         y = 0
  104.         width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  105.         one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
  106.         if PLAN_HPSP_DRAW::DRAW_NAME
  107.           @enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32)
  108.           y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  109.         end
  110.         if PLAN_HPSP_DRAW::DRAW_HP
  111.           @enemy_hpsp_window.draw_actor_hp(@battler, 0, y, width - 32)
  112.           y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  113.         end
  114.         if PLAN_HPSP_DRAW::DRAW_SP
  115.           @enemy_hpsp_window.draw_actor_sp(@battler, 0, y, width - 32)
  116.         end
  117.         Graphics.frame_reset
  118.       end
  119.     end
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ● visible の設定
  123.   #--------------------------------------------------------------------------
  124.   if !method_defined?("plan_enemy_hpsp_draw_visible=")
  125.     alias plan_enemy_hpsp_draw_visible= visible=
  126.   end
  127.   def visible=(bool)
  128.     # エネミーの場合
  129.     if @battler.is_a?(Game_Enemy)
  130.       @enemy_hpsp_window.visible = bool
  131.     end
  132.     # 元のメソッドに戻す
  133.     self.plan_enemy_hpsp_draw_visible=(bool)
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # ● 不透明度の設定
  137.   #--------------------------------------------------------------------------
  138.   if !method_defined?("plan_enemy_hpsp_draw_opacity=")
  139.     alias plan_enemy_hpsp_draw_opacity= opacity=
  140.   end
  141.   def opacity=(n)
  142.     # 元のメソッドに戻す
  143.     self.plan_enemy_hpsp_draw_opacity=(n)
  144.     # エネミーの場合
  145.     if @battler.is_a?(Game_Enemy)
  146.       @enemy_hpsp_window.contents_opacity = n
  147.     end
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # ● ダメージ
  151.   #--------------------------------------------------------------------------
  152.   def damage(value, critical)
  153.     super(value, critical)
  154.     bitmap = @_damage_sprite.bitmap
  155.     @_damage_sprite.dispose
  156.     @_damage_sprite = ::Sprite.new(Viewport.new(0, 0, 640, 480))
  157.     @_damage_sprite.bitmap = bitmap
  158.     @_damage_sprite.ox = 80
  159.     @_damage_sprite.oy = 20
  160.     @_damage_sprite.x = self.x
  161.     @_damage_sprite.y = self.y - self.oy / 2
  162.     @_damage_sprite.viewport.z = self.viewport.z + 1
  163.     @_damage_sprite.z = 3000
  164.     @_damage_duration = 40
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # ● ダメージ解放
  168.   #--------------------------------------------------------------------------
  169.   def dispose_damage
  170.     if @_damage_sprite != nil
  171.       @_damage_sprite.viewport.dispose
  172.     end
  173.     super
  174.   end
  175. end





  176. #==============================================================================
  177. # ■ Game_Temp
  178. #==============================================================================

  179. class Game_Temp
  180.   #--------------------------------------------------------------------------
  181.   # ● 公開インスタンス変数
  182.   #--------------------------------------------------------------------------
  183.   attr_accessor :enemy_hpsp_refresh
  184.   #--------------------------------------------------------------------------
  185.   # ● オブジェクト初期化
  186.   #--------------------------------------------------------------------------
  187.   alias plan_enemy_hpsp_draw_initialize initialize
  188.   def initialize
  189.     # 元のメソッドに戻す
  190.     plan_enemy_hpsp_draw_initialize
  191.     @enemy_hpsp_refresh = false
  192.   end
  193. end

  194. #==============================================================================
  195. # ■ Scene_Battle
  196. #==============================================================================

  197. class Scene_Battle
  198.   #--------------------------------------------------------------------------
  199.   # ● プレバトルフェーズ開始 (エネミー名+アルファベット用)
  200.   #--------------------------------------------------------------------------
  201.   alias plan_enemy_hpsp_draw_start_phase1 start_phase1
  202.   def start_phase1
  203.     $game_temp.enemy_hpsp_refresh = true
  204.     # 元のメソッドに戻す
  205.     plan_enemy_hpsp_draw_start_phase1
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # ● パーティコマンドフェーズ開始 (エネミー名+アルファベット用)
  209.   #--------------------------------------------------------------------------
  210.   alias plan_enemy_hpsp_draw_start_phase2 start_phase2
  211.   def start_phase2
  212.     $game_temp.enemy_hpsp_refresh = false
  213.     # 元のメソッドに戻す
  214.     plan_enemy_hpsp_draw_start_phase2
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  218.   #--------------------------------------------------------------------------
  219.   alias plan_enemy_hpsp_draw_update_phase4_step5 update_phase4_step5
  220.   def update_phase4_step5
  221.     # 元のメソッドに戻す
  222.     plan_enemy_hpsp_draw_update_phase4_step5
  223.     $game_temp.enemy_hpsp_refresh = true
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
  227.   #--------------------------------------------------------------------------
  228.   alias plan_enemy_hpsp_draw_update_phase4_step6 update_phase4_step6
  229.   def update_phase4_step6
  230.     # 元のメソッドに戻す
  231.     plan_enemy_hpsp_draw_update_phase4_step6
  232.     $game_temp.enemy_hpsp_refresh = false
  233.   end
  234. end


  235. #==============================================================================
  236. # ■ Window_Base
  237. #==============================================================================

  238. class Window_Base < Window
  239.   #--------------------------------------------------------------------------
  240.   # ● 名前の描画
  241.   #--------------------------------------------------------------------------
  242.   def draw_actor_name(actor, x, y, width = 120, align = 0)
  243.     self.contents.font.color = normal_color
  244.     align = 1 if $scene.is_a?(Scene_Battle)
  245.     self.contents.draw_text(x, y, width, 32, actor.name, align)
  246.   end
  247.   #--------------------------------------------------------------------------
  248.   # ● ステートの描画
  249.   #--------------------------------------------------------------------------
  250.   def draw_actor_state(actor, x, y, width = 120)
  251.     # 元のメソッドに戻す
  252.     text = make_battler_state_text(actor, width, true)
  253.     self.contents.draw_text(x, y, width, 32, text, 1)
  254.   end
  255. end

  256. #==============================================================================
  257. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  258. #==============================================================================
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-15 03:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表