#e
#Title[C(LVE)]
#Text[Akagi]
#Image[]
#Player[FREE]
#ScriptVersion[2]
#BackGround[User(.\BG\Map1\O2.png,0,-2)]

script_enemy_main {
	let current = GetCurrentScriptDirectory();
	let imgAkagi = current~"Akagi.png";
	let imgRW = current~"RW.png";
	let count = 0;
	let counter = 0;
	let Moct = 0;
	let vg = 20;
	let RWA=GetCurrentScriptDirectory~"EnemyRWA.txt";
	
	@Initialize { 
		SetX(GetCenterX);
		SetY(GetCenterY-120);
		
		SetLife(5000);
		SetDamageRate(100,0);
		SetTimer(60); 
		SetScore(3000);
		
		LoadGraphic(imgAkagi);
		LoadGraphic(imgRW);
		SetTexture(imgAkagi);
		LoadUserShotData(current~"WeaponData.txt"); 
		
		//PlayMusic("BGM\05BossAkagi.mp3");
	}
	
	@MainLoop { 
		SetCollisionA(GetX,GetY,12);
		SetCollisionB(GetX,GetY,12);
		MagicCircle(false);
		
		alternative(Moct)
		case(80,100,120){ShotA;}
		case(550,556,562,568,574,580,586,592,598){ShotB;}
		
		if(Moct>160&&Moct<245||Moct>450&&Moct<540){
			if(count%5==0){ShotD;}}
		if(Moct>255&&Moct<465||Moct>650&&Moct<740){
			if(count%15==0){ShotC;}
			if(count%10==0){ShotE;}
			}
		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(imgAkagi);
		DeleteGraphic(imgRW);
		DeleteMusic("BGM\05BossAkagi.mp3");
	}
	task ShotA{//(ԐA)42 4
		let way =-50;
		loop(8){
			CreateShotA(1,GetX+16,GetY,10);
			SetShotDataA(1, 0,6,way+GetAngleToPlayer,0,0,0,42);
			SetShotDataA(1, 20,4,GetAngleToPlayer,0,0,0,4);
			FireShot(1);
			way+=15;
			}
		}
	task ShotB{//(ԐB)52 4
		let arw=Obj_Create(OBJ_SHOT);
		Obj_SetX(arw,GetX+16);
		Obj_SetY(arw,GetY);
		Obj_SetSpeed(arw, 4);
		Obj_SetAngle(arw, GetAngleToPlayer);
		ObjShot_SetGraphic(arw,52);
		ObjShot_SetDelay(arw,10);
			loop(30){yield;}
			Obj_Delete(arw);
			loop(1){
				CreateEnemyFromFile(RWA,Obj_GetX(arw),Obj_GetY(arw),0,0,0);
			}
		yield;
	}
	task ShotC{//C
		let sg = 10;
		let sa = 0;
		loop(5){
			CreateShot01(GetX-10,GetY+sg,7, 10-sa,12,5);
			CreateShot01(GetX-20,GetY+sg,7,170+sa,12,5);
			sg-=10;
			sa-=10;
			}
		}
	task ShotD{//C
		CreateShot01(GetX-10,GetY+vg,rand(3,6), 60-vg*rand(2,3),12,5);
		CreateShot01(GetX-20,GetY+vg,rand(3,6),120+vg*rand(2,3),12,5);
		vg-=10;
		if(vg== -30){vg= 20;}
		}
	task ShotE{//Ԑ͔
		CreateEnemyFromFile(RWA,GetClipMinX+rand(30,100),GetClipMinY-30,0,0,0);
		CreateEnemyFromFile(RWA,GetClipMaxX-rand(30,100),GetClipMinY-30,0,0,0);
		}
	task Move{//224,140
		alternative(Moct)
		case( 90){SetMovePosition03(324,120,15,4);}
		case(180){SetMovePosition03(124,120,15,4);}
		case(270,650){SetMovePosition03(224,240,15,4);}
		case(470){SetMovePosition03(124,100,15,4);}
		case(560){SetMovePosition03(324,100,15,4);}
	yield;	
	}
}