Project1

标题: 关于用箭头指定物品使用者的问题 [打印本页]

作者: stella    时间: 2008-2-26 20:51
标题: 关于用箭头指定物品使用者的问题
战斗中使用物品时会用箭头来指定回复类药品的使用者,能不能让处于某状态的角色不能用箭头来指定,当试图指向他时,箭头只会跳到下一个角色,除非解除该状态 [LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: 精灵使者    时间: 2008-2-26 21:48
换句话说,这个角色不能使用物品,也不能被使用是吧?
这个问题到现在似乎还没有好的解决方案。
作者: 禾西    时间: 2008-2-26 23:36
其實很簡單啦……==
只要在腳本裏面改變兩樣東西
1.Arrow_Actor裏面的update方法裏面加多個判斷:
如果角色中了某種狀態,光標自動跳過。
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
    # 光标右
    if Input.repeat?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      @index += 1
#----------------------------
      if $game_party.actors[@index].state?(狀態id)
        @index += 1
      end
#----------------------------
      @index %= $game_party.actors.size
    end
    # 光标左
    if Input.repeat?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      @index += $game_party.actors.size - 1
#----------------------------
      if $game_party.actors[@index].state?(狀態id)
        @index -= 1
      end
#----------------------------
      @index %= $game_party.actors.size
    end
    # 设置活动块坐标
    if self.actor != nil
      self.x = self.actor.screen_x
      self.y = self.actor.screen_y
    end
  end

2。要在scene_battle 3的start_actor_select方法中添加判斷:
如果角色中了某種狀態,光標不初始化在這個角色身上
  #--------------------------------------------------------------------------
  # ● 开始选择角色
  #--------------------------------------------------------------------------
  def start_actor_select
    # 生成角色箭头
    @actor_arrow = Arrow_Actor.new(@spriteset.viewport2)
#----------------------------
    if $game_party.actors[@actor_index].state?(狀態id)
      if @actor_index == 0
        @actor_arrow.index = 1
      elsif @actor_index == $game_party.actors.size - 1
        @actor_arrow.index = @actor_index - 1
      end
    else
      @actor_arrow.index = @actor_index
    end
#----------------------------
    # 关联帮助窗口
    @actor_arrow.help_window = @help_window
    # 无效化角色指令窗口
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end

理論上是這樣做,但是同樣,這樣改變的話,如果這個角色中了這種狀態,不止物品無法選擇他,就連技能也無法選擇他。因爲在默認的戰鬥系統裏面,技能的選擇和物品的選擇調用的是同一個方法。

因此,想要單獨是物品的話,就要按照上面的方法去寫一個新類(包括調用的選擇界面和在scene_battle 3當中的方法)。
在scene_battle 3的update_phase3_item_select方法當中替換start_actor_select語句
麻煩是麻煩一點了。如果不懂腳本的話就很難做得出來(應該==a)
作者: stella    时间: 2008-2-27 20:14
我就是要技能和物品都無法選擇他
作者: stella    时间: 2008-2-27 20:21
但是添加了上述脚本后在战斗中还是能把箭头指到特定状态中的角色,而且再移动一下箭头就出错了{/fd}



作者: 水迭澜    时间: 2008-2-27 20:35
应该加成这样……

     if $game_party.actors[@index]!= nil and $game_party.actors[@index].state?(狀態id)
       @index += 1
     end

下边那个同理~~~
我猜……LZ是要做隐身效果咩?

作者: stella    时间: 2008-2-27 20:40
不是隐身,我用了超出四人的战斗,让超过四人以上的队员处于待命状态,不能用物品也无法参战,但是前面如果有人阵亡就可以用指令换上场去除待命状态
作者: 水迭澜    时间: 2008-2-27 20:42
个人感觉不应该用这个思路。。。这样的话不是还要重新写群体技能的判断咩?
于是LZ加油……
作者: stella    时间: 2008-2-27 20:49
其实别的问题都解决了,也可以正常游戏,就是四人以上的角色是隐藏在画面右端不可见的,如果能用物品选择到就不大美观。。。

又出现这个问题了:


作者: 水迭澜    时间: 2008-2-27 20:50
参考着在scene_battle的相应位置改啊。。。。。。。
就是
if  $game_party.actors[@actor_index]!= nil and $game_party.actors[@actor_index].state?(状态ID) [LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者: stella    时间: 2008-2-27 20:55
我是在 scene_battle 3 的 # 生成角色箭头下改成 if $game_party.actors[@index]!= nil and $game_party.actors[@index].state?(狀態id) 了。。。
结果一使用物品就报错
作者: 水迭澜    时间: 2008-2-27 20:56
因为Scene_Battle没有@index这变量,只有@actor_index。。。。。。。
作者: stella    时间: 2008-2-27 21:00
测试了一下,当待命角色是队伍中的2号和3号角色时,2号可以跳过去,3号就跳不过去了,而且按左键回来就都能选得到。。Arrow_Actor里面也要把 @index 全部改成@actor_index ??
作者: 水迭澜    时间: 2008-2-27 21:02
哦……明白了
等我一阵……= =
作者: 水迭澜    时间: 2008-2-27 21:07
替换默认的Arrow_Actor
那两个state?(2)我自己加的,你可以随便改~

  1. #==============================================================================
  2. # ■ Arrow_Actor
  3. #------------------------------------------------------------------------------
  4. #  选择角色的箭头光标。本类继承 Arrow_Base
  5. # 类。
  6. #==============================================================================

  7. class Arrow_Actor < Arrow_Base
  8.   #--------------------------------------------------------------------------
  9.   # ● 获取光标指向的角色
  10.   #--------------------------------------------------------------------------
  11.   def actor
  12.     return $game_party.actors[@index]
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # ● 刷新画面
  16.   #--------------------------------------------------------------------------
  17.   def update
  18.     super
  19.     # 光标右
  20.     if Input.repeat?(Input::RIGHT)
  21.       $game_system.se_play($data_system.cursor_se)
  22.       @index += 1
  23.       @index %= $game_party.actors.size
  24.       if $game_party.actors[@index]!= nil and $game_party.actors[@index].state?(2)
  25.         @index += 1
  26.         @index %= $game_party.actors.size
  27.      end
  28.     end
  29.     # 光标左
  30.     if Input.repeat?(Input::LEFT)
  31.       $game_system.se_play($data_system.cursor_se)
  32.       @index += $game_party.actors.size - 1
  33.       @index %= $game_party.actors.size
  34.       if $game_party.actors[@index]!= nil and $game_party.actors[@index].state?(2)
  35.         @index  += $game_party.actors.size - 1
  36.         @index %= $game_party.actors.size
  37.       end
  38.     end
  39.     # 设置活动块坐标
  40.     if self.actor != nil
  41.       self.x = self.actor.screen_x
  42.       self.y = self.actor.screen_y
  43.     end
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● 刷新帮助文本
  47.   #--------------------------------------------------------------------------
  48.   def update_help
  49.     # 帮助窗口显示角色的状态
  50.     @help_window.set_actor(self.actor)
  51.   end
  52. end
复制代码


另外,不是@index的问题……LZ等进一步学习类别的概念就明白了
之前出错是因为没有考虑到角色循环的状态而已……
作者: 禾西    时间: 2008-2-27 21:10
以下引用stella于2008-2-27 13:00:33的发言:

测试了一下,当待命角色是队伍中的2号和3号角色时,2号可以跳过去,3号就跳不过去了,而且按左键回来就都能选得到。。Arrow_Actor里面也要把 @index 全部改成@actor_index ??


[本贴由作者于 2008-2-27 13:03:41 最后编辑]

Arrow_Actor當中用@index
Scene_Battle當中用@actor_index
默認的腳本的思維的確很難理解=v=
出現這個情况貌似需要在Arrow_Actor用到一個循環,直到下個角色可以選擇停止==||
在Arrow_Actor當中的if其實只會判斷一次……
另外,我也覺得要實現樓主的效果的話,這個不是個很好的辦法==
作者: stella    时间: 2008-2-27 21:15
这样的话顺选2号跳过3号还是能选中,反过来选3号跳过了2号能选中
作者: 水迭澜    时间: 2008-2-27 21:18
orz……

  1. #==============================================================================
  2. # ■ Arrow_Actor
  3. #------------------------------------------------------------------------------
  4. #  选择角色的箭头光标。本类继承 Arrow_Base
  5. # 类。
  6. #==============================================================================

  7. class Arrow_Actor < Arrow_Base
  8.   #--------------------------------------------------------------------------
  9.   # ● 获取光标指向的角色
  10.   #--------------------------------------------------------------------------
  11.   def actor
  12.     return $game_party.actors[@index]
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # ● 刷新画面
  16.   #--------------------------------------------------------------------------
  17.   def update
  18.     super
  19.     # 光标右
  20.     if Input.repeat?(Input::RIGHT)
  21.       $game_system.se_play($data_system.cursor_se)
  22.       @index += 1
  23.       @index %= $game_party.actors.size
  24.       while $game_party.actors[@index]!= nil and $game_party.actors[@index].state?(2)
  25.           @index += 1
  26.           @index %= $game_party.actors.size
  27.       end
  28.     end
  29.     # 光标左
  30.     if Input.repeat?(Input::LEFT)
  31.       $game_system.se_play($data_system.cursor_se)
  32.       @index += $game_party.actors.size - 1
  33.       @index %= $game_party.actors.size
  34.       while $game_party.actors[@index]!= nil and $game_party.actors[@index].state?(2)
  35.         @index  += $game_party.actors.size - 1
  36.         @index %= $game_party.actors.size
  37.       end
  38.     end
  39.     # 设置活动块坐标
  40.     if self.actor != nil
  41.       self.x = self.actor.screen_x
  42.       self.y = self.actor.screen_y
  43.     end
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● 刷新帮助文本
  47.   #--------------------------------------------------------------------------
  48.   def update_help
  49.     # 帮助窗口显示角色的状态
  50.     @help_window.set_actor(self.actor)
  51.   end
  52. end
复制代码

其实就是把两个if改成while……
作者: 禾西    时间: 2008-2-27 21:23
慢了一步……自删
作者: stella    时间: 2008-2-27 21:26
太感谢了!辛苦。。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1