#TouhouDanmakufu
#Title[16]
#Text[GASSSSSSSSP- Really damn fucking long card without using a OP Reimu. But even with Overpowered Reimu its hell long...]
#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" ;

	@Initialize{
		SetLife(5000);
		SetDamageRate(40, 0);
		SetInvincibility(300);
		LoadGraphic(image);
		LoadGraphic(lay);
		LoadGraphic(bg);
		LoadGraphic(bosseffect2);
		LoadSE(shot);
		LoadSE(laser);
		LoadSE(caution);
		LoadSE(ch);
		LoadSE(ling);
		SetTimer(290);
		SetDurableSpellCard;
		LoadUserShotData(CSD ~ "tiro\ZUN's shotdata.txt");
		CutIn(KOUMA, "Venomancer Sign "\""Fossilized Curse "\", BossCutIn, 0, 0, 200,282);
		SetEnemyMarker(true);
		SetScore(13000000);
		SetEffectForZeroLife(70, 120, 2);
		SetMovePosition02(GetCenterX, GetCenterY-30, 60); 

		fire;
	}
	

	@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 fire{


		wait(210);

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


		let x = 0;
		let slide = 0;
		let dir= 0;

		while(GetLife > 4100){
			loop(14){
			while(x<12){	
				CreateShot01(GetX, GetY, 2, (GetAngleToPlayer + dir) + 10 - slide,141,0);
				PlaySE(shot);
				dir+=360/12;

				x++;
				}
			wait(4);
			slide+=-2;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
			wait(10);

			loop(14){
			while(x<12){	
				CreateShot01(GetX, GetY, 2, (GetAngleToPlayer + dir) - 10 + slide,141,0);
				PlaySE(shot);
				dir+=360/12;

				x++;
				}
			wait(4);
			slide+=-2;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
			wait(10);
		}
		DeleteEnemyShot(ALL);
		fire2;
	}

	task fire2{


		wait(60);

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


		let x = 0;
		let slide = 0;
		let dir= 0;

		while(GetLife > 2800){
			loop(20){
			while(x<16){	
				CreateShot01(GetX, GetY, 3, (GetAngleToPlayer + dir) + 20 + slide,139,0);
				PlaySE(shot);
				dir+=360/16;

				x++;
				}
			wait(4);
			slide+=-2;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;

			loop(10){
			while(x<16){	
				CreateShot01(GetX, GetY, 2, (GetAngleToPlayer + dir) - 20 + slide,143,0);
				PlaySE(shot);
				dir+=360/16;

				x++;
				}
			wait(4);
			slide+=4;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
		wait(30);
		}
		DeleteEnemyShot(ALL);
		fire3;
	}

	task fire3{
		SetDamageRate(28, 0);

		wait(60);

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


		let x = 0;
		let slide = 0;
		let dir= 0;

		while(GetLife > 2300){
			loop(20){
			while(x<12){	
				CreateShot01(GetX, GetY, 3, (GetAngleToPlayer + dir) + 20 + slide,159,0);
				PlaySE(shot);
				dir+=360/12;

				x++;
				}
			wait(3);
			slide+=-2;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
			wait(30);

			loop(10){
			while(x<11){	
				CreateShot01(GetX, GetY, 1, (GetAngleToPlayer + dir) - 20 + slide,164,0);
				PlaySE(shot);
				dir+=360/11;

				x++;
				}
			wait(5);
			slide+=4;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
			wait(10);

			loop(10){
			while(x<11){	
				CreateShot01(GetX, GetY, 1, (GetAngleToPlayer + dir) - 20 + slide,164,0);
				PlaySE(shot);
				dir+=360/11;

				x++;
				}
			wait(5);
			slide+=-4;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
			wait(10);
		}
		DeleteEnemyShot(ALL);
		fire4;
	}


	task fire4{
		SetDamageRate(35, 0);

		wait(60);

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


		let x = 0;
		let slide = 0;
		let dir= 0;

		while(GetLife > 1500){
			loop(1){
			while(x<24){	
				CreateShot01(GetX, GetY, 1, GetAngleToPlayer + dir, 29,0);
				PlaySE(shot);
				dir+=360/24;

				x++;
				}
			wait(10);
			slide+=-2;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
			wait(30);

			loop(10){
			while(x<21){	
				CreateShot01(GetX, GetY, 2, (GetAngleToPlayer + dir),140,0);
				PlaySE(shot);
				dir+=360/21;

				x++;
				}
			wait(2);
			slide+=2;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;

			loop(10){
			while(x<21){	
				CreateShot01(GetX, GetY, 1, (GetAngleToPlayer + dir)+6,140,0);
				PlaySE(shot);
				dir+=360/21;

				x++;
				}
			wait(2);
			slide+=-2;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
		wait(60);
		}
		DeleteEnemyShot(ALL);
		fire5;
	}

	task fire5{
		SetDamageRate(20, 0);

		wait(210);

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


		let x = 0;
		let slide = 0;
		let dir= 0;

		while(GetLife > 1000){
			loop(28){
			while(x<12){	
				CreateShot01(GetX, GetY, 3, (GetAngleToPlayer + dir) + 10 - slide,141,0);
				PlaySE(shot);
				dir+=360/12;

				x++;
				}
			wait(2);
			slide+=-1;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
			wait(10);

			loop(14){
			while(x<12){	
				CreateShot01(GetX, GetY, 2, (GetAngleToPlayer + dir) - 10 + slide,138,0);
				PlaySE(shot);
				dir+=360/12;

				x++;
				}
			wait(4);
			slide+=-2;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
			wait(10);
		}
		DeleteEnemyShot(ALL);
		fire6;
	}

	task fire6{


		wait(210);

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


		let x = 0;
		let slide = 0;
		let dir= 0;

		while(GetLife > 500){
			loop(28){
			while(x<12){	
				CreateShot01(GetX, GetY, 1, (GetAngleToPlayer + dir) + 10 - slide,141,0);
				PlaySE(shot);
				dir+=360/12;

				x++;
				}
			wait(2);
			slide+=-1;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
			wait(10);

			loop(14){
			while(x<12){	
				CreateShot01(GetX, GetY, 3, (GetAngleToPlayer + dir) - 10 + slide,138,0);
				PlaySE(shot);
				dir+=360/12;

				x++;
				}
			wait(4);
			slide+=-2;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
			wait(10);
		}
		DeleteEnemyShot(ALL);
		final;
	}

	task final{


		wait(210);

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


		let x = 0;
		let slide = 0;
		let dir= 0;

		while(GetLife > 1){
			loop(28){
			while(x<12){	
				CreateShot01(GetX, GetY, 3, (GetAngleToPlayer + dir) + 10 - slide,141,0);
				PlaySE(shot);
				dir+=360/12;

				x++;
				}
			wait(2);
			slide+=-1;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;	

			wait(40);
			loop(14){
			while(x<12){	
				CreateShot01(GetX, GetY, 5, (GetAngleToPlayer + dir) - 10 + slide,138,0);
				PlaySE(shot);
				dir+=360/12;

				x++;
				}
			wait(4);
			slide+=-2;
			x=0;
			}
		x=0;	
		dir+=rand(0, 360);
		slide = 0;
		wait(40);
		}
		DeleteEnemyShot(ALL);
		fire2;
	}

	//Função "wait"

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


}