#e
#Title[l(JN)]
#Text[Tone]
#Image[.\..\img\Select\Select01.png]
#Player[FREE]
#ScriptVersion[2]
#BackGround[User(.\..\BG\Map1\O2.png,0,-2)]

script_enemy_main {
	let csd = GetCurrentScriptDirectory;
	let Img = [
		csd~"..\img\Tone.png",
		csd~"..\img\System.png",
		];
	let count = 0;
	let Moct = 0;
	let nx=68;
	let ny=72;
	
	@Initialize{
		SetX(GetCenterX);
		SetY(GetCenterY-120);
		
		SetLife(3000);
		SetDamageRate(100,100);
		SetTimer(90);
		SetScore(1000);
		
		LoadData;
		ShotData;
		PlayMusic(BGM[0]);
	}
	
	@MainLoop {
		SetCollisionA(GetX,GetY,20);
		SetCollisionB(GetX,GetY,20);
		MagicCircle(false);
	
		if(count%30==0)
		{ShotA;ShotB;}
		
		alternative(Moct)
		case(120,140){ShotE;}
		case(360,390,410,430){ShotC;}
		case(320,340,440,460){ShotD;}
		
		Move;
		if(Moct==480){Moct=0;}

		count++;Moct++;
		yield;
	}
	
	@DrawLoop {
		if(int(GetSpeedX)==0){BossImg(x[0],y[0],x[1],y[1]);}
		else if(GetSpeedX>0){BossImg(x[1],y[0],x[2],y[1]);}
		else if(GetSpeedX<0){BossImg(x[0],y[1],x[1],y[2]);}
		LifeDraw(3000);
		yield;
	}
	
	@Finalize {
		DeleteData;
	}
	task ShotA{//20.3cmAC
		CreateShot01(GetX-10,GetY-12,5+rand(-2,2),100,23,5);
		CreateShot01(GetX-8,GetY-10,5+rand(-2,2),120,23,5);
		}
	task ShotB{//AC(E) 
		CreateShot01(GetX+7,GetY-14,6+rand(-2,2),80,13,5);
		CreateShot01(GetX+9,GetY-10,6+rand(-2,2),60,13,5);
		}
	task ShotC{//AC()
		CreateShot01(GetX-12,GetY+3,6,120+rand(-5,5),21,2);
		CreateShot01(GetX-12,GetY+5,6,110+rand(-5,5),21,2);
		CreateShot01(GetX-12,GetY+7,6,100+rand(-5,5),21,2);
		}
	task ShotD{//d
			CreateShotA(1,GetX+20,GetY-2,4);
			SetShotDataA(1, 0,3,GetAngleToPlayer,0,0,0, 1);
			SetShotDataA(1,80,3,270+rand(-5,5)  ,0,0,3,61);
			FireShot(1);	
		}
	task ShotE{//
		let angle = 60;
			loop(3){
				CreateShotA(2,GetX+8,GetY+4,8);
				SetShotDataA(2,0,3,angle,0,0,3,71);
				SetShotDataA(2,40,9,GetAngleToPlayer+15,0,0,6,71);
				FireShot(2);
				angle += 15;
			}
		}
	task Move{//224,140
		alternative(Moct)
		case( 60){SetMovePosition01(344,100,4);}
		case(120){SetMovePosition03( 84,340,15,5);}
		case(210,450){SetMovePosition01(224,140,4);}
		case(300){SetMovePosition01(104,100,4);}
		case(360){SetMovePosition03(364,340,15,5);}
	yield;	
	}
#include_function ".\..\txt\ImageObj.txt"
#include_function ".\..\txt\LoadData.txt"
#include_function ".\..\txt\System.txt"
#include_function ".\..\txt\MusicData.txt"
}