
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Daiyousei_AnimeLib.txt";
	
	tex_enemy=filedir~"DaiyouseiAnother_Main.png";
	
	@Initialize
	{
		SetLife(3500);
		SetTimer(53);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	task MainThread_Standard{}

	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+140,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		wait(120);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_A,200);
			let sp=0;
			let sch=0.3*r;
			let p=rand(0,360);
			loop(8)
			{
				
				let way=24;
				let sx=GetX+7;
				let sy=GetY-30;
				let speed=3-sp;
				let angle=p;
				let gra=150;
				let delay=10;
				while(angle<p+360)
				{
					SetShot(sx,sy,speed,angle,sch,gra,delay);
					angle+=360/way;
				}
//				sch+=0.05*r;
				sp+=0.25;
			}
			wait(80);
			local
			{
				let way=20;
				let p=rand(0,360);
				let sx=GetX+7;
				let sy=GetY-30;
				let speed=[0.7,1.2,2.1];
				let angle=p;
				let gra=53;
				let delay=30;
				while(angle<p+360)
				{
					ascent(a in 0..length(speed))
					{
						CreateShot01(sx,sy,speed[a],angle,gra,delay);
					}
					angle+=360/way;
				}
			}
			wait(40);
			SetMovePositionHermite(cenX+rand(-80,80),minY+rand(130,150),0,0,0,0,100);
			SetAction(ACT_MOVE,100);
			wait(120);
			r=-r;
		}
		task SetShot(let sx,let sy,let speed,let angle,let sch,let gra,let delay)
		{
			let flame=0;
			let leng=0;
			let o=Obj_Create(OBJ_SHOT);
			Obj_SetX(o,sx);
			Obj_SetY(o,sy);
			Obj_SetSpeed(o,0);
			Obj_SetAngle(o,angle);
			ObjShot_SetGraphic(o,gra);
			ObjShot_SetDelay(o,delay);
			Obj_SetAutoDelete(o,false);
//			ObjShot_SetBombResist(o,true);
			
			while(!Obj_BeDeleted(o))
			{
				Obj_SetX(o,sx+leng*cos(angle));
				Obj_SetY(o,sy+leng*sin(angle));
				Obj_SetAngle(o,angle);
				
				if(flame>=delay)
				{
					angle+=sch;
					leng+=speed;
				}
				if(leng>=500||Obj_GetY(o)>=maxY+20){Obj_Delete(o);}
				flame++;
				yield;
			}
		}
	}
	
	
	
	
	task MainThread_Unlimited{}
	
}