/**************************************************************************************************************
*	Script: Cutin script Special Edition
*	Author: Helepolis
*	Shameless Theft: GenericTouhouFan
*	version 3.0
*	Types: 1 - MOF   	Middle appear -> float to top -> leave top
*             2 - SA/UFO	Diagonal right top entrance -> slowmode -> follow path to leave
*	       3 - UFO2  	Horizontal left entrance -> slowmode -> follow path to leave (Byakuren style)
*	
*	This script is no longer bound any other scripts or extra functions.
*	Full support in one single file.
**************************************************************************************************************/
let name = "";
let dif = GetCommonDataDefault("difficulty",2);

    // new cutin function eliminates the old commondata style. 
    task cutin(type,spellcardname,cutinImg,left,top,right,bottom){
	
	LoadCommonData;
	yield;
	name = spellcardname;
	
	// Charismatic variables
	let obj = Obj_Create(OBJ_EFFECT);
	let alphret = 0;
	let as = 0;
	let c = 0;
	let x = 0;
	let y = 0;

    	let XYbLR = left + right / 2;
    	let XYbTB = top + bottom / 2;

	if(type == "KANAKO") { x = GetClipMaxX; y = GetCenterY+10; }
	if(type == "NAZRIN") { x = GetClipMaxX+256; y = GetCenterY-120; }
	if(type == "BYAKUREN") { x = GetClipMinX-256; y = GetCenterY; }
	SetCommonData("attempts"~spellcardname,GetCommonDataDefault("attempts"~spellcardname,0)+1);
	DrawTextNew(spellcardname,GetClipMinX+15,GetClipMinY+45,GetClipMaxX-50,255,255,255,255,1);
	PlaySE(GetCurrentScriptDirectory~"se\se_cat00.wav");
	DrawTextNew("History "~ToFormatz(GetCommonDataDefault("captures"~spellcardname,0),7)~"/"~ToFormatz(GetCommonDataDefault("attempts"~spellcardname,1),7)~"    ("~ToFormatz(GetCommonDataDefault("captures"~spellcardname,0)/GetCommonDataDefault("attempts"~spellcardname,1)*100,7)~"%)",GetClipMinX+10,GetClipMinY+60,GetClipMaxX-50,255,255,255,255,1);
	summontext;
	summonhexagon;
SaveCommonData;
LoadCommonData;

	Obj_SetPosition(obj,x,y);
	ObjEffect_SetRenderState(obj,ALPHA);
	ObjEffect_SetTexture(obj,cutinImg);
	ObjEffect_SetLayer(obj,1);

	// this is a special function to handle the cutin alpha modification seperate.
	cutinEffect_Alphret(obj,as,alphret);
	
	// Nifty effect vertex setting ( basically a rectangular using the parameters )
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexXY(obj, 0, -XYbLR, -XYbTB);
	ObjEffect_SetVertexUV(obj, 0, left, top);
	ObjEffect_SetVertexXY(obj, 1, XYbLR, -XYbTB);
	ObjEffect_SetVertexUV(obj, 1, right, top);
	ObjEffect_SetVertexXY(obj, 2, -XYbLR, XYbTB);
	ObjEffect_SetVertexUV(obj, 2, left, bottom);
	ObjEffect_SetVertexXY(obj, 3, XYbLR, XYbTB);
	ObjEffect_SetVertexUV(obj, 3, right, bottom);

	// hooray for complex movement path. Depending on the cutin type, perform cutin.
	while(! Obj_BeDeleted(obj)){
		if(type=="KANAKO"){
			if(c<15){x-=10; y+=10}
			if(c>=15 && c<45){y-=4;}
			if(c>=45){y-=2;}
			if(c>120){ Obj_Delete(obj); }
		}
		if(type=="NAZRIN"){
			if(c<21){x-=20; y+=5}
			if(c>=21 && c<100){x--; y+=0.5;}
			if(c>=100){x-=20; y+=5;}
			if(c>120){ Obj_Delete(obj); }
		}
		if(type=="BYAKUREN"){
			if(c<21){x+=20;}
			if(c>=21 && c<100){x++;}
			if(c>=100){x+=20;}
			if(c>120){Obj_Delete(obj);}
		}
		Obj_SetPosition(obj,x,y);
		c++;
		yield;
	}
    }

    // seperate function to make the fadein and fadeout effect.
    task cutinEffect_Alphret(obj,as,alphret) {
	let c = 0;
	loop{
	  	ObjEffect_SetVertexColor(obj,0,alphret,255,255,255);
	 	ObjEffect_SetVertexColor(obj,1,alphret,255,255,255);
	  	ObjEffect_SetVertexColor(obj,2,alphret,255,255,255);
	  	ObjEffect_SetVertexColor(obj,3,alphret,255,255,255);
		if(as==0){alphret+=20; if(alphret>250){as=1;} }
		if(as==1){c++; if(c==90){ as=2; } }
		if(as==2){alphret-=10; if(alphret<10){as=4;} }	
		yield;
	}
    }
    
    // handler for summoning the diagonal text
    task summontext {
	let yyPos = 0;
	loop(5){
		spellcardtext(GetClipMinX,GetClipMaxY-22-yyPos,1.5);
		spellcardtext(GetClipMaxX,GetClipMinY-30+yyPos,-1.5);
		yyPos+=54;
		yield;
	}
    } 

    // handler for summoning the hexagons
    task summonhexagon {
	let dir = 0;
	loop(8){
		hexagontext(GetCenterX+100,GetCenterY+150,1.5,dir,1.4,1.4);
		hexagontext(GetCenterX+100,GetCenterY+150,1.5,dir,1.2,1.2);
		hexagontext(GetCenterX+100,GetCenterY+150,-1.5,-dir,1.0,1.0);
		hexagontext(80,100,1.5,dir,0.8,0.8);
		dir+=45;
		yield;
	}
    } 

//************************************************************************
// 	Text animation for spellcard spawn ( HEXAGON STYLE )
//   
//	alphret - alpha value
//	as - variable acting like a switch
//	c - counter variable
//************************************************************************

    let CSD = GetCurrentScriptDirectory;
    let textdata = CSD~"system\spellcardanm.png";
    LoadGraphic(textdata);

    task hexagontext(x,y,v,draai,sx,sy) {
	let obj = Obj_Create(OBJ_EFFECT);
	let alphret = 0;
	let as = 0;
        let c = 0;
	let angle = draai;
	let speed = v;

	Obj_SetPosition(obj,x,y);	
	ObjEffect_SetRenderState(obj,ADD);
	ObjEffect_SetTexture(obj,textdata);
        ObjEffect_SetScale(obj, sx, sy);
	ObjEffect_SetLayer(obj,2);

	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -48, -128);
	ObjEffect_SetVertexUV(obj, 0, 0, 0);
	ObjEffect_SetVertexXY(obj, 1, 48, -128);
	ObjEffect_SetVertexUV(obj, 1, 128, 0);
	ObjEffect_SetVertexXY(obj, 2, -48, -104);
	ObjEffect_SetVertexUV(obj, 2, 0, 32);
	ObjEffect_SetVertexXY(obj, 3, 48, -104);
	ObjEffect_SetVertexUV(obj, 3, 128, 32);

	while(! Obj_BeDeleted(obj)){
		ObjEffect_SetAngle(obj,0,0,angle);
	  	ObjEffect_SetVertexColor(obj,0,alphret,255,255,255);
	 	ObjEffect_SetVertexColor(obj,1,alphret,255,255,255);
	  	ObjEffect_SetVertexColor(obj,2,alphret,255,255,255);
	  	ObjEffect_SetVertexColor(obj,3,alphret,255,255,255);

		if(as==0){alphret+=20; if(alphret>185){as=1;} }
		if(as==1){c++; if(c==90){as=2;} }		
		if(as==2){alphret-=10; if(alphret<0){ Obj_Delete(obj); } }
		angle += speed;

		yield;
	  }
    }

//************************************************************************
//	Text animation for spellcard spawn ( Diagonal text ) 
//   
//	alphret - alpha value
//	as - variable acting like a switch
//	c - counter variable
//************************************************************************
    task spellcardtext(x,y,v) {
	let obj = Obj_Create(OBJ_EFFECT);
	let alphret = 0;
	let as = 0;
        let c = 0;
	
	Obj_SetPosition(obj,x,y);
	Obj_SetSpeed(obj,v);
	Obj_SetAngle(obj,-35);
	ObjEffect_SetAngle(obj,0,0,-35);
	ObjEffect_SetRenderState(obj,ADD);
	ObjEffect_SetTexture(obj,textdata);
	ObjEffect_SetLayer(obj,2);

	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexXY(obj, 0, -1024, -16);
	ObjEffect_SetVertexUV(obj, 0, 0, 0);
	ObjEffect_SetVertexXY(obj, 1, 1024, -16);
	ObjEffect_SetVertexUV(obj, 1, 2048, 0);
	ObjEffect_SetVertexXY(obj, 2, -1024, 16);
	ObjEffect_SetVertexUV(obj, 2, 0, 32);
	ObjEffect_SetVertexXY(obj, 3, 1024, 16);
	ObjEffect_SetVertexUV(obj, 3, 2048, 32);

	while(! Obj_BeDeleted(obj)){
	  	ObjEffect_SetVertexColor(obj,0,alphret,255,255,255);
	 	ObjEffect_SetVertexColor(obj,1,alphret,255,255,255);
	  	ObjEffect_SetVertexColor(obj,2,alphret,255,255,255);
	  	ObjEffect_SetVertexColor(obj,3,alphret,255,255,255);
		if(as==0){alphret+=20; if(alphret>185){as=1;} }
		if(as==1){c++; if(c==90){as=2;} }		
		if(as==2){alphret-=10; if(alphret<0){ Obj_Delete(obj); } }
		yield;
	}
    }
//-------------------------------
//Not So charismatic stuff
//-------------------------------

#include_function ".\ObjEffectFunctions.txt";

#include_function ".\drawtextnew.txt";

#include_function ".\spellcardnum.txt";


let lifearray = 0;

let MOFbar = 0;

let sctimer = 0;

let scbonus =0;
let imgMarker = GetCurrentScriptDirectory~"system\mark.png";
LoadGraphic(imgMarker);
let durable = false;
let mark = 0;
let ratio = 0;
let width = (GetClipMaxX);
let imgLife = GetCurrentScriptDirectory~"system\hp.png";
LoadGraphic(imgLife);
task Init(life,healthbars,name){
DrawTextNew("Enemy: "~ToFormatz(healthbars,7),GetClipMinX,GetClipMinY,GetCenterX,255,255,255,255,1);
DrawTextNew(name,GetClipMinX+10,GetClipMinY+20,GetCenterX,255,255,255,255,1);
lifearray=life;
}
function PlaySEEx(se){
if(GetLife>10000){
PlaySE(se);
}
}
task BossInit(nextbar,timer,spellcardbonus,durablex,prgb,nrgb){
	
SetLife(10000+lifearray);
	

	
SetTimer(9999);
	


sctimer = timer*60;
	
scbonus = spellcardbonus;
	
durable = durablex;

ratio = scbonus/sctimer;

mark = ObjEffect_InitializeRect(imgMarker,8);
ObjEffect_SetUVRect(mark,0,0,42,15);
ObjEffect_SetXYRect(mark,-21,-7.5,21,7.5);
Obj_SetPosition(mark,GetX,GetClipMaxY+10);
lifebar(prgb);
if(nextbar==true){
let obj = ObjEffect_InitializeRect(imgLife,6);
	ObjEffect_SetUVRect(obj,0,0,2,3);
	 let k=0;
   loop(4){
      ObjEffect_SetVertexColor(obj,k,255,nrgb[0],nrgb[1],nrgb[2]);
      k++;
   }
   Obj_SetPosition(obj,GetClipMinX,GetClipMinY+20);
   	let totallife = lifearray;
	
	let life2 = 0;

	ObjEffect_SetXYRect(obj,0,0,2,3);

	
	
   ObjEffect_SetScale(obj,width*0.6,1);
   

		
}

}

task lifebar(rgb){
	
	let obj = ObjEffect_InitializeRect(imgLife,7);
	ObjEffect_SetUVRect(obj,0,0,2,3);
	 let k=0;
   loop(4){
      ObjEffect_SetVertexColor(obj,k,255,rgb[0],rgb[1],rgb[2]);
      k++;
   }
   Obj_SetPosition(obj,GetClipMinX,GetClipMinY+20);
   	let totallife = lifearray;
	
	let life2 = 0;

	ObjEffect_SetXYRect(obj,0,0,2,3);

	while(!Obj_BeDeleted(obj)){
	let wat = (GetLife-10000)/totallife;
	let lolx = (GetClipMaxX-50);
	
   ObjEffect_SetScale(obj,width*wat*0.6,1);
   yield;

		}
		}

let timertext1 = [];
let timertext2 = [];
let over = false;
let displaytimer = sctimer;
let candy = GetCurrentScriptDirectory~"system\eyecandy.png";
let bonustext = [];
let bombcount = GetBombCount;
let misscount = GetMissCount;
LoadGraphic(candy);
task DrawBonus{
if(scbonus!=0){
	if(GetBombCount==bombcount && GetMissCount==misscount){
	
		
	DrawText("Bonus "~ToFormatz(scbonus,7),GetCenterX+70,GetClipMinY+60,12,200);
	} else {
	DrawText("Bonus Failed",GetCenterX+70,GetClipMinY+60,12,200);
	
	}
	}
}
task SPMainLoop{
	
sctimer--;
	Obj_SetX(mark,GetX);
resetNum(timertext1);
	if(int(sctimer/60)<12 && sctimer%60 ==0){
	PlaySE(GetCurrentScriptDirectory~"se\timeout.wav");
	
	
	}
displaytimer = sctimer;
if(displaytimer>99*60){
displaytimer=99*60;
}

	timertext1 = DrawBonusNum(displaytimer/60,GetClipMaxX-30,GetClipMinY+10,"LEFT",0.5);
	
	
	if(!durable){
		
	ratio = scbonus/sctimer;
	
	scbonus-=ratio;
		
	
	}
	
	if(GetLife-10000<=0 || sctimer==0 ){
	SetAlpha(0);
	if(over==false){
	over=true;
	DeleteEnemyShotToItem(ALL);
		
	if(scbonus>0){
			
	SPEnd;
		
	}
		
	SPFinalize; 
		
	loop(60){
		
	DeleteEnemyShotToItem(SHOT);
		
	yield;
		
	}
		DeleteEnemyShotToItem(SHOT);
	VanishEnemy;
	}
	
	}
	

	}

	task SPEnd{
	
	SetCommonData("difficulty",dif);
	
	if(GetBombCount==bombcount && GetMissCount==misscount){
		
	if(sctimer==0){
			
	if(durable){
				
	GetSpellCardBonus;
			
	}
		
	} else {
			
	GetSpellCardBonus;
		
	}
	
	} else {
		BonusFailed;
	
	}



	}
	@DrawLoop{
	if(GetLife>10000){
	DrawTask;
	DrawBonus;
	}	
	}
task BonusFailed{
let obj = ObjEffect_InitializeRect(candy,7);
ObjEffect_SetUVRect(obj,8,112,149,139);
ObjEffect_SetXYRect(obj,-74,-13,75,14);
Obj_SetPosition(obj,GetCenterX,GetCenterY-80);
ObjEffect_SetScale(obj,1,1);
SaveCommonData;
LoadCommonData;
}
task GetSpellCardBonus(){
SetCommonData("captures"~name,GetCommonDataDefault("captures"~name,0)+1);
SaveCommonData;
LoadCommonData;
let obj = ObjEffect_InitializeRect(candy,7);
ObjEffect_SetUVRect(obj,5,81,229,107);
ObjEffect_SetXYRect(obj,-145,-18,145,18);
Obj_SetPosition(obj,GetCenterX,GetCenterY-80);
ObjEffect_SetScale(obj,0.8,0.8);
	
let wut = DrawBonusNum(scbonus,GetCenterX-40,GetCenterY-50,"LEFT",0.5);
	
AddScore(scbonus);

PlaySE(GetCurrentScriptDirectory~"se\se_cardget.wav");

}




let csd = GetCurrentScriptDirectory;
let Circ = csd~"system\MagicCircle.png";
let effect_img_cir = csd~"system\etama3.png";
let angleS = 0;
	let scalecount = 0;
	let scale = 1;
	let scale2 = 1;
	let scalecountB = 0;
	let scaleB = 1;
	let ang = 0;
	let scalecount3 = 0;
	let scalea1=2;
	let scalea2=2;
	let scaleb5=0.5;
	let scaleb6=0.5;
	let L=0;
	let lan=0;
	let en=0;

LoadGraphic(Circ);
LoadGraphic(effect_img_cir);
function Circle{
	angleS+=6;
	scalecount ++;
	if(scalecount>=0 && scalecount<=60){
		scale+= 0.01;
		}
	if(scalecount>=61 && scalecount<=121){
		scale-=0.01;
		}
	if(scalecount==122){
		scalecount = 0;
		}
	SetTexture(Circ);
	SetGraphicRect(0, 0, 128, 128);
	SetAlpha(150);
	SetRenderState(ALPHA);
	SetGraphicAngle(0, 0, angleS);
	SetGraphicScale(scale, scale);
	DrawGraphic(GetX, GetY);

}
//////////////////////////////////////////////////////////////////////////////////
///"BORDER" TIMED CIRCLES (from Mitori script)///
//////////////////////////////////////////////////////////////////////////////////

function Border(){
yield;
	let S_Circle_r = 180;		//èâä˙îºåa
	task Spell_CircleA{
		let e_r_flag = true;
		let e_r = 0;
		let e_r_d = 15;
		let e_r_dd = -0.3;
		let e_ang = 0;
		let e_ang_d = 3.5;
		let e_ang_sub = 360/24;

		let e_x = [GetEnemyX];
		let e_y = [GetEnemyY];

		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj, e_x[0], e_y[0]);
		Obj_SetAngle(obj, 0);
		Obj_SetSpeed(obj, 0);
		Obj_SetAutoDelete(obj, false);
		ObjEffect_SetTexture(obj, effect_img_cir);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_SetLayer(obj, 2);
		ObjEffect_SetAngle(obj, 0, 0, e_ang);

		//í∏ì_ê›íË
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_CreateVertex(obj, 54);
		ascent(let i in 0..3){
			ascent(let j in 0..9){
				ObjEffect_SetVertexUV(obj, i*2*9+2*j, 80, j/8*127);
				ObjEffect_SetVertexUV(obj, i*2*9+2*j+1, 95, j/8*127);

				ObjEffect_SetVertexXY(obj, i*2*9+2*j, (e_r+16)*cos(120*i+e_ang_sub*j), (e_r+16)*sin(120*i+e_ang_sub*j));
				ObjEffect_SetVertexXY(obj, i*2*9+2*j+1, e_r*cos(120*i+e_ang_sub*j), e_r*sin(120*i+e_ang_sub*j));
			}
		}
		ascent(let i in 0..54){
			ObjEffect_SetVertexColor(obj, i, 255, 127, 127, 127);
		}

		yield;

		//íxÇÍÇƒìÆÇ≠
		task e_move{
			let e_M_delay_t = 15;//à⁄ìÆíxâÑéûä‘

			loop(e_M_delay_t){
				e_x = e_x ~ [GetEnemyX];
				e_y = e_y ~ [GetEnemyY];
				yield;
			}
			loop{
				e_x = e_x ~ [GetEnemyX];
				e_y = e_y ~ [GetEnemyY];
				e_x = erase(e_x, 0);
				e_y = erase(e_y, 0);
				Obj_SetPosition(obj, e_x[0], e_y[0]);
				yield;
			}
		}
		e_move;

		loop{
			e_r += e_r_d;
			e_r_d += e_r_dd;
			if((e_r <= S_Circle_r)&&(e_r_d < 0)&&(e_r_flag)){
				e_r = S_Circle_r;
				e_r_d = -(S_Circle_r-16)/(sctimer);
				e_r_dd = 0;
				e_r_flag = false;
			}
			ascent(let i in 0..3){
				ascent(let j in 0..9){
					ObjEffect_SetVertexXY(obj, i*2*9+2*j, (e_r+16)*cos(120*i+e_ang_sub*j), (e_r+16)*sin(120*i+e_ang_sub*j));
					ObjEffect_SetVertexXY(obj, i*2*9+2*j+1, e_r*cos(120*i+e_ang_sub*j), e_r*sin(120*i+e_ang_sub*j));
				}
			}
			e_ang += e_ang_d;
			if(e_ang > 360){e_ang += -360;}
			if(e_ang < -360){e_ang += 360;}
			ObjEffect_SetAngle(obj, 0, 0, e_ang);
			if(!OnEnemySpellChirei){break;}
			yield;
		}
		Obj_Delete(obj);
	}

	//ì‡ë§îΩéûåvâÒÇËÇÃâ~ÅuSpell Card Attack of Little Girl...ÅvÅ{ÉøäOë§è„å¸Ç´
	task Spell_CircleB{
		let e_r = 0;
		let e_ang_d = -3.5;
		let e_ang = 0;
		let e_ang_sub = 360/24;

		let e_x = [GetEnemyX];
		let e_y = [GetEnemyY];

		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj, e_x[0], e_y[0]);
		Obj_SetAngle(obj, 0);
		Obj_SetSpeed(obj, 0);
		Obj_SetAutoDelete(obj, false);
		ObjEffect_SetTexture(obj, effect_img_cir);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_SetLayer(obj, 2);
		ObjEffect_SetAngle(obj, 0, 0, e_ang);

		//í∏ì_ê›íË
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_CreateVertex(obj, 54);
		ascent(let i in 0..3){
			ascent(let j in 0..9){
				ObjEffect_SetVertexUV(obj, i*2*9+2*j, 49, j/8*127);
				ObjEffect_SetVertexUV(obj, i*2*9+2*j+1, 64, j/8*127);

				ObjEffect_SetVertexXY(obj, i*2*9+2*j, e_r*cos(120*i+e_ang_sub*j), e_r*sin(120*i+e_ang_sub*j));
				ObjEffect_SetVertexXY(obj, i*2*9+2*j+1, (e_r-16)*cos(120*i+e_ang_sub*j), (e_r-16)*sin(120*i+e_ang_sub*j));
			}
		}
		ascent(let i in 0..54){
			ObjEffect_SetVertexColor(obj, i, 255, 127, 127, 127);
		}

		yield;

		//í∏ì_ÇÃÇP2nÇÃäO
		task e_vt_1{
			let e_r_sub = 0;
			let e_r_sub_ang = 0;
			let e_r_sub_ang_d = 180/30;
			loop(30){
				e_r_sub_ang += e_r_sub_ang_d;
				e_r_sub = (S_Circle_r+6)/2 - (S_Circle_r+6)/2*cos(e_r_sub_ang);
				ascent(let i in 0..3){
					ascent(let j in 0..5){
						ObjEffect_SetVertexXY(obj, i*2*9+4*j, e_r_sub*cos(120*i+e_ang_sub*j*2), e_r_sub*sin(120*i+e_ang_sub*j*2));
					}
				}
				yield;
			}
		}

		//í∏ì_ÇÃÇQ2n+1ÇÃäO
		task e_vt_2{
			let e_r_sub = 0;
			let e_r_sub_ang = 0;
			let e_r_sub_ang_d = 180/45;

			loop(45){
				e_r_sub_ang += e_r_sub_ang_d;
				e_r_sub = (S_Circle_r+6)/2 - (S_Circle_r+6)/2*cos(e_r_sub_ang);
				ascent(let i in 0..3){
					ascent(let j in 0..4){
						ObjEffect_SetVertexXY(obj, i*2*9+4*j+2, e_r_sub*cos(120*i+e_ang_sub*(2*j+1)), e_r_sub*sin(120*i+e_ang_sub*(2*j+1)));
					}
				}
				yield;
			}
		}

		//í∏ì_ÇÃÇRì‡
		task e_vt_3{
			let e_r_sub = 0;
			let e_r_sub_ang = 0;
			let e_r_sub_ang_d = 180/30;

			ef_wait(15);

			loop(30){
				e_r_sub_ang += e_r_sub_ang_d;
				e_r_sub = (S_Circle_r+6)/2 - (S_Circle_r+6)/2*cos(e_r_sub_ang) - 16;
				ascent(let i in 0..3){
					ascent(let j in 0..5){
						ObjEffect_SetVertexXY(obj, i*2*9+4*j+1, e_r_sub*cos(120*i+e_ang_sub*2*j), e_r_sub*sin(120*i+e_ang_sub*2*j));
					}
					ascent(let j in 0..4){
						ObjEffect_SetVertexXY(obj, i*2*9+4*j+3, e_r_sub*cos(120*i+e_ang_sub*(2*j+1)), e_r_sub*sin(120*i+e_ang_sub*(2*j+1)));
					}
				}
				yield;
			}
		}

		//å„ÇÕèôÅXÇ…îºåaÇè¨Ç≥Ç≠ÅB
		task e_vt_4{
			e_r = S_Circle_r+6;
			let e_r_d = -(S_Circle_r-16)/(sctimer);

			ef_wait(60);
			loop{
			e_r += e_r_d;
			ascent(let i in 0..3){
				ascent(let j in 0..9){
					ObjEffect_SetVertexXY(obj, i*2*9+2*j, e_r*cos(120*i+e_ang_sub*j), e_r*sin(120*i+e_ang_sub*j));
					ObjEffect_SetVertexXY(obj, i*2*9+2*j+1, (e_r-16)*cos(120*i+e_ang_sub*j), (e_r-16)*sin(120*i+e_ang_sub*j));
				}
			}
				yield;
			}
		}

		task e_move{
			let e_M_delay_t = 15;//à⁄ìÆíxâÑéûä‘

			loop(e_M_delay_t){
				e_x = e_x ~ [GetEnemyX];
				e_y = e_y ~ [GetEnemyY];
				yield;
			}
			loop{
				e_x = e_x ~ [GetEnemyX];
				e_y = e_y ~ [GetEnemyY];
				e_x = erase(e_x, 0);
				e_y = erase(e_y, 0);
				Obj_SetPosition(obj, e_x[0], e_y[0]);
				yield;
			}
		}

		//í∏ì_ëÄçÏ
		e_vt_1;//è„ÇÃÉ^ÉXÉNåƒÇ—èoÇµ
		e_vt_2;
		e_vt_3;
		e_vt_4;

		//íxÇÍÇƒìÆÇ≠
		e_move;

		//Ç≈Ç‡Ç¡ÇƒâÒì]
		loop{
			e_ang += e_ang_d;
			if(e_ang > 360){e_ang += -360;}
			if(e_ang < -360){e_ang += 360;}
			ObjEffect_SetAngle(obj, 0, 0, e_ang);
			if(!OnEnemySpellChirei){break;}
			yield;
		}
		Obj_Delete(obj);

	}
Spell_CircleA;
Spell_CircleB;
	}

function OnEnemySpellChirei{
	return GetCommonData("SCA_Flag");
}


function spl_wait(let w){
	loop(w){yield;}
}
function ef_wait(let w){
	loop(w){yield;}
}
function MiniCircle{
	angleS+=6;
	scalecount ++;
	if(scalecount>=0 && scalecount<=30){
		scale2+= 0.01;
		}
	if(scalecount>=31 && scalecount<=61){
		scale2-=0.01;
		}
	if(scalecount==62){
		scalecount = 0;
		}
	SetTexture(Circ);
	SetGraphicRect(0, 0, 128, 128);
	SetAlpha(70);
	SetGraphicAngle(0, 0, angleS);
	SetGraphicScale(scale2, scale2);
	DrawGraphic(GetX, GetY);

}