#TouhouDanmakufu[Single]
#Title[Koishi - Spell #2]
#Text[Replaced with a better spell.]
#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("Dream World "\""Multichromatic Magicant"\",imgBossCut,0,0,255,511); SetScore(1000000);
		SetInvincibility(120);
		wait(120);
		attack0;
		attack1;
	}
	task attack0 {
		let pos = 0;
		task CreateLaser(side, angle, arg) {
			let obj = Obj_Create(OBJ_LASER);
			ObjShot_SetGraphic(obj, RED11+(arg*6/17)%6);
			ObjLaser_SetWidth(obj, 10);
			Obj_SetAngle(obj, angle-90*side);
			let obj2 = Obj_Create(OBJ_SHOT);
			ObjShot_SetGraphic(obj2, RED36+(arg*6/17)%6);
			ObjShot_SetBombResist(obj2, true);
			Obj_SetAutoDelete(obj2, false);
			loop {
				Obj_SetPosition(obj, GetCenterX+200*side, GetCenterY);
				Obj_SetAngle(obj, Obj_GetAngle(obj)+pi/6*side);
				Obj_SetPosition(obj2, ObjLaser_GetEndX(obj), ObjLaser_GetEndY(obj));
				Obj_SetAngle(obj2, 180+Obj_GetAngle(obj));
				let ang = atan2(GetPlayerY-GetCenterY, GetPlayerX-(GetCenterX+200));
				ObjLaser_SetLength(obj, (200+100*sin(angle*2))*cos(pos+90));
				yield;
			}
		}
		ascent(i in 0..17) {
			CreateLaser(1, i*360/17, i);
			CreateLaser(-1, i*360/17, i);
		}
		loop(180) { pos+=1/2; yield; }
	}
	task attack1 {
		let a = 0; let b = 0;
		loop {
			PlaySE2("se_shot_tan");
			ascent(i in 0..31) { CreateShot01(GetX, GetY, 2+1*sin(b+i*360/31*2), a+i*360/11, RED01+i*1/3, 0); }
			a+=19; a%=360;
			b+=pi^2; b%=360;
			wait(15);
		}
	}
}