script_enemy_main {
  #include_function ".\lib\enemy.dnh"
  #include_function ".\lib\fairy_animation.dnh"
  @Initialize {
    InitializeEnemy;
    InitializeFairyAnimation(imgRedFairy);
    SetLife(30);
    Attack;
    Move;
  }
  
  @MainLoop {
    if(Spawned){
      SetCollisionA(GetX, GetY, 16);
      SetCollisionB(GetX, GetY, 12);
    }
    yield;
  }
  
  @DrawLoop {
    if(Spawned){
      DrawFairy;
    }
  }
  
  @Finalize {
    FinalizeEnemy;
  }
  
  task Attack {
    while(!Spawned){ yield; }
    loop {
      ShootLine(GetAngleToPlayer);
      Wait(180);
    }
    
    function ShootLine(angle){
      PlaySE(sfxShot1);
      ascent(i in 0..6){
        WrapObjShot_Initialize(GetX, GetY, 1+i*0.5, angle, 41, 10, 600);
      }
    }
  }
  
  task Move {
    while(!Spawned){ yield; }
    SetWrapSpeed(1.5);
    loop {
      SetWrapAngle(GetAngleToPlayer+5);
      Wait(30);
    }
  }
}