
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Chen_AnimeLib.txt";
	
	tex_enemy=filedir~"Chen_Main.png";
	
	@Initialize
	{
		SetLife(3000);
		SetTimer(40);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetRoll(100);
		wait(120);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_B,180);
			let lp=0;
			loop(2)
			{
				let p=rand(0,360);
				let way=36;
				let speed=3;
				let angle=p;
				let gra=[113,115];
				let delay=5;
				while(angle<p+360)
				{
					SetShotDirectionType(ABSOLUTE);
					CreateShotA(1,GetX,GetY,delay);
					SetShotDataA(1,0,speed,angle,0,-speed/60,0,gra[lp%length(gra)]);
					let cnt=60;
					local
					{
						let sp=0;
						let ag=angle+90*r;
						loop(9)
						{
							let speedB=3-sp;
							CreateShotA(2,0,0,delay);
							SetShotDataA(2,0,0,ag,0,speedB/60,speedB,gra[lp%length(gra)]);
							AddShot(cnt,1,2,0);
							sp+=0.15;
							ag+=10*r;
						}
						local
						{
							SetShotDirectionType(PLAYER);
							CreateShotA(2,0,0,delay);
							SetShotDataA(2,0,0,0,0,speed/60,speed,gra[lp%length(gra)]+8);
							AddShot(cnt,1,2,0);
						}
					}
					SetShotKillTime(1,cnt+1);
					FireShot(1);
					SetShotDirectionType(ABSOLUTE);
					angle+=360/way;
				}
				lp++;
				wait(100);
				r=-r;
			}
			SetMovePositionHermite(cenX+rand(-80,80),minY+rand(110,140),0,0,0,0,100);
			SetAction(ACT_MOVE,100);
			SetRoll(100);
			loop(2)
			{
				let way=11;
				let p=atan2(GetPlayerY-GetY,GetPlayerX-GetX);
				let speed=4.5;
				let speedB=1.5;
				let gra=134;
				let delay=10;
				while(speed>=1.5)
				{
					let angle=p;
					while(angle<p+360)
					{
						CreateShotA(1,GetX,GetY,delay);
						SetShotDataA(1,0,0,angle,0,speed/60,speed,gra);
						let cnt=70;
						local
						{
							CreateShotA(2,0,0,0);
							SetShotDataA(2,0,0,angle+180,0,speedB/60,speedB,gra);
							AddShot(cnt,1,2,0);
						}
						FireShot(1);
						angle+=360/way;
					}
					speed/=1.15;
				}
				wait(60);
			}
			wait(40);
		}
	}
	
	task MainThread_Advanced{}
	task MainThread_Unlimited{}
	
}