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

Project1

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

[已经过期] 连击技能如何判定次数?

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2054
在线时间
540 小时
注册时间
2012-5-3
帖子
86

开拓者

跳转到指定楼层
1
发表于 2021-8-29 14:31:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我最近想修改一下关于连击的次数判定,因为采用了全动画脚本,所以不太知道如何修改哪一处敌方才能实现效果。现在的问题是不管敌人多少血都会一口气把动画给播完,这样的话看起来就会很奇葩,按照常规应该是假设敌方200血量,我第一下如果已经输出了201血的时候那么剩下的动画应该就结束不播放直接重新开始计算才对,所以想请教大神帮我看看。
  1. #==============================================================================
  2. # ■ Game_Battler (分割定义 3)
  3. # v1.0更改了普通攻击效果与法术攻击效果计算
  4. #------------------------------------------------------------------------------
  5. #  处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
  6. # 超级类来使用。
  7. #==============================================================================
  8. class Game_Battler
  9.         #--------------------------------------------------------------------------
  10.         # ● 可以使用特技的判定
  11.         #     skill_id : 特技 ID
  12.         #--------------------------------------------------------------------------
  13.         def skill_can_use?(skill_id)
  14.                 # 狮驼岭变身检测
  15.                 if skill_id == 139 or skill_id == 140 or skill_id == 141 or skill_id == 142
  16.                         if self.states.include?(56)
  17.                         else
  18.                                 return false
  19.                         end
  20.                 end
  21.                 # SP 不足的情况下不能使用
  22.                 if $data_skills[skill_id].sp_cost > self.sp
  23.                         return false
  24.                 end
  25.                 # 战斗不能的情况下不能使用
  26.                 if dead?
  27.                         return false
  28.                 end
  29.                 # 沉默状态的情况下、物理特技以外的特技不能使用
  30.                 if $data_skills[skill_id].atk_f >= 0 and self.restriction == 1
  31.                         return false
  32.                 end
  33.                 # 获取可以使用的时机
  34.                 occasion = $data_skills[skill_id].occasion
  35.                 # 战斗中的情况下
  36.                 if $game_temp.in_battle
  37.                         # [平时] 或者是 [战斗中] 可以使用
  38.                         return (occasion == 0 or occasion == 1)
  39.                         # 不是战斗中的情况下
  40.                 else
  41.                         # [平时] 或者是 [菜单中] 可以使用
  42.                         return (occasion == 0 or occasion == 2)
  43.                 end
  44.         end
  45.         #--------------------------------------------------------------------------
  46.         # ● 基本通常攻击效果
  47.         #     attacker : 攻击者 (battler)
  48.         #     damage : 原伤害
  49.         #--------------------------------------------------------------------------
  50.         def base_attack_effect(attacker,damage)
  51.                 # 大雁塔副本第一层男性角色物理攻击无效
  52.                 if $game_variables.[](3)== 11
  53.                         if attacker.name == "怀念" or attacker.name == "逍遥生" or
  54.                                 attacker.name == "落夜" or attacker.name == "虎头怪" or
  55.                                 attacker.name == "坤哥" or attacker.name == "神天兵"
  56.                                 damage = 0
  57.                         end
  58.                 end
  59.                 # 大雁塔副本第二层所有角色攻击无效,只能使用法术技能。
  60.                 if $game_variables.[](3)== 12
  61.                         if attacker.name == "怀念" or attacker.name == "逍遥生" or
  62.                                 attacker.name == "钱小燕" or attacker.name == "怀玉" or
  63.                                 attacker.name == "风玲儿" or attacker.name == "落夜" or
  64.                                 attacker.name == "玄彩娥" or attacker.name == "虎头怪" or
  65.                                 attacker.name == "坤哥" or attacker.name == "狐美人" or
  66.                                 attacker.name == "骨精灵" or attacker.name == "神天兵"
  67.                                 damage = 0
  68.                         end
  69.                 end
  70.                 # 大雁塔副本第三层物理攻击无效,只能使用含沙射影。
  71.                 if $game_variables.[](3)== 13
  72.                         if attacker.name == "怀念" or attacker.name == "逍遥生" or
  73.                                 attacker.name == "钱小燕" or attacker.name == "怀玉" or
  74.                                 attacker.name == "风玲儿" or attacker.name == "落夜" or
  75.                                 attacker.name == "玄彩娥" or attacker.name == "虎头怪" or
  76.                                 attacker.name == "坤哥" or attacker.name == "狐美人" or
  77.                                 attacker.name == "骨精灵" or attacker.name == "神天兵"
  78.                                 damage = 0
  79.                         end
  80.                 end
  81.                 # 大雁塔副本第四层物理攻击无效,只能使用唧唧歪歪。
  82.                 if $game_variables.[](3)== 14
  83.                         if attacker.name == "怀念" or attacker.name == "逍遥生" or
  84.                                 attacker.name == "钱小燕" or attacker.name == "怀玉" or
  85.                                 attacker.name == "风玲儿" or attacker.name == "落夜" or
  86.                                 attacker.name == "玄彩娥" or attacker.name == "虎头怪" or
  87.                                 attacker.name == "坤哥" or attacker.name == "狐美人" or
  88.                                 attacker.name == "骨精灵" or attacker.name == "神天兵"
  89.                                 damage = 0
  90.                         end
  91.                 end
  92.     # 大雁塔副本所有宝宝物理攻击无效
  93.     if $game_variables.[](3)== 11 or $game_variables.[](3)== 12 or
  94.       $game_variables.[](3)== 13 or $game_variables.[](3)== 14
  95.       if attacker.id >= 21 and attacker.id <= 404
  96.        damage = 0
  97.       end
  98.     end
  99.                 # 伤害符号正确的情况下
  100.                 if damage > 0
  101.                         # 会心一击修正
  102.                         bs  = (attacker.atk - self.pdef*2)*100 / attacker.atk
  103.                         # 设置必杀技能几率
  104.                         bisha = 0
  105.                         # 是否含有必杀技能
  106.                         if attacker.skill_learn?(48)
  107.                                 bisha = 20
  108.                         elsif attacker.skill_learn?(47)
  109.                                 bisha = 10
  110.                         end
  111.                         # 设置幸运几率
  112.                         xingyun = 0
  113.                         # 是否含有幸运技能
  114.                         if skill_learn?(89)
  115.                                 xingyun = 100
  116.                         end
  117.                         if rand(100) < [[bs,3].max,7].min + bisha - xingyun
  118.                                 damage *= 2
  119.                                 self.critical = true
  120.                         end
  121.                 end
  122.                 # 技能防御检测
  123.                 # 技能防御生成的防御力
  124.                 fy = 0
  125.                 if skill_learn?(55)
  126.                         fy = self.pdef / 5
  127.                 elsif skill_learn?(54)
  128.                         fy = self.pdef / 10
  129.                 end
  130.                 # 计算基本伤害
  131.                 damage = [damage - fy,10].max
  132.                 if attacker.is_a?(Game_Actor)
  133.                         #检测如果攻击者学会了连击,攻击力降低80%
  134.                         if attacker.skill_learn?(52) or attacker.skill_learn?(53)
  135.                                 damage = damage * 80 / 100
  136.                         end
  137.                 end
  138.                 # 高级偷袭检测
  139.                 if attacker.skill_learn?(57)
  140.                         damage += damage / 10
  141.                 end
  142.                 #是否学习了隐身技能
  143.                 #if skill_learn?(179)
  144.                 # if $game_temp.battle_turn == 1
  145.                 #   add_state(79)
  146.                 # end
  147.                 #end
  148.                 # 检测神佑复生
  149.                 if skill_learn?(61)
  150.                         if rand(100) < 30 and self.hp <= self.maxhp / 2
  151.                                 damage = [self.hp - self.maxhp,0].min
  152.                         end
  153.                 elsif skill_learn?(60) and self.hp <= self.maxhp / 2
  154.                         if rand(100) < 15
  155.                                 damage = [self.hp - self.maxhp,0].min
  156.                         end
  157.                 end
  158.                 # 防御修正
  159.                 if self.guarding?
  160.                         damage /= 2
  161.                 end
  162.                 return damage
  163.         end
  164.         #--------------------------------------------------------------------------
  165.         # ● 应用通常攻击效果
  166.         #     attacker : 攻击者 (battler)
  167.         #--------------------------------------------------------------------------
  168.         def attack_effect(attacker)
  169.                 # 谁打我
  170.                 @who_attack_me = attacker
  171.                 # 清除会心一击标志
  172.                 self.critical = false
  173.                 # 第一命中判定
  174.                 hit_result = (rand(100) < attacker.hit - self.eva)
  175.                 # 命中的情况下
  176.                 if hit_result == true
  177.                         # 计算基本伤害
  178.                         self.damage = [attacker.atk - self.pdef,10].max
  179.                         # 根据等级递进伤害
  180.                         self.damage += self.damage * attacker.level / 1000
  181.                         # 分散
  182.                         if self.damage.abs > 0
  183.                                 amp = [self.damage.abs * 15 / 100, 1].max
  184.                                 self.damage += rand(amp+1) + rand(amp+1) - amp
  185.                         end
  186.                         # 连击检测
  187.                         if self.lianji == false
  188.                         elsif self.lianji == true
  189.                                 self.damage *= 2
  190.                         end
  191.                         # 关闭连击标志
  192.                         self.lianji=(false)
  193.                         # 检测是否后发状态
  194.                         if attacker.state?(3)
  195.                                 if self.damage > 500
  196.                                         self.damage *= 2
  197.                                 else
  198.                                         self.damage *= 2
  199.                                         self.damage += 200
  200.                                 end
  201.                         end
  202.                 end
  203.                 # 命中的情况下
  204.                 if hit_result == true
  205.                         # 状态冲击解除
  206.                         remove_states_shock
  207.                         # 检测攻击方是否处于后发状态
  208.                         if attacker.state?(3)
  209.                                 attacker.remove_state(3, false)
  210.                         end
  211.                         # HP 的伤害计算
  212.                         self.damage = base_attack_effect(attacker,self.damage)
  213.                         # 技能数加成奖励
  214.                         if attacker.is_a?(Game_Actor)
  215.                                 a = self.damage * attacker.skills.size / 100
  216.                                 self.damage += a
  217.                         end
  218.                         d = Integer(self.damage)
  219.                         self.hp -= d
  220.                         # 状态变化
  221.                         @state_changed = false
  222.                         states_plus(attacker.plus_state_set)
  223.                         states_minus(attacker.minus_state_set)
  224.                         # Miss 的情况下
  225.                 else
  226.                         # 伤害设置为 "Miss"
  227.                         self.damage = "Miss"
  228.                         # 清除会心一击标志
  229.                         self.critical = false
  230.                 end
  231.                 # 过程结束
  232.                 return true
  233.         end
  234.         #--------------------------------------------------------------------------
  235.         # ● 应用特技效果
  236.         #     user  : 特技的使用者 (battler)
  237.         #     skill : 特技
  238.         #--------------------------------------------------------------------------
  239.         def skill_effect(user, skill)
  240.                 # 大雁塔副本第一层男性角色技能攻击无效
  241.                 if $game_variables.[](3)== 11
  242.                         if user.name == "怀念" or user.name == "逍遥生" or
  243.                                 user.name == "落夜" or user.name == "虎头怪" or
  244.                                 user.name == "坤哥" or user.name == "神天兵"
  245.                                 skill.power = 0
  246.                         end
  247.                 end
  248.                 # 大雁塔副本第三层法术攻击无效,只能使用含沙射影。
  249.                 if $game_variables.[](3)== 13
  250.                         if user.name == "怀念" or user.name == "逍遥生" or
  251.                                 user.name == "钱小燕" or user.name == "怀玉" or
  252.                                 user.name == "风玲儿" or user.name == "落夜" or
  253.                                 user.name == "玄彩娥" or user.name == "虎头怪" or
  254.                                 user.name == "坤哥" or user.name == "狐美人" or
  255.                                 user.name == "骨精灵" or user.name == "神天兵"
  256.                                 skill.power = 0
  257.                         end
  258.                 end
  259.                 # 大雁塔副本第四层法术攻击无效,只能使用唧唧歪歪。
  260.                 if $game_variables.[](3)== 14
  261.                         if user.name == "怀念" or user.name == "怀玉" or
  262.                                 user.name == "钱小燕" or user.name == "落夜" or
  263.                                 user.name == "玄彩娥" or user.name == "虎头怪" or
  264.                                 user.name == "坤哥" or user.name == "狐美人" or
  265.                                 user.name == "骨精灵" or user.name == "神天兵"
  266.         skill.hit = 0
  267.       elsif user.name == "风玲儿"
  268.         skill.power = 0
  269.                         end
  270.                 end
  271.     # 大雁塔副本所有宝宝法术攻击无效
  272.     if $game_variables.[](3)== 11 or $game_variables.[](3)== 13 or
  273.       $game_variables.[](3)== 14
  274.       if user.id >= 21 and user.id <= 404
  275.        skill.power = 0
  276.       end
  277.     end
  278.                         # 如果是捕捉
  279.                         if skill.id == 9
  280.                                 r = 230 - user.level
  281.                                 if self.id > 320 and self.id < 353
  282.                                         if rand(250) < r
  283.                                                 baby_id = (self.id - 300) + (user.id - 1)*32
  284.                                                 if user.add_baby(baby_id)
  285.                                                         self.damage = self.hp
  286.                                                         self.hp -= self.damage
  287.                                                         return true
  288.                                                 end
  289.                                         else
  290.                                                 txt = user.name + "捕捉"+self.name+"失败."
  291.                                                 $game_party.update_message(txt)
  292.                                         end
  293.                                 elsif self.id > 401 and self.id < 404
  294.                                         if rand(250) < r
  295.                                                 baby_id = (self.id - 353) + (user.id - 1)*32
  296.                                                 if user.add_baby(baby_id)
  297.                                                         self.damage = self.hp
  298.                                                         self.hp -= self.damage
  299.                                                         return true
  300.                                                 end
  301.                                         else
  302.                                                 txt = user.name + "捕捉"+self.name+"失败."
  303.                                                 $game_party.update_message(txt)
  304.                                         end
  305.                                 elsif self.id > 406 and self.id < 419
  306.                                         if rand(250) < r
  307.                                                 baby_id = (self.id - 190) + (user.id - 1)*32
  308.                                                 if user.add_baby(baby_id)
  309.                                                         self.damage = self.hp
  310.                                                         self.hp -= self.damage
  311.                                                         return true
  312.                                                 end
  313.                                         else
  314.                                                 txt = user.name + "捕捉"+self.name+"失败."
  315.                                                 $game_party.update_message(txt)
  316.                                         end
  317.                                 else
  318.                                         txt = "该对象不是宝宝不可以捕捉."
  319.                                         $game_party.update_message(txt)
  320.                                 end
  321.                         end
  322.                         # 清除会心一击标志
  323.                         self.critical = false
  324.                         # 特技的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
  325.                         # 或者特技的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
  326.                         if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  327.                                 ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  328.                                 # 过程结束
  329.                                 return false
  330.                         end
  331.                         # 清除有效标志
  332.                         effective = false
  333.                         # 公共事件 ID 是有效的情况下,设置为有效标志
  334.                         effective |= skill.common_event_id > 0
  335.                         # 第一命中判定
  336.                         hit = skill.hit
  337.                         if skill.atk_f > 0
  338.                                 hit *= user.hit / 100
  339.                         end
  340.                         hit_result = (rand(100) < hit)
  341.                         # 不确定的特技的情况下设置为有效标志
  342.                         effective |= hit < 100
  343.                         # 命中的情况下
  344.                         if hit_result == true
  345.                                 # 如果法术的攻击力不为0则换成物理攻击效果
  346.                                 if skill.atk_f != 0
  347.                                         ac1 = [user.atk - self.pdef * 2 / 3,1].max
  348.                                         # 法术攻击力为攻击加成,攻击力为200则认为是200%攻击力
  349.                                         ac1 += ac1 * skill.atk_f / 100
  350.                                         # 如果同时法术威力小于0则代表降低伤害
  351.                                         if skill.power < 0
  352.                                                 ac1 += ac1 * skill.power / 100
  353.                                         end
  354.                                         self.damage = ac1
  355.                                         # 检测对象是否正在被善恶善报
  356.                                         if self.shanbao == true
  357.                                                 #是的话伤害为负
  358.                                                 self.damage = -(self.damage / 2)
  359.                                                 #关闭善报标志
  360.                                                 self.shanbao=(false)
  361.                                         else
  362.                                                 # 检测攻击力是否加成伤害倍数(用于连击与善恶时)
  363.                                                 for i in 22..27
  364.                                                         if skill.element_set.include?(i)
  365.                                                                 self.damage *= i - 21
  366.                                                         end
  367.                                                 end
  368.                                         end
  369.                                         # 调用基本攻击效果
  370.                                         self.damage = base_attack_effect(user,self.damage)
  371.                                         if skill.variance > 0 and self.damage.abs > 0
  372.                                                 a = self.damage * skill.variance / 100
  373.                                                 self.damage += rand(a) - rand(a)
  374.                                         end
  375.                                 else
  376.                                         # 计算威力
  377.                                         power = skill.power
  378.                                         if power > 0
  379.                                                 #计算基本法术伤害公式
  380.                                                 #((技能加成百分比+1)*(双方灵力差与0的最大值)+([自身灵力/5-受击者灵力/10]与1的最大值))*(10-作用人数)/10
  381.                                                 #技能百分比与双方灵力差
  382.                                                 #add1 = (power / 100.0 + 1) * [user.mdef - self.mdef,0].max
  383.             add1 = (power / 100.0 + 1) * [user.int - self.mdef,0].max
  384.                                                 #双方灵力不平等灵力差
  385.                                                 #add2 = [user.mdef / 5 - self.mdef / 10,1].max
  386.             add2 = [user.int - self.mdef,1].max
  387.             #p  self.mdef
  388.                                                 #作用人数
  389.                                                 add3 = $scene.target_battlers.size
  390.                                                 self.damage = Integer((add1 + add2)*(10 - add3) / 10)
  391.                                                 if skill.variance > 0 and self.damage.abs > 0
  392.                                                         amp = [self.damage.abs * skill.variance / 100, 1].max
  393.                                                         self.damage += rand(amp+1) + rand(amp+1) - amp
  394.                                                 end
  395.                                         else
  396.                                                 self.damage = power
  397.                                         end
  398.                                         # 检测特殊法术效果
  399.                                         if skill.name == "夜舞倾城"
  400.                                                 self.damage = user.atk * 2 / 3
  401.                                         end
  402.                                         if skill.name == "壁垒击破"
  403.                                                 self.damage *= 2
  404.                                         end
  405.                                         # 检测魔之心
  406.                                         if user.skill_learn?(63)
  407.                                                 self.damage += self.damage / 5
  408.                                         elsif user.skill_learn?(62)
  409.                                                 self.damage += self.damage / 10
  410.                                         end
  411.                                         # 检测法术暴击
  412.                                         if user.skill_learn?(65)
  413.                                                 if rand(100) < 40
  414.                                                         self.damage *= 2
  415.                                                         self.critical = true
  416.                                                 end
  417.                                         elsif user.skill_learn?(64)
  418.                                                 if rand(100) < 20
  419.                                                         self.damage *= 2
  420.                                                         self.critical = true
  421.                                                 end
  422.                                         end
  423.                                         # 检测法术波动
  424.                                         if user.skill_learn?(97)
  425.                                                 a = self.damage / 5
  426.                                                 self.damage += rand(a) - rand(a)
  427.                                         elsif user.skill_learn?(96)
  428.                                                 a = self.damage / 10
  429.                                                 self.damage += rand(a) - rand(a)
  430.                                         end
  431.                                 end
  432.                         end
  433.                         # 命中的情况下
  434.                         if hit_result == true
  435.                                 # 威力0以外的物理攻击的情况下
  436.                                 if skill.power != 0 or skill.atk_f > 0
  437.                                         # 状态冲击解除
  438.                                         remove_states_shock
  439.                                         # 设置有效标志
  440.                                         effective = true
  441.                                 end
  442.                                 # HP 的伤害减法运算
  443.                                 last_hp = self.hp
  444.                                 # 如果法术没有动画则不减少气血.
  445.                                 if skill.animation2_id != 0
  446.                                         # 固定伤害法术检测
  447.                                         if skill.id == 31 or skill.id == 155#暗器 or 阎罗令
  448.                                                 self.damage = user.level * 4
  449.                                         elsif skill.id == 6#小试牛刀
  450.                                                 self.damage = 200 + user.level * 5
  451.                                         elsif skill.id == 109#我佛慈悲
  452.                                                 self.damage = - user.level * 12
  453.                                         elsif skill.id == 110#推气过宫
  454.                                                 self.damage = - user.level * 10
  455.                                         elsif skill.id == 104#针灸
  456.                                                 self.damage = -user.level * 12
  457.                                         elsif skill.id == 117#龙吟
  458.                                                 self.damage = user.level + 20
  459.                                                 self.sp -= user.level + 20
  460.                                         elsif skill.id == 121#生命之泉
  461.                                                 self.damage = - user.level * 4
  462.                                         elsif skill.id == 133#五雷轰顶
  463.                                                 self.damage = self.hp * user.level * (rand(6) + 1) / 3000
  464.                                         elsif skill.id  == 150 or skill.id  == 165 or  skill.id  == 166 or
  465.                                                 skill.id  == 167 or skill.id  == 168
  466.                                                 #天罗地网,地烈火,苍茫树,巨岩破,日光华
  467.                                                 self.damage = user.level * 4
  468.                                         elsif skill.id == 151#勾魂
  469.                                                 self.damage = self.hp / 5
  470.                                         elsif skill.id == 156#判官令
  471.                                                 self.damage = user.level * 7
  472.                                         elsif skill.id == 162#普渡众生
  473.                                                 self.damage = - user.level * 4
  474.                                         elsif skill.id == 163#杨柳甘露
  475.                                                 self.damage = - user.level * 5
  476.                                         elsif skill.id == 72#惊心一剑
  477.                                                 self.sp -= self.damage  
  478.                                         end
  479.                                         self.hp -= self.damage
  480.                                 end
  481.                                 effective |= self.hp != last_hp
  482.                                 # 状态变化
  483.                                 @state_changed = false
  484.                                 effective |= states_plus(skill.plus_state_set)
  485.                                 effective |= states_minus(skill.minus_state_set)
  486.                                 # Miss 的情况下
  487.                         else
  488.                                 # 伤害设置为 "Miss"
  489.                                 self.damage = "Miss"
  490.                         end
  491.                         # 不在战斗中的情况下
  492.                         unless $game_temp.in_battle
  493.                                 # 伤害设置为 nil
  494.                                 self.damage = nil
  495.                         end
  496.                         # 过程结束
  497.                         return effective
  498.                 end
  499.                 #--------------------------------------------------------------------------
  500.                 # ● 应用物品效果
  501.                 #     item : 物品
  502.                 #--------------------------------------------------------------------------
  503.                 def item_effect(item)
  504.                         # 清除会心一击标志
  505.                         self.critical = false
  506.                         # 物品的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
  507.                         # 或者物品的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
  508.                         if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  509.                                 ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  510.                                 # 过程结束
  511.                                 return false
  512.                         end
  513.                         # 清除有效标志
  514.                         effective = false
  515.                         # 公共事件 ID 是有效的情况下,设置为有效标志
  516.                         effective |= item.common_event_id > 0
  517.                         # 命中判定
  518.                         hit_result = (rand(100) < item.hit)
  519.                         # 不确定的特技的情况下设置为有效标志
  520.                         effective |= item.hit < 100
  521.                         # 命中的情况
  522.                         if hit_result == true
  523.                                 # 计算回复量
  524.                                 recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
  525.                                 recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
  526.                                 if recover_hp < 0
  527.                                         recover_hp += self.pdef * item.pdef_f / 20
  528.                                         recover_hp += self.mdef * item.mdef_f / 20
  529.                                         recover_hp = [recover_hp, 0].min
  530.                                 end
  531.                                 # 属性修正
  532.                                 recover_hp *= elements_correct(item.element_set)
  533.                                 recover_hp /= 100
  534.                                 recover_sp *= elements_correct(item.element_set)
  535.                                 recover_sp /= 100
  536.                                 # 分散
  537.                                 if item.variance > 0 and recover_hp.abs > 0
  538.                                         amp = [recover_hp.abs * item.variance / 100, 1].max
  539.                                         recover_hp += rand(amp+1) + rand(amp+1) - amp
  540.                                 end
  541.                                 if item.variance > 0 and recover_sp.abs > 0
  542.                                         amp = [recover_sp.abs * item.variance / 100, 1].max
  543.                                         recover_sp += rand(amp+1) + rand(amp+1) - amp
  544.                                 end
  545.                                 # 回复量符号为负的情况下
  546.                                 if recover_hp < 0
  547.                                         # 防御修正
  548.                                         if self.guarding?
  549.                                                 recover_hp /= 2
  550.                                         end
  551.                                 end
  552.                                 # HP 回复量符号的反转、设置伤害值
  553.                                 self.damage = -recover_hp
  554.                                 # HP 以及 SP 的回复
  555.                                 last_hp = self.hp
  556.                                 last_sp = self.sp
  557.                                 self.hp += recover_hp
  558.                                 self.sp += recover_sp
  559.                                 effective |= self.hp != last_hp
  560.                                 effective |= self.sp != last_sp
  561.                                 # 状态变化
  562.                                 @state_changed = false
  563.                                 effective |= states_plus(item.plus_state_set)
  564.                                 effective |= states_minus(item.minus_state_set)
  565.                                 # 能力上升值有效的情况下
  566.                                 if item.parameter_type > 0 and item.parameter_points != 0
  567.                                         # 能力值的分支
  568.                                         case item.parameter_type
  569.                                         when 1  # MaxHP
  570.                                                 @maxhp_plus += item.parameter_points
  571.                                         when 2  # MaxSP
  572.                                                 @maxsp_plus += item.parameter_points
  573.                                         when 3  # 力量
  574.                                                 @str_plus += item.parameter_points
  575.                                         when 4  # 灵巧
  576.                                                 @dex_plus += item.parameter_points
  577.                                         when 5  # 速度
  578.                                                 @agi_plus += item.parameter_points
  579.                                         when 6  # 魔力
  580.                                                 @int_plus += item.parameter_points
  581.                                         end
  582.                                         # 设置有效标志
  583.                                         effective = true
  584.                                 end
  585.                                 # HP 回复率与回复量为 0 的情况下
  586.                                 if item.recover_hp_rate == 0 and item.recover_hp == 0
  587.                                         # 设置伤害为空的字符串
  588.                                         self.damage = ""
  589.                                         # SP 回复率与回复量为 0、能力上升值无效的情况下
  590.                                         if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  591.                                                 (item.parameter_type == 0 or item.parameter_points == 0)
  592.                                                 # 状态没有变化的情况下
  593.                                                 unless @state_changed
  594.                                                         # 伤害设置为 "Miss"
  595.                                                         self.damage = "Miss"
  596.                                                 end
  597.                                         end
  598.                                 end
  599.                                 # Miss 的情况下
  600.                         else
  601.                                 # 伤害设置为 "Miss"
  602.                                 self.damage = "Miss"
  603.                         end
  604.                         # 不在战斗中的情况下
  605.                         unless $game_temp.in_battle
  606.                                 # 伤害设置为 nil
  607.                                 self.damage = nil
  608.                         end
  609.                         # 过程结束
  610.                         return effective
  611.                 end
  612.                 #--------------------------------------------------------------------------
  613.                 # ● 应用连续伤害效果
  614.                 #--------------------------------------------------------------------------
  615.                 def slip_damage_effect()
  616.                         # 设置伤害
  617.                         sp_count = 0
  618.                         for i in @states
  619.                                 if $data_states[i].slip_damage
  620.                                         if i == 24#漫天花雨
  621.                                                 self.damage = self.hp / 10
  622.                                                 self.hp -= self.damage
  623.                                                 self.sp -= self.sp / 20
  624.                                         elsif i == 53#尸腐毒
  625.                                                 self.damage = self.hp / 10
  626.                                                 self.hp -= self.damage
  627.                                         elsif i == 50#紧箍咒
  628.                                                 self.damage = self.hp / 10
  629.                                                 self.hp -= self.damage
  630.                                         elsif i == 45#生命之泉
  631.                                                 #伤害为队伍平均等级*2
  632.                                                 self.damage = -$game_party.avg_level * 5
  633.                                                 self.hp -= self.damage
  634.                                         elsif i == 49#普渡众生
  635.                                                 #伤害为队伍平均等级*2
  636.                                                 self.damage = -$game_party.avg_level * 8
  637.                                                 self.hp -= self.damage
  638.                                         elsif i == 46#炼气化神
  639.                                                 self.damage = -$game_party.avg_level * 5
  640.                                                 self.sp -= self.damage
  641.                                         end
  642.                                         #显示弹出伤害动画
  643.                                         if self.damage != nil
  644.                                                 self.show_damage_animation = false
  645.                                                 self.show_damage(self.damage)
  646.                                         end
  647.                                 end
  648.                         end
  649.                         # 过程结束
  650.                         return true
  651.                 end
  652.                 #--------------------------------------------------------------------------
  653.                 # ● 属性修正计算
  654.                 #     element_set : 属性
  655.                 #--------------------------------------------------------------------------
  656.                 def elements_correct(element_set)
  657.                         # 無属性的情况
  658.                         if element_set == []
  659.                                 # 返回 100
  660.                                 return 100
  661.                         end
  662.                         # 在被赋予的属性中返回最弱的
  663.                         # ※过程 element_rate 是、本类以及继承的 Game_Actor
  664.                         #   和 Game_Enemy 类的定义
  665.                         weakest = -100
  666.                         for i in element_set
  667.                                 weakest = [weakest, self.element_rate(i)].max
  668.                         end
  669.                         return weakest
  670.                 end
  671.         end
复制代码
  1. #==============================================================================
  2. # ■ Scene_Battle (分割定义 4)
  3. #------------------------------------------------------------------------------
  4. #  处理战斗画面的类。
  5. # v1.0 添加了使用物品和特技时不选择使用方动画则默认播放角色施法动画
  6. # v1.1 添加连续法术效果(关键字:连续播放)
  7. #==============================================================================
  8. class Scene_Battle
  9.         #--------------------------------------------------------------------------
  10.         # ● 开始主回合
  11.         #--------------------------------------------------------------------------
  12.         def start_phase4
  13.                 # 转移到回合 4
  14.                 @phase = 4
  15.                 # 回合数计数
  16.                 $game_temp.battle_turn += 1
  17.                 # 搜索全页的战斗事件
  18.                 for index in 0...$data_troops[@troop_id].pages.size
  19.                         # 获取事件页
  20.                         page = $data_troops[@troop_id].pages[index]
  21.                         # 本页的范围是 [回合] 的情况下
  22.                         if page.span == 1
  23.                                 # 设置已经执行标志
  24.                                 $game_temp.battle_event_flags[index] = false
  25.                         end
  26.                 end
  27.                 # 设置角色为非选择状态
  28.                 @actor_index = -1
  29.                 @active_battler = nil
  30.                 # 无效化角色指令窗口
  31.                 @actor_command_window.active = false
  32.                 @actor_command_window.visible = false
  33.                 @baby_command_window.active = false
  34.                 @baby_command_window.visible = false
  35.                 # 设置主回合标志
  36.                 $game_temp.battle_main_phase = true
  37.                 # 生成敌人行动
  38.                 for enemy in $game_troop.enemies
  39.                         enemy.make_action
  40.                 end
  41.                 # 生成行动顺序
  42.                 make_action_orders
  43.                 # 移动到步骤 1
  44.                 @phase4_step = 1
  45.         end
  46.         #--------------------------------------------------------------------------
  47.         # ● 生成行动循序 (改动)
  48.         #--------------------------------------------------------------------------
  49.         def make_action_orders
  50.                 # 初始化序列 @action_battlers
  51.                 @action_battlers = []
  52.                 # 添加敌人到 @action_battlers 序列
  53.                 for enemy in $game_troop.enemies
  54.                         @action_battlers.push(enemy)
  55.                 end
  56.                 # 添加角色到 @action_battlers 序列
  57.                 for actor in $game_party.actors
  58.                         @action_battlers.push(actor)
  59.                 end
  60.                 # 确定全体的行动速度
  61.                 for battler in @action_battlers
  62.                         battler.make_action_speed
  63.                         # 检测迟钝
  64.                         if battler.skill_learn?(51)
  65.                                 battler.current_action.speed = battler.current_action.speed * 4 / 5
  66.                         end
  67.                         # 检测高级敏捷
  68.                         if battler.skill_learn?(59)
  69.                                 battler.current_action.speed += battler.current_action.speed * 3 /10
  70.                         elsif battler.skill_learn?(58)
  71.                                 battler.current_action.speed += battler.current_action.speed / 10
  72.                         end
  73.                         # 后发
  74.                         if battler.state?(3)
  75.                                 battler.current_action.speed += 5000
  76.                         end
  77.                 end
  78.                 # 按照行动速度从大到小排列
  79.                 @action_battlers.sort! {|a,b|
  80.                         b.current_action.speed - a.current_action.speed }
  81.         end
  82.         #--------------------------------------------------------------------------
  83.         # ● 刷新画面 (主回合)
  84.         #--------------------------------------------------------------------------
  85.         def update_phase4
  86.                 case @phase4_step
  87.                 when 1
  88.                         update_phase4_step1
  89.                 when 2
  90.                         update_phase4_step2
  91.                 when 3
  92.                         update_phase4_step3
  93.                 when 4
  94.                         update_phase4_step4
  95.                 when 5
  96.                         update_phase4_step5
  97.                 when 6
  98.                         update_phase4_step6
  99.                 end
  100.         end
  101.         #--------------------------------------------------------------------------
  102.         # ● 刷新画面 (主回合步骤 1 : 准备行动)
  103.         #--------------------------------------------------------------------------
  104.         def update_phase4_step1
  105.                 # 隐藏帮助窗口
  106.                 @help_window.visible = false
  107.                 # 判定胜败
  108.                 if judge
  109.                         # 胜利或者失败的情况下 : 过程结束
  110.                         return
  111.                 end
  112.                 # 强制行动的战斗者不存在的情况下
  113.                 if $game_temp.forcing_battler == nil
  114.                         # 设置战斗事件
  115.                         setup_battle_event
  116.                         # 执行战斗事件中的情况下
  117.                         if $game_system.battle_interpreter.running?
  118.                                 return
  119.                         end
  120.                 end
  121.                 # 强制行动的战斗者存在的情况下
  122.                 if $game_temp.forcing_battler != nil
  123.                         # 在头部添加后移动
  124.                         @action_battlers.delete($game_temp.forcing_battler)
  125.                         @action_battlers.unshift($game_temp.forcing_battler)
  126.                 end
  127.                 # 未行动的战斗者不存在的情况下 (全员已经行动)
  128.                 if @action_battlers.size == 0
  129.                         # 开始同伴命令回合
  130.                         start_phase2
  131.                         return
  132.                 end
  133.                 # 初始化动画 ID 和公共事件 ID
  134.                 @animation1_id = 0
  135.                 @animation2_id = 0
  136.                 @common_event_id = 0
  137.                 # 未行动的战斗者移动到序列的头部
  138.                 @active_battler = @action_battlers.shift
  139.                 # 如果已经在战斗之外的情况下
  140.                 if @active_battler.index == nil
  141.                         return
  142.                 end
  143.                 # 移至步骤 2
  144.                 @phase4_step = 2
  145.         end
  146.         #--------------------------------------------------------------------------
  147.         # ● 刷新画面 (主回合步骤 2 : 开始行动)
  148.         #--------------------------------------------------------------------------
  149.         def update_phase4_step2
  150.                 # 如果不是强制行动
  151.                 unless @active_battler.current_action.forcing
  152.                         # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  153.                         if @active_battler.restriction == 2 or @active_battler.restriction == 3
  154.                                 # 设置行动为攻击
  155.                                 @active_battler.current_action.kind = 0
  156.                                 @active_battler.current_action.basic = 0
  157.                         end
  158.                         # 限制为 [不能行动]以及死亡的情况下
  159.                         if @active_battler.restriction == 4 or @active_battler.hp == 0
  160.                                 # 清除行动强制对像的战斗者
  161.                                 $game_temp.forcing_battler = nil
  162.                                 # 移至步骤 1
  163.                                 @phase4_step = 1
  164.                                 return
  165.                         end
  166.                 end
  167.                 # 清除对像战斗者
  168.                 @target_battlers = []
  169.                 # 检测后发状态,并强制转换为普通攻击
  170.                 if @active_battler.state?(3) and @active_battler.current_houfa != -1
  171.                         # 设置行动
  172.                         @active_battler.current_action.kind = 0
  173.                         @active_battler.current_action.basic = 0
  174.                         @active_battler.current_action.target_index = @active_battler.current_houfa
  175.                         @active_battler.current_houfa = -1
  176.                 end
  177.                 # 行动种类分支
  178.                 case @active_battler.current_action.kind
  179.                 when 0  # 基本
  180.                         make_basic_action_result
  181.                 when 1  # 特技
  182.                         make_skill_action_result
  183.                 when 2  # 物品
  184.                         make_item_action_result
  185.                 end
  186.                 # 移至步骤 3
  187.                 if @phase4_step == 2
  188.                         @phase4_step = 3
  189.                 end
  190.         end
  191.         #--------------------------------------------------------------------------
  192.         # ● 生成基本行动结果
  193.         #--------------------------------------------------------------------------
  194.         def make_basic_action_result
  195.                 # 攻击的情况下
  196.                 if @active_battler.current_action.basic == 0
  197.                         # 物理攻击不能状态下不生成行动结果
  198.                         for i in @active_battler.states
  199.                                 # 15为物理攻击不能
  200.                                 if $data_states[i].guard_element_set.include?(15)
  201.                                         return
  202.                                 end
  203.                         end
  204.                         # 设置攻击 ID
  205.                         @animation1_id = @active_battler.animation1_id
  206.                         @animation2_id = @active_battler.animation2_id
  207.                         # 如果动画为666则默认攻击多样动画
  208.                         if @active_battler.animation2_id == 666 or @animation2_id == 0
  209.                                 case rand(2)
  210.                                 when 0
  211.                                         @animation2_id = @active_battler.battler_name.split(/★/)[9].to_i()
  212.                                         @animation1_id = @active_battler.battler_name.split(/★/)[10].to_i()
  213.                                 when 1
  214.                                         @animation2_id = @active_battler.battler_name.split(/★/)[11].to_i()
  215.                                         @animation1_id = @active_battler.battler_name.split(/★/)[12].to_i()
  216.                                 end
  217.                         end
  218.                         # 这里通过判断是否攻击多样化
  219.                         # 行动方的战斗者是敌人的情况下
  220.                         if @active_battler.is_a?(Game_Enemy)
  221.                                 if @active_battler.restriction == 3
  222.                                         target = $game_troop.random_target_enemy
  223.                                 elsif @active_battler.restriction == 2
  224.                                         target = $game_party.random_target_actor
  225.                                 else
  226.                                         index = @active_battler.current_action.target_index
  227.                                         target = $game_party.smooth_target_actor(index)
  228.                                 end
  229.                         end
  230.                         # 行动方的战斗者是角色的情况下
  231.                         if @active_battler.is_a?(Game_Actor)
  232.                                 if @active_battler.restriction == 3
  233.                                         target = $game_party.random_target_actor
  234.                                 elsif @active_battler.restriction == 2
  235.                                         target = $game_troop.random_target_enemy
  236.                                 else
  237.                                         index = @active_battler.current_action.target_index
  238.                                         target = $game_troop.smooth_target_enemy(index)
  239.                                 end
  240.                         end
  241.                         # 设置对像方的战斗者序列
  242.                         @target_battlers = [target]
  243.                         # 应用行动效果
  244.                         for target in @target_battlers
  245.                                 if @active_battler.is_a?(Game_Actor)
  246.                                         # 设置连击效果
  247.                                         if @active_battler.skill_learn?(53)
  248.                                                 if @active_battler.battler_name.split(/★/)[13].to_i()!=0
  249.                                                         if rand(100) < 55
  250.                                                                 @animation2_id = @active_battler.battler_name.split(/★/)[13].to_i()
  251.                                                                 @animation1_id = @active_battler.battler_name.split(/★/)[14].to_i()
  252.                                                                 target.lianji=(true)
  253.                                                         end
  254.                                                 end
  255.                                         elsif @active_battler.skill_learn?(52)
  256.                                                 if @active_battler.battler_name.split(/★/)[13].to_i()!=0
  257.                                                         if rand(100) < 25
  258.                                                                 @animation2_id = @active_battler.battler_name.split(/★/)[13].to_i()
  259.                                                                 @animation1_id = @active_battler.battler_name.split(/★/)[14].to_i()
  260.                                                                 target.lianji=(true)
  261.                                                         end
  262.                                                 end
  263.                                         end
  264.                                 end
  265.                                 target.attack_effect(@active_battler)
  266.                         end
  267.                         return
  268.                 end
  269.                 # 逃跑的情况下
  270.                 if @active_battler.is_a?(Game_Enemy) and
  271.                         @active_battler.current_action.basic == 2
  272.                         # 逃跑
  273.                         @active_battler.escape
  274.                         return
  275.                 end
  276.                 # 什么也不做的情况下
  277.                 if @active_battler.current_action.basic == 3
  278.                         # 清除强制行动对像的战斗者
  279.                         $game_temp.forcing_battler = nil
  280.                         # 移至步骤 1
  281.                         @phase4_step = 1
  282.                         return
  283.                 end
  284.         end
  285.         #--------------------------------------------------------------------------
  286.         # ● 设置物品或特技对像方的战斗者
  287.         #     scope : 特技或者是物品的范围
  288.         #--------------------------------------------------------------------------
  289.         def set_target_battlers(scope)
  290.                 # 行动方的战斗者是敌人的情况下
  291.                 if @active_battler.is_a?(Game_Enemy)
  292.                         # 效果范围分支
  293.                         case scope
  294.                         when 1  # 敌单体
  295.                                 index = @active_battler.current_action.target_index
  296.                                 @target_battlers.push($game_party.smooth_target_actor(index))
  297.                         when 2  # 敌全体
  298.                                 for actor in $game_party.actors
  299.                                         if actor.exist?
  300.                                                 @target_battlers.push(actor)
  301.                                         end
  302.                                 end
  303.                         when 3  # 我方单体
  304.                                 index = @active_battler.current_action.target_index
  305.                                 @target_battlers.push($game_troop.smooth_target_enemy(index))
  306.                         when 4  # 我方全体
  307.                                 for enemy in $game_troop.enemies
  308.                                         if enemy.exist?
  309.                                                 @target_battlers.push(enemy)
  310.                                         end
  311.                                 end
  312.                         when 5  # 我方单体 (HP 0)
  313.                                 index = @active_battler.current_action.target_index
  314.                                 enemy = $game_troop.enemies[index]
  315.                                 if enemy != nil and enemy.hp0?
  316.                                         @target_battlers.push(enemy)
  317.                                 end
  318.                         when 6  # 我方全体 (HP 0)
  319.                                 for enemy in $game_troop.enemies
  320.                                         if enemy != nil and enemy.hp0?
  321.                                                 @target_battlers.push(enemy)
  322.                                         end
  323.                                 end
  324.                         when 7  # 使用者
  325.                                 @target_battlers.push(@active_battler)
  326.                         end
  327.                 end
  328.                 # 行动方的战斗者是角色的情况下
  329.                 if @active_battler.is_a?(Game_Actor)
  330.                         # 效果范围分支
  331.                         case scope
  332.                         when 1  # 敌单体
  333.                                 index = @active_battler.current_action.target_index
  334.                                 @target_battlers.push($game_troop.smooth_target_enemy(index))
  335.                         when 2  # 敌全体
  336.                                 for enemy in $game_troop.enemies
  337.                                         if enemy.exist?
  338.                                                 @target_battlers.push(enemy)
  339.                                         end
  340.                                 end
  341.                         when 3  # 我方单体
  342.                                 index = @active_battler.current_action.target_index
  343.                                 @target_battlers.push($game_party.smooth_target_actor(index))
  344.                         when 4  # 我方全体
  345.                                 for actor in $game_party.actors
  346.                                         if actor.exist?
  347.                                                 @target_battlers.push(actor)
  348.                                         end
  349.                                 end
  350.                         when 5  # 我方单体 (HP 0)
  351.                                 index = @active_battler.current_action.target_index
  352.                                 actor = $game_party.actors[index]
  353.                                 # 不允许复活的状态(死亡召唤)
  354.                                 if actor != nil and actor.hp0? and actor.id < 20
  355.                                         @target_battlers.push(actor)
  356.                                 end
  357.                         when 6  # 我方全体 (HP 0)
  358.                                 for actor in $game_party.actors
  359.                                         if actor != nil and actor.hp0? and actor.id < 20
  360.                                                 @target_battlers.push(actor)
  361.                                         end
  362.                                 end
  363.                         when 7  # 使用者
  364.                                 @target_battlers.push(@active_battler)
  365.                                 p @target_battlers
  366.                         end
  367.                 end
  368.         end
  369.         #--------------------------------------------------------------------------
  370.         # ● 生成特技行动结果
  371.         #--------------------------------------------------------------------------
  372.         def make_skill_action_result
  373.                 # 获取特技
  374.                 @skill = $data_skills[@active_battler.current_action.skill_id]
  375.                 # 设置对像战斗者
  376.                 set_target_battlers(@skill.scope)
  377.                 # 如果不是强制行动
  378.                 unless @active_battler.current_action.forcing
  379.                         # 因为 SP 耗尽而无法使用的情况下
  380.                         unless @active_battler.skill_can_use?(@skill.id)
  381.                                 # 清除强制行动对像的战斗者
  382.                                 $game_temp.forcing_battler = nil
  383.                                 # 移至步骤 1
  384.                                 @phase4_step = 1
  385.                                 return
  386.                         end
  387.                         if @active_battler.sp < @skill.sp_cost * @target_battlers.size
  388.                                 # 清除强制行动对像的战斗者
  389.                                 $game_temp.forcing_battler = nil
  390.                                 # 移至步骤 1
  391.                                 @phase4_step = 1
  392.                                 return
  393.                         end
  394.                 end
  395.                 # 消耗 SP
  396.                 @active_battler.sp -= @skill.sp_cost * @target_battlers.size
  397.                 # 在帮助窗口显示特技名
  398.                 if @skill.id == 9
  399.                         @help_window.y = 30
  400.                         @help_window.set_text(@active_battler.name + "使用技能" + @skill.name, 1)
  401.                 else
  402.                         @help_window.y = 30
  403.                         @help_window.set_text(@active_battler.name + "使用法术" + @skill.name, 1)
  404.                 end
  405.                 # 设置动画 ID
  406.                 # 使用方的动画 ID。
  407.                 @animation1_id = @skill.animation1_id
  408.                 # 对象方的动画 ID。
  409.                 @animation2_id = @skill.animation2_id
  410.                 if @skill.name == "破血狂攻"
  411.                         @animation1_id = @active_battler.battler_name.split(/★/)[14].to_i()
  412.                         @animation2_id = @active_battler.battler_name.split(/★/)[13].to_i()
  413.                 end
  414.                 if @skill.name == "横扫千军"
  415.                         @animation1_id = @active_battler.battler_name.split(/★/)[16].to_i()
  416.                         @animation2_id = @active_battler.battler_name.split(/★/)[15].to_i()
  417.                 end
  418.                 #if @skill.name == "破血狂攻"
  419.                 #        @animation1_id = @active_battler.battler_name.split(/★/)[14].to_i()
  420.                 #        @animation2_id = @active_battler.battler_name.split(/★/)[13].to_i()
  421.                 #end
  422.                 if @skill.name == "壁垒击破"
  423.                         @animation1_id = @active_battler.battler_name.split(/★/)[12].to_i()
  424.                         @animation2_id = @active_battler.battler_name.split(/★/)[11].to_i()
  425.                 end
  426.                 if @animation1_id == 0
  427.                         @animation1_id = @active_battler.battler_name.split(/★/)[8].to_i()
  428.                 end
  429.                 # 设置公共事件 ID
  430.                 @common_event_id = @skill.common_event_id
  431.                 # 应用特技效果
  432.                 for target in @target_battlers
  433.                         # 检测法术名字是否为善恶有报
  434.                         if @skill.name == "善恶有报"
  435.                                 if rand(100) < 30
  436.                                         @animation1_id += 2
  437.                                         @animation2_id += 2
  438.                                         target.shanbao=(true)
  439.                                 end
  440.                         elsif @skill.name == "善恶不报"
  441.                                 if rand(100) < 30
  442.                                         target.shanbao=(true)
  443.                                 end
  444.                         end
  445.                         target.skill_effect(@active_battler, @skill)
  446.                 end
  447.                 @C = false #使用者动画是否连续播放开关
  448.                 @C2 = false #受击者动画是否连续播放开关
  449.                 # 这里设定带有连续播放攻击动画效果的特技所带有的属性,默认为17号。
  450.                 if @skill.element_set.include?(17)
  451.                         for i in 0..(@CA.size-1)
  452.                                 c = @CA[i]
  453.                                 if @skill.id == c[0]
  454.                                         @anime = []
  455.                                         for c_1 in c[1]
  456.                                                 @anime.push(c_1)
  457.                                         end
  458.                                         @C = true
  459.                                         @acount = 0
  460.                                         # 检测是否含有默认攻击的动画
  461.                                         for g in [email protected] - 1
  462.                                                 if @anime[g] == 9999
  463.                                                         @anime[g] = @active_battler.battler_name.split(/★/)[12].to_i()
  464.                                                 end
  465.                                         end
  466.                                 end
  467.                         end
  468.                 end
  469.                 if @skill.element_set.include?(18)
  470.                         for i in 0..(@CA2.size-1)
  471.                                 c2=@CA2[i]
  472.                                 if @skill.id == c2[0]
  473.                                         @anime2 = []
  474.                                         @C2 = true
  475.                                         @acount2 = 0
  476.                                         for c_2 in c2[1]
  477.                                                 @anime2.push(c_2)
  478.                                         end
  479.                                         for g in [email protected] - 1
  480.                                                 if @anime2[g] == 9999
  481.                                                         @anime2[g] = @active_battler.battler_name.split(/★/)[9].to_i()
  482.                                                 end
  483.                                         end
  484.                                         return
  485.                                 end
  486.                         end
  487.                 end
  488.         end
  489.         #--------------------------------------------------------------------------
  490.         # ● 生成物品行动结果
  491.         #--------------------------------------------------------------------------
  492.         def make_item_action_result
  493.                 # 获取物品
  494.                 @item = $data_items[@active_battler.current_action.item_id]
  495.                 # 因为物品耗尽而无法使用的情况下
  496.                 unless $game_party.item_can_use?(@item.id)
  497.                         # 移至步骤 1
  498.                         @phase4_step = 1
  499.                         return
  500.                 end
  501.                 # 消耗品的情况下
  502.                 if @item.consumable
  503.                         # 使用的物品减 1
  504.                         $game_party.lose_item(@item.id, 1)
  505.                 end
  506.                 # 在帮助窗口显示物品名
  507.                 @help_window.set_text(@item.name, 1)
  508.                 # 设置角色使用物品时动画
  509.                 # 设置动画 ID
  510.                 @animation1_id = @item.animation1_id
  511.                 @animation2_id = @item.animation2_id
  512.                 if @animation1_id == 0
  513.                         @animation1_id = @active_battler.battler_name.split(/★/)[8].to_i()
  514.                 end
  515.                 # 设置公共事件 ID
  516.                 @common_event_id = @item.common_event_id
  517.                 # 确定对像
  518.                 index = @active_battler.current_action.target_index
  519.                 target = $game_party.smooth_target_actor(index)
  520.                 # 设置对像战斗者
  521.                 set_target_battlers(@item.scope)
  522.                 # 应用物品效果
  523.                 for target in @target_battlers
  524.                         target.item_effect(@item)
  525.                 end
  526.         end
  527.         #--------------------------------------------------------------------------
  528.         # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  529.         #--------------------------------------------------------------------------
  530.         def update_phase4_step3
  531.                 if @C == true && @C2 == true
  532.                         # 行动方
  533.                         if @anime[@acount] == 0
  534.                                 @active_battler.white_flash = true
  535.                         else
  536.                                 if @acount == 0 && @anime[@acount] != @active_battler.battler_name.split(/★/)[10].to_i()
  537.                                         @active_battler.animation_id = @animation1_id
  538.                                 else
  539.                                         @active_battler.animation_id = @anime[@acount]
  540.                                 end
  541.                                 @active_battler.animation_hit = true
  542.                         end
  543.                         @acount += 1
  544.                         if @acount == @anime.size
  545.                                 @C = false
  546.                         end
  547.                         # 对像方动画
  548.                         for target in @target_battlers
  549.                                 target.animation_id = @anime2[@acount2]
  550.                                 target.animation_hit = (target.damage != "Miss")
  551.                         end
  552.                         @acount2 += 1
  553.                         if @acount2 == @anime2.size
  554.                                 @C2 = false
  555.                         end
  556.                 elsif @C == false && @C2 == true
  557.                         if @acount == nil
  558.                                 @acount = 0
  559.                                 # 行动方
  560.                                 @active_battler.animation_id = @animation1_id
  561.                                 @active_battler.animation_hit = true
  562.                                 # 对像方动画
  563.                                 for target in @target_battlers
  564.                                         target.animation_id = @anime2[@acount2]
  565.                                         target.animation_hit = (target.damage != "Miss")
  566.                                 end
  567.                                 @acount2 += 1
  568.                                 if @acount2 == @anime2.size
  569.                                         @C2 = false
  570.                                 end
  571.                         elsif @acount >= 0
  572.                                 # 对像方动画
  573.                                 for target in @target_battlers
  574.                                         target.animation_id = @anime2[@acount2]
  575.                                         target.animation_hit = (target.damage != "Miss")
  576.                                 end
  577.                                 @acount2 += 1
  578.                                 if @acount2 == @anime2.size
  579.                                         @C2 = false
  580.                                 end
  581.                         end
  582.                 elsif @C == true && @C2 == false && (@acount2 == nil)
  583.                         @acount2 = 0
  584.                         # 行动方
  585.                         if @anime[@acount] == 0
  586.                                 @active_battler.white_flash = true
  587.                         else
  588.                                 if @acount == 0 and @anime[@acount] != 9999
  589.                                         @active_battler.animation_id = @animation1_id
  590.                                 else
  591.                                         @active_battler.animation_id = @anime[@acount]
  592.                                 end
  593.                                 @active_battler.animation_hit = true
  594.                         end
  595.                         @acount += 1
  596.                         if @acount == @anime.size
  597.                                 @C = false
  598.                         end
  599.                         # 对像方动画
  600.                         for target in @target_battlers
  601.                                 target.animation_id = @animation2_id
  602.                                 target.animation_hit = (target.damage != "Miss")
  603.                         end
  604.                 elsif @C == true && @C2 == false && (@acount2>= 0)
  605.                         # 行动方
  606.                         if @anime[@acount] == 0
  607.                                 @active_battler.white_flash = true
  608.                         else
  609.                                 if @acount == 0
  610.                                         @active_battler.animation_id = @animation1_id
  611.                                 else
  612.                                         @active_battler.animation_id = @anime[@acount]
  613.                                 end
  614.                                 @active_battler.animation_hit = true
  615.                         end
  616.                         @acount += 1
  617.                         if @acount == @anime.size
  618.                                 @C = false
  619.                         end
  620.                 else
  621.                         # 行动方
  622.                         @active_battler.animation_id = @animation1_id
  623.                         @active_battler.animation_hit = true
  624.                         # 对像方动画
  625.                         for target in @target_battlers
  626.                                 target.animation_id = @animation2_id
  627.                                 target.animation_hit = (target.damage != "Miss")
  628.                         end
  629.                 end
  630.                 if @C != true and @C2 != true
  631.                         # 移至步骤 5
  632.                         @phase4_step = 5
  633.                 end
  634.         end
  635.         #--------------------------------------------------------------------------
  636.         # ● 刷新画面 (主回合步骤 4 : 对像方动画)
  637.         #--------------------------------------------------------------------------
  638.         def update_phase4_step4
  639.         end
  640.         #--------------------------------------------------------------------------
  641.         # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  642.         #--------------------------------------------------------------------------
  643.         def update_phase4_step5
  644.                 # 隐藏帮助窗口
  645.                 @help_window.visible = false
  646.                 # 显示伤害
  647.                 for target in @target_battlers
  648.                         if target.damage != nil
  649.                                 target.damage_pop = true
  650.                         end
  651.                 end
  652.                 if @active_battler.damage != nil
  653.                         @active_battler.damage_pop = true
  654.                 end
  655.                 # 移至步骤 6
  656.                 @phase4_step = 6
  657.         end
  658.         #--------------------------------------------------------------------------
  659.         # ● 刷新画面 (主回合步骤 6 : 刷新 23种战斗特效)
  660.         #--------------------------------------------------------------------------
  661.         def update_phase4_step6
  662.                 # 清除强制行动对像的战斗者
  663.                 $game_temp.forcing_battler = nil
  664.                 @C = nil
  665.                 @C2 = nil
  666.                 RPG::Cache.clear
  667.                 # 移至步骤 1
  668.                 @phase4_step = 1
  669.         end
  670. end
复制代码

Lv5.捕梦者 (版主)

梦石
1
星屑
23963
在线时间
3338 小时
注册时间
2011-7-8
帖子
3925

开拓者

2
发表于 2021-8-29 14:51:08 | 只看该作者
鞭尸也是一种乐趣,而且你这里发的不是全动画脚本吧?感觉都是具体技能的设置
熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2054
在线时间
540 小时
注册时间
2012-5-3
帖子
86

开拓者

3
 楼主| 发表于 2021-8-29 14:58:29 | 只看该作者
guoxiaomi 发表于 2021-8-29 14:51
鞭尸也是一种乐趣,而且你这里发的不是全动画脚本吧?感觉都是具体技能的设置 ...

大佬也来拉,全动画脚本在这里,刚刚没有发完全。大佬能否帮我看看?
RUBY 代码复制
  1. #==============================================================================
  2. # ■ 全动画战斗系统(修改加强再加强版)
  3. #------------------------------------------------------------------------------
  4. #  By whbm
  5. #   应用脚本 彩虹神剑 By 66
  6. #   v1.0 by liulu 添加了23种战斗特技,另外有一部分在单技能连击脚本中
  7. #==============================================================================
  8. $fangyu = 0
  9. # 叮当猫的全动画脚本
  10. module RPG
  11.         class Sprite < ::Sprite
  12.                 @@_animations = []
  13.                 @@_reference_count = {}
  14.                 #---------------------------------------------------------------------------
  15.                 # 释放
  16.                 #---------------------------------------------------------------------------
  17.                 def dispose
  18.                         dispose_damage
  19.                         dispose_animation
  20.                         dispose_loop_animation
  21.                         dispose_loop_animation1
  22.                         super
  23.                 end
  24.                 #---------------------------------------------------------------------------
  25.                 # 设置循环动画1
  26.                 #---------------------------------------------------------------------------
  27.                 def loop_animation1(animation)
  28.                         #如果动画重复跳出
  29.                         return if animation == @_loop_animation1
  30.                         #释放动画资源
  31.                         dispose_loop_animation1
  32.                         #动画变更
  33.                         @_loop_animation1 = animation
  34.                         #如果动画还为空跳出
  35.                         return if @_loop_animation1 == nil or @_loop_animation1 == []
  36.                         #精灵动画组清空
  37.                         @_loop_animation1_sprites_array = []
  38.                         #动画索引为0
  39.                         @_loop_animation1_index = []
  40.                         #状态动画深度
  41.                         tm_viewport = Viewport.new(0, 0, 640, 480)
  42.                         for temp_animation in @_loop_animation1
  43.                                 #动画索引为0
  44.                                 @_loop_animation1_index.push(0)
  45.                                 #动画名
  46.                                 animation_name = temp_animation.animation_name
  47.                                 #动画色调
  48.                                 animation_hue = temp_animation.animation_hue
  49.                                 #从高速缓存中取得动画图像
  50.                                 bitmap = RPG::Cache.animation(animation_name, animation_hue)
  51.                                 #如果此动画被计数过则自加1,否则初始化1
  52.                                 if @@_reference_count.include?(bitmap)
  53.                                         @@_reference_count[bitmap] += 1
  54.                                 else
  55.                                         @@_reference_count[bitmap] = 1
  56.                                 end
  57.                                 #清空动画1精灵组
  58.                                 @_loop_animation1_sprites = []
  59.                                 #push 15次
  60.                                 for i in 0..15
  61.                                         #状态动画深度深入判断
  62.                                         if temp_animation.name.split(/,/)[1] == "z"
  63.                                                 sprite = ::Sprite.new(self.viewport)
  64.                                                 sprite.bitmap = bitmap
  65.                                                 sprite.visible = false
  66.                                                 @_loop_animation1_sprites.push(sprite)
  67.                                         else
  68.                                                 sprite = ::Sprite.new(self.viewport)
  69.                                                 sprite.bitmap = bitmap
  70.                                                 sprite.visible = false
  71.                                                 @_loop_animation1_sprites.push(sprite)
  72.                                         end
  73.                                 end
  74.                                 @_loop_animation1_sprites_array.push(@_loop_animation1_sprites)
  75.                         end
  76.                         update_loop_animation1
  77.                 end
  78.                 #--------------------------------------------------------------------------
  79.                 # ● 释放循环动画1
  80.                 #--------------------------------------------------------------------------
  81.                 def dispose_loop_animation1
  82.                         #如果精灵组的动画组不为空
  83.                         if @_loop_animation1_sprites_array != nil
  84.                                 #循环遍历精灵组的动画组
  85.                                 for loop_animation1_sprites in @_loop_animation1_sprites_array
  86.                                         #如果精灵组不为空
  87.                                         if loop_animation1_sprites != nil
  88.                                                 #获得第一个精灵
  89.                                                 sprite = loop_animation1_sprites[0]
  90.                                                 #第一个精灵不为空的情况下
  91.                                                 if sprite != nil
  92.                                                         @@_reference_count[sprite.bitmap] -= 1
  93.                                                         if @@_reference_count[sprite.bitmap] <= 0
  94.                                                                 sprite.bitmap.dispose
  95.                                                         end
  96.                                                 end
  97.                                                 #遍历精灵组释放资源
  98.                                                 for sprite in loop_animation1_sprites
  99.                                                         sprite.dispose
  100.                                                 end
  101.                                                 #将当前精灵组清空
  102.                                                 loop_animation1_sprites = nil
  103.                                         end
  104.                                 end
  105.                                 #将精灵组的动画组清空
  106.                                 @_loop_animation1_sprites_array = nil
  107.                                 #清空动画组
  108.                                 @_loop_animation1 = nil
  109.                         end
  110.                 end
  111.                 #---------------------------------------------------------------------------
  112.                 # ● 闪烁
  113.                 #---------------------------------------------------------------------------
  114.                 def animation_process_timing(timing, hit)
  115.                         #判断闪烁条件
  116.                         if (timing.condition == 0) or
  117.                                 (timing.condition == 1 and hit == true) or
  118.                                 (timing.condition == 2 and hit == false)
  119.                                 if timing.se.name != ""
  120.                                         se = timing.se
  121.                                         Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  122.                                 end
  123.                                 case timing.flash_scope
  124.                                 when 1
  125.                                         self.flash(timing.flash_color, timing.flash_duration * 2)
  126.                                 when 2
  127.                                         if self.viewport != nil
  128.                                                 self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  129.                                         end
  130.                                 when 3
  131.                                         self.flash(nil, timing.flash_duration * 2)
  132.                                 end
  133.                         end
  134.                 end
  135.                 #---------------------------------------------------------------------------
  136.                 # ● 更新循环动画1
  137.                 #---------------------------------------------------------------------------
  138.                 def update_loop_animation1
  139.                         for index in 0..@_loop_animation1.size - 1
  140.                                 #帧索引赋值
  141.                                 frame_index = @_loop_animation1_index[index]
  142.                                 #动画当前帧的式样(大小,透明,旋转,等等)
  143.                                 cell_data = @_loop_animation1[index].frames[frame_index].cell_data
  144.                                 #动画相对于屏幕的位置(上,中,下,画面)
  145.                                 position = @_loop_animation1[index].position
  146.                                 #·改·
  147.                                 if @wait_count.to_i <= 0
  148.                                         @wait_count = 0
  149.                                         animation_set_sprites(@_loop_animation1_sprites_array[index], cell_data, position)
  150.                                 else
  151.                                         for sprite in @_loop_animation1_sprites_array[index]
  152.                                                 sprite.visible = false
  153.                                         end
  154.                                 end
  155.                                 if @wait_flash.to_i <= 0
  156.                                         @wait_flash = 0
  157.                                 else
  158.                                         @wait_flash -= 1
  159.                                         for sprite in @_loop_animation1_sprites_array[index]
  160.                                                 sprite.blend_type = 1
  161.                                         end
  162.                                 end
  163.                                 #循环判断动画闪烁
  164.                                 for timing in @_loop_animation1[index].timings
  165.                                         if timing.frame == frame_index
  166.                                                 #闪烁
  167.                                                 animation_process_timing(timing, true)
  168.                                         end
  169.                                 end
  170.                         end
  171.                 end
  172.         end
  173. end
  174. # 新加部分
  175. class Spriteset_Battle
  176.         #--------------------------------------------------------------------------
  177.         # ● 初始化变量
  178.         #--------------------------------------------------------------------------
  179.         def initialize
  180.                 # 生成显示端口
  181.                 @viewport1 = Viewport.new(0, 0, 640, 480)
  182.                 @viewport2 = Viewport.new(0, 0, 640, 480)
  183.                 @viewport3 = Viewport.new(0, 0, 640, 480)
  184.                 @viewport2.z = 5000
  185.                 @viewport3.z = 200
  186.                 # 生成战斗背景活动块
  187.                 @battleback_sprite = Sprite.new(@viewport1)
  188.                 # 生成敌人活动块
  189.                 @enemy_sprites = []
  190.                 for enemy in $game_troop.enemies.reverse
  191.                         @enemy_sprites.push(Sprite_Battler.new(@viewport2, enemy))
  192.                 end
  193.                 # 生成角色活动块
  194.                 @actor_sprites = []
  195.                 @actor_sprites.push(Sprite_Battler.new(@viewport2))
  196.                 @actor_sprites.push(Sprite_Battler.new(@viewport2))
  197.                 @actor_sprites.push(Sprite_Battler.new(@viewport2))
  198.                 @actor_sprites.push(Sprite_Battler.new(@viewport2))
  199.                 #第5-10个角色
  200.                 @actor_sprites.push(Sprite_Battler.new(@viewport2))
  201.                 @actor_sprites.push(Sprite_Battler.new(@viewport2))
  202.                 @actor_sprites.push(Sprite_Battler.new(@viewport2))
  203.                 @actor_sprites.push(Sprite_Battler.new(@viewport2))
  204.                 @actor_sprites.push(Sprite_Battler.new(@viewport2))
  205.                 @actor_sprites.push(Sprite_Battler.new(@viewport2))
  206.                 # 生成图片活动块
  207.                 @picture_sprites = []
  208.                 for i in 51..53
  209.                         @picture_sprites.push(Sprite_Picture.new(@viewport3,
  210.                                         $game_screen.pictures[i]))
  211.                 end
  212.                 # 刷新画面
  213.                 update
  214.         end
  215.         #--------------------------------------------------------------------------
  216.         # ● 胜利图
  217.         #--------------------------------------------------------------------------
  218.         def win
  219.                 for sprite in @actor_sprites
  220.                         sprite.win
  221.                 end
  222.         end
  223.         #--------------------------------------------------------------------------
  224.         # ● 刷新画面
  225.         #--------------------------------------------------------------------------
  226.         def update
  227.                 # 刷新角色的活动块 (对应角色的替换)
  228.                 @actor_sprites[0].battler = $game_party.actors[0]
  229.                 @actor_sprites[1].battler = $game_party.actors[1]
  230.                 @actor_sprites[2].battler = $game_party.actors[2]
  231.                 @actor_sprites[3].battler = $game_party.actors[3]
  232.                 @actor_sprites[4].battler = $game_party.actors[4]
  233.                 @actor_sprites[5].battler = $game_party.actors[5]
  234.                 @actor_sprites[6].battler = $game_party.actors[6]
  235.                 @actor_sprites[7].battler = $game_party.actors[7]
  236.                 @actor_sprites[8].battler = $game_party.actors[8]
  237.                 @actor_sprites[9].battler = $game_party.actors[9]
  238.                 # 战斗背景的文件名与现在情况有差异的情况下
  239.                 if @battleback_name != $game_temp.battleback_name
  240.                         @battleback_name = $game_temp.battleback_name
  241.                         if @battleback_sprite.bitmap != nil
  242.                                 @battleback_sprite.bitmap.dispose
  243.                         end
  244.                         @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  245.                         @battleback_sprite.src_rect.set(0, 0, 640, 480)
  246.                 end
  247.                 # 刷新战斗者的活动块
  248.                 for sprite in @enemy_sprites + @actor_sprites
  249.                         sprite.update
  250.                 end
  251.                 # 刷新图片活动块
  252.                 for sprite in @picture_sprites
  253.                         sprite.update
  254.                 end
  255.                 # 设置画面的色调与震动位置
  256.                 @viewport1.tone = $game_screen.tone
  257.                 @viewport1.ox = $game_screen.shake
  258.                 # 刷新显示端口
  259.                 @viewport1.update
  260.                 @viewport2.update
  261.         end
  262. end
  263. class Game_Battler
  264.         #--------------------------------------------------------------------------
  265.         # ● 定义实例变量
  266.         #--------------------------------------------------------------------------
  267.         attr_reader   :last_hp                  # 受效前的HP
  268.         #--------------------------------------------------------------------------
  269.         # ● 设置显示伤害
  270.         #--------------------------------------------------------------------------  
  271.         def show_damage(value)
  272.                 @show_damage_value = value
  273.         end
  274.         #--------------------------------------------------------------------------
  275.         # ● 显示伤害
  276.         #--------------------------------------------------------------------------
  277.         def show_damage_value
  278.                 return @show_damage_value
  279.         end
  280.         #--------------------------------------------------------------------------
  281.         # ● 获取循环的动画 ID
  282.         #--------------------------------------------------------------------------
  283.         def battler_ani
  284.                 return @battler_ani
  285.         end
  286.         #--------------------------------------------------------------------------
  287.         # ● 获取循环的动画 ID
  288.         #--------------------------------------------------------------------------
  289.         def setup_battler_ani(battler_ani, once = 0)
  290.                 @battler_ani = battler_ani
  291.                 @once = once
  292.         end
  293.         #--------------------------------------------------------------------------
  294.         # ● 获取循环的动画 ID
  295.         #--------------------------------------------------------------------------
  296.         def setup_battler_hurt_ani(hurt)
  297.                 @hurt = hurt
  298.         end  
  299.         #--------------------------------------------------------------------------
  300.         # ● 获取循环的动画 ID
  301.         #--------------------------------------------------------------------------
  302.         def setup_battler_dead_ani(over)
  303.                 @over = over
  304.         end
  305.         #--------------------------------------------------------------------------
  306.         # ● 获取循环的动画 ID
  307.         #--------------------------------------------------------------------------
  308.         def battler_dead_ani
  309.                 return @over
  310.         end
  311.         #--------------------------------------------------------------------------
  312.         # ● 获取循环的动画 ID
  313.         #--------------------------------------------------------------------------
  314.         def battler_ani_once
  315.                 return @once
  316.         end
  317.         #--------------------------------------------------------------------------
  318.         # ● 获取循环的动画 ID
  319.         #--------------------------------------------------------------------------
  320.         def battler_hurt_ani
  321.                 return @hurt
  322.         end
  323. end
  324. module RPG
  325.         #--------------------------------------------------------------------------
  326.         # ● 常量设定
  327.         #--------------------------------------------------------------------------
  328.         # 是否显示总伤害
  329.         SHOW_TOTAL_DAMAGE = false
  330.         # 角色受攻击时是否跳一下
  331.         BATTLER_JUMP = false
  332.         # 伤害美化字符串文件夹名(放在Pictures文件夹中的子文件夹)
  333.         #STRING_DOCUMENTS = ""
  334.         # 是否使用伤害美化效果
  335.         USE_DAMAGE = true
  336.         class Sprite < ::Sprite
  337.                 # 修改说明:
  338.                 # @flash_shake用来制作挨打时候跳跃
  339.                 # @_damage    用来记录每次打击之后弹出数字
  340.                 # @_total_damage 记录总伤害
  341.                 # @_total_damage_duration 总伤害持续帧
  342.                 #---------------------------------------------------------------------------
  343.                 # ● 初始化
  344.                 #---------------------------------------------------------------------------
  345.                 def initialize(viewport = nil)
  346.                         super(viewport)
  347.                         @_whiten_duration = 0
  348.                         @_appear_duration = 0
  349.                         @_escape_duration = 0
  350.                         @_collapse_duration = 0
  351.                         @_damage_duration = 0
  352.                         @_animation_duration = 0
  353.                         @_blink = false
  354.                         # 挨打时候跳跃
  355.                         @flash_shake = 0
  356.                         # 伤害记录数组
  357.                         @_damage = []
  358.                         # 总伤害数字
  359.                         @_total_damage = 0
  360.                         # 总伤害持续帧
  361.                         @_total_damage_duration = 0
  362.                         #记录已经发生的伤害的变量
  363.                         @p_dam=0
  364.                         @hits=0
  365.                         #记录前一次攻击次数
  366.                         @temp_hits=0
  367.                         #判断是否为最后一次攻击
  368.                         @last_hits=0
  369.                 end
  370.                 #---------------------------------------------------------------------------
  371.                 # ● 设置动画精灵
  372.                 #---------------------------------------------------------------------------
  373.                 def animation_set_sprites(sprites, cell_data, position)
  374.                         for i in 0..15
  375.                                 sprite = sprites[i]
  376.                                 pattern = cell_data[i, 0]
  377.                                 if sprite == nil or pattern == nil or pattern == -1
  378.                                         sprite.visible = false if sprite != nil
  379.                                         next
  380.                                 end
  381.                                 sprite.visible = true
  382.                                 sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  383.                                 if position == 3
  384.                                         if self.viewport != nil
  385.                                                 sprite.x = self.viewport.rect.width / 2
  386.                                                 sprite.y = self.viewport.rect.height - 160
  387.                                         else
  388.                                                 sprite.x = 320
  389.                                                 sprite.y = 240
  390.                                         end
  391.                                 else
  392.                                         sprite.x = self.x - self.ox + self.src_rect.width / 2
  393.                                         sprite.y = self.y - self.oy + self.src_rect.height / 2
  394.                                         sprite.y -= self.src_rect.height / 4 if position == 0
  395.                                         sprite.y += self.src_rect.height / 4 if position == 2
  396.                                 end
  397.                                 sprite.x += cell_data[i, 1]
  398.                                 sprite.y += cell_data[i, 2]
  399.                                 sprite.z =1
  400.                                 sprite.ox = 96
  401.                                 sprite.oy = 96
  402.                                 sprite.zoom_x = cell_data[i, 3] / 100.0
  403.                                 sprite.zoom_y = cell_data[i, 3] / 100.0
  404.                                 sprite.angle = cell_data[i, 4]
  405.                                 sprite.mirror = (cell_data[i, 5] == 1)
  406.                                 sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  407.                                 sprite.blend_type = cell_data[i, 7]
  408.                         end
  409.                 end
  410.                 #--------------------------------------------------------------------------
  411.                 # ● 美化的伤害处理
  412.                 #--------------------------------------------------------------------------
  413.                 def damage(value, critical)
  414.                         if USE_DAMAGE == true then
  415.                                 # 释放伤害,效果是伤害数字快速消失,觉得不如不消失好看
  416.                                 # 清除hit数
  417.                                 dispose_hit
  418.                                 # 如果伤害值是数值
  419.                                 if value.is_a?(Numeric)
  420.                                         # 绝对值转为字符串
  421.                                         damage_string = value.to_i.abs.to_s
  422.                                 else
  423.                                         # 转为字符串
  424.                                         damage_string = value.to_s
  425.                                 end
  426.                                 # 初始化位图
  427.                                 bitmap = Bitmap.new(162, 64)
  428.                                 bitmap.font.name = ["华文行楷","黑体", "宋体","宋体"]
  429.                                 bitmap.font.size = 32
  430.                                 # 伤害值是数值的情况下
  431.                                 if value.is_a?(Numeric)
  432.                                         # 分割伤害值字符串
  433.                                         damage_array = damage_string.scan(/./)
  434.                                         damage_x = 81 - damage_string.size * 9
  435.                                         # 伤害值为负的情况下
  436.                                         if value < 0
  437.                                                 # 调用回复数字表
  438.                                                 rect_y = 15
  439.                                         else
  440.                                                 # 调用伤害数字表
  441.                                                 rect_y = 0
  442.                                         end
  443.                                         # 循环伤害值字符串
  444.                                         for char in damage_array
  445.                                                 number = char.to_i
  446.                                                 # 显示伤害数字
  447.                                                 bitmap.blt(damage_x, 32, RPG::Cache.picture( "Damage"),
  448.                                                         Rect.new(number * 14, rect_y, 15, 15))
  449.                                                 #Rect.new(number * 18, rect_y, 18, 32))
  450.                                                 # 后移一位
  451.                                                 damage_x += 15
  452.                                                 #damage_x += 18
  453.                                         end
  454.                                         # 伤害值不是数值的情况
  455.                                 else
  456.                                         # 如果伤害值不是 Miss
  457.                                         unless value == "Miss"
  458.                                                 # 系统默认描画字符串
  459.                                                 bitmap.font.color.set(0, 0, 0)
  460.                                                 bitmap.draw_text(-1, 27, 162, 36, damage_string, 1)
  461.                                                 bitmap.draw_text(+1, 27, 162, 36, damage_string, 1)
  462.                                                 bitmap.draw_text(-1, 29, 162, 36, damage_string, 1)
  463.                                                 bitmap.draw_text(+1, 29, 162, 36, damage_string, 1)
  464.                                                 bitmap.font.color.set(255, 255, 255)
  465.                                                 bitmap.draw_text(0, 28, 162, 36, damage_string, 1)
  466.                                                 # Miss 的情况下
  467.                                         else
  468.                                                 # 显示未击中图画
  469.                                                 bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(71, 30, 71, 32))
  470.                                                 #bitmap.blt(36, 28, RPG::Cache.picture("damage-1"), Rect.new(90, 64, 90, 32))
  471.                                         end
  472.                                 end
  473.                                 # 会心一击标志打开的情况
  474.                                 if critical
  475.                                         # 显示会心一击图画
  476.                                         bitmap.blt(36, 0, RPG::Cache.picture( "Damage"), Rect.new(0, 30, 71, 32))
  477.                                         #bitmap.blt(36, 0, RPG::Cache.picture( "damage"), Rect.new(0, 64, 90, 32))
  478.                                 end
  479.                         end
  480.                         # 结束USE_DAMAGE == true
  481.                         # 伤害值定位
  482.                         @_damage_sprite = ::Sprite.new(self.viewport)
  483.                         @_damage_sprite.bitmap = bitmap
  484.                         @_damage_sprite.ox = 80
  485.                         @_damage_sprite.oy = 20
  486.                         @_damage_sprite.x = self.x
  487.                         @_damage_sprite.y = self.y - self.oy / 2
  488.                         @_damage_sprite.z = 3000
  489.                         @_damage_duration = 40
  490.                         # 修改:推入新的伤害
  491.                         @_damage.push([@_damage_sprite,@_damage_duration - 10,0, rand(30) - 15, rand(3)])
  492.                         # 总伤害处理
  493.                         make_total_damage(value)
  494.                 end
  495.                 #--------------------------------------------------------------------------
  496.                 # ● 返回 @hits
  497.                 #--------------------------------------------------------------------------
  498.                 def get_hit
  499.                         return @hits
  500.                 end
  501.                 #--------------------------------------------------------------------------
  502.                 # ● hit数的美化描绘
  503.                 #--------------------------------------------------------------------------
  504.                 def hit
  505.                         # 如果伤害值是数值
  506.                         # 转为字符串
  507.                         value = @hits
  508.                         hits_string = value.to_s
  509.                         # 初始化位图
  510.                         bitmap = Bitmap.new(320, 64)
  511.                         bitmap.font.name = "Arial Black"
  512.                         bitmap.font.size = 32
  513.                         # 分割伤害值字符串
  514.                         hits_array = hits_string.scan(/./)
  515.                         hits_x = - 36.2
  516.                         rect_y = 0
  517.                         # 循环伤害值字符串
  518.                         for char in hits_array
  519.                                 # 后移一位
  520.                                 hits_x += 36.2
  521.                                 number = char.to_i
  522.                                 # 显示伤害数字
  523.                                 bitmap.blt(hits_x, 0, RPG::Cache.picture("Number"),
  524.                                         Rect.new(number * 36.2, rect_y, 36.2, 50))
  525.                         end
  526.                         hits_x += 18.1
  527.                         bitmap.blt(hits_x, 0, RPG::Cache.picture("HITS"),
  528.                                 Rect.new(0, -21, 90, 50))
  529.                         # 伤害值定位
  530.                         @_hits_sprite = ::Sprite.new(self.viewport)
  531.                         @_hits_sprite.bitmap = bitmap
  532.                         @_hits_sprite.x = 560 - hits_string.size * 36.2
  533.                         @_hits_sprite.y = 70
  534.                         @_hits_sprite.z = 3000
  535.                         @_hits_duration = 40
  536.                 end
  537.                 #--------------------------------------------------------------------------
  538.                 # ● 美化的总伤害处理
  539.                 #--------------------------------------------------------------------------
  540.                 def make_total_damage(value)
  541.                         if USE_DAMAGE == true then
  542.                                 if value.is_a?(Numeric)
  543.                                         @_total_damage += value
  544.                                         # 绝对值转为字符串
  545.                                         damage_string = @_total_damage.abs.to_s
  546.                                 else
  547.                                         return
  548.                                 end
  549.                                 if SHOW_TOTAL_DAMAGE
  550.                                         # 初始化位图
  551.                                         bitmap = Bitmap.new(300, 150)
  552.                                         bitmap.font.name = "Arial Black"
  553.                                         bitmap.font.size = 30
  554.                                         # 伤害值是数值的情况下
  555.                                         if value.is_a?(Numeric)
  556.                                                 # 分割伤害值字符串
  557.                                                 damage_array = damage_string.scan(/./)
  558.                                                 damage_x = 40 - damage_string.size * 9
  559.                                                 # 伤害值为负的情况下
  560.                                                 if value < 0
  561.                                                         # 调用回复数字表
  562.                                                         name=  "Number3"
  563.                                                 else
  564.                                                         # 调用伤害数字表
  565.                                                         name=   "Number2"
  566.                                                 end
  567.                                                 # 循环伤害值字符串
  568.                                                 for char in damage_array
  569.                                                         number = char.to_i
  570.                                                         # 显示伤害数字
  571.                                                         bitmap.blt(damage_x, 0, RPG::Cache.picture(name),
  572.                                                                 Rect.new(number * 30, 0, 30, 50))
  573.                                                         # 后移一位
  574.                                                         damage_x += 26
  575.                                                 end
  576.                                         end
  577.                                 end
  578.                         else
  579.                                 if value.is_a?(Numeric)
  580.                                         @_total_damage += value
  581.                                 else
  582.                                         return
  583.                                 end
  584.                                 if SHOW_TOTAL_DAMAGE
  585.                                         bitmap = Bitmap.new(300, 150)
  586.                                         bitmap.font.name = "Arial Black"
  587.                                         bitmap.font.size = 48
  588.                                         bitmap.font.color.set(0, 0, 0)
  589.                                         bitmap.draw_text(+2, 12+2, 160, 36, @_total_damage.abs.to_s, 1)
  590.                                         if @_total_damage < 0
  591.                                                 bitmap.font.color.set(80, 255, 00)
  592.                                         else
  593.                                                 bitmap.font.color.set(255, 140, 0)
  594.                                         end
  595.                                         bitmap.draw_text(0, 12, 160, 36, @_total_damage.abs.to_s, 1)
  596.                                 end
  597.                         end
  598.                         if @_total_damage_sprite.nil?
  599.                                 @_total_damage_sprite = ::Sprite.new
  600.                                 @_total_damage_sprite.ox = 80
  601.                                 @_total_damage_sprite.oy = 20
  602.                                 @_total_damage_sprite.z = 3000
  603.                         end
  604.                         @_total_damage_sprite.bitmap = bitmap
  605.                         @_total_damage_sprite.zoom_x = 1.5
  606.                         @_total_damage_sprite.zoom_y = 1.5
  607.                         @_total_damage_sprite.x = self.x
  608.                         @_total_damage_sprite.y = self.y  - self.oy / 2 - 64
  609.                         @_total_damage_sprite.z = 3001
  610.                         @_total_damage_duration = 40
  611.                         # hit数描绘
  612.                         @hits+=1
  613.                         hit
  614.                 end
  615.                 def animation(animation, hit, battler_damage="", battler_critical=false)
  616.                         dispose_animation      
  617.                         # 修改:记录伤害和critical
  618.                         @battler_damage = battler_damage
  619.                         @battler_critical = battler_critical
  620.                         @_animation = animation
  621.                         return if @_animation == nil
  622.                         @_animation_hit = hit
  623.                         @_animation_duration = @_animation.frame_max
  624.                         animation_name = @_animation.animation_name
  625.                         animation_hue = @_animation.animation_hue
  626.                         bitmap = RPG::Cache.animation(animation_name, animation_hue)
  627.                         # 修改:计算总闪光权限值
  628.                         for timing in @_animation.timings
  629.                                 quanzhong = animation_process_timing(timing, @_animation_hit,true)
  630.                                 @all_quanzhong += quanzhong
  631.                                 # 记录最后一次闪光
  632.                                 @_last_frame = timing.frame if quanzhong != 0
  633.                         end
  634.                         @last_frame = @_last_frame
  635.                         if @@_reference_count.include?(bitmap)
  636.                                 @@_reference_count[bitmap] += 1
  637.                         else
  638.                                 @@_reference_count[bitmap] = 1
  639.                         end
  640.                         # 修改行动方动画不显示伤害
  641.                         if $scene.is_a?(Scene_Battle)
  642.                                 if $scene.animation1_id == @battler.animation_id
  643.                                         @battler_damage = ""
  644.                                 end
  645.                         end
  646.                         @_animation_sprites = []
  647.                         if @_animation.position != 3 or not @@_animations.include?(animation)
  648.                                 for i in 0..15
  649.                                         sprite = ::Sprite.new(self.viewport)
  650.                                         sprite.bitmap = bitmap
  651.                                         sprite.visible = false
  652.                                         @_animation_sprites.push(sprite)
  653.                                 end
  654.                                 unless @@_animations.include?(animation)
  655.                                         @@_animations.push(animation)
  656.                                 end
  657.                         end
  658.                         update_animation
  659.                 end
  660.                 # 修改:更换清除伤害的算法,以防万一
  661.                 #       本内容在脚本中没有使用过
  662.                 def dispose_damage
  663.                         #逆序排列伤害数组
  664.                         for damage in @_damage.reverse
  665.                                 #清空当前伤害精灵
  666.                                 damage[0].bitmap.dispose
  667.                                 damage[0].dispose
  668.                                 @_damage.delete(damage)
  669.                         end
  670.                         @_total_damage = 0
  671.                         @_last_frame = -1
  672.                         #如果伤害统计精灵不为空则清空
  673.                         if @_total_damage_sprite != nil
  674.                                 @_total_damage_duration = 0
  675.                                 @_total_damage_sprite.bitmap.dispose
  676.                                 @_total_damage_sprite.dispose
  677.                                 @_total_damage_sprite = nil
  678.                         end
  679.                 end
  680.                 # 清除hit数
  681.                 def dispose_hit
  682.                         if @_hits_sprite != nil
  683.                                 @_hits_sprite.bitmap.dispose
  684.                                 @_hits_sprite.dispose
  685.                                 @_hits_sprite = nil
  686.                         end
  687.                 end
  688.                 def dispose_animation
  689.                         # 修改:清除记录的伤害,清除权重记录
  690.                         @battler_damage = nil
  691.                         @battler_critical = nil
  692.                         @all_quanzhong = 1
  693.                         @_total_damage = 0
  694.                         @_last_frame = -1
  695.                         @hits = 0
  696.                         if @_animation_sprites != nil
  697.                                 sprite = @_animation_sprites[0]
  698.                                 if sprite != nil
  699.                                         @@_reference_count[sprite.bitmap] -= 1
  700.                                         #条件改为<=0
  701.                                         if @@_reference_count[sprite.bitmap] <= 0
  702.                                                 sprite.bitmap.dispose
  703.                                         end
  704.                                 end
  705.                                 for sprite in @_animation_sprites
  706.                                         sprite.dispose
  707.                                 end
  708.                                 @_animation_sprites = nil
  709.                                 @_animation = nil
  710.                         end
  711.                 end
  712.                 def update
  713.                         super
  714.                         if @_whiten_duration > 0
  715.                                 @_whiten_duration -= 1
  716.                                 self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  717.                         end
  718.                         if @_appear_duration > 0
  719.                                 @_appear_duration -= 1
  720.                                 self.opacity = (16 - @_appear_duration) * 16
  721.                         end
  722.                         if @_escape_duration > 0
  723.                                 @_escape_duration -= 1
  724.                                 self.opacity = 256 - (32 - @_escape_duration) * 10
  725.                         end
  726.                         if @_collapse_duration > 0
  727.                                 @_collapse_duration -= 1
  728.                                 self.opacity = 256 - (48 - @_collapse_duration) * 6
  729.                         end
  730.                         # 修改:更新算法,更新弹出
  731.                         if @_damage_duration > 0
  732.                                 @_damage_duration -= 1
  733.                                 for damage in @_damage
  734.                                         damage[0].x = self.x + self.viewport.rect.x -
  735.                                         self.ox + self.src_rect.width / 2 +
  736.                                         (40 - damage[1]) * damage[3] / 10
  737.                                         damage[0].y -= damage[4]+damage[1]/10
  738.                                         damage[0].opacity = damage[1]*20
  739.                                         damage[1] -= 1
  740.                                         if damage[1]==0
  741.                                                 damage[0].bitmap.dispose
  742.                                                 damage[0].dispose
  743.                                                 @_damage.delete(damage)
  744.                                                 next
  745.                                         end
  746.                                 end
  747.                         end
  748.                         # 添加:弹出总伤害
  749.                         if @_total_damage_duration > 0
  750.                                 @_total_damage_duration -= 1
  751.                                 @_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
  752.                                 if @_total_damage_sprite.zoom_x > 1.0
  753.                                         @_total_damage_sprite.zoom_x -= 0.05
  754.                                 end
  755.                                 if @_total_damage_sprite.zoom_y > 1.0
  756.                                         @_total_damage_sprite.zoom_y -= 0.05
  757.                                 end
  758.                                 @_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
  759.                                 if @_total_damage_duration <= 7 and @_total_damage_duration > 0
  760.                                         @_hits_sprite.opacity -= 32
  761.                                         @_hits_sprite.x += 1
  762.                                 end
  763.                                 if @_total_damage_duration <= 0
  764.                                         dispose_hit
  765.                                         @_total_damage = 0
  766.                                         @_total_damage = 0
  767.                                         @_total_damage_duration = 0
  768.                                         if SHOW_TOTAL_DAMAGE
  769.                                                 @_total_damage_sprite.bitmap.dispose
  770.                                         end
  771.                                         @_total_damage_sprite.dispose
  772.                                         @_total_damage_sprite = nil
  773.                                 end
  774.                         end
  775.                         if @_animation != nil and (Graphics.frame_count % 2 == 0)
  776.                                 @_animation_duration -= 1
  777.                                 update_animation
  778.                         end
  779.                         if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  780.                                 update_loop_animation
  781.                                 @_loop_animation_index += 1
  782.                                 @loop_animation_once = 0
  783.                                 @loop_animation_once = 1 if @once == 1 and @_loop_animation_index == @_loop_animation.frame_max
  784.                                 @_loop_animation_index %= @_loop_animation.frame_max
  785.                         end
  786.                         if @_loop_animation1 != nil and (Graphics.frame_count % 2 == 0)
  787.                                 for index in 0..(@_loop_animation1.size) - 1
  788.                                         update_loop_animation1
  789.                                         @_loop_animation1_index[index] += 1
  790.                                         @_loop_animation1_index[index] %= @_loop_animation1[index].frame_max
  791.                                 end
  792.                         end
  793.                         if @_blink
  794.                                 @_blink_count = (@_blink_count + 1) % 32
  795.                                 if @_blink_count < 16
  796.                                         alpha = (16 - @_blink_count) * 6
  797.                                 else
  798.                                         alpha = (@_blink_count - 16) * 6
  799.                                 end
  800.                                 self.color.set(255, 255, 255, alpha)
  801.                         end
  802.                         @@_animations.clear
  803.                 end
  804.                 def loop_animation_once
  805.                         return @_loop_animation_once
  806.                 end
  807.                 def update_animation
  808.                         #如果动画剩余帧数大于0
  809.                         if @_animation_duration > 0
  810.                                 #获得当前动画帧索引
  811.                                 frame_index = @_animation.frame_max - @_animation_duration
  812.                                 @frame_index = frame_index
  813.                                 #获得当前帧样式
  814.                                 cell_data = @_animation.frames[frame_index].cell_data
  815.                                 #动画位置
  816.                                 position = @_animation.position
  817.                                 #设置动画精灵
  818.                                 animation_set_sprites(@_animation_sprites, cell_data, position)
  819.                                 # 修改:弹出伤害,权重计算
  820.                                 for timing in @_animation.timings
  821.                                         if timing.frame == frame_index
  822.                                                 t = 1.0 * animation_process_timing(timing, @_animation_hit)            
  823.                                                 #p t,"当前权重", @all_quanzhong,"总权重"
  824.                                                 if @battler_damage.is_a?(Numeric) and t != 0
  825.                                                         t *= @battler_damage
  826.                                                         t /= @all_quanzhong
  827.                                                         t = t.to_i
  828.                                                         #在闪光不是最后一次的情况下,把这次伤害加入到已经发生的伤害中
  829.                                                         if frame_index != @_last_frame
  830.                                                                 @p_dam+= t
  831.                                                         end
  832.                                                         #p @p_dam,"已发生伤害",@battler_damage,"总伤害"
  833.                                                         #闪光为最后一次的情况下,改变这次伤害的计算方法(总伤害-已经发生伤害)
  834.                                                         if frame_index == @_last_frame
  835.                                                                 t= @battler_damage-@p_dam
  836.                                                         end
  837.                                                         #p t,"当前伤害",@battler_damage,"总伤害"
  838.                                                         # 最后一次闪光的话,伤害修正
  839.                                                         if frame_index == @_last_frame
  840.                                                                 @_total_damage = @battler_damage - t
  841.                                                                 # 已经发生的伤害归0
  842.                                                                 @p_dam=0      
  843.                                                         end
  844.                                                         damage(t,@battler_critical)
  845.                                                         #连击次数归0
  846.                                                         if frame_index == @_last_frame
  847.                                                                 @last_hits=1
  848.                                                                 @temp_hits=0
  849.                                                                 @hits=0
  850.                                                         end
  851.                                                         # 防止重复播放miss
  852.                                                 elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
  853.                                                         damage(@battler_damage,@battler_critical)
  854.                                                 end
  855.                                         end
  856.                                 end
  857.                         else
  858.                                 dispose_animation
  859.                         end
  860.                 end
  861.                 # 更新循环动画
  862.                 def update_loop_animation
  863.                         frame_index = @_loop_animation_index
  864.                         cell_data = @_loop_animation.frames[frame_index].cell_data
  865.                         position = @_loop_animation.position
  866.                         #·改·
  867.                         if @wait_count.to_i <= 0
  868.                                 @wait_count = 0
  869.                                 animation_set_sprites(@_loop_animation_sprites, cell_data, position)
  870.                         else
  871.                                 @wait_count -= 1
  872.                                 for sprite in @_loop_animation_sprites
  873.                                         sprite.visible = false
  874.                                 end
  875.                         end
  876.                         if @wait_flash.to_i <= 0
  877.                                 @wait_flash = 0
  878.                         else
  879.                                 @wait_flash -= 1
  880.                                 for sprite in @_loop_animation_sprites
  881.                                         sprite.blend_type = 1
  882.                                 end
  883.                         end
  884.                         #·改·
  885.                         for timing in @_loop_animation.timings
  886.                                 if timing.frame == frame_index
  887.                                         animation_process_timing(timing, true)
  888.                                 end
  889.                         end
  890.                 end
  891.                 # 循环动画
  892.                 def loop_animation(animation)
  893.                         #如果动画重复return
  894.                         return if animation == @_loop_animation
  895.                         #释放原有动画
  896.                         dispose_loop_animation
  897.                         #加载新动画
  898.                         @_loop_animation = animation
  899.                         #如果动画为空return
  900.                         return if @_loop_animation == nil
  901.                         #动画索引初始化
  902.                         @_loop_animation_index = 0
  903.                         animation_name = @_loop_animation.animation_name
  904.                         animation_hue = @_loop_animation.animation_hue
  905.                         bitmap = RPG::Cache.animation(animation_name, animation_hue)
  906.                         if @@_reference_count.include?(bitmap)
  907.                                 @@_reference_count[bitmap] += 1
  908.                         else
  909.                                 @@_reference_count[bitmap] = 1
  910.                         end
  911.                         @_loop_animation_sprites = []
  912.                         for i in 0..15
  913.                                 sprite = ::Sprite.new(self.viewport)
  914.                                 sprite.bitmap = bitmap
  915.                                 sprite.visible = false
  916.                                 @_loop_animation_sprites.push(sprite)
  917.                         end
  918.                         update_loop_animation
  919.                 end
  920.                 # 修改: 敌人跳跃功能 (伤害数值被敌人遮盖)
  921.                 def loop_animation_s(animation)
  922.                         return if animation == @_loop_animation
  923.                         dispose_loop_animation
  924.                         @_loop_animation = animation
  925.                         return if @_loop_animation == nil
  926.                         @_loop_animation_index = 0
  927.                         animation_name = @_loop_animation.animation_name
  928.                         animation_hue = @_loop_animation.animation_hue
  929.                         bitmap = RPG::Cache.animation(animation_name, animation_hue)
  930.                         if @@_reference_count.include?(bitmap)
  931.                                 @@_reference_count[bitmap] += 1
  932.                         else
  933.                                 @@_reference_count[bitmap] = 1
  934.                         end
  935.                         @_loop_animation_sprites = []
  936.                         for i in 0..15
  937.                                 sprite = ::Sprite.new(self.viewport)
  938.                                 sprite.bitmap = bitmap
  939.                                 sprite.visible = false
  940.                                 @_loop_animation_sprites.push(sprite)
  941.                         end
  942.                         update_loop_animation
  943.                 end
  944.                 # 修改:敌人跳跃的功能 + 添加返回数值
  945.                 def animation_process_timing(timing, hit,dontflash=false)
  946.                         if (timing.condition == 0) or
  947.                                 (timing.condition == 1 and hit == true) or
  948.                                 (timing.condition == 2 and hit == false)
  949.                                 unless dontflash
  950.                                         if timing.se.name != ""
  951.                                                 se = timing.se
  952.                                                 Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  953.                                         end
  954.                                 end
  955.                                 case timing.flash_scope
  956.                                 when 1
  957.                                         unless dontflash
  958.                                                 self.flash(timing.flash_color, timing.flash_duration * 2)
  959.                                                 @wait_flash = timing.flash_duration
  960.                                                 if @_total_damage >0
  961.                                                         @flash_shake_switch = true
  962.                                                         @flash_shake = 10
  963.                                                 end
  964.                                         end
  965.                                         return timing.flash_color.alpha * timing.flash_duration
  966.                                 when 2
  967.                                         unless dontflash
  968.                                                 if self.viewport != nil
  969.                                                         self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  970.                                                         return timing.flash_color.alpha * timing.flash_duration
  971.                                                 end
  972.                                         end
  973.                                 when 3
  974.                                         unless dontflash
  975.                                                 self.flash(nil, timing.flash_duration * 2)
  976.                                                 @wait_count = timing.flash_duration
  977.                                         end
  978.                                         return timing.flash_color.alpha * timing.flash_duration
  979.                                 end
  980.                         end      
  981.                         return 0
  982.                 end   
  983.         end
  984. end

点评

重点是第一句,全动画脚本如果没有致命bug,建议忍着用  发表于 2021-8-29 16:09
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2851
在线时间
446 小时
注册时间
2016-9-26
帖子
1222
4
发表于 2021-8-29 19:29:38 | 只看该作者
鞭尸有什么奇怪的
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-23 17:11

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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