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

Project1

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

[已经解决] 战斗测试脚本出错了.......

[复制链接]

Lv1.梦旅人

梦石
0
星屑
609
在线时间
21 小时
注册时间
2012-3-17
帖子
4
跳转到指定楼层
1
发表于 2012-3-23 17:37:57 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
除了我自己原先创造的几个怪可以战斗,其他原来的和新创建的都出这个问题.......求助~~~~
  1. #==============================================================================
  2. # ■ Game_Battler (分割定义 1)
  3. #------------------------------------------------------------------------------
  4. #  处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
  5. # 超级类来使用。
  6. #==============================================================================

  7. class Game_Battler
  8.   #--------------------------------------------------------------------------
  9.   # ● 定义实例变量
  10.   #--------------------------------------------------------------------------
  11.   attr_reader   :battler_name             # 战斗者 文件名
  12.   attr_reader   :battler_hue              # 战斗者 色相
  13.   attr_reader   :hp                       # HP
  14.   attr_reader   :sp                       # SP
  15.   attr_reader   :states                   # 状态
  16.   attr_accessor :hidden                   # 隐藏标志
  17.   attr_accessor :immortal                 # 不死身标志
  18.   attr_accessor :damage_pop               # 显示伤害标志
  19.   attr_accessor :damage                   # 伤害值
  20.   attr_accessor :critical                 # 会心一击标志
  21.   attr_accessor :animation_id             # 动画 ID
  22.   attr_accessor :animation_hit            # 动画 击中标志
  23.   attr_accessor :white_flash              # 白色屏幕闪烁标志
  24.   attr_accessor :blink                    # 闪烁标志
  25.   #--------------------------------------------------------------------------
  26.   # ● 初始化对像
  27.   #--------------------------------------------------------------------------
  28.   def initialize
  29.     @battler_name = ""
  30.     @battler_hue = 0
  31.     @hp = 0
  32.     @sp = 0
  33.     @states = []
  34.     @states_turn = {}
  35.     @maxhp_plus = 0
  36.     @maxsp_plus = 0
  37.     @str_plus = 0
  38.     @dex_plus = 0
  39.     @agi_plus = 0
  40.     @int_plus = 0
  41.     @hidden = false
  42.     @immortal = false
  43.     @damage_pop = false
  44.     @damage = nil
  45.     @critical = false
  46.     @animation_id = 0
  47.     @animation_hit = false
  48.     @white_flash = false
  49.     @blink = false
  50.     @current_action = Game_BattleAction.new
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # ● 获取 MaxHP
  54.   #--------------------------------------------------------------------------
  55.   def maxhp
  56.     n = [[base_maxhp + @maxhp_plus, 1].max, 99999999].min
  57.     for i in @states
  58.       n *= $data_states[i].maxhp_rate / 100.0
  59.     end
  60.     n = [[Integer(n), 1].max, 9999999].min
  61.     return n
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● 获取 MaxSP
  65.   #--------------------------------------------------------------------------
  66.   def maxsp
  67.     n = [[base_maxsp + @maxsp_plus, 0].max, 15000].min
  68.     for i in @states
  69.       n *= $data_states[i].maxsp_rate / 100.0
  70.     end
  71.     n = [[Integer(n), 0].max, 15000].min
  72.     return n
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # ● 获取力量
  76.   #--------------------------------------------------------------------------
  77.   def str
  78.     n = [[base_str + @str_plus, 1].max, 99999].min
  79.     for i in @states
  80.       n *= $data_states[i].str_rate / 100.0
  81.     end
  82.     n = [[Integer(n), 1].max, 99999].min
  83.     return n
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # ● 获取灵巧
  87.   #--------------------------------------------------------------------------
  88.   def dex
  89.     n = [[base_dex + @dex_plus, 1].max, 99999].min
  90.     for i in @states
  91.       n *= $data_states[i].dex_rate / 100.0
  92.     end
  93.     n = [[Integer(n), 1].max, 99999].min
  94.     return n
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● 获取速度
  98.   #--------------------------------------------------------------------------
  99.   def agi
  100.     n = [[base_agi + @agi_plus, 1].max, 99999].min
  101.     for i in @states
  102.       n *= $data_states[i].agi_rate / 100.0
  103.     end
  104.     n = [[Integer(n), 1].max, 9999].min
  105.     return n
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ● 获取魔力
  109.   #--------------------------------------------------------------------------
  110.   def int
  111.     n = [[base_int + @int_plus, 1].max, 99999].min
  112.     for i in @states
  113.       n *= $data_states[i].int_rate / 100.0
  114.     end
  115.     n = [[Integer(n), 1].max, 99999].min
  116.     return n
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● 设置 MaxHP
  120.   #     maxhp : 新的 MaxHP
  121.   #--------------------------------------------------------------------------
  122.   def maxhp=(maxhp)
  123.     @maxhp_plus += maxhp - self.maxhp
  124.     @maxhp_plus = [[@maxhp_plus, -99999].max, 99999].min
  125.     @hp = [@hp, self.maxhp].min
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● 设置 MaxSP
  129.   #     maxsp : 新的 MaxSP
  130.   #--------------------------------------------------------------------------
  131.   def maxsp=(maxsp)
  132.     @maxsp_plus += maxsp - self.maxsp
  133.     @maxsp_plus = [[@maxsp_plus, -9999].max, 9999].min
  134.     @sp = [@sp, self.maxsp].min
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ● 设置力量
  138.   #     str : 新的力量
  139.   #--------------------------------------------------------------------------
  140.   def str=(str)
  141.     @str_plus += str - self.str
  142.     @str_plus = [[@str_plus, -9999].max, 9999].min
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 设置灵巧
  146.   #     dex : 新的灵巧
  147.   #--------------------------------------------------------------------------
  148.   def dex=(dex)
  149.     @dex_plus += dex - self.dex
  150.     @dex_plus = [[@dex_plus, -9999].max, 9999].min
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● 设置速度
  154.   #     agi : 新的速度
  155.   #--------------------------------------------------------------------------
  156.   def agi=(agi)
  157.     @agi_plus += agi - self.agi
  158.     @agi_plus = [[@agi_plus, -9999].max, 9999].min
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● 设置魔力
  162.   #     int : 新的魔力
  163.   #--------------------------------------------------------------------------
  164.   def int=(int)
  165.     @int_plus += int - self.int
  166.     @int_plus = [[@int_plus, -9999].max, 9999].min
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # ● 获取命中率
  170.   #--------------------------------------------------------------------------
  171.   def hit
  172.     n = 100
  173.     for i in @states
  174.       n *= $data_states[i].hit_rate / 100.0
  175.     end
  176.     return Integer(n)
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 获取攻击力
  180.   #--------------------------------------------------------------------------
  181.   def atk
  182.     n = base_atk
  183.     for i in @states
  184.       n *= $data_states[i].atk_rate / 100.0
  185.     end
  186.     return Integer(n)
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● 获取物理防御
  190.   #--------------------------------------------------------------------------
  191.   def pdef
  192.     n = base_pdef
  193.     for i in @states
  194.       n *= $data_states[i].pdef_rate / 100.0
  195.     end
  196.     return Integer(n)
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● 获取魔法防御
  200.   #--------------------------------------------------------------------------
  201.   def mdef
  202.     n = base_mdef
  203.     for i in @states
  204.       n *= $data_states[i].mdef_rate / 100.0
  205.     end
  206.     return Integer(n)
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # ● 获取回避修正
  210.   #--------------------------------------------------------------------------
  211.   def eva
  212.     n = base_eva
  213.     for i in @states
  214.       n += $data_states[i].eva
  215.     end
  216.     return n
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ● 更改 HP
  220.   #     hp : 新的 HP
  221.   #--------------------------------------------------------------------------
  222.   def hp=(hp)
  223.     @hp = [[hp, maxhp].min, 0].max
  224.     # 解除附加的战斗不能状态
  225.     for i in 1...$data_states.size
  226.       if $data_states[i].zero_hp
  227.         if self.dead?
  228.           add_state(i)
  229.         else
  230.           remove_state(i)
  231.         end
  232.       end
  233.     end
  234.   end
  235.   #--------------------------------------------------------------------------
  236.   # ● 更改 SP
  237.   #     sp : 新的 SP
  238.   #--------------------------------------------------------------------------
  239.   def sp=(sp)
  240.     @sp = [[sp, maxsp].min, 0].max
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● 全回复
  244.   #--------------------------------------------------------------------------
  245.   def recover_all
  246.     @hp = maxhp
  247.     @sp = maxsp
  248.     for i in @states.clone
  249.       remove_state(i)
  250.     end
  251.   end
  252.   #--------------------------------------------------------------------------
  253.   # ● 获取当前的动作
  254.   #--------------------------------------------------------------------------
  255.   def current_action
  256.     return @current_action
  257.   end
  258.   def current_action=(v)
  259.     @current_action = v
  260.   end
  261.   #--------------------------------------------------------------------------
  262.   # ● 确定动作速度
  263.   #--------------------------------------------------------------------------
  264.   def make_action_speed
  265.     @current_action.speed = agi + rand(10 + agi / 4)
  266.   end
  267.   #--------------------------------------------------------------------------
  268.   # ● 战斗不能判定
  269.   #--------------------------------------------------------------------------
  270.   def dead?
  271.     return (@hp == 0 and not @immortal)
  272.   end
  273.   #--------------------------------------------------------------------------
  274.   # ● 存在判定
  275.   #--------------------------------------------------------------------------
  276.   def exist?
  277.     return (not @hidden and (@hp > 0 or @immortal))
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # ● HP 0 判定
  281.   #--------------------------------------------------------------------------
  282.   def hp0?
  283.     return (not @hidden and @hp == 0)
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ● 可以输入命令判定
  287.   #--------------------------------------------------------------------------
  288.   def inputable?
  289.     return (not @hidden and restriction <= 1)
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   # ● 可以行动判定
  293.   #--------------------------------------------------------------------------
  294.   def movable?
  295.     return (not @hidden and restriction < 4)
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # ● 防御中判定
  299.   #--------------------------------------------------------------------------
  300.   def guarding?
  301.     return (@current_action.kind == 0 and @current_action.basic == 1)
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # ● 休止中判定
  305.   #--------------------------------------------------------------------------
  306.   def resting?
  307.     return (@current_action.kind == 0 and @current_action.basic == 3)
  308.   end
  309. end
复制代码

Lv3.寻梦者

灌水局大小姐

梦石
0
星屑
3820
在线时间
1690 小时
注册时间
2012-3-10
帖子
2469
2
发表于 2012-3-23 19:04:38 | 只看该作者
  1.     n = [[base_maxhp + @maxhp_plus, 1].max, 99999999].min
  2.     for i in @states
  3.       n *= $data_states[i].maxhp_rate / 100.0
  4.     end
  5.     n = [[Integer(n), 1].max, 9999999].min
复制代码
上面的9999999...是八位数~
而下面这个99999····才7位数.....不用我说了吧  你懂的
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
609
在线时间
21 小时
注册时间
2012-3-17
帖子
4
3
 楼主| 发表于 2012-3-23 19:15:24 | 只看该作者
YeYe. 发表于 2012-3-23 19:04
上面的9999999...是八位数~
而下面这个99999····才7位数.....不用我说了吧  你懂的 ...

话说我把上面改成七位数,一样报错,下面改成八位数,也一样......PS:莫非我没懂......

点评

我需要范例,然后帮你解决掉这问题  发表于 2012-3-23 19:16
回复

使用道具 举报

Lv3.寻梦者

灌水局大小姐

梦石
0
星屑
3820
在线时间
1690 小时
注册时间
2012-3-10
帖子
2469
4
发表于 2012-3-23 19:23:44 | 只看该作者
冰无漪 发表于 2012-3-23 19:15
话说我把上面改成七位数,一样报错,下面改成八位数,也一样......PS:莫非我没懂...... ...
  1.   #--------------------------------------------------------------------------
  2.   # ● 获取速度
  3.   #--------------------------------------------------------------------------
  4.   def agi
  5.     n = [[base_agi + @agi_plus, 1].max, 99999].min
  6.     for i in @states
  7.       n *= $data_states[i].agi_rate / 100.0
  8.     end
  9.     n = [[Integer(n), 1].max, 9999].min
  10.     return n
  11.   end
复制代码
太粗心了,速度上限也改错了·····能否提供范例呀?
这样解决问题太不效率了
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
609
在线时间
21 小时
注册时间
2012-3-17
帖子
4
5
 楼主| 发表于 2012-3-23 19:33:33 | 只看该作者
好了,我自己把脚本重置了,就好了.......看来是脚本冲突了......
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
237 小时
注册时间
2011-7-28
帖子
81
6
发表于 2012-3-23 20:29:00 | 只看该作者
请对游戏进行详细的测试,确定发生此bug的条件,再查看相关代码修正bug
看看网络,数不清的信息扑面而来,你知道了什么是冗余;看看每一天的生活,日复一日,许多的无奈,你理解了什么是缺陷;生命里充满了不可预知,明天将发生什么,谁也不知道,这就是动态。 ...
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-30 17:40

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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