Project1

标题: 显示敌人HP、SP血槽 [打印本页]

作者: 200878242    时间: 2008-9-23 07:15
标题: 显示敌人HP、SP血槽
显示敌人HP、SP血槽可以加上数字吗比如:HP:600/800   SP:500/600 [LINE]1,#dddddd[/LINE]此贴于 2008-9-24 11:35:20 被版主darkten提醒,请楼主看到后对本贴做出回应。 [LINE]1,#dddddd[/LINE]版务信息:版主帮忙结贴~
作者: 塑望    时间: 2008-9-23 07:19
  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. #==============================================================================
复制代码

谁说我回答得不认真就PIA死谁
作者: 200878242    时间: 2008-9-23 07:37
这个和我原来的一样我是说在血槽的上面再显示数字
作者: 艾铃    时间: 2008-9-23 11:05
提示: 作者被禁止或删除 内容自动屏蔽
作者: redant    时间: 2008-9-23 16:54
http://rpg.blue/web/htm/news421.htm [LINE]1,#dddddd[/LINE]系统信息:本贴由本区版主认可为正确答案,66RPG感谢您的热情解答~




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