Project1

标题: 打开17号开关显示HP条脚本,这个脚本开关设置为何无效? [打印本页]

作者: 天使喝可乐    时间: 2011-7-6 09:40
标题: 打开17号开关显示HP条脚本,这个脚本开关设置为何无效?
这是个地图上显示HP条脚本,其中第一段是打开17号开关才显示HP条 不打开不显示。
但是现在是否打开17号开关,HP条都显示……也就是开关设置无效了
怎么试都不行..在默认工程中试验也是如此,所以应该不是脚本冲突的问题,求解,谢谢各位~
  1. #-----------------------------------------------------------------
  2. class Scene_Map
  3. #-----------------------------------------------------------------
  4.   ID = 17
  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-7-6 12:19
在16行修改为if $game_switches[ID]=true.
@bars.visible=true,
不行的话54
作者: Wind2010    时间: 2011-7-6 12:20
把15和16行对调试试
作者: fux2    时间: 2011-7-6 13:06
$game_variables是变量不是开关
16行改成@bars.visible = $game_switches[ID]
作者: 天使喝可乐    时间: 2011-7-6 13:35
为什么不能认可答案了= =囧
作者: 忧雪の伤    时间: 2011-7-6 19:13
  1. #-----------------------------------------------------------------
  2. class Scene_Map
  3. #-----------------------------------------------------------------
  4.   ID = 17
  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_switches[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. #-----------------------------------------------------------------
复制代码

作者: 985064351    时间: 2011-7-6 20:22
#==============================================================================
# ■ Window_Actor_Status
#------------------------------------------------------------------------------
#  角色状态
#==============================================================================
ACTOR_STATUS_SWITCH = 1
class Window_Actor_Status < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化窗口
  #--------------------------------------------------------------------------
  def initialize
    super(-10,-118, 640, 230)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    self.z = 9999
    self.contents.font.color = 黑_color
    refresh
    @old_hp = $game_actors[1].hp
    @old_sp = $game_actors[1].sp
    cx = contents.text_size($data_system.words.gold).width
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
     if $game_switches[ACTOR_STATUS_SWITCH]
     @old_hp != $game_actors[1].hp or
     @old_sp != $game_actors[1].sp or
     @old_exp != $game_actors[1].exp
     @old_hp = $game_actors[1].hp
     @old_sp = $game_actors[1].sp
     cf =   100 * $game_actors[1].now_exp / $game_actors[1].next_exp
     cx = contents.text_size($data_system.words.gold).width
     self.contents.clear
    #=====================================================================#
    self.contents.font.size = 12
    if $game_actors[1].level < 10
    self.contents.draw_text(25,94,32,32,$game_actors[1].level.to_s)
    else
    self.contents.draw_text(22,94,32,32,$game_actors[1].level.to_s)
    end
    #=====================================================================#
    self.contents.font.size = 11
    if $game_actors[1].hp > 1000
    self.contents.draw_text(90,107,32,32,$game_actors[1].hp.to_s)
    elsif $game_actors[1].hp < 100 && $game_actors[1].hp > 10
    self.contents.draw_text(90+10,107,32,32,$game_actors[1].hp.to_s)
    elsif $game_actors[1].hp < 10
    self.contents.draw_text(90+15,107,32,32,$game_actors[1].hp.to_s)
    else
    self.contents.draw_text(90+5,107,32,32,$game_actors[1].hp.to_s)
    end
    self.contents.draw_text(90+10+20,108,32,32,"/")
    self.contents.draw_text(90+10+30,107,32,32,$game_actors[1].maxhp.to_s)
    bitmap1 = RPG::Cache.picture("血条")
    w = bitmap1.width * $game_actors[1].hp / [$game_actors[1].maxhp,1].max
    rect1 = Rect.new(0,0,w,bitmap1.height)
    self.contents.blt(0,118,bitmap1,rect1)
    #=====================================================================#
    @plus_sp = 85
    if $game_actors[1].sp > 1000
    self.contents.draw_text(0+@plus_sp+5,127,32,32,$game_actors[1].sp.to_s)
    elsif $game_actors[1].sp < 100 && $game_actors[1].sp > 10
    self.contents.draw_text(0+10+@plus_sp+5,127,32,32,$game_actors[1].sp.to_s)
    elsif $game_actors[1].sp < 10
    self.contents.draw_text(0+15+@plus_sp+5,127,32,32,$game_actors[1].sp.to_s)
    else
    self.contents.draw_text(0+5+@plus_sp+5,127,32,32,$game_actors[1].sp.to_s)
    end
    self.contents.draw_text(0+10+20+@plus_sp+5,128,32,32,"/")
    self.contents.draw_text(0+10+30+@plus_sp+5,127,32,32,$game_actors[1].maxsp.to_s)
    bitmap2 = RPG::Cache.picture("法条")
    w = bitmap2.width * $game_actors[1].sp / [$game_actors[1].maxsp,1].max
    rect2 = Rect.new(0,0,w,bitmap2.height)
    self.contents.blt(-87+bitmap1.width,135,bitmap2,rect2)
    #=====================================================================#
    @plus_exp = 85*2+20
    self.contents.draw_text(-80+@plus_exp,144,22,32,cf.to_s)
    bitmap3 = RPG::Cache.picture("经验条")
    w = bitmap3.width * $game_actors[1].now_exp / [$game_actors[1].next_exp,1].max
    rect3 = Rect.new(0,0,w,bitmap3.height)
    self.contents.blt(-173+bitmap1.width+bitmap2.width,152,bitmap3,rect3)
    #=========================================================================#
    if  $game_party.gold >= 0 &&  $game_party.gold < 99
    self.contents.draw_text(100, 165, 120+cx,32, $game_party.gold.to_s)
    elsif  $game_party.gold >= 99 && $game_party.gold < 999
    self.contents.draw_text(96, 165, 120+cx,32, $game_party.gold.to_s)
    elsif  $game_party.gold >= 999 && $game_party.gold < 9999
    self.contents.draw_text(92, 165, 120+cx,32, $game_party.gold.to_s)
    elsif  $game_party.gold >= 9999 && $game_party.gold < 99999
    self.contents.draw_text(88, 165, 120+cx,32, $game_party.gold.to_s)
    elsif  $game_party.gold >= 99999 && $game_party.gold < 999999
    self.contents.draw_text(84, 165, 120+cx,32, $game_party.gold.to_s)
    elsif  $game_party.gold >= 999999 && $game_party.gold < 9999999
    self.contents.draw_text(80, 165, 120+cx,32, $game_party.gold.to_s)
    elsif  $game_party.gold >= 9999999 && $game_party.gold < 99999999
    self.contents.draw_text(76, 165, 120+cx,32, $game_party.gold.to_s)
    elsif  $game_party.gold >= 99999999 && $game_party.gold < 999999999
    self.contents.draw_text(72, 165, 120+cx,32, $game_party.gold.to_s)
    elsif  $game_party.gold >= 999999999 && $game_party.gold < 9999999999
    self.contents.draw_text(68, 165, 120+cx,32, $game_party.gold.to_s)
    elsif  $game_party.gold >= 9999999999
    self.contents.draw_text(10, 165, 120+cx,32, $game_party.gold.to_s)
    end
    #=========================================================================#
    end
  end
end

  换个吧 HP+SP+经验+金钱 +等级 不要的话 把SP+经验+金钱+等级的删去   

R9AFMHA([email protected] (7.01 KB, 下载次数: 2)

R9AFMHA(LUPJ698$T7Y@JF0.jpg

作者: 忧雪の伤    时间: 2011-7-8 14:00
6楼啊喂,




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