let dirCurrent = GetCurrentScriptDirectory();
let DIR = GetCurrentScriptDirectory();
let typeEnd = 0;
let END_FAILED = 1;
let END_SUCCESS = 2;
let BossDf = 90;
let imgEffLine = DIR ~ "img/eff_line.png";
@Initialize
{
	MagicCircle();
	MagicCircle2();
	SetAutoDeleteObject(true);
}

@MainLoop
{
	yield;
}

@Event
{
	alternative(GetEventType())
	case(EV_END_BOSS_STEP)
	{
		//師偺揋摦嶌傊
		if(typeEnd == 0)
		{
			//僗儁儖僇乕僪庢摼幐攕
			typeEnd = END_FAILED;
		}
	}
	case(EV_GAIN_SPELL)
	{
		//僗儁儖僇乕僪庢摼
		typeEnd = END_SUCCESS;
	}
}

task MagicCircle2()
{
	//捀揰婏悢丗嬼悢丗墌偺奜懁丄墌偺撪懁
	let countVertex = 64;
	let listRadius = [];
	loop(countVertex)
	{
		listRadius = listRadius ~ [0];
	}

	let path = dirCurrent ~ "img/Default_MagicCircle.png";
	let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
	ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(obj, countVertex);
	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	Obj_SetRenderPriority(obj, 0.4);
	ObjPrim_SetTexture(obj, path);
	ascent(iVert in 0..countVertex / 2)
	{
		let left = iVert * 128;
		let indexVert = iVert * 2;
		ObjPrim_SetVertexUVT(obj, indexVert + 0, left, 0);
		ObjPrim_SetVertexUVT(obj, indexVert + 1, left, 64);		
	}

	let objScene = GetEnemyBossSceneObjectID();
	let objBoss = GetEnemyBossObjectID()[0];
	let timerOrg = ObjEnemyBossScene_GetInfo(objScene, INFO_ORGTIMERF);
	let bLastSpell = ObjEnemyBossScene_GetInfo(objScene, INFO_IS_LAST_SPELL);

	let cx = 0;
	let cy = 0;
	let maxRadius = 256 * 1.2;
	let alpha = 0;
	let frame = 0;
	let angleRender = 0;

	function GetPlayerX()
	{
		let objPlayer = GetPlayerObjectID();
		return ObjRender_GetX(objPlayer);
	}

	function GetPlayerY()
	{
		let objPlayer = GetPlayerObjectID();
		return ObjRender_GetY(objPlayer);
	}

	function UpdateVertex()
	{
		if(bLastSpell)
		{
			ObjRender_SetColor(obj, 255 * alpha, 192 * alpha, 192 * alpha);
		}
		else
		{
			ObjRender_SetColor(obj, 192 * alpha, 192 * alpha, 255 * alpha);
		}

		ObjRender_SetPosition(obj, cx, cy, 0);
		ObjRender_SetAngleZ(obj, angleRender);
	}

	let pathUseSpell = dirCurrent ~ "se/seUseSpellCard.wav";
	let objs = ObjSound_Create();
    ObjSound_Load(objs,pathUseSpell);
    ObjSound_SetSoundDivision(objs, SOUND_SE);
    //ObjSound_SetLoopTime(objs, 0,300);
	ObjSound_SetRestartEnable(objs,true);
    ObjSound_SetVolumeRate(objs,GetAreaCommonData("Config", "SFXVolume", 95));
    ObjSound_Play(objs);
	DeleteAtFrame(objs,90);

	while(typeEnd == 0)
	{
		if(!Obj_IsDeleted(objBoss))
		{
			cx = ObjRender_GetX(objBoss);
			cy = ObjRender_GetY(objBoss);
		}

		alpha += 1 / 120;
		alpha = min(alpha, 1);
		angleRender += 360 / countVertex / 4;

		let timer = ObjEnemyBossScene_GetInfo(objScene, INFO_TIMERF);
		let rRate = timer / timerOrg;
		let bMiss = ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT) > 0 ||
					 ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) > 0 ;

		ascent(iVert in 0..countVertex / 2)
		{
			let indexVert = iVert * 2;
			let angle = 360 / (countVertex / 2 - 1) * iVert;

			let vx1 = listRadius[indexVert] * cos(angle);
			let vy1 = listRadius[indexVert] * sin(angle);
			ObjPrim_SetVertexPosition(obj, indexVert + 0, vx1, vy1, 0);

			let vx2 = listRadius[indexVert+1] * cos(angle);
			let vy2 = listRadius[indexVert+1] * sin(angle);
			ObjPrim_SetVertexPosition(obj, indexVert + 1, vx2, vy2, 0);

			//杺曽恮奼戝
			if(frame >= 0)
			{//奜懁
				let dr = (maxRadius * rRate - listRadius[indexVert]) / 16;
				listRadius[indexVert] = listRadius[indexVert] + dr;
			}
			if(frame > 45)
			{//撪懁
				let rRateIn = rRate - 0.08;
				if(bMiss)
				{
					rRateIn = rRate - 0.04;
				}
				if(rRateIn < 0){rRateIn=0;}
				let dr= (maxRadius * rRateIn - listRadius[indexVert + 1]) / 64;
				listRadius[indexVert + 1] = listRadius[indexVert + 1] + dr;
			}

		}

		UpdateVertex();
		frame++;

		yield;
	}

	//僗儁儖僇乕僪庢摼幐攕
	if(typeEnd == END_FAILED)
	{
		Obj_Delete(obj);
		CloseScript(GetOwnScriptID());
		return;
	}

	let pathGainSpell = dirCurrent ~ "se/seGetSpellCardBonus.wav";
	let objss = ObjSound_Create();
    ObjSound_Load(objss,pathGainSpell);
    ObjSound_SetSoundDivision(objss, SOUND_SE);
    //ObjSound_SetLoopTime(objs, 0,300);
	ObjSound_SetRestartEnable(objss,true);
    ObjSound_SetVolumeRate(objss,GetAreaCommonData("Config", "SFXVolume", 95));
    ObjSound_Play(objss);
	DeleteAtFrame(objss,90);

	let rRate = 1.0;
	frame = 0;
	alpha = 1;
	//僗儁儖僇乕僪庢摼惉岟
	loop(105)
	{
		angleRender += 360 / countVertex / 4;
		let dx = (GetPlayerX() - cx) / 16;
		let dy = (GetPlayerY() - cy) / 16;
		cx += dx;
		cy += dy;
		if(frame >= 45)
		{
			alpha -= 1 / 45;
			alpha = max(alpha, 0);
		}

		ascent(iVert in 0..countVertex / 2)
		{
			let indexVert = iVert * 2;
			let angle = 360 / (countVertex / 2 - 1) * iVert;

			let vx1 = listRadius[indexVert] * cos(angle);
			let vy1 = listRadius[indexVert] * sin(angle);
			ObjPrim_SetVertexPosition(obj, indexVert + 0, vx1, vy1, 0);

			let vx2 = listRadius[indexVert+1] * cos(angle);
			let vy2 = listRadius[indexVert+1] * sin(angle);
			ObjPrim_SetVertexPosition(obj, indexVert + 1, vx2, vy2, 0);

			let drOut = 0;
			let drIn = 0;
			if(frame <= 45)
			{
				//杺曽恮奼戝
				let rRateOut = 1.0;
				drOut = (maxRadius * rRateOut - listRadius[indexVert]) / 8;

				let rRateIn = rRateOut - 0.08;
				if(rRateIn<0){rRateIn=0;}
				drIn = (maxRadius * rRateIn - listRadius[indexVert+1]) / 8;
			}
			else
			{
				cx = GetPlayerX();
				cy = GetPlayerY();

				rRate -= 1.0 / 60.0;
				let rRateOut = rRate * sin(angle % 60);
				drOut = (maxRadius * rRateOut - listRadius[indexVert]) / 16;

				let rRateIn = rRate * sin(angle % 60)-0.08;
				if(rRateIn<0){rRateIn=0;}
				drIn=(maxRadius * rRateIn - listRadius[indexVert+1])/16;
			}
			listRadius[indexVert] = listRadius[indexVert] + drOut;
			listRadius[indexVert + 1] = listRadius[indexVert + 1] + drIn;
		}

		UpdateVertex();
		frame++;
		yield;
	}

	Obj_Delete(obj);
	CloseScript(GetOwnScriptID());
	
}


task MagicCircle{
if(GetAreaCommonData("Config", "Effects", 0) < 2){
	let objScene = GetEnemyBossSceneObjectID();
	let GetTimers = ObjEnemyBossScene_GetInfo(objScene, INFO_TIMERF);
	let objEnemy = GetEnemyBossObjectID()[0];
	let S_Circle_r = 180;		//弶婜敿宎
	let way = 54;
	let way1 = 3;
	let way2 = 9;
	let close_f = BossDf-1;
	let c_Alpha_Rate = 0.55;
	
	//奜墌乽Border of Life乿
	task Spell_CircleA(layer){
		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 alpha = 255;
		let cx = ObjMove_GetX(objEnemy);
		let cy = ObjMove_GetY(objEnemy);
	
		let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
		ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjPrim_SetVertexCount(obj, way);
		ObjRender_SetFogEnable(obj,false);
		ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
		Obj_SetRenderPriorityI(obj, layer+9);
		ObjPrim_SetTexture(obj, imgEffLine);
	
		ascent( i in 0..way1){
			ascent( j in 0..way2){
				ObjPrim_SetVertexUVT(obj, i*18+2*j, j/8*256,161);
				ObjPrim_SetVertexUVT(obj, i*18+2*j+1, j/8*256,191);
	
				ObjPrim_SetVertexPosition(obj, i*18+2*j, (e_r+16+2)*cos(120*i+e_ang_sub*j), (e_r+16+2)*sin(120*i+e_ang_sub*j),0);
				ObjPrim_SetVertexPosition(obj, i*18+2*j+1, (e_r+0+2)*cos(120*i+e_ang_sub*j), (e_r+0+2)*sin(120*i+e_ang_sub*j),0);
			}
		}
		ObjRender_SetColor(obj, alpha*c_Alpha_Rate, alpha*c_Alpha_Rate, alpha*c_Alpha_Rate);
	
		while(typeEnd == 0){
			GetTimers = ObjEnemyBossScene_GetInfo(objScene, INFO_TIMERF);
			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)/(GetTimers-90);
				e_r_dd = 0;
				e_r_flag = false;
			}
			e_r = absolute(e_r);
			ascent( i in 0..way1){
				ascent( j in 0..way2){
					ObjPrim_SetVertexPosition(obj, i*18+2*j, (e_r+16+2)*cos(120*i+e_ang_sub*j), (e_r+16+2)*sin(120*i+e_ang_sub*j),0);
					ObjPrim_SetVertexPosition(obj, i*18+2*j+1, (e_r+0+2)*cos(120*i+e_ang_sub*j), (e_r+0+2)*sin(120*i+e_ang_sub*j),0);
				}
			}
			e_ang += e_ang_d;
			if(e_ang > 360){e_ang += -360;}
			if(e_ang < -360){e_ang += 360;}
			ObjRender_SetAngleZ(obj,e_ang);
			if(!Obj_IsDeleted(objEnemy))
			{
				cx = cx * 0.95 + ObjMove_GetX(objEnemy) * 0.05;
				cy = cy * 0.95 + ObjMove_GetY(objEnemy) * 0.05;
			}
			ObjRender_SetPosition(obj, cx, cy, 0);
			ObjRender_SetColor(obj, alpha*c_Alpha_Rate, alpha*c_Alpha_Rate, alpha*c_Alpha_Rate);
			yield;
		}
		task Ring_SpGet{
			S_Circle_r = 180/2;
			e_r = S_Circle_r;
			e_r_d = 15*2;
			e_r_dd = -0.3*2;
			loop(90/2){
				e_r -= e_r_d;
				e_r_d -= e_r_dd;
				e_r = absolute(e_r);
				descent( i in 0..way1){
					descent( j in 0..way2){
						ObjPrim_SetVertexUVT(obj, i*18+2*j, j/8*256,65);
						ObjPrim_SetVertexUVT(obj, i*18+2*j+1, j/8*256,95);
						ObjPrim_SetVertexPosition(obj, i*18+2*j, (e_r+16+2)*cos(120*i+e_ang_sub*j), (e_r+16+2)*sin(120*i+e_ang_sub*j),0);
						ObjPrim_SetVertexPosition(obj, i*18+2*j+1, (e_r+0+2)*cos(120*i+e_ang_sub*j), (e_r+0+2)*sin(120*i+e_ang_sub*j),0);
					}
				}
				yield;
			}
		}
		function SpellCircleMoveAnima
		{
			let frame = 0;
			let alp = 1;
			let cx = ObjMove_GetX(objEnemy);
			let cy = ObjMove_GetY(objEnemy);
	
			S_Circle_r = 180;
			Ring_SpGet;
			loop(close_f)
			{
				cx = GetPlayerX();
				cy = GetPlayerY();
		
				if(frame >= 45)
				{
					alp -= 1 / 45;
					//alpha = max(alpha, 0);
				}
				e_ang += e_ang_d;
				if(e_ang > 360){e_ang += -360;}
				if(e_ang < -360){e_ang += 360;}
				ObjRender_SetAngleZ(obj,e_ang);
				ObjRender_SetPosition(obj, cx, cy, 0);
				ObjRender_SetColor(obj, alpha*alp*c_Alpha_Rate, alpha*alp*c_Alpha_Rate, alpha*alp*c_Alpha_Rate);
				frame++;
				yield;
			}
		}
	
		if(typeEnd == END_SUCCESS){SpellCircleMoveAnima; 
		
		}
		Obj_Delete(obj);
	}

	//撪墌乽Spell Card Attack of Little Girl...乿
	task Spell_CircleB(layer){
		let e_r = 0;
		let e_ang_d = -3.5;
		let e_ang = 0;
		let e_ang_sub = 360/24;
		let e_alp = 255;
		let alpha = 255;
	
		let cx = ObjMove_GetX(objEnemy);
		let cy = ObjMove_GetY(objEnemy);
	
		let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
		ObjPrim_SetTexture(obj, imgEffLine);
	
		ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjPrim_SetVertexCount(obj, way);
		ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
		ObjRender_SetFogEnable(obj,false);
		Obj_SetRenderPriorityI(obj, layer+9);
	
		ascent( i in 0..way1){
			ascent( j in 0..way2){
				ObjPrim_SetVertexUVT(obj, i*18+2*j, j/8*256,97);
				ObjPrim_SetVertexUVT(obj, i*18+2*j+1, j/8*256,127);
				ObjPrim_SetVertexPosition(obj, i*18+2*j, e_r*cos(120*i+e_ang_sub*j), e_r*sin(120*i+e_ang_sub*j),0);
				ObjPrim_SetVertexPosition(obj, i*18+2*j+1, e_r*cos(120*i+e_ang_sub*j), e_r*sin(120*i+e_ang_sub*j),0);
			}
		}
		ObjRender_SetColor(obj, alpha*c_Alpha_Rate, alpha*c_Alpha_Rate, alpha*c_Alpha_Rate);
	
	
		//奜廃偺捀揰憖嶌
		task e_vt_out{
			let e_r_sub = 0;
	
			let e_r_sub_ang = 0;
			let e_r_sub_ang_d = 180/90;
			loop(90){
				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( i in 0..way1){
					ascent( j in 0..9){
						ObjPrim_SetVertexPosition(obj, i*18+2*j, e_r_sub*cos(120*i+e_ang_sub*j), e_r_sub*sin(120*i+e_ang_sub*j),0);
					}
				}
				yield;
			}
		}
	
		//撪廃偺捀揰憖嶌
		task e_vt_in{
			let e_r_sub = -90;
			let e_r_sub_ang = 0;
			let e_r_sub_ang_d = 180/30;
	
			loop(60){
				e_r_sub_ang += e_r_sub_ang_d;
				e_r_sub += 90/60;
				ascent( i in 0..way1){
					ascent( j in 0..9){
						ObjPrim_SetVertexPosition(obj, i*18+2*j+1, e_r_sub*cos(120*i+e_ang_sub*j), e_r_sub*sin(120*i+e_ang_sub*j),0);
					}
				}
				yield;
			}
			loop(30){
				e_r_sub_ang += e_r_sub_ang_d;
				e_r_sub = (S_Circle_r-10)/2 - (S_Circle_r-10)/2*cos(e_r_sub_ang);
				ascent( i in 0..way1){
					ascent( j in 0..9){
						ObjPrim_SetVertexPosition(obj, i*18+2*j+1, e_r_sub*cos(120*i+e_ang_sub*j), e_r_sub*sin(120*i+e_ang_sub*j),0);
					}
				}
				yield;
			}
		}
		//屻偼彊乆偵敿宎傪彫偝偔丅
		task e_vt_reduce{
			e_r = S_Circle_r+6;
			let e_r_d = -(S_Circle_r-16)/(GetTimers-90);
	
			loop(90){yield;}
			while(typeEnd == 0){
				e_r += e_r_d;
				e_r = absolute(e_r);
				ascent( i in 0..way1){
					ascent( j in 0..9){
						ObjPrim_SetVertexPosition(obj, i*18+2*j, e_r*cos(120*i+e_ang_sub*j), e_r*sin(120*i+e_ang_sub*j),0);
						ObjPrim_SetVertexPosition(obj, i*18+2*j+1, (e_r-16)*cos(120*i+e_ang_sub*j), (e_r-16)*sin(120*i+e_ang_sub*j),0);
					}
				}
				yield;
			}
		}
		task e_vt_out_spGet{
			S_Circle_r = 180/2;
			let e_r_sub = (S_Circle_r+6)/2;
			let e_r_sub_ang = 180;
			let e_r_sub_ang_d = 180/90*2;
			loop(90/2){
				e_r_sub_ang -= e_r_sub_ang_d;
				e_r_sub = (S_Circle_r+6) - (S_Circle_r+6)/2*cos(e_r_sub_ang*2);
				descent( i in 0..way1){
					descent( j in 0..9){
						ObjPrim_SetVertexPosition(obj, i*18+2*j, e_r_sub*cos(120*i+e_ang_sub*j), e_r_sub*sin(120*i+e_ang_sub*j),0);
					}
				}
				yield;
			}
		}
	
		//撪廃偺捀揰憖嶌
		task e_vt_in_spGet{
			S_Circle_r = 180/2;
			let e_r_sub = (S_Circle_r-10)/2;
			let e_r_sub_ang = 180;
			let e_r_sub_ang_d = 180/30*2;
			loop(30/2){
				e_r_sub_ang -= e_r_sub_ang_d;
				e_r_sub = 0 - (S_Circle_r-10)/2*cos(e_r_sub_ang);
				descent( i in 0..way1){
					descent( j in 0..9){
						ObjPrim_SetVertexPosition(obj, i*18+2*j+1, e_r_sub*cos(120*i+e_ang_sub*j), e_r_sub*sin(120*i+e_ang_sub*j),0);
					}
				}
				yield;
			}
		}
	
	function SpellCircleMoveAnima
	{
		let rRate = 1.0;
		let frame = 0;
		let alp = 1;
		let cx = ObjMove_GetX(obj);
		let cy = ObjMove_GetY(obj);
		let rRateOut = 1.0;
		let rRateIn = 1.0;
		let er = e_r;
		S_Circle_r = 180;
		e_vt_out_spGet;
		e_vt_in_spGet;
		loop(close_f)
		{
			cx = GetPlayerX();
			cy = GetPlayerY();
			if(frame >= 45)
			{
				alp -= 1 / 45;
			}
			if(frame <= 45)
			{
				//杺曽恮奼戝
				S_Circle_r += (180-16)/45;
			}
			else
			{
				S_Circle_r -= (180-16)/(close_f-45-30);
			}
	
			e_ang += e_ang_d;
			if(e_ang > 360){e_ang += -360;}
			if(e_ang < -360){e_ang += 360;}
			ObjRender_SetAngleZ(obj,e_ang);
			ObjRender_SetPosition(obj, cx, cy, 0);
			ObjRender_SetColor(obj, alpha*alp*c_Alpha_Rate, alpha*alp*c_Alpha_Rate, alpha*alp*c_Alpha_Rate);
			frame++;
			yield;
		}
	}
	
	
		//捀揰憖嶌
		e_vt_in;
		e_vt_out;
		e_vt_reduce;
	
		//夞揮丒堏摦
		while(typeEnd == 0){
			e_ang += e_ang_d;
			if(e_ang > 360){e_ang += -360;}
			if(e_ang < -360){e_ang += 360;}
			ObjRender_SetAngleZ(obj,e_ang);
			e_r = absolute(e_r);
	
			if(!Obj_IsDeleted(objEnemy))
			{
				cx = cx * 0.95 + ObjMove_GetX(objEnemy) * 0.05;
				cy = cy * 0.95 + ObjMove_GetY(objEnemy) * 0.05;
			}
			ObjRender_SetPosition(obj, cx, cy, 0);
			yield;
		}
		if(typeEnd == END_SUCCESS){SpellCircleMoveAnima;
		}
		Obj_Delete(obj);
	}

	Spell_CircleA(23);
	Spell_CircleB(23);
}
}
// ===========================================================
// 敪摦帪偺乽SpellCardAttack!!乿偺僄僼僃僋僩
// ===========================================================
task SpellCardAttackEffect{
	let x    = GetStgFrameWidth/2;
	let y    = GetStgFrameHeight/2 - 155;
	let dirL = -1;
	ascent( i in 0..10){
		AttackEffLine(x,y+(30*i), dirL);
		dirL *= -1;
	}

	AttackEffCircle(0 + 60, 0 + 60, 120,  1);
	AttackEffCircle(GetStgFrameWidth - 60, GetStgFrameHeight - 60, 130, -1);
	AttackEffCircle(GetStgFrameWidth - 60, GetStgFrameHeight - 60, 160,  1);
	AttackEffCircle(GetStgFrameWidth - 60, GetStgFrameHeight - 60, 190,  1);
//}
}

//捈慄昤夋惂屼
task AttackEffLine(x,y, dir) {
	let obj  = ObjPrim_Create(OBJ_PRIMITIVE_2D);

	let alpha = 0;
	let r     = 255;
	let g     = 255;
	let b     = 255;

	let u     = rand(0, 50);

	ObjRender_SetPosition(obj, x, y, 0);
	ObjPrim_SetTexture(obj, imgEffLine);
	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	Obj_SetRenderPriorityI(obj, 23);

	ObjPrim_SetVertexCount(obj, 4);
	ObjPrim_SetVertexPosition(obj, 0, 250*cos(150) + 8*cos( 240), 250*sin(150) + 8*sin( 240),0);
	ObjPrim_SetVertexPosition(obj, 1, 250*cos(150) + 8*cos(  60), 250*sin(150) + 8*sin(  60),0);
	ObjPrim_SetVertexPosition(obj, 2, 250*cos(-30) + 8*cos(-120), 250*sin(-30) + 8*sin(-120),0);
	ObjPrim_SetVertexPosition(obj, 3, 250*cos(-30) + 8*cos(  60), 250*sin(-30) + 8*sin(  60),0);
	SetUV(0);


	function SetUV(u)
	{
		ObjPrim_SetVertexUVT(obj, 0,   0+u, 192);
		ObjPrim_SetVertexUVT(obj, 1,   0+u, 224);
		ObjPrim_SetVertexUVT(obj, 2,1024+u, 192);
		ObjPrim_SetVertexUVT(obj, 3,1024+u, 224);
		ObjRender_SetColor(obj,alpha,alpha,alpha);
	}


	loop(20) {
	  u     += 1.5 * dir;
	  alpha += 192/20;
	  SetUV(u);
	  yield;
	}

	loop(100) {
	  u += 1.5 * dir;
	  SetUV(u);
	  yield;
	}

	loop(30) {
	  u     += 1.5 * dir;
	  alpha -= 192/30;
	  SetUV(u);
	  yield;
	}

	Obj_Delete(obj);
}
//墌宍昤夋惂屼
task AttackEffCircle(x, y, radius, dir) {
	let obj  = ObjPrim_Create(OBJ_PRIMITIVE_2D);

	let angle = 0;

	let alpha = 0;
	let r     = 255;
	let g     = 255;
	let b     = 255;

	ObjRender_SetPosition(obj, x, y, 0);
	ObjPrim_SetTexture(obj, imgEffLine);
	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	Obj_SetRenderPriorityI(obj, 30);

	ObjPrim_SetVertexCount(obj, 32);
	ascent( i in 0..8) {
		ObjPrim_SetVertexPosition(obj, i*4,     (radius+8)*cos(angle+(45*i)),     (radius+8)*sin(angle+(45*i)),0);
		ObjPrim_SetVertexPosition(obj, (i*4)+1, (radius-8)*cos(angle+(45*i)),     (radius-8)*sin(angle+(45*i)),0);
		ObjPrim_SetVertexPosition(obj, (i*4)+2, (radius+8)*cos(angle+(45*(i+1))), (radius+8)*sin(angle+(45*(i+1))),0);
		ObjPrim_SetVertexPosition(obj, (i*4)+3, (radius-8)*cos(angle+(45*(i+1))), (radius-8)*sin(angle+(45*(i+1))),0);
	}

	ascent( i in 0..8) {
		ObjPrim_SetVertexUVT(obj, i*4,     256, 256);
		ObjPrim_SetVertexUVT(obj, (i*4)+1, 256, 224);
		ObjPrim_SetVertexUVT(obj, (i*4)+2,   0, 256);
		ObjPrim_SetVertexUVT(obj, (i*4)+3,   0, 224);
	}

	ObjRender_SetColor(obj,alpha,alpha,alpha);


	loop(20) {
	  angle += 1.5 * dir;
	  alpha += 192/20;

	  ascent( i in 0..8) {
		ObjPrim_SetVertexPosition(obj, i*4,     (radius+8)*cos(angle+(45*i)),     (radius+8)*sin(angle+(45*i)),0);
		ObjPrim_SetVertexPosition(obj, (i*4)+1, (radius-8)*cos(angle+(45*i)),     (radius-8)*sin(angle+(45*i)),0);
		ObjPrim_SetVertexPosition(obj, (i*4)+2, (radius+8)*cos(angle+(45*(i+1))), (radius+8)*sin(angle+(45*(i+1))),0);
		ObjPrim_SetVertexPosition(obj, (i*4)+3, (radius-8)*cos(angle+(45*(i+1))), (radius-8)*sin(angle+(45*(i+1))),0);
	  }
	  ObjRender_SetColor(obj,alpha,alpha,alpha);

	  yield;
	}

	loop(100) {
	  angle += 1.5 * dir;

	  ascent( i in 0..8) {
		ObjPrim_SetVertexPosition(obj, i*4,     (radius+8)*cos(angle+(45*i)),     (radius+8)*sin(angle+(45*i)),0);
		ObjPrim_SetVertexPosition(obj, (i*4)+1, (radius-8)*cos(angle+(45*i)),     (radius-8)*sin(angle+(45*i)),0);
		ObjPrim_SetVertexPosition(obj, (i*4)+2, (radius+8)*cos(angle+(45*(i+1))), (radius+8)*sin(angle+(45*(i+1))),0);
		ObjPrim_SetVertexPosition(obj, (i*4)+3, (radius-8)*cos(angle+(45*(i+1))), (radius-8)*sin(angle+(45*(i+1))),0);
	  }

	  yield;
	}

	loop(30) {
	  angle += 1.5 * dir;
	  alpha -= 192/30;

	  ascent( i in 0..8) {
		ObjPrim_SetVertexPosition(obj, i*4,     (radius+8)*cos(angle+(45*i)),     (radius+8)*sin(angle+(45*i)),0);
		ObjPrim_SetVertexPosition(obj, (i*4)+1, (radius-8)*cos(angle+(45*i)),     (radius-8)*sin(angle+(45*i)),0);
		ObjPrim_SetVertexPosition(obj, (i*4)+2, (radius+8)*cos(angle+(45*(i+1))), (radius+8)*sin(angle+(45*(i+1))),0);
		ObjPrim_SetVertexPosition(obj, (i*4)+3, (radius-8)*cos(angle+(45*(i+1))), (radius-8)*sin(angle+(45*(i+1))),0);
	  }
	  ObjRender_SetColor(obj,alpha,alpha,alpha);

	  yield;
	}

	Obj_Delete(obj);
}

task DeleteAtFrame(obj,frame){
loop(frame){yield;}
Obj_Delete(obj);
}