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

Project1

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

[RMVA发布] mother3的转轮血条(更新1.03版,附带事件用sdk- -bbb)

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
270 小时
注册时间
2010-2-4
帖子
1305
跳转到指定楼层
1
 楼主| 发表于 2013-1-28 21:46:28 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 zhangbanxian 于 2013-2-16 16:31 编辑

玩过mother3的可能知道,就是受到攻击不是马上扣血而是一格一格地掉,所以你如果菜单选得快就算受到致命一击也能起死回生- -b
就是这么个系统,可以让rpg变得act一点的东西- -b
那个音乐连击就不整了,通用性不高...
有啥bug欢迎报上来哈...


新版采用了比较试验性质的新写法,可能会有很多奇妙的bug...大家玩得愉快哈...欢迎吐槽xd
顺便有图有真相orz
  1. #================================================================
  2. #                   转轮血条
  3. #
  4. #                  章半仙制作
  5. #================================================================
  6. =begin
  7. 1.03版

  8.   修正默认系统失效的问题
  9.   
  10. 1.02版
  11.   
  12.   增加与XAS系统的兼容

  13.   修正整队后的显示问题

  14.   修正事件注解中的一些笔误
  15.   
  16.   修正与YEA::BATTLE脸图战斗系统共用时的一些显示问题

  17. 1.01版

  18. 修正一处方法名写错导致的bug - -b

  19. 1.00版更新说明

  20. 滚动的计时单位改为帧数,增加更为通俗易懂的转轮速度设置

  21. 增加致命伤害时,显示特别信息和播放特别音效的功能

  22. 增加预览血条的显示,使损血更为直观

  23. 增加更改回血速度和瞬间回血等的事件指令

  24. 增加RollBarManager方便整合到自己的系统

  25. 增加了各种兼容性检测以保证和其他脚本共同工作,代价是代码的可读性更加诡异了- -b

  26. 增加兼容模式,此状态下可以解决大部分血条的显示问题,但效率比较坑爹

  27. 增加与YEA::BATTLE脸图战斗系统的兼容

  28. 解决部分窗口状态刷新不及时的问题

  29. 原本的线程替换为纤程应该可以解决一些战场中途死亡造成的诡异问题- -b


  30. ps:报错的童鞋最好提供冲突工程链接以便排错...

  31.     为了最佳的兼容性,建议把脚本插在main以前的最后一个位置
  32.    
  33. =end

  34. module RollBar
  35. VERSION = 1.03
  36. #转轮的速度
  37. ROLL_SPEED = 1
  38. #对hp、mp和tp转轮速度的分别设置
  39. ROLL_SPEED_FOR_HP = ROLL_SPEED
  40. ROLL_SPEED_FOR_MP = ROLL_SPEED
  41. ROLL_SPEED_FOR_TP = ROLL_SPEED
  42. #每次转轮扣的血(新版建议修改ROLL_SPEED)
  43. ROLL_UNIT = 0.5
  44. #每次转轮花的帧数,数值加大可以增加fps,不过血条显示会变得不流畅(新版建议修改ROLL_SPEED)
  45. ROLL_TIME = 2           
  46. #受到致命的攻击时显示的信息(不需要的话设为nil)
  47. KILL_MSG = {
  48.      :hp => "快要不行了",
  49.      :mp => nil,
  50.      :tp => nil
  51.      }
  52. #受到致命的攻击时播放的音效(设为数字时播放系统声音,设为字符串时指定路径的音效,设为nil时不播放)
  53. KILL_SOUND = {
  54.      :hp => "audio/se/Collapse2.ogg",
  55.      :mp => nil,
  56.      :tp => nil
  57.      }
  58. #是否开启预览条,有预览条可以更清晰的表明损血的状况
  59. PRE_BAR_ENABLE = true
  60. #预览条的颜色设置,只有开启PRE_BAR_ENABLE才有效,颜色格式为Color.new(R,G,B,A),R代表红色值,G代表绿色值,B代表蓝色值,A代表透明值
  61. #受到伤害时的预览条颜色,第一个颜色为渐变初始值,第二个为结束值,设为nil则采用默认色彩
  62. PRE_BAR_COLOR_DAMAGE = {
  63.      :hp => [Color.new(200,0,0),Color.new(255,0,0)],
  64.      :mp => [Color.new(200,0,0),Color.new(255,0,0)],
  65.      :tp => [Color.new(200,0,0),Color.new(255,0,0)]
  66.     }
  67. #恢复时的预览条颜色
  68. PRE_BAR_COLOR_RECOVER = {
  69.      :hp => [Color.new(0,150,0),Color.new(0,200,0)],
  70.      :mp => [Color.new(0,150,0),Color.new(0,200,0)],
  71.      :tp => [Color.new(0,150,0),Color.new(0,200,0)]
  72.      }
  73. #如果需要战斗结束时停止血条的滚动并抛弃伤害的话设为true
  74. STOP_ROLL_AND_CLEAR_DAMGE_WHEN_BATTLE_END = true
  75. #如果需要战斗结束时停止血条的滚动并结算的话设为true
  76. STOP_ROLL_AND_EVAL_DAMGE_WHEN_BATTLE_END = false
  77. #如果读档时需要继续存档之前的滚动状态的话设为true
  78. RESUME_ROLL_WHEN_LOAD = true
  79. #如果血条不显示时就同时暂停血条的滚动(如果你想在对话时停止血条的话就设为true)
  80. PAUSE_ROLL_WHEN_WINDOW_INVISIBLE = false

  81. #兼容模式,可以解决一些血条显示上的问题,效率比较坑爹- -b
  82. SLOW_MODE_ENABLE = false

  83. module RollBarFunc
  84.    #事件脚本接口列表(在事件的脚本框中输入以下内容即可达到相应效果)

  85.    #  速度式回血(值,速度,角色id)
  86.    #  效果:以特定的速度回血
  87.    #  参数表:值  数值型 要加的血
  88.    #         速度 数值型   为0时无视滚动直接加血
  89.    #         角色id 数值型 0或负数时则指代队伍中的id
  90.    #                       例如-1时就指代队伍中的第二个人
  91.    #  使用范例:(注意全半角- -b)
  92.    #      速度式回血(100,2,1)
  93.    def recover_hp_with_speed(val,speed,actor_id=0)
  94.      get_actor(actor_id).send(:hp=,get_actor(actor_id).hp+val,speed)
  95.    end
  96.    #  速度式扣血(值,速度,角色id)
  97.    #  效果:以特定的速度扣血
  98.    #  参数表:值  数值型
  99.    #         速度 数值型   
  100.    #         角色id 数值型
  101.    def damage_hp_with_speed(val,speed,actor_id=0)
  102.      recover_hp_with_speed(-val,speed,actor_id)
  103.    end
  104.    #  直接回血(值,角色id)
  105.    #  效果:无视滚动直接回血
  106.    #  参数表:值  数值型
  107.    #         角色id 数值型
  108.    def recover_hp_straight(val,actor_id=0)
  109.      get_actor(actor_id).will_hp = nil
  110.      recover_hp_with_speed(val,0,actor_id)
  111.    end
  112.    #  直接扣血(值,角色id)
  113.    #  效果:无视滚动直接扣血
  114.    #  参数表:值  数值型
  115.    #         角色id 数值型   
  116.    def damage_hp_straight(val,actor_id=0)
  117.      recover_hp_straight(-val,actor_id)
  118.    end   
  119.    #  速度式回魔(值,速度,角色id)
  120.    #  效果:以特定的速度回魔
  121.    #  参数表:值  数值型
  122.    #         速度 数值型   
  123.    #         角色id 数值型
  124.    def recover_mp_with_speed(val,speed,actor_id=0)
  125.      get_actor(actor_id).send(:mp=,get_actor(actor_id).mp+val,speed)
  126.    end
  127.    #  速度式扣魔(值,速度,角色id)
  128.    #  效果:以特定的速度扣魔
  129.    #  参数表:值  数值型
  130.    #         速度 数值型   
  131.    #         角色id 数值型
  132.    def damage_mp_with_speed(val,speed,actor_id=0)
  133.      recover_mp_with_speed(-val,speed,actor_id)
  134.    end
  135.    #  直接回魔(值,角色id)
  136.    #  效果:无视滚动直接回魔
  137.    #  参数表:值  数值型
  138.    #         角色id 数值型
  139.    def recover_mp_straight(val,actor_id=0)
  140.      get_actor(actor_id).will_mp = nil
  141.      recover_mp_with_speed(val,0,actor_id)
  142.    end
  143.    #  直接扣魔(值,角色id)
  144.    #  效果:无视滚动直接扣魔
  145.    #  参数表:值  数值型
  146.    #         角色id 数值型   
  147.    def damage_mp_straight(val,actor_id=0)
  148.      drecover_mp_straight(-val,actor_id)
  149.    end   
  150.    
  151.    #  瞬间全恢复(角色序列)
  152.    #  效果:无视滚动回满血蓝
  153.    #  参数表:角色序列 数值型  角色在队伍中的序列
  154.    #                          -1代表全体队员,可省略
  155.    #  使用范例:
  156.    #  瞬间全恢复
  157.    def all_recover_straight(index=-1)
  158.      get_party(index) do |i|
  159.        i.will_hp = nil;i.send(:hp=,i.mhp,0)
  160.        i.will_mp = nil;i.send(:mp=,i.mmp,0)
  161.        i.will_tp = nil;i.send(:tp=,i.max_tp,0)
  162.      end
  163.    end
  164.    #  设置滚动暂停标志(角色序列,血条类型,标志)
  165.    #  效果:暂停相应角色的血条滚动(暂停状态下减血不会立即显示但会计入)
  166.    #  参数表:角色序列 数值型  角色在队伍中的序列
  167.    #                          -1代表全体队员,可省略
  168.    #         血条类型  :hp  #=>对应hp条
  169.    #                   :mp  #=>对应mp条  
  170.    #                   :tp  #=>对应tp条
  171.    #         标志 布尔型 决定是暂停还是继续
  172.    #  使用范例:
  173.    #      设置滚动暂停标志(-1,:mp,true)

  174.    def set_roll_pause_flag(index=-1,type=:hp,flag=true)
  175.      get_party(index) do |i|
  176.        case type
  177.        when :hp
  178.          i.hp_rollbar_pause = flag
  179.        when :mp
  180.          i.mp_rollbar_pause = flag
  181.        when :tp
  182.          i.tp_rollbar_pause = flag
  183.        end
  184.      end
  185.    end
  186.    #  暂停滚动
  187.    #  效果:暂停所有的滚动中的血条
  188.    #  参数表:无
  189.    #  使用范例:
  190.    #      暂停滚动
  191.    #      显示文章 : 因为我在说话就给你们休息一下
  192.    #      恢复滚动
  193.    def pause_roll
  194.      set_roll_pause_flag(-1,:hp,true)
  195.      set_roll_pause_flag(-1,:mp,true)
  196.      set_roll_pause_flag(-1,:tp,true)
  197.    end
  198.    #  恢复滚动
  199.    #  效果:恢复所有的滚动中的血条
  200.    #  参数表:无
  201.    def resume_roll
  202.      set_roll_pause_flag(-1,:hp,false)
  203.      set_roll_pause_flag(-1,:mp,false)
  204.      set_roll_pause_flag(-1,:tp,false)
  205.    end
  206.    #  清除伤害(角色序列,血条类型)
  207.    #  效果:让某个角色当前滚动的血条不再滚动
  208.    #  参数表:角色序列 数值型  角色在队伍中的序列
  209.    #                          -1代表全体队员,可省略
  210.    #         血条类型  :hp  #=>对应hp条
  211.    #                   :mp  #=>对应mp条  
  212.    #                   :tp  #=>对应tp条
  213.    def clear_roll_damage(index=-1,type=:hp)
  214.      get_party(index) do |i|
  215.        case type
  216.        when :hp
  217.          i.will_hp = i.hp
  218.        when :mp
  219.          i.will_mp = i.mp
  220.        when :tp
  221.          i.will_tp = i.tp
  222.        end
  223.      end
  224.    end
  225.    #  清除所有伤害(角色序列)
  226.    #  效果:让某个角色当前滚动的所有血条不再滚动
  227.    #  参数表:角色序列 数值型  角色在队伍中的序列
  228.    #                          -1代表全体队员,可省略
  229.    def clear_all_roll_damage(index=-1)
  230.      clear_roll_damage(-1,:hp)
  231.      clear_roll_damage(-1,:mp)
  232.      clear_roll_damage(-1,:tp)
  233.    end   
  234.    #  结算伤害(角色序列,血条类型)
  235.    #  效果:让某个角色当前滚动的血条直接到达目标血量
  236.    #  参数表:角色序列 数值型  角色在队伍中的序列
  237.    #                          -1代表全体队员,可省略
  238.    #         血条类型  :hp  #=>对应hp条
  239.    #                   :mp  #=>对应mp条  
  240.    #                   :tp  #=>对应tp条
  241.    def eval_roll_damage(index=-1,type=:hp)
  242.      get_party(index) do |i|
  243.        case type
  244.        when :hp
  245.          huaka = i.will_hp;i.will_hp = nil;i.send(:hp=,huaka,0)
  246.        when :mp
  247.          huaka = i.will_mp;i.will_mp = nil;i.send(:mp=,huaka,0)
  248.        when :tp
  249.          huaka = i.will_tp;i.will_tp = nil;i.send(:tp=,huaka,0)
  250.        end
  251.      end
  252.    end
  253.    #  结算所有伤害(角色序列,血条类型)
  254.    #  效果:让某个角色当前滚动的血条不再滚动
  255.    #  参数表:角色序列 数值型  角色在队伍中的序列
  256.    #                          -1代表全体队员,可省略
  257.    #         血条类型  :hp  #=>对应hp条
  258.    #                   :mp  #=>对应mp条  
  259.    #                   :tp  #=>对应tp条
  260.    def eval_all_roll_damage(index=-1)
  261.      eval_roll_damage(-1,:hp)
  262.      eval_roll_damage(-1,:mp)
  263.      eval_roll_damage(-1,:tp)
  264.    end   
  265.    #  改变角色滚动速度(速度,角色id,血条类型)
  266.    #  效果:改变对应角色id的相应血条的滚动速度(正在滚动的血条速度不变)
  267.    #  参数表:速度 数值型   为0时无视滚动直接加血
  268.    #                       为负数时可以让以后的一切扣血变为加血
  269.    #         角色id 数值型                       
  270.    #         血条类型  :hp  #=>对应hp条
  271.    #                   :mp  #=>对应mp条  
  272.    #                   :tp  #=>对应tp条
  273.    #  使用范例:
  274.    #      改变角色滚动速度(2,1,:hp)
  275.    #      增减hp : 全体队友, +100
  276.    #      恢复角色滚动速度(1,:hp)
  277.    def change_roll_speed_for_actor(speed,actor_id=0,type=:hp)
  278.      case type
  279.      when :hp
  280.        get_actor(actor_id).hp_rollbar_speed = speed
  281.      when :mp
  282.        get_actor(actor_id).mp_rollbar_speed = speed
  283.      when :tp
  284.        get_actor(actor_id).tp_rollbar_speed = speed
  285.      end
  286.    end
  287.    #  恢复角色滚动速度(角色id,血条类型)
  288.    #  效果:恢复对应角色id的相应血条的滚动速度
  289.    #  参数表:角色id 数值型
  290.    #          血条类型  :hp  #=>对应hp条
  291.    #                   :mp  #=>对应mp条  
  292.    #                   :tp  #=>对应tp条
  293.    def recover_roll_speed_for_actor(actor_id=0,type=:hp)
  294.      change_roll_speed_for_actor(nil,actor_id,type)
  295.    end
  296.    def get_actor(actor_id)
  297.      actor_id > 0 ? $game_actors[actor_id] : $game_party.members[actor_id.abs]
  298.    end
  299.    def get_party(index)
  300.      party = index == -1 ? $game_party.members : [$game_party.members[index]]
  301.      party.each{|i|yield i}
  302.    end
  303.    #速查表- -b
  304.    alias 速度式回血 recover_hp_with_speed
  305.    alias 速度式扣血 damage_hp_with_speed
  306.    alias 直接回血 recover_hp_straight
  307.    alias 直接扣血 damage_hp_straight   
  308.    alias 速度式回魔 recover_mp_with_speed
  309.    alias 速度式扣魔 damage_mp_with_speed
  310.    alias 直接回魔 recover_mp_straight
  311.    alias 直接扣魔 damage_mp_straight
  312.    alias 瞬间全恢复 all_recover_straight
  313.    alias 设置滚动暂停标志 set_roll_pause_flag
  314.    alias 暂停滚动 pause_roll
  315.    alias 恢复滚动 resume_roll
  316.    alias 暂停滚动 pause_roll
  317.    alias 清除伤害 clear_roll_damage
  318.    alias 清除所有伤害 clear_all_roll_damage
  319.    alias 结算伤害 eval_roll_damage
  320.    alias 结算所有伤害 eval_all_roll_damage
  321.    alias 改变角色滚动速度 change_roll_speed_for_actor
  322.    alias 恢复角色滚动速度 recover_roll_speed_for_actor
  323. end
  324. module RollBarManager
  325.   class << self
  326.     def init
  327.       @roll_bar_missions = []
  328.       @roll_bar_visible_missions = []
  329.       @roll_bar_windows = []
  330.       @huaka_classes = {}
  331.       @default_rollbar_speed = {:hp => RollBar::ROLL_SPEED_FOR_HP,
  332.                                 :mp => RollBar::ROLL_SPEED_FOR_MP,
  333.                                 :tp => RollBar::ROLL_SPEED_FOR_TP
  334.       }
  335.     end
  336.      #sample:
  337.      #roll_bar_item RollBarActor, :hp
  338.      #@hp,@will_hp,@hp_rollbar_speed,@hp_rollbar_pause
  339.      def roll_bar_item(actor_class,item,
  340.                                   max_name="m"+item.to_s,
  341.                                   will_name="will_"+item.to_s,
  342.                                   speed_name=item.to_s+"_rollbar_speed",
  343.                                   pause_name=item.to_s+"_rollbar_pause")
  344.       method_name = huaka_name = item.to_s + "="
  345.       each_huaka_class(actor_class) do
  346.        attr_writer speed_name
  347.        attr_accessor pause_name
  348.        attr_accessor will_name
  349.        define_huaka_method method_name do |val,speed=self.send(speed_name)|
  350.          return unless val
  351.          now_p = instance_variable_get("@"+item.to_s)
  352.          will_p = instance_variable_get("@"+will_name)
  353.          instance_variable_set("@"+will_name,will_p = now_p) unless will_p
  354.          huaka_p = val - now_p        
  355.          return if huaka_p == 0
  356.          roll_unit = (speed == 0) ? huaka_p : ROLL_UNIT * speed
  357.          huaka_p = - huaka_p if speed < 0
  358.          rec = huaka_p > 0
  359.          roll_unit = - roll_unit if rec ^ (speed > 0)
  360.          instance_variable_set("@"+will_name,[[will_p+huaka_p,send(max_name)].min, 0].max.round)
  361.          RollBarManager.reg_roll_bar_mission huaka_fiber = Fiber.new {
  362.          (huaka_p / roll_unit).round.abs.times do
  363.            will_p = instance_variable_get("@"+will_name)
  364.            now_p = instance_variable_get("@"+item.to_s)
  365.            break if will_p == now_p || (will_p > now_p) ^ rec
  366.            Fiber.yield while instance_variable_get("@"+pause_name)
  367.            instance_variable_set("@"+item.to_s,[[now_p+roll_unit.round,send(max_name)].min, 0].max.round)
  368.            refresh
  369.            Fiber.yield
  370.          end
  371.          RollBarManager.unreg_roll_bar_mission(huaka_fiber)
  372.          }
  373.        end
  374.        define_method speed_name do
  375.         huaka = instance_variable_get("@"+speed_name)
  376.         huaka ? huaka : RollBarManager.default_rollbar_speed[item]
  377.        end
  378.      end
  379.     end
  380.      #sample:
  381.      #draw_roll_bar RollBarVisibleObject, :hp
  382.      #hook_metod: draw_actor_hp , draw_gauge
  383.      #callback_method: hp_bar_flag , hp_pre_bar_args , hp_clear_args
  384.     def draw_roll_bar(window_class,type,
  385.                                    bar_method="draw_actor_"+type.to_s,
  386.                                    pre_bar_method=:draw_gauge,
  387.                                    slow_mode=false,
  388.                                    pre_repeat_method=:def_pre_repeat,
  389.                                    bar_flag_method=type.to_s+"_bar_flag",
  390.                                    pre_bar_args_method=type.to_s+"_pre_bar_args",
  391.                                    clear_args_method=type.to_s+"_clear_args",
  392.                                    contents_method=false)
  393.        bar_method = bar_method.to_s
  394.        pre_bar_method = PRE_BAR_ENABLE ? pre_bar_method.to_s : false
  395.        define_huaka_method_for_classes(window_class,bar_method) do |*args|
  396.         fiber = Fiber.new {
  397.           until disposed?
  398.             break unless RollBarManager.roll_bar_visible_missions.include? fiber
  399.             flag ||= false
  400.             huaka_flag = bar_flag_method ? send(bar_flag_method,*args) : true
  401.             if !huaka_flag || flag == huaka_flag
  402.               Fiber.yield !close? && visible
  403.               next
  404.             end
  405.             flag = bar_flag_method ? send(bar_flag_method,*args) : true
  406.             clear_args = clear_args_method ? send(clear_args_method,*args) : args[1,4]
  407.             x,y,width,height = *clear_args
  408.             huaka_bitmap ||= save_bitmap(x,y,width,height) if slow_mode
  409.             contents.clear_rect(x,y,width,height)
  410.             load_bitmap(x,y,huaka_bitmap) if slow_mode
  411.             if pre_bar_method
  412.              define_singleton_method pre_bar_method do |*a|
  413.                super(*a)
  414.                pre_bar_args = send(pre_bar_args_method,*args)
  415.                return unless pre_bar_args
  416.                rate = pre_bar_args[0]
  417.                color = pre_bar_args[1] ? PRE_BAR_COLOR_DAMAGE[type] : PRE_BAR_COLOR_RECOVER[type]
  418.                x = a[0] + (a[2] * [rate,a[3]].min).round
  419.                y = a[1] + line_height - 8
  420.                width = (a[2] * ([rate,a[3]].max - [rate,a[3]].min)).round
  421.                color1 = color[0] ? color[0] : a[4]
  422.                color2 = color[1] ? color[1] : a[5]
  423.                contents.gradient_fill_rect(x, y, width, 6, color1,color2)
  424.              end
  425.             end
  426.             call_meta_method(bar_method,*args)
  427.             if pre_bar_method
  428.              (class << self;self;end).send(:remove_method,pre_bar_method)
  429.             end
  430.             Fiber.yield !close? && visible
  431.           end  
  432.           huaka_bitmap.dispose if slow_mode && huaka_bitmap
  433.           @roll_bars_pre_repeat.delete fiber
  434.           RollBarManager.unreg_roll_bar_visible_mission(fiber)
  435.          }
  436.         @roll_bars_pre_repeat ||= {}
  437.         pre_repeat = send(:def_pre_repeat,*args)
  438.         @roll_bars_pre_repeat.each_pair do |f,p|
  439.           RollBarManager.unreg_roll_bar_visible_mission(f) if pre_repeat == p
  440.         end
  441.         @roll_bars_pre_repeat[fiber] = pre_repeat
  442.         RollBarManager.reg_roll_bar_visible_mission fiber
  443.         fiber.resume
  444.        end  
  445.     end
  446.     def reg_roll_bar_mission(fiber)
  447.       @roll_bar_missions.push fiber unless @roll_bar_missions.include? fiber
  448.     end
  449.     def unreg_roll_bar_mission(fiber)
  450.       @roll_bar_missions.delete fiber
  451.     end
  452.     def reg_roll_bar_visible_mission(fiber)
  453.       @roll_bar_visible_missions.push fiber unless @roll_bar_missions.include? fiber
  454.     end
  455.     def unreg_roll_bar_visible_mission(fiber)
  456.       @roll_bar_visible_missions.delete fiber
  457.     end
  458.     def find_huaka_class(klass)
  459.       return klass if @huaka_classes.has_value?(klass)
  460.       unless @huaka_classes[klass]
  461.         return klass if klass.name == ""
  462.         @huaka_classes[klass] = Class.new(klass)
  463.         klass_name = klass.name.split("::")
  464.         const_name = klass_name.pop
  465.         nesting = klass_name.empty? ? Object : eval(klass_name.join("::"))
  466.         nesting.const_set(const_name,@huaka_classes[klass])
  467.       end
  468.       @huaka_classes[klass]
  469.     end
  470.     def each_huaka_class(type,&def_proc)
  471.       ObjectSpace.each_object(Class) do |i|
  472.         next if !i.include?(type)
  473.         huaka_class = find_huaka_class(i)
  474.         def huaka_class.define_huaka_method(method_name,&proc)
  475.           RollBarManager.define_huaka_method(self,method_name,&proc)
  476.         end
  477.         huaka_class.module_eval &def_proc
  478.       end
  479.     end
  480.     def define_huaka_method_for_classes(type,method_name,&proc)
  481.       ObjectSpace.each_object(Class) do |i|
  482.         next if !i.include?(type)
  483.         define_huaka_method(i,method_name,&proc)
  484.       end
  485.     end
  486.     def define_huaka_method(klass,method_name,&proc)
  487.       klass = find_huaka_class(klass)
  488.       unless klass.method_defined? :call_meta_method
  489.         klass.send(:define_method,:call_meta_method) do |method_name,*args|
  490.           RollBarManager.call_meta_method(self,method_name,*args)
  491.         end
  492.       end
  493.       klass.send(:define_method,method_name,&proc)
  494.     end
  495.     def call_meta_method(object,method_name,*args)
  496.       klass = ::Object.instance_method(:class).bind(object).call
  497.       @huaka_classes.key(klass).instance_method(method_name).bind(object).call(*args)
  498.     end
  499.     attr_reader   :roll_bar_missions
  500.     attr_reader   :roll_bar_visible_missions
  501.     attr_accessor :default_rollbar_speed
  502.   end
  503. end
  504. module RollBarActor
  505.    def self.included(klass)
  506.      RollBarManager.roll_bar_item self, :hp,:mhp
  507.      RollBarManager.roll_bar_item self, :mp,:mmp
  508.      RollBarManager.roll_bar_item self, :tp,:max_tp
  509.    end
  510. end
  511. module RollBarScene
  512.    def self.included(klass)
  513.       RollBarManager.define_huaka_method_for_classes(self,:refresh_status){}
  514.       RollBarManager.define_huaka_method_for_classes(self,:update_basic) do
  515.          super()
  516.          @frame_count ||=0   
  517.          @frame_count += 1        
  518.          return unless @frame_count > ROLL_TIME
  519.          @frame_count = 0
  520.          for i in RollBarManager.roll_bar_visible_missions
  521.           needroll |= i.resume
  522.         end
  523.          if PAUSE_ROLL_WHEN_WINDOW_INVISIBLE
  524.            return unless needroll
  525.          end
  526.          for i in RollBarManager.roll_bar_missions
  527.           i.resume
  528.          end
  529.          if is_a?(Scene_Battle) && BattleManager.actor
  530.           if BattleManager.actor.input.nil?
  531.            BattleManager.actor.make_actions
  532.            next_command
  533.           end
  534.         end
  535.       end
  536.       RollBarManager.define_huaka_method_for_classes(self,:terminate) do
  537.         super()
  538.         case self
  539.         when Scene_Battle
  540.         if STOP_ROLL_AND_CLEAR_DAMGE_WHEN_BATTLE_END
  541.           clear_all_roll_damage
  542.         elsif STOP_ROLL_AND_EVAL_DAMGE_WHEN_BATTLE_END
  543.           eval_all_roll_damage
  544.         end
  545.         when Scene_Load
  546.         if RESUME_ROLL_WHEN_LOAD
  547.           get_party(-1) do |i|
  548.            will_hp = i.will_hp
  549.            will_mp = i.will_mp
  550.            will_tp = i.will_tp
  551.            (i.will_hp = nil;i.hp = will_hp) if will_hp
  552.            (i.will_mp = nil;i.mp = will_mp) if will_mp
  553.            (i.will_tp = nil;i.tp = will_tp) if will_tp
  554.           end
  555.          end
  556.         end
  557.       end
  558.     end
  559. end
  560. module RollBarVisibleObject
  561.    def self.included(klass)
  562.     RollBarManager.draw_roll_bar self, :hp, :draw_actor_hp, :draw_gauge, SLOW_MODE_ENABLE || defined? YEA::BATTLE
  563.     RollBarManager.draw_roll_bar self, :mp, :draw_actor_mp, :draw_gauge ,SLOW_MODE_ENABLE || defined? YEA::BATTLE
  564.     RollBarManager.draw_roll_bar self, :tp, :draw_actor_tp, :draw_gauge, SLOW_MODE_ENABLE || defined? YEA::BATTLE
  565.     RollBarManager.draw_roll_bar self, :name, :draw_actor_name, false, SLOW_MODE_ENABLE || defined? YEA::BATTLE
  566.     RollBarManager.draw_roll_bar self, :state,:draw_actor_icons, false, SLOW_MODE_ENABLE || defined? YEA::BATTLE
  567.     if defined? YEA::BATTLE
  568.      RollBarManager.draw_roll_bar self, :yea_action,:draw_actor_action,false,true
  569.     end
  570.   end
  571.   def save_bitmap(x, y, width,height=line_height)
  572.     bitmap = Bitmap.new(width,height)
  573.     rect = Rect.new(x, y, width,height)
  574.     bitmap.blt(0, 0, contents, rect)
  575.     bitmap
  576.   end
  577.   def load_bitmap(x,y,bitmap)
  578.     rect = Rect.new(0, 0, bitmap.width,bitmap.height)
  579.     contents.blt(x, y,bitmap, rect)
  580.   end
  581.   #callback系列
  582.   def hp_bar_flag(actor, x, y, width=124)
  583.     actor.hp
  584.   end
  585.   def mp_bar_flag(actor, x, y, width=124)
  586.     actor.mp
  587.   end
  588.   def tp_bar_flag(actor, x, y, width=124)
  589.     actor.tp
  590.   end
  591.   def name_bar_flag(actor, x, y, width=112)
  592.     [actor.hp == 0,(actor.hp < actor.mhp / 4)]
  593.   end
  594.   def state_bar_flag(actor, x, y, width=96)
  595.     return false if actor.is_a?(Game_Enemy) && actor.dead?
  596.     actor.state_icons | actor.buff_icons
  597.   end
  598.   def hp_clear_args(actor, x, y, width=124)
  599.     if defined? YEA::BATTLE
  600.       if SceneManager.scene_is?(Scene_Battle)
  601.        contents.font.size = YEA::BATTLE::BATTLESTATUS_TEXT_FONT_SIZE
  602.       end
  603.     end
  604.     [x, y, width, line_height]
  605.   end
  606.   alias mp_clear_args hp_clear_args
  607.   alias tp_clear_args hp_clear_args
  608.   def name_clear_args(actor, x, y, width=112)
  609.     if defined? YEA::BATTLE
  610.       if SceneManager.scene_is?(Scene_Battle)
  611.        (x += 24;width -= 24)
  612.       end
  613.     end
  614.     [x, y, width, line_height]
  615.   end
  616.   def state_clear_args(actor, x, y, width=96)
  617.     [x, y, width, line_height]
  618.   end
  619.   def hp_pre_bar_args(actor, x, y, width=124)
  620.      return false if actor.will_hp.nil?
  621.      return false if actor.will_hp == actor.hp
  622.      [actor.will_hp.to_f / actor.mhp,actor.will_hp < actor.hp]
  623.   end
  624.   def mp_pre_bar_args(actor, x, y, width=124)
  625.      return false if actor.will_mp.nil?
  626.      return false if actor.will_mp == actor.mp
  627.      [actor.will_mp.to_f / actor.mmp,actor.will_mp < actor.mp]
  628.   end
  629.    def tp_pre_bar_args(actor, x, y, width=124)
  630.      return false if actor.will_tp.nil?
  631.      return false if actor.will_tp == actor.tp
  632.      [actor.will_tp.to_f / actor.max_tp,actor.will_tp < actor.tp]
  633.    end
  634.    def def_pre_repeat(actor, x, y, width=96)
  635.      [x,y,width]
  636.    end
  637.    if defined? YEA::BATTLE
  638.     def yea_action_bar_flag(actor, dx, dy)
  639.       action_icon(actor)
  640.     end
  641.     def yea_action_clear_args(actor, dx, dy)
  642.       [dx, dy, 24, 24]
  643.     end
  644.    end
  645. end

  646. module RollBarActionResult
  647.   
  648.   def kill?(type=:hp)
  649.     case type
  650.     when :hp
  651.     return false unless @battler.will_hp
  652.     @hp_damage > 0 && @battler.will_hp <= 0
  653.     when :mp
  654.     return false unless @battler.will_mp
  655.     @mp_damage > 0 && @battler.will_mp <= 0
  656.     when :tp
  657.     return false unless @battler.will_tp
  658.     @tp_damage > 0 && @battler.will_tp <= 0
  659.     end   
  660.   end
  661. end
  662. module RollBarBattleLog
  663.    def self.included(klass)
  664.      KILL_MSG.each_pair do |sym,msg|
  665.       method_name = "display_" + sym.to_s + "_damage"
  666.       RollBarManager.define_huaka_method_for_classes(self,method_name) do |target, item|
  667.        super(target, item)
  668.        return unless target.is_a?(Game_Actor)
  669.        return unless target.result.kill?(sym)
  670.        add_text(target.name+msg) unless msg.nil?
  671.        if KILL_SOUND[sym].is_a?(Integer)
  672.         Sound.play_system_sound(KILL_SOUND[sym])
  673.        elsif KILL_SOUND[sym].is_a?(String)
  674.         Audio.se_play(KILL_SOUND[sym])
  675.        end
  676.        wait unless msg.nil?
  677.      end  
  678.    end
  679.   end
  680. end
  681. RollBarManager.init
  682. end
  683. class Game_Interpreter
  684.   include RollBar
  685.   include RollBarFunc
  686. end
  687. class Window_Base
  688.   include RollBar
  689.   include RollBarVisibleObject
  690. end
  691. class Game_Actor
  692. include RollBar
  693. include RollBarActor
  694. end
  695. class Scene_Base
  696.   include RollBar
  697.   include RollBarFunc
  698.   include RollBarScene
  699. end
  700. class Game_ActionResult
  701.   include RollBar
  702.   include RollBarActionResult
  703. end
  704. class Window_BattleLog
  705.   include RollBar
  706.   include RollBarBattleLog
  707. end
  708. if defined? XAS_SYSTEM
  709.   class Active_Hud
  710.    include RollBar
  711.    RollBarManager.define_huaka_method(self,:hp_flow_update) do
  712.     super()
  713.     if @actor.will_hp && @actor.hp != @actor.will_hp
  714.      will_hp_width = @hp_range * @actor.will_hp / @actor.mhp
  715.      color = @actor.will_hp < @actor.hp ? PRE_BAR_COLOR_DAMAGE[:hp] : PRE_BAR_COLOR_RECOVER[:hp]
  716.      color1 = color[0] ? color[0] : @hp_sprite.bitmap.get_pixel(0, 0)
  717.      color2 = color[1] ? color[1] : @hp_sprite.bitmap.get_pixel(0, 0)
  718.      width = [@hp_width,will_hp_width].max - [@hp_width,will_hp_width].min
  719.      @hp_sprite.bitmap.gradient_fill_rect([@hp_width,will_hp_width].min, 0, width, @hp_height, color1,color2)
  720.     end
  721.    end
  722.    RollBarManager.define_huaka_method(self,:sp_flow_update) do
  723.     super()
  724.     if @actor.will_mp && @actor.mp != @actor.will_mp
  725.      will_sp_width = @sp_range * @actor.will_mp / @actor.mmp
  726.      color = @actor.will_mp < @actor.mp ? PRE_BAR_COLOR_DAMAGE[:mp] : PRE_BAR_COLOR_RECOVER[:mp]
  727.      color1 = color[0] ? color[0] : @sp_sprite.bitmap.get_pixel(0, 0)
  728.      color2 = color[1] ? color[1] : @sp_sprite.bitmap.get_pixel(0, 0)
  729.      width = [@sp_width,will_sp_width].max - [@sp_width,will_sp_width].min
  730.      @sp_sprite.bitmap.gradient_fill_rect([@sp_width,will_sp_width].min, 0, width, @sp_height, color1,color2)
  731.     end
  732.    end
  733. end
  734. end
复制代码

评分

参与人数 6星屑 +535 +1 收起 理由
TXYC + 1 我很赞同
cinderelmini + 20 塞糖~
纠结之星 + 5 不解释~~
feizhaodan + 300 奖赏条例
Luciffer + 200 精品文章
acn00269 + 10

查看全部评分

Lv3.寻梦者

梦石
0
星屑
3657
在线时间
4466 小时
注册时间
2008-6-12
帖子
802
2
发表于 2013-1-28 22:53:24 | 只看该作者
不错,就是滚动的稍微有点慢。

点评

懂了,就是加个预览血条吧...  发表于 2013-2-1 10:12
半仙大概我表达的意思不太对,怎么说呢,就是扣血之后,没法第一时间知道掉去的血量。然后慢慢的滚动~  发表于 2013-1-29 13:38
滚动的速度方面ROLL_TIME可以调的,降fps这是没办法的,优化了半天还是这样- -b  发表于 2013-1-29 11:30
本人三无老人,请大神轻拍
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
132 小时
注册时间
2012-1-13
帖子
95
3
发表于 2013-1-28 23:32:01 | 只看该作者
怎么没有什么效果???
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
45
在线时间
25 小时
注册时间
2013-1-26
帖子
42
4
发表于 2013-1-29 16:18:35 | 只看该作者
很不错,就是血掉的太慢了!

我觉得应该先快后慢这样不错!
回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

万兽

梦石
0
星屑
597
在线时间
2271 小时
注册时间
2006-11-4
帖子
4868

贵宾

5
发表于 2013-1-29 19:17:38 | 只看该作者
想法很好啊,可是俺想不到回合制的战斗该为何运用起来…另外,LZ起变量名也太随便了吧,这个fuck hp是要闹哪样啊…
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
270 小时
注册时间
2010-2-4
帖子
1305
6
 楼主| 发表于 2013-1-29 23:43:45 手机端发表。 | 只看该作者
弗雷德 发表于 2013-1-29 19:17
想法很好啊,可是俺想不到回合制的战斗该为何运用起来…另外,LZ起变量名也太随便了吧,这个fuck hp是要闹 ...

就跟mother3一样运用呗...命名的话,看不爽全文替换下就好了,谁叫ruby不能编译xd
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
530 小时
注册时间
2012-4-16
帖子
99
7
发表于 2013-1-30 19:44:22 | 只看该作者
发现一BUG,和后知后觉版的横版一起用,角色被敌人打死后,血条滚动到0,接着就卡住不动了。还有一个问题,我测试的角色打完第一场战斗后,角色最大血条600血左右,被打到剩100血,然后吃了个补500血的血瓶,接着那数字在一直滚动,遇到了第二场战斗,战斗开始了那数字还在滚动,还没补满血( ⊙ o ⊙ )啊!

点评

哦哦,有人在用啊~那个横版的链接给下,要不然不好解决- -b  发表于 2013-2-1 10:14
头像透露一个角色,开坑制作中……
回复 支持 反对

使用道具 举报

Lv4.逐梦者 (超级版主)

嗜谎者

梦石
2
星屑
16856
在线时间
3904 小时
注册时间
2010-9-12
帖子
9647

极短24评委极短23评委极短22评委极短21评委开拓者

8
发表于 2013-1-31 16:17:23 | 只看该作者
有点意思,我拿去玩了~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
99
在线时间
60 小时
注册时间
2013-1-29
帖子
45
9
发表于 2013-1-31 16:29:06 | 只看该作者
表示你这是要弄生化危机么,转轮血条.....................

点评

放心不是你想象的那样的= =  发表于 2013-2-2 21:13
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
589
在线时间
332 小时
注册时间
2011-11-19
帖子
194
10
发表于 2013-1-31 20:46:33 | 只看该作者
跟脸图战斗配合以后就没反应了,脚本的效果如同消失了一般……

点评

哪个脚本来着?  发表于 2013-2-1 10:15
支持《彼岸之光》系列!加油!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-6-26 19:18

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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