task TShadow
	{
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "../system/img/WhiteSquare.png");	
	ObjSprite2D_SetSourceRect(obj,0,0,1,1);
	ObjSprite2D_SetDestRect(obj,-64,-64,GetStgFrameWidth+64,GetStgFrameHeight+64);
	ObjRender_SetColorHSV(obj,0,0,0);
	Obj_SetRenderPriority(obj,0.3);
	ascent(t in 1..36)
		{
		ObjRender_SetAlpha(obj,t*255/35);
		ObjRender_SetAlpha(img,(36-t)*255/35);
		yield;
		}
	while(SpellSwitch == false){yield;}
	loop(25){yield;}
	descent(t in 0..20)
		{
		ObjRender_SetAlpha(obj,t*255/20);
		ObjRender_SetAlpha(img,(20-t)*255/20);
		yield;
		}
	Obj_Delete(obj);
	}

task TKoiSpell
{
	let spell = GetSpellManageObject();
	SpellSwitch = false;
	ShotPermit = false;
	SetPlayerSpeed(7.5,7.5);
	TShadow;
	let spread = 3;
	SetPlayerInvincibilityFrame(5*5*10+120);
	ascent(t in 0..5)
		{
		ascent(i0 in 0..5)
			{
			ascent(i1 in 0..spread+1)
				{
				TSpam(GetStgFrameWidth+8,(i1+i0*0.15+t*0.05)*GetStgFrameHeight/spread,180,0);
				TSpam((i1+i0*0.15+t*0.05)*GetStgFrameWidth/spread,-8,90,1);
				}
			PlaySound("se_Shot4",100);
			loop(10){yield;}
			}
		}
	loop(30){yield;}
	PlaySound("se_Die5",120);
	SpellSwitch = true;
	ShotPermit = true;
	SetPlayerSpeed(PlayerSpeed[0],PlayerSpeed[1]);
	loop(20){yield;}
	Obj_Delete(spell);

	task TSpam(x,y,angle,graph)
		{
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		Obj_SetRenderPriority(obj,0.5);
		let scale = 8;
		let scaleM = 64;	
		let damage = false;
		let alpha = 255;
		while(!Obj_IsDeleted(obj) && x > -9 && x < GetStgFrameWidth+9 && y > -9 && y < GetStgFrameHeight+9)
			{
			if(GetDistance(PlayerX,PlayerY,x,y) < 64 && SpellSwitch == false)
				{
				if(scale < scaleM)
					{
					scale+=scaleM/7;
					}
				else
					{
					PlaySound("se_Shot5",100);
					scale=scaleM;
					}
				damage = true;
				ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "pl0/Sprite.png");
				ObjSprite2D_SetSourceRect(obj,graph*64,176,(graph+1)*64,240);
				ObjRender_SetColorHSV(obj,graph,0,255);
				}
			else
				{
				if(scale > 8)
					{
					scale-=(scaleM-8)/7;
					}
				else
					{
					scale = 8;
					ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "../system/img/WhiteCircleAlpha.png");
					ObjSprite2D_SetSourceRect(obj,0,0,64,64);
					}
				damage = false;
				ObjRender_SetColorHSV(obj,graph*240,155,255);
				}
			if(SpellSwitch == true)
				{	
				damage = true;
				alpha-=255/20;
				ObjRender_SetAlpha(obj,alpha);
				scale+=scaleM/20;
				}
			if(damage == true)
				{
				let array = GetAllEnemyID;
				ascent(i in 0..length(array))
					{
					let enemy = array[i];
					if(!Obj_IsDeleted(enemy) && Obj_GetValueD(enemy,"PLAYER",false) == false && GetDistance(x,y,ObjMove_GetX(enemy),ObjMove_GetY(enemy)) <= scale && IsPermitPlayerShot == true)
						{
						let shot = CreatePlayerShotA1(ObjMove_GetX(enemy),ObjMove_GetY(enemy),0,0,1.75,100,0);
						Obj_DelayDelete(shot,2);
						}
					}
				array = GetShotIdInCircleA2(x,y,scale,TARGET_ENEMY);
				ascent(i in 0..length(array))
					{
					let enemy = array[i];
					if(!Obj_IsDeleted(enemy) && ObjShot_IsSpellResist(enemy) == false)
						{		
						ObjShot_ToItem(enemy);
						}
					}
				}
			x+=4*cos(angle);
			y+=4*sin(angle);
			ObjRender_SetPosition(obj,x,y,0);
			ObjSprite2D_SetDestRect(obj,-scale,-scale,scale,scale);
			yield;
			}
		Obj_Delete(obj);
		}
}
