
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Chen_AnimeLib.txt";
	
	tex_enemy=filedir~"Chen_Main.png";
	
	@Initialize
	{
		SetLife(3000);
		SetTimer(42);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard
	{
		yield;
		SetMovePositionHermite(cenX,minY+150,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_A,100);
			
			local
			{
				let px=GetPlayerX;
				let py=GetPlayerY;
				let i=0;
				loop(15)
				{
					let way=12;
					let sx=[GetX+40,GetX-40];
					let gra=[114,115];
					let spd=[3,2];
					let delay=10;
					ascent(a in 0..2)
					{
						let p=atan2(py-GetY,px-sx[a]);
						let ag=[p+i,p-i];
						let speed=[spd[a],spd[a]/2];
						ascent(s in 0..2)
						{
							let angle=ag[a];
							while(angle<ag[a]+360)
							{
								CreateShot01(sx[a],GetY,speed[s],angle,gra[a],delay);
								angle+=360/way;
							}
						}
					}
					wait(4);
					i+=0.8;
				}
				wait(60);
			}
			
			let lp=0;
			loop(2)
			{
				let wt=40;
				SetMovePositionHermite(cenX+160*r,minY+rand(140,160),0,0,0,0,wt);
				SetAction(ACT_MOVE,wt);
				SetRoll(wt);
				loop(4)
				{
					let p=rand(0,360);
					let way=36;
					let speed=3;
					let angle=p;
					let gra=[65,70];
					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
						{
							local
							{
								SetShotDirectionType(PLAYER);
								CreateShotA(2,0,0,delay);
								SetShotDataA(2,0,0,0,0,speed/60,speed,gra[lp%length(gra)]);
								AddShot(cnt,1,2,0);
							}
						}
						SetShotKillTime(1,cnt+1);
						FireShot(1);
						SetShotDirectionType(ABSOLUTE);
						angle+=360/way;
					}
					wait(12);
				}
				SetAction(ACT_SHOT_A,60);
				let p=GetAngleToPlayer;
				let sp=0;
				loop(13)
				{
					let wide=60;
					let way=5;
					
					let speed=4-sp;
					let angleA=p;
					let gra=[73,78];
					let delay=10;
					while(angleA<p+360)
					{
						let angleB=angleA-wide/2;
						while(angleB<=angleA+wide/2+1)
						{
							CreateShot02(GetX,GetY,0,angleB,speed/60,speed,gra[lp%length(gra)],delay);
							angleB+=wide/(way-1);
						}
						angleA+=120;
					}
					wait(2);
					sp+=0.25;
				}
				wait(120);
				
				r=-r;
				lp++;
			}
			SetMovePositionHermite(cenX,minY+150,0,0,0,0,100);
			SetAction(ACT_MOVE,100);
			SetRoll(100);
			wait(120);
			r=-r;
		}
	}
	
	task MainThread_Advanced{}
	task MainThread_Unlimited{}
	
}