-- ガード
function guard_act()
  -- 行動済みフラグ
  local done = false
  local i

  if guard==0 then
    -- 有効
    if check_need_guard() then
      done = true
      key_on(back)
      if is_attack_low(TAG_ENEMY) then
        key_on(ACT_DOWN)
      else
        key_off(ACT_DOWN)
      end
    end
  elseif guard==1 then
    -- 無効
  elseif guard==2 then
    -- 中段
    if check_need_guard() then
      done = true
      key_on(back)
    end
  elseif guard==3 then
    -- 下段
    if check_need_guard() then
      done = true
      key_on(back)
      key_on(ACT_DOWN)
    end
  elseif guard==4 then
    -- 1HIT以降
    if my_act>=50 and my_act<100 then
      done = true
      for i=0, guard_keep_frame do
        if check_need_guard() and is_attack_low(TAG_ENEMY) then
          -- 下段ガード
          key_on(back)
          key_on(ACT_DOWN)
        else
          -- 中段ガード
          key_on(back)
          key_off(ACT_DOWN)
        end
        yield()
      end
    end
  elseif guard==5 then
    -- 1HITのみ
    if my_act>=150 and my_act<180 then
      key_reset()
      yield()
      wait(guard_release_frame)
    else
      if check_need_guard() then
        done = true
        key_on(back)
        if is_attack_low(TAG_ENEMY) then
          key_on(ACT_DOWN)
        else
          key_off(ACT_DOWN)
        end
      end
    end
  end
  
  return done
end
