
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,512];
	
	@Initialize
	{
		point=450;
		SetLife(800);
		SetTimer(50);
		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);
		SetSpellCard("qduʎC@v",39);
		wait(120);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		let lp=0;
		loop
		{
			SetAction(ACT_SHOT_A,90);
			local
			{
				let rd=rand(90,160);
				let sx=[cenX+rd,cenX-rd];
				rd=rand(50,150);
				let sy=minY+rd;
				let col=[1,4];
				ascent(a in 0..2)
				{
					SetFamilier(sx[a],sy,col[a]);
				}
			}
			wait(90);
			loop(3)
			{
				SetAction(ACT_SHOT_B,40);
				let way=60;
				let speed=[3,4,5];
				let gra=115;
				let delay=10;
				let limit=80;
				ascent(a in 0..length(speed))
				{
					let speedB=2.5;
					let angle=0;
					while(angle<360)
					{
						SetShotDirectionType(ABSOLUTE);
						CreateShotA(1,GetX,GetY,delay);
						SetShotDataA(1,0,speed[a],angle,0,-speed[a]/limit,0,gra);
						SetShotDirectionType(PLAYER);
						SetShotDataA(1,limit,NULL,0,0,speedB/limit,speedB,gra);
						FireShot(1);
						angle+=360/way;
					}
					SetShotDirectionType(ABSOLUTE);
					wait(15);
				}
				let wt=120;
				SetMovePositionHermite(cenX+rand(-60,60),minY+rand(110,140),0,0,0,0,wt);
				SetAction(ACT_MOVE,wt);
				SetRoll(wt);
				wait(wt+40);
			}
		}
		
		task SetFamilier(let sx,let sy,let color)
		{
			let f_flg=false;
			Eff;
			wait(90);
			loop(4)
			{
				let px=GetPlayerX;
				let py=GetPlayerY;
				let wide=0;
				loop(12)
				{
					let way=12;
					let p=atan2(py-sy,px-sx);
					let ag=[p,p+(360/way)/2];
					let speed=[3.9,1.5];
					let gra=81+color;
					let delay=0;
					ascent(a in 0..2)
					{
						let angleA=ag[a];
						while(angleA<ag[a]+360)
						{
							if(wide==0)
							{
								CreateShot02(sx,sy,0,angleA,speed[a]/100,speed[a],gra,delay);
							}
							else
							{
								let angleB=angleA-wide/2;
								while(angleB<=angleA+wide/2+1)
								{
									CreateShot02(sx,sy,0,angleB,speed[a]/100,speed[a],gra,delay);
									angleB+=wide;
								}
							}
							angleA+=360/way;
						}
					}
					wide+=1.5;
					wait(2);
				}
				wait(100);
			}
			wait(60);
			f_flg=true;
			task Eff
			{
				SetTargeting(sx,sy,0.5,90,0);
				while(!f_flg)
				{
					let gra=1+color;
					let delay=10;
					SetDelayEffect(sx,sy,gra,delay);
					yield;
				}
			}
		}
	}
	
	task MainThread_Advanced{}
	task MainThread_Unlimited{}
	
}