#TouhouDanmakufu
#Title[Just a fucking failed bonus test - woot -]
#Text[Hm...]
#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 ch = 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" ;


	let time = 0;
	let time2 = 0;

	@Initialize{
		SetLife(1700);
		SetDamageRate(20, 0);
		SetInvincibility(1200);
		LoadGraphic(image);
		LoadGraphic(lay);
		LoadGraphic(bg);
		LoadGraphic(bosseffect2);
		LoadSE(shot);
		LoadSE(laser);
		LoadSE(caution);
		LoadSE(ch);
		LoadSE(ling);
		SetTimer(89);
		SetDurableSpellCard;
		LoadUserShotData(CSD ~ "tiro\ZUN's shotdata.txt");
		CutIn(KOUMA, "Ultimate Treasure "\""Archangel Smite "\", BossCutIn, 0, 0, 200,282);
		SetEnemyMarker(true);
		SetEffectForZeroLife(180, 255, 3);
		SetDurableSpellCard;
		SetScore(13000000);
		SetMovePosition02(GetCenterX, GetCenterY, 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);
		SetAlpha(120);
		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{
		fire;
		yield;
		}

	task fire{


		wait(210);

		SetInvincibility(180);
		wait(30);
		PlaySE(ch);
		Concentration02(60);
		wait(90);


		let x = 0;
		let xa = 5;
		let slide = 0;
		let dir= 0;
		let dir2 = 0;
		let dir3 = 0;

			loop(1){



			loop(20){
			loop(9){
			while(x<xa){	
				reflect(GetCenterX+200*cos(dir), GetCenterY+200*sin(dir), 3, 180+dir2, 86, 50);
				reflect(GetCenterX+200*cos(-dir), GetCenterY+200*sin(-dir), 3, 180-dir2, 82,50);

				PlaySE(shot);
				dir+=360/xa;
				dir2+=360/xa;

				x++;
				}
				dir+=1;
				dir2+=1;
				x=0;
				wait(2);
				time+=1;
				time2+=0.03;
					}
				wait(1);
				time+=1;
				dir+=9;
				dir2+=1;
				}
				wait(600);
				time = 0;
				time2=0;
				dir = 0;
				dir2 = 0;
				dir3 = 0;

				xa = 3;

			loop(60){
			loop(3){
			while(x<xa){	
				reflect(GetCenterX+200*cos(dir), GetCenterY+200*sin(dir), 2, 180+dir2, 86, 50);
				reflect(GetCenterX+200*cos(dir3), GetCenterY+200*sin(dir3), 3, 180-dir2, 82, 50);

				PlaySE(shot);
				dir+=360/xa;
				dir2+=360/xa;
				dir3+=360/xa;

				x++;
				}
				dir+=-2;
				dir2+=-2;
				dir3+=2;
				x=0;
				wait(2);
				time+=1.8;
				time2+=0.03;
					}
				wait(1);
				time+=1.4;
				dir+=-9;
				dir2+=-5;
				dir3+=9;
				}

				wait(600);
				time = 0;
				time2=30;
				dir = 0;
				dir2 = 0;
				dir3 = 0;

				xa = 3;



			loop(9){
			loop(20){
			while(x<xa){	
				reflect(GetCenterX+230*cos(dir), GetCenterY+230*sin(dir), 2, 180+dir2, 86, 10);
				reflect(GetCenterX+230*cos(dir3), GetCenterY+230*sin(dir3), 2, 180+dir2, 82, 10);

				PlaySE(shot);
				dir+=360/xa;
				dir2+=360/xa;
				dir3+=360/xa;

				x++;
				}
				dir+=-1;
				dir2+=-1;
				dir3+=1;
				x=0;
				wait(2);
					}
				wait(5);
				time+=10;
				dir+=-10;
				dir2+=-10;
				dir3+=10;
				time2+=2;
				}

				wait(780);
				time = 0;
				time2=40;
				dir = 0;
				dir2 = 0;
				dir3 = 0;

				xa = 3;



				}



			loop(36){
			loop(20){
			while(x<xa){	
				reflect(GetCenterX+230*cos(dir), GetCenterY+230*sin(dir), 2, 180+dir2, 86, 20);
				reflect(GetCenterX+230*cos(dir3), GetCenterY+230*sin(dir3), 2, 180-dir2*3, 82, 20);
				PlaySE(shot);
				dir+=360/xa;
				dir2+=360/xa;
				dir3+=360/xa;

				x++;
				}
				dir+=-1;
				dir2+=-1;
				dir3+=2;
				x=0;
				wait(2);
					}
				wait(5);
				time+=10;
				dir+=-10;
				dir2+=-10;
				dir3+=10;
				time2+=1;
				}

				wait(600);
				time = 0;
				time2=0;
				dir = 0;
				dir2 = 0;
				dir3 = 0;

				xa = 2;

			
	}

		


	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(80-time2);
				Obj_SetSpeed(obj, 0);
				wait(360-time);
				PlaySE(ch);
				wait(120);
				Obj_SetSpeed(obj, 1);
				loop(6){
					PlaySE(ling);
					wait(4);
					}
				yield;

	}


			
	//Função "wait"

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


}