script_enemy_main
{
	let frame=-100;
	#include_function ".\spellcard.txt";
    #include_function ".\..\lib\enemyfunctions.txt"
	#include_function ".\boss1anim.txt";
	
task attack{
	Concentration01(100);
	PlaySE(GetCurrentScriptDirectory~"sound\Charge.wav");
	loop(100){yield;}
	ascent(i in 0..60){
		PlaySE(GetCurrentScriptDirectory~"sound\BulletWave.wav");
		if(GetCommonData("DIFFICULTY")=="EASY"){
			CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 7, atan2(GetPlayerY-GetY-50, GetPlayerX-GetX-40), 201, 10);
			CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 7, atan2(GetPlayerY-GetY-50, GetPlayerX-GetX+40), 201, 10);
			if(i%3==0){
				CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
				CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
			}
		}
		if(GetCommonData("DIFFICULTY")=="NORMAL"){
			CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 7, atan2(GetPlayerY-GetY-50, GetPlayerX-GetX-40), 201, 10);
			CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 7, atan2(GetPlayerY-GetY-50, GetPlayerX-GetX+40), 201, 10);
			if(i%3==0){
				CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
				CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
				CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
				CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
			}
		}
		if(GetCommonData("DIFFICULTY")=="HARD"){
			CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 7, atan2(GetPlayerY-GetY-50, GetPlayerX-GetX-40), 201, 10);
			CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 7, atan2(GetPlayerY-GetY-50, GetPlayerX-GetX+40), 201, 10);
			if(i%2==0){
				CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
				CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
				CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
				CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
			}
		}
		if(GetCommonData("DIFFICULTY")=="LUNATIC"){
			CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 7, atan2(GetPlayerY-GetY-50, GetPlayerX-GetX-40), 201, 10);
			CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 7, atan2(GetPlayerY-GetY-50, GetPlayerX-GetX+40), 201, 10);
			if(i%1==0){
				CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
				CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
				CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
				CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
				CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
				CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 2, rand(0, 359), 201, 0);
			}
		}
		yield;
	}
	loop(100){yield;}
	trapper(1);
	attack;
}
task trapper(num){
	let angle=-45;
	while(angle<85){
		angle+=2;
		CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 7, GetAngleToPlayer-90+angle, 222, 10);
		CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 7, GetAngleToPlayer+90-angle, 222, 10);
		loop(2){yield;}
	}
	if(num>0){trapper(0);}
	loop(65){
		CreateShot01(GetX+40+rand(-5, 5), GetY+50+rand(-5, 5), 7, GetAngleToPlayer-90+angle, 222, 10);
		CreateShot01(GetX-40+rand(-5, 5), GetY+50+rand(-5, 5), 7, GetAngleToPlayer+90-angle, 222, 10);
		loop(2){yield;}
	}
}
		
	
	@Initialize
	{
		SetInvincibility(200);
		LoadUserShotData(GetCurrentScriptDirectory~"supershot.txt");

		EnemyInit(70, 10);
		ClearScreen;
		Atktimer(3600);
	}
	
	@MainLoop
	{
		SetCollisionA(GetX(),GetY(),60);
		SetCollisionB(GetX(),GetY(),40);
		frame++;
		if(frame==0){attack;}
		yield;
}
	
	@Finalize
	{
		CreateEnemyFromFile(GetCurrentScriptDirectory~"boss1_talk02.txt", GetX, GetY, 0, 0, 0);
	}
	
	@DrawLoop
	{
		anim_idle;
	}
}