#TouhouDanmakufu
#Title[6]
#Text[Fucking random "WOOT" at the final of the card name removed. Card renamed, though :DD ]
#Player[FREE]
#PlayLevel[Normal]
#BGM[.\theme]
#ScriptVersion[2]

script_enemy_main{
	let shot = GetCurrentScriptDirectory ~ "bgm\se_tan01.wav";
	let ling = GetCurrentScriptDirectory ~ "bgm\se_kira00.wav";
	let laser = GetCurrentScriptDirectory ~ "bgm\se_lazer01.wav";
	let caution = GetCurrentScriptDirectory ~ "bgm\se_caution.wav";
	let charge = GetCurrentScriptDirectory ~ "bgm\se_charge.wav";



    	let BossCutIn = "script\Shiro\Shiro.png"; 
    	let image="script\Shiro\sheet.png"; 
	let frame = 0;
	let angle = 0;
	let CSD = GetCurrentScriptDirectory;
	let lay = CSD ~ "iceflakes.png";
	let bg = CSD ~ "spbg.png";
	let slide = 200;
	let slide2 = 0;
	let rotate = 0;
	let bosseffect2 = CSD ~ "bosseffect2.png" ;

	@Initialize{
		SetLife(1000);
		SetDamageRate(25, 0);
		SetInvincibility(400);
		LoadGraphic(image);
		LoadGraphic(lay);
		LoadGraphic(bg);
		LoadGraphic(bosseffect2);
		LoadSE(shot);
		LoadSE(laser);
		LoadSE(caution);
		LoadSE(charge);
		LoadSE(ling);
		SetTimer(93);
		LoadUserShotData(CSD ~ "tiro\ZUN's shotdata.txt");
		CutIn(KOUMA, "Machinery "\""Merry-go-round Mechanism"\", BossCutIn, 0, 0, 200,282);
		SetEnemyMarker(true);
		SetScore(3000000);
		SetMovePosition02(GetCenterX, GetCenterY-30, 60); 

		main;
	}
	

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


	}

	@DrawLoop{

		SetTexture(lay);
		SetColor(255,255,255);
		SetRenderState(ALPHA);
		SetGraphicAngle(0, 0, 0);
		SetGraphicRect(0,0,600000,600000);
		SetGraphicScale(1, 1);
		DrawGraphic(GetX+rotate,GetY+rotate/2);


		SetTexture(bosseffect2);
		SetColor(255,255,255);
		SetRenderState(ALPHA);
		SetGraphicAngle(0, 0, rotate);
		SetGraphicRect(0,0,256,256);
		SetGraphicScale(2, 2);
		DrawGraphic(GetX,GetY);



		SetTexture(image);
		SetColor(255,255,255);
		SetRenderState(ALPHA);
		SetGraphicAngle(0, 0, 0);
		SetGraphicRect(0,0,83,117);
		SetGraphicScale(1, 1);
		DrawGraphic(GetX,GetY);

	}

	@BackGround{


		SetTexture(bg);
		SetRenderState(ALPHA);
		SetAlpha(255);
		SetGraphicAngle(0, 0, rotate/2);
		SetGraphicScale(2, 2);
		SetGraphicRect(0,0,256,256);
		DrawGraphic(GetCenterX,GetCenterY);

		rotate+=1;
		slide2+=1;
		}


	@Finalize
	{
		DeleteSE(shot);
		DeleteGraphic(bg);
		DeleteGraphic(lay);
		DeleteGraphic(image);
	}

	task main{
		wait(120);
		circle;
		yield;
		}

	task circle{

		let x = 0;
		let dir = 0;

		let dir2acc = 0;
		let dir2 = 0;

		let dir3 = 0;

		let sp = 0;
		let slide = 0;
		wait(60);

		loop{

				loop(rand_int(1, 6)){
				while(x<18){
				ascent(i in 0..1){
				qqnml(GetX,GetY, 1+i*1, dir, 28, 0); }
				PlaySE(shot);
				dir+=360/18;
				x++;
						}
				x=0;
				dir+=rand(0, 360);
				wait(60);

				while(x<18){	
				ascent(i in 0..1){
				qqinv(GetX,GetY, 1+i*1, dir, 30, 0); }
				PlaySE(shot);
				dir+=360/18;
				x++;
						}
				x=0;
				dir+=rand(0, 360);
				wait(60);
				}
				loop(1){
				while(x<18){
				ascent(i in 0..1){
				qqnml(GetX,GetY, 1+i*1, dir, 28, 0);
				qqinv(GetX,GetY, 1+i*1, dir, 30, 0); }
				PlaySE(shot);

				dir+=360/18;
				x++;
						}
				x=0;
				dir+=rand(0, 360);
				wait(60);
				}

			}
		}



		

	task qqq(x, y, speed, dir, graph, delay){
		let obj = Obj_Create(OBJ_SHOT);
		let dr = 0;

		Obj_SetPosition(obj, x, y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, dir);
		ObjShot_SetGraphic(obj, graph);	
		ObjShot_SetDelay(obj, delay);	
		ObjShot_SetBombResist(obj, true);

				wait(60);
				loop(1){
					ascent(i in 0..6){
					CreateShot01(Obj_GetX(obj),Obj_GetY(obj), 1.3+i*0.3, Obj_GetAngle(obj), 26, 0); }
					PlaySE(ling);
					dr+=360/1;
					}
				

				
				yield;

	}



	task reflect(x, y, speed, dir, graph, delay){
		let obj = Obj_Create(OBJ_SHOT);

		Obj_SetPosition(obj, x, y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, dir);
		ObjShot_SetGraphic(obj, graph);	
		ObjShot_SetDelay(obj, delay);	
		ObjShot_SetBombResist(obj, true);

				wait(120);
				loop(16){
					ascent(i in 0..8){
					CreateShot01(Obj_GetX(obj),Obj_GetY(obj), 1+i*0.3, Obj_GetAngle(obj)+angle, 99, 30); }
					PlaySE(ling);
					angle+=360/16;
					}
				
				yield;

	}



	task qqinv(x, y, speed, dir, graph, delay){
		let obj = Obj_Create(OBJ_SHOT);

		Obj_SetPosition(obj, x, y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, dir);
		ObjShot_SetGraphic(obj, graph);	
		ObjShot_SetDelay(obj, delay);	
		ObjShot_SetBombResist(obj, true);

				loop{
					Obj_SetAngle(obj, Obj_GetAngle(obj) - 0.3);
					wait(1);
						}





				yield;
			}

	task qqnml(x, y, speed, dir, graph, delay){
		let obj = Obj_Create(OBJ_SHOT);

		Obj_SetPosition(obj, x, y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, dir);
		ObjShot_SetGraphic(obj, graph);	
		ObjShot_SetDelay(obj, delay);	
		ObjShot_SetBombResist(obj, true);

				loop{
					Obj_SetAngle(obj, Obj_GetAngle(obj) + 0.3);
					wait(1);
						}
					




				yield;
			}



	//Função "wait"

	function wait(w){
		loop(w){yield;}
		}

}