#Title[無意識「偏執の渦」]
#Text[古明地こいしのスペルカード]
#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name="無意識「偏執の渦」";
        let csd=GetCurrentScriptDirectory;
        let imgBoss=csd~"img\ExKoishi.png";
	let angle=0;
	let Animation=0;
	let Motion=0;
	let shotseA=csd~"se\ShotSE02.wav";

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

        SetLife(700);
        SetTimer(60);
        SetScore(1000000);
        SetDamageRate(20,20);

        SetInvincibility(200);
        SetMovePosition02(GetCenterX(),150,60);
	LoadGraphic(imgBoss);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
	}

        @MainLoop
        {
	if(count>=200&&count%10==0){
		PlaySE(shotseA);
		let i=0;
		while(i<3)
		{
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,2,angle-50+i*120,0,0,0,25);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,2,angle-40+i*120,0,0,0,25);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,2,angle-30+i*120,0,0,0,25);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,2,angle-20+i*120,0,0,0,25);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,2,angle-10+i*120,0,0,0,25);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,2,angle+i*120,0,0,0,25);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,2,angle+10+i*120,0,0,0,25);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,2,angle+20+i*120,0,0,0,25);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,2,angle+30+i*120,0,0,0,25);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,2,angle+40+i*120,0,0,0,25);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,2,angle+50+i*120,0,0,0,25);
			FireShot(shotA);
			i++;
			}
		angle+=5;
		}
	if(count>=300&&count%200==0){
		SetMovePositionRandom01(rand(20,40),rand(20,40),3,GetClipMinX()+150,100,GetClipMaxX()-150,175);
		}
        SetCollisionB(GetX(),GetY(),18);
	SetCollisionA(GetX(),GetY(),18);
        count++;
        }

	@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);
	}

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetAlpha(255);
		SetColor(255,255,255);
		SetGraphicAngle(0,0,0);
	if(Motion==0){
		if(int(GetSpeedX())==0)
		{SetGraphicRect(128,0,255,127);}
		else if(GetSpeedX()>0){SetGraphicRect(384,0,511,127);}
		else if(GetSpeedX()<0){SetGraphicRect(256,0,383,127);}
		}
	if(Motion==1){
		SetGraphicRect(0,0,127,127);
		}
		DrawGraphic(GetX(),GetY());
	}
}