Project1

标题: 一个关于角色出手判断的问题 [横版战斗系统] [打印本页]

作者: alonescud    时间: 2009-11-3 00:40
标题: 一个关于角色出手判断的问题 [横版战斗系统]
本帖最后由 alonescud 于 2009-11-3 00:44 编辑

脚本里默认已经定义的普通攻击动作,里面主要就是:定义了一套读取武器ICON,附在行走图上进行一系列攻击动作.

----------------------------------------base_action----------------------------------------

"普通攻击"          => [" PREV_MOVING_TARGET","WPN_SWING_V","OBJ_ANIM_WEIGHT",
                          "12","WPN_SWING_VL","OBJ_ANIM_L","One Wpn Only","16",
                          "Can Collapse","FLEE_RESET"],

然后在下面有一个 武器 附带 攻击动画的判定

class Weapon
# when 1 ←这个数字是武器ID
# return
  def base_action
    case @id
    when 1
      return "普通攻击"
    end
    # 上述ID以外的其他全部使用的动作
  return "普通攻击"
end


上述就是case武器的ID, 默认设置是when 1也是调用"普通攻击". 除when 1以外的也是调用"普通攻击"

现在我就想在when 1以后再判断现在是哪名角色进行攻击,然后再return相应的'动作'
例1: 我这样写: (蓝色为新增)  

class Weapon
# when 1 ←这个数字是武器ID
# return
  def base_action
    case @id
    when 1
      return "普通攻击"
   case @battler.id  
  when 2
  return "强烈攻击"  #<- 这个我已经在脚本里写好了

    end
else
    return "普通攻击"
end
end
结果是完全无效,用case @actor_id也是不行的,都是读取"普通攻击", 于是我又换了种方法:
class Game_Actor < Game_Battler
def  base_action
case @battler.id
  when 2
  return "强烈攻击"  #<- 这个我已经在脚本里写好了
    end
else
    return "普通攻击"
end
end


上述方法也是完全没有效果,所以请高人指点迷津.
作者: Flyingpww    时间: 2009-11-3 14:31
class Game_Actor < Game_Battler
   def  base_action
     case id
        when 2
        return "强烈攻击"  #<- 这个我已经在脚本里写好了
    end
    return "普通攻击"
   end
end

在战斗中调用 @active_battler.base_action
作者: alonescud    时间: 2009-11-3 20:56
本帖最后由 alonescud 于 2009-11-3 20:58 编辑

能否再详细点?谢谢.

这里是战斗部分执行攻击动作的代码:
-------------------------------------------------------------------
  def execute_action_attack
    if @active_battler.actor?
      if @active_battler.weapon_id == 0
        action = @active_battler.non_weapon
        immortaling
      else  
       action = $data_weapons[@active_battler.weapon_id].base_action
   
        if $data_weapons[@active_battler.weapon_id].state_set.include?(1)
          for member in $game_party.members + $game_troop.members
            next if member.immortal
            next if member.dead?
            member.dying = true
          end
        else
          immortaling
        end
      end  
    else
      if @active_battler.weapon == 0
        action = @active_battler.base_action
        immortaling
      else
       action = $data_weapons[@active_battler.weapon].base_action
        if $data_weapons[@active_battler.weapon].state_set.include?(1)
          for member in $game_party.members + $game_troop.members
            next if member.immortal
            next if member.dead?
            member.dying = true
          end
        else
          immortaling
        end
      end  
    end
    target_decision
    @spriteset.set_action(@active_battler.actor?, @active_battler.index, action)
    playing_action
  end



--------------------------------------
红字部分就是调用前面定义的base_action.
我是不是要直接修改前面的默认脚本的def? ↓

class Weapon
# when 1 ←这个数字是武器ID
# return
  def base_action
    case @id
    when 1
      return "普通攻击"
    end
    # 上述ID以外的其他全部使用的动作
  return "普通攻击"
end

作者: 123955763    时间: 2009-11-3 22:15
提示: 作者被禁止或删除 内容自动屏蔽
作者: alonescud    时间: 2009-11-3 23:21
目的:
本来所有角色攻击都是调用  "普通攻击"+数据库武器动画.
现在我想变成  同一把武器  因角色不同
分别变成 角色1 --> 普通攻击1 + 数据库武器动画.
             角色2 --> 普通攻击2 + 数据库武器动画.
             角色3 --> 普通攻击3 + 数据库武器动画...
             类推.




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