
script_enemy_main{
	let csd		=GetCurrentScriptDirectory;
	let imgBoss	=csd ~ ".\img\dot_yukari.png";
	let shotData	=csd ~ ".\img\shot_all.txt";

	@Initialize {
        	SetLife(1200);
		SetTimer(125);
		InitializeAction();
		LoadUserShotData(shotData);
        	LoadGraphic(imgBoss);
        	Main;
	}
	
	@MainLoop {
		if(GetTimer==10&&counter==0){
			Timer;
			counter++;
		}
		if(OnPlayerMissed){VanishEnemy;}
		yield;
	}

	@DrawLoop {
		SetColor(255,255,255);
		SetGraphicScale(1,1);
		DrawBoss(imgBoss);
	}

	sub standBy {
		SetMovePosition03(224, 240, 10, 7);
		SetAction(ACT_MOVE, 60);
		wait(60);
	}

    	task Main {
        	yield;
		standBy;
		CutIn(YOUMU,"ueE `` v",NULL,0,0,0,0);
		SetScore(80000000);
		SetDurableSpellCard;
		SetAction(ACT_SPELL, 120);
		wait(120);
		attack;
		death;
	}

	task attack{
		CreateEnemyFromScript("FAMI1",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI2",GetX,GetY,0,0,0);
		PlaySE(seShot3);
		wait(560);
		CreateEnemyFromScript("FAMI3",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI4",GetX,GetY,0,0,0);
		PlaySE(seShot3);
		wait(560);
		CreateEnemyFromScript("FAMI5",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI6",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI7",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI8",GetX,GetY,0,0,0);
		PlaySE(seShot3);
		wait(560);
		CreateEnemyFromScript("FAMI9",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI10",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI11",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI12",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI13",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI14",GetX,GetY,0,0,0);
		PlaySE(seShot3);
		wait(560);
		CreateEnemyFromScript("FAMI15",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI16",GetX,GetY,0,0,0);
		PlaySE(seShot3);
		wait(700);
		CreateEnemyFromScript("FAMI17",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI18",GetX,GetY,0,0,0);
		PlaySE(seShot3);
		wait(600);
		CreateEnemyFromScript("FAMI19",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI20",GetX,GetY,0,0,0);
		PlaySE(seShot3);
		wait(660);
		CreateEnemyFromScript("FAMI21",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI22",GetX,GetY,0,0,0);
		PlaySE(seShot3);
		wait(600);
		CreateEnemyFromScript("FAMI23",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI24",GetX,GetY,0,0,0);
		PlaySE(seShot3);
		wait(600);
		CreateEnemyFromScript("FAMI25",GetX,GetY,0,0,0);
		CreateEnemyFromScript("FAMI26",GetX,GetY,0,0,0);
		PlaySE(seShot3);
		wait(760);
		shot;
		PlaySE(seShot3);
	}

	task shot{
		let time=420;
		loop(300){
			shotA(rand(32,416),rand(16,464),0.1,time);
			shotB(rand(32,416),rand(16,464),0.1,time);
			shotC(rand(32,416),rand(16,464),0.1,time);
			shotD(rand(32,416),rand(16,464),0.1,time);
			PlaySE(seShot2);
			wait(1);
			time--;
		}
	}

	task shotA(x,y,speed,time){
		CreateShotA(1,x,y,20);
		SetShotDataA(1,0,0,atan2(cenY-y, cenX-x),0,0,0,89);
		SetShotDataA(1,time,0,NULL,0,0.001,speed,89);
		FireShot(1);
	}

	task shotB(x,y,speed,time){
		CreateShotA(1,x,y,20);
		SetShotDataA(1,0,0,atan2(cenY-y, cenX-x)+180,0,0,0,94);
		SetShotDataA(1,time,0,NULL,0,0.001,speed,94);
		FireShot(1);
	}

	task shotC(x,y,speed,time){
		CreateShotA(1,x,y,20);
		SetShotDataA(1,0,0,rand(0,180),0,0,0,91);
		SetShotDataA(1,time,0,NULL,0,0.001,speed,91);
		FireShot(1);
	}

	task shotD(x,y,speed,time){
		CreateShotA(1,x,y,20);
		SetShotDataA(1,0,0,rand(180,360),0,0,0,92);
		SetShotDataA(1,time,0,NULL,0,0.001,speed,92);
		FireShot(1);
	}

	task death{
		loop{
			if(GetTimer<=0){break;}
			yield;
		}
		SetCommonDataEx("Effect","bossx",GetX);
		SetCommonDataEx("Effect","bossy",GetY);
		SetCommonDataEx("Effect","boss",1);
	}

	@Finalize{
		DeleteGraphic(imgBoss);
	}

	#include_function ".\lib\lib_anime_Yukari.txt"
	#include_function ".\lib\lib_Functions.txt"
}

#include_script ".\familiar_yukari.txt"