#Title[お燐通常４]
#Text[火焔猫燐の通常]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let csd     = GetCurrentScriptDirectory;
        let imgBoss =csd~"img\ExOrin.png";
        let imgBoss2=csd~"img\dot_yousei.png";
        let angle=0;
	let shotseA=csd~"se\ShotSE02.wav";
	let shotseB=csd~"se\ShotSE04.wav";

    @Initialize {
        SetLife(1500);
        SetTimer(50);
        SetDamageRate(100,100);
	SetEnemyMarker(true);
        SetMovePosition02(GetCenterX(),150,100);
        SetInvincibility(200);
	SetCommonData("zako",1);
	LoadGraphic(imgBoss);
	LoadGraphic(imgBoss2);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
    }

        @MainLoop
        {
	if(count==150){
		Concentration01(50);
		let i=0;
		while(i<19){
			CreateEnemyFromScript("DOLLA",GetX,GetY,0,i*15,0);
			i++;
			}
		}
	if(count>=200&&count%10==0)
		{
		PlaySE(shotseA);
        	SetShotDirectionType(ABSOLUTE);
		let i=0;
		while(i<15){
        		let shot01 = 1;
        		CreateShotA(shot01,GetX+cos(i*24+angle)*50,GetY+sin(i*24+angle)*50,15);
        		SetShotDataA(shot01,0,4,i*18+angle+5,0,-0.02,1,111);
        		FireShot(shot01);
			i++;
			}
		angle=rand(0,360);
		}
	if(count>=200&&count%10==5)
		{
		PlaySE(shotseA);
        	SetShotDirectionType(ABSOLUTE);
		let i=0;
		while(i<15){
        		let shot01 = 1;
        		CreateShotA(shot01,GetX+cos(i*24+angle)*50,GetY+sin(i*24+angle)*50,15);
        		SetShotDataA(shot01,0,4,i*18+angle-5,0,-0.02,1,111);
        		FireShot(shot01);
			i++;
			}
		angle=rand(0,360);
		}
        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(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);}
		DrawGraphic(GetX(),GetY());
	}

        @Finalize
        {
		DeleteGraphic(imgBoss);
		DeleteGraphic(imgBoss2);
        }
}

script_enemy DOLLA{
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let Animation=0;
        let csd=GetCurrentScriptDirectory;
        let imgBoss2=csd~"img\dot_yousei.png";
	let angle=GetAngle;
	let r=40;
	let imgAlpha=255;
	let deathse=csd~"se\DEATH.wav";
	let Flag=false;
	let shotseA=csd~"se\ShotSE02.wav";
	let zakoA=0;

    @Initialize {
        SetLife(115);
        SetDamageRateEx(100,100,10,10);
        TAnime;
	}

	@MainLoop {
	if(GetLife<=100&&Flag==false){
			PlaySE(deathse);
			Flag=true;
			zakoA=GetCommonData("zako");
			SetCommonData("zako",zakoA+1);
			}
	if(Flag==true){
		imgAlpha=102;
		} else {
		SetCollisionA(GetX(),GetY(),10);
		SetCollisionB(GetX(),GetY(),10);
		}
	if(count%20==0&&Flag==false){
		SetMovePosition02(GetEnemyX+cos(angle)*r,GetEnemyY+sin(angle)*r,20);
		angle-=10;
		r+=40;
		}
	if(r>=150){
		r=150;
		}
	count++;
	yield;
	}

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

        @Finalize
        {
        } 

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