TouhouDanmakufu
#Title[Magical Research "Deep Ecological Bomb"]
#Text[Lunatic]
#Image[]
#PlayLevel[Lunatic]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{

	#include_function ".\lib\lib_anime_marisa.txt"
        #include_function ".\lib\Func.txt"

	@Initialize{
		SetLife(3500);
                SetInvincibility(260);
		SetTimer(65);
		SetScore(15000000);
                SetEnemyMarker(true);
                MagicCircle(true);
                SetMovePosition02(GetCenterX, GetClipMinY + 120, 60);
                LoadUserShotData(shot);
                InitializeAction();
	CutIn(YOUMU,"Magical Research "\""Deep Ecological Bomb"\",cut,0,0,203,360);
	
		mainTask;
	}

	@MainLoop{
		SetCollisionA(GetX,GetY,32);
		SetCollisionB(GetX,GetY,16);
		yield;

	}

	@DrawLoop{

	if(GetSpeedX()>0){SetAction(ACT_MOVE,0)}
	if(GetSpeedX()<0){SetAction(ACT_MOVE,0)}		
	DrawBoss(imgBoss);
        DrawText("Marisa Kirisame", 40, 30, 11, 255);
	}

	@BackGround{
        fondue;
	}

	@Finalize{
        DeleteSE(throw);
	}

	// main task, activates stuff.
	task mainTask{
		yield;
                wait(60);
                MagicC;
                wait(120);
		loop(2){
			ConcentrationEx( 60, 243 );
			ConcentrationEx( 60, 243 );
		}
	        PlaySE(imachargingup);
		fire;
		movement;
	}

	task movement{
		loop{
			wait(25*rand_int(8,14));
			SetMovePositionRandom01(rand(90,120),rand(90,120),7,GetCenterX-120,GetCenterY-120,GetCenterX+120,GetCenterY-90);
		}
	}

	task fire{
		loop{
                        wait(80);
                        CreateEnemyFromScript("BOBOMB01",GetX,GetY,0,0,1);
                        PlaySE(throw);
			wait(200);
                        CreateEnemyFromScript("BOBOMB01",GetX,GetY,0,0,1);
                        PlaySE(throw);
                        wait(40);
                        CreateEnemyFromScript("BOBOMB01",GetX,GetY,0,0,1);
                        PlaySE(throw);
                        wait(40);
                        CreateEnemyFromScript("BOBOMB01",GetX,GetY,0,0,1);
                        PlaySE(throw);
                        wait(40);
                        CreateEnemyFromScript("BOBOMB01",GetX,GetY,0,0,1);
                        PlaySE(throw);
                        wait(200);
                        CreateEnemyFromScript("BOBOMB01",GetX,GetY,0,0,1);
                        PlaySE(throw);
			wait(200);
                        CreateEnemyFromScript("BOBOMB02",GetX,GetY,0,0,1);
                        PlaySE(throw);
                        wait(10);
                        CreateEnemyFromScript("BOBOMB02",GetX,GetY,0,0,1);
                        PlaySE(throw);
                        wait(10);
                        CreateEnemyFromScript("BOBOMB02",GetX,GetY,0,0,1);
                        PlaySE(throw);
                        wait(10);
                        CreateEnemyFromScript("BOBOMB02",GetX,GetY,0,0,1);
                        PlaySE(throw);
                        wait(120);
			yield;
		}
	}

}


////////////////////////////////////////////

script_enemy BOBOMB01 {

	let count=0;
	let imgAngle=0;
	let angle=0;
        let imgBoss2 = GetCurrentScriptDirectory ~ "img\bomb.png";
        let imgBoss2a = GetCurrentScriptDirectory ~ "img\bomba.png";
	let MAnimation=0;
	let shotseA = GetCurrentScriptDirectory ~ "se\016.wav";
        LoadGraphic(imgBoss2);
        LoadGraphic(imgBoss2a);
let blanc=0;
let frame=0;

	@Initialize
	{
		SetLife(30);
		SetMovePosition02(GetPlayerX,GetPlayerY,45);
	}
	
	@MainLoop
	{

frame++;
if(frame>=50){
blanc+=5;
}

	MAnimation-=5;
	if(MAnimation<-360){MAnimation=0;}
	imgAngle+=4;
	if(imgAngle>360){imgAngle=0;}
        	if(count==50)
        	{
        	TShotA;
        	}
        	if(count==130)
        	{
        	VanishEnemy();
        	}
		count++;
	yield;
	}

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgBoss2);
		SetGraphicScale(0.5,0.5);
		SetAlpha(255);
		SetGraphicRect(0,0,43,61);
		SetGraphicAngle(0, 0, MAnimation);
		DrawGraphic(GetX(),GetY());

		SetRenderState(ALPHA);
		SetTexture(imgBoss2a);
		SetGraphicScale(0.5,0.5);
		SetAlpha(blanc);
		SetGraphicRect(0,0,43,61);
		SetGraphicAngle(0, 0, MAnimation);
		DrawGraphic(GetX(),GetY());
	}
        
        @Finalize
        {
        } 

    task TShotA {
        	loop(50){yield;}
		Explosion01(GetX(),GetY(),1/60*255,0.3,60);
		PlaySE(shotseA);
        	shotBomC;
        	loop(5){yield;}
        	shotBomD;
	}

    sub shotBomC {
        	let j = 0;
        	while(j<15)
        	{
        	let i = 0;
        	while(i<20)
        	{
		let id   = 0;
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(id,GetX+cos(angle+24*j)*60,GetY+sin(angle+24*j)*60,0);
		SetShotDataA(id,0,rand(2,2.5),i*18,0,0,0,238);
		SetShotKillTime(id,30);
		FireShot(id);
        	i++;
		}
        	j++;
		}
	yield;
    }
    sub shotBomD {
        	let i = 0;
        	while( i < 40 )
        	{
		let id   = 0;
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(id,GetX,GetY,5);
		SetShotDataA(id,0,rand(1,5),rand(0,360),0,rand(-0.2,-0.01),0.5,240);
		FireShot(id);
        	i++;
		}
	yield;
    }
}


////////////////////////////////////////////

script_enemy BOBOMB02 {
	let count=0;
	let imgAngle=0;
	let angle=0;
        let imgBoss2 = GetCurrentScriptDirectory ~ "img\bomb.png";
        let imgBoss2a = GetCurrentScriptDirectory ~ "img\bomba.png";
	let MAnimation=0;
	let shotseA = GetCurrentScriptDirectory ~ "se\016.wav";
        LoadGraphic(imgBoss2);
        LoadGraphic(imgBoss2a);
let blanc=0;
let frame=0;

	@Initialize
	{
		SetLife(30);
		SetMovePosition02(rand(GetClipMinX(),GetClipMaxX()),rand(GetClipMinY(),GetClipMaxY()),45);
	}
	
	@MainLoop
	{
frame++;
if(frame>=50){
blanc+=5;
}
	MAnimation-=5;
	if(MAnimation<-360){MAnimation=0;}
	imgAngle+=4;
	if(imgAngle>360){imgAngle=0;}
        	if(count==50)
        	{
        	TShotA;
        	}
        	if(count==130)
        	{
        	VanishEnemy();
        	}
		count++;
	yield;
	}

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgBoss2);
		SetGraphicScale(0.5,0.5);
		SetAlpha(255);
		SetGraphicRect(0,0,43,61);
		SetGraphicAngle(0, 0, MAnimation);
		DrawGraphic(GetX(),GetY());

		SetRenderState(ALPHA);
		SetTexture(imgBoss2a);
		SetGraphicScale(0.5,0.5);
		SetAlpha(blanc);
		SetGraphicRect(0,0,43,61);
		SetGraphicAngle(0, 0, MAnimation);
		DrawGraphic(GetX(),GetY());
	}
        
        @Finalize
        {
        } 

    task TShotA {
        	loop(50){yield;}
		Explosion01(GetX(),GetY(),1/60*255,0.3,60);
		PlaySE(shotseA);
        	shotBomC;
        	loop(5){yield;}
        	shotBomD;
	}

    sub shotBomC {
        	let j = 0;
        	while(j<15)
        	{
        	let i = 0;
        	while(i<20)
        	{
		let id   = 0;
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(id,GetX+cos(angle+24*j)*60,GetY+sin(angle+24*j)*60,0);
		SetShotDataA(id,0,rand(2,2.5),i*18,0,0,0,238);
		SetShotKillTime(id,30);
		FireShot(id);
        	i++;
		}
        	j++;
		}
	yield;
    }
    sub shotBomD {
        	let i = 0;
        	while( i < 40 )
        	{
		let id   = 0;
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(id,GetX,GetY,5);
		SetShotDataA(id,0,rand(1,5),rand(0,360),0,rand(-0.2,-0.01),0.5,240);
		FireShot(id);
        	i++;
		}
	yield;
    }
}
