
script_enemy_main {
	#include_function ".\lib\lib_anime_mokou.txt"
	#include_function ".\Draw.txt"
	#include_function ".\lib_Functions.txt"
	let imgBoss	=csd ~ "img\dot_mokou.png";
	let imgback	=csd~"img\back2.png";

	@Initialize {
        	SetLife(800);
		SetTimer(70);
		SetScore(1100000);
		SetDamageRate(0, 0);
		InitializeAction();
		LoadUserShotData(shotData);
		LoadGraphic(imgBoss);
		LoadGraphic(imgback);
		Load;
        	CutIn(YOUMU,"su΂̒@-PV- ̓v", NULL, 0, 0, 0, 0);
        	Main;
	}

    	@MainLoop {
        	SetCollisionA(GetX, GetY, 32);
        	SetCollisionB(GetX, GetY, 16);
		if(GetTimer==10&&counter==0){
			Timer;
			counter++;
		}
        	yield;
    	}

	@DrawLoop {
		SetColor(255,255,255);
		SetGraphicScale(1,1);
		SetAlpha(255);
		DrawBoss(imgBoss);
	}

	@BackGround {
		SetColor(100,100,255);
		SetAlpha(150);
		SetTexture(imgback);
		SetGraphicRect(0, 0, 384, 457);
		SetGraphicAngle(0, 0, 0);
		DrawGraphic(224, 240);
		if(drawcount==1){
			DrawHououZ(200, 200, 100, 100);
		}
		if(drawcount>0){
			DrawHouou(200, 200, 100, 100);
			DrawIrusion(GetX, GetY,100,255,100,100);
		}
	}

	sub standBy {
		SetMovePosition03(cenX,cenY-120, 10, 7);
		SetAction(ACT_MOVE, 60);
		wait(120);
	}

   	task Main {
        	yield;
		standBy;
		Charge;
		PlaySE(seCharge1);
		wait(30);
		drawcount++;
		wait(30);
		drawcount++;
		wait(60);
		SetDamageRate(20, 0);
		BombBarrier;
		Att;
	}

	task Att{
		shotA(5);
		shotC;
		SetAction(ACT_MOVE,60);
		SetMovePosition02(388,120,60);
		wait(240);
		loop{
			SetAction(ACT_MOVE,120);
			SetMovePosition02(60,120,120);
			shotA(1);
			wait(30);
			shotA(1);
			wait(30);
			shotA(1);
			wait(30);
			shotA(1);
			wait(30);
			shotA(1);
			wait(180);
			shotA(7);
			shotD;
			wait(300);
			SetAction(ACT_MOVE,120);
			SetMovePosition02(388,120,120);
			shotA(1);
			wait(30);
			shotA(1);
			wait(30);
			shotA(1);
			wait(30);
			shotA(1);
			wait(30);
			shotA(1);
			wait(180);
			shotA(7);
			shotD;
			wait(300);
			yield;			
		}
	}

	task shotA(type){
		let z=0;
		let angle=GetAngleToPlayer;
		let x=GetX;
		let y=GetY;
		while(z<type){
			shotB(z,angle,x,y);
			CreateBardShot(z,angle,x,y);
			z++;
		}
		PlaySE(seShot4);
	}

	task shotB(type,base,x,y){
		let sp=0;
		let ang= [ 0, 30, -30, 60, -60, 90, -90];
		wait(20);
		while(sp<540){
			let sx=rand(-60,60);
			let sy=rand(-30,30);
			CreateShotA(1,x+sp*cos(base+ang[type])+sx,y+sp*sin(base+ang[type])+sy,0);
			SetShotDataA(1,0,0,base+ang[type],0,0,0,49);	
			SetShotDataA(1,140,0,base+ang[type],0,0.1,4,49);
			FireShot(1);
			sp+=4;
			wait(1);
		}
	}

	task shotC{
		let angle=0;
		while(angle<360){
	        	CreateShot01(GetX, GetY, 3, angle+rand(0,10), 65, 0);
			angle+=10;
	    	}
		PlaySE(seShot2);
	}

	task shotD{
		shotC;
		wait(10);
		shotC;
		wait(10);
		shotC;
		wait(10);
		shotC;
		wait(10);
		shotC;
	}

	task CreateBardShot(type,base,x,y){
		let ba=-40;
		let bb=20;
		let bba=0;
		let bc=20;
		let bbc=0;
		let bd=30;
		let bbd=15;
		let be=30;
		let bbe=15;
		let bf=50;
		let bbf=41;
		let bg=50;
		let bbg=41;
		let ang= [ 0, 30, -30, 60, -60, 90, -90];
		loop(4){
			let g=241;
			if(ba==0){
			g=225;
			}
			CreateShot02(x-ba*cos(base+ang[type]), y-ba*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, g, 0);
			ba+=20;
		}
		loop(4){
			CreateShot02(x+bb*sin(base+ang[type])-bba*cos(base+ang[type]), y-bb*cos(base+ang[type])-bba*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, 241, 0);
			bb+=10;
			bba+=5;
		}
		loop(4){
			CreateShot02(x-bc*sin(base+ang[type])-bbc*cos(base+ang[type]), y+bc*cos(base+ang[type])-bbc*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, 241, 0);
			bc+=10;
			bbc+=5;
		}
		loop(4){
			CreateShot02(x+bd*sin(base+ang[type])-bbd*cos(base+ang[type]), y-bd*cos(base+ang[type])-bbd*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, 241, 0);
			bd+=10;
			bbd+=8;
		}
		loop(4){
			CreateShot02(x-be*sin(base+ang[type])-bbe*cos(base+ang[type]), y+be*cos(base+ang[type])-bbe*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, 241, 0);
			be+=10;
			bbe+=8;
		}
		loop(2){
			CreateShot02(x+bf*sin(base+ang[type])-bbf*cos(base+ang[type]), y-bf*cos(base+ang[type])-bbf*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, 241, 0);
			bf+=10;
			bbf+=10;
		}
		loop(2){
			CreateShot02(x-bg*sin(base+ang[type])-bbg*cos(base+ang[type]), y+bg*cos(base+ang[type])-bbg*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, 241, 0);
			bg+=10;
			bbg+=10;
		}	
	}

	@Finalize{
		DeleteGraphic(imgBoss);
		Delete;
		Spell;
	}

}