
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Chen_AnimeLib.txt";
	
	tex_enemy=filedir~"Chen_Main.png";
	tex_spellbg=filedir~"Chen_SpellBG.png";
	
	bg_rect=[0,0,512,768];
	
	@Initialize
	{
		point=450;
		SetLife(300);
		SetTimer(50);
		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);
		SetSpellCard("뮫뽸걏뷅밮뽭뜵뿉븨걐",30);
		wait(120);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		let lp=0;
		loop
		{
			let posx=[cenX+((maxX-cenX)*r),cenX+((maxX-cenX)*r)];
			let posy=[cenX,cenX/2,cenX/2,cenX,minY,minY];
			Explosion01(GetX,GetY,5,0.2,60);
			SetMovePosition02(posx[lp%2],posy[lp%6],30);
			SetAction(ACT_MOVE,30);
			SetRoll(30);
			let delay=30;
			let px=GetPlayerX;
			let py=GetPlayerY;
			local
			{
				let way=11;
				let p=atan2(py-GetY,px-GetX);
				let speed=6;
				let speedB=1.5;
				let gra=136;
				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;
				}
			}
			if(lp%3<2)
			{
				loop(15)
				{
					let way=18;
					let speed=GetGapLength(GetX,GetY,px,py)/80;
					let p=atan2(py-GetY,px-GetX);
					let angle=p;
					let gra=[113,118];
					while(angle<p+360)
					{
						CreateShotA(1,GetX,GetY,delay);
						SetShotDataA(1,0,0.1,angle,0,speed/40,speed,gra[lp%2]);
						FireShot(1);
						angle+=360/way;
					}
					delay-=2;
					wait(2);
				}
			}
			else
			{
				let p=atan2(py-GetY,px-GetX);
				let s=0;
				loop(10)
				{
					let way=18;
					let speed=3.5-s;
					let angle=p;
					let gra=132;
					while(angle<p+360)
					{
						CreateShotA(1,GetX,GetY,delay);
						SetShotDataA(1,0,0.1,angle,0,speed/40,speed,gra);
						FireShot(1);
						angle+=360/way;
					}
					s+=0.2;
					wait(3);
				}
			}
			wait(50);
			lp++;
			r=-r;
		}
	}
	
	task MainThread_Advanced{}
	task MainThread_Unlimited{}
	
}