#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 angleA=0;
        let angleB=0;
        let angleC=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==150){
		Concentration01(60);
		}
	if(count>=200&&GetX>GetPlayerX){
		SetPlayerX(GetPlayerX-0.5);
		} else if(count>=200&&GetX<=GetPlayerX){
		SetPlayerX(GetPlayerX+0.5);
		}
	if(count>=200&&count%4==0){
		PlaySE(shotseA);
        	angle=rand(0,480);
        	angleA=rand(0,480);
        	angleB=rand(-1,1);
        	angleC=rand(-1,1);
		let i=0;
		while(i<3){
			let id=0;
			CreateShotA(1,416,angle,50+i*10);
			SetShotDataA(1,0,1,180,angleB,0,0,66);
			FireShot(1);
			CreateShotA(1,32,angleA,50+i*10);
			SetShotDataA(1,0,1,0,angleC,0,0,66);
			FireShot(1);
			i++;
			}
        	
        	
        	FireShot(1);
        	
        	
        	FireShot(1);
		}
	if(count>=200&&count%200==50){
		TAnime2;
		let i=0;
		while(i<40){
			let id=0;
			CreateShotA(id,GetX,GetY,0);
			SetShotDataA(id,0,1,i*9,0,0,0,227);
			FireShot(id);
			CreateShotA(id,GetX,GetY,0);
			SetShotDataA(id,0,1.5,i*9,0,0,0,227);
			FireShot(id);
			CreateShotA(id,GetX,GetY,0);
			SetShotDataA(id,0,2,i*9,0,0,0,227);
			FireShot(id);
			CreateShotA(id,GetX,GetY,0);
			SetShotDataA(id,0,2.5,i*9,0,0,0,227);
			FireShot(id);
			CreateShotA(id,GetX,GetY,0);
			SetShotDataA(id,0,3,i*9,0,0,0,227);
			FireShot(id);
			i++;
			}
		SetMovePositionRandom01(rand(50,60),rand(20,40),1,GetClipMinX()+150,100,GetClipMaxX()-150,175);
		}
        count++;
        yield;

}
	@Finalize {
		if(!IsTimeOut){
			CreateItem(ITEM_BOMB,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);
		if(int(GetSpeedX())==0)
		{SetGraphicRect(128*AnimationC,128*AnimationB,127+128*AnimationC,127+128*AnimationB);}
		else if(GetSpeedX()>0){SetGraphicRect(256,256+128*AnimationA,383,383+128*AnimationA);}
		else if(GetSpeedX()<0){SetGraphicRect(256,128*AnimationA,383,127+128*AnimationA);}
		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;
        		loop(130){yield;}
		loop{
			AnimationB=0;
			AnimationC=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
			}
		}

    	task TAnime2{
			AnimationA=0;
        		loop(10){yield;}
			AnimationA=1;
        		loop(50){yield;}
			AnimationA=0;
        		loop(10){yield;}
		}
}