task TMariFlash
{
	let path = PlayerPath;
	PlayerPath = GetCurrentScriptDirectory ~ "pl0/Sprite.png";

	let spell = GetFlashManageObject;

	IsHitEnable = false;

	let obj = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
	ObjPrim_SetTexture(obj, GetCurrentScriptDirectory() ~ "./pl0/flash.png");
	let scaleM = 150;

	let x = GetPlayerX;
	let yM = GetPlayerY;
	let y = yM;
	let angle = rand(0,360);
	let scale = 0;
	let scaleA = 180;
	let scaleB = 0;
	let blink = false;
	ascent(t in 0..180)
		{
		if(t >= 170)	
			{
			scale-=1/10;
			}
		else if(scale < 1)
			{
			scale+=1/10;
			}		
		if(t == 15)
			{
			IsHitEnable = true;
			}
		scaleA+=9;
		scaleB = scale*scaleM*(0.95+0.05*cos(scaleA));

		y=yM-(GetStgFrameHeight*0.8)*(1-cos(t*90/180));

		angle+=2;

		let array = GetShotIdInCircleA2(x,y,scaleB,TARGET_ENEMY);
		ascent(i in 0..length(array))
			{
			let shot = array[i];
			if(!ObjShot_IsSpellResist(shot))
				{
				let xS = ObjMove_GetX(shot);
				let yS = ObjMove_GetY(shot);
				let distS = GetDistance(x,y,xS,yS);
				if(distS <= scaleB*0.5)
					{
					let angle = atan2(yS-y,xS-x);
					let dist = min(distS+2,scaleB+2);
					ObjMove_SetPosition(shot,x+dist*cos(angle),y+dist*sin(angle));
					ObjMove_SetSpeed(shot,2);
					ObjMove_SetAngle(shot,angle);
					}
				}
			}
		
		ObjSpriteList2D_ClearVertexCount(obj);
		TRender;
		if(!IsPermitPlayerSpell)
			{
			break;
			}
		yield;
		}	
	Obj_Delete(obj);
	PlayerPath = path;
	Obj_Delete(spell);

	task TRender
		{
		ObjSpriteList2D_SetSourceRect(obj, 0, 0, 128, 128);
		ObjSpriteList2D_SetDestRect(obj, 0,0,1,1);
		ObjRender_SetColorHSV(obj,0,0,225);
		ObjRender_SetPosition(obj,x,y,0);
	
		ObjRender_SetAngleZ(obj,angle);
		ObjRender_SetScaleXYZ(obj,scaleB*1/1.125,scaleB*1/1.125,0);
		Obj_SetRenderPriority(obj, 0.3);
		ObjRender_SetAlpha(obj,205);
		ObjSpriteList2D_AddVertex(obj);
		
		ObjRender_SetAngleZ(obj,-angle*1.125);
		ObjRender_SetScaleXYZ(obj,scaleB,scaleB,0);
		Obj_SetRenderPriority(obj, 0.29);
		ObjRender_SetAlpha(obj,135);
		ObjSpriteList2D_AddVertex(obj);
		}
}