赞 | 28 |
VIP | 1 |
好人卡 | 12 |
积分 | 10 |
经验 | 18722 |
最后登录 | 2022-3-28 |
在线时间 | 145 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 1023
- 在线时间
- 145 小时
- 注册时间
- 2013-10-16
- 帖子
- 271
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
新人第一次写脚本……就想写一个UI。
但是网上UI特别多。我就想写一个和大家不一样的。
所以这个UI脚本带有跑步血条的功能。
跑步时会一点一点减少,不跑步时会一点一点回复。当跑步血条为零时,就不能跑步了。同时要等恢复到一定阶段才能继续跑步。
第一次发脚本难免有些错误,希望大神们多多帮助!
话不多说,上图。
这里是脚本代码:- #==============================================================================
- # 显示人物信息(UI)中的 {跑步血条}
- #
- # By. 原色工作室rpg-sheep
- #转载和使用请保留此信息。
- #
- #这是我写的一个UI。但是因为其中的一个跑步血条可能对于一些人比较重要,
- #所以我就改了改发了上来。
- #
- #本脚本可以完全脱离RTP运行,但是需要更改Game_Map的第227行。
- #请将Game_Map的第227行:
- #
- # 223 #--------------------------------------------------------------------------
- # 224 # ● 获取是否禁止跑步
- # 225 #--------------------------------------------------------------------------
- # 226 def disable_dash?
- # 227 @map.disable_dashing
- # 228 end
- #
- #改为:
- #
- # @map.disable_dashing || $running
- #
- #其中值槽的描绘不是原创的,是SLOTCR生成的。
- #
- #脚本中有注释的地方可以帮助大家设置。
- #==============================================================================
- #==============================================================================
- # ■ 设置区
- #------------------------------------------------------------------------------
- $mrp = 50 # 跑步值(总量)
- $rp = $mrp
- $reset = 70 # 当跑步值为0时,会一点点的回满。当回到上限百分之多少时可以继续跑步。
- $window_x = 0 # 窗口的x坐标
- $window_y = 0 # 窗口的y坐标
- #==============================================================================
- #==============================================================================
- # ■ Game_Actor
- #------------------------------------------------------------------------------
- #
- #==============================================================================
- class Game_Actor < Game_Battler
- #----------------------------------------------------------------------------
- # ● 重命名方法
- #----------------------------------------------------------------------------
- alias ms_refresh refresh
- alias ms_tp tp=
- alias ms_add_state add_state
- #----------------------------------------------------------------------------
- # ● 刷新
- #----------------------------------------------------------------------------
- def refresh
- ms_refresh
- $need_refresh = true
- end
- #----------------------------------------------------------------------------
- # ● 更改 TP
- #----------------------------------------------------------------------------
- def tp=(tp)
- ms_tp(tp)
- $need_refresh = true
- end
- #----------------------------------------------------------------------------
- # ● 附加状态
- #----------------------------------------------------------------------------
- def add_state(state_id)
- ms_add_state(state_id)
- $need_refresh = true
- end
- end
- #==============================================================================
- # ■ Game_Party
- #------------------------------------------------------------------------------
- #
- #==============================================================================
- class Game_Party
- #----------------------------------------------------------------------------
- # ● 重命名方法
- #----------------------------------------------------------------------------
- alias ms_swap_order swap_order
- #----------------------------------------------------------------------------
- # ● 交换顺序
- #----------------------------------------------------------------------------
- def swap_order(index1, index2)
- ms_swap_order(index1, index2)
- $need_refresh = true
- end
- end
- #==============================================================================
- #■值槽(改编自SLOTCR的值槽生成器,所以保留了他的信息)(是我懒得写了)
- #==============================================================================
- # -----------------------------------------------------------------------------
- # 值槽脚本随机生成系统(SLOTCR) By.Clov
- # 通用版本:RMXP(RGSS1) RMVX(RGSS2) RMVX ACE(RGSS3)
- # 使用方法:在全部窗口类插入即可 例:draw_cr(0,0,变量1,变量2,'开心值',100,10)
- # 参数说明:x x坐标,y y坐标,current 当前值,max 最大值,txt 显示的文字
- # width 值槽的宽,height 值槽的高
- # 背景与边框没有随机的必要,请自行到脚本里设置
- # -----------------------------------------------------------------------------
- class Window_Base
- # -----------------------------------------------------------------------------
- # ● 角色的HP
- # -----------------------------------------------------------------------------
- def draw_cr_hp(x,y,current,max,txt='',width=100,height=7)
- #颜色1、颜色2
- c1=[255, 255, 0];c2=[0, 255, 0]
- #边框色颜色
- bk_color = Color.new(255,255,255,255)
- #数值是否显示
- num = false
- #显示数值的对齐方式 0:向左对齐 1:向中间对齐 2:向右边对齐
- num_align = 1
- #计算比率
- bl = current.to_f / max
- #计算实际宽
- w = (width*bl).round
- #描绘值槽
- r = c1[0];g = c1[1];b = c1[2]
- plus_r = (c2[0]-c1[0])/((width-1)*bl)
- plus_g = (c2[1]-c1[1])/((width-1)*bl)
- plus_b = (c2[2]-c1[2])/((width-1)*bl)
- w.times {|k|
- contents.fill_rect(x+k, y, 1, height, Color.new(r,g,b,255))
- r+=plus_r;g+=plus_g;b+=plus_b}
- contents.fill_rect(x-1, y-1, width+2, 1, bk_color)
- contents.fill_rect(x-1, y+height, width+2, 1, bk_color)
- contents.fill_rect(x-1, y, 1, height, bk_color)
- contents.fill_rect(x+width, y, 1, height, bk_color)
- #描绘文字
- txt_w = contents.text_size(txt).width + 2
- contents.draw_text(x-txt_w,y+height/2-12, width, 24, txt)
- contents.draw_text(x,y+height/2-12, width, 24,
- current.to_s+'/'+max.to_s,num_align) if num
- end
- # -----------------------------------------------------------------------------
- # ● 角色的MP
- # -----------------------------------------------------------------------------
- def draw_cr_mp(x,y,current,max,txt='',width=100,height=7)
- #颜色1、颜色2
- c1=[255, 0, 255];c2=[180, 0, 255]
- #边框色颜色
- bk_color = Color.new(255,255,255,255)
- #数值是否显示
- num = false
- #显示数值的对齐方式 0:向左对齐 1:向中间对齐 2:向右边对齐
- num_align = 1
- #计算比率
- bl = current.to_f / max
- #计算实际宽
- w = (width*bl).round
- #描绘值槽
- r = c1[0];g = c1[1];b = c1[2]
- plus_r = (c2[0]-c1[0])/((width-1)*bl)
- plus_g = (c2[1]-c1[1])/((width-1)*bl)
- plus_b = (c2[2]-c1[2])/((width-1)*bl)
- w.times {|k|
- contents.fill_rect(x+k, y, 1, height, Color.new(r,g,b,255))
- r+=plus_r;g+=plus_g;b+=plus_b}
- contents.fill_rect(x-1, y-1, width+2, 1, bk_color)
- contents.fill_rect(x-1, y+height, width+2, 1, bk_color)
- contents.fill_rect(x-1, y, 1, height, bk_color)
- contents.fill_rect(x+width, y, 1, height, bk_color)
- #描绘文字
- txt_w = contents.text_size(txt).width + 2
- contents.draw_text(x-txt_w,y+height/2-12, width, 24, txt)
- contents.draw_text(x,y+height/2-12, width, 24,
- current.to_s+'/'+max.to_s,num_align) if num
- end
- # -----------------------------------------------------------------------------
- # ● 角色的EXP
- # -----------------------------------------------------------------------------
- def draw_cr_exp(x,y,current,max,txt='',width=100,height=7)
- #颜色1、颜色2
- c1=[0, 255, 255];c2=[0, 0, 255]
- #边框色颜色
- bk_color = Color.new(255,255,255,255)
- #数值是否显示
- num = false
- #显示数值的对齐方式 0:向左对齐 1:向中间对齐 2:向右边对齐
- num_align = 1
- #计算比率
- bl = current.to_f / max
- #计算实际宽
- w = (width*bl).round
- #描绘值槽
- r = c1[0];g = c1[1];b = c1[2]
- plus_r = (c2[0]-c1[0])/((width-1)*bl)
- plus_g = (c2[1]-c1[1])/((width-1)*bl)
- plus_b = (c2[2]-c1[2])/((width-1)*bl)
- w.times {|k|
- contents.fill_rect(x+k, y, 1, height, Color.new(r,g,b,255))
- r+=plus_r;g+=plus_g;b+=plus_b}
- contents.fill_rect(x-1, y-1, width+2, 1, bk_color)
- contents.fill_rect(x-1, y+height, width+2, 1, bk_color)
- contents.fill_rect(x-1, y, 1, height, bk_color)
- contents.fill_rect(x+width, y, 1, height, bk_color)
- #描绘文字
- txt_w = contents.text_size(txt).width + 2
- contents.draw_text(x-txt_w,y+height/2-12, width, 24, txt)
- contents.draw_text(x,y+height/2-12, width, 24,
- current.to_s+'/'+max.to_s,num_align) if num
- end
- end
- # -----------------------------------------------------------------------------
- # ● 角色的跑步值
- # -----------------------------------------------------------------------------
- def draw_cr_rp(x,y,current,max,txt='',width=199,height=7)
- #颜色1、颜色2
- c1=[255, 0, 0];c2=[0, 255, 0]
- #边框色颜色
- bk_color = Color.new(255,255,255,255)
- #数值是否显示
- num = false
- #显示数值的对齐方式 0:向左对齐 1:向中间对齐 2:向右边对齐
- num_align = 1
- #计算比率
- bl = current.to_f / max
- #计算实际宽
- w = (width*bl).round
- #描绘值槽
- r = c1[0];g = c1[1];b = c1[2]
- plus_r = (c2[0]-c1[0])/((width-1)*bl)
- plus_g = (c2[1]-c1[1])/((width-1)*bl)
- plus_b = (c2[2]-c1[2])/((width-1)*bl)
- w.times {|k|
- contents.fill_rect(x+k, y, 1, height, Color.new(r,g,b,255))
- r+=plus_r;g+=plus_g;b+=plus_b}
- contents.fill_rect(x-1, y-1, width+2, 1, bk_color)
- contents.fill_rect(x-1, y+height, width+2, 1, bk_color)
- contents.fill_rect(x-1, y, 1, height, bk_color)
- contents.fill_rect(x+width, y, 1, height, bk_color)
- #描绘文字
- txt_w = contents.text_size(txt).width + 2
- contents.draw_text(x-txt_w,y+height/2-12, width, 24, txt)
- contents.draw_text(x,y+height/2-12, width, 24,
- current.to_s+'/'+max.to_s,num_align) if num
- end
- #==============================================================================
- # ■ Window_MapStatus
- #------------------------------------------------------------------------------
- # UI窗口
- #==============================================================================
- class Window_MapStatus < Window_Base
- #----------------------------------------------------------------------------
- # ● 初始化
- #----------------------------------------------------------------------------
- def initialize
- super($window_x ,$window_y ,230,140)
- self.opacity = 0
- refresh
- end
- #----------------------------------------------------------------------------
- # ● 刷新画面
- #----------------------------------------------------------------------------
- def update
- super
- update_dash
- refresh if $need_refresh
- $need_refresh = false
- if $game_player.screen_x >= 0 and $game_player.screen_x <= self.width and
- $game_player.screen_y >= 0 and $game_player.screen_y <= self.height
- self.contents_opacity = 150
- else self.contents_opacity = 255
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新跑步
- #--------------------------------------------------------------------------
- def update_dash
- # 如果跑步
- if $game_player.dash? && $game_player.moving?
- # 持续减少跑步值
- if $rp > 0
- if Graphics.frame_count % 10 == 0
- $rp -= 1
- $need_refresh = true
- end
- end
- # 不跑步
- else
- # 缓慢恢复跑步值
- if $rp < $mrp
- if Graphics.frame_count % 30 == 0
- $rp += 1
- $need_refresh = true
- end
- end
- end
- # 如果跑步值归零,则禁止跑步,否则可以跑。(在Game_Map的第227行控制)
- if $rp <= 0
- $running= true
- else
- if 100 * $rp / $mrp>= $reset
- $running = false
- end
- end
- end
- #----------------------------------------------------------------------------
- # ● 更新内容
- #----------------------------------------------------------------------------
- def refresh
- self.contents.clear
- draw_actor_face($game_party.members[0], 0, 0)
- draw_actor_name($game_party.members[0], 100, 25)
- draw_actor_level($game_party.members[0], 100, 0)
- draw_actor_icons($game_party.members[0], 100, 50)
- draw_cr_hp(100,78,$game_party.members[0].hp,$game_party.members[0].mhp)
- draw_cr_mp(100,86,$game_party.members[0].mp,$game_party.members[0].mmp)
- draw_cr_exp(100,94,$game_party.members[0].exp,$game_party.members[0].next_level_exp)
- draw_cr_rp(1,102,$rp,$mrp)
- end
-
- end
- #==============================================================================
- # ■ Scene_Map
- #------------------------------------------------------------------------------
- # 将窗口嵌入地图场景
- #==============================================================================
- class Scene_Map < Scene_Base
- #----------------------------------------------------------------------------
- # ● 重命名方法
- #----------------------------------------------------------------------------
- alias ms_sta start
- #----------------------------------------------------------------------------
- # ● 开始处理
- #----------------------------------------------------------------------------
- def start
- ms_sta
- @mapstatus_window = Window_MapStatus.new
- end
- end
复制代码 最后是范例工程(自解压格式文件)(无DLL):
本人喜好使用百度网盘链接,不便之处请谅解。
http://pan.baidu.com/s/1qW8TtwC
|
|