#TouhouDanmakufu[Single]
#Title[Koishi - Spell #1]
#BackGround[User(.\bgNon.png, 0, 0)]
#BGM[.\music0.mp3]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {

	#include_function ".\Include.~ath"

	task codeInit {
		SetLife(10000); SetTimer(62);
		SetMovePosition03(GetCenterX, GetCenterY/2, 10, 4);
		cutin("Accidental Disclosure "\""Rediscovered Lost Memories"\",imgBossCut,0,0,255,511); SetScore(1000000);
		SetInvincibility(120);
		wait(120);
		attack0;
		attack1;
	}
	task attack0 {
		let x;
		loop {
			let x = 0;
			ascent(i in 0..3) { AncestorsLaser(GetClipMinX+x,-90+8-i*2); AncestorsLaser(GetClipMaxX-x,-90-8+i*2); x+=51; wait(15); }
			wait(75);
			x = 0;
			ascent(i in 0..4) { AncestorsLaser(GetClipMinX+x,-90+1+i*3); AncestorsLaser(GetClipMaxX-x,-90-1-i*3); x+=12; wait(15); }
			wait(75);
		}
	}
	task AncestorsLaser (let x, let angle) {
		PlaySE2("se_shot_laser");
		let obj = Obj_Create(OBJ_SINUATE_LASER);
		Obj_SetPosition(obj, x, GetClipMaxY);
		Obj_SetAngle(obj, angle);
		ObjSinuateLaser_SetLength(obj, 50);
		ObjSinuateLaser_SetWidth(obj, 30);
		Obj_SetSpeed(obj, 2);
		ObjShot_SetGraphic(obj, BLUE02);
		while(!Obj_BeDeleted(obj)) {
			Obj_SetSpeed(obj, Obj_GetSpeed(obj)+1/3);
			if(Obj_GetY(obj) < GetClipMinY) { Obj_SetY(obj, GetClipMinY*2-Obj_GetY(obj)); Obj_SetAngle(obj, -Obj_GetAngle(obj)); Obj_SetSpeed(obj, 2); }
			else if(Obj_GetX(obj) < GetClipMinX) { Obj_SetX(obj, GetClipMinX*2-Obj_GetX(obj)); Obj_SetAngle(obj, 180-Obj_GetAngle(obj)); Obj_SetSpeed(obj, 2); }
			else if(Obj_GetX(obj) > GetClipMaxX) { Obj_SetX(obj, GetClipMaxX*2-Obj_GetX(obj)); Obj_SetAngle(obj, 180-Obj_GetAngle(obj)); Obj_SetSpeed(obj, 2); }
			yield;
		}
	}
	task attack1 {
		let a = rand(0,360); let aa = 0; let b = 0;
		loop {
			PlaySE2("se_shot_tan");
			ascent(i in 0..4) { ascent(j in 0..5) { 
				CreateShotA(0, GetX, GetY, 10);
				SetShotDataA(0, 0, 5, a+i*360/4, 0, -5/45, 0, RED02);
				SetShotDataA(0, 45, 0, b+j*360/5, 0, 2/45, 2, RED01);
				FireShot(0);
			} }
			a+=15*sin(aa); a%=360; aa+=5; aa%=360; b-=2; b%=360;
			wait(15);
		}
	}
}