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

script_enemy_main {
	let current = GetCurrentScriptDirectory();
	let imgTone = current~"Tone.png";
	let count = 0;
	let counter = 0;
	let Moct = 0;
	
	@Initialize { 
		SetX(GetCenterX);
		SetY(GetCenterY-120);
		
		SetLife(3000);
		SetTimer(90); 
		SetScore(3000);
		
		LoadGraphic(imgTone);
		SetTexture(imgTone);
		LoadUserShotData(current~".\WeaponData.txt"); 

		//LoadMusic("bgm\Track02.mp3"); 
		//PlayMusic("bgm\Track02.mp3");
	}
	
	@MainLoop { 
		SetCollisionA(GetX,GetY,12);
		SetCollisionB(GetX,GetY,12);
		
		if(count%30==0)
		{ShotA;ShotB;}
		
		if((Moct==120)||(Moct==140)){ShotE;}
		if((Moct==360)||(Moct==390)||(Moct==410)||(Moct==430)){ShotC;}
		if((Moct==320)||(Moct==340)||(Moct==440)||(Moct==460)){ShotD;}
		


		Move;
		if(Moct==480){Moct=0;}

		count++;Moct++;
		yield;
	}
	
	@DrawLoop {
		SetColor( 255, 255, 255);
		SetRenderState(ALPHA);
		SetGraphicRect(2,2,66,70);
		
		if(int(GetSpeedX)==0){SetGraphicRect(2,2,66,70);}
		else if(GetSpeedX>0){
		SetGraphicRect(69,2,133,70);}
		else if(GetSpeedX<0){
		SetGraphicRect(2,73,66,140);}
		DrawGraphic(GetX,GetY);

	}
	
	@Finalize {
		DeleteGraphic(imgTone);
		//DeleteMusic("bgm\Track02.mp3");
	}
	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
		if(Moct== 60){SetMovePosition01(344,100,4);}
		if(Moct==120){SetMovePosition03( 84,340,15,5);}
		if(Moct==210){SetMovePosition01(224,140,4);}
		if(Moct==300){SetMovePosition01(104,100,4);}
		if(Moct==360){SetMovePosition03(364,340,15,5);}
		if(Moct==450){SetMovePosition01(224,140,4);}
	yield;	
	}

}