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

Project1

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

[已经解决] 血條腳本內加入能力值的血條

[复制链接]

Lv1.梦旅人

梦石
0
星屑
80
在线时间
1730 小时
注册时间
2009-7-12
帖子
443
1
发表于 2012-1-8 02:41:40 | 显示全部楼层
把他原腳本裡的描繪方法CO出來,開新腳本貼上
  1. #==============================================================================
  2. # ◇ 外部ライブラリ
  3. #==============================================================================
  4. class Window_Base
  5.   #--------------------------------------------------------------------------
  6.   # ● ライン描画 軽量版 by 桜雅 在土
  7.   #--------------------------------------------------------------------------
  8.   def draw_lineght(start_x, start_y, end_x, end_y, start_color)
  9.     # 描写距離の計算。大きめに直角時の長さ。
  10.     distance = (start_x - end_x).abs + (start_y - end_y).abs
  11.     # 描写開始
  12.     for i in 1..distance
  13.       x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  14.       y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  15.       self.contents.set_pixel(x, y, start_color)
  16.     end
  17.   end
  18.   #--------------------------------------------------------------------------
  19.   # ● ライン描画 by 桜雅 在土
  20.   #--------------------------------------------------------------------------
  21.   def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color)
  22.     # 描写距離の計算。大きめに直角時の長さ。
  23.     distance = (start_x - end_x).abs + (start_y - end_y).abs
  24.     # 描写開始
  25.     if end_color == start_color
  26.       for i in 1..distance
  27.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  28.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  29.         if width == 1
  30.           self.contents.set_pixel(x, y, start_color)
  31.         else
  32.           self.contents.fill_rect(x, y, width, width, start_color)
  33.         end
  34.       end
  35.     else
  36.       for i in 1..distance
  37.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  38.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  39.         r = start_color.red * (distance-i)/distance + end_color.red * i/distance
  40.         g = start_color.green * (distance-i)/distance + end_color.green * i/distance
  41.         b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance
  42.         a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance
  43.         if width == 1
  44.           self.contents.set_pixel(x, y, Color.new(r, g, b, a))
  45.         else
  46.           self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a))
  47.         end
  48.       end
  49.     end
  50.   end
  51. end
复制代码
然後到Window_Base下新增描繪項目
比如我要新增力量的
  1.   #-----------------------------------------------------------------------
  2.   # ● STR描画
  3.   #-----------------------------------------------------------------------
  4.   
  5.   #描繪方法名
  6.   def draw_actor_str_meter_line(actor, x, y, width = 81, height = 6)
  7.     # 描繪寬度,注意內容變量,力量的代碼為str,若要改成其他的請將代碼更改,力量的最大值為999,若不是請更改
  8.     w = width * actor.str / 999
  9.     # 力量條左邊漸變的顏色
  10.     str_color_1 = Color.new(80,0,0, 192)
  11.     # 力量條右邊漸變的顏色
  12.     str_color_2 = Color.new(240, 0, 0,192)
  13.     # 描繪條狀(這裡是我遊戲的畫法,仿RTAB的行動條((個人覺得較美觀
  14.     self.contents.fill_rect(x-1, y-2, width+9, (height+4).floor, Color.new(0, 0, 0, 222))
  15.     self.contents.fill_rect(x, y-1, width+7, (height+2).floor, Color.new(255, 255, 192, 192))
  16.     self.contents.fill_rect(x+1, y, width+5, height.floor, Color.new(0, 0, 0, 222))
  17.     #注意若你要描繪的不是力量的話這裡要修改
  18.     draw_line(x, y, x + w, y, str_color_1, (height).floor, str_color_2)
  19.      
  20.   end
复制代码
注意一下注釋

然後如果要用就使用這條函式
draw_actor_str_meter_line(actor, x, y)
如果高度或寬度要更改就使用
draw_actor_str_meter_line(actor, x, y, 你要的寬度, 你要的高度)

然後各屬性的代碼為下
攻擊力stk 物理防禦pdef 魔法防禦mdef 力量str 敏捷dex 速度agi 魔力int

那啥…我以為用戶名只是通行碼…
所以我暱稱不是serena718哈,是月見斐夜
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
80
在线时间
1730 小时
注册时间
2009-7-12
帖子
443
2
发表于 2012-1-9 21:23:26 | 显示全部楼层
我叫你加進Window_Base的draw_actor_str_meter_line(actor, x, y)
就是已經定義了力量條的表示
你只要去Window_BattleStatus裡的refresh裡
描繪血條的下方新增draw_actor_str_meter_line(actor, x, y)就好了

那啥…我以為用戶名只是通行碼…
所以我暱稱不是serena718哈,是月見斐夜
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
80
在线时间
1730 小时
注册时间
2009-7-12
帖子
443
3
发表于 2012-1-11 00:16:42 | 显示全部楼层
親,記得用回復喔,不然我們收不到通知
是說我才剛把原版改完LS就發了(汗
不過我還是貼上來好了,不然感覺好像做了白工(欸
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. # ————————————————————————————————————

  5. # ▼▲▼ XRXS_BP 7. バトルステータス?クリアデザイン ver.1.03 ▼▲▼
  6. # by 桜雅 在土

  7. #==============================================================================
  8. # ■ Window_BattleStatus
  9. #==============================================================================
  10. class Window_BattleStatus < Window_Base
  11.   #--------------------------------------------------------------------------
  12.   # ● 公開インスタンス変数
  13.   #--------------------------------------------------------------------------
  14.   attr_accessor :update_cp_only # CPメーターのみの更新
  15.   #--------------------------------------------------------------------------
  16.   # ● オブジェクト初期化
  17.   #--------------------------------------------------------------------------
  18.   alias xrxs_bp7_initialize initialize
  19.   def initialize
  20.     # 初期化
  21.     @previous_hp = []
  22.     @previous_sp = []
  23.     # 呼び戻す
  24.     xrxs_bp7_initialize
  25.     # ↓Full-Viewの場合は下二行の # を消してください。
  26.     #self.opacity = 0
  27.     #self.back_opacity = 0
  28.   end
  29.   #--------------------------------------------------------------------------
  30.   # ● リフレッシュ
  31.   #--------------------------------------------------------------------------
  32.   alias xrxs_bp7_refresh refresh
  33.   def refresh
  34.     # CPメーターの更新のみ の場合
  35.     if @update_cp_only
  36.       xrxs_bp7_refresh
  37.       return
  38.     end
  39.     # 変更するものがない場合、飛ばす
  40.     @item_max = $game_party.actors.size
  41.     bool = false
  42.     for i in 0...@item_max
  43.       actor = $game_party.actors[i]
  44.       if (@previous_hp[i] != actor.hp) or (@previous_sp[i] != actor.sp)
  45.         bool = true
  46.       end
  47.     end
  48.     return if bool == false
  49.     # 描写を開始
  50.     self.contents.clear
  51.     for i in 0...@item_max
  52.       actor = $game_party.actors[i]
  53.       actor_x = i * 160 + 82 #修改hp&mp血條的x座標位置
  54.       # 歩行キャラグラフィックの描写 - 修改臉圖位置
  55.       #draw_actor_face(actor, actor_x - 9, 60)
  56.       # HP/SPメーターの描写 - 修改hp&mp血條位置
  57.       draw_actor_hp_meter_line(actor, actor_x, 76, 46, 8)
  58.       draw_actor_sp_meter_line(actor, actor_x, 99, 46, 8)
  59.       draw_actor_str_meter_line(actor, actor_x,122 , 46, 8)
  60.       # HP数値の描写
  61.       self.contents.font.size = 15 # HP/SP数値の文字の大きさ
  62.       self.contents.font.color = Color.new(0,0,0,192)
  63.       self.contents.draw_text(actor_x-51, 65, 96, 24, actor.hp.to_s, 2)
  64.       self.contents.font.color = actor.hp == 0 ? knockout_color :
  65.       actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  66.       self.contents.draw_text(actor_x-50, 64, 96, 24, actor.hp.to_s, 2)
  67.       # SP数値の描写
  68.       self.contents.font.color = Color.new(0,0,0,192)
  69.       self.contents.draw_text(actor_x-49, 88, 96, 24, actor.sp.to_s, 2)
  70.       self.contents.font.color = actor.sp == 0 ? knockout_color :
  71.       actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  72.       self.contents.draw_text(actor_x-50, 87, 96, 24, actor.sp.to_s, 2)
  73.       # STR数値の描写
  74.       self.contents.font.color = Color.new(0,0,0,192)
  75.       self.contents.draw_text(actor_x-49, 111, 96, 24, actor.str.to_s, 2)
  76.       self.contents.font.color = normal_color
  77.       self.contents.draw_text(actor_x-50, 110, 96, 24, actor.str.to_s, 2)
  78.       # 用語「HP」と用語「SP」の描写
  79. #      self.contents.font.size = 10 # 用語「HP/SP」の文字の大きさ
  80. #      self.contents.font.color = Color.new(100,50,50,192)
  81. #      self.contents.draw_text(actor_x-8, 77, 196, 24, $data_system.words.hp)
  82. #      self.contents.draw_text(actor_x-8, 91, 196, 24, $data_system.words.sp)
  83. #      self.contents.font.color = system_color # 用語「HP/SP」の文字の色
  84. #      self.contents.draw_text(actor_x-10, 89, 196, 24, $data_system.words.hp)
  85. #      self.contents.draw_text(actor_x-10, 93, 196, 24, $data_system.words.sp)
  86.       # ステートの描写
  87.       draw_actor_state(actor, actor_x, 100)
  88.       # 値を更新
  89.       @previous_hp[i] = actor.hp
  90.       @previous_hp[i] = actor.hp
  91.     end
  92.   end
  93. end
  94. #==============================================================================
  95. # ■ Window_Base
  96. #==============================================================================
  97. class Window_Base < Window
  98.   #--------------------------------------------------------------------------
  99.   # ● HPメーター の描画
  100.   #--------------------------------------------------------------------------
  101.   def draw_actor_hp_meter_line(actor, x, y, width = 156, height = 4)
  102.     w = width * actor.hp / [actor.maxhp,1].max
  103.     hp_color_1 = Color.new(255, 0, 0, 192)
  104.     hp_color_2 = Color.new(255, 255, 0, 192)
  105.     self.contents.fill_rect(x+0, y+0, width, (height/4).floor, Color.new(0, 0, 0, 128))
  106.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  107.     x -= 1
  108.     y += (height/4).floor
  109.     self.contents.fill_rect(x+0, y+0, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  110.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  111.     x -= 1
  112.     y += (height/4).ceil
  113.     self.contents.fill_rect(x+0, y+0, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  114.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  115.     x -= 1
  116.     y += (height/4).ceil
  117.     self.contents.fill_rect(x+0, y+0, width, (height/4).floor, Color.new(0, 0, 0, 128))
  118.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● SPメーター の描画
  122.   #--------------------------------------------------------------------------
  123.   def draw_actor_sp_meter_line(actor, x, y, width = 156, height = 4)
  124.     w = width * actor.sp / [actor.maxsp,1].max
  125.     hp_color_1 = Color.new( 0, 0, 255, 192)
  126.     hp_color_2 = Color.new( 0, 255, 255, 192)
  127.     self.contents.fill_rect(x+0, y+0, width, (height/4).floor, Color.new(0, 0, 0, 128))
  128.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  129.     x -= 1
  130.     y += (height/4).floor
  131.     self.contents.fill_rect(x+0, y+0, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  132.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  133.     x -= 1
  134.     y += (height/4).ceil
  135.     self.contents.fill_rect(x+0, y+0, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  136.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  137.     x -= 1
  138.     y += (height/4).ceil
  139.     self.contents.fill_rect(x+0, y+0, width, (height/4).floor, Color.new(0, 0, 0, 128))
  140.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● STR メーター の描画
  144.   #--------------------------------------------------------------------------
  145.   def draw_actor_str_meter_line(actor, x, y, width = 156, height = 4)
  146.     w = width * actor.str / 999
  147.     hp_color_1 = Color.new(80,0,0, 192)
  148.     hp_color_2 = Color.new(240, 0, 0,192)
  149.     self.contents.fill_rect(x+0, y+0, width, (height/4).floor, Color.new(0, 0, 0, 128))
  150.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  151.     x -= 1
  152.     y += (height/4).floor
  153.     self.contents.fill_rect(x+0, y+0, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  154.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  155.     x -= 1
  156.     y += (height/4).ceil
  157.     self.contents.fill_rect(x+0, y+0, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  158.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  159.     x -= 1
  160.     y += (height/4).ceil
  161.     self.contents.fill_rect(x+0, y+0, width, (height/4).floor, Color.new(0, 0, 0, 128))
  162.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  163.   end   
  164.   #--------------------------------------------------------------------------
  165.   # ● 名前の描画
  166.   #--------------------------------------------------------------------------
  167.   alias xrxs_bp7_draw_actor_name draw_actor_name
  168.   def draw_actor_name(actor, x, y)
  169.     xrxs_bp7_draw_actor_name(actor, x, y) if @draw_ban != true
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● ステートの描画
  173.   #--------------------------------------------------------------------------
  174.   alias xrxs_bp7_draw_actor_state draw_actor_state
  175.   def draw_actor_state(actor, x, y, width = 120)
  176.     xrxs_bp7_draw_actor_state(actor, x, y, width) if @draw_ban != true
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● HP の描画
  180.   #--------------------------------------------------------------------------
  181.   alias xrxs_bp7_draw_actor_hp draw_actor_hp
  182.   def draw_actor_hp(actor, x, y, width = 144)
  183.     xrxs_bp7_draw_actor_hp(actor, x, y, width) if @draw_ban != true
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ● SP の描画
  187.   #--------------------------------------------------------------------------
  188.   alias xrxs_bp7_draw_actor_sp draw_actor_sp
  189.   def draw_actor_sp(actor, x, y, width = 144)
  190.     xrxs_bp7_draw_actor_sp(actor, x, y, width) if @draw_ban != true
  191.   end
  192. end
  193. #==============================================================================
  194. # ■ Scene_Battle
  195. #==============================================================================
  196. class Scene_Battle
  197.   #--------------------------------------------------------------------------
  198.   # ● フレーム更新
  199.   #--------------------------------------------------------------------------
  200.   alias xrxs_bp7_update update
  201.   def update
  202.     xrxs_bp7_update
  203.     # メッセージウィンドウ表示中の場合
  204.     if $game_temp.message_window_showing
  205.       @status_window.update_cp_only = true      
  206.     else
  207.       @status_window.update_cp_only = false
  208.     end
  209.   end
  210. end
  211. #==============================================================================
  212. # ◇ 外部ライブラリ
  213. #==============================================================================
  214. class Window_Base
  215.   #--------------------------------------------------------------------------
  216.   # ● ライン描画 軽量版 by 桜雅 在土
  217.   #--------------------------------------------------------------------------
  218.   def draw_lineght(start_x, start_y, end_x, end_y, start_color)
  219.     # 描写距離の計算。大きめに直角時の長さ。
  220.     distance = (start_x - end_x).abs + (start_y - end_y).abs
  221.     # 描写開始
  222.     for i in 1..distance
  223.       x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  224.       y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  225.       self.contents.set_pixel(x, y, start_color)
  226.     end
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # ● ライン描画 by 桜雅 在土
  230.   #--------------------------------------------------------------------------
  231.   def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color)
  232.     # 描写距離の計算。大きめに直角時の長さ。
  233.     distance = (start_x - end_x).abs + (start_y - end_y).abs
  234.     # 描写開始
  235.     if end_color == start_color
  236.       for i in 1..distance
  237.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  238.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  239.         if width == 1
  240.           self.contents.set_pixel(x, y, start_color)
  241.         else
  242.           self.contents.fill_rect(x, y, width, width, start_color)
  243.         end
  244.       end
  245.     else
  246.       for i in 1..distance
  247.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  248.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  249.         r = start_color.red * (distance-i)/distance + end_color.red * i/distance
  250.         g = start_color.green * (distance-i)/distance + end_color.green * i/distance
  251.         b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance
  252.         a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance
  253.         if width == 1
  254.           self.contents.set_pixel(x, y, Color.new(r, g, b, a))
  255.         else
  256.           self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a))
  257.         end
  258.       end
  259.     end
  260.   end
  261. end


  262. #==============================================================================
  263. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  264. #==============================================================================
复制代码

点评

因為我開過類似的相關問題~不過沒人回~這次才會直接開懸賞~~~^^  发表于 2012-1-11 21:27
555...PIA飛你T_T  发表于 2012-1-11 20:51
这问题居然是悬赏,我表示我在偷笑。  发表于 2012-1-11 03:38

那啥…我以為用戶名只是通行碼…
所以我暱稱不是serena718哈,是月見斐夜
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
80
在线时间
1730 小时
注册时间
2009-7-12
帖子
443
4
发表于 2012-1-11 22:01:52 | 显示全部楼层
銀藍色的零 发表于 2012-1-11 21:26
已成功
不過還有一點問題
str顯示的數值要比實際數值少1

STR描繪那邊改成這樣
  1.       # STR数値の描写
  2.       a = actor.str
  3.       a -= 1
  4.       self.contents.font.color = Color.new(0,0,0,192)
  5.       self.contents.draw_text(actor_x-49, 111, 96, 24, a.to_s, 2)
  6.       self.contents.font.color = normal_color
  7.       self.contents.draw_text(actor_x-50, 110, 96, 24, a.to_s, 2)
复制代码

点评

因為draw_text那邊是專門描繪字符的,直接動用加減乘除會出錯,所以必須在事前就將數值扣掉  发表于 2012-1-11 22:03

那啥…我以為用戶名只是通行碼…
所以我暱稱不是serena718哈,是月見斐夜
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
80
在线时间
1730 小时
注册时间
2009-7-12
帖子
443
5
发表于 2012-1-11 22:52:37 | 显示全部楼层
本帖最后由 serena718 于 2012-1-11 22:53 编辑
銀藍色的零 发表于 2012-1-11 22:37
ok!
已解決
現在換我不知道要怎辦啦~


給他好了,畢竟他先回答的,而且他差2積分就劍士了~
而且他也解釋得比較詳細

评分

参与人数 1星屑 +1200 收起 理由
仲秋启明 + 1200 应提问人要求

查看全部评分


那啥…我以為用戶名只是通行碼…
所以我暱稱不是serena718哈,是月見斐夜
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-16 21:46

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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