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

#include"./Default_ShotConst.txt"
#include"./Default_Effect.txt"
#include"./effect.txt"
SetCommonData("dat",0);
#include"./Effects/Effects.txt"

#include"./Cutin.txt"

let cirr = GetCurrentScriptDirectory ~ "circle2.png" ;
	

let cirrr = GetCurrentScriptDirectory ~ "circle3.png" ;
let cir = GetCurrentScriptDirectory ~ "circle.png" ;
let bg = GetCurrentScriptDirectory ~ "spbg.jpg" ;
let cut = GetCurrentScriptDirectory ~ "Cut.png" ;
let bg2 = GetCurrentScriptDirectory ~ "spbg2.jpg" ;
let cha = GetCurrentScriptDirectory ~ "./Sounds/se_ch02.wav" ;
let cha0 = GetCurrentScriptDirectory ~ "./Sounds/se_ch00.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 boonn = GetCurrentScriptDirectory ~ "./Sounds/se_boon01.wav" ;
let img=GetCurrentScriptDirectory ~ "KE.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{

objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objEnemy);
	animate;yield;
	
	ObjMove_SetDestAtWeight(objEnemy, 192, 190, 10,3);
	
TExplosionA(ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),5,1);
TExplosionA(ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),2,0.1);
	
	move;
	LoadSound(cha);
	LoadSound(boonn);
	LoadSound(cha2);
	LoadSound(cha0);
	LoadSound(tana);
	LoadSound(boo);
	LoadSound(bgam);
	LoadSound(ki);
PlaySE(bgam);
	
	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;

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(bg133)){yield;
		ObjRender_SetPosition(bg133,ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),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,113);
			////
			
			asd2+=6;}}}
let dir;
	let speed;
	let time=0;
	
	
	
	
	
	
	
	
task animate{
	
	
	
	
	

while(!Obj_IsDeleted(objEnemy)){
	ObjPrim_SetTexture(objEnemy,img);
	ObjSprite2D_SetDestRect(objEnemy,-61.5,-83+5*sin(h),61.5,83+5*sin(h));
	ObjRender_SetScaleXYZ(objEnemy,0.7,0.7,0);
	dir=ObjMove_GetAngle(objEnemy);
	speed=ObjMove_GetSpeed(objEnemy);
	h+=4;

	if(speed==0){
	af1=0;
		if(af3==1){time++;
//af1=0;
		if(time<15){ObjSprite2D_SetSourceRect(objEnemy,373, 256, 511, 454);}
		if(time>=15+1 && af1<=20+1){ObjSprite2D_SetSourceRect(objEnemy,533,255, 671, 453);
		
		
		
		
if(time>80){
		time=0;
		af3=0;}
		
		}
		
		}
	else{
	
if(af1<15){ObjSprite2D_SetSourceRect(objEnemy,0, 0, 136, 197);}
		if(af1>=30+1 && af1<=45+1){ObjSprite2D_SetSourceRect(objEnemy,137,0, 274, 197);}
		if(af1>=46+1 && af1<=60+1){ObjSprite2D_SetSourceRect(objEnemy,137+137,0, 411, 197);}
		if(af1>=61+1 && af1<=76+1){ObjSprite2D_SetSourceRect(objEnemy,137,0, 274, 197);}
		
if(af1>77){ObjSprite2D_SetSourceRect(objEnemy,0, 0, 136, 197);}
		}


		}

	if(speed>0 && cos(dir)>0 ){
		ObjRender_SetAngleY(objEnemy,0);
		if(af2>12){ObjSprite2D_SetSourceRect(objEnemy,6, 234, 144, 431);}
		if(af2>24){ObjSprite2D_SetSourceRect(objEnemy,6, 234, 144, 431);}
		if(af2>36){af1=0;}
		af2++;}

	if(speed>0 && cos(dir)<0 ){
		//ObjRender_SetAngleY(objEnemy,180);
		if(af2>12){ObjSprite2D_SetSourceRect(objEnemy,144, 234, 282, 431);}
		if(af2>24){ObjSprite2D_SetSourceRect(objEnemy,144, 234, 282, 431);}
		if(af2>36){af1=0;}
		af2++;}

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


task end{
	while(ObjEnemy_GetInfo(objEnemy,INFO_LIFE)>0){yield;}
	
	/////////////////////////////////////////////////////////////ччч там х3
	SetCommonData("dat",1);
	
	
	
	DeleteShotAll(TYPE_ALL,TYPE_ITEM);
	Obj_Delete(objEnemy);
	yield;
	CloseScript(GetOwnScriptID);}

@Event{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){SetScriptResult(1800);}
	case(EV_REQUEST_TIMER){SetScriptResult(65);}
	case(EV_REQUEST_SPELL_SCORE){SetScriptResult(15000);}}

	
	
	let ggg=0;
	let ggg2=0;
	let ttt=0;
	let ttt2=0;
	
let ang=0;
let ang2=0;
task sss{












let bg1q=ObjPrim_Create(OBJ_SPRITE_2D);
bax(bg1q);
ObjPrim_SetTexture(bg1q,bg);
ObjSprite2D_SetSourceRect(bg1q,0,0,1024,1024);
ObjRender_SetAlpha(bg1q,255);
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,20000,20000,1024,20024);
ObjRender_SetAlpha(qw,155);
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,255);

ObjRender_SetAngleZ(bg1q,3*cos(hhh*5)+5);
hhh+=0.1;
}
}


task baxx(vv){let gg=0;
while(!Obj_IsDeleted(vv)){
yield;
	ObjSprite2D_SetSourceRect(vv,20000,20000,256,256);
	ObjSprite2D_SetDestCenter(vv);
	ObjRender_SetPosition(vv,0,gg,0);
			gg+=-0.5;
hhh+=0.1;
}
}




ObjRender_SetScaleXYZ(bg1q,0.7,0.7,0);

Obj_SetRenderPriorityI(bg1q,20);


ObjRender_SetScaleXYZ(qw,0.7,0.7,0);
ObjRender_SetBlendType(qw,BLEND_MULTIPLY);
Obj_SetRenderPriorityI(qw,20);






}

let alp=255;








let bb=0;
let bb2=0;
let co=0;
task plop{


if(co==0){
PlaySE(tana);
loop(15){
	let bub2=CreateShotA1(ObjRender_GetX(objEnemy),ObjRender_GetY(objEnemy), 3, bb+bb2, 28, 10);
kk(bub2);
	task kk(k){wait(30);ObjMove_SetSpeed(k,0.8);loop(20){ObjMove_SetAngle(k,ObjMove_GetAngle(k)+2);wait(3);}}
bb+=360/15;
}bb2+=14.87656789;
}



if(co==1){
PlaySE(tana);
loop(15){
	let bub2=CreateShotA1(ObjRender_GetX(objEnemy),ObjRender_GetY(objEnemy), 3, bb+bb2, 28, 10);
kk(bub2);
	task kk(k){wait(30);ObjMove_SetSpeed(k,0.8);loop(20){ObjMove_SetAngle(k,ObjMove_GetAngle(k)-2);wait(3);}}
bb+=360/15;
}bb2+=14.87656789;
}



if(co==2){
PlaySE(tana);
loop(15){
	let bub2=CreateShotA1(ObjRender_GetX(objEnemy),ObjRender_GetY(objEnemy), 3, bb+bb2, 28, 10);
	let bub22=CreateShotA1(ObjRender_GetX(objEnemy),ObjRender_GetY(objEnemy), 3, bb+bb2, 28, 10);
kk(bub2);
kk2(bub22);
	task kk(k){wait(30);ObjMove_SetSpeed(k,0.8);loop(20){ObjMove_SetAngle(k,ObjMove_GetAngle(k)-2);wait(3);}}
	task kk2(k){wait(30);ObjMove_SetSpeed(k,0.8);loop(20){ObjMove_SetAngle(k,ObjMove_GetAngle(k)+2);wait(3);}}
bb+=360/15;
}bb2+=14.87656789;
}


co+=1;
if(co==3){co=0;}


}






let asdd=rand(1,8);
task krug{
	
	
	
	loop{
	
	
	
	
	
	loop(3){
	
	
	
	
	
	
	
	
	
	
	let bub=CreateShotA1(ObjRender_GetX(objEnemy)+r*cos(tut),ObjRender_GetY(objEnemy)+r*sin(tut), 5, 90, 79, 10);
ObjMove_SetAngle(bub,atan2(ObjRender_GetY(objEnemy)-ObjRender_GetY(bub),ObjRender_GetX(objEnemy)-ObjRender_GetX(bub))+180);
	ObjRender_SetAlpha(bub,alp);
	if(krut==1){ObjShot_SetIntersectionEnable(bub,false);}
	if(krut==2){ObjShot_SetIntersectionEnable(bub,false);}
	
	
	
	
	let bub2=CreateShotA1(ObjRender_GetX(objEnemy)+r*cos(-tut+60),ObjRender_GetY(objEnemy)+r*sin(-tut+60), 5, 90, 79, 10);
ObjMove_SetAngle(bub2,atan2(ObjRender_GetY(objEnemy)-ObjRender_GetY(bub2),ObjRender_GetX(objEnemy)-ObjRender_GetX(bub2))+180);
	ObjRender_SetAlpha(bub2,alp);
	if(krut==1){ObjShot_SetIntersectionEnable(bub2,false);}
	if(krut==2){ObjShot_SetIntersectionEnable(bub2,false);}
	
	
	ang+=360/3;
	tut+=360/3;
	}
	
	
	
	wait(3);
	
	
	if(krut==1){
	tut+=asdd;
	angle+=asdd;
	}
	
	
	
	}
	
	
	
	
	
	
	
	
	}
let krut=0;



task spin{




krut=2;
alp=90;
krug;
loop{
	
wait(30);

	PlaySE(cha);
	MakeConcentration("MAPLE",objEnemy,255,155,255,50);
	
wait(90);
plop;
asdd=rand(1,8);
krut=1;alp=90;

wait(120);

krut=2;
wait(60);
krut=0;
alp=255;

wait(120);
}




}



task move{
	
	
	wait(120);
	
	
	
af3=1;
wait(15);
PlaySE(boo);sss;
ObjCutin_SetSpellcardS4(" Exposure '' Oxygen Poisoning '' ", cut, NAZRIN, 240, 104, 104);
ObjCutin_LaunchS3(NAZRIN, cut, "normal");


wait(60);


	PlaySE(cha);
	MakeConcentration("SAKURA",objEnemy,155,155,255,50);
	
wait(90);

MakeExplosion("SAKURA",objEnemy,155,155,255);
PlaySE(cha2);

af3=1;
wait(5);

spin;

	dam=1;
	let plu=0;
	
	loop(130){PlaySE(ki);
	yield;
	bullet(rand(-200,GetStgFrameWidth+200),ObjMove_GetY(objEnemy)+plu,270);
	bullet(rand(-200,GetStgFrameWidth+200),ObjMove_GetY(objEnemy)-plu,90);
	
	
	
	plu+=3;
	}
	
	task poison(x,y,speed1){
	wave(x,y,speed1);
	wave2(x-6,y,speed1);
	}
	
	
	//poison(-140,222,0.5);
	
	
	task poisonous{
	loop{
	
	wait(60);
	poison(-140,rand(10,150),rand(0.1,1));
	wait(60);
	poison(GetStgFrameWidth+15,rand(50,220),rand(-0.1,-1));
	
	
	}
	}
	
	PlaySE(cha);
	MakeConcentration("SAKURA",objEnemy,155,155,255,50);
	
wait(90);

MakeExplosion("SAKURA",objEnemy,155,155,255);
PlaySE(cha2);

af3=1;
wait(5);
	trig=1;
	
	
	
	///
	loop{
	SetCommonData("pois",0);
	trig=1;
	
	loop(5){
	
	wait(10);
	poison(-140,rand(10,150),rand(0.1,0.7));
	wait(10);
	poison(GetStgFrameWidth+15,rand(10,150),rand(-0.1,-0.7));
	
	
	}
	
	
	
	wait(rand(340,420));
	PlaySE(cha0);
	MakeConcentration("SAKURA",objEnemy,155,155,255,50);
	SetCommonData("pois",0);
wait(90);
SetCommonData("pois",0);
MakeExplosion("SAKURA",objEnemy,155,155,255);
PlaySE(cha2);
SetCommonData("pois",0);
af3=1;
wait(5);trig=0;
	SetCommonData("pois",1);
	yield;
	
	wait(300);
	trig=0;
	}
	}

	SetCommonData("pois",0);
	
	let inc=0;let as=0;
	task circl{
	
	}
	
	
	
	
	
	let trig=0;
	task bullet(x,y,ang){
	
	
let bub=CreateShotA1(x,y, 0, ang, 21, 30);
	
	
	ObjMove_SetAngle(bub,rand(0,360));
	ObjShot_SetAutoDelete(bub,false);
	
	
	
	
	let spe=rand(0.00005,0.0002);
	let spe2=rand(1,3);
	let gf2=0;
	loop{
	
	yield;
	if(trig==1){
	loop(30){
	gf+=spe/10000;
	ObjMove_SetSpeed(bub,ObjMove_GetSpeed(bub)+0.001);wait(2);
	}
	
	
	
	loop(60){
	
	ObjMove_SetAngle(bub,ObjMove_GetAngle(bub)+spe2);wait(2);
	}
	wait(120);spe2=rand(1,3);
	loop(60){
	
	ObjMove_SetAngle(bub,ObjMove_GetAngle(bub)+spe2);wait(2);
	}
	
	wait(120);
	
	loop(60){
	
	ObjMove_SetAngle(bub,ObjMove_GetAngle(bub)+spe2);wait(2);
	}
	wait(120); spe2=rand(1,3);
	loop(60){
	
	ObjMove_SetAngle(bub,ObjMove_GetAngle(bub)+spe2);wait(2);
	}
	
	loop(60){
	
	ObjMove_SetAngle(bub,ObjMove_GetAngle(bub)+spe2);wait(2);
	}
	wait(120); spe2=rand(1,3);
	loop(60){
	
	ObjMove_SetAngle(bub,ObjMove_GetAngle(bub)+spe2);wait(2);
	}
	
	break;
	}
	}}
	///
	let gf=0.01;
	
	let gggg=round(rand(41,48));
	
	let x=0;
	
	task wave(x,y,slide){let daw=0;
	yield;
	yield;
	
	
	loop(10){
	
let bub=CreateShotA1(x,y, 0, 90, 46, 0);
ObjShot_SetAutoDelete(bub,false);
	poi(bub);
	x+=13;
	lll(bub);
	wait(5);
	}
	
	task poi(o){
	
	loop{
	
	if(GetCommonData("pois",1)){
	
	
	
	ObjMove_SetSpeed(o,0);
	trig=0;
	wait(120);
	PlaySE(boonn);
	//daw=rand(0.02,0.08);
	verh(o);
	
	task verh(u){
	
	loop{
	yield;
	if(ObjMove_GetY(u)<0){PlaySE(ki);
		let bub=CreateShotA1(ObjRender_GetX(u),ObjRender_GetY(u), rand(0.5,2.5), 90+rand(-10,10), 52, 10);
	
	sled(bub);
	
	
	
	task sled(g){
	while(!Obj_IsDeleted(g)){
	wait(10);
		let bub=CreateShotA1(ObjRender_GetX(g),ObjRender_GetY(g), 0.5, ObjMove_GetAngle(g), 52, 0);
	ObjRender_SetAlpha(bub,90);
	ObjShot_FadeDelete(bub);
	}
	
	}
	
	
	
	break;
	}
	
	}
	
	
	}
	
	
	loop(30){
	
	ObjMove_SetSpeed(o,ObjMove_GetSpeed(o)-0.1);
	
	
	wait(2);
	}
	
	
	break;
	}
	yield;
	}
	
	
	
	}
	
	
		task lll(om){
	las(om,slide);
	
	loop(60){
	//ObjMove_SetX(om,ObjMove_GetX(om)+slide);
	ObjMove_SetSpeed(om,ObjMove_GetSpeed(om)+0.04);wait(1);
	}
	loop{
	if(GetCommonData("pois",1)){break;}
	loop(120){if(GetCommonData("pois",1)){break;}
	
	ObjMove_SetSpeed(om,ObjMove_GetSpeed(om)-0.04);wait(1);
	}
	loop(120){if(GetCommonData("pois",1)){break;}
	
	ObjMove_SetSpeed(om,ObjMove_GetSpeed(om)+0.04);wait(1);
	}
	
	}
	
	task las(oo,slide){wait(120);
	loop{
	if(trig==1){
	ObjMove_SetX(oo,ObjMove_GetX(om)+slide);}
	yield;
	}
	
	}
	
	
	}
	
	
	
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	///
	let trig2=0;
	task wave2(x,y,slide){
	
	loop(10){
	x+=13;
let bub=CreateShotA1(x-13,y, 0, 90, 46, 0);
	ObjShot_SetAutoDelete(bub,false);
	poi(bub);
	lll(bub);
	wait(5);
	}
	
	
	task sled(g){let spp=0;
	while(!Obj_IsDeleted(g)){
	yield;spp+=0.01;
		let bub=CreateShotA1(ObjRender_GetX(g),ObjRender_GetY(g), 0+spp, ObjMove_GetAngle(g)+180, 44, 0);
	ObjRender_SetAlpha(bub,30);
	ObjShot_FadeDelete(bub);
	}
	
	}
	task poi(o){
	
	loop{
	
	if(GetCommonData("pois",1)){
	let spe=rand(0.03,0.06);
	let spe2=rand(-1,1);
	sled(o);
	ObjMove_SetSpeed(o,0);
	
	ObjShot_SetGraphic(o,44);
	
	loop(30){
	
	ObjMove_SetSpeed(o,ObjMove_GetSpeed(o)+spe);
	ObjMove_SetAngle(o,ObjMove_GetAngle(o)+spe2/2);
	
	wait(2);
	}
	
	loop(60){
	

	ObjMove_SetAngle(o,ObjMove_GetAngle(o)+spe2);
	
	wait(2);
	}
	
	break;
	}
	yield;
	}
	
	
	
	}
	
	
	
	
	task lll(om){
	las(om,slide);
	
	loop(60){
	//ObjMove_SetX(om,ObjMove_GetX(om)+slide);
	ObjMove_SetSpeed(om,ObjMove_GetSpeed(om)+0.04);wait(1);
	}
	loop{
	if(GetCommonData("pois",1)){break;}
	loop(120){if(GetCommonData("pois",1)){break;}
	
	ObjMove_SetSpeed(om,ObjMove_GetSpeed(om)-0.04);wait(1);
	}
	loop(120){if(GetCommonData("pois",1)){break;}
	
	ObjMove_SetSpeed(om,ObjMove_GetSpeed(om)+0.04);wait(1);
	}
	
	}
	
	task las(oo,slide){wait(120);
	loop(620){if(trig==1){
	ObjMove_SetX(oo,ObjMove_GetX(om)+slide);}
	yield;
	}
	
	}
	
	
	}
	
	
	
	}
@MainLoop{yield;
	SetAutoDeleteObject(true);
	if(dam==0){ObjEnemy_SetDamageRate(objEnemy,0,0);}
	if(dam==1){ObjEnemy_SetDamageRate(objEnemy,14,10);}
	let ex = ObjMove_GetX(objEnemy);
	let ey = ObjMove_GetY(objEnemy);

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


ObjEnemy_SetIntersectionCircleToShot(objEnemy, ex, ey, 32);
ObjEnemy_SetIntersectionCircleToShot(objEnemy, ex, ey+30, 20);
ObjEnemy_SetIntersectionCircleToShot(objEnemy, ex, ey+60, 10);
ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey, 32);
ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey+20, 20);
ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey+30, 10);
ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey+40, 10);
ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey+50, 5);
ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey-20,32);
frame++;}
SetCommonData("lel",0);
let lasa=0;
task sdd{




}


let r=60;
	let tut=0;
	let angle=0;