#e
#Title[HuVg̗v]
#Text[d̃XyJ[h]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name    = "HuVg̗v";
        let csd     = GetCurrentScriptDirectory;
        let imgBoss =csd~"img\dot_daiyousei.png";
	let imgEnemy=csd~"img\familiar2.png";
        let imgSPELL =csd~"img\SPELL_H.png";
	let imgEnemy2=csd~"img\wing.png";
	let big=0;
	let bigX=1;
	let bigY=0;
	let imgAngle=0;
	let imgALP1=255;
	let imgALP2=0;
	let imgALP3=0;
	let imgBACK=0;
	let retune=0;
	let Lock=0;
	let l=1;
	let angle=0;
	let angleA=0;
	let angleB=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;
	let Flag=false;
	let shotseA = csd~"se\ShotSE01.wav";
	let shotseB = csd~"se\Powar.wav";

    @Initialize {
        CutIn(YOUMU,name,0,0,0,0,0);
        SetLife(3500);
        SetTimer(60);
        SetScore(1000000);
        SetDamageRate(100,0);
        SetInvincibility(200);
        SetMovePosition02(cx,120,60);
	LoadGraphic(imgBoss);
	LoadGraphic(imgEnemy);
	LoadGraphic(imgSPELL);
	LoadGraphic(imgEnemy2);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
        TAnime1;
        }

        @MainLoop
        {
	imgAngle+=5;
	if(imgAngle>=360){imgAngle=0;}
	if(retune==0&&big<99){big+=2;}
	if(retune==1&&big>1){big-=2;}
	imgBACK+=4;
	if(imgBACK==448){imgBACK=0;}

	if(count>=50&&count%100==0){
        	retune=1;
		}
	if(count>=50&&count%100==50){
        	retune=0;
		}
	if(count>=150&&count<=199&&Flag==false){bigY+=0.02;}
	if(count==200){Flag=true;}
	if(count%50==0&&Flag==true){
		imgALP3=200;
		bigX=1;
		}
	if(imgALP3>1){
		imgALP3-=4;
		bigX+=0.02
		}

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

	if(count==150){
		PlaySE(shotseB);
		Concentration02(60);
        	angle=200;
		}
	if(count==650){
		PlaySE(shotseB);
		Concentration02(60);
        	angle=-20;
		}
	if(count>=200&&count<=450&&count%50==0){
        	SetShotDirectionType(ABSOLUTE);
		PlaySE(shotseA);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(20)*15,GetY+sin(20)*15,5);
		SetShotDataA(shotA,0,2,20,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
        		SetShotDirectionType(PLAYER);
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),0,0,0,0,50);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(shotA,GetX+cos(160)*15,GetY+sin(160)*15,5);
		SetShotDataA(shotA,0,2,160,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),angle+rand(-10,10),0,0.01,5,53);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	angle-=11;
        	}
	if(count>=200&&count<=500&&count%50==10){
        	SetShotDirectionType(ABSOLUTE);
		PlaySE(shotseA);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(10)*15,GetY+sin(10)*15,5);
		SetShotDataA(shotA,0,2.5,10,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
        		SetShotDirectionType(PLAYER);
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),0,0,0,0,50);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(shotA,GetX+cos(170)*15,GetY+sin(170)*15,5);
		SetShotDataA(shotA,0,2.5,170,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),angle+rand(-10,10),0,0.01,5,53);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	angle-=11;
        	}
	if(count>=200&&count<=500&&count%50==20){
        	SetShotDirectionType(ABSOLUTE);
		PlaySE(shotseA);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(0)*15,GetY+sin(0)*15,5);
		SetShotDataA(shotA,0,3,0,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
        		SetShotDirectionType(PLAYER);
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),0,0,0,0,50);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(shotA,GetX+cos(180)*15,GetY+sin(180)*15,5);
		SetShotDataA(shotA,0,3,180,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),angle+rand(-10,10),0,0.01,5,53);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	angle-=11;
        	}
	if(count>=200&&count<=500&&count%50==30){
        	SetShotDirectionType(ABSOLUTE);
		PlaySE(shotseA);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(350)*15,GetY+sin(350)*15,5);
		SetShotDataA(shotA,0,3.5,350,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
        		SetShotDirectionType(PLAYER);
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),0,0,0,0,50);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(shotA,GetX+cos(190)*15,GetY+sin(190)*15,5);
		SetShotDataA(shotA,0,3.5,190,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),angle+rand(-10,10),0,0.01,5,53);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	angle-=11;
        	}
	if(count>=200&&count<=500&&count%50==40){
		PlaySE(shotseA);
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(340)*15,GetY+sin(340)*15,5);
		SetShotDataA(shotA,0,4,340,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
        		SetShotDirectionType(PLAYER);
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),0,0,0,0,50);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(shotA,GetX+cos(200)*15,GetY+sin(200)*15,5);
		SetShotDataA(shotA,0,4,200,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),angle+rand(-10,10),0,0.01,5,53);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	angle-=11;
        	}
	if(count>=250&&count<=500&&count%50==0){
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(330)*20,GetY+sin(330)*20,5);
		SetShotDataA(shotA,0,4.5,330,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
        		SetShotDirectionType(PLAYER);
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),0,0,0,0,50);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(shotA,GetX+cos(210)*20,GetY+sin(210)*20,5);
		SetShotDataA(shotA,0,4.5,210,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),angle+rand(-10,10),0,0.01,5,53);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	}
	if(count>=700&&count<=950&&count%50==0){
        	SetShotDirectionType(ABSOLUTE);
		PlaySE(shotseA);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(160)*15,GetY+sin(160)*15,5);
		SetShotDataA(shotA,0,2,160,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
        		SetShotDirectionType(PLAYER);
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),0,0,0,0,50);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(shotA,GetX+cos(20)*15,GetY+sin(20)*15,5);
		SetShotDataA(shotA,0,2,20,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),angle+rand(-10,10),0,0.01,5,53);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	angle+=11;
        	}
	if(count>=700&&count<=1000&&count%50==10){
        	SetShotDirectionType(ABSOLUTE);
		PlaySE(shotseA);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(170)*15,GetY+sin(170)*15,5);
		SetShotDataA(shotA,0,2.5,170,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
        		SetShotDirectionType(PLAYER);
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),0,0,0,0,50);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(shotA,GetX+cos(10)*15,GetY+sin(10)*15,5);
		SetShotDataA(shotA,0,2.5,10,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),angle+rand(-10,10),0,0.01,5,53);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	angle+=11;
        	}
	if(count>=700&&count<=1000&&count%50==20){
        	SetShotDirectionType(ABSOLUTE);
		PlaySE(shotseA);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(180)*15,GetY+sin(180)*15,5);
		SetShotDataA(shotA,0,3,180,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
        		SetShotDirectionType(PLAYER);
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),0,0,0,0,50);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(shotA,GetX+cos(0)*15,GetY+sin(0)*15,5);
		SetShotDataA(shotA,0,3,0,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),angle+rand(-10,10),0,0.01,5,53);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	angle+=11;
        	}
	if(count>=700&&count<=1000&&count%50==30){
        	SetShotDirectionType(ABSOLUTE);
		PlaySE(shotseA);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(190)*15,GetY+sin(190)*15,5);
		SetShotDataA(shotA,0,3.5,190,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
        		SetShotDirectionType(PLAYER);
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),0,0,0,0,50);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(shotA,GetX+cos(350)*15,GetY+sin(350)*15,5);
		SetShotDataA(shotA,0,3.5,350,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),angle+rand(-10,10),0,0.01,5,53);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	angle+=11;
        	}
	if(count>=700&&count<=1000&&count%50==40){
        	SetShotDirectionType(ABSOLUTE);
		PlaySE(shotseA);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(200)*15,GetY+sin(200)*15,5);
		SetShotDataA(shotA,0,4,200,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
        		SetShotDirectionType(PLAYER);
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),0,0,0,0,50);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(shotA,GetX+cos(340)*15,GetY+sin(340)*15,5);
		SetShotDataA(shotA,0,4,340,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),angle+rand(-10,10),0,0.01,5,53);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	angle+=11;
        	}
	if(count>=750&&count<=1000&&count%50==0){
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(210)*20,GetY+sin(210)*20,5);
		SetShotDataA(shotA,0,4.5,210,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
        		SetShotDirectionType(PLAYER);
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),0,0,0,0,50);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(shotA,GetX+cos(330)*20,GetY+sin(330)*20,5);
		SetShotDataA(shotA,0,4.5,330,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			angleA=rand(-5,5);
			angleB=rand(-5,5);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(1,2),angle+rand(-10,10),0,0.01,5,53);
			AddShot(j,shotA,ta,0);
			j+=4;
			}
		FireShot(shotA);
        	}
	if(count>=500&&count%500==0){
		TAnime2;
		move;
		}
	if(count==1000){
		count=1;
		}
        count++;
        yield;
        }

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

		SetColor(0,128,255);
		SetGraphicAngle(0,0,-imgAngle);
		DrawGraphic(GetX(),GetY());

		SetTexture(imgEnemy2);
		SetColor(255,255,255);
		SetAlpha(imgALP3);
		SetGraphicRect(0,0,127,127);
		SetGraphicScale(bigX,bigX);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetX(),GetY()-5);

		SetGraphicScale(bigX*2-1,bigX*2-1);
		DrawGraphic(GetX(),GetY()-5);

		SetGraphicScale(bigY,1);
		SetAlpha(200);
		DrawGraphic(GetX(),GetY()-5);

		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetAlpha(imgALP2);
		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());
	}

	@BackGround
	{
		//wi`
		SetGraphicRect(0,0,384,448);
		SetTexture(imgSPELL);
		SetRenderState(ALPHA);
		SetColor(255,255,255);
		SetAlpha(155);
		DrawGraphic(cx,cy-448+imgBACK);

		DrawGraphic(cx,cy+imgBACK);
	}
        
        @Finalize
        {
	loop(100)
	{
		angle=rand(0,360);
		CreateItem(ITEM_SCORE,GetX+cos(angle)*rand(35,50),GetY+sin(angle)*rand(35,50));
	}
		CreateItem(ITEM_BOMB,GetX,GetY);
        } 
	
    	task TAnime1{
			AnimationB=0;
			AnimationC=3;
        		loop(16){yield;}
			AnimationB=1;
        		loop(56){yield;}
			AnimationB=0;
        		loop(8){yield;}
			AnimationB=0;
			AnimationC=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
			AnimationB=3;
        		loop(10){yield;}
			AnimationB=0;
			AnimationC=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
		loop{
			AnimationB=0;
			AnimationC=5;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(310){yield;}

			AnimationB=1;
        		loop(10){yield;}
			AnimationB=0;
        		loop(10){yield;}
			loop(5){
				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(40){yield;}
			AnimationA=0;
        		loop(10){yield;}
		}

task move{
	let wMove = 60;
	moveToPlayer(rand(10,20),rand(-10,10),wMove,GetClipMinX+48,80,GetClipMaxX-48,150);
	wait(wMove);
	}

function moveToPlayer(xMove,yAdd,frame,left,top,right,bottom){
	let x;
	let y;
	if(GetPlayerX<GetX){//vC[EɓG΁AG͍ɓ܂B
		x=GetX-xMove;
		//AAG̈̍[ɂ悤ȂAEɓ܂B
			if(x<left){
				x=GetX+xMove;
 			}
		} else {
		//Ȃ΁AG͉Eɓ܂B
		x=GetX+xMove;
		// AAG̈̉E[Eɂ悤ȂAɓ܂B
		if(right<x){
			x=GetX-xMove;
			}
		}
	y=GetY+yAdd;
	if(y<top) {
		y=top;
	} else if(bottom<y){
		y=bottom;
		}
	SetMovePosition02(x,y,frame);
	}

function wait(w) {
	loop(w){yield;}
	}
}