#TouhouDanmakufu
#Title[Unused Spell]
#Text[Guest starring...]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\mu\bgm.mp3]

script_enemy_main {
let c = 0;
let life = 0;
let one = 1;
let angle1 = 0;
let angle2 = 0;
let patchyy = 0;
let patchyx = 0;
	#include_function ".\Eirininclude.txt";
	

	@Initialize{
	DeleteSE("se\seEnemyExplode01.wav");
	shotinit;
	LoadGraphic(imglifebar); 
	LoadSE(time1);
	LoadGraphic(imageFile);
	LoadSE(time2);
	LoadSE(charge);
	LoadSE(laser2);
	LoadSE(familiarspawn);
	InitializeAction;
	SetLife(1500);
	LoadSE(shot);
	DelayedStart;
	LoadSE(shot2);
	SetTimer(99);
	SetEnemyMarker(true);
	SetInvincibility(600);
	SetDamageRate(25, 10);
	SetMovePosition02(GetCenterX, GetClipMinY + 60, 120);
	SetAction(ACT_MOVE, 60);
	SetShotAutoDeleteClip(50, 100, 50, 50);
	LoadGraphic(SP);
	LoadGraphic(MC);
	MagicCircle(false);
	LoadGraphic(CBG1);
	LoadGraphic(CBG2);
	LoadGraphic(CBG3);
	LoadGraphic(CBG4);
	LoadGraphic(CBG5);
	LoadGraphic(Cut);
	LoadSE(orb);
	LoadSE(warp);
	LoadSE(caution);
	LoadSE(border);
	SetAction(ACT_MOVE, 120);
	}


task DelayedStart {
CreateEnemyFromScript("patchy", GetClipMaxX+60, GetClipMinY+160, 0, 0, angle);
wait(210);
Concentration01(120);
PlaySE(charge);
wait(120);
SetScore(5000000);
PlaySE(GetCurrentScriptDirectory~"cardcall.wav");
cutin("Quarantine "\""Poisonous Mercury Containment"\", Cut, 0, 0, 256, 512);
SetAction(ACT_SPELL, 90);
attack1;
patchybullets;
SetTimer(73);
}


task patchybullets {
wait(120);
loop{
loop(40){
			PlaySE(shot);
			loop(30){
				if(one==1){
				CreateShotA(1, patchyx, patchyy, 10);
				SetShotDataA(1, 0, 4, angle, 0, -0.25, 1.5, AQUA50);
				SetShotDataA(1, 30, NULL, NULL, 0.85, -0.2, 1.5, AQUA50);
				SetShotDataA(1, 90, NULL, NULL, 0.05, -0.2, 1.5, AQUA50);
				CreateShotA(2, patchyx, patchyy, 10);
				SetShotDataA(2, 0, 4, angle, 0, -0.3, 1.35, AQUA50);
				SetShotDataA(2, 30, NULL, NULL, 0.75, -0.2, 1.35, AQUA50);
				SetShotDataA(2, 90, NULL, NULL, 0, -0.01, 1.35, AQUA50);
				}
				if(one==-1){
				CreateShotA(1, patchyx, patchyy, 10);
				SetShotDataA(1, 0, 4, angle, 0, -0.25, 1.5, YELLOW50);
				SetShotDataA(1, 30, NULL, NULL, -0.85, -0.2, 1.5, YELLOW50);
				SetShotDataA(1, 90, NULL, NULL, -0.05, -0.2, 1.5, YELLOW50);
				CreateShotA(2, patchyx, patchyy, 10);
				SetShotDataA(2, 0, 4, angle, 0, -0.3, 1.35, YELLOW50);
				SetShotDataA(2, 30, NULL, NULL, -0.75, -0.2, 1.35, YELLOW50);
				SetShotDataA(2, 90, NULL, NULL, 0, -0.01, 1.35, YELLOW50);
			
				}
				FireShot(1);
				FireShot(2);
				angle+=360/30;
				
				
				
				}
			wait(20);
			angle = rand(0, 360);
			one = one*-1;
			}
wait(145);
}
}
		

task attack1 {
//collision=false;
let one = 1;
let firsttime = true;
let j = 0;
wait(150);
loop{
Concentration01(120);
PlaySE(charge);
SetAction(ACT_SHOT_B, 360);
wait(150);
PlaySE(laser);
patchyy = GetCommonDataDefault("patchyy", 0);
patchyx = GetCommonDataDefault("patchyx", 0);

angle1 = atan2(patchyy - GetY, patchyx - GetX);

CreateLaserA(1, GetX, GetY, 0, 30, WHITE60, 90);
SetLaserDataA(1, 0, angle1+30, 0, 10, 0, 0);
SetShotKillTime(1, 270);
FireShot(1); 
CreateLaserA(1, GetX, GetY, 0, 30, WHITE60, 90);
SetLaserDataA(1, 0, angle1-30, 0, 10, 0, 0);
SetShotKillTime(1, 270);
FireShot(1);
angle+=360/6;

wait(90);
loop(180){


	ascent(i in 0..30){
DeleteEnemyShotImmediatelyInCircle(SHOT, GetX+(i*15)*cos(angle1+30), GetY+(i*15)*sin(angle1+30), 10);
DeleteEnemyShotImmediatelyInCircle(SHOT, GetX+(i*15)*cos(angle1-30), GetY+(i*15)*sin(angle1-30), 10);
		}

wait(1);
}
ExMoveHigher;
wait(130);



}
}






@BackGround{
SetTexture(CBG1);
SetGraphicRect(0, anim2/-2, 512, 512+(anim2/-2));
DrawGraphic(GetCenterX, GetCenterY);
SetTexture(CBG2);
SetAlpha(130);
SetGraphicScale(0.5, 1);
SetGraphicRect(0, anim2*3, 512, 512 + anim2*3);
DrawGraphic(GetCenterX-130, GetCenterY);
DrawGraphic(GetCenterX+130, GetCenterY);
SetGraphicScale(1, 1);
SetAlpha(255);
SetTexture(CBG3);
SetGraphicRect( 0, 0, 512, 512 );
DrawGraphic(GetCenterX, GetCenterY);
SetTexture(CBG4);
SetRenderState(ADD);
SetGraphicRect(0, 0, 512, 512);
SetGraphicScale(0.9, 0.9);
SetColor(80, 80, 80);
DrawGraphic(GetCenterX, GetCenterY-70);
SetColor(255, 255, 255);
SetRenderState(ALPHA);
SetGraphicScale(1, 1);



anim2 += 1;
acc1 = 6;


}




}

	




script_enemy patchy{
	
	#include_function ".\Patchyinclude.txt"


let imageFile = GetCurrentScriptDirectory~"sprites\patchy.png";
let shot3 = GetCurrentScriptDirectory~"sfx\shot3.wav";
let shot2 = GetCurrentScriptDirectory~"sfx\shot2.wav";
let shot = GetCurrentScriptDirectory~"sfx\shot.wav";
let charge = GetCurrentScriptDirectory~"sfx\Charge.wav";
let laser2 = GetCurrentScriptDirectory~"sfx\laser2.wav";
let wtf = GetCurrentScriptDirectory~"sfx\kira00.wav";

let Cut = GetCurrentScriptDirectory~"sprites\CutP.png";

let laser = GetCurrentScriptDirectory~"sfx\laser.wav";
let angle2 = 0;
let boom = GetCurrentScriptDirectory~"sfx\se_enep01.wav";
let cardcall = GetCurrentScriptDirectory~"cardcall.wav";
	let one = 1;
	@Initialize {
	LoadSE(shot);
	LoadSE(shot2);
	LoadSE(boom);
	LoadGraphic(Cut);
	LoadSE(shot3);
	LoadGraphic(imageFile);
	SetLife(150000);
	SetInvincibility(400);
	SetDamageRateEx(25, 10, 100, 10);
	SetMovePosition02(GetCenterX, GetClipMinY+120, 120);
	SetAction(ACT_MOVE, 120); 
	attack1;
	}

	task attack1 {
	wait(120);
	PlaySE(cardcall);
	cutin("Metal & Water Sign "\""Mercury Poison"\", Cut, 0, 0, 256, 512);
	SpellDeclare;
	wait(360);
	
	loop{
		SetAction(ACT_SHOT_A, 240);
		
		
			wait(800);
			
	wait(30);
	SetMovePosition03(GetEnemyX, GetY, 9, 2);
	SetAction(ACT_MOVE, 45);
	wait(45);
	
	}
	}



@Finalize {
PlaySE(boom);
}

}
