Project1

标题: 如何设置地图显示HP脚本X号开关打开才有效,队伍无人不显示? [打印本页]

作者: 天使喝可乐    时间: 2011-6-22 13:42
标题: 如何设置地图显示HP脚本X号开关打开才有效,队伍无人不显示?
既然RTAB无人研究所以就换了个新的HP显示脚本……这个比较简单和连击数没冲突
求改下
当队伍中无队友时,脚本会报错 所以 设置成 当队伍中无队友时脚本无效(不显示HP条也不报错)
另一个就是 当X号开关打开时 HP条才显示 X号开关关闭时脚本无效(不显示HP条也不报错)

谢谢咯~
  1. #-----------------------------------------------------------------
  2. class Scene_Map
  3. #-----------------------------------------------------------------
  4.   alias sk_bar_main main
  5.   def main
  6.     @bars = Window_Sk_Bars.new
  7.     sk_bar_main
  8.     @bars.dispose if @bars != nil
  9.   end
  10. #-----------------------------------------------------------------
  11.   alias sk_bar_update update
  12.   def update
  13.     @bars.update
  14.     sk_bar_update
  15.   end
  16. #-----------------------------------------------------------------
  17. end
  18. #-----------------------------------------------------------------
  19. class Window_Base < Window
  20. #-----------------------------------------------------------------
  21.   def sk_initialize(font=0,size=22)
  22.     font = "Tahoma" if font == 0
  23.     self.contents = Bitmap.new(self.width-32,self.height-32)
  24.     self.contents.font.name = font
  25.     self.contents.font.size = size
  26.   end
  27. #-----------------------------------------------------------------
  28.   def draw_text_outline(x,y,w,h,str,c=normal_color,a=0)
  29.     self.contents.font.color = Color.new(0,0,0,255)
  30.     self.contents.draw_text(x-1,y,w,h,str,a)
  31.     self.contents.draw_text(x+1,y,w,h,str,a)
  32.     self.contents.draw_text(x,y+1,w,h,str,a)
  33.     self.contents.draw_text(x,y-1,w,h,str,a)
  34.     self.contents.font.color = c
  35.     self.contents.draw_text(x,y,w,h,str,a)
  36.   end
  37. #-----------------------------------------------------------------
  38. end
  39. #-----------------------------------------------------------------
  40. class Window_Sk_Bars < Window_Base
  41. #-----------------------------------------------------------------
  42.   def initialize
  43.     super(444,-8,206,96)
  44.     sk_initialize("Arial")
  45.     self.opacity = 0
  46.   end
  47. #-----------------------------------------------------------------
  48.   def update
  49.     self.contents.clear
  50.     actor = $game_party.actors[0]
  51.     draw_text_outline(0,-4,64,26,"HP")
  52.     draw_actor_hp(actor,30,0)
  53.   end
  54. #-----------------------------------------------------------------
  55.   def draw_actor_hp(actor,x,y)
  56.     width = 128
  57.     y += 4
  58.     white = Color.new(255,255,255,255)
  59.     black = Color.new(0,0,0,255)
  60.     w = width * actor.hp / actor.maxhp
  61.     # White border
  62.     self.contents.fill_rect(x+1, y-1, width-2, 1, white)
  63.     self.contents.fill_rect(x, y, width, 1, white)
  64.     self.contents.fill_rect(x-1, y+1, width+2, 9, white)
  65.     self.contents.fill_rect(x, y+10, width, 1, white)
  66.     self.contents.fill_rect(x+1, y+11, width-2, 1, white)
  67.     # Black back
  68.     self.contents.fill_rect(x+2, y, width-4, 1, black)
  69.     self.contents.fill_rect(x+1, y+1, width-2, 1, black)
  70.     self.contents.fill_rect(x, y+2, width, 7, black)
  71.     self.contents.fill_rect(x+1, y+9, width-2, 1, black)
  72.     self.contents.fill_rect(x+2, y+10, width-4, 1, black)
  73.     # Generating the color
  74.     val = 255 * ((actor.hp*100)/actor.maxhp)
  75.     green = 255 - val/100
  76.     color = Color.new(224,green,0,255)
  77.     w_color = Color.new(255,green+32,96,255)
  78.     if green > 64 then green -= 32
  79.     elsif green > 128 then green -= 64 end
  80.     b_color = Color.new(172,green,0,255)
  81.     # Making the bar
  82.     self.contents.fill_rect(x+2, y, w-4, 1, w_color)
  83.     self.contents.fill_rect(x+1, y+1, w-2, 1, w_color)
  84.     self.contents.fill_rect(x, y+2, w, 7, color)
  85.     self.contents.fill_rect(x+1, y+9, w-2, 1, color)
  86.     self.contents.fill_rect(x+2, y+10, w-4, 1, b_color)
  87.   end
  88. #-----------------------------------------------------------------
  89. end
  90. #-----------------------------------------------------------------
复制代码
dsu_plus_rewardpost_czw
作者: 忧雪の伤    时间: 2011-6-22 14:07
  1. #-----------------------------------------------------------------
  2. class Scene_Map
  3. #-----------------------------------------------------------------
  4.   ID = 10
  5.   alias sk_bar_main main
  6.   def main
  7.     @bars = Window_Sk_Bars.new
  8.     sk_bar_main
  9.     @bars.dispose if @bars != nil
  10.   end
  11. #-----------------------------------------------------------------
  12.   alias sk_bar_update update
  13.   def update
  14.     @bars.update
  15.     sk_bar_update
  16.     @bars.visible = $game_variables[ID]
  17.   end
  18. #-----------------------------------------------------------------
  19. end
  20. #-----------------------------------------------------------------
  21. class Window_Base < Window
  22. #-----------------------------------------------------------------
  23.   def sk_initialize(font=0,size=22)
  24.     font = "Tahoma" if font == 0
  25.     self.contents = Bitmap.new(self.width-32,self.height-32)
  26.     self.contents.font.name = font
  27.     self.contents.font.size = size
  28.   end
  29. #-----------------------------------------------------------------
  30.   def draw_text_outline(x,y,w,h,str,c=normal_color,a=0)
  31.     self.contents.font.color = Color.new(0,0,0,255)
  32.     self.contents.draw_text(x-1,y,w,h,str,a)
  33.     self.contents.draw_text(x+1,y,w,h,str,a)
  34.     self.contents.draw_text(x,y+1,w,h,str,a)
  35.     self.contents.draw_text(x,y-1,w,h,str,a)
  36.     self.contents.font.color = c
  37.     self.contents.draw_text(x,y,w,h,str,a)
  38.   end
  39. #-----------------------------------------------------------------
  40. end
  41. #-----------------------------------------------------------------
  42. class Window_Sk_Bars < Window_Base
  43. #-----------------------------------------------------------------
  44.   def initialize
  45.     super(444,-8,206,96)
  46.     sk_initialize("Arial")
  47.     self.opacity = 0
  48.   end
  49. #-----------------------------------------------------------------
  50.   def update
  51.     self.contents.clear
  52.     actor = $game_party.actors[0]
  53.     return if actor.nil?
  54.     draw_text_outline(0,-4,64,26,"HP")
  55.     draw_actor_hp(actor,30,0)
  56.   end
  57. #-----------------------------------------------------------------
  58.   def draw_actor_hp(actor,x,y)
  59.     width = 128
  60.     y += 4
  61.     white = Color.new(255,255,255,255)
  62.     black = Color.new(0,0,0,255)
  63.     w = width * actor.hp / actor.maxhp
  64.     # White border
  65.     self.contents.fill_rect(x+1, y-1, width-2, 1, white)
  66.     self.contents.fill_rect(x, y, width, 1, white)
  67.     self.contents.fill_rect(x-1, y+1, width+2, 9, white)
  68.     self.contents.fill_rect(x, y+10, width, 1, white)
  69.     self.contents.fill_rect(x+1, y+11, width-2, 1, white)
  70.     # Black back
  71.     self.contents.fill_rect(x+2, y, width-4, 1, black)
  72.     self.contents.fill_rect(x+1, y+1, width-2, 1, black)
  73.     self.contents.fill_rect(x, y+2, width, 7, black)
  74.     self.contents.fill_rect(x+1, y+9, width-2, 1, black)
  75.     self.contents.fill_rect(x+2, y+10, width-4, 1, black)
  76.     # Generating the color
  77.     val = 255 * ((actor.hp*100)/actor.maxhp)
  78.     green = 255 - val/100
  79.     color = Color.new(224,green,0,255)
  80.     w_color = Color.new(255,green+32,96,255)
  81.     if green > 64 then green -= 32
  82.     elsif green > 128 then green -= 64 end
  83.     b_color = Color.new(172,green,0,255)
  84.     # Making the bar
  85.     self.contents.fill_rect(x+2, y, w-4, 1, w_color)
  86.     self.contents.fill_rect(x+1, y+1, w-2, 1, w_color)
  87.     self.contents.fill_rect(x, y+2, w, 7, color)
  88.     self.contents.fill_rect(x+1, y+9, w-2, 1, color)
  89.     self.contents.fill_rect(x+2, y+10, w-4, 1, b_color)
  90.   end
  91. #-----------------------------------------------------------------
  92. end
  93. #-----------------------------------------------------------------
复制代码

作者: 天使喝可乐    时间: 2011-6-26 08:09
顶下……求解完全= =
作者: 精灵使者    时间: 2011-6-26 08:30
@bars.visible = $game_variables[ID]
2楼正解
请把这里的ID改为你的开关号
作者: 天使喝可乐    时间: 2011-6-26 11:55
精灵使者 发表于 2011-6-26 08:30
@bars.visible = $game_variables
2楼正解
请把这里的ID改为你的开关号

2楼开关不可用……
上面不是有ID = 10么
那@bars.visible = $game_variables[ID]
不就等于@bars.visible = $game_variables[10]吗……


天使喝可乐于2011-6-28 22:28补充以下内容:
不行啊= = 又试了一遍 无论是否把ID改成号 还是直接复制过来 还是放在新工程中   是否开关HP条都不消失的




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