//“Œ•û’e–‹•—
//enemy01
#ScriptVersion[2]

script_enemy_main{

#include_function".\lib\include_std.txt"
#include_function".\system\include_enemy.txt"

let animation_counter = 0;

@Initialize{

	SetDamageRate(100,100);
	system_SetEnemyTexture("TYPE03");
	system_SetEnemyType(4);
	once_system_LoadResource();
	system_SetEnemyLife(10);
	system_SetEnemyWeight(15);
	system_SetEnemyRadius(46);
	once_MainRoutine();
}

@MainLoop{
	SetCollisionA(GetX(), GetY(), 40);
	animation_counter++;
	yield;
}

@DrawLoop{
	if(system_IsInvisible()){return;}
	SetTexture(img_Enemy);
	SetGraphicScale(1.5,1.5);
	system_SetGraphicRect(["SPHERE_MAIN01","SPHERE_MAIN02","SPHERE_MAIN03","SPHERE_MAIN04"][trunc(animation_counter/4)%4]);
	DrawGraphic(GetX(), GetY());
}

@Finalize{

}


task once_MainRoutine(){
	once_system_TaskSphereParameterChecker();
	once_system_TaskSphereHitTest();
	once_system_EnemyMain();
	once_MoveRoutine();
}

task once_MoveRoutine(){

	system_MoveTypeSelect();
	system_StartMove();

	CreateEnemyFromFile(system_GetEnemyPath("TYPE02B"), GetX(), GetY(), 0, 0, [11, 0, 40, 0, 2]);
	CreateEnemyFromFile(system_GetEnemyPath("TYPE02B"), GetX(), GetY(), 0, 0, [11, 0, -40, 0, 2]);
	CreateEnemyFromFile(system_GetEnemyPath("TYPE02B"), GetX(), GetY(), 0, 0, [11, 40, 0, 0, 2]);
	CreateEnemyFromFile(system_GetEnemyPath("TYPE02B"), GetX(), GetY(), 0, 0, [11, -40, 0, 0, 2]);

	ShotRoutine();

	system_StopMove();
	yield;
	system_StartMove();


}//end task

function ShotRoutine(){

	loop(60){yield;}
	ascent(i in 0..2){

		ascent(j in 0..8){
			if(j%2 != 1){
				let id = 0;
				CreateShotA(id, GetX(), GetY(), 10);
				SetShotDataA(id, 0, 1.8, GetAngleToPlayer()+360*(j/8), 0, -0.02, 1.1, RED01);
				SetShotDataA(id, 30, 1.1, NULL, 0, 0, 1.2, NULL);
				FireShot(id);
			}
			//loop(8){yield;}
		}
		loop(40){yield;}
	}
	loop(60){yield;}


}//end task






}

