= do
  setName "ホーミング弾"

  e <- use self
  zoom _1 $ motionCommon 100 Stay
  ang' <- anglePlayer
  when (e^.counter == 150) $ do
    enemyEffect $ effEnemyAttack 0 (e^.pos)
    enemyEffect $ effEnemyAttack 1 (e^.pos)
    enemyEffect $ effEnemyAttack 2 (e^.pos)
  
  let n = 3 :: Int
  when (e^.counter `mod` 50 == 0 && e^.statePiece == Attack) $ do
    shots $ (flip map) [0..n] $ \i ->
      makeBullet Oval (toEnum $ i*2 `mod` 2) def
        & pos .~ e^.pos & speed .~ 5
        & ang .~ ang' + fromIntegral i*2*pi/fromIntegral n
        & runAuto %~ (go >>)
  
  where
    go = do
      ang' <- anglePlayer
      zoom _1 $ do
        use counter >>= \c -> when (c <= 50) $ speed -= 0.02
        counter += 1

        b <- use ang
        let V2 ax ay = unitV2 ang'; V2 bx by = unitV2 b
        use counter >>= \c -> when (c `mod` 5 == 0) $ do
          ang += case ax*by - ay*bx > 0 of
                   True -> -10*pi/180
                   False -> 10*pi/180

boss4 :: (Given Resource, HasPiece c, HasObject c, HasChara c) =>
         Danmaku c ()
boss4 = do
  setName "ホーミング弾"

  e <- use self
  zoom _1 $ motionCommon 100 Stay
  ang' <- anglePlayer
  when (e^.counter == 150) $ do
    enemyEffect $ effEnemyAttack 0 (e^.pos)
    enemyEffect $ effEnemyAttack 1 (e^.pos)
    enemyEffect $ effEnemyAttack 2 (e^.pos)
  
  let n = 3 :: Int
  when (e^.counter `mod` 50 == 0 && e^.statePiece == Attack) $ do
    shots $ (flip map) [0..n] $ \i ->
      makeBullet Oval (toEnum $ i*2 `mod` 2) def
        & pos .~ e^.pos & speed .~ 5
        & ang .~ ang' + fromIntegral i*2*pi/fromIntegral n
        & runAuto %~ (go >>)
  
  where
    go = do
      ang' <- anglePlayer
      zoom _1 $ do
        use counter >>= \c -> when (c <= 50) $ speed -= 0.02
        counter += 1

        b <- use ang
        let V2 ax ay = unitV2 ang'; V2 bx by = unitV2 b
        use counter >>= \c -> when (c `mod` 5 == 0) $ do
          ang += case ax*by - ay*bx > 0 of
                   True -> -10*pi/180
                   False -> 10*pi/180
boss4 = do
  setName "ホーミング弾"

  e <- use self
  zoom _1 $ motionCommon 100 Stay
  ang' <- anglePlayer
  when (e^.counter == 150) $ do
    enemyEffect $ effEnemyAttack 0 (e^.pos)
    enemyEffect $ effEnemyAttack 1 (e^.pos)
    enemyEffect $ effEnemyAttack 2 (e^.pos)
  
  let n = 3 :: Int
  when (e^.counter `mod` 50 == 0 && e^.statePiece == Attack) $ do
    shots $ (flip map) [0..n] $ \i ->
      makeBullet Oval (toEnum $ i*2 `mod` 2) def
        & pos .~ e^.pos & speed .~ 5
        & ang .~ ang' + fromIntegral i*2*pi/fromIntegral n
        & runAuto %~ (go >>)
  
  where
    go = do
      ang' <- anglePlayer
      zoom _1 $ do
        use counter >>= \c -> when (c <= 50) $ speed -= 0.02
        counter += 1

        b <- use ang
        let V2 ax ay = unitV2 ang'; V2 bx by = unitV2 b
        use counter >>= \c -> when (c `mod` 5 == 0) $ do
          ang += case ax*by - ay*bx > 0 of
                   True -> -10*pi/180
                   False -> 10*pi/180