#TouhouDanmakufu
#Title[SatoriApollo H]
#Text[Nonspell]
#BackGround[User(.\img\stage.png,0,-0.5)]
#PlayLevel[Extra]
#Player[FREE]
#BGM[.\Heartfelt Fancy.mp3]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\Library.dnh"

let SatoriSprite = csd~"img/Satori/SatoriSprite.png";

@Initialize
	{
	LoadUserShotData(csd~"Shot.txt");
	LoadGraphic(SatoriSprite);
	SetLife(8000);
	SetEnemyMarker(true);
	SetDamageRate(10,10);
	SetTimer(121);
	//let a=0;
	SetEffectForZeroLife(60,0,0);	
	SetDurableSpellCard;
	LastSpell;

MainTask;
Vulnerable;
Timer;
IdleSatori;
//MoveAbout;
SetMovePosition03(GetCenterX, GetCenterY - 100, 30,10);
}

task Vulnerable
{
Wait(1200);
SetDamageRate(50,50);
}


task MainTask
{
Wait(120);

loop
	{
	let angle = rand(0,360);
	
	PlaySE(Shot2);

	Wait(20);
	let a=0;
	let t=-1;
	let u=0;
	loop(8000)
		{
		
		
		if(t%360==0){
//ascent(j in 0..2){ascent(i in 0..16){CreateShot02(GetX,GetY,3,22.5*i,-0.2,1,229+j,180*j+30-10*(-1)^i)}};
ascent(i in 0..12)
		{
		//Wait(3);
		}}
		let n=a+2;
		let r=25;
		let R=-80;
		let j=1;
		let s=2.324;
		let S=26.189;
		let v=2.5;
		loop(j){Waiter(GetX+R*cos(t)+r*cos((1+n)*t)+50*cos((1+2*n)*t)+35*cos((1+3*n)*t),
GetY+R*sin(t)+r*sin((1+n)*t)+50*sin((1+2*n)*t)+35*sin((1+3*n)*t),1,110+(1+2*n)*t,56+u,20,380-t);t=t+1/j;};
		
		if(t==360){Wait(60);t=0;a=a+1;u=(u+2)%4;}
		
		
		
		angle += rand(0,360);
		yield;
		}
	Wait(60);
	}
}

task Waiter(x,y,s,a,t,d,w){
		let obj= Obj_Create(OBJ_SHOT);
		let hit=w;
		ObjShot_SetGraphic(obj, t);
		ObjShot_SetDelay(obj,d);
		Obj_SetX(obj, x);
		Obj_SetY(obj, y);
		Obj_SetAngle(obj,a);
		Obj_SetSpeed(obj,0);
		
		while( !Obj_BeDeleted(obj)){
			w--;
			if(w<0){Obj_SetSpeed(obj,s);}
			
			yield;
		}
}

task MoveAbout
{
SetMovePosition02(GetCenterX,GetCenterY-120,60);
MoveSatori;
loop
	{
	Wait(250);
	SetMovePositionRandom01(64,64,1,GetClipMinX+64,GetClipMinY+64,GetClipMaxX-64,GetClipMinY+128);
	MoveSatori;
	Wait(150);
	}
}

@MainLoop
	{
	SetCollisionA(GetX,GetY,16);
	SetCollisionB(GetX,GetY,20);
	yield;
	}



@DrawLoop
	{
	SetAlpha(255);
	if (bossflip==0){SetGraphicScale(1,1);}
	if (bossflip==1){SetGraphicScale(-1,1);}
	SetColor(255,255,255);
	SetGraphicAngle(0,0,0);
	SetTexture(SatoriSprite);
	SetGraphicRect(BR[0],BR[1],BR[2],BR[3]);
	DrawGraphic(GetX,GetY);
	}

@Finalize
	{
	DeleteGraphic(SatoriSprite);
	}

}