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

Project1

 找回密码
 注册会员
搜索

谁有灵儿续传范例啊 想研究一下组合技能

查看数: 2474 | 评论数: 6 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2016-2-19 14:39

正文摘要:

有的分享一下

回复

金芒芒 发表于 2016-2-20 16:21:46
jiushiainilip19 发表于 2016-2-20 16:07
插入战斗类,不要插入到main前 我这里是写出来告诉你 你自己手动添加进去就好了  自动战斗的话要看你用的 ...

谢了,大神在人间
jiushiainilip19 发表于 2016-2-20 16:07:11
本帖最后由 jiushiainilip19 于 2016-2-20 16:08 编辑
金芒芒 发表于 2016-2-20 08:05
我的游戏是自动战斗模式,你的这段脚本是我想要的,不过这段脚本应该放哪个脚本里呢大哥 ...


插入战斗类,不要插入到main前 我这里是写出来告诉你 你自己手动添加进去就好了  自动战斗的话要看你用的那个脚本
需要你自己在自动战斗脚本中添加释放技能几率的判定
我个人是使用技能冷却配合自动战斗 比如在某个状态下必定释放这个技能


RUBY 代码复制
  1. #==============================================================================
  2. # ■ Game_Battler (分割定义 3)
  3. #------------------------------------------------------------------------------
  4. #  处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
  5. # 超级类来使用。
  6. #==============================================================================
  7.  
  8. class Game_Battler
  9.   #--------------------------------------------------------------------------
  10.   # ● 可以使用特技的判定
  11.   #     skill_id : 特技 ID
  12.   #--------------------------------------------------------------------------
  13.   def skill_can_use?(skill_id)
  14.     # SP 不足的情况下不能使用
  15.     if $data_skills[skill_id].sp_cost > self.sp
  16.       return false
  17.     end
  18.     # 战斗不能的情况下不能使用
  19.     if dead?
  20.       return false
  21.     end
  22.     # 沉默状态的情况下、物理特技以外的特技不能使用
  23.     if $data_skills[skill_id].atk_f == 0 and self.restriction == 1
  24.       return false
  25.     end
  26.     # 获取可以使用的时机
  27.     occasion = $data_skills[skill_id].occasion
  28.     # 战斗中的情况下
  29.     if $game_temp.in_battle
  30.       # [平时] 或者是 [战斗中] 可以使用
  31.       return (occasion == 0 or occasion == 1)
  32.     # 不是战斗中的情况下
  33.     else
  34.       # [平时] 或者是 [菜单中] 可以使用
  35.       return (occasion == 0 or occasion == 2)
  36.     end
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 应用通常攻击效果
  40.   #     attacker : 攻击者 (battler)
  41.   #--------------------------------------------------------------------------
  42.   def attack_effect(attacker)
  43.     # 清除会心一击标志
  44.     self.critical = false
  45.     # 第一命中判定
  46.     hit_result = (rand(100) < attacker.hit)
  47.     # 命中的情况下
  48.     if hit_result == true
  49.       # 计算基本伤害
  50.       atk = [attacker.atk - self.pdef / 2, 0].max
  51.       self.damage = atk * (20 + attacker.str) / 20
  52.  
  53.       # 属性修正
  54.       self.damage *= elements_correct(attacker.element_set)
  55.       self.damage /= 100
  56.       # 伤害符号正确的情况下
  57.       if self.damage > 0
  58.         # 会心一击修正
  59.         if rand(100) < 4 * attacker.dex / self.agi
  60.           self.damage *= 2
  61.           self.critical = true
  62.         end
  63.         # 防御修正
  64.         if self.guarding?
  65.           self.damage /= 2
  66.         end
  67.       end
  68.       # 分散
  69.       if self.damage.abs > 0
  70.         amp = [self.damage.abs * 15 / 100, 1].max
  71.         self.damage += rand(amp+1) + rand(amp+1) - amp
  72.       end
  73.       # 第二命中判定
  74.       eva = 8 * self.agi / attacker.dex + self.eva
  75.       hit = self.damage < 0 ? 100 : 100 - eva
  76.       hit = self.cant_evade? ? 100 : hit
  77.       hit_result = (rand(100) < hit)
  78.     end
  79.     # 命中的情况下
  80.     if hit_result == true
  81.       # 状态冲击解除
  82.       remove_states_shock
  83.       # HP 的伤害计算
  84.       self.hp -= self.damage
  85.       # 状态变化
  86.       @state_changed = false
  87.       states_plus(attacker.plus_state_set)
  88.       states_minus(attacker.minus_state_set)
  89.     # Miss 的情况下
  90.     else
  91.       # 伤害设置为 "Miss"
  92.       self.damage = "Miss"
  93.       # 清除会心一击标志
  94.       self.critical = false
  95.     end
  96.     # 过程结束
  97.     return true
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ● 应用特技效果
  101.   #     user  : 特技的使用者 (battler)
  102.   #     skill : 特技
  103.   #--------------------------------------------------------------------------
  104.   def skill_effect(user, skill)
  105.     # 清除会心一击标志
  106.     self.critical = false
  107.     # 特技的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
  108.     # 或者特技的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
  109.     if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  110.        ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  111.       # 过程结束
  112.       return false
  113.     end
  114.     # 清除有效标志
  115.     effective = false
  116.     # 公共事件 ID 是有效的情况下,设置为有效标志
  117.     effective |= skill.common_event_id > 0
  118.     # 第一命中判定
  119.     hit = skill.hit
  120.     if skill.atk_f > 0
  121.       hit *= user.hit / 100
  122.     end
  123.     hit_result = (rand(100) < hit)
  124.     # 不确定的特技的情况下设置为有效标志
  125.     effective |= hit < 100
  126.     # 命中的情况下
  127.     if hit_result == true
  128.       # 计算威力
  129.       power = skill.power + user.atk * skill.atk_f / 100
  130.       if power > 0
  131.         power -= self.pdef * skill.pdef_f / 200
  132.         power -= self.mdef * skill.mdef_f / 200
  133.         power = [power, 0].max
  134.       end
  135.  
  136. ##############################################################      
  137. #   合击 需要 2 3号角色在队伍中由2号角色发动  指定威力
  138. #  如需要指定技能就添加 if skill.id == xx
  139. ##############################################################   
  140.         if user.is_a?(Game_Actor)
  141.         if [2,3].include?(user.id)
  142.         for actor in $game_party.actors
  143.          if user.id == 2 && actor.id == 3 && actor.hp>0
  144.           power*=190000000
  145.         end ; end ; end  ; end
  146. ##############################################################      
  147. #   合击 需要 2 3号角色在队伍中由2号角色发动  
  148. ##############################################################   
  149.  
  150.  
  151.  
  152.       # 计算倍率
  153.       rate = 20
  154.       rate += (user.str * skill.str_f / 100)
  155.       rate += (user.dex * skill.dex_f / 100)
  156.       rate += (user.agi * skill.agi_f / 100)
  157.       rate += (user.int * skill.int_f / 100)
  158.       # 计算基本伤害
  159.       self.damage = power * rate / 20
  160.       # 属性修正
  161.       self.damage *= elements_correct(skill.element_set)
  162.       self.damage /= 100
  163.       # 伤害符号正确的情况下
  164.       if self.damage > 0
  165.         # 防御修正
  166.         if self.guarding?
  167.           self.damage /= 2
  168.         end
  169.       end
  170.  
  171. ##############################################################      
  172. #   合击 需要 1 2号角色在队伍中由1号角色发动  指定伤害
  173. #  如需要指定技能就添加 if skill.id == xx
  174. ##############################################################   
  175.         if user.is_a?(Game_Actor)
  176.         if [1,2].include?(user.id)
  177.         for actor in $game_party.actors
  178.          if user.id == 1 && actor.id == 2 && actor.hp>0
  179.          if skill.id == 57 #########技能
  180.         self.damage+=1111111
  181.         end ; end ; end  ; end;end
  182. ##############################################################      
  183. #   合击 需要 1 2号角色在队伍中由1号角色发动  
  184. ##############################################################   
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.       # 分散
  192.       if skill.variance > 0 and self.damage.abs > 0
  193.         amp = [self.damage.abs * skill.variance / 100, 1].max
  194.         self.damage += rand(amp+1) + rand(amp+1) - amp
  195.       end
  196.       # 第二命中判定
  197.       eva = 8 * self.agi / user.dex + self.eva
  198.       hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
  199.       hit = self.cant_evade? ? 100 : hit
  200.       hit_result = (rand(100) < hit)
  201.       # 不确定的特技的情况下设置为有效标志
  202.       effective |= hit < 100
  203.     end
  204.     # 命中的情况下
  205.     if hit_result == true
  206.       # 威力 0 以外的物理攻击的情况下
  207.       if skill.power != 0 and skill.atk_f > 0
  208.         # 状态冲击解除
  209.         remove_states_shock
  210.         # 设置有效标志
  211.         effective = true
  212.       end
  213.       # HP 的伤害减法运算
  214.       last_hp = self.hp
  215.       self.hp -= self.damage
  216.       effective |= self.hp != last_hp
  217.       # 状态变化
  218.       @state_changed = false
  219.       effective |= states_plus(skill.plus_state_set)
  220.       effective |= states_minus(skill.minus_state_set)
  221.       # 威力为 0 的场合
  222.       if skill.power == 0
  223.         # 伤害设置为空的字串
  224.         self.damage = ""
  225.         # 状态没有变化的情况下
  226.         unless @state_changed
  227.           # 伤害设置为 "Miss"
  228.           self.damage = "Miss"
  229.         end
  230.       end
  231.     # Miss 的情况下
  232.     else
  233.       # 伤害设置为 "Miss"
  234.       self.damage = "Miss"
  235.     end
  236.     # 不在战斗中的情况下
  237.     unless $game_temp.in_battle
  238.       # 伤害设置为 nil
  239.       self.damage = nil
  240.     end
  241.     # 过程结束
  242.     return effective
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ● 应用物品效果
  246.   #     item : 物品
  247.   #--------------------------------------------------------------------------
  248.   def item_effect(item)
  249.     # 清除会心一击标志
  250.     self.critical = false
  251.     # 物品的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
  252.     # 或者物品的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
  253.     if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  254.        ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  255.       # 过程结束
  256.       return false
  257.     end
  258.     # 清除有效标志
  259.     effective = false
  260.     # 公共事件 ID 是有效的情况下,设置为有效标志
  261.     effective |= item.common_event_id > 0
  262.     # 命中判定
  263.     hit_result = (rand(100) < item.hit)
  264.     # 不确定的特技的情况下设置为有效标志
  265.     effective |= item.hit < 100
  266.     # 命中的情况
  267.     if hit_result == true
  268.       # 计算回复量
  269.       recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
  270.       recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
  271.       if recover_hp < 0
  272.         recover_hp += self.pdef * item.pdef_f / 20
  273.         recover_hp += self.mdef * item.mdef_f / 20
  274.         recover_hp = [recover_hp, 0].min
  275.       end
  276.       # 属性修正
  277.       recover_hp *= elements_correct(item.element_set)
  278.       recover_hp /= 100
  279.       recover_sp *= elements_correct(item.element_set)
  280.       recover_sp /= 100
  281.       # 分散
  282.       if item.variance > 0 and recover_hp.abs > 0
  283.         amp = [recover_hp.abs * item.variance / 100, 1].max
  284.         recover_hp += rand(amp+1) + rand(amp+1) - amp
  285.       end
  286.       if item.variance > 0 and recover_sp.abs > 0
  287.         amp = [recover_sp.abs * item.variance / 100, 1].max
  288.         recover_sp += rand(amp+1) + rand(amp+1) - amp
  289.       end
  290.       # 回复量符号为负的情况下
  291.       if recover_hp < 0
  292.         # 防御修正
  293.         if self.guarding?
  294.           recover_hp /= 2
  295.         end
  296.       end
  297.       # HP 回复量符号的反转、设置伤害值
  298.       self.damage = -recover_hp
  299.       # HP 以及 SP 的回复
  300.       last_hp = self.hp
  301.       last_sp = self.sp
  302.       self.hp += recover_hp
  303.       self.sp += recover_sp
  304.       effective |= self.hp != last_hp
  305.       effective |= self.sp != last_sp
  306.       # 状态变化
  307.       @state_changed = false
  308.       effective |= states_plus(item.plus_state_set)
  309.       effective |= states_minus(item.minus_state_set)
  310.       # 能力上升值有效的情况下
  311.       if item.parameter_type > 0 and item.parameter_points != 0
  312.         # 能力值的分支
  313.         case item.parameter_type
  314.         when 1  # MaxHP
  315.           @maxhp_plus += item.parameter_points
  316.         when 2  # MaxSP
  317.           @maxsp_plus += item.parameter_points
  318.         when 3  # 力量
  319.           @str_plus += item.parameter_points
  320.         when 4  # 灵巧
  321.           @dex_plus += item.parameter_points
  322.         when 5  # 速度
  323.           @agi_plus += item.parameter_points
  324.         when 6  # 魔力
  325.           @int_plus += item.parameter_points
  326.         end
  327.         # 设置有效标志
  328.         effective = true
  329.       end
  330.       # HP 回复率与回复量为 0 的情况下
  331.       if item.recover_hp_rate == 0 and item.recover_hp == 0
  332.         # 设置伤害为空的字符串
  333.         self.damage = ""
  334.         # SP 回复率与回复量为 0、能力上升值无效的情况下
  335.         if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  336.            (item.parameter_type == 0 or item.parameter_points == 0)
  337.           # 状态没有变化的情况下
  338.           unless @state_changed
  339.             # 伤害设置为 "Miss"
  340.             self.damage = "Miss"
  341.           end
  342.         end
  343.       end
  344.     # Miss 的情况下
  345.     else
  346.       # 伤害设置为 "Miss"
  347.       self.damage = "Miss"
  348.     end
  349.     # 不在战斗中的情况下
  350.     unless $game_temp.in_battle
  351.       # 伤害设置为 nil
  352.       self.damage = nil
  353.     end
  354.     # 过程结束
  355.     return effective
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # ● 应用连续伤害效果
  359.   #--------------------------------------------------------------------------
  360.   def slip_damage_effect
  361.     # 设置伤害
  362.     self.damage = self.maxhp / 10
  363.     # 分散
  364.     if self.damage.abs > 0
  365.       amp = [self.damage.abs * 15 / 100, 1].max
  366.       self.damage += rand(amp+1) + rand(amp+1) - amp
  367.     end
  368.     # HP 的伤害减法运算
  369.     self.hp -= self.damage
  370.     # 过程结束
  371.     return true
  372.   end
  373.   #--------------------------------------------------------------------------
  374.   # ● 属性修正计算
  375.   #     element_set : 属性
  376.   #--------------------------------------------------------------------------
  377.   def elements_correct(element_set)
  378.     # 无属性的情况
  379.     if element_set == []
  380.       # 返回 100
  381.       return 100
  382.     end
  383.     # 在被赋予的属性中返回最弱的
  384.     # ※过程 element_rate 是、本类以及继承的 Game_Actor
  385.     #   和 Game_Enemy 类的定义
  386.     weakest = -100
  387.     for i in element_set
  388.       weakest = [weakest, self.element_rate(i)].max
  389.     end
  390.     return weakest
  391.   end
  392. end

评分

参与人数 1梦石 +1 收起 理由
RyanBern + 1 认可答案

查看全部评分

金芒芒 发表于 2016-2-20 08:05:55
jiushiainilip19 发表于 2016-2-19 21:22
你说的那些我都没玩过 所以不要用游戏说明要求
把你要求的效果说明白些就好 看我能不能帮你搞搞
如果只是发 ...

我的游戏是自动战斗模式,你的这段脚本是我想要的,不过这段脚本应该放哪个脚本里呢大哥
jiushiainilip19 发表于 2016-2-19 21:22:03
你说的那些我都没玩过 所以不要用游戏说明要求
把你要求的效果说明白些就好 看我能不能帮你搞搞
如果只是发挥技能的话就直接判定角色有没有装备几号装备
if user.armor2_id == XXX #角色装备栏2的装备是什么  看你游戏设定来设定
power*=100 and power/=100
elsif user.armor2_id == XXX #通过elsif的方法可以不断的进行调整
power*=100 and power/=100
end #这个多少威力就自己设定
然后要看你的游戏是不是什么模式  是自动战斗模式还是说动模式
金芒芒 发表于 2016-2-19 17:03:22
本帖最后由 金芒芒 于 2016-2-19 17:05 编辑
jiushiainilip19 发表于 2016-2-19 15:57
没有 不过要判断合击要先判断角色
大概就是下面的方法 要用在战斗类脚本中


1号装备只能发挥1技能 +上2号装备就可以发挥3级技能+上3号装备就可以发挥5号技能,,跟天空的回路装备一样
jiushiainilip19 发表于 2016-2-19 15:57:09
没有 不过要判断合击要先判断角色
大概就是下面的方法 要用在战斗类脚本中
RUBY 代码复制
  1. #角色为我方
  2.   if user.is_a?(Game_Actor)
  3. if [1,4].include?(user.id)
  4.      for actor in $game_party.actors
  5. #1号角色发动技能 需要4号角色存在
  6.     if user.id == 1 && actor.id == 4 && actor.hp>0
  7. #然后计算威力
  8.         self.damage+=1111111
  9.     end ; end ; end  ; end
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-9-22 17:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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