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

Project1

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

[已经解决] 地图技能和援助技能无法使用

[复制链接]

Lv2.观梦者

梦石
0
星屑
740
在线时间
290 小时
注册时间
2013-10-13
帖子
60
跳转到指定楼层
1
发表于 2014-1-1 23:59:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 wly611341 于 2014-1-2 00:01 编辑

我用的战斗系统是ARPG系统 v1.0 ,因为这个脚本是从别的游戏中拷贝出来的,所以他多多少少带了些东西,其中就包括了地图技能,援助技能和危机技能。
但是,这些技能在那个游戏中就可以使用,在我的游戏中就无法使用。也不知道是哪里出了错,求前辈们帮帮忙。不按技能键没事,一按就挂。
会弹出对话框"no implicit conversion from nil to integer"
出错的是这句’ check_event_skill($data_skills[SKILL_IN_MENU[$game_party.actors[1].id-1]], $game_party.actors[1])‘
就是下面代码的第160句
全代码如下
  1. #==============================================================================
  2. # ■ Game_Player
  3. #------------------------------------------------------------------------------
  4. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  5. # 本类的实例请参考 $game_player。
  6. #==============================================================================

  7. class Game_Player < Game_Character
  8.   #--------------------------------------------------------------------------
  9.   # ● 刷新
  10.   #--------------------------------------------------------------------------
  11.   def refresh
  12.       # 同伴人数为 0 的情况下
  13.     if $game_party.actors.size == 0
  14.       # 清除角色的文件名及对像
  15.       @character_name = ""
  16.       @character_hue = 0
  17.       # 分支结束
  18.       return
  19.     end
  20.     # 获取带头的角色
  21.     actor = $game_party.actors[0]
  22.     # 设置角色的文件名及对像
  23.     @character_name = actor.character_name
  24.        if $game_map.battle?
  25.           @need_move_speed = 4 + $game_party.actors[0].agi / 80
  26.         if @need_move_speed > 7
  27.           @need_move_speed = 7
  28.         end
  29.       else
  30.         @need_move_speed = 5
  31.       end
  32.     @character_hue = actor.character_hue
  33.     # 初始化不透明度和合成方式子
  34.     [url=home.php?mod=space&uid=316553]@opacity[/url] = 255
  35.     @blend_type = 0
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 画面更新
  39.   #--------------------------------------------------------------------------
  40.   def update
  41.     # 本地变量记录移动信息
  42.     last_moving = moving?
  43.     # 移动中、事件执行中、强制移动路线中、
  44.     # 信息窗口一个也不显示的时候
  45.     unless moving? or $game_system.map_interpreter.running? or
  46.            @move_route_forcing or $game_temp.message_window_showing or !$game_party.actors[0].movable?
  47.       # 如果方向键被按下、主角就朝那个方向移动
  48.       case Input.dir4
  49.       when 2
  50.         if @move_speed < @need_move_speed
  51.           @move_speed += 1
  52.         end
  53.         move_down
  54.       when 4
  55.         if @move_speed < @need_move_speed
  56.           @move_speed += 1
  57.         end
  58.         move_left
  59.       when 6
  60.         if @move_speed < @need_move_speed
  61.           @move_speed += 1
  62.         end
  63.         move_right
  64.       when 8
  65.         if @move_speed < @need_move_speed
  66.           @move_speed += 1
  67.         end
  68.         move_up
  69.       end
  70.     end   
  71.     # 本地变量记忆坐标
  72.     last_real_x = @real_x
  73.     last_real_y = @real_y
  74.     super
  75.     if Input.dir4 == 0
  76.        @move_speed = 4
  77.     end
  78.     # 角色向下移动、画面上的位置在中央下方的情况下
  79.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  80.       # 画面向下卷动
  81.       $game_map.scroll_down(@real_y - last_real_y)
  82.     end
  83.     # 角色向左移动、画面上的位置在中央左方的情况下
  84.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  85.       # 画面向左卷动
  86.       $game_map.scroll_left(last_real_x - @real_x)
  87.     end
  88.     # 角色向右移动、画面上的位置在中央右方的情况下
  89.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  90.       # 画面向右卷动
  91.       $game_map.scroll_right(@real_x - last_real_x)
  92.     end
  93.     # 角色向上移动、画面上的位置在中央上方的情况下
  94.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  95.       # 画面向上卷动
  96.       $game_map.scroll_up(last_real_y - @real_y)
  97.     end
  98.     # 不在移动中的情况下
  99.     unless moving?
  100.       # 上次主角移动中的情况
  101.       if last_moving
  102.         # 与同位置的事件接触就判定为事件启动
  103.         result = check_event_trigger_here([1,2])
  104.         # 没有可以启动的事件的情况下
  105.         if result == false
  106.           # 调试模式为 ON 并且按下 CTRL 键的情况下除外
  107.           unless $DEBUG and Input.press?(Input::CTRL)
  108.             # 遇敌计数下降
  109.             if @encounter_count > 0
  110.               @encounter_count -= 1
  111.             end
  112.           end
  113.         end
  114.       end
  115.       if @action_wait_count > 0
  116.         @action_wait_count -= 1
  117.       end
  118.       if $game_map.battle?
  119.         if Kboard.trigger?($R_Key_1)
  120.           use_item($data_items[$game_party.set_items[0]])
  121.           return
  122.         end
  123.         if Kboard.trigger?($R_Key_2)
  124.           use_item($data_items[$game_party.set_items[1]])
  125.           return
  126.         end
  127.         if Kboard.trigger?($R_Key_3)
  128.           use_item($data_items[$game_party.set_items[2]])
  129.           return
  130.         end
  131.         if Kboard.trigger?($R_Key_4)
  132.           use_item($data_items[$game_party.set_items[3]])
  133.           return
  134.         end
  135.       end
  136.       # 以下为不能行动的状况
  137.       unless $game_party.actors.size > 0 and $game_party.actors[0].movable?
  138.         return
  139.       end
  140.       # 按下 C 键的情况下
  141.       if Input.trigger?(Input::C)
  142.         # 判定为同位置以及正面的事件启动
  143.         check_event_trigger_here([0])
  144.         check_event_trigger_there([0,1,2])
  145.         if $game_map.battle?
  146.           check_event_attack
  147.         end
  148.         return
  149.       end
  150.       if Kboard.trigger?(MAP_SKILL_KEY)
  151.         check_event_skill($data_skills[SKILL_IN_MAP[$game_party.actors[0].id-1]])
  152.         return
  153.       end
  154.       if $game_map.battle?
  155.         if $game_party.actors[0].hp <= $game_party.actors[0].maxhp / 5 and
  156.           check_event_skill($data_skills[SKILL_IN_DANGER[$game_party.actors[0].id-1]])
  157.         end
  158.         if Kboard.trigger?(MENU_SKILL_KEY)
  159.          check_event_skill($data_skills[SKILL_IN_MENU[$game_party.actors[1].id-1]], $game_party.actors[1])
  160.          return
  161.         end
  162.         if Input.trigger?(Input::X)
  163.           check_event_skill($data_skills[$game_party.actors[0].set_skills[0]])
  164.           return
  165.         end
  166.         if Input.trigger?(Input::Y)
  167.           check_event_skill($data_skills[$game_party.actors[0].set_skills[1]])
  168.           return
  169.         end
  170.         if Input.trigger?(Input::Z)
  171.           check_event_skill($data_skills[$game_party.actors[0].set_skills[2]])
  172.           return
  173.         end
  174.         if Kboard.trigger?($R_Key_F)
  175.           check_event_skill($data_skills[$game_party.actors[0].set_skills[3]])
  176.           return
  177.         end
  178.         if Kboard.trigger?($R_Key_G)
  179.           check_event_skill($data_skills[$game_party.actors[0].set_skills[4]])
  180.           return
  181.         end
  182.         if Kboard.trigger?(JUMP_KEY) and @action_wait_count == 0
  183.           dis = 4
  184.           if $game_party.actors[0].id == 3
  185.             dis = 6
  186.           end
  187.           case @direction
  188.           when 2
  189.             $game_player.jump(0,dis)
  190.           when 4
  191.             $game_player.jump(-dis,0)
  192.           when 6
  193.             $game_player.jump(dis,0)
  194.           when 8
  195.             $game_player.jump(0,-dis)
  196.           end
  197.          @action_wait_count =  45 - $game_party.actors[0].dex / 5 + BASE_ACTION_COUNT
  198.          Audio.se_play(JUMP_SE)
  199.          return
  200.         end
  201.       end
  202.     end
  203.   end
  204. #===========================================================================
  205. # 物品判定
  206. #===========================================================================
  207.   def use_item(item)
  208.       if item.id == 0 or item == nil
  209.         return
  210.       end
  211.       # 如果物品用完的情况下
  212.       if $game_party.item_number(item.id) == 0
  213.         # 演奏冻结 SE
  214.         $game_system.se_play($data_system.buzzer_se)
  215.         return
  216.       end
  217.       # 目标是全体的情况下
  218.       if item.scope == 4
  219.         # 对同伴全体应用物品使用效果
  220.         used = false
  221.         for i in $game_party.actors
  222.           used |= i.item_effect(item)
  223.         end
  224.       end
  225.       # 目标是单体的情况下
  226.       if item.scope == 3
  227.         # 对目标角色应用物品的使用效果
  228.         target = $game_party.actors[0]
  229.         used = target.item_effect(item)
  230.       end
  231.       # 使用物品的情况下
  232.       if used
  233.         # 演奏物品使用时的 SE
  234.         $game_system.se_play(item.menu_se)
  235.         # 消耗品的情况下
  236.         if item.consumable
  237.           # 使用的物品数减 1
  238.           $game_party.lose_item(item.id, 1)
  239.           # 再描绘物品窗口的项目
  240.           $skill_window_need_refresh = true
  241.         end
  242.         # 公共事件 ID 有效的情况下
  243.         if item.common_event_id > 0
  244.           # 预约调用公共事件
  245.           $game_temp.common_event_id = item.common_event_id
  246.           # 切换到地图画面
  247.           return
  248.         end
  249.       end
  250.       # 无法使用物品的情况下
  251.       unless used
  252.         # 演奏冻结 SE
  253.         $game_system.se_play($data_system.buzzer_se)
  254.       end
  255.       return
  256.   end
  257. #===========================================================================
  258. # 技能判定
  259. #===========================================================================
  260.   def check_event_skill(skill,actor = $game_party.actors[0])
  261.     # 事件执行中的情况下
  262.     if skill.id == 0 or skill == nil
  263.       return
  264.     end
  265.     if $game_system.map_interpreter.running?
  266.       return
  267.     end
  268.      unless actor.current_action.forcing
  269.       # 因为 SP 耗尽而无法使用的情况下
  270.       unless actor.skill_can_use?(skill.id)
  271.         return
  272.       end
  273.     end
  274.     if skill.scope == 1
  275.         # 全部事件的循环
  276.       for event in $game_map.events.values
  277.         case @direction
  278.         when 2
  279.           attack_able = (event.y - @y > 0 and event.y - @y < skill.range and (@x - event.x).abs < 2)
  280.         when 4
  281.           attack_able = (@x - event.x > 0 and @x - event.x < skill.range and (@y - event.y).abs < 2)
  282.         when 6
  283.           attack_able = (event.x - @x > 0 and event.x - @x < skill.range and (@y - event.y).abs < 2)
  284.         when 8
  285.           attack_able = (@y - event.y > 0 and @y - event.y < skill.range and (@x - event.x).abs < 2)
  286.         end
  287.         if attack_able
  288.           # 事件坐标与目标一致的情况下
  289.           # 跳跃中以外的情况下、启动判定是正面的事件
  290.           if not event.jumping? and not event.over_trigger? and event.enemy != nil and @action_wait_count <= 0
  291.             if skill.animation1_id == 0
  292.               self.white_flash = true
  293.             else
  294.               self.animation_id = skill.animation1_id
  295.             end
  296.             $game_variables[TARGET] = event.id
  297.             event.damage = event.enemy.skill_effect(actor, skill) if event.enemy.id != 100
  298.             event.damage_pop = event.enemy.id != 100
  299.             event.animation_id = skill.animation2_id
  300.             actor.sp -= skill.sp_cost
  301.             if skill.cold.to_i != 0
  302.               actor.cold[skill.id] = skill.cold.to_i
  303.             end
  304.             @action_wait_count =  45 - $game_party.actors[0].dex / 5 + BASE_ACTION_COUNT
  305.           end
  306.         end
  307.       end
  308.     end
  309.     if skill.scope == 2
  310.     ####============================
  311.     range = skill.range
  312.     ####============================
  313.       # 全部事件的循环
  314.     $target = []
  315.       for event in $game_map.events.values
  316.         # 事件坐标与目标一致的情况下
  317.         # 事件坐标与目标一致的情况下
  318.         sx = @x - event.x
  319.         sy = @y - event.y
  320.         # 求得差的绝对值
  321.         abs_sx = sx > 0 ? sx : -sx
  322.         abs_sy = sy > 0 ? sy : -sy
  323.         # 跳跃中以外的情况下、启动判定是正面的事件
  324.         if not event.jumping? and not event.over_trigger? and event.enemy != nil and @action_wait_count <= 0 and abs_sx + abs_sy < range and event.enemy.id != 100
  325.           if skill.animation1_id == 0
  326.             self.white_flash = true
  327.           else
  328.             self.animation_id = skill.animation1_id
  329.           end
  330.           $target.push(event.id)
  331.           event.damage = event.enemy.skill_effect(actor, skill)
  332.           event.damage_pop = true
  333.           unless $data_animations[skill.animation2_id].position == 3
  334.             event.animation_id = skill.animation2_id
  335.           else
  336.             event.animation_id = 102
  337.           end
  338.         end
  339.       end
  340.       if $target == []
  341.         return
  342.       end
  343.       if $data_animations[skill.animation2_id].position == 3
  344.         self.animation_id = skill.animation2_id
  345.       end
  346.       @action_wait_count =  45 - $game_party.actors[0].dex / 5 + BASE_ACTION_COUNT
  347.       actor.sp -= skill.sp_cost
  348.       if skill.cold.to_i != 0
  349.         actor.cold[skill.id] = skill.cold.to_i
  350.       end
  351.      end
  352.      if skill.scope == 3
  353.       # 全部事件的循环
  354. #      if $game_party.actors[0].hp == $game_party.actors[0].maxhp
  355. #        return
  356. #      end
  357.       if skill.animation1_id == 0
  358.         self.white_flash = true
  359.       else
  360.         self.animation_id = skill.animation1_id
  361.       end
  362.       self.damage = $game_party.actors[0].skill_effect(actor, skill)
  363.       self.damage_pop = true
  364.       self.animation_id = skill.animation2_id if skill.animation2_id != 0
  365.        @action_wait_count =  45 - actor.dex / 5 + BASE_ACTION_COUNT
  366.        actor.sp -= skill.sp_cost
  367.        if skill.cold.to_i != 0
  368.          actor.cold[skill.id] = skill.cold.to_i
  369.        end
  370.      end
  371.      if skill.scope > 3 or skill.scope == 0
  372.       if skill.animation1_id == 0
  373.         self.white_flash = true
  374.       else
  375.         self.animation_id = skill.animation1_id
  376.       end
  377.       self.animation_id = skill.animation1_id
  378.        @action_wait_count =  45 - $game_party.actors[0].dex / 5 + BASE_ACTION_COUNT
  379.        actor.sp -= skill.sp_cost
  380.        if skill.cold.to_i != 0
  381.          actor.cold[skill.id] = skill.cold.to_i
  382.        end
  383.      end
  384.     if skill.common_event_id > 0
  385.       # 设置事件
  386.       common_event = $data_common_events[skill.common_event_id]
  387.       $game_system.map_interpreter.setup(common_event.list, 0)
  388.     end
  389.     $skill_window_need_refresh = true
  390.     return# result
  391.   end
  392. #===========================================================================
  393. # 攻击判定
  394. #===========================================================================
  395.   def check_event_attack
  396.     result = false
  397.     # 事件执行中的情况下
  398.     if $game_system.map_interpreter.running?
  399.       return result
  400.     end
  401.     # 全部事件的循环
  402.     for event in $game_map.events.values
  403.       # 武器射程判定
  404.       attack_able = false
  405.       # 全部事件的循环
  406.       for event in $game_map.events.values
  407.         # 事件坐标与目标一致的情况下
  408.         case @direction
  409.         when 2
  410.           attack_able = (event.y - @y > 0 and event.y - @y < $game_party.actors[0].range and @x == event.x)
  411.         when 4
  412.           attack_able = (@x - event.x > 0 and @x - event.x < $game_party.actors[0].range and @y == event.y)
  413.         when 6
  414.           attack_able = (event.x - @x > 0 and event.x - @x < $game_party.actors[0].range and @y == event.y)
  415.         when 8
  416.           attack_able = (@y - event.y > 0 and @y - event.y < $game_party.actors[0].range and @x == event.x)
  417.         end
  418.         if attack_able
  419.           # 跳跃中以外的情况下、启动判定是正面的事件
  420.           if not event.jumping? and not event.over_trigger? and event.enemy != nil and @action_wait_count <= 0 and event.enemy.id != 100
  421.             make_attack(event)
  422.             result = true
  423.             @action_wait_count =  45 - $game_party.actors[0].dex / 5 + BASE_ACTION_COUNT
  424.           end
  425.         end
  426.       end
  427.     end
  428.     return result
  429.   end
  430.   def make_attack(event)
  431.     # 设置攻击 ID
  432.     if $game_party.actors[0].animation1_id == 0
  433.       self.white_flash = true
  434.     else
  435.       self.animation_id = $game_party.actors[0].animation1_id
  436.     end
  437.      event.damage = event.enemy.attack_effect($game_party.actors[0])
  438.      event.critical = event.enemy.critical
  439.      event.damage_pop = true
  440.      event.animation_id = $game_party.actors[0].animation2_id
  441.      return
  442.   end
  443. end
复制代码
和这个有关的
  1. #==============================================================================
  2. #ARPG系统 v1.0 按键设置
  3. #==============================================================================
  4. #KEY = [$R_Key_A,$R_Key_S,$R_Key_D,$R_Key_F,$R_Key_G]
  5. #招式\物品快捷键的设置,因为全键盘脚本本身的冲突放弃了= =
  6. KEY_NAME = ["A","S","D","F","G"] #招式\物品快捷键的名字
  7. KEY_NAME_2 = ["1", "2", "3", "4"]
  8. MAP_KEY = $R_Key_TAB #小地图是否显示的快捷键的设置
  9. MAP_SKILL_KEY = $R_Key_T #地图技能键
  10. MENU_SKILL_KEY = $R_Key_P #援助技能键

  11. MENU_KEY = [$R_Key_Z,$R_Key_X,$R_Key_C,$R_Key_V] #快速呼叫各场景菜单使用的按键,从左到右分别为menu, equip, status, skill
  12. BASE_TURN_COUNT = 100 #状态的基础持续祯数
  13. BASE_ACTION_COUNT = 10
  14. JUMP_KEY = $R_Key_E
  15. JUMP_SE = "Audio/se/015-jump01"

  16. SKILL_IN_DANGER = [180, 181, 182] #三个主角分别的危机技能
  17. SKILL_IN_MAP = [170, 171, 172] #三个主角分别的地图技能
  18. SKILL_IN_MENU = [175, 176,177] #三个主角分别的援助技能

  19. TARGET = 5 #储存敌人ID的变量

  20. #==============================================================================
  21. #ARPG系统 v1.0 系统说明
  22. #==============================================================================
  23. =begin

  24. 本游戏系统经过大幅度更改,提取并使用其中单个脚本极其有可能出错。
  25. 如果需要其中的插件脚本,请自行上66RPG站点搜索。

  26. 名字前边带!的地图是战斗地图。
  27. 为了方便设置,一个地图如果带!,它下边的地图就全部是战斗地图了。

  28. =end
复制代码
求前辈帮帮忙啊!谢谢!

评分

参与人数 1星屑 +30 收起 理由
︶ㄣ牛排ぶ + 30 手动认可奖励

查看全部评分

Lv2.观梦者

梦石
0
星屑
740
在线时间
290 小时
注册时间
2013-10-13
帖子
60
2
 楼主| 发表于 2014-1-9 20:41:25 | 只看该作者
自己解决了,原来是初始人数的关系啊……
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-4 00:49

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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