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

Project1

 找回密码
 注册会员
搜索
查看: 5506|回复: 8

[RMVA发布] 【3/4原创脚本】带有跑步血条功能的UI

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1007
在线时间
145 小时
注册时间
2013-10-16
帖子
271
发表于 2014-2-15 14:53:56 | 显示全部楼层 |阅读模式

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

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

x
新人第一次写脚本……就想写一个UI。
但是网上UI特别多。我就想写一个和大家不一样的。
所以这个UI脚本带有跑步血条的功能。
跑步时会一点一点减少,不跑步时会一点一点回复。当跑步血条为零时,就不能跑步了。同时要等恢复到一定阶段才能继续跑步。
第一次发脚本难免有些错误,希望大神们多多帮助!
话不多说,上图。


未命名.JPG


这里是脚本代码:
  1. #==============================================================================
  2. # 显示人物信息(UI)中的 {跑步血条}
  3. #
  4. # By. 原色工作室rpg-sheep
  5. #转载和使用请保留此信息。
  6. #
  7. #这是我写的一个UI。但是因为其中的一个跑步血条可能对于一些人比较重要,
  8. #所以我就改了改发了上来。
  9. #
  10. #本脚本可以完全脱离RTP运行,但是需要更改Game_Map的第227行。
  11. #请将Game_Map的第227行:
  12. #
  13. # 223  #--------------------------------------------------------------------------
  14. # 224  # ● 获取是否禁止跑步
  15. # 225  #--------------------------------------------------------------------------
  16. # 226  def disable_dash?
  17. # 227    @map.disable_dashing
  18. # 228  end
  19. #
  20. #改为:
  21. #
  22. #  @map.disable_dashing || $running
  23. #
  24. #其中值槽的描绘不是原创的,是SLOTCR生成的。
  25. #
  26. #脚本中有注释的地方可以帮助大家设置。
  27. #==============================================================================
  28. #==============================================================================
  29. # ■ 设置区
  30. #------------------------------------------------------------------------------
  31. $mrp = 50 # 跑步值(总量)
  32. $rp = $mrp
  33. $reset = 70 # 当跑步值为0时,会一点点的回满。当回到上限百分之多少时可以继续跑步。
  34. $window_x = 0 # 窗口的x坐标
  35. $window_y = 0 # 窗口的y坐标
  36. #==============================================================================
  37. #==============================================================================
  38. # ■ Game_Actor
  39. #------------------------------------------------------------------------------
  40. #  
  41. #==============================================================================
  42. class Game_Actor < Game_Battler
  43.   #----------------------------------------------------------------------------
  44.   # ● 重命名方法
  45.   #----------------------------------------------------------------------------
  46.   alias ms_refresh refresh
  47.   alias ms_tp tp=
  48.   alias ms_add_state add_state
  49.   #----------------------------------------------------------------------------
  50.   # ● 刷新
  51.   #----------------------------------------------------------------------------
  52.   def refresh
  53.     ms_refresh
  54.     $need_refresh = true
  55.   end
  56.   #----------------------------------------------------------------------------
  57.   # ● 更改 TP
  58.   #----------------------------------------------------------------------------
  59.   def tp=(tp)
  60.     ms_tp(tp)
  61.     $need_refresh = true
  62.   end
  63.   #----------------------------------------------------------------------------
  64.   # ● 附加状态
  65.   #----------------------------------------------------------------------------
  66.   def add_state(state_id)
  67.     ms_add_state(state_id)
  68.     $need_refresh = true
  69.   end
  70. end

  71. #==============================================================================
  72. # ■ Game_Party
  73. #------------------------------------------------------------------------------
  74. #  
  75. #==============================================================================
  76. class Game_Party
  77.   #----------------------------------------------------------------------------
  78.   # ● 重命名方法
  79.   #----------------------------------------------------------------------------
  80.   alias ms_swap_order swap_order
  81.   #----------------------------------------------------------------------------
  82.   # ● 交换顺序
  83.   #----------------------------------------------------------------------------
  84.   def swap_order(index1, index2)
  85.     ms_swap_order(index1, index2)
  86.     $need_refresh = true
  87.   end
  88. end

  89. #==============================================================================
  90. #■值槽(改编自SLOTCR的值槽生成器,所以保留了他的信息)(是我懒得写了)
  91. #==============================================================================
  92. # -----------------------------------------------------------------------------
  93. # 值槽脚本随机生成系统(SLOTCR) By.Clov
  94. # 通用版本:RMXP(RGSS1) RMVX(RGSS2) RMVX ACE(RGSS3)
  95. # 使用方法:在全部窗口类插入即可 例:draw_cr(0,0,变量1,变量2,'开心值',100,10)
  96. # 参数说明:x x坐标,y y坐标,current 当前值,max 最大值,txt 显示的文字
  97. # width 值槽的宽,height 值槽的高
  98. # 背景与边框没有随机的必要,请自行到脚本里设置
  99. # -----------------------------------------------------------------------------
  100. class Window_Base
  101. # -----------------------------------------------------------------------------
  102. # ● 角色的HP
  103. # -----------------------------------------------------------------------------
  104.   def draw_cr_hp(x,y,current,max,txt='',width=100,height=7)
  105.     #颜色1、颜色2
  106.     c1=[255, 255, 0];c2=[0, 255, 0]
  107.     #边框色颜色
  108.     bk_color = Color.new(255,255,255,255)
  109.     #数值是否显示
  110.     num = false
  111.     #显示数值的对齐方式 0:向左对齐 1:向中间对齐 2:向右边对齐
  112.     num_align = 1
  113.     #计算比率
  114.     bl = current.to_f / max
  115.     #计算实际宽
  116.     w = (width*bl).round
  117.     #描绘值槽
  118.     r = c1[0];g = c1[1];b = c1[2]
  119.     plus_r = (c2[0]-c1[0])/((width-1)*bl)
  120.     plus_g = (c2[1]-c1[1])/((width-1)*bl)
  121.     plus_b = (c2[2]-c1[2])/((width-1)*bl)
  122.     w.times {|k|
  123.     contents.fill_rect(x+k, y, 1, height, Color.new(r,g,b,255))
  124.     r+=plus_r;g+=plus_g;b+=plus_b}
  125.     contents.fill_rect(x-1, y-1, width+2, 1, bk_color)
  126.     contents.fill_rect(x-1, y+height, width+2, 1, bk_color)
  127.     contents.fill_rect(x-1, y, 1, height, bk_color)
  128.     contents.fill_rect(x+width, y, 1, height, bk_color)
  129.     #描绘文字
  130.     txt_w = contents.text_size(txt).width + 2
  131.     contents.draw_text(x-txt_w,y+height/2-12, width, 24, txt)
  132.     contents.draw_text(x,y+height/2-12, width, 24,
  133.     current.to_s+'/'+max.to_s,num_align) if num
  134.   end
  135. # -----------------------------------------------------------------------------
  136. # ● 角色的MP
  137. # -----------------------------------------------------------------------------
  138.   def draw_cr_mp(x,y,current,max,txt='',width=100,height=7)
  139.     #颜色1、颜色2
  140.     c1=[255, 0, 255];c2=[180, 0, 255]
  141.     #边框色颜色
  142.     bk_color = Color.new(255,255,255,255)
  143.     #数值是否显示
  144.     num = false
  145.     #显示数值的对齐方式 0:向左对齐 1:向中间对齐 2:向右边对齐
  146.     num_align = 1
  147.     #计算比率
  148.     bl = current.to_f / max
  149.     #计算实际宽
  150.     w = (width*bl).round
  151.     #描绘值槽
  152.     r = c1[0];g = c1[1];b = c1[2]
  153.     plus_r = (c2[0]-c1[0])/((width-1)*bl)
  154.     plus_g = (c2[1]-c1[1])/((width-1)*bl)
  155.     plus_b = (c2[2]-c1[2])/((width-1)*bl)
  156.     w.times {|k|
  157.     contents.fill_rect(x+k, y, 1, height, Color.new(r,g,b,255))
  158.     r+=plus_r;g+=plus_g;b+=plus_b}
  159.     contents.fill_rect(x-1, y-1, width+2, 1, bk_color)
  160.     contents.fill_rect(x-1, y+height, width+2, 1, bk_color)
  161.     contents.fill_rect(x-1, y, 1, height, bk_color)
  162.     contents.fill_rect(x+width, y, 1, height, bk_color)
  163.     #描绘文字
  164.     txt_w = contents.text_size(txt).width + 2
  165.     contents.draw_text(x-txt_w,y+height/2-12, width, 24, txt)
  166.     contents.draw_text(x,y+height/2-12, width, 24,
  167.     current.to_s+'/'+max.to_s,num_align) if num
  168.   end
  169. # -----------------------------------------------------------------------------
  170. # ● 角色的EXP
  171. # -----------------------------------------------------------------------------
  172.   def draw_cr_exp(x,y,current,max,txt='',width=100,height=7)
  173.     #颜色1、颜色2
  174.     c1=[0, 255, 255];c2=[0, 0, 255]
  175.     #边框色颜色
  176.     bk_color = Color.new(255,255,255,255)
  177.     #数值是否显示
  178.     num = false
  179.     #显示数值的对齐方式 0:向左对齐 1:向中间对齐 2:向右边对齐
  180.     num_align = 1
  181.     #计算比率
  182.     bl = current.to_f / max
  183.     #计算实际宽
  184.     w = (width*bl).round
  185.     #描绘值槽
  186.     r = c1[0];g = c1[1];b = c1[2]
  187.     plus_r = (c2[0]-c1[0])/((width-1)*bl)
  188.     plus_g = (c2[1]-c1[1])/((width-1)*bl)
  189.     plus_b = (c2[2]-c1[2])/((width-1)*bl)
  190.     w.times {|k|
  191.     contents.fill_rect(x+k, y, 1, height, Color.new(r,g,b,255))
  192.     r+=plus_r;g+=plus_g;b+=plus_b}
  193.     contents.fill_rect(x-1, y-1, width+2, 1, bk_color)
  194.     contents.fill_rect(x-1, y+height, width+2, 1, bk_color)
  195.     contents.fill_rect(x-1, y, 1, height, bk_color)
  196.     contents.fill_rect(x+width, y, 1, height, bk_color)
  197.     #描绘文字
  198.     txt_w = contents.text_size(txt).width + 2
  199.     contents.draw_text(x-txt_w,y+height/2-12, width, 24, txt)
  200.     contents.draw_text(x,y+height/2-12, width, 24,
  201.     current.to_s+'/'+max.to_s,num_align) if num
  202.   end
  203. end
  204. # -----------------------------------------------------------------------------
  205. # ● 角色的跑步值
  206. # -----------------------------------------------------------------------------
  207.   def draw_cr_rp(x,y,current,max,txt='',width=199,height=7)
  208.     #颜色1、颜色2
  209.     c1=[255, 0, 0];c2=[0, 255, 0]
  210.     #边框色颜色
  211.     bk_color = Color.new(255,255,255,255)
  212.     #数值是否显示
  213.     num = false
  214.     #显示数值的对齐方式 0:向左对齐 1:向中间对齐 2:向右边对齐
  215.     num_align = 1
  216.     #计算比率
  217.     bl = current.to_f / max
  218.     #计算实际宽
  219.     w = (width*bl).round
  220.     #描绘值槽
  221.     r = c1[0];g = c1[1];b = c1[2]
  222.     plus_r = (c2[0]-c1[0])/((width-1)*bl)
  223.     plus_g = (c2[1]-c1[1])/((width-1)*bl)
  224.     plus_b = (c2[2]-c1[2])/((width-1)*bl)
  225.     w.times {|k|
  226.     contents.fill_rect(x+k, y, 1, height, Color.new(r,g,b,255))
  227.     r+=plus_r;g+=plus_g;b+=plus_b}
  228.     contents.fill_rect(x-1, y-1, width+2, 1, bk_color)
  229.     contents.fill_rect(x-1, y+height, width+2, 1, bk_color)
  230.     contents.fill_rect(x-1, y, 1, height, bk_color)
  231.     contents.fill_rect(x+width, y, 1, height, bk_color)
  232.     #描绘文字
  233.     txt_w = contents.text_size(txt).width + 2
  234.     contents.draw_text(x-txt_w,y+height/2-12, width, 24, txt)
  235.     contents.draw_text(x,y+height/2-12, width, 24,
  236.     current.to_s+'/'+max.to_s,num_align) if num
  237.   end
  238. #==============================================================================
  239. # ■ Window_MapStatus
  240. #------------------------------------------------------------------------------
  241. #  UI窗口
  242. #==============================================================================
  243. class Window_MapStatus < Window_Base
  244.   #----------------------------------------------------------------------------
  245.   # ● 初始化
  246.   #----------------------------------------------------------------------------
  247.   def initialize
  248.     super($window_x ,$window_y ,230,140)
  249.     self.opacity = 0
  250.     refresh
  251.   end
  252.   #----------------------------------------------------------------------------
  253.   # ● 刷新画面
  254.   #----------------------------------------------------------------------------
  255.   def update
  256.     super
  257.     update_dash
  258.     refresh if $need_refresh
  259.     $need_refresh = false
  260.     if $game_player.screen_x >= 0 and $game_player.screen_x <= self.width and
  261.        $game_player.screen_y >= 0 and $game_player.screen_y <= self.height
  262.       self.contents_opacity = 150
  263.     else self.contents_opacity = 255
  264.     end
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # ● 更新跑步
  268.   #--------------------------------------------------------------------------
  269.   def update_dash
  270.     # 如果跑步
  271.     if $game_player.dash? && $game_player.moving?
  272.       # 持续减少跑步值
  273.       if $rp > 0
  274.         if Graphics.frame_count % 10 == 0
  275.           $rp -= 1
  276.           $need_refresh = true
  277.         end
  278.       end
  279.     # 不跑步
  280.     else
  281.       # 缓慢恢复跑步值
  282.       if $rp < $mrp
  283.         if Graphics.frame_count % 30 == 0
  284.           $rp += 1
  285.           $need_refresh = true
  286.         end
  287.       end
  288.     end
  289.     # 如果跑步值归零,则禁止跑步,否则可以跑。(在Game_Map的第227行控制)
  290.     if $rp <= 0
  291.       $running= true
  292.     else
  293.       if 100 * $rp / $mrp>= $reset
  294.         $running = false
  295.       end
  296.     end
  297.   end
  298.   #----------------------------------------------------------------------------
  299.   # ● 更新内容
  300.   #----------------------------------------------------------------------------
  301.   def refresh
  302.     self.contents.clear
  303.     draw_actor_face($game_party.members[0], 0, 0)
  304.     draw_actor_name($game_party.members[0], 100, 25)
  305.     draw_actor_level($game_party.members[0], 100, 0)
  306.     draw_actor_icons($game_party.members[0], 100, 50)
  307.     draw_cr_hp(100,78,$game_party.members[0].hp,$game_party.members[0].mhp)
  308.     draw_cr_mp(100,86,$game_party.members[0].mp,$game_party.members[0].mmp)
  309.     draw_cr_exp(100,94,$game_party.members[0].exp,$game_party.members[0].next_level_exp)   
  310.     draw_cr_rp(1,102,$rp,$mrp)
  311.   end
  312.   
  313. end
  314. #==============================================================================
  315. # ■ Scene_Map
  316. #------------------------------------------------------------------------------
  317. #  将窗口嵌入地图场景
  318. #==============================================================================
  319. class Scene_Map < Scene_Base
  320.   #----------------------------------------------------------------------------
  321.   # ● 重命名方法
  322.   #----------------------------------------------------------------------------
  323.   alias ms_sta start
  324.   #----------------------------------------------------------------------------
  325.   # ● 开始处理
  326.   #----------------------------------------------------------------------------
  327.   def start
  328.     ms_sta
  329.     @mapstatus_window = Window_MapStatus.new
  330.   end
  331. end
复制代码
最后是范例工程(自解压格式文件)(无DLL):
本人喜好使用百度网盘链接,不便之处请谅解。

http://pan.baidu.com/s/1qW8TtwC

开心咸鱼每一天~

Lv2.观梦者

bluer
公主殿下

梦石
0
星屑
278
在线时间
532 小时
注册时间
2013-10-19
帖子
2067
发表于 2014-2-15 15:04:58 手机端发表。 | 显示全部楼层
恩。。。顶。。。很实用。。希望能美化。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
992
在线时间
17 小时
注册时间
2014-2-26
帖子
2
发表于 2014-2-27 21:34:48 | 显示全部楼层
求助一下,用了这个后哪怕跑步值降到0任然能跑步怎么修改?@rpg-sheep

点评

#请将Game_Map的第227行: # # 223 #-------------------------------------------------------------------------- # 224 # ● 获取是否禁止跑步 # 225 #-----------------------------------------------------   发表于 2014-2-28 12:48
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
992
在线时间
17 小时
注册时间
2014-2-26
帖子
2
发表于 2014-2-28 18:51:11 | 显示全部楼层
xxcxxc 发表于 2014-2-27 21:34
求助一下,用了这个后哪怕跑步值降到0任然能跑步怎么修改?@rpg-sheep

改了但降到后还是可以跑步@3106345123
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1007
在线时间
145 小时
注册时间
2013-10-16
帖子
271
 楼主| 发表于 2014-11-23 10:22:32 | 显示全部楼层
xxcxxc 发表于 2014-2-28 18:51
改了但降到后还是可以跑步@3106345123

设置区有。。。

一个$reset变量,把他搞到0
开心咸鱼每一天~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
185 小时
注册时间
2014-9-4
帖子
82
发表于 2014-11-23 11:05:43 | 显示全部楼层
喔,这个我以前也做过,不过我那是公共事件结合脚本的,非常粗糙。
解谜游戏追逐战用来提升难度很不错。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
1019 小时
注册时间
2012-4-25
帖子
799
发表于 2015-4-26 20:50:49 | 显示全部楼层
请问怎么样添加开关了开启关闭脚本?这个脚本在迷宫用不错,但是在城镇里,似乎有些麻烦啊。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
106
在线时间
35 小时
注册时间
2019-7-16
帖子
3
发表于 2020-2-14 11:24:05 | 显示全部楼层
用了,很不错,赞一个
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
479
在线时间
35 小时
注册时间
2019-8-22
帖子
48
发表于 2020-2-27 11:30:52 | 显示全部楼层
范例链接显示链接错误_(:ι」∠)_
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-18 10:05

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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