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

Project1

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

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
596
在线时间
797 小时
注册时间
2014-7-1
帖子
578

开拓者

跳转到指定楼层
1
发表于 2016-1-20 00:41:55 | 只看该作者 |只看大图 回帖奖励 |正序浏览 |阅读模式

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

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

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

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

RUBY 代码复制
  1. #==============================================================================
  2. # ■ Game_Actor
  3. #------------------------------------------------------------------------------
  4. #  AI模块 本脚本来自与66RPG
  5. #==============================================================================
  6.  
  7. class  Game_Battler
  8.   attr_accessor :marks
  9. end
  10. class Game_Actor < Game_Battler
  11.   AI = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] # 需要自动攻击的角色编号
  12.  
  13.            # 物理攻击倾向指数 魔法攻击倾向指数 防御指数 什么都不做指数
  14.   Action_Index = [0,100,0]
  15.  
  16.   IQ = 90 # 智商设定,90为标准值,IQ越高,越优先攻击生命值少,防御力小的
  17.   Hp_Mark = [30,-10] # 生命值评分标准,[生命值最低的得分,步进值(负)]
  18.   Df_Mark = [20,-10] # 防御值评分标准,[防御值最低的得分,步进值(负)]
  19.  
  20.   EQ = 90 # 情商设定,90为标准值,EQ越高,越优先使用对应魔法(属性有效度为准),
  21.   def make_action
  22.     $game_troop.enemies.each{|i|i.marks=50}
  23.     $game_party.actors.each{|i|i.marks=50}
  24.     # 先确认动作
  25.     index = Action_Index
  26.     skills = self.skills.inject([]){|a,b|a<<b if skill_can_use?(b);a}
  27.     index[1] = 0 if skills == []
  28.     index[0] *= IQ/90.0;index[1] *= IQ/90.0;index[1] *= EQ/1.0
  29.     index[0].to_i;index[1].to_i
  30.     all = index.inject(0){|a,b|a+b}.to_i
  31.     value = rand(all)
  32.     action = 2 # 默认魔法
  33.     for i in 0...index.size
  34.       if i > value
  35.         action = i
  36.         break
  37.       else
  38.         value -= index[i]
  39.       end
  40.     end
  41.     case action
  42.     when 1 # 攻击
  43.       # 智商检查
  44.       enemies = $game_troop.enemies.inject([]){|a,b|a<<b if !b.hp0?;a}
  45.       # 评分
  46.       enemies.sort!{|a,b|a.hp<=>b.hp}
  47.       for i in 0...enemies.size
  48.         enemies[i].marks += (Hp_Mark[0] + i*Hp_Mark[1])*IQ/90
  49.       end
  50.       # 防御检查
  51.       enemies.sort!{|a,b|a.pdef<=>b.pdef}
  52.       for i in 0...enemies.size
  53.         enemies[i].marks += (Df_Mark[0] + i*Df_Mark[1])*IQ/90
  54.       end
  55.       # 确认目标
  56.       value = rand(enemies.inject(0){|a,b|a+b.marks})
  57.       tag = nil
  58.       for i in enemies
  59.         if i.marks > value
  60.           tag = i
  61.           break
  62.         else
  63.           value -= i.marks
  64.         end
  65.       end
  66.       # 目标确认 tag
  67.       @current_action.kind = 0
  68.       @current_action.basic = 0
  69.       return @current_action.target_index = 0 unless tag
  70.       @current_action.target_index = $game_troop.enemies.index(tag)
  71.     when 2 # 魔法
  72.       # 魔法分类,对敌/对己(加持)/附着状态/解除状态
  73.       @current_action.kind = 0
  74.       return @current_action.basic = 1 if skills == []
  75.       @current_action.kind = 1
  76.       # 随机技能
  77.       idex = 0
  78.       loop do
  79.       idex += 1
  80.      @current_action.skill_id = skills[rand(skills.size)]
  81.       if $data_skills[@current_action.skill_id].int_f != 1 #@current_action.skill_id >=94 && @current_action.skill_id <=900
  82.         break
  83.        end
  84.        if idex >= 100 && $data_skills[@current_action.skill_id].int_f == 1
  85.         @current_action.kind = 0
  86.         @current_action.basic = 1
  87.        break
  88.        end
  89.      end
  90.       case self.id
  91.          when 1
  92.            if self.state?(951)
  93.               @current_action.skill_id = 54
  94.               else
  95.               @current_action.skill_id = 950
  96.            end
  97.          when 2
  98.            if self.state?(952)
  99.               @current_action.skill_id = 56
  100.               else
  101.               @current_action.skill_id = 951
  102.            end
  103.          when 3
  104.            if self.state?(953)
  105.               @current_action.skill_id = 57
  106.               else
  107.               @current_action.skill_id = 952
  108.            end
  109.          when 4
  110.            if self.state?(954)
  111.               @current_action.skill_id = 55
  112.               else
  113.               @current_action.skill_id = 953
  114.            end
  115.          when 5
  116.            if self.state?(955)
  117.               @current_action.skill_id = 62
  118.               else
  119.               @current_action.skill_id = 954
  120.            end
  121.          when 6
  122.            if self.state?(957)
  123.               @current_action.skill_id = 59
  124.               else
  125.               @current_action.skill_id = 956
  126.            end
  127.          when 7
  128.            if self.state?(958)
  129.               @current_action.skill_id = 58
  130.               else
  131.               @current_action.skill_id = 957
  132.            end
  133.          when 8
  134.            if self.state?(959)
  135.               @current_action.skill_id = 65
  136.               else
  137.               @current_action.skill_id = 958
  138.            end
  139.          when 9
  140.            if self.state?(960)
  141.               @current_action.skill_id = 60
  142.               else
  143.               @current_action.skill_id = 959
  144.            end
  145.          when 10
  146.            if self.state?(961)
  147.               @current_action.skill_id = 61
  148.               else
  149.               @current_action.skill_id = 960
  150.            end
  151.          when 11
  152.            if self.state?(963)
  153.               @current_action.skill_id = 63
  154.               else
  155.               @current_action.skill_id = 962
  156.            end
  157.          when 12
  158.            if self.state?(964)
  159.               @current_action.skill_id = 64
  160.               else
  161.               @current_action.skill_id = 963
  162.            end
  163.          when 13
  164.            if self.state?(965)
  165.               @current_action.skill_id = 66
  166.               else
  167.               @current_action.skill_id = 964
  168.            end
  169.          when 14
  170.            if self.state?(966)
  171.               @current_action.skill_id = 67
  172.               else
  173.               @current_action.skill_id = 965
  174.            end
  175.          when 15
  176.            if self.state?(967)
  177.               @current_action.skill_id = 68
  178.               else
  179.               @current_action.skill_id = 966
  180.            end
  181.  
  182.  
  183.       end
  184.       # 确认对象
  185.       scope = $data_skills[@current_action.skill_id].scope
  186.       @current_action.target_index = 0
  187.       case scope
  188.  
  189.  
  190.  
  191.  
  192.       when 1 # 敌单体
  193.         # 智商检查
  194.         enemies = $game_troop.enemies.inject([]){|a,b|a<<b if !b.hp0?;a}
  195.        target = $game_troop.random_target_enemy
  196.        @current_action.target_index = target.index
  197.       when 2
  198.         @current_action.target_index = game_party.actors.index(tag) if tag
  199.       when 7
  200.        @current_action.kind = 0
  201.        @current_action.basic = 1
  202.       when 3
  203.         target = $game_troop.random_target_enemy
  204.         @current_action.target_index = target.index
  205.       end
  206.     when 3 # 防御
  207.       @current_action.kind = 0
  208.       @current_action.basic = 1
  209.     end
  210.   end
  211. end
  212. class Scene_Battle
  213.   #--------------------------------------------------------------------------
  214.   # ● 转到输入下一个角色的命令
  215.   #--------------------------------------------------------------------------
  216.   def phase3_next_actor
  217.     # 循环
  218.     begin
  219.       # 角色的明灭效果 OFF
  220.       if @active_battler != nil
  221.         @active_battler.blink = false
  222.       end
  223.       # 最后的角色的情况
  224.       if @actor_index == $game_party.actors.size-1
  225.         # 开始主回合
  226.         start_phase4
  227.         return
  228.       end
  229.       # 推进角色索引
  230.       @actor_index += 1
  231.       @active_battler = $game_party.actors[@actor_index]
  232.       @active_battler.blink = true
  233.     # 如果角色是在无法接受指令的状态就再试
  234.   end until @active_battler.inputable?
  235.     #当角色装备@active_battler.state?(213)状态下就可以开启自动化战斗
  236.     if  Game_Actor::AI.include?(@active_battler.id) or $game_switches[14] == true#@active_battler.state?(213)
  237.    #AI同伴
  238.       @actor_command_window.active = false
  239.       @actor_command_window.visible = false
  240.       @active_battler.make_action
  241.       phase3_next_actor
  242.     else
  243.       # 设置角色的命令窗口
  244.       phase3_setup_command_window
  245.     end
  246.   end
  247.  
  248.   #--------------------------------------------------------------------------
  249.   # ● 转向前一个角色的命令输入
  250.   #--------------------------------------------------------------------------
  251.   def phase3_prior_actor
  252.     # 循环
  253.     begin
  254.       # 角色的明灭效果 OFF
  255.       if @active_battler != nil
  256.         @active_battler.blink = false
  257.       end
  258.       # 最初的角色的情况下
  259.       if @actor_index == 0
  260.         # 开始同伴指令回合
  261.         start_phase2
  262.         return
  263.       end
  264.       # 返回角色索引
  265.       @actor_index -= 1
  266.       @active_battler = $game_party.actors[@actor_index]
  267.       @active_battler.blink = true
  268.     # 如果角色是在无法接受指令的状态就再试
  269.     end until @active_battler.inputable?
  270.     # 设置角色的命令窗口
  271.     if  Game_Actor::AI.include?(@active_battler.id)#@active_battler.id !=1
  272.       #AI同伴
  273.       phase3_prior_actor
  274.     else
  275.       phase3_setup_command_window
  276.     end
  277.   end
  278. end

QQ截图20160120004254.png (6.2 KB, 下载次数: 8)

QQ截图20160120004254.png

Scripts.rar

291.93 KB, 下载次数: 44

点评

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

Lv3.寻梦者

梦石
0
星屑
2744
在线时间
2630 小时
注册时间
2013-1-16
帖子
5657

贵宾

2
发表于 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
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 23:25

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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