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

Project1

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

[已经过期] 目前所使用的hud介面內容設置問題

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
158 小时
注册时间
2016-1-7
帖子
129
跳转到指定楼层
1
发表于 2016-3-2 03:10:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 燕征 于 2016-3-3 01:14 编辑

首先放上我使用的該功能相關腳本參考來源帖子  [轉載] RMXP之ARPG製作小師分享

再來陳訴問題,
我想要讓已經被設置好的物品使用快捷鍵隨時可以讓玩家自行更替物品
但在我使用的hud的設置腳本中,我看了很久...如果我理解沒有錯的話,那個是寫死的QQ(我希望是我接觸未深業務不熟練所以理解錯)
也就是說,他原本就設置了快捷鍵qwer對應了他自己的四個藥品,可是我現在想換成我要使用的藥品
我要怎麼改才能達成我的目的?

腳本(相關部分應在312行開始到最後)
[pre lang="ruby" file="◆Arpg_Window"]#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● 描繪狀態
  #--------------------------------------------------------------------------
  def draw_actor_state(actor, x, y, width = 120)
    text = make_battler_state_text(actor, width, true)
    self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
    self.contents.draw_text(x, y, width, 32, text,1)
  end  
  #--------------------------------------------------------------------------
  # ● HP 描畫
  #--------------------------------------------------------------------------
  alias :draw_actor_hp_hpsp :draw_actor_hp
  def draw_actor_hp(actor, x, y, width = 144)
    if actor.maxhp != 0
      rate = actor.hp.to_f / actor.maxhp
    else
      rate = 0
    end
    plus_x = 0
    rate_x = 0
    plus_y = 25
    plus_width = 0
    rate_width = 100
    height = 10
    align1 = 1
    align2 = 2
    align3 = 0
    grade1 = 1
    grade2 = 0
    color1 = Color.new(0, 0, 0, 192)
    color2 = Color.new(255, 255, 192, 192)
    color3 = Color.new(0, 0, 0, 192)
    color4 = Color.new(64, 0, 0, 192)
    color5 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
    color6 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
    if actor.maxhp != 0
      hp = (width + plus_width) * actor.hp * rate_width / 100 / actor.maxhp
    else
      hp = 0
    end
    gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
                width, plus_width + width * rate_width / 100,
                height, hp, align1, align2, align3,
                color1, color2, color3, color4, color5, color6, grade1, grade2)
    draw_actor_hp_hpsp(actor, x, y, width)
  end
  #--------------------------------------------------------------------------
  # ● SP 描畫
  #--------------------------------------------------------------------------
  alias :draw_actor_sp_hpsp :draw_actor_sp
  def draw_actor_sp(actor, x, y, width = 144)
    if actor.maxsp != 0
      rate = actor.sp.to_f / actor.maxsp
    else
      rate = 1
    end
    plus_x = 0
    rate_x = 0
    plus_y = 25
    plus_width = 0
    rate_width = 100
    height = 10
    align1 = 1
    align2 = 2
    align3 = 0
    grade1 = 1
    grade2 = 0
    color1 = Color.new(0, 0, 0, 192)
    color2 = Color.new(255, 255, 192, 192)
    color3 = Color.new(0, 0, 0, 192)
    color4 = Color.new(0, 64, 0, 192)
    color5 = Color.new(14 * rate, 80 - 24 * rate, 80 * rate, 192)
    color6 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
    if actor.maxsp != 0
      sp = (width + plus_width) * actor.sp * rate_width / 100 / actor.maxsp
    else
      sp = (width + plus_width) * rate_width / 100
    end
    gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
                width, plus_width + width * rate_width / 100,
                height, sp, align1, align2, align3,
                color1, color2, color3, color4, color5, color6, grade1, grade2)
    draw_actor_sp_hpsp(actor, x, y, width)
  end
  #--------------------------------------------------------------------------
  # ● EXP 描畫
  #--------------------------------------------------------------------------
  alias :draw_actor_exp_hpsp :draw_actor_exp
  def draw_actor_exp(actor, x, y, width = 204)
    if actor.next_exp != 0
      rate = actor.now_exp.to_f / actor.next_exp
    else
      rate = 1
    end
    plus_x = 0
    rate_x = 0
    plus_y = 25
    plus_width = 0
    rate_width = 100
    height = 10
    align1 = 1
    align2 = 2
    align3 = 0
    grade1 = 1
    grade2 = 0
    color1 = Color.new(0, 0, 0, 192)
    color2 = Color.new(255, 255, 192, 192)
    color3 = Color.new(0, 0, 0, 192)
    color4 = Color.new(64, 0, 0, 192)
    color5 = Color.new(80 * rate, 80 - 80 * rate ** 2, 80 - 80 * rate, 192)
    color6 = Color.new(240 * rate, 240 - 240 * rate ** 2, 240 - 240 * rate, 192)
    if actor.next_exp != 0
      exp = (width + plus_width) * actor.now_exp * rate_width /
                                                          100 / actor.next_exp
    else
      exp = (width + plus_width) * rate_width / 100
    end
    gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
                width, plus_width + width * rate_width / 100,
                height, exp, align1, align2, align3,
                color1, color2, color3, color4, color5, color6, grade1, grade2)
    draw_actor_exp_hpsp(actor, x, y)
  end
  def gauge_rect(x, y, rect_width, width, height, gauge, align1, align2, align3,
                color1, color2, color3, color4, color5, color6, grade1, grade2)
    case align1
    when 1
      x += (rect_width - width) / 2
    when 2
      x += rect_width - width
    end
    case align2
    when 1
      y -= height / 2
    when 2
      y -= height
    end
    self.contents.fill_rect(x, y, width, height, color1)
    self.contents.fill_rect(x + 1, y + 1, width - 2, height - 2, color2)
    if align3 == 0
      if grade1 == 2
        grade1 = 3
      end
      if grade2 == 2
        grade2 = 3
      end
    end
    if (align3 == 1 and grade1 == 0) or grade1 > 0
      color = color3
      color3 = color4
      color4 = color
    end
    if (align3 == 1 and grade2 == 0) or grade2 > 0
      color = color5
      color5 = color6
      color6 = color
    end
    self.contents.gradation_rect(x + 2, y + 2, width - 4, height - 4,
                                  color3, color4, grade1)
    if align3 == 1
      x += width - gauge
    end
    self.contents.gradation_rect(x + 2, y + 2, gauge - 4, height - 4,
                                  color5, color6, grade2)
  end
end
class Bitmap
  def gradation_rect(x, y, width, height, color1, color2, align = 0)
    if align == 0
      for i in x...x + width
        red   = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
        green = color1.green +
                (color2.green - color1.green) * (i - x) / (width - 1)
        blue  = color1.blue +
                (color2.blue - color1.blue) * (i - x) / (width - 1)
        alpha = color1.alpha +
                (color2.alpha - color1.alpha) * (i - x) / (width - 1)
        color = Color.new(red, green, blue, alpha)
        fill_rect(i, y, 1, height, color)
      end
    elsif align == 1
      for i in y...y + height
        red   = color1.red +
                (color2.red - color1.red) * (i - y) / (height - 1)
        green = color1.green +
                (color2.green - color1.green) * (i - y) / (height - 1)
        blue  = color1.blue +
                (color2.blue - color1.blue) * (i - y) / (height - 1)
        alpha = color1.alpha +
                (color2.alpha - color1.alpha) * (i - y) / (height - 1)
        color = Color.new(red, green, blue, alpha)
        fill_rect(x, i, width, 1, color)
      end
    elsif align == 2
      for i in x...x + width
        for j in y...y + height
          red   = color1.red + (color2.red - color1.red) *
                  ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          green = color1.green + (color2.green - color1.green) *
                  ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          blue  = color1.blue + (color2.blue - color1.blue) *
                  ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          alpha = color1.alpha + (color2.alpha - color1.alpha) *
                  ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          color = Color.new(red, green, blue, alpha)
          set_pixel(i, j, color)
        end
      end
    elsif align == 3
      for i in x...x + width
        for j in y...y + height
          red   = color1.red + (color2.red - color1.red) *
                ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          green = color1.green + (color2.green - color1.green) *
                ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          blue  = color1.blue + (color2.blue - color1.blue) *
                ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          alpha = color1.alpha + (color2.alpha - color1.alpha) *
                ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          color = Color.new(red, green, blue, alpha)
          set_pixel(i, j, color)
        end
      end
    end
  end
end
#==============================================================================
# ■ Window_Arpg
#==============================================================================
class Window_Arpg < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0,0,220,130)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    self.visible = false
    @actor = actor
    @data = []
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    if @actor == nil
      @data = []
      return
    end
    make_data
    self.contents.font.size = 15
    self.contents.font.bold = true
    text = @actor.name+" "[email protected]_name+" "+"LV"[email protected]_s
    self.contents.draw_text(0, 0, 188, 20, text,1)
    draw_actor_hp(@actor, 4, 15, 172)
    draw_actor_sp(@actor, 4, 35, 172)
    draw_actor_exp(@actor, 4, 55, 172)
    self.contents.font.size = 14
    draw_actor_state(@actor,0,75,188)
  end
  #--------------------------------------------------------------------------
  # ● 製作資料
  #--------------------------------------------------------------------------  
  def make_data
    @data = [@actor.id]
    @data.push(@actor.class_id)
    @data.push(@actor.level)
    @data.push(@actor.states.clone)
    @data.push(@actor.exp)
    @data.push(@actor.maxhp)
    @data.push(@actor.hp)
    @data.push(@actor.maxsp)
    @data.push(@actor.sp)        
  end
  #--------------------------------------------------------------------------
  # ● 更新畫面
  #--------------------------------------------------------------------------
  def update
    super
    actor = $game_party.actors[0]
    if actor == nil
      self.visible = false
      return
    end
    if $game_player.screen_x < 230 && $game_player.screen_y < 140
      self.x = 420
    else
      self.x = 0
    end
    self.visible = $game_switches[1]
    data = [actor.id]
    data.push(actor.class_id)
    data.push(actor.level)
    data.push(actor.states.clone)
    data.push(actor.exp)
    data.push(actor.maxhp)
    data.push(actor.hp)
    data.push(actor.maxsp)
    data.push(actor.sp)        
    if data != @data
      @actor = actor
      refresh
    end
  end
end
#==============================================================================
# ■ Window_Arpg_Icon
#==============================================================================
class Window_Arpg_Icon < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize(unmber)
    x = unmber < 4 ? (unmber * 32-16) : (496 + (unmber-4) * 32)      
    super(x,412,64,96)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 0
    self.opacity = 0
    self.visible = false
    @unmber = unmber
    @variables = 0
    @item_number = 0
    @id = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear   
    @variables = $game_variables[@unmber+1]
    actor = $game_party.actors[0]
    if actor == nil
      return
    end   
    if @unmber < 4
      text = ["1","2","3","4"]
      self.contents.font.size = 15
      self.contents.font.bold = true
      self.contents.font.color = Color.new(0,255,200)
      self.contents.draw_text(0, 0, 32, 26, text[@unmber],1)
      self.contents.fill_rect(0, 20, 32, 32, Color.new(0,0,0))
      self.contents.fill_rect(1, 21, 30, 30, Color.new(200,200,255))
      self.contents.gradation_rect(3, 23, 26, 26, Color.new(0,0,255,180),Color.new(100,0,180,160), 0)
      skill = $data_skills[$game_variables[@unmber+1]]
      if skill != nil
        op = actor.arpg_skill_can_use?(skill.id) ? 255 : 100
        @item_number = actor.arpg_skill_can_use?(skill.id) ? 1 : 0
        bitmap = RPG::Cache.icon(skill.icon_name)
        self.contents.blt(4, 24, bitmap, Rect.new(0, 0, 24, 24),op)
      end
    else
      text = ["Q","W","E","R"]
      self.contents.font.size = 15
      self.contents.font.bold = true
      self.contents.font.color = Color.new(0,255,200)
      self.contents.draw_text(0, 0, 32, 26, text[@unmber-4],1)
      self.contents.fill_rect(0, 20, 32, 32, Color.new(0,0,0))
      self.contents.fill_rect(1, 21, 30, 30, Color.new(200,200,255))
      self.contents.gradation_rect(3, 23, 26, 26, Color.new(220,160,0,180),Color.new(200,180,0,160), 0)
      item = $data_items[$game_variables[@unmber+1]]
      if item != nil
        @item_number = $game_party.item_number(item.id)
        op = $game_party.arpg_item_can_use?(item.id) ? 255 : 100
        bitmap = RPG::Cache.icon(item.icon_name)
        self.contents.blt(4, 24, bitmap, Rect.new(0, 0, 24, 24),op)
        self.contents.font.size = 12
        self.contents.font.color = Color.new(0,0,0)
        self.contents.draw_text(1, 35, 32, 20, @item_number.to_s,2)
        self.contents.font.color = normal_color
        self.contents.draw_text(0, 34, 32, 20, @item_number.to_s,2)
        self.contents.draw_text(0, 34, 32, 20, @item_number.to_s,2)
      else
        @item_number = 0
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 更新畫面
  #--------------------------------------------------------------------------
  def update
    super
    actor = $game_party.actors[0]
    if actor == nil
      self.visible = false
      return
    end
    unless $game_temp.message_window_showing
      self.visible = $game_switches[1]
    else
      self.visible = false
    end
    item_number = 0
    if @unmber >= 4
      item = $data_items[$game_variables[@unmber+1]]
      if item != nil
        item_number = $game_party.item_number(item.id)
      end
    else
      skill = $data_skills[$game_variables[@unmber+1]]
      if skill != nil
        item_number = actor.arpg_skill_can_use?(skill.id) ? 1 : 0
      end      
    end
    if @variables != $game_variables[@unmber+1] or @item_number != item_number
      refresh
    end
  end  
end[/pre]

另外,其實我一直很想使用xas,這樣子我上面想做的事情應該就可以輕易做到的樣子。
我也有嘗試過把我的東西植入下載回來的xas範例中試看看能不能用
忘了之前發問時是不是也有提到,但造成我沒有這麼做的其中一個原因是xas東西太多太複雜,我很怕我之後想再加什麼改什麼動不了
另一個有點承上,我沒搞懂那些腳本在幹嘛,我連要怎麼用怎麼改都不知道去哪裡找源頭。譬如我曾試著想把 [教程发布] 【补档】XAS系统XP/VX/VA 原版工程华为补档下载裡的 [box=Orange]XAS 3.91 领队切换插件 个人汉化版[/box]看起來腳本裝得比其他少的揉進我的東西裡,然後...遊戲從來沒讓我成功打開來看過OTZ
所以,我就回來使用我現在的做法了。
(我使用別人的插件都是根據他們的工程裡有什麼,我就先複製到我的工程裡然後再看有沒有要改的東西,包括Graphics的東西我都會去比對有沒有少)

不過現在覺得這種逃避不好,我發了關於使用xas的問題後再把連結補過來這
1. XAS 的hud介面顯示 << 已解決
2.XAS的使用方式

Lv1.梦旅人

梦石
0
星屑
50
在线时间
158 小时
注册时间
2016-1-7
帖子
129
2
 楼主| 发表于 2016-3-3 01:55:13 | 只看该作者
(想到相關的問題所以接著放2樓順便頂上來比較容易讓人看到QQ)

其實我原來想說把xas的hud看看能不能移植上去
可是xas的hud製作方法好像跟我現在用的方法好像差很多:
xas這樣做: class Active_Hud < Sprite  
我的長這樣: Window_Base < Window
他們倆個已經註定無法共存了嗎?
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-12-27 23:10

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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