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

Project1

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

[已经过期] 显示敌人血量的脚本

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2440
在线时间
432 小时
注册时间
2016-10-1
帖子
42
跳转到指定楼层
1
发表于 2016-10-8 12:12:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我使用了这个显示敌人血量的脚本,在攻击选择敌人时会显示敌人血量,但是我不想有详细数字显示是否可以改成百分比?例如血满时显示100% ,剩一半显示50%之类的,如果不行的话,只把数字去掉也是可以的.....






RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_Help
  3. #------------------------------------------------------------------------------
  4. # 重新定义的内容,可以显示敌人的HP\MP百分比
  5. # 你可以改脚本的开头部分定义生命、精神描述词。只和敌人描述有关,可随意修改
  6. #==============================================================================
  7.  
  8. class Window_Help < Window_Base
  9. def set_enemy(actor)
  10. #--------------------------------------------------------------------
  11. # 在这里修改描述文字,比如@生命描述词="敌人生命"
  12. #--------------------------------------------------------------------
  13.  
  14. @生命描述词 = $data_system.words.hp
  15. @精神描述词 = $data_system.words.sp
  16.  
  17. #--------------------------------------------------------------------
  18. #--------------------------------------------------------------------
  19. self.contents.clear
  20. draw_actor_name(actor, 4, 0)
  21. draw_actor_state(actor, 140, 0)
  22. carol3_draw_hp_bar(actor, 284, 12)
  23. carol3_draw_sp_bar(actor, 460, 12)
  24. @text = nil
  25. self.visible = true
  26. end
  27. def carol3_draw_hp_bar(actor, x, y, width = 128, height = 14) #宽度可调
  28. w = width * actor.hp / [actor.maxhp,1].max
  29. hp_color_1 = Color.new(255, 0, 0, 192)
  30. hp_color_2 = Color.new(255, 255, 0, 192)
  31. self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  32. draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  33. x -= 1
  34. y += (height/4).floor
  35. self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  36. draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  37. x -= 1
  38. y += (height/4).ceil
  39. self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  40. draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  41. x -= 1
  42. y += (height/4).ceil
  43. self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  44. draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  45. self.contents.font.color = Color.new(0,0,0,255)
  46. self.contents.draw_text(x+2,-3,128,32,@生命描述词,1)
  47. self.contents.font.color = Color.new(255,255,255,255)
  48. self.contents.draw_text(x,-4,128,32,@生命描述词,1)
  49. end
  50. def carol3_draw_sp_bar(actor, x, y, width = 128, height=14)
  51. w = width * actor.sp / [actor.maxsp,1].max
  52. hp_color_1 = Color.new( 0, 0, 255, 192)
  53. hp_color_2 = Color.new( 0, 255, 255, 192)
  54. self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  55. draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  56. x -= 1
  57. y += (height/4).floor
  58. self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  59. draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  60. x -= 1
  61. y += (height/4).ceil
  62. self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  63. draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  64. x -= 1
  65. y += (height/4).ceil
  66. self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  67. draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  68. self.contents.font.color = Color.new(0,0,0,255)
  69. self.contents.draw_text(x+2,-3,128,32,@精神描述词,1)
  70. self.contents.font.color = Color.new(255,255,255,255)
  71. self.contents.draw_text(x,-4,128,32,@精神描述词,1)
  72. end
  73. #--------------------------------------------------------------------------
  74. # ● ライン描画 by 桜雅 在土
  75. #--------------------------------------------------------------------------
  76. def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color)
  77. # 描写距離の計算。大きめに直角時の長さ。
  78. distance = (start_x - end_x).abs + (start_y - end_y).abs
  79. # 描写開始
  80. if end_color == start_color
  81. for i in 1..distance
  82. x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  83. y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  84. if width == 1
  85. self.contents.set_pixel(x, y, start_color)
  86. else
  87. self.contents.fill_rect(x, y, width, width, start_color)
  88. end
  89. end
  90. else
  91. for i in 1..distance
  92. x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  93. y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  94. r = start_color.red * (distance-i)/distance + end_color.red * i/distance
  95. g = start_color.green * (distance-i)/distance + end_color.green * i/distance
  96. b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance
  97. a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance
  98. if width == 1
  99. self.contents.set_pixel(x, y, Color.new(r, g, b, a))
  100. else
  101. self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a))
  102. end
  103. end
  104. end
  105. end
  106. end

点评

你的Window_Help里面应该改了什么吧  发表于 2016-10-8 22:57
这脚本不就是只显示百分比值槽的咩………………  发表于 2016-10-8 14:44
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-9-22 04:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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