#Title[魍魎「西行二連黒死蝶」]
#Text[西行寺幽々子のスペルカード]
#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name="魍魎「西行二連黒死蝶」";
        let csd=GetCurrentScriptDirectory;
        let imgBoss=csd~"img\dot_yuyuko.png";
        let imgEnemy=csd~"img\familiar3.png";
        let angle=0;
	let angleB=0;
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;
	let shotseA=csd~"se\ShotSE02.wav";
	let imgAngle=0;
	let imgALP1=255;
	let imgALP2=0;

    @Initialize {
        CutIn(YOUMU,name,0,0,0,0,0);
        SetLife(900);
        SetTimer(75);
        SetScore(3000000);
        SetDamageRate(20,0);
        SetInvincibility(200);
        SetMovePosition02(GetCenterX(),150,50);
	LoadGraphic(imgBoss);
	LoadGraphic(imgEnemy);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
        TAnime1;
	}

        @MainLoop
        {
	imgAngle+=0.5;
	if(imgAngle>=360){imgAngle=0;}

        if(!OnBomb){
        SetCollisionB(GetX(),GetY(),22);
	SetCollisionA(GetX(),GetY(),22);
        imgALP2=255;
        imgALP1=100;
	SetDamageRate(20,0);
        SetEnemyMarker(true);}
        else {
        imgALP2=0;
        imgALP1=255;
	SetDamageRate(0,0);
	SetEnemyMarker(false);}

	if(count>=200&&count%200==0){
        	SetShotDirectionType(ABSOLUTE);
		PlaySE(shotseA);
		angle=rand(0,360);
		let i=0;
		while(i<10){
        		let shot01=1;
        		CreateShotA(shot01,GetX,GetY,0);
        		SetShotDataA(shot01,0,2,angle+i*36,0,0,0,36);
			let j=20;
			while(j<250){
				let id2=2;
				CreateShotA(id2,0,0,50);
				SetShotDataA(id2,0,0,angle+135+i*36-j/5,0,0,0,226);
				SetShotDataA(id2,50,0,NULL,0,0.01,1.5,226);
				AddShot(j,shot01,id2,0);
				CreateShotA(id2,0,0,50);
				SetShotDataA(id2,0,0,angle+15+i*36-j/5,0,0,0,226);
				SetShotDataA(id2,50,0,NULL,0,0.01,1.5,226);
				AddShot(j,shot01,id2,0);
				j+=20;
				}
        		FireShot(shot01);
			i++;
			}
		}
	if(count>=200&&count%200==100){
        	SetShotDirectionType(ABSOLUTE);
		PlaySE(shotseA);
		angle=rand(0,360);
		let i=0;
		while(i<10){
        		let shot01=1;
        		CreateShotA(shot01,GetX,GetY,0);
        		SetShotDataA(shot01,0,2,angle+i*36,0,0,0,31);
			let j=20;
			while(j<250){
				let id2=2;
				CreateShotA(id2,0,0,50);
				SetShotDataA(id2,0,0,angle-135+i*36+j/5,0,0,0,221);
				SetShotDataA(id2,50,0,NULL,0,0.01,1.5,221);
				AddShot(j,shot01,id2,0);
				CreateShotA(id2,0,0,50);
				SetShotDataA(id2,0,0,angle-15+i*36+j/5,0,0,0,221);
				SetShotDataA(id2,50,0,NULL,0,0.01,1.5,221);
				AddShot(j,shot01,id2,0);
				j+=20;
				}
        		FireShot(shot01);
			i++;
			}
		}
        count++;
        yield;

}
	@Finalize {
		if(!IsTimeOut){
			CreateItem(ITEM_1UP,GetX,GetY);
			loop(50){
				angle=rand(0,360);
				CreateItem(ITEM_SCORE,GetX+cos(angle)*rand(35,45),GetY+sin(angle)*rand(35,45));
			}
		}
		DeleteGraphic(imgBoss);
		DeleteGraphic(imgEnemy);
	}

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgEnemy);
		SetGraphicRect(0,0,192,192);
		SetAlpha(imgALP1);
		SetColor(255,255,255);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,imgAngle);
		DrawGraphic(GetX(),GetY());

		SetTexture(imgBoss);
		SetAlpha(255);
		SetColor(imgALP2,imgALP2,imgALP2);
		SetGraphicAngle(0,0,0);
		SetGraphicRect(128*AnimationC,128*AnimationB,127+128*AnimationC,127+128*AnimationB);
		DrawGraphic(GetX(),GetY());
		}

    	task TAnime1{
			AnimationB=0;
			AnimationC=3;
        		loop(16){yield;}
			AnimationB=1;
        		loop(46){yield;}
			AnimationB=0;
        		loop(8){yield;}
		loop(2){
			AnimationB=0;
			AnimationC=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
			}
			AnimationB=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=0;
			AnimationC=5;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
		}
}