#TouhouDanmakufu[Single]
#Title[Koishi - Spell #???]
#Text[Please do not judge.]
#BackGround[User(.\bgNon.png, 0, 0)]
#BGM[.\music0.mp3]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {

	#include_function ".\Include.~ath"

	task codeInit {
		SetLife(15000); SetTimer(152);
		SetMovePosition03(GetCenterX, GetCenterY/2, 10, 4);
		cutin("Artificial Beauty "\""Subconscious Hell"\",imgBossCut,0,0,255,511); SetScore(100000000);
		SetInvincibility(120);
		wait(120);
		SetShotAutoDeleteClip(30, 30, 30, 30);
		attack1;
	}
	task attack1 {
		task Rose(angle, arg) {
			let obj = Obj_Create(OBJ_SHOT);
			Obj_SetPosition(obj, GetX, GetY);
			Obj_SetSpeed(obj, 3/2); Obj_SetAngle(obj, angle);
			ObjShot_SetBombResist(obj, true);
			while(!Obj_BeDeleted(obj)) {
				let ang = [b-Obj_GetAngle(obj)%180, Obj_GetAngle(obj)%180-c][arg];
				while(ang>90) { ang-=180; }
				if((|ang|) < 20) {
					ObjShot_SetGraphic(obj, [RED35, BLUE35][arg]);
				} else { ObjShot_SetGraphic(obj, [RED01, BLUE01][arg]); }
				yield;
			}
		}
		let a = 0;
		let b = 0;
		let c = 90;
		while(GetLife > 15000-3750*1 && GetTimer > 120) {
			PlaySE2("se_shot_kira");
			ascent(i in 0..4) { ascent(j in 0..12) { Rose(a+j*360/12+i*(360/12)/4, floor(i/2)%2); } }
			a+=29/pi; a%=360;
			loop(30) { b+=3/4; b%=360; c-=3/4; c%=360; wait(1); }
		}
		PlaySE2("se_shot_tan"); DeleteEnemyShotToItemInCircle(ALL, GetX, GetY, 1000);
		SetInvincibility(60); wait(60); attack2;
	}
	task attack2 {
		task Rose(angle, arg) {
			let obj = Obj_Create(OBJ_SHOT);
			Obj_SetPosition(obj, GetX, GetY);
			Obj_SetSpeed(obj, 3/2); Obj_SetAngle(obj, angle);
			ObjShot_SetBombResist(obj, true);
			while(!Obj_BeDeleted(obj)) {
				let ang = [b-Obj_GetAngle(obj)%120, Obj_GetAngle(obj)%120-c][arg];
				while(ang>60) { ang-=120; }
				if((|ang|) < 10) {
					ObjShot_SetGraphic(obj, [RED35, BLUE35][arg]);
				} else { ObjShot_SetGraphic(obj, [RED01, BLUE01][arg]); }
				yield;
			}
		}
		let a = 0;
		let b = 0;
		let c = 30;
		while(GetLife > 15000-3750*2 && GetTimer > 90) {
			PlaySE2("se_shot_kira");
			ascent(i in 0..4) { ascent(j in 0..6) { Rose(a+j*360/6+i*(360/6)/4, floor(i/2)%2); } }
			a+=59/pi; a%=360;
			loop(15) { b+=3/4; b%=360; c-=3/4; c%=360; wait(1); }
		}
		PlaySE2("se_shot_tan"); DeleteEnemyShotToItemInCircle(ALL, GetX, GetY, 1000);
		SetInvincibility(60); wait(60); attack3;
	}
	task attack3 {
		task Rose(angle, arg) {
			let obj = Obj_Create(OBJ_SHOT);
			Obj_SetPosition(obj, GetX, GetY);
			Obj_SetSpeed(obj, 3/2); Obj_SetAngle(obj, angle);
			ObjShot_SetBombResist(obj, true);
			while(!Obj_BeDeleted(obj)) {
				let ang = [b-Obj_GetAngle(obj)%180, Obj_GetAngle(obj)%180-c][arg];
				while(ang>90) { ang-=180; }
				if((|ang|) < 30) {
					ObjShot_SetGraphic(obj, [RED35, BLUE35][arg]);
				} else { ObjShot_SetGraphic(obj, [RED01, BLUE01][arg]); }
				yield;
			}
		}
		let a = 0;
		let b = 0;
		let c = 90;
		while(GetLife > 15000-3750*3 && GetTimer > 60) {
			PlaySE2("se_shot_kira");
			ascent(i in 0..12) { ascent(j in 0..1) { Rose(a+j*360/2+i*(360/12)/1, floor((i))%2); } }
			a+=11; a%=360;
			loop(10) { b+=1; b%=360; c-=1; c%=360; wait(1); }
		}
		PlaySE2("se_shot_tan"); DeleteEnemyShotToItemInCircle(ALL, GetX, GetY, 1000);
		SetInvincibility(60); wait(60); attack4;
	}
	task attack4 {
		task Rose(angle, arg) {
			let obj = Obj_Create(OBJ_SHOT);
			Obj_SetPosition(obj, GetX, GetY);
			Obj_SetSpeed(obj, 3/2); Obj_SetAngle(obj, angle);
			ObjShot_SetBombResist(obj, true);
			while(!Obj_BeDeleted(obj)) {
				let ang = b-Obj_GetAngle(obj)%180;
				while(ang>90) { ang-=180; }
				if((|ang|) < 45) {
					ObjShot_SetGraphic(obj, [RED35, BLUE35][arg]);
				} else { ObjShot_SetGraphic(obj, [RED01, BLUE01][arg]); }
				yield;
			}
		}
		let a = 0;
		let b = 0;
		let c = 45;
		while(GetLife > 15000-3750*4 && GetTimer > 30) {
			PlaySE2("se_shot_kira");
			ascent(i in 0..11) {
				Rose(a+i*360/11, 0);
				Rose(-a+i*360/11, 1);
			}
			a+=6; a%=360;
			loop(10) { b+=pi/3; b%=360; c-=pi/3; c%=360; wait(1); }
		}
		PlaySE2("se_shot_tan"); DeleteEnemyShotToItemInCircle(ALL, GetX, GetY, 1000);
	}
}