 //#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Sp5"]
#Text[""]

#include"./Default_ShotConst.txt"
#include"./Default_Effect.txt"
//#include"./effect.txt"

#include"./Effects/Effects.txt"

#include"./Cutin.txt"


let cir = GetCurrentScriptDirectory ~ "circle.png" ;
let ey = GetCurrentScriptDirectory ~ "eye.png" ;
let bg = GetCurrentScriptDirectory ~ "spr.png" ;
let inv = GetCurrentScriptDirectory ~ "sh.png" ;
let cut = GetCurrentScriptDirectory ~ "Cut.png" ;
let bg2 = GetCurrentScriptDirectory ~ "spg.png" ;
let cha = GetCurrentScriptDirectory ~ "./Sounds/se_ch02.wav" ;
let cha2 = GetCurrentScriptDirectory ~ "./Sounds/se_enep02.wav" ;
let tana = GetCurrentScriptDirectory ~ "./Sounds/se_tan01.wav" ;
let bgam = GetCurrentScriptDirectory ~ "./Sounds/se_cardget.wav" ;
let ki = GetCurrentScriptDirectory ~ "./Sounds/se_kira00.wav" ;
let boo = GetCurrentScriptDirectory ~ "./Sounds/se_cat00.wav" ;
let img=GetCurrentScriptDirectory ~ "KE.png";
let img2=GetCurrentScriptDirectory ~ "flower.png";
function wait(w){loop(w){yield;}}
let frame = 0;
let af1=0;
let af2=0;
let af3=0;
let dam=0;

let objEnemy;

@Initialize{
LoadEnemyShotData(GetCurrentScriptDirectory ~ "./Parsee system/System/AllStarShot.txt"); 
objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objEnemy);
	animate;
	
	ObjMove_SetDestAtWeight(objEnemy, 192, 140, 10,2);
	
TExplosionA(ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),5,1);
TExplosionA(ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),2,0.1);
	
	move;
	LoadSound(cha);
	LoadSound(cha2);
	LoadSound(tana);
	LoadSound(boo);
	LoadSound(bgam);
	LoadSound(ki);
	
	end;
back;

	//ObjMove_SetDestAtWeight(objEnemy, -120, -120, 10,12);
	let cx = GetStgFrameWidth() / 2;
	}

let t=0;
let ff=0;
let ff2=0;
let gg=0;
let gg2=0;
let tt=0;

////////////////////////////////////////////////////////////////////////////////////////
let h=0;
let asd=0;
let asd2=0;


	let bossal=255;
	let ciral=133;
	let ccc=0;
	 

task back{
	let bg133=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(bg133, BLEND_ADD_RGB);
	ObjPrim_SetTexture(bg133,cir);
	ObjSprite2D_SetSourceRect(bg133,0,0,132,132);
	ObjSprite2D_SetDestCenter(bg133);
	////
	

	let hh=0;
	dd;

	task dd{
		while(!Obj_IsDeleted(objEnemy)){
		if(ccc==0){
		ObjRender_SetPosition(bg133,ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),0);}else{ObjRender_SetPosition(bg133,ObjMove_GetX(objEnemy)-999,ObjMove_GetY(objEnemy)+333,0);}
		ObjRender_SetAngleZ(bg133,asd2/2);
			ObjRender_SetScaleXYZ(bg133,1.8+0.3*cos(hh),1.8+0.3*cos(hh),0);
			
		hh+=2;
			Obj_SetRenderPriorityI(bg133,22);
			ObjRender_SetAlpha(bg133,ciral);
			////
			
			asd2+=6;yield;}}}
let dir;
	let speed;
	let time=0;
	
	
	
	
	
	
	let g=0;
	
	
task animate{
	
	
	
	
	

while(!Obj_IsDeleted(objEnemy)){yield;
	ObjPrim_SetTexture(objEnemy,img);
	ObjSprite2D_SetDestRect(objEnemy,-32,-32+5*sin(h),32,32+5*sin(h));
	ObjRender_SetScaleXYZ(objEnemy,1.1,1.1,0);
	dir=ObjMove_GetAngle(objEnemy);
	speed=ObjMove_GetSpeed(objEnemy);
	h+=4;
ObjRender_SetAlpha(objEnemy,bossal);
	if(speed==0){
		if(af3==1){time++;ObjRender_SetAngleY(objEnemy,0);
		
af1=0;
		if(time<7){ObjSprite2D_SetSourceRect(objEnemy,64, 0, 128, 64);}
		if(time>=7+1 && af1<=7+5+1){ObjSprite2D_SetSourceRect(objEnemy,128,0, 192, 64);}
		if(time>=14+1 && af1<=15+1){ObjSprite2D_SetSourceRect(objEnemy,192,0, 256, 64);
		
		
		
if(time>20){wait(30);


if(fir==1){loop{yield;ObjSprite2D_SetDestRect(objEnemy,-32,-32+5*sin(h),32,32+5*sin(h));
	h+=4;ObjSprite2D_SetSourceRect(objEnemy,192,0, 256, 64);}}


ObjSprite2D_SetSourceRect(objEnemy,128,0, 192, 64);
wait(7);
ObjSprite2D_SetSourceRect(objEnemy,64, 0, 128, 64);
wait(7);
		time=0;
		af3=0;
		
		}
		
		
		
		
		}
		
		}
	else{ObjRender_SetAngleY(objEnemy,0);
		
	
if(af1<15){af2=0;ObjSprite2D_SetSourceRect(objEnemy,0, 0, 64, 64);}
		
		}


		}

	if(speed>0 && cos(dir)>0 ){
		ObjRender_SetAngleY(objEnemy,0);
		if(af2>7){ObjSprite2D_SetSourceRect(objEnemy,0, 64, 64, 128);}
		if(af2>14){ObjSprite2D_SetSourceRect(objEnemy,64, 64, 128,128);}
		if(af2>21){ObjSprite2D_SetSourceRect(objEnemy,128, 64, 192,128);}
		if(af2>28){ObjSprite2D_SetSourceRect(objEnemy,192, 64, 256,128);}
		if(af2>35){af1=0;}
		af2++;}

	if(speed>0 && cos(dir)<0 ){
		ObjRender_SetAngleY(objEnemy,180);
		if(af2>7){ObjSprite2D_SetSourceRect(objEnemy,0, 64, 64, 128);}
		if(af2>14){ObjSprite2D_SetSourceRect(objEnemy,64, 64, 128,128);}
		if(af2>21){ObjSprite2D_SetSourceRect(objEnemy,128, 64, 192,128);}
		if(af2>28){ObjSprite2D_SetSourceRect(objEnemy,192, 64, 256,128);}
		if(af2>35){af1=0;}
		af2++;}

	af1++;
	if(af1>120){af1=0;}}}

task ded{
	let so = GetCurrentScriptDirectory ~ "./Sounds/se_focus.wav";
	let obj = ObjSound_Create;
	ObjSound_Load(obj,so);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,80);}
	
	
	
	
	
task bamm{
	let so = GetCurrentScriptDirectory ~ "./Sounds/se_enep01.wav";
	let obj = ObjSound_Create;
	ObjSound_Load(obj,so);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,80);}

task end{
	while(ObjEnemy_GetInfo(objEnemy,INFO_LIFE)>0){yield;}
	
	
	ObjMove_SetDestAtWeight(objEnemy, 192+rand(-40,40), 140+10, 10,0.1);
	sas;
	task sas{loop(4){wait(30);tank;}}
	
	StartSlow(TARGET_ALL,30);
	ded;
	
		MakeConcentration("SAKURA",objEnemy,rand(100,255),rand(100,255),rand(100,255),50);
	MakeConcentration("SAKURA",objEnemy,rand(100,255),rand(100,255),rand(100,255),50);
	MakeConcentration("SAKURA",objEnemy,rand(100,255),rand(100,255),rand(100,255),50);
	

//dec;

wait(120);
bamm;
 bossal=0;
	 ciral=0;
	 ccc=1;
	 spellal=0;
	 spellal2=0;

StartSlow(TARGET_ALL,60);
	
	DeleteShotAll(TYPE_ALL,TYPE_ITEM);
	
	let q = CreateShotA1(ObjRender_GetX(objEnemy),ObjRender_GetY(objEnemy),0,90,4,10);
	ObjRender_SetAlpha(q,0);
	ObjShot_SetIntersectionEnable(q,false);
	
	ObjMove_SetX(objEnemy,999);
	ObjMove_SetY(objEnemy,-999);
	
MakeExplosion("MAPLE",q,155,155,255);
MakeExplosion("MAPLE",q,255,155,255);
TExplosionA(ObjMove_GetX(q),ObjMove_GetY(q),5,0.3);
TExplosionA(ObjMove_GetX(q),ObjMove_GetY(q),10,0.5);

TExplosionA(ObjMove_GetX(q),ObjMove_GetY(q),2,0.1);
TExplosionA(ObjMove_GetX(q),ObjMove_GetY(q),15,0.7);
	
	
	
	
	
	wait(180);
	Obj_Delete(objEnemy);
	CloseScript(GetOwnScriptID);}
let qq=0;
@Event{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){SetScriptResult(1800);}
	case(EV_REQUEST_TIMER){SetScriptResult(53);}
	case(EV_REQUEST_SPELL_SCORE){SetScriptResult(15000);}
	
	
	
	
	}

	
	
	let ggg=0;
	let ggg2=0;
	let ttt=0;
	let ttt2=0;
	task flow2{
	
	
	}
	
	
let stop=0;

let ang=0;
let ang2=0;


let spellal=130;
	 let spellal2=255;
task sss{











let bg1q=ObjPrim_Create(OBJ_SPRITE_2D);
bax(bg1q);
ObjPrim_SetTexture(bg1q,bg);
ObjSprite2D_SetSourceRect(bg1q,0,0,256,256);
ObjRender_SetAlpha(bg1q,255);
ObjRender_SetScaleXYZ(bg1q,1.5,1.5,1.5);
ObjSprite2D_SetDestCenter(bg1q);
ObjRender_SetPosition(bg1q,GetStgFrameWidth/2,GetStgFrameHeight/2,0);



/////


let qw=ObjPrim_Create(OBJ_SPRITE_2D);

ObjPrim_SetTexture(qw,bg2);
ObjSprite2D_SetSourceRect(qw,0,0,256,256);
ObjRender_SetAlpha(qw,spellal);

ObjRender_SetScaleXYZ(qw,2.5,2.5,2.5);
ObjSprite2D_SetDestCenter(qw);
ObjRender_SetPosition(qw,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
baxx(qw);




////
let hhh=0;
task bax(vv){
while(!Obj_IsDeleted(vv)){
yield;
ObjRender_SetAlpha(bg1q,spellal);

ObjRender_SetScaleXYZ(bg1q,2.4,2.4,2.4);
ObjRender_SetPosition(bg1q,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
ObjRender_SetAngleZ(bg1q,hhh);
hhh+=0.2;
}
}


task baxx(vv){let gg=0;
while(!Obj_IsDeleted(vv)){
yield;
	
ObjRender_SetScaleXYZ(qw,2.4,2.4,2.4);
ObjRender_SetAlpha(vv,spellal2);

ObjRender_SetPosition(vv,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
ObjRender_SetAngleZ(vv,-hhh);
			gg+=-0.2;
}
}




Obj_SetRenderPriorityI(bg1q,21);


//ObjRender_SetBlendType(qw,BLEND_MULTIPLY);
Obj_SetRenderPriorityI(qw,20);






}
let aas=0;
task circ{dam=1;
}

task kur{
	let so = GetCurrentScriptDirectory ~ "./Sounds/se_kira00.wav";
	let obj = ObjSound_Create;
	ObjSound_Load(obj,so);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,50);}
	
	
task incoming{
	let so = GetCurrentScriptDirectory ~ "./Sounds/se_border.wav";
	let obj = ObjSound_Create;
	ObjSound_Load(obj,so);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,80);}
	
	
task charge{
	let so = GetCurrentScriptDirectory ~ "./Sounds/se_ch02.wav";
	let obj = ObjSound_Create;
	ObjSound_Load(obj,so);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,80);}
	
	
task begi{
	let obj = ObjSound_Create;
	ObjSound_Load(obj,bgam);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,80);}
	
	
	
task appe{let so = GetCurrentScriptDirectory ~ "./Sounds/se_tan01.wav";
	let obj = ObjSound_Create;
	ObjSound_Load(obj,so);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,50);}
	
	
	
task boom{
	let so = GetCurrentScriptDirectory ~ "./Sounds/se_enep02.wav";
	let obj = ObjSound_Create;
	ObjSound_Load(obj,so);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,50);}
	
	
	
task tank{
	let so = GetCurrentScriptDirectory ~ "./Sounds/se_tan00.wav";
	let obj = ObjSound_Create;
	ObjSound_Load(obj,so);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,20);}
	

	
	
	
task boss{
	let obj = ObjSound_Create;
	ObjSound_Load(obj,boo);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,70);}
	
	
	
task he2{let so = GetCurrentScriptDirectory ~ "./Sounds/se_msl2.wav";
	
	let obj = ObjSound_Create;
	ObjSound_Load(obj,so);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,40);}
	
task he{let so = GetCurrentScriptDirectory ~ "./Sounds/Charge.wav";
	
	let obj = ObjSound_Create;
	ObjSound_Load(obj,so);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,80);}
	
	
task sp{
	let so = GetCurrentScriptDirectory ~ "./Sounds/se_break.wav";
	let obj = ObjSound_Create;
	ObjSound_Load(obj,so);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,60);}
	
	let cas=0;
task move{
lll;
task lll{let objScene = GetEnemyBossSceneObjectID();
loop{
yield;

if(ObjEnemyBossScene_GetInfo(objScene, INFO_TIMER)==0){
SetCommonData("sos",2);
	
}
		   

}
}
MakeExplosion("MAPLE",objEnemy,rand(55,255),rand(55,255),rand(55,255));
MakeExplosion("MAPLE",objEnemy,rand(55,255),rand(55,255),rand(55,255));
sp;
	begi;
	while(ObjMove_GetSpeed(objEnemy)>0){yield;}
	
	
charge;
	
	MakeConcentration("MAPLE",objEnemy,0,255,55,60);
	
wait(90);
	
af3=1;
wait(15);
boss;sss;
ObjCutin_SetSpellcardS4(" Seal '' Deep seal of jealousy ''  ", cut, NAZRIN, 240, 104, 104);
ObjCutin_LaunchS3(NAZRIN, cut, "normal");


wait(60);


charge;
	
	MakeConcentration("MAPLE",objEnemy,0,255,55,60);
	
wait(90);

af3=1;
wait(15);circ;
boom;
MakeExplosion("MAPLE",objEnemy,0,255,55);


bossal=130;
cas=1;
  a1=2;
 a2=7;
a3=4;
a4=0;
let corner=0;
let fir=0;
	
	task ls{
	
	let qwee= CreateShotA1(ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),1.5,rand(0,360),825,30);wait(30);
ObjShot_SetSpellResist(qwee,true);
	while(ccc==1){yield;Obj_Delete(qwee)}	
	lop(qwee);
		
		task lop(obj){
		loop{
	
		task cic{let sos=0;tank;
		loop(10){
		let qwee1= CreateShotA1(ObjMove_GetX(qwee),ObjMove_GetY(qwee),0.5,sos,718,10);
		
		while(ccc==1){yield;Obj_Delete(qwee)}	
	sos+=360/10;
		}
		}
		
		
		
		if(ObjMove_GetX(obj)<0){cic;	ObjMove_SetX(qwee,GetStgFrameWidth+10);
	cic;wait(60);}
	
	
	 if(ObjMove_GetX(obj)>GetStgFrameWidth){cic;	ObjMove_SetX(qwee,-10);
	cic;wait(60);}
	if(ObjMove_GetY(obj)<0){cic;	ObjMove_SetY(qwee,GetStgFrameHeight+10);
	cic;wait(60);}
	if(ObjMove_GetY(obj)>GetStgFrameHeight){cic;	ObjMove_SetY(qwee,-10);
	cic;wait(60);}
		yield;}}
		
		while(!Obj_IsDeleted(qwee)){TFlower(ObjMove_GetX(qwee)+rand(-15,15),ObjMove_GetY(qwee)+rand(-15,15),time);wait(15);}



		task TFlower(x,y,time_explode){
		let pel=round(rand(49,64));
			ascent(i in 0..5){
			let flower = CreateShotA1(x+8*cos(i*72),y+8*sin(i*72),0,i*72,pel,10);
			while(ccc==1){yield;Obj_Delete(flower)}	
			graph;
			task graph{
			wait(180);
			ObjShot_FadeDelete(flower);
			
			
			}
			
					}}}
					
					
					
					sos;
					
					task sos{
					
					
					
					
					
					
					
					loop{
					ls;tank;

wait(660);}}let plus=0;
lols;
loop{

a4=0;
loop(20){
kur;
while(ccc==1){yield;}	
loop(4){
line(angle+lol);
line2(angle-lol);
	angle+=360/4}
	wait(8);lol+=plus;plus+=0.1;if(plus<6){plus=1;}
	}
	
	
	a4=1;
loop(40){
kur;while(ccc==1){yield;}	
loop(4){
line(angle+lol);
line2(angle-lol);
	angle+=360/4}
	wait(4);lol+=plus;
	}
	
	
	
	}
	
	}
let a1=rand(-2,2);
let a2=rand(-6,6);
let a3=rand(-1,1);
	let a4=0;
	let surp=0;
	
	
	
					task lols{
						
task bo{
	let so = GetCurrentScriptDirectory ~ "./Sounds/se_boon00.wav";
	let obj = ObjSound_Create;
	ObjSound_Load(obj,so);
	ObjSound_Play(obj);
	ObjSound_SetVolumeRate(obj,60);}
	
					wait(360);
					loop(7){
					soss;
					
					task soss{
					
					
					
					
while(ccc==1){yield;}	
charge;
	
	MakeConcentration("MAPLE",objEnemy,255,55,55,60);
	
while(ccc==1){yield;}	
wait(90);bo;
surp=1;
wait(30);
charge;
	
	MakeConcentration("MAPLE",objEnemy,0,155,155,60);
	

wait(90);bo;

wait(999999);
					
					}
					wait(360);
					}
					
					}
	
	
	task line(ang){
	
	
	
	let qwe=CreateShotA1(ObjRender_GetX(objEnemy),ObjRender_GetY(objEnemy), 1.5, ang, 10, 5);
	while(ccc==1){yield;Obj_Delete(qwe)}	
	
	if(a4==0){
	wai2;
	task wai2{
	loop{
	while(surp==0){yield;}
	
	ObjShot_SetIntersectionEnable(qwe,false);
	ObjRender_SetAlpha(qwe,50);
	
	yield;
	
	ObjShot_SetIntersectionEnable(qwe,true);
	ObjRender_SetAlpha(qwe,255);
	
	}
	}
	}
	if(a4==1){
	wai;
	task wai{
	loop{
	while(surp==0){yield;}
	
	
	ObjShot_SetIntersectionEnable(qwe,true);
	ObjRender_SetAlpha(qwe,255);
	wait(120);
	surp=0;
	ObjShot_SetIntersectionEnable(qwe,false);
	ObjRender_SetAlpha(qwe,50);
	
	}
	}
	
	
	ObjShot_SetIntersectionEnable(qwe,false);
	ObjRender_SetAlpha(qwe,50);
	ObjShot_SetGraphic(qwe,3);
	}
	seal;
	task seal{
	
	loop(30){
	
	
	ObjMove_SetAngle(qwe,ObjMove_GetAngle(qwe)+a1);
	wait(2);
	}
	loop(30){
	
	
	ObjMove_SetAngle(qwe,ObjMove_GetAngle(qwe)+a2);
	wait(2);
	}
	loop(60){
	
	
	ObjMove_SetAngle(qwe,ObjMove_GetAngle(qwe)+a3);
	wait(2);
	}
	ObjMove_SetSpeed(qwe,1);
	
	//ObjMove_SetAngle(qwe,ObjMove_GetAngle(qwe)+a4);
	
	
	}
	
	
	
	
	
	
	
	
	
	}
	
	///
	
	task line2(ang){
	
	
	
	let qwe=CreateShotA1(ObjRender_GetX(objEnemy),ObjRender_GetY(objEnemy), 1.5, ang, 9, 5);
	while(ccc==1){yield;Obj_Delete(qwe)}	
	if(a4==0){
	wai2;
	task wai2{
	loop{
	while(surp==0){yield;}
	
	ObjShot_SetIntersectionEnable(qwe,false);
	ObjRender_SetAlpha(qwe,50);
	
	yield;
	
	ObjShot_SetIntersectionEnable(qwe,true);
	ObjRender_SetAlpha(qwe,255);
	
	}
	}
	}
	if(a4==1){
	wai;
	task wai{
	loop{
	while(surp==0){yield;}
	
	
	ObjShot_SetIntersectionEnable(qwe,true);
	ObjRender_SetAlpha(qwe,255);
	wait(120);
	surp=0;
	ObjShot_SetIntersectionEnable(qwe,false);
	ObjRender_SetAlpha(qwe,50);
	
	}
	}
	
	
	ObjShot_SetIntersectionEnable(qwe,false);
	ObjRender_SetAlpha(qwe,50);
	ObjShot_SetGraphic(qwe,3);
	}
	seal;
	task seal{
	
	loop(30){
	
	
	ObjMove_SetAngle(qwe,ObjMove_GetAngle(qwe)-a1);
	wait(2);
	}
	loop(30){
	
	
	ObjMove_SetAngle(qwe,ObjMove_GetAngle(qwe)-a2);
	wait(2);
	}
	loop(60){
	
	
	ObjMove_SetAngle(qwe,ObjMove_GetAngle(qwe)-a3);
	wait(2);
	}
	ObjMove_SetSpeed(qwe,1);
	
	//ObjMove_SetAngle(qwe,ObjMove_GetAngle(qwe)+a4);
	
	
	}
	
	
	
	
	
	
	
	
	
	}
	
	
	
	
	
	let lab=0;
	let angle=0;
	let angel=0;
	let r=0;
	let lol=0;
	let lol2=0;
	
	let fir=0;
	
	
	
	
	
@MainLoop{yield;
//DeleteShotInCircle(TYPE_ALL,TYPE_IMMEDIATE,0,0,2);
	SetAutoDeleteObject(true);
	if(dam==0){ObjEnemy_SetDamageRate(objEnemy,0,0);}
	if(dam==1){ObjEnemy_SetDamageRate(objEnemy,35,10);}
	let ex = ObjMove_GetX(objEnemy);
	let ey = ObjMove_GetY(objEnemy);

	
	
	let px = GetPlayerX();
	let py = GetPlayerY();
	let ATP = atan2(py - ey, px - ex);

if(ccc==0){

if(cas==1){}else{

ObjEnemy_SetIntersectionCircleToShot(objEnemy, ex, ey, 26);

ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey,29);

}
}else{}


frame++;}