#e
#Title[Ŕ(JN)]
#Text[Kaga]
#Image[]
#Player[FREE]
#ScriptVersion[2]
#BackGround[User(.\BG\Map1\O4.png,0,-2)]

script_enemy_main {
	let current = GetCurrentScriptDirectory;
	let imgKaga = current~"Kaga.png";
	let count = 0;
	let counter = 0;
	let Moct = 0;
	let vg = -20;
	
	@Initialize { 
		SetX(GetCenterX);
		SetY(GetCenterY-120);
		
		SetLife(4000);
		SetTimer(90); 
		SetScore(3000);
		
		LoadGraphic(imgKaga);
		SetTexture(imgKaga);
		LoadUserShotData(current~".\Weapon\WeaponData.txt"); 
		
		//PlayMusic("BGM\02BossKaga.mp3");
	}
	
	@MainLoop { 
		SetCollisionA(GetX,GetY,15);
		SetCollisionB(GetX,GetY,15);
		
		if(Moct== 80||Moct==100||Moct==120){ShotA;}
		if(Moct==550||Moct==562||Moct==574||Moct==586||Moct==598){ShotB;}
		if(Moct>160&&Moct<245||Moct>450&&Moct<540){
			if(count%15==0){ShotC;}}
		if(Moct>255&&Moct<465||Moct>650&&Moct<740){
			if(count%5==0){ShotD;}}
		Move;
		if(Moct==750){Moct=0;}
		count++;Moct++;
		yield;
	}
	
	@DrawLoop {
		SetColor( 255, 255, 255);
		SetRenderState(ALPHA);
		SetGraphicRect(3,3,67,106);

		if(int(GetSpeedX)==0){SetGraphicRect(3,3,67,106);}
		else if(GetSpeedX>0){
		SetGraphicRect(71,110,135,213);}
		else if(GetSpeedX<0){
		SetGraphicRect(3,110,67,213);}
		
		if((Moct>255&&Moct<460)||(Moct>650&&Moct<740)){
		SetGraphicRect(71,3,135,106);}

		DrawGraphic(GetX,GetY);
	}
	
	@Finalize {
		DeleteGraphic(imgKaga);
		//DeleteMusic("BGM\02BossKaga.mp3");
	}
	task ShotA{//(dA)41 3
		CreateShotA(1,GetX+16,GetY,10);
		SetShotDataA(1, 0,6,GetAngleToPlayer,0,0,0,41);
		SetShotDataA(1, 20,4,GetAngleToPlayer,0,0,0,3);
		FireShot(1);
		}
	task ShotB{//(dB)51 3
		CreateShotA(1,GetX+16,GetY,10);
		SetShotDataA(1,0,4,90,rand(-0.5,0.5),0,0,51);
			let way =-15;
		loop(4){CreateShotA(2,0,0,10);//4way
				SetShotDataA(2, 30,3,way+GetAngleToPlayer,rand(-0.5,0.5),0,0,3);
				AddShot(25,1,2,0);
				SetShotKillTime(1,26);
			way+=15;	
			}
		FireShot(1);
		}
	task ShotC{//C
		let sg =-2;
		let sa = 0;
		loop(5){
			CreateShot01(GetX+10,GetY-sg,4, 90+sa,11,5);
			CreateShot01(GetX+20,GetY-sg,4, 90-sa,11,5);
			sg+=10;
			sa+=10;
			}
		}
	task ShotD{//C
		CreateShot01(GetX+10,GetY+vg,rand(7,10), 90+vg*rand(2,3),11,5);
		CreateShot01(GetX+20,GetY+vg,rand(7,10), 90-vg*rand(2,3),11,5);
		vg+=10;
		if(vg==30){vg= -20;}
		}
	task ShotE{//

		}
	task Move{//224,140
		alternative(Moct)
		case( 90){SetMovePosition03(124,120,15,4);}
		case(180){SetMovePosition03(324,120,15,4);}
		case(270){SetMovePosition03(224,240,15,4);}
		case(470){SetMovePosition03(324,100,15,4);}
		case(560){SetMovePosition03(124,100,15,4);}
		case(650){SetMovePosition03(224,220,15,4);}
	yield;	
	}
}