查看: 2292|回复: 1

[已经过期] FloatDomainError.Infinity错误问题

[复制链接]
梦石
0
星屑
606
在线时间
797 小时
注册时间
2014-7-1
回帖
501

开拓者

发表于 2016-1-20 00:41:55 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 jiushiainilip19 于 2016-1-21 22:40 编辑

这个错误好像是一个超出大小范围的错误 但是要怎么解决呢?请教一下

[pre lang="ruby"]
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  AI模块 本脚本来自与66RPG
#==============================================================================

class  Game_Battler
  attr_accessor :marks
end
class Game_Actor < Game_Battler
  AI = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] # 需要自动攻击的角色编号

           # 物理攻击倾向指数 魔法攻击倾向指数 防御指数 什么都不做指数
  Action_Index = [0,100,0]

  IQ = 90 # 智商设定,90为标准值,IQ越高,越优先攻击生命值少,防御力小的
  Hp_Mark = [30,-10] # 生命值评分标准,[生命值最低的得分,步进值(负)]
  Df_Mark = [20,-10] # 防御值评分标准,[防御值最低的得分,步进值(负)]

  EQ = 90 # 情商设定,90为标准值,EQ越高,越优先使用对应魔法(属性有效度为准),
  def make_action
    $game_troop.enemies.each{|i|i.marks=50}
    $game_party.actors.each{|i|i.marks=50}
    # 先确认动作
    index = Action_Index
    skills = self.skills.inject([]){|a,b|a<<b if skill_can_use?(b);a}
    index[1] = 0 if skills == []
    index[0] *= IQ/90.0;index[1] *= IQ/90.0;index[1] *= EQ/1.0
    index[0].to_i;index[1].to_i
    all = index.inject(0){|a,b|a+b}.to_i
    value = rand(all)
    action = 2 # 默认魔法
    for i in 0...index.size
      if i > value
        action = i
        break
      else
        value -= index
      end
    end
    case action
    when 1 # 攻击
      # 智商检查
      enemies = $game_troop.enemies.inject([]){|a,b|a<<b if !b.hp0?;a}
      # 评分
      enemies.sort!{|a,b|a.hp<=>b.hp}
      for i in 0...enemies.size
        enemies.marks += (Hp_Mark[0] + i*Hp_Mark[1])*IQ/90
      end
      # 防御检查
      enemies.sort!{|a,b|a.pdef<=>b.pdef}
      for i in 0...enemies.size
        enemies.marks += (Df_Mark[0] + i*Df_Mark[1])*IQ/90
      end
      # 确认目标
      value = rand(enemies.inject(0){|a,b|a+b.marks})
      tag = nil
      for i in enemies
        if i.marks > value
          tag = i
          break
        else
          value -= i.marks
        end
      end
      # 目标确认 tag
      @current_action.kind = 0
      @current_action.basic = 0
      return @current_action.target_index = 0 unless tag
      @current_action.target_index = $game_troop.enemies.index(tag)
    when 2 # 魔法
      # 魔法分类,对敌/对己(加持)/附着状态/解除状态
      @current_action.kind = 0
      return @current_action.basic = 1 if skills == []
      @current_action.kind = 1
      # 随机技能
      idex = 0
      loop do
      idex += 1
     @current_action.skill_id = skills[rand(skills.size)]
      if $data_skills[@current_action.skill_id].int_f != 1 #@current_action.skill_id >=94 && @current_action.skill_id <=900
        break
       end
       if idex >= 100 && $data_skills[@current_action.skill_id].int_f == 1
        @current_action.kind = 0
        @current_action.basic = 1
       break
       end
     end
      case self.id
         when 1
           if self.state?(951)
              @current_action.skill_id = 54
              else
              @current_action.skill_id = 950
           end
         when 2
           if self.state?(952)
              @current_action.skill_id = 56
              else
              @current_action.skill_id = 951
           end
         when 3
           if self.state?(953)
              @current_action.skill_id = 57
              else
              @current_action.skill_id = 952
           end
         when 4
           if self.state?(954)
              @current_action.skill_id = 55
              else
              @current_action.skill_id = 953
           end
         when 5
           if self.state?(955)
              @current_action.skill_id = 62
              else
              @current_action.skill_id = 954
           end
         when 6
           if self.state?(957)
              @current_action.skill_id = 59
              else
              @current_action.skill_id = 956
           end
         when 7
           if self.state?(958)
              @current_action.skill_id = 58
              else
              @current_action.skill_id = 957
           end
         when 8
           if self.state?(959)
              @current_action.skill_id = 65
              else
              @current_action.skill_id = 958
           end
         when 9
           if self.state?(960)
              @current_action.skill_id = 60
              else
              @current_action.skill_id = 959
           end
         when 10
           if self.state?(961)
              @current_action.skill_id = 61
              else
              @current_action.skill_id = 960
           end
         when 11
           if self.state?(963)
              @current_action.skill_id = 63
              else
              @current_action.skill_id = 962
           end
         when 12
           if self.state?(964)
              @current_action.skill_id = 64
              else
              @current_action.skill_id = 963
           end
         when 13
           if self.state?(965)
              @current_action.skill_id = 66
              else
              @current_action.skill_id = 964
           end
         when 14
           if self.state?(966)
              @current_action.skill_id = 67
              else
              @current_action.skill_id = 965
           end
         when 15
           if self.state?(967)
              @current_action.skill_id = 68
              else
              @current_action.skill_id = 966
           end

     
      end
      # 确认对象
      scope = $data_skills[@current_action.skill_id].scope
      @current_action.target_index = 0
      case scope


      
      
      when 1 # 敌单体
        # 智商检查
        enemies = $game_troop.enemies.inject([]){|a,b|a<<b if !b.hp0?;a}
       target = $game_troop.random_target_enemy
       @current_action.target_index = target.index
      when 2
        @current_action.target_index = game_party.actors.index(tag) if tag
      when 7
       @current_action.kind = 0
       @current_action.basic = 1
      when 3
        target = $game_troop.random_target_enemy
        @current_action.target_index = target.index
      end
    when 3 # 防御
      @current_action.kind = 0
      @current_action.basic = 1
    end
  end
end
class Scene_Battle
  #--------------------------------------------------------------------------
  # ● 转到输入下一个角色的命令
  #--------------------------------------------------------------------------
  def phase3_next_actor
    # 循环
    begin
      # 角色的明灭效果 OFF
      if @active_battler != nil
        @active_battler.blink = false
      end
      # 最后的角色的情况
      if @actor_index == $game_party.actors.size-1
        # 开始主回合
        start_phase4
        return
      end
      # 推进角色索引
      @actor_index += 1
      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
    # 如果角色是在无法接受指令的状态就再试
  end until @active_battler.inputable?
    #当角色装备@active_battler.state?(213)状态下就可以开启自动化战斗
    if  Game_Actor::AI.include?(@active_battler.id) or $game_switches[14] == true#@active_battler.state?(213)
   #AI同伴
      @actor_command_window.active = false
      @actor_command_window.visible = false
      @active_battler.make_action
      phase3_next_actor
    else
      # 设置角色的命令窗口
      phase3_setup_command_window
    end
  end

  #--------------------------------------------------------------------------
  # ● 转向前一个角色的命令输入
  #--------------------------------------------------------------------------
  def phase3_prior_actor
    # 循环
    begin
      # 角色的明灭效果 OFF
      if @active_battler != nil
        @active_battler.blink = false
      end
      # 最初的角色的情况下
      if @actor_index == 0
        # 开始同伴指令回合
        start_phase2
        return
      end
      # 返回角色索引
      @actor_index -= 1
      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
    # 如果角色是在无法接受指令的状态就再试
    end until @active_battler.inputable?
    # 设置角色的命令窗口
    if  Game_Actor::AI.include?(@active_battler.id)#@active_battler.id !=1
      #AI同伴
      phase3_prior_actor
    else
      phase3_setup_command_window
    end
  end
end
[/pre]
QQ截图20160120004254.png

Scripts.rar

291.93 KB, 下载次数: 44

点评

这个问题一般是除数为0时比较容易发生这种错误  发表于 2016-2-5 08:52
学习使我疲劳,打工使我疲惫,恋爱使我伤身,吸烟伤我肺腑,饮酒损我形象,旅游使我破费,月底不见铜板,只有在论坛里面看看各种大佬才能使我进去
梦石
0
星屑
2826
在线时间
2634 小时
注册时间
2013-1-16
回帖
5453

贵宾

发表于 2016-1-20 20:42:55 | 显示全部楼层
本帖最后由 myownroc 于 2016-1-20 20:44 编辑
FloatDomainError
若想将正负无穷或NaN(Not a Number)变为Bignum,或与NaN进行比较时就会引发该异常。

在出错前设置一个断点,看看index[0]和index[1]的值是否能转为Bignum

点评

http://pan.baidu.com/s/1pKrCQIv这个是游戏全部。。  发表于 2016-1-22 00:00
整个工程。。400多M 我要慢慢抽个了工程出来  发表于 2016-1-21 23:59
我说的是工程……  发表于 2016-1-21 23:47
报错的方式上面贴出来了 工程脚本也补上了 !麻烦你了  发表于 2016-1-21 22:39
给出出错时的结果,也可以上传工程  发表于 2016-1-21 07:10
(Created by @喵kano)


施工现场:hotege.github.io
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部