#Title[呪精「目覚める怨霊、眠る怨霊」]
#Text[火焔猫燐のスペルカード]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name="呪精「目覚める怨霊、眠る怨霊」";
        let csd=GetCurrentScriptDirectory;
        let imgBoss =csd~"img\ExOrin.png";
        let imgBoss2=csd~"img\dot_yousei3.png";
	let angle=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let Motion=0;
	let shotseA=csd~"se\Powar.wav";

    @Initialize {
    CutIn(YOUMU,name,0,0,0,0,0);

        SetLife(800);
        SetTimer(60);
        SetScore(3000000);
        SetDamageRate(20,20);

        SetInvincibility(100);
	LoadGraphic(imgBoss);
	LoadGraphic(imgBoss2);
        SetMovePosition02(cx,175,60);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
    }

        @MainLoop
        {
	if(count==150){
		Motion=1;
		Concentration01(60);
		let i=0;
		while(i<90){
			CreateEnemyFromScript("DOLLA",GetX,GetY,1.5,i*4,1);
			i++;
			}
		}
	if(count>=200&&count%100==0){
		PlaySE(shotseA);
		angle=rand(0,360);
		let i=0;
		while(i<18){
			let shotA=0;
			CreateShotA(shotA,GetX+7,GetY-38,0);
			SetShotDataA(shotA,0,0.5,20*i+angle,0,0.01,1.5,31);
			FireShot(shotA);
			i++;
			}
		}
	SetCollisionB(GetX(),GetY(),18);
	SetCollisionA(GetX(),GetY(),18);
        count++;
        yield;
        }

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetAlpha(255);
		SetColor(255,255,255);
		SetGraphicAngle(0,0,0);
		if(Motion==0){SetGraphicRect(128,0,255,127);}
		else {SetGraphicRect(0,128,127,255);}
		DrawGraphic(GetX(),GetY());
	}

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

script_enemy DOLLA{
        let count=1;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let LockonX=0;
	let LockonY=0;
	let Motion=0;
	let Animation=0;
        let csd=GetCurrentScriptDirectory;
        let imgBoss2=csd~"img\dot_yousei3.png";
	let deathse=csd~"se\DEATH.wav";

    @Initialize {
        SetLife(30);
        SetScore(0);
        TAnime;
	}

	@MainLoop {
	if(count>=50&&count<=100&&count%2==0){
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX+rand(-5,5),GetY+rand(-5,5),20);
		SetShotDataA(shotA,0,0,0,0,0,0,67);
		SetShotKillTime(shotA,0);
		FireShot(shotA);
		}
	if(GetX<20||GetX>428||GetY>460||GetY<20){
		LockonX=(GetPlayerX*10000-GetX*10000+GetX);
		LockonY=(GetPlayerY*10000-GetY*10000+GetY);
		SetMovePosition01(LockonX,LockonY,1.5);
		}
	if(count==1){
		PlaySE(deathse);
		}
	if(count>=100){
		Motion=0;
		SetCollisionB(GetX(),GetY(),10);
		} else {Motion=1;}
	if(count>=200){
		count=rand_int(-10,0);
		}
	count++;
	yield;
	}

        @DrawLoop {
		SetTexture(imgBoss2);
		SetGraphicAngle(0,0,0);
		if(Motion==0){SetAlpha(255);}
		else {SetAlpha(100);}
		if(int(GetSpeedX())==0&&Motion==0)
		{SetGraphicRect(Animation*32,0,31+Animation*32,31);}
		else if(GetSpeedX()>0&&Motion==0){SetGraphicRect(Animation*32+128,32,159+Animation*32,63);}
		else if(GetSpeedX()<0&&Motion==0){SetGraphicRect(Animation*32,32,31+Animation*32,63);}
		else {SetGraphicRect(Animation*32+96,0,127+Animation*32,31);}
		DrawGraphic(GetX(),GetY());
	}

        @Finalize
        {
        	if(GetEnemyLife>0){
		PlaySE(deathse);
		CreateEnemyFromScript("DOLL11",GetX,GetY,0,0,1);
        	}
        } 

    	task TAnime{
		loop{
			Animation=0;
        		loop(10){yield;}
			Animation=1;
        		loop(10){yield;}
			Animation=2;
        		loop(10){yield;}
			}
		}
}