#TouhouDanmakufu[Player]
#ScriptVersion[3]	
#ID["Shitodo"]
#Title["Shitodo"]
#Text["Shitodo family. [r] Switch by pressing C"]
#Image["./Cutin.png"]
#ReplayName["Shitodo"]

let objPlayer = GetPlayerObjectID();
let objSlowShot = ID_INVALID;
let current = GetCurrentScriptDirectory();
let enemy;
let focus = false;
let type = 0;
let vx = 5;
let vy = 2.25;
let spelltime = false;
let arr1 = [];
let arr2 = [];
let arr3 = [];
let arr4 = [];
let arr5 = [];
let lwidth = 0;
let lwidthC = 0;
let enemyCount;

task EnemyCount{
	loop{
		enemyCount = length(GetIntersectionRegistedEnemyID());
		yield;
	}
}
let s = ObjSound_Create;
@Initialize
{
	SetPlayerSpeed(vx, vy);
	SetPlayerClip(12,12,GetStgFrameWidth-12,GetStgFrameHeight-12);
	SetPlayerDownStateFrame(60);
	SetPlayerRebirthFrame(20);
	let path = current ~ "MarisaShotData.txt";
	LoadPlayerShotData(path); //???????
	ObjPlayer_AddIntersectionCircleA1(objPlayer, 0, 0, 2, 25);
	LoadSound(GetCurrentScriptDirectory~"graze.wav");
	LoadSound(GetCurrentScriptDirectory~"se_shot.wav");
	LoadSound(GetCurrentScriptDirectory~"Eff2.wav");
	LoadSound(GetCurrentScriptDirectory~"Shot6.wav");
	LoadSound(GetCurrentScriptDirectory~"Shot7.wav");
	LoadSound(GetCurrentScriptDirectory~"Shot8.wav");
	LoadSound(GetCurrentScriptDirectory~"Shot9.wav");
	LoadSound(GetCurrentScriptDirectory~"Laser7.wav");
	LoadSound(GetCurrentScriptDirectory~"Charge1.wav");
	LoadSound(GetCurrentScriptDirectory~"Charge2.wav");
	LoadSound(GetCurrentScriptDirectory~"SpellCard.wav");
	LoadSound(current~"se_pldead.dat");
	//SetPlayerInvincibilityFrame(99999999999);
	TImage();
	TShot();
	TMagicCircle();
	TMagicCircle2();
	HitBox(3);
	HitBox(-3);
	Orb;
}

@MainLoop
{
	enemy = GetAllEnemyID;
	yield;
}

@FinalizeShot
{
}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_SPELL)
	{
		//????????
		let spell = GetPlayerSpell();
		if(spell >= 1)
		{
			SetScriptResult(true);
			SetPlayerSpell(spell-1);
			if(type==0)
			{
			TSpellA;
			}
			if(type==1)
			{
			TSpellH;
			}
			if(type==2)
			{
			TSpellK;
			}
			
		}
		else
		{
			SetScriptResult(false);
		}
	}
	case(EV_HIT)
	{
		PlaySE(GetCurrentScriptDirectory~"se_pldead.wav");
		TExplosion();
	}
	case(EV_PLAYER_REBIRTH)
	{
		//??
		SetPlayerSpell(3);
		SetPlayerInvincibilityFrame(180);
	}
		case(EV_GRAZE){
			PlaySE(GetCurrentScriptDirectory~"graze.wav");
		}
				case(EV_GET_ITEM)
		{
			let itemType = GetEventArgument(0);
			alternative(itemType)
				case(ITEM_1UP){
					PlaySE(current~"./1up.wav");
					SetPlayerLife(GetPlayerLife);
					WriteLog("ITEM_1UP");
				}
				case(ITEM_1UP_S){
					PlaySE(current~"./1up.wav");
					SetPlayerLife(GetPlayerLife);
					WriteLog("ITEM_1UP_S");
				}
				case(ITEM_SPELL){
					PlaySE(current~"./item_00.wav");
					SetPlayerSpell(GetPlayerSpell);
					WriteLog("ITEM_SPELL");
				}
				case(ITEM_SPELL_S){
					PlaySE(current~"./item_00.wav");
					SetPlayerSpell(GetPlayerSpell);
					WriteLog("ITEM_SPELL_S");
				}
				case(ITEM_POWER){
					PlaySE(current~"./item_00.wav");
					WriteLog("ITEM_POWER");
				}
				case(ITEM_POWER_S){
					PlaySE(current~"./item_00.wav");
					WriteLog("ITEM_POWER_S");
				}
				case(ITEM_POINT){
					PlaySE(current~"./item_00.wav");
					WriteLog("ITEM_POWER");
				}
				case(ITEM_POINT_S){
					PlaySE(current~"./item_00.wav");
					WriteLog("ITEM_POWER_S");
				}
		}
	
}

task TImage
{
	let f = 0;
	let f2 = 0;
	let px = 31;
	let py = 53;
	let path = GetCurrentScriptDirectory() ~ "Sprite.png";
	ObjPrim_SetTexture(objPlayer, path);
	Obj_SetRenderPriorityI(objPlayer,45);
	ObjRender_SetScaleXYZ(objPlayer,1.1,1.1,0);
	loop
	{
	if(type==0)
		{
			let path = GetCurrentScriptDirectory() ~ "AojiS.png";
			ObjPrim_SetTexture(objPlayer, path);
		}
		if(type==1)
		{
			let path = GetCurrentScriptDirectory() ~ "HooakaS.png";
			ObjPrim_SetTexture(objPlayer, path);
		}
		if(type==2)
		{
			let path = GetCurrentScriptDirectory() ~ "KurojiS.png";
			ObjPrim_SetTexture(objPlayer, path);
		}
		
		if(GetVirtualKeyState(VK_LEFT) == KEY_PUSH || GetVirtualKeyState(VK_LEFT) == KEY_HOLD)
		{
			if(f2<1){ObjSprite2D_SetSourceRect(objPlayer, 0, py, px, py*2);}
			if(f2>=1&& f2<=2){ObjSprite2D_SetSourceRect(objPlayer, px, py, px*2, py*2);}
			if(f2>=2 && f2<=3){ObjSprite2D_SetSourceRect(objPlayer, px*2, py, px*3, py*2);}
			if(f2>=3 && f2<=4){ObjSprite2D_SetSourceRect(objPlayer, px*3, py, px*4, py*2);}
			if(f2>=4 && f2<=10){ObjSprite2D_SetSourceRect(objPlayer, px*4, py, px*5, py*2);}
			if(f2>=10&& f2<=16){ObjSprite2D_SetSourceRect(objPlayer, px*5, py, px*6, py*2);}
			if(f2>=16 && f2<=22){ObjSprite2D_SetSourceRect(objPlayer, px*6, py, px*7, py*2);}
			if(f2>=22){ObjSprite2D_SetSourceRect(objPlayer, px*7,py, px*8, py*2);}
			if(f2>=28){f2=12;}
			f2++;
		}
		else if(GetVirtualKeyState(VK_RIGHT) == KEY_PUSH || GetVirtualKeyState(VK_RIGHT) == KEY_HOLD)
		{
			if(f2<1){ObjSprite2D_SetSourceRect(objPlayer, 0, py*2, px, py*3);}
			if(f2>=1&& f2<=2){ObjSprite2D_SetSourceRect(objPlayer, px, py*2, px*2, py*3);}
			if(f2>=2 && f2<=3){ObjSprite2D_SetSourceRect(objPlayer, px*2, py*2, px*3, py*3);}
			if(f2>=3 && f2<=4){ObjSprite2D_SetSourceRect(objPlayer, px*3, py*2, px*4, py*3);}
			if(f2>=4 && f2<=10){ObjSprite2D_SetSourceRect(objPlayer, px*4, py*2, px*5, py*3);}
			if(f2>=10 && f2<=16){ObjSprite2D_SetSourceRect(objPlayer, px*5, py*2, px*6, py*3);}
			if(f2>=16 && f2<=22){ObjSprite2D_SetSourceRect(objPlayer, px*6, py*2, px*7, py*3);}
			if(f2>=22){ObjSprite2D_SetSourceRect(objPlayer, px*7, py*2, px*8, py*3);}
			if(f2>=28){f2=12;}
			f2++;
		}
		else
		{
			if(f<6){ObjSprite2D_SetSourceRect(objPlayer, 0, 1, px, 48);}
			if(f>=6&& f<=12){ObjSprite2D_SetSourceRect(objPlayer, px, 1, px*2, 48);}
			if(f>=12 && f<=18){ObjSprite2D_SetSourceRect(objPlayer, px*2, 1, px*3, 48);}
			if(f>=18 && f<=24){ObjSprite2D_SetSourceRect(objPlayer, px*3, 1, px*4, 48);}
			if(f>=24 && f<=30){ObjSprite2D_SetSourceRect(objPlayer, px*4, 1, px*5, 48);}
			if(f>=30 && f<=36){ObjSprite2D_SetSourceRect(objPlayer, px*5, 1, px*6, 48);}
			if(f>=36 && f<=42){ObjSprite2D_SetSourceRect(objPlayer, px*6, 1, px*7, 48);}
			if(f>=42){ObjSprite2D_SetSourceRect(objPlayer, px*7, 1, px*8, 48);}
			if(f>=48){f=0;}
			f++;
			f2 = 0;
		}
		ObjSprite2D_SetDestCenter(objPlayer);
		yield;
	}

}

task Orb
{
	ascent(i in 0..2) // Generate Orbs
	{
		let obj= CreateTool;
		arr1 = arr1 ~ [obj];
	}
	ascent(i in 0..2) // Generate Orbs
	{
		let obj= CreateTool;
		arr2 = arr2 ~ [obj];
	}
	ascent(i in 0..4) // Generate Orbs
	{
		let obj= CreateTool;
		arr3 = arr3 ~ [obj];
	}

	/*
	1.U:Blue missle / F:Green missle / Bomb: The sun thing
	2.U:Illution Laser [spead] / F:Flame / Bomb:master spark
	3.U:Spread Shot / F:Green Stars (Reisen) / Bomb: Marisa B 11
	4.U:Cold Inferno / F:Alice 11 / Bomb:Cold star
	*/
	ascent(i in 0..2)
	{
		Orb1(arr1[i],i);
		Orb2(arr2[i],i);
	}
	ascent(i in 0..4)
	{
	Orb3(arr3[i],i);
	}

		task Orb1(obj,num)
		{
			let ufco = [[-65,-5],[65,-5]];
			let fco = [[18,-15],[7,-25]];
			let count = 0;
			let dif = [[25,0],[-25,0]];
			let way = [-1,1];
			let siway = [-15,15];
			let time = 10;
			let fcount = 0;
			let dn0 = 0;
			let dn1 = 0;
			let dr0 = dif[num][0]/time;
			let dr1 = dif[num][1]/time;
			ObjRender_SetAlpha(obj,192);
			ObjSprite2D_SetDestRect(obj,-7,-7,7,7);
			ObjSprite2D_SetSourceRect(obj,0,0,16,16);
			while(!Obj_IsDeleted(obj))
			{
				if(GetPlayerState==STATE_DOWN || type!=0){Obj_SetVisible(obj,false);}
				else{Obj_SetVisible(obj,true);}

				ObjRender_SetPosition(obj,GetPlayerX+ufco[num][0]+dn0+siway[num]*sin(count*2),GetPlayerY+ufco[num][1]+dn1,0);

				ObjRender_SetAngleXYZ(obj,0,0,count*way[num]*10);
				count++;
				if(focus==true && fcount<10)
				{
					dn0 += dr0;
					dn1 += dr1;
					fcount++;
				}
				if(focus==false && fcount>0)
				{
					dn0 -= dr0;
					dn1 -= dr1;
					fcount--;
				}
				yield;
			}
		}
		
		task Orb2(obj,num)
		{
			let ufco = [[-65,0],[65,0]];
			let fco = [[16,-15],[6,-25]];
			let count = 0;
			let dif = [[100,0],[-100,0]];
			let way = [0,0];
			let time = 10;
			let fcount = 0;
			let orbcount = 0;
			let dn0 = 0;
			let dn1 = 0;
			let dr0 = dif[num][0]/time;
			let dr1 = dif[num][1]/time;
			ObjRender_SetAlpha(obj,192);
			ObjSprite2D_SetDestRect(obj,-8,-9,8,9);
			ObjSprite2D_SetSourceRect(obj,22,0,38,20);
			while(!Obj_IsDeleted(obj))
			{
				if(GetPlayerState==STATE_DOWN || type!=1){Obj_SetVisible(obj,false);}
				else{Obj_SetVisible(obj,true);}
				if(fcount<10){ObjRender_SetPosition(obj,GetPlayerX+ufco[num][0]+dn0,GetPlayerY+ufco[num][1]+dn1,0);}
				ObjRender_SetPosition(obj,GetPlayerX+ufco[num][0]+dn0,GetPlayerY+ufco[num][1]+dn1+10*sin(num*90+orbcount-40),0);
				ObjRender_SetAngleXYZ(obj,0,0,count*way[num]*10);
				ObjRender_SetScaleXYZ(obj,1.2+0.2*sin(count*8),1.2+0.2*sin(count*8),0);
				count++;
				if(focus==true && fcount<10)
				{
					dn0 += dr0;
					dn1 += dr1;
					fcount++;
				}
				orbcount+=4;
				
				if(focus==false && fcount>0)
				{
					dn0 -= dr0;
					dn1 -= dr1;
					fcount--;
					orbcount=0;
				}
				yield;
			}
		}
		
		task Orb3(obj,num)
		{
			let ufco = [[-35,-40],[-65,5],[35,-40],[65,5]];
			let fco = [[0,-30],[0,-30],[0,-30],[0,-30]];
			let count = 0;
			let dif = [[15,15],[22,-28],[-15,15],[-22,-28]];
			let way = [0,0,0,0];
			let time = 10;
			let fcount = 0;
			let img = GetCurrentScriptDirectory~"jiki_option_04.png";
		    ObjPrim_SetTexture(obj,img);
			let dn0 = 0;
			let dn1 = 0;
			let dir = [270,270,270,270];
			let dr0 = dif[num][0]/time;
			let dr1 = dif[num][1]/time;
			LaserGraphic;
			let f = 0;
			let px = 24;
			ObjRender_SetScaleXYZ(obj,1.5,1.5,0);
			ObjRender_SetAlpha(obj,192);
			ObjSprite2D_SetDestRect(obj,-8,-8,8,8);
			ObjSprite2D_SetSourceRect(obj,29,0,44,14);
			while(!Obj_IsDeleted(obj))
			{
				if(GetPlayerState==STATE_DOWN || type!=2){Obj_SetVisible(obj,false);}
				else{Obj_SetVisible(obj,true);}
			if(f<6){ObjSprite2D_SetSourceRect(obj, 0, 0, px, 24);}
			if(f>=6&& f<=12){ObjSprite2D_SetSourceRect(obj, px, 0, px*2, 24);}
			if(f>=12 && f<=18){ObjSprite2D_SetSourceRect(obj, px*2, 0, px*3, 24);}
			if(f>=18 && f<=24){ObjSprite2D_SetSourceRect(obj, px*3, 0, px*4, 24);}
			if(f>=24 && f<=30){ObjSprite2D_SetSourceRect(obj, px*4, 0, px*5, 24);}
			if(f>=30 && f<=36){ObjSprite2D_SetSourceRect(obj, px*5, 0, px*6, 24);}
			if(f>=36 && f<=42){ObjSprite2D_SetSourceRect(obj, px*6, 0, px*7, 24);}
			if(f>=42){ObjSprite2D_SetSourceRect(obj, px*7, 0, px*8, 24);}
			if(f>=48){f=0;}
			f++;
				ObjRender_SetPosition(obj,GetPlayerX+ufco[num][0]+dn0,GetPlayerY+ufco[num][1]+dn1,0);
				if(focus==true)
					{
					dir = [90+270,90+270,90+270,90+270];
					ObjRender_SetAngleXYZ(obj,0,0,dir[num]);
					}
					if(focus==false)
					{
					let oa = sin(count/2)*40;
					dir = [90+250+oa,90+220-oa,90+290+oa,90+320-oa];
					ObjRender_SetAngleXYZ(obj,0,0,dir[num]);
					}
				count++;
				if(focus==true && fcount<10)
				{
					dn0 += dr0;
					dn1 += dr1;
					fcount++;
				}
				if(focus==false && fcount>0)
				{
					dn0 -= dr0;
					dn1 -= dr1;
					fcount--;
				}
				yield;
			}
			//GetVirtualKeyState(VK_SHOT)==KEY_HOLD
			task LaserGraphic
			{
				let laser = ObjPrim_Create(OBJ_SPRITE_2D); // graphic
				let img = GetCurrentScriptDirectory~"b040.png";
				let angle = [270,270,270,270];
				ObjPrim_SetTexture(laser,img);
				ObjSprite2D_SetSourceRect(laser,0,0,512,12);
				ObjSprite2D_SetDestCenter(laser);
				Obj_SetRenderPriorityI(laser,43);
				ObjRender_SetBlendType(laser,BLEND_ADD_ARGB);
				ObjRender_SetColor(laser,192,192,192);
				while(!Obj_IsDeleted(obj))
				{
					ObjRender_SetPosition(laser,ObjRender_GetX(obj)+256*cos(angle[num]),ObjRender_GetY(obj)+256*sin(angle[num]),0);
					ObjSprite2D_SetSourceRect(laser,-count*8.5,0,512-count*8.5,12);
					ObjRender_SetScaleY(laser,lwidth/4);
					let oa = sin(count/2)*40;
					if(focus==true)
					{
					angle = [270,270,270,270];
					ObjRender_SetAngleXYZ(laser,0,0,angle[num]);
					}
					if(focus==false)
					{
					angle = [250+oa,220-oa,290+oa,320-oa];
					ObjRender_SetAngleXYZ(laser,0,0,angle[num]);
					}
					if(GetPlayerState==STATE_DOWN || lwidth<=0 || type!=2 || IsPlayerSpellActive){Obj_SetVisible(laser,false);}
					else{Obj_SetVisible(laser,true);}
					let eneid = GetIntersectionRegistedEnemyID;
					ascent(i in 0..length(eneid))
					{
						let lx = ObjRender_GetX(obj);
						let ly = ObjRender_GetY(obj);
						if(IsIntersected_Line_Circle(lx,ly,lx+600*cos(angle[num]),ly+600*sin(angle[num]),24,ObjMove_GetX(eneid[i]),ObjMove_GetY(eneid[i]),10)
						&& count%4==0 && GetVirtualKeyState(VK_SHOT)==KEY_HOLD && type==2  && !IsPlayerSpellActive && GetPlayerState!=STATE_DOWN )
						{
							let dis = GetObjectDistance(obj,eneid[i]);
							LaserDamage(eneid[i],ObjRender_GetX(obj)+dis*cos(angle[num]),ObjRender_GetY(obj)+dis*sin(angle[num]),angle[num]);
							
						}
					}
					yield;
			}
			}
task LaserDamage(obj,x,y,dir)
{
	let mainobj = CreatePlayerShotA1(x,y,0,dir,6.5,1,5);
	let finalpos = 0;
	let graphic= ObjPrim_Create(OBJ_SPRITE_2D); // graphic
	let img = GetCurrentScriptDirectory~"Sprite.png";
	ObjPrim_SetTexture(graphic,img);
	ObjRender_SetPosition(graphic,x,y,0);
	ObjSprite2D_SetSourceRect(graphic,228,192,256,211);
	ObjSprite2D_SetDestCenter(graphic);
	ObjRender_SetAngleZ(mainobj,-90);
	ObjRender_SetAlpha(mainobj,0);
	ObjRender_SetScaleXYZ(mainobj,4.5,4.5,0);
	ObjRender_SetAngleXYZ(graphic,0,0,dir);
	ObjRender_SetColor(graphic,200,200/3,200/3);
	
	ascent(i in 0..6)
	{
	loop(2)
		{
			ObjRender_SetPosition(graphic,x-finalpos*cos(dir),y-finalpos*sin(dir),0);
			finalpos-=5;
			yield;
		}
		ObjRender_SetAlpha(graphic,200-i*2);
		ObjRender_SetColor(graphic,200,200/3,200/3);
		ObjRender_SetScaleXYZ(graphic,1/i*0.8,1/i*0.8,0);
		yield;
	}
	Obj_Delete(graphic);
	Obj_Delete(mainobj);
}
			
			}
		}
	
	
function CreateTool
{
		let obj=ObjPrim_Create(OBJ_SPRITE_2D); 
		let img = GetCurrentScriptDirectory~"Shitop.png";
		ObjPrim_SetTexture(obj,img);
		ObjRender_SetBlendType(obj,BLEND_ALPHA);
		Obj_SetRenderPriorityI(obj,45);
		return obj;
}

task TShot
{
	let shotCount = -1;
	let bNextShot = false;
	let objShot = ID_INVALID;
	let shotnum = 0;
	AddVirtualKey(VK_USER1,KEY_C,KEY_INVALID);
	LoadSound(GetCurrentScriptDirectory~"Shot9.wav");
	loop
	{
		if(GetVirtualKeyState(VK_USER1)==KEY_PUSH && spelltime == false)
		{
			PlaySE(GetCurrentScriptDirectory~"Shot9.wav");
			type = (type+1)%3;
		}
		if((GetVirtualKeyState(VK_SHOT)==KEY_PUSH || GetVirtualKeyState(VK_SHOT)==KEY_HOLD || bNextShot==true) && shotCount==-1)
		{
			shotCount = 0;
			bNextShot = false;
		}
		if(GetVirtualKeyState(VK_SHOT)==KEY_FREE)
		{
			if(lwidth>0){lwidth--;}
			if(lwidthC>0){lwidthC--;}
		}
		if(GetVirtualKeyState(VK_SHOT)==KEY_HOLD && shotCount>0)
		{
			bNextShot = true;
		}
		if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_PUSH || GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD && GetPlayerState == STATE_NORMAL && IsPermitPlayerShot && !IsPlayerSpellActive)
		{
			focus = true;
		}
		else if(GetPlayerState == STATE_NORMAL && IsPermitPlayerShot && !IsPlayerSpellActive)
		{
			focus = false;
			Obj_Delete(objSlowShot);
		}
		
		if(shotCount%2==0 && GetPlayerState==STATE_NORMAL && IsPermitPlayerShot && !IsPlayerSpellActive)
		{
				if(type==0)
				{
					PlaySound("se_shot",98,0);
					let dir = [270,270,270,270];;
					let t = 0;
					if(focus == true) {dir = [270,270,270,270];}
					if(focus==false)
					{
					AojiVanillaBullet(GetPlayerX,GetPlayerY+10,30,250,3.5,1,1,-60,50);
					AojiVanillaBullet(GetPlayerX,GetPlayerY+10,30,270,3.5,1,2,-70,40);
					AojiVanillaBullet(GetPlayerX,GetPlayerY+10,30,290,3.5,1,1,60,50);
					AojiVanillaBullet(GetPlayerX,GetPlayerY+10,30,270,3.5,1,2,70,40);
					
					AojiVanillaBullet(ObjRender_GetX(arr1[0]),ObjRender_GetY(arr1[0]),30,240,1.5,1,1,-60,40);
					AojiVanillaBullet(ObjRender_GetX(arr1[0]),ObjRender_GetY(arr1[0]),30,240,1.5,1,2,-50,30);
					
					AojiVanillaBullet(ObjRender_GetX(arr1[1]),ObjRender_GetY(arr1[1]),30,300,1.5,1,1,60,40);
					AojiVanillaBullet(ObjRender_GetX(arr1[1]),ObjRender_GetY(arr1[1]),30,300,1.5,1,2,50,30);
					}
					if(focus==true)
					{
					AojiVanillaBullet(GetPlayerX,GetPlayerY+10,30,260,3.5,1,1,60,30);
					AojiVanillaBullet(GetPlayerX,GetPlayerY+10,30,285,3.5,1,2,60,40);
					AojiVanillaBullet(GetPlayerX,GetPlayerY+10,30,280,3.5,1,1,-60,30);
					AojiVanillaBullet(GetPlayerX,GetPlayerY+10,30,255,3.5,1,2,-60,40);
					
					AojiVanillaBullet(ObjRender_GetX(arr1[0]),ObjRender_GetY(arr1[0]),30,280,1.5,1,1,-60,40);
					AojiVanillaBullet(ObjRender_GetX(arr1[0]),ObjRender_GetY(arr1[0]),30,280,1.5,1,2,-50,30);
					
					AojiVanillaBullet(ObjRender_GetX(arr1[1]),ObjRender_GetY(arr1[1]),30,260,1.5,1,1,60,40);
					AojiVanillaBullet(ObjRender_GetX(arr1[1]),ObjRender_GetY(arr1[1]),30,260,1.5,1,2,50,30);
					}
					t++;
					shotnum++;
				}
				
				if(type==1 && !IsPlayerSpellActive)
				{
					PlaySound("se_shot",98,0);
					let dir = [270,270,270,270];;
					if(focus == true) {dir = [270,270,270,270];}
					if(focus==false)
					{
					if(shotnum%2==0)
					{
					HoaVanillaBulletR(GetPlayerX,GetPlayerY+10,12,260,3.5,1);
					HoaVanillaBulletR(GetPlayerX,GetPlayerY+10,12,270,3.5,1);
					HoaVanillaBulletR(GetPlayerX,GetPlayerY+10,12,280,3.5,1);
					HoaVanillaBulletR(GetPlayerX,GetPlayerY+10,12,240,3.5,1);
					HoaVanillaBulletR(GetPlayerX,GetPlayerY+10,12,300,3.5,1);
					}
					if(shotnum%10==0)
					{
					HoaSubVanillaBullet(ObjRender_GetX(arr2[0]),ObjRender_GetY(arr2[0])-20,18,270,4,1,7);
					HoaSubVanillaBullet(ObjRender_GetX(arr2[1]),ObjRender_GetY(arr2[1])-20,18,270,4,1,8);
					}
					}
					if(focus==true)
					{
					if(shotnum%2==0)
					{
					HoaVanillaBulletR(GetPlayerX,GetPlayerY+10,12,265,3.5,1);
					HoaVanillaBulletR(GetPlayerX,GetPlayerY+10,12,270,3.5,1);
					HoaVanillaBulletR(GetPlayerX,GetPlayerY+10,12,275,3.5,1);
					HoaVanillaBulletR(GetPlayerX,GetPlayerY+10,12,250,3.5,1);
					HoaVanillaBulletR(GetPlayerX,GetPlayerY+10,12,290,3.5,1);
					}
					if(shotnum%10==0)
					{
					HoaSubVanillaBullet(ObjRender_GetX(arr2[0]),ObjRender_GetY(arr2[0])-20,18,270,4,1,7);
					HoaSubVanillaBullet(ObjRender_GetX(arr2[1]),ObjRender_GetY(arr2[1])-20,18,270,4,1,8);
					}
					}
					shotnum++;
				}
				if(type==2)
				{
					PlaySound("se_shot",98,0);
			
					let t = 0;
					lwidthC = 6;
					if(shotnum%10==0)
					{
					KuroVanillaBullet(GetPlayerX,GetPlayerY+10,35,270,3.5,1,11);
					}
					if(shotnum%10==1)
					{
					KuroVanillaBullet(GetPlayerX,GetPlayerY+10,35,270,3.5,1,11);
					}
					if(shotnum%10==2)
					{
					KuroVanillaBullet(GetPlayerX,GetPlayerY+10,35,270,3.5,1,11);
					}
					if(shotnum%10==3)
					{
					KuroVanillaBullet(GetPlayerX,GetPlayerY+10,35,270,3.5,1,11);
					}
					if(shotnum%10==4)
					{
					KuroVanillaBullet(GetPlayerX,GetPlayerY+10,35,270,3.5,1,11);
					}
					if(focus==false){
					if(shotnum%4==0)
					{
					KuroVanillaBullet(GetPlayerX+20,GetPlayerY+10,35,270,2,1,12);
					KuroVanillaBullet(GetPlayerX-20,GetPlayerY+10,35,270,2,1,12);
					}
					lwidth=8
					}
					if(focus==true){
					if(shotnum%4==0)
					{
					KuroVanillaBullet(GetPlayerX+10,GetPlayerY+10,35,270,2,1,12);
					KuroVanillaBullet(GetPlayerX-10,GetPlayerY+10,35,270,2,1,12);
					}
					lwidth=4
					}
					t+=20;
					shotnum++;
				}
		}

		if(shotCount >= 0)
		{
			shotCount++;
		}
		if(shotCount == 15)
		{
			shotCount=-1;
		}
		yield;
	}
}

task HitBox(z){
		let obj=ObjPrim_Create(OBJ_SPRITE_2D); 
		let img = GetCurrentScriptDirectory~"Focus.png";
		let c = 0;
		let alpha = 0;
		ObjPrim_SetTexture(obj,img);
		ObjSprite2D_SetSourceRect(obj,0,0,64,64);
		ObjSprite2D_SetDestCenter(obj);
		ObjRender_SetBlendType(obj,BLEND_ALPHA);
		while(!Obj_IsDeleted(obj)){
		ObjRender_SetPosition(obj,GetPlayerX,GetPlayerY,0);
		ObjRender_SetAngleXYZ(obj,0,0,c);
		ObjRender_SetAlpha(obj,alpha);
		if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD){
			if(alpha<250){alpha+=30;}
		}
		if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_FREE){
		if(alpha>0){alpha-=30;}
		}
		if(GetPlayerState != STATE_NORMAL){alpha=0;}
		c+=z;
		yield;
		}
	}
	
task AojiVanillaBullet(x,y,spd,dir,dmg,pdmg,type,a_width,b_width)
{
	let shotcolor = type;
	let mx;
	let my;
	let mangle;
	let t = 0;
	let t2 = 1;
	let finalpos = 0;
	let mainobj = CreatePlayerShotA1(x,y,spd,dir,dmg,pdmg,shotcolor);
	ObjRender_SetAngleZ(mainobj, -90);
        Obj_SetRenderPriorityI(mainobj,42);
	let count = 0;
	while(!Obj_IsDeleted(mainobj))
	{
		mx = ObjMove_GetX(mainobj);
		my = ObjMove_GetY(mainobj);
		mangle = ObjMove_GetAngle(mainobj);
		ObjMove_SetAngle(mainobj, dir+cos(t*b_width)*a_width);
		t++;
		yield;
	}
	let obj2 = CreatePlayerShotA1(mx,my,5,mangle,0,10^10,type);
		
		ObjMove_SetAcceleration(obj2,-10/15);
		let alpha = 192;
		ObjMove_SetMaxSpeed(obj2,2.5);
		ObjRender_SetBlendType(obj2,BLEND_ADD_ARGB);
		let alphaM = 192;
		alpha = alphaM;	
		let angleZ = 0;
		let oa = rand(-(t%8-3.5)*5,(t%8-3.5)*5);
		let dirs = mangle;
		loop(15)
			{
			alpha-=alphaM/15;
			angleZ+=14;
			ObjRender_SetAngleZ(obj2,-90+oa*1.2);
			ObjRender_SetAlpha(obj2,alpha);
			ObjRender_SetScaleXYZ(obj2,t2,t2,0);
			t2+=0.08;
			yield;
			}
		Obj_Delete(obj2);
	Obj_Delete(mainobj);
}

task HoaVanillaBulletR(x,y,spd,dir,dmg,pdmg)
{
	let shotcolor = 4;
	let mx;
	let my;
	let mangle;
	let t = 0;
	let t2 = 1;
	let finalpos = 0;
	let mainobj = CreatePlayerShotA1(x,y,spd,dir,dmg,pdmg,shotcolor);
	ObjRender_SetAngleZ(mainobj, -90);
        Obj_SetRenderPriorityI(mainobj,42);
	let count = 0;
	while(!Obj_IsDeleted(mainobj))
	{
		mx = ObjMove_GetX(mainobj);
		my = ObjMove_GetY(mainobj);
		mangle = ObjMove_GetAngle(mainobj);
		if(t>10)
		{
		ObjMove_SetSpeed(mainobj,0);
		ObjRender_SetAlpha(mainobj,110);
		}
		if(t>14)
		{
		ObjMove_SetSpeed(mainobj,20);
        Obj_Delete(mainobj);
		HoaVanillaBulletB(mx,my,20,mangle,3.5,1);
		}
		t++;
		yield;
	}
	let obj2 = CreatePlayerShotA1(mx,my,2,dir,0,10^10,6);
		
		ObjMove_SetAcceleration(obj2,-10/15);
		let alpha = 80;
		ObjMove_SetMaxSpeed(obj2,0);
		ObjRender_SetBlendType(obj2,BLEND_ADD_ARGB);
		let alphaM = 80;
		alpha = alphaM;	
		let angleZ = 0;
		let oa = rand(-(t%8-3.5)*5,(t%8-3.5)*5);
		let dirs = mangle;
		loop(15)
			{
			alpha-=alphaM/15;
			angleZ+=14;
			ObjRender_SetAngleZ(obj2,rand(0,360));
			ObjRender_SetAlpha(obj2,alpha);
			ObjRender_SetScaleXYZ(obj2,t2,t2,0);
			t2+=0.1;
			yield;
			}
		Obj_Delete(obj2);
}

task HoaVanillaBulletB(x,y,spd,dir,dmg,pdmg)
{
	let shotcolor = 5;
	let mx;
	let my;
	let mangle;
	let t = 0;
	let t2 = 1;
	let finalpos = 0;
	let mainobj = CreatePlayerShotA1(x,y,spd,dir,dmg,pdmg,shotcolor);
	ObjRender_SetAngleZ(mainobj, -90);
    Obj_SetRenderPriorityI(mainobj,42);
	let count = 0;
	while(!Obj_IsDeleted(mainobj))
	{
		mx = ObjMove_GetX(mainobj);
		my = ObjMove_GetY(mainobj);
		mangle = ObjMove_GetAngle(mainobj);
		t++;
		yield;
	}
	let obj2 = CreatePlayerShotA1(mx,my,5,dir,0,10^10,6);
		
		ObjMove_SetAcceleration(obj2,-10/15);
		let alpha = 210;
		ObjMove_SetMaxSpeed(obj2,0);
		ObjRender_SetBlendType(obj2,BLEND_ADD_ARGB);
		let alphaM = 210;
		alpha = alphaM;	
		let angleZ = 0;
		let oa = rand(-(t%8-3.5)*5,(t%8-3.5)*5);
		let dirs = mangle;
		loop(15)
			{
			alpha-=alphaM/15;
			angleZ+=14;
			ObjRender_SetAngleZ(obj2,rand(0,360));
			ObjRender_SetAlpha(obj2,alpha);
			ObjRender_SetScaleXYZ(obj2,t2,t2,0);
			t2+=0.1;
			yield;
			}
		Obj_Delete(obj2);
	Obj_Delete(mainobj);
}

task HoaSubVanillaBullet(x,y,spd,dir,dmg,pdmg,type)
{
	let shotcolor = type;
	let mx;
	let my;
	let mangle;
	let t = 0;
	let t2 = 1.4;
	let finalpos = 0;
	let oa = rand(-(t%8-3.5)*5,(t%8-3.5)*5);
	let mainobj = CreatePlayerShotA1(x,y,spd,dir,dmg,pdmg,shotcolor);
	ObjRender_SetAngleZ(mainobj, -90);
    Obj_SetRenderPriorityI(mainobj,42);
	let count = 0;
	while(!Obj_IsDeleted(mainobj))
	{
		mx = ObjMove_GetX(mainobj);
		my = ObjMove_GetY(mainobj);
		mangle = ObjMove_GetAngle(mainobj);
		ObjMove_SetSpeed(mainobj,t-4);
		ObjRender_SetScaleXYZ(mainobj,1.2,1.2,0);
		t++;
		yield;
	}
	if(mx>0 && mx<GetStgFrameWidth && my>0 && my<GetStgFrameHeight)
	{
	delete();
	}
	Obj_Delete(mainobj);
	
task delete()
{
let obj2 = CreatePlayerShotA1(mx+oa,my+oa,5,dir,0,10^10,type+2);
		
		ObjMove_SetAcceleration(obj2,-10/15);
		let alpha = 192;
		ObjMove_SetMaxSpeed(obj2,0);
		ObjRender_SetBlendType(obj2,BLEND_ADD_ARGB);
		let alphaM = 192;
		alpha = alphaM;	
		let angleZ = 0;
		let dirs = mangle;
		loop(15)
			{
			alpha-=alphaM/15;
			angleZ+=14;
			ObjRender_SetAngleZ(obj2,rand(0,360));
			ObjRender_SetAlpha(obj2,alpha);
			ObjRender_SetScaleXYZ(obj2,t2,t2,0);
			t2+=0.4;
			yield;
			}
		Obj_Delete(obj2);
		}
}

task KuroVanillaBullet(x,y,spd,dir,dmg,pdmg,type)
{
	let shotcolor = type;
	let mx;
	let my;
	let mangle;
	let t = 0;
	let t2 = 1;
	let finalpos = 0;
	let mainobj = CreatePlayerShotA1(x,y,spd,dir,dmg,pdmg,shotcolor);
	ObjRender_SetAngleZ(mainobj, -90);
        Obj_SetRenderPriorityI(mainobj,42);
	let count = 0;
	while(!Obj_IsDeleted(mainobj))
	{
		mx = ObjMove_GetX(mainobj);
		my = ObjMove_GetY(mainobj);
		mangle = ObjMove_GetAngle(mainobj);
		t++;
		yield;
	}
	let obj2 = CreatePlayerShotA1(mx,my,10,mangle,0,10^10,type);
		
		ObjMove_SetAcceleration(obj2,-10/15);
		let alpha = 192;
		ObjMove_SetMaxSpeed(obj2,2.5);
		ObjRender_SetBlendType(obj2,BLEND_ADD_ARGB);
		let alphaM = 192;
		alpha = alphaM;	
		let angleZ = 0;
		let oa = rand(-(t%8-3.5)*5,(t%8-3.5)*5);
		let dirs = mangle;
		loop(15)
			{
			alpha-=alphaM/15;
			angleZ+=14;
			ObjRender_SetAngleZ(obj2,-90);
			ObjRender_SetAlpha(obj2,alpha);
			ObjRender_SetScaleXYZ(obj2,1,t2,0);
			t2-=0.08;
			yield;
			}
		Obj_Delete(obj2);
	Obj_Delete(mainobj);
}

let pfPlayerCutInDpellNameDeleted = true;
let pfPlayerCutInSpellNameGhostDeleted = true;
let pfPlayerCuIinameEffectDeleted = true;
let pfPlayerCutInSpellName;
let pfPlayerCutInSpellNameGhost;
let pfPlayerCutInNameEffect;
		
task TSpellA
{
	let current = GetCurrentScriptDirectory();
	let imgEffect = current ~ "./musou_effect.png";
	spelltime = true;
	let objManage = GetSpellManageObject();
	let spell = ObjSpell_Create;
	ObjSpell_Regist(spell);
	ObjSpell_SetDamage(spell,12);

	let t = 1;
	let t2 = 1;
	SetPlayerInvincibilityFrame(380);//無敵時間を設定
	let angle = rand(0, 360);
    SpellUseName(" ",255,255,255);
	PlaySound("cardcall",100,0);
	GraphicSpB;
	GraphicSpB2;
	GraphicSpB3;
	GraphicSpB4(-1);
	GraphicSpB4(1);
	IsPermitPlayerShot;
	SetPlayerSpeed(vx/8,vy/8);
	wait(60);
	PlaySound("bom_07",80,0);
	ScreenShake(280);
	ascent(i in 0 .. 24){
	loop(10){
	ascent(i in 0 .. 5){
	let ar = GetIntersectionRegistedEnemyID;
	AojiBomb(GetPlayerX,GetPlayerY,20,i*72+t*sin(t/1.5),2.5,40,100,20);
	PlaySound("LenenShot3",70,0);
	
	}
		//Musou(angle + 45*i);
		t++;
		wait(1);
		}
	}
	loop(160){
	SetPlayerSpeed(vx,vy);
	spelltime = false;
		yield;
	}
	Obj_Delete(objManage);
	
task AojiBomb(x,y,spd,dir,dmg,pdmg,a_width,b_width)
{
	let shotcolor = 3;
	let mx;
	let my;
	let mangle;
	let t = 0;
	let t2 = 1;
	let finalpos = 0;
	let mainobj = CreatePlayerShotA1(x,y,spd,dir,dmg,pdmg,shotcolor);
	ObjRender_SetAngleZ(mainobj, -90);
    Obj_SetRenderPriorityI(mainobj,42);
	let count = 0;
	while(!Obj_IsDeleted(mainobj))
	{
		mx = ObjMove_GetX(mainobj);
		my = ObjMove_GetY(mainobj);
		mangle = ObjMove_GetAngle(mainobj);
		ObjMove_SetAngle(mainobj, dir+cos(t*b_width)*a_width);
		ObjRender_SetScaleXYZ(mainobj,1,1,1);
		DeleteShotInCircle(TYPE_SHOT, TYPE_ITEM, mx, my, 10);
		t++;
		yield;
	}
	let obj2 = CreatePlayerShotA1(mx,my,5,mangle,0,10^10,3);
		
		ObjMove_SetAcceleration(obj2,-10/15);
		let alpha = 192;
		ObjMove_SetMaxSpeed(obj2,2.5);
		ObjRender_SetBlendType(obj2,BLEND_ADD_ARGB);
		let alphaM = 192;
		alpha = alphaM;	
		let angleZ = 0;
		let oa = rand(-(t%8-3.5)*5,(t%8-3.5)*5);
		let dirs = mangle;
		loop(15)
			{
			alpha-=alphaM/15;
			angleZ+=14;
			ObjRender_SetAngleZ(obj2,-90+oa*1.2);
			ObjRender_SetAlpha(obj2,alpha);
			ObjRender_SetScaleXYZ(obj2,t2,t2,0);
			t2+=0.08;
			yield;
			}
		Obj_Delete(obj2);
	Obj_Delete(mainobj);
}

task GraphicSpB
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 0.95;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 0;
		let an = 0;
		let img = GetCurrentScriptDirectory~"./spbg/02_02.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,512,512);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ALPHA);
		Obj_SetRenderPriorityI(spellgraphic,30);
		ascent(i in 0..20)
		{
		ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
		ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(al<164){al+=15;}
			yield;
		}
		ascent(i in 0..340)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);
			ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetColor(spellgraphic,255,255,255);
			ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(scale<3){scale+=0;}
			speed += acc;
			acc+=0.005;
			cl+=2;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			ObjRender_SetAlpha(spellgraphic,al);
			yield;
		}
		Obj_Delete(spellgraphic);
	}
	
task GraphicSpB2
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 0.6;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 0;
		let an = 0;
		let img = GetCurrentScriptDirectory~"./spbg/02_01.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,685,800);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ALPHA);
		Obj_SetRenderPriorityI(spellgraphic,29);
		ascent(i in 0..10)
		{
		ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
		ObjRender_SetColor(spellgraphic,55,255,255);
		ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(al<250){al+=15;}
			yield;
		}
		ascent(i in 0..340)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);
			ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetColor(spellgraphic,55,255,255);
			ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(scale<3){scale+=0;}
			speed += acc;
			acc+=0.005;
			cl+=2;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			ObjRender_SetAlpha(spellgraphic,al);
			yield;
		}
		Obj_Delete(spellgraphic);
	}

task GraphicSpB3
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 1;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 0;
		let an = 0;
		let t = 0;
		let img = GetCurrentScriptDirectory~"./spbg/02_00.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,787,787);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ALPHA);
		Obj_SetRenderPriorityI(spellgraphic,29);
		ascent(i in 0..10)
		{
		ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetAlpha(spellgraphic,al);
			ObjRender_SetAngleZ(spellgraphic,t*2);
			t++;
			if(al<64){al+=15;}
			yield;
		}
		ascent(i in 0..340)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);
			ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetColor(spellgraphic,210,210,210);
			ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			ObjRender_SetAlpha(spellgraphic,al);
			ObjRender_SetAngleZ(spellgraphic,t*2);
			if(scale<3){scale+=0;}
			speed += acc;
			acc+=0.005;
			cl+=2;
			t++;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			t++;
			ObjRender_SetAlpha(spellgraphic,al);
			ObjRender_SetAngleZ(spellgraphic,t*2);
			yield;
		}
		Obj_Delete(spellgraphic);
	}
	
task GraphicSpB4(z)
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 1.2;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 0;
		let an = 0;
		let t = 0;
		let img = GetCurrentScriptDirectory~"./spbg/02_03.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,800,800);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ADD_ARGB);
		Obj_SetRenderPriorityI(spellgraphic,29);
		ascent(i in 0..10)
		{
		ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
		ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,0,0);
			ObjRender_SetAlpha(spellgraphic,al);
			ObjRender_SetAngleZ(spellgraphic,t*2);
			t+=z;
			if(al<250){al+=15;}
			yield;
		}
		ascent(i in 0..340)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);

			ObjRender_SetColor(spellgraphic,210,210,210);
			ObjRender_SetAlpha(spellgraphic,al);
			ObjRender_SetAngleZ(spellgraphic,t*2);
			if(scale<3){scale+=0;}
			speed += acc;
			acc+=0.005;
			cl+=2;
			t+=z;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			t+=z;
			ObjRender_SetAlpha(spellgraphic,al);
			ObjRender_SetAngleZ(spellgraphic,t*2);
			yield;
		}
		Obj_Delete(spellgraphic);
	}
	
task SpellUseName(n,r,g,b){
	
	pfPlayerCutInDpellNameDeleted = false;
	pfPlayerCutInSpellNameGhostDeleted = false;
	


	
	let tScale1 = 10;
	let tScale2 = 10;
	
	let tAlpha1 = 0;
	let tAlpha2 = 0;
	
	let yOff = 400;
	
	let tYOff1 = -yOff;
	let tYOff2 = -yOff;
	
	
	pfPlayerCutInDpellNameDeleted = false;
	
	pfPlayerCutInNameEffect = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(pfPlayerCutInNameEffect, BLEND_ALPHA);
	Obj_SetRenderPriority(pfPlayerCutInNameEffect, 0.60);
	ObjPrim_SetTexture(pfPlayerCutInNameEffect, GetCurrentScriptDirectory() ~ "./bom_name_05.png");
	ObjSprite2D_SetDestRect(pfPlayerCutInNameEffect, -100, -15, 100, 15);
	ObjSprite2D_SetSourceRect(pfPlayerCutInNameEffect, 0, 0, 255, 40);
	
	let eScale = 10;
	
	let eAlpha = 0;
	
	let xOff = 100;
	yOff = 500;
	
	let eXOff = xOff;
	let eYOff = -yOff;
	
	loop(60){
		if(!pfPlayerCutInDpellNameDeleted){
			ObjRender_SetX(pfPlayerCutInNameEffect, 270 + eXOff);
			ObjRender_SetY(pfPlayerCutInNameEffect, 430 + eYOff);
			
			ObjRender_SetScaleXYZ(pfPlayerCutInNameEffect, eScale, eScale, eScale);
			ObjRender_SetAlpha(pfPlayerCutInNameEffect, eAlpha);
			
			eScale -= 9/60;
			eAlpha += 195/60;
			
			eXOff -= xOff/60;
			eYOff += yOff/60;
			yield;
		}
	}
	
	loop(60){yield;}
	
	let x = 14;
	let y = 218;
	
	while(x > 0 && !pfPlayerCutInDpellNameDeleted){
		ObjRender_SetY(pfPlayerCutInNameEffect, 430);
		
		y -= x;
		
		if(y < 200){
			x -= 0.58;
		}
		yield;
	}
	

	
	loop(120){yield;}
	
	xOff = 0;
	
	loop(65){
		if(!pfPlayerCutInDpellNameDeleted){
			ObjRender_SetX(pfPlayerCutInNameEffect, 270 - xOff);
			xOff -= 10;
			
			yield;
		}
	}
	
	if(!pfPlayerCutInDpellNameDeleted){
		Obj_Delete(pfPlayerCutInNameEffect);
		
		pfPlayerCutInDpellNameDeleted = true;
		pfPlayerCutInDpellNameDeleted = true;
	}
}

task DeleteSpellName{
	if(!pfPlayerCutInDpellNameDeleted){
		
		pfPlayerCutInDpellNameDeleted = true;
		
		Obj_Delete(pfPlayerCutInSpellName);
		if(!pfPlayerCutInSpellNameGhostDeleted){Obj_Delete(pfPlayerCutInSpellNameGhost);}
		if(!pfPlayerCutInDpellNameDeleted){Obj_Delete(pfPlayerCutInNameEffect);}
	}
}
	
}

task TSpellH
{
	let current = GetCurrentScriptDirectory();
	let imgEffect = current ~ "./musou_effect.png";
	spelltime = true;
	let objManage = GetSpellManageObject();
	let spell = ObjSpell_Create;
	ObjSpell_Regist(spell);
	ObjSpell_SetDamage(spell,12);

	let t = 15;
	let t2 = 1;
	SetPlayerInvincibilityFrame(380);//無敵時間を設定
	let angle = rand(0, 360);
    SpellUseName(" ",255,255,255);
	PlaySound("cardcall",100,0);
	GraphicSpB;
	GraphicSpB2;
	IsPermitPlayerShot;
	SetPlayerSpeed(vx/8,vy/8);
	wait(60);
	PlaySound("bom_06",80,0);
	ScreenShake(280);
	ascent(i in 0 .. 20){
	loop(6){
	ascent(i in 0 .. 15){
	HooSteam(rand(0,380),rand(0,470),0,rand(0,360),3.5,40);
	}
	ascent(i in 0 .. 15){
	let ar = GetIntersectionRegistedEnemyID;
	//HooSteam(rand(0,380),rand(0,470),0,rand(0,360),3.5,40);
	HooBomb(i*360/10,470,20,270,0,40);
	PlaySound("freeze_00",50,0);
	}
		if(t>1)
		{
		t--;
		}
		wait(t);
		}
	}
	loop(160){
	SetPlayerSpeed(vx,vy);
	spelltime = false;
	yield;
	}
	Obj_Delete(objManage);
	
task HooBomb(x,y,spd,dir,dmg,pdmg)
{
	let shotcolor = 7;
	let mx;
	let my;
	let mangle;
	let t = 0;
	let t2 = 1;
	let finalpos = 0;
	let mainobj = CreatePlayerShotA1(x,y,spd,dir,dmg,pdmg,shotcolor);
	ObjRender_SetAngleZ(mainobj, -90);
    Obj_SetRenderPriorityI(mainobj,42);
	let count = 0;
	let ra = rand(220,320);
	while(!Obj_IsDeleted(mainobj))
	{
		mx = ObjMove_GetX(mainobj);
		my = ObjMove_GetY(mainobj);
		mangle = ObjMove_GetAngle(mainobj);
		ObjRender_SetScaleXYZ(mainobj,1,1,1);
		DeleteShotInCircle(TYPE_SHOT, TYPE_ITEM, mx, my, 20);
		if(t>10)
		{
		ObjMove_SetSpeed(mainobj,0);
		}
		if(t>25)
		{
		ObjMove_SetSpeed(mainobj,spd);
		ObjMove_SetAngle(mainobj,ra);
		ObjShot_SetGraphic(mainobj,8);
		}
		t++;
		yield;
	}
	let obj2 = CreatePlayerShotA1(mx,my,5,mangle,0,10^10,3);
		
		ObjMove_SetAcceleration(obj2,-10/15);
		let alpha = 192;
		ObjMove_SetMaxSpeed(obj2,2.5);
		ObjRender_SetBlendType(obj2,BLEND_ADD_ARGB);
		let alphaM = 192;
		alpha = alphaM;	
		let angleZ = 0;
		let oa = rand(-(t%8-3.5)*5,(t%8-3.5)*5);
		let dirs = mangle;
		loop(15)
			{
			alpha-=alphaM/15;
			angleZ+=14;
			ObjRender_SetAngleZ(obj2,-90+oa*1.2);
			ObjRender_SetAlpha(obj2,alpha);
			ObjRender_SetScaleXYZ(obj2,t2,t2,0);
			t2+=0.08;
			yield;
			}
		Obj_Delete(obj2);
	Obj_Delete(mainobj);
}

task HooSteam(x,y,spd,dir,dmg,pdmg)
{
	let shotcolor = 6;
	let mx;
	let my;
	let mangle;
	let t = 0;
	let t2 = 1;
	let finalpos = 0;
	let mainobj = CreatePlayerShotA1(x,y,spd,dir,dmg,pdmg,shotcolor);
    Obj_SetRenderPriorityI(mainobj,41);
	let count = 0;
	let ra = rand(0.5,3.5);
	while(!Obj_IsDeleted(mainobj))
	{
		mx = ObjMove_GetX(mainobj);
		my = ObjMove_GetY(mainobj);
		mangle = ObjMove_GetAngle(mainobj);
		ObjRender_SetAngleZ(mainobj, rand(0,360));
		ObjRender_SetScaleXYZ(mainobj,ra,ra,ra);
		ObjRender_SetAlpha(mainobj,84);
		if(t>10)
		{
		Obj_Delete(mainobj);
		}
		t++;
		yield;
	}
	let obj2 = CreatePlayerShotA1(mx,my,5,mangle,0,10^10,6);
		
		ObjMove_SetAcceleration(obj2,-10/15);
		let alpha = 160;
		ObjMove_SetMaxSpeed(obj2,0);
		ObjRender_SetBlendType(obj2,BLEND_ADD_ARGB);
		let alphaM = 160;
		alpha = alphaM;	
		let angleZ = 0;
		let oa = rand(-(t%8-3.5)*5,(t%8-3.5)*5);
		let dirs = mangle;
		loop(15)
			{
			alpha-=alphaM/15;
			angleZ+=14;
			ObjRender_SetAngleZ(obj2,rand(0,360));
			ObjRender_SetAlpha(obj2,alpha);
			ObjRender_SetScaleXYZ(obj2,t2,t2,0);
			t2+=0.08;
			yield;
			}
		Obj_Delete(obj2);
}

task GraphicSpB
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 1;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 0;
		let an = 0;
		let img = GetCurrentScriptDirectory~"./spbg/04_00.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,384,448);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ALPHA);
		Obj_SetRenderPriorityI(spellgraphic,30);
		ascent(i in 0..20)
		{
		ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(al<255){al+=15;}
			yield;
		}
		ascent(i in 0..340)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);
			ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetColor(spellgraphic,255,255,255);
			ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(scale<3){scale+=0;}
			speed += acc;
			acc+=0.005;
			cl+=2;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			ObjRender_SetAlpha(spellgraphic,al);
			yield;
		}
		Obj_Delete(spellgraphic);
	}
	
task GraphicSpB2
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 1;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 0;
		let an = 0;
		let img = GetCurrentScriptDirectory~"./spbg/04_01.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,384,448);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ADD_ARGB);
		Obj_SetRenderPriorityI(spellgraphic,29);
		ascent(i in 0..10)
		{
		ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(al<172){al+=15;}
			yield;
		}
		ascent(i in 0..340)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);
			ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetColor(spellgraphic,255,155,155);
			ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(scale<3){scale+=0;}
			speed += acc;
			acc+=0.005;
			cl+=2;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			ObjRender_SetAlpha(spellgraphic,al);
			yield;
		}
		Obj_Delete(spellgraphic);
	}

task SpellUseName(n,r,g,b){
	
	pfPlayerCutInDpellNameDeleted = false;
	pfPlayerCutInSpellNameGhostDeleted = false;
	


	
	let tScale1 = 10;
	let tScale2 = 10;
	
	let tAlpha1 = 0;
	let tAlpha2 = 0;
	
	let yOff = 400;
	
	let tYOff1 = -yOff;
	let tYOff2 = -yOff;
	
	
	pfPlayerCutInDpellNameDeleted = false;
	
	pfPlayerCutInNameEffect = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(pfPlayerCutInNameEffect, BLEND_ALPHA);
	Obj_SetRenderPriority(pfPlayerCutInNameEffect, 0.60);
	ObjPrim_SetTexture(pfPlayerCutInNameEffect, GetCurrentScriptDirectory() ~ "./bom_name_06.png");
	ObjSprite2D_SetDestRect(pfPlayerCutInNameEffect, -100, -15, 100, 15);
	ObjSprite2D_SetSourceRect(pfPlayerCutInNameEffect, 0, 0, 255, 40);
	
	let eScale = 10;
	
	let eAlpha = 0;
	
	let xOff = 100;
	yOff = 500;
	
	let eXOff = xOff;
	let eYOff = -yOff;
	
	loop(60){
		if(!pfPlayerCutInDpellNameDeleted){
			ObjRender_SetX(pfPlayerCutInNameEffect, 270 + eXOff);
			ObjRender_SetY(pfPlayerCutInNameEffect, 430 + eYOff);
			
			ObjRender_SetScaleXYZ(pfPlayerCutInNameEffect, eScale, eScale, eScale);
			ObjRender_SetAlpha(pfPlayerCutInNameEffect, eAlpha);
			
			eScale -= 9/60;
			eAlpha += 195/60;
			
			eXOff -= xOff/60;
			eYOff += yOff/60;
			yield;
		}
	}
	
	loop(60){yield;}
	
	let x = 14;
	let y = 218;
	
	while(x > 0 && !pfPlayerCutInDpellNameDeleted){
		ObjRender_SetY(pfPlayerCutInNameEffect, 430);
		
		y -= x;
		
		if(y < 200){
			x -= 0.58;
		}
		yield;
	}
	

	
	loop(120){yield;}
	
	xOff = 0;
	
	loop(65){
		if(!pfPlayerCutInDpellNameDeleted){
			ObjRender_SetX(pfPlayerCutInNameEffect, 270 - xOff);
			xOff -= 10;
			
			yield;
		}
	}
	
	if(!pfPlayerCutInDpellNameDeleted){
		Obj_Delete(pfPlayerCutInNameEffect);
		
		pfPlayerCutInDpellNameDeleted = true;
		pfPlayerCutInDpellNameDeleted = true;
	}
}

task DeleteSpellName{
	if(!pfPlayerCutInDpellNameDeleted){
		
		pfPlayerCutInDpellNameDeleted = true;
		
		Obj_Delete(pfPlayerCutInSpellName);
		if(!pfPlayerCutInSpellNameGhostDeleted){Obj_Delete(pfPlayerCutInSpellNameGhost);}
		if(!pfPlayerCutInDpellNameDeleted){Obj_Delete(pfPlayerCutInNameEffect);}
	}
}
	
}

task TSpellK
{
	let current = GetCurrentScriptDirectory();
	let imgEffect = current ~ "./musou_effect.png";
	spelltime = true;
	let objManage = GetSpellManageObject();
	let spell = ObjSpell_Create;
	ObjSpell_Regist(spell);

	let t = 1;
	let t2 = 1;
	SetPlayerInvincibilityFrame(380);//無敵時間を設定
	let angle = rand(0, 360);
    SpellUseName(" ",255,255,255);
	GraphicSpB;
	GraphicSpB2;
	GraphicSpB3;
	GraphicSpB4;
	PlaySound("cardcall",100,0);
	IsPermitPlayerShot;
	SetPlayerSpeed(vx/8,vy/8);
	wait(60);
	PlaySound("bom_05",80,0);
	ascent(i in 0 .. 1){
	loop(1){
	GraphicB;
	GraphicW;
	//GraphicB;
	ascent(i in 0 .. 1){
	let ar = GetIntersectionRegistedEnemyID;
    Graphic4(-12);
	Graphic4(12);
	ascent(i in 0 .. t){
	ScreenShake(280);
	}
	}
		if(t<20)
		{
		t+=2;
		}
		wait(t);
		}
	}
	loop(160){
	SetPlayerSpeed(vx,vy);
	spelltime = false;
	yield;
	}
	Obj_Delete(objManage);

task Graphic4(a)
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 0;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 255;
		let an = 0;
		let img = GetCurrentScriptDirectory~"b042.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,256,256);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ADD_ARGB);
		//Obj_SetRenderPriorityI(spellgraphic,21);
		ascent(i in 0..210)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);
			ObjRender_SetPosition(spellgraphic,x,y,0);
			ObjRender_SetColor(spellgraphic,255,255,255);
			ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			//DeleteShotInCircle(TYPE_SHOT, TYPE_ITEM, x, y, scale*150);
			ObjSpell_SetIntersectionCircle(spell,x, y, scale*150);
			ObjSpell_SetDamage(spell,200);
			ObjRender_SetAngleZ(spellgraphic,an);
			if(scale<3){scale+=0.0055;}
			an+=a;
			speed += acc;
			acc+=0.005;
			cl+=2;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			ObjRender_SetAngleZ(spellgraphic,an);
			an+=a;
			ObjRender_SetAlpha(spellgraphic,al);
			yield;
		}
		Obj_Delete(spellgraphic);
	}

task GraphicW
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 0;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 255;
		let an = 0;
		let img = GetCurrentScriptDirectory~"bright.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,64,64);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ADD_ARGB);
		Obj_SetRenderPriorityI(spellgraphic,42);
		ascent(i in 0..210)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);
			ObjRender_SetPosition(spellgraphic,x,y,0);
			ObjRender_SetColor(spellgraphic,cl,cl,cl);
			ObjRender_SetScaleXYZ(spellgraphic,40,40,0);
			ObjRender_SetAngleZ(spellgraphic,an);
			if(scale<3){scale+=0.0055;}
			speed += acc;
			acc+=0.005;
			cl+=0.75;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			ObjRender_SetAlpha(spellgraphic,al);
			yield;
		}
		Obj_Delete(spellgraphic);
	}
	
task GraphicB
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 1;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 255;
		let an = 0;
		let img = GetCurrentScriptDirectory~"kuroji_bom_00.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,384,448);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ADD_ARGB);
		//Obj_SetRenderPriorityI(spellgraphic,21);
		ascent(i in 0..210)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);
			ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetColor(spellgraphic,255,155,155);
			ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			ObjRender_SetAlpha(spellgraphic,150+105*sin(cl*4));
			if(scale<3){scale+=0;}
			speed += acc;
			acc+=0.005;
			cl+=2;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			ObjRender_SetAlpha(spellgraphic,al);
			yield;
		}
		Obj_Delete(spellgraphic);
	}
	
task GraphicSpB
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 0.75;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 0;
		let an = 0;
		let img = GetCurrentScriptDirectory~"./spbg/05_05.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,291,591);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ALPHA);
		Obj_SetRenderPriorityI(spellgraphic,32);
		ascent(i in 0..20)
		{
		ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
		ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(al<172){al+=15;}
			yield;
		}
		ascent(i in 0..340)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);
			ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetColor(spellgraphic,255,255,255);
			ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(scale<3){scale+=0;}
			speed += acc;
			acc+=0.005;
			cl+=2;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			ObjRender_SetAlpha(spellgraphic,al);
			yield;
		}
		Obj_Delete(spellgraphic);
	}
	
task GraphicSpB2
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 1;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 0;
		let an = 0;
		let img = GetCurrentScriptDirectory~"./spbg/05_01.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,384,446);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ALPHA);
		Obj_SetRenderPriorityI(spellgraphic,29);
		ascent(i in 0..10)
		{
		ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
		ObjRender_SetColor(spellgraphic,255,255,255);
		ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(al<250){al+=15;}
			yield;
		}
		ascent(i in 0..340)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);
			ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
			ObjRender_SetColor(spellgraphic,255,255,255);
			ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(scale<3){scale+=0;}
			speed += acc;
			acc+=0.005;
			cl+=2;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			ObjRender_SetAlpha(spellgraphic,al);
			yield;
		}
		Obj_Delete(spellgraphic);
	}

task GraphicSpB3
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 1;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 0;
		let an = 0;
		let t = 0;
		let img = GetCurrentScriptDirectory~"./spbg/05_07.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,397,750*5);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ALPHA);
		Obj_SetRenderPriorityI(spellgraphic,31);
		ascent(i in 0..10)
		{
		ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,-GetStgFrameHeight/2+t*2,0);
		ObjRender_SetColor(spellgraphic,210,110,210);
		t++;
			ObjRender_SetAlpha(spellgraphic,al);
			if(al<132){al+=15;}
			yield;
		}
		ascent(i in 0..340)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);
			ObjRender_SetColor(spellgraphic,210,110,210);
			ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,-GetStgFrameHeight/2+t*2,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(scale<3){scale+=0;}
			speed += acc;
			acc+=0.005;
			cl+=2;
			t++;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			t++;
			ObjRender_SetAlpha(spellgraphic,al);
			ObjRender_SetColor(spellgraphic,210,110,210);
			ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,-GetStgFrameHeight/2+t*2,0);
			yield;
		}
		Obj_Delete(spellgraphic);
	}
	
task GraphicSpB4
	{
		let spellgraphic= ObjPrim_Create(OBJ_SPRITE_2D);
		let scale = 1;
		let speed = 0.3;
		let acc = 0.01;
		let cl = 0;
		let r = 55;
        let g = 55;
        let b = 55;
		let al = 0;
		let an = 0;
		let t = 0;
		let img = GetCurrentScriptDirectory~"./spbg/05_06.png";
		ObjPrim_SetTexture(spellgraphic,img);
		let x = GetPlayerX;
		let y = GetPlayerY;
		ObjSprite2D_SetSourceRect(spellgraphic,0,0,397,750*5);
		ObjSprite2D_SetDestCenter(spellgraphic);
		ObjRender_SetBlendType(spellgraphic,BLEND_ALPHA);
		Obj_SetRenderPriorityI(spellgraphic,30);
		ascent(i in 0..10)
		{
		ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,-GetStgFrameHeight/2+t,0);
		t++;
			ObjRender_SetAlpha(spellgraphic,al);
			if(al<32){al+=15;}
			yield;
		}
		ascent(i in 0..340)
		{
		    r = 40+25*cos(cl);
		    g = 40+25*cos(cl-360/3);
		    b = 40+25*cos(cl+360/3);
			ObjRender_SetColor(spellgraphic,210,210,210);
			ObjRender_SetScaleXYZ(spellgraphic,scale,scale,0);
			ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,-GetStgFrameHeight/2+t,0);
			ObjRender_SetAlpha(spellgraphic,al);
			if(scale<3){scale+=0;}
			speed += acc;
			acc+=0.005;
			cl+=2;
			t++;
			yield;
		}
		let scaleratio = scale/30;
		while(scale>0)
		{
			al-=15;
			t++;
			ObjRender_SetAlpha(spellgraphic,al);
			ObjRender_SetPosition(spellgraphic,GetStgFrameWidth/2,-GetStgFrameHeight/2+t,0);
			yield;
		}
		Obj_Delete(spellgraphic);
	}
	
task SpellUseName(n,r,g,b){
	
	pfPlayerCutInDpellNameDeleted = false;
	pfPlayerCutInSpellNameGhostDeleted = false;
	


	
	let tScale1 = 10;
	let tScale2 = 10;
	
	let tAlpha1 = 0;
	let tAlpha2 = 0;
	
	let yOff = 400;
	
	let tYOff1 = -yOff;
	let tYOff2 = -yOff;
	
	
	pfPlayerCutInDpellNameDeleted = false;
	
	pfPlayerCutInNameEffect = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(pfPlayerCutInNameEffect, BLEND_ALPHA);
	Obj_SetRenderPriority(pfPlayerCutInNameEffect, 0.60);
	ObjPrim_SetTexture(pfPlayerCutInNameEffect, GetCurrentScriptDirectory() ~ "./bom_name_02.png");
	ObjSprite2D_SetDestRect(pfPlayerCutInNameEffect, -100, -15, 100, 15);
	ObjSprite2D_SetSourceRect(pfPlayerCutInNameEffect, 0, 0, 255, 40);
	
	let eScale = 10;
	
	let eAlpha = 0;
	
	let xOff = 100;
	yOff = 500;
	
	let eXOff = xOff;
	let eYOff = -yOff;
	
	loop(60){
		if(!pfPlayerCutInDpellNameDeleted){
			ObjRender_SetX(pfPlayerCutInNameEffect, 270 + eXOff);
			ObjRender_SetY(pfPlayerCutInNameEffect, 430 + eYOff);
			
			ObjRender_SetScaleXYZ(pfPlayerCutInNameEffect, eScale, eScale, eScale);
			ObjRender_SetAlpha(pfPlayerCutInNameEffect, eAlpha);
			
			eScale -= 9/60;
			eAlpha += 195/60;
			
			eXOff -= xOff/60;
			eYOff += yOff/60;
			yield;
		}
	}
	
	loop(60){yield;}
	
	let x = 14;
	let y = 218;
	
	while(x > 0 && !pfPlayerCutInDpellNameDeleted){
		ObjRender_SetY(pfPlayerCutInNameEffect, 430);
		
		y -= x;
		
		if(y < 200){
			x -= 0.58;
		}
		yield;
	}
	

	
	loop(120){yield;}
	
	xOff = 0;
	
	loop(65){
		if(!pfPlayerCutInDpellNameDeleted){
			ObjRender_SetX(pfPlayerCutInNameEffect, 270 - xOff);
			xOff -= 10;
			
			yield;
		}
	}
	
	if(!pfPlayerCutInDpellNameDeleted){
		Obj_Delete(pfPlayerCutInNameEffect);
		
		pfPlayerCutInDpellNameDeleted = true;
		pfPlayerCutInDpellNameDeleted = true;
	}
}

task DeleteSpellName{
	if(!pfPlayerCutInDpellNameDeleted){
		
		pfPlayerCutInDpellNameDeleted = true;
		
		Obj_Delete(pfPlayerCutInSpellName);
		if(!pfPlayerCutInSpellNameGhostDeleted){Obj_Delete(pfPlayerCutInSpellNameGhost);}
		if(!pfPlayerCutInDpellNameDeleted){Obj_Delete(pfPlayerCutInNameEffect);}
	}
}
	
}

function TExpan(px,py,maxv,t,r,g,b)
{
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GetCurrentScriptDirectory~"./charge.png";
	let scale = 0;
	let v = 0;
	let malpha = 255/t;
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetPosition(obj,px,py,0);
	ObjRender_SetColor(obj,r,g,b);
	Obj_SetRenderPriorityI(obj,25);
	Expan;
		task Expan{
			descent(i in 0..t)
			{
			ObjRender_SetAlpha(obj,malpha*i);
			v = (i*maxv/2)/(t*t);
			scale += v;
			ObjRender_SetScaleXYZ(obj,scale,scale,0);
			yield;
			}
			Obj_Delete(obj);
		}
}

function TExpan2(px,py,maxv,t,r,g,b) // Missile Explode
{
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GetCurrentScriptDirectory~"./MissleExplode.png";
	let scale = 0;
	let v = 0;
	let malpha = 255/t;
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetPosition(obj,px,py,0);
	ObjRender_SetColor(obj,r,g,b);
	Obj_SetRenderPriorityI(obj,25);
	Expan;
		task Expan{
			descent(i in 0..t)
			{
			ObjRender_SetAlpha(obj,malpha*i);
			v = (i*maxv/2)/(t*t);
			scale += v;
			ObjRender_SetScaleXYZ(obj,scale,scale,0);
			yield;
			}
			Obj_Delete(obj);
		}
}


		
task etama(r,a,type){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GetCurrentScriptDirectory~"eff2.png";
	let dir = rand(0,359);
	let angle = rand(0,359);
	let size = 0.5+r/150;
	let s = size;
	let ra = r;
	let c = 0;
	let m = -10;
	let cp = rand(-7,7);
	let alpha = 0;
	let count = 0;
	let alphaplus = 255/ra;
	ObjPrim_SetTexture(obj,img);
	if(type==1){ObjSprite2D_SetSourceRect(obj,32,226,64,254);}
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetAlpha(obj,0);
	while(r>0){
	ObjRender_SetPosition(obj,GetPlayerX+r*cos(dir),GetPlayerY+r*sin(dir),0);
	ObjRender_SetAngleXYZ(obj,0,0,angle+c*20);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	ObjRender_SetAlpha(obj,alpha*5);
	if(r>ra/2){alpha += alphaplus+1;}
	else{
	alpha -= alphaplus;
	if(alpha<=0){Obj_Delete(obj);}
	}
	r -= 10+c;
	c -= 0.1;
	yield;
	}
	Obj_Delete(obj);
}

function TCharge01(x,y,size,frame,r,g,b){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GetCurrentScriptDirectory~"charge.png";
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,x,y,0);
	ObjRender_SetAlpha(obj,0);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	ObjRender_SetColor(obj,r,g,b);
	TAlpha;
	TShrink;
	return obj;
	task TAlpha{
		let l=10;
		let alpha=255/l;
		loop(l){
			ObjRender_SetAlpha(obj,alpha);
			alpha+=255/(l*2);
			yield;
			}
		}
	task TShrink{
		let l=frame;
		let a = size*2/l/l;
		ascent(i in 0..l){
			ObjRender_SetScaleXYZ(obj,size,size,0);
			ObjRender_SetPosition(obj,GetPlayerX,GetPlayerY,0);
			size = size-i*a;
			if(Obj_IsDeleted(GetPlayerID)){Obj_Delete(obj);}
			yield;
			}
		Obj_Delete(obj);
		
	}
}

task fragment(shot,size,num){
		if(!Obj_IsDeleted(shot)){
		loop(num){
		realTask;
		}
		}
			task realTask{
			let obj=ObjPrim_Create(OBJ_SPRITE_2D);
			let img=GetCurrentScriptDirectory~"effbreak.png";
			let s = rand(0.8,1.2)+size;
			let pic = ObjShot_GetImageID(shot);
			let color = GetShotDataInfoA1(pic,TARGET_ENEMY,INFO_DELAY_COLOR);
			let rect = [0,0,32,32];
			ObjPrim_SetTexture(obj,img);
			ObjSprite2D_SetSourceRect(obj,rect[0],rect[1],rect[2],rect[3]);
			ObjSprite2D_SetDestCenter(obj);
			ObjRender_SetScaleXYZ(obj,s,s,0);
			ObjRender_SetAngleXYZ(obj,0,0,rand(0,359));
			ObjRender_SetBlendType(obj,BLEND_ALPHA);
			ObjRender_SetColor(obj,color[0],color[1],color[2]);
			Obj_SetRenderPriority(obj,0.21);
			ObjShot_SetIntersectionEnable(shot,false);
			let x = ObjMove_GetX(shot);
			let y = ObjMove_GetY(shot);
			if(x!=0 && y!=0){
			ascent(i in 0..7){
			ObjRender_SetPosition(obj,x,y,0);
			ObjSprite2D_SetSourceRect(obj,rect[0],rect[1],rect[2],rect[3]);
			rect[0] = rect[0]+32;
			rect[2] = rect[2]+32;
			wait(3);
			}
			}
			Obj_Delete(obj);
			}
		}
		
task spongy(shot,t){
		let cloud = ObjShot_GetImageID(shot);
		let obj=ObjPrim_Create(OBJ_SPRITE_2D);
		if(!Obj_IsDeleted(shot)){
		let img=GetCurrentScriptDirectory()~"AllStarShot.png";
		let s = 1;
		let adc = false;
		let rect = GetShotDataInfoA1(cloud,TARGET_ENEMY,INFO_RECT);
		let dir = ObjMove_GetAngle(shot)+90;
		ObjPrim_SetTexture(obj,img);
		ObjSprite2D_SetSourceRect(obj,rect[0],rect[1],rect[2],rect[3]);
		ObjSprite2D_SetDestCenter(obj);
		ObjRender_SetPosition(obj,ObjMove_GetX(shot),ObjMove_GetY(shot),0);
		ObjRender_SetAngleXYZ(obj,0,0,dir);
		ObjRender_SetBlendType(obj,BLEND_ALPHA);
	 if( (cloud>=1 && cloud<=41) || (cloud>=58 && cloud<=73) || (cloud>=106 && cloud <=121)
	 || (cloud>=170 && cloud<=185) || (cloud>=233 && cloud<=239)
	 || (cloud>=248 && cloud <=252) || (cloud>=269 && cloud<=283)
	 || (cloud>=300 && cloud<=307) || (cloud>=340 && cloud<=346)
	 || (cloud>=355 && cloud<=362) || (cloud>=371 && cloud<=382)
	 || (cloud>=399 && cloud<=408)){
	 adc = true;
	 ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	 }
		if(cloud>=41){
		ascent(i in 0..t){
		ObjRender_SetScaleXYZ(obj,s,s,0);
		if(adc==false){ObjRender_SetAlpha(obj,255-i*255/t);}
		if(adc==true){ObjRender_SetColor(obj,255-i*255/t,255-i*255/t,255-i*255/t);}
		s += 0.1;
		yield;
		}
		}
		Obj_Delete(obj);
		}
		}

function GetDistance(x1,y1,x2,y2){
return((|((x2-x1)^2+(y2-y1)^2)^(1/2)|));
}

task TMagicCircle
{


	let countVertex = 40;
	let listRadius = [];
	let t = 0;
	loop(countVertex)
	{
		listRadius = listRadius ~ [0];
	}

	let path = current ~ "spell_card_00.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.60);
	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 cx = 0;
	let cy = 0;
	let maxRadius = 228;
	let alpha = 0;
	let frame = 0;
	let angleRender = 0;
	let frameInvOld = 0;

	while(true)
	{
		let frameInv = GetPlayerInvincibilityFrame();

		if(frameInv <= 0)
		{
			Obj_SetVisible(obj, false);
			frameInvOld = 0;
		}
		else
		{
			if(frameInvOld == 0)
			{
				//???
				ascent(iVert in 0..countVertex)
				{
					listRadius[iVert] = 0;
				}
				alpha = 0;
				frame = 0;
			}
			frameInvOld = frameInv;

			let px = GetPlayerX();
			let py = GetPlayerY();

			alpha += 1 / 120;
			alpha = min(alpha, 1);
			angleRender += 180 / countVertex / 2 *sin(t*2);
			Obj_SetVisible(obj, true);
            t++;
			frameInv = min(100, frameInv);
			let rRate = frameInv / 100;

			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]) / 8;
					listRadius[indexVert] = listRadius[indexVert] + dr;
				}
				if(frame > 10)
				{//??
					let rRateIn = rRate - 0.12;
					if(rRateIn < 0){rRateIn=0;}
					let dr= (maxRadius * rRateIn - listRadius[indexVert + 1]) / 16;
					listRadius[indexVert + 1] = listRadius[indexVert + 1] + dr;
				}

			}
            if(type==0)
			{
			ObjRender_SetColor(obj, 64 * alpha, 255 * alpha, 64 * alpha);
			}
			if(type==1)
			{
			ObjRender_SetColor(obj, 64 * alpha, 64 * alpha, 255 * alpha);
			}
			if(type==2)
			{
			ObjRender_SetColor(obj, 64 * alpha, 255 * alpha, 190 * alpha);
			}
			ObjRender_SetPosition(obj, px, py, 0);
			ObjRender_SetAngleXYZ(obj,t,t, t*5);

			frame++;
		}

		yield;
	}
}

task TMagicCircle2
{


	let countVertex = 120;
	let listRadius = [];
	let t = 0;
	loop(countVertex)
	{
		listRadius = listRadius ~ [0];
	}

	let path = current ~ "spell_eff_00.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.60);
	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 cx = 0;
	let cy = 0;
	let maxRadius = 172;
	let alpha = 0;
	let frame = 0;
	let angleRender = 0;
	let frameInvOld = 0;

	while(true)
	{
		let frameInv = GetPlayerInvincibilityFrame();

		if(frameInv <= 0)
		{
			Obj_SetVisible(obj, false);
			frameInvOld = 0;
		}
		else
		{
			if(frameInvOld == 0)
			{
				//???
				ascent(iVert in 0..countVertex)
				{
					listRadius[iVert] = 0;
				}
				alpha = 0;
				frame = 0;
			}
			frameInvOld = frameInv;

			let px = GetPlayerX();
			let py = GetPlayerY();

			alpha += 1 / 120;
			alpha = min(alpha, 1);
			angleRender += 180 / countVertex / 2 *sin(t*2);
			Obj_SetVisible(obj, true);
            t--;
			frameInv = min(100, frameInv);
			let rRate = frameInv / 100;

			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]) / 8;
					listRadius[indexVert] = listRadius[indexVert] + dr;
				}
				if(frame > 10)
				{//??
					let rRateIn = rRate - 0.12;
					if(rRateIn < 0){rRateIn=0;}
					let dr= (maxRadius * rRateIn - listRadius[indexVert + 1]) / 16;
					listRadius[indexVert + 1] = listRadius[indexVert + 1] + dr;
				}

			}

			if(type==0)
			{
			ObjRender_SetColor(obj, 64 * alpha, 192 * alpha, 255 * alpha);
			}
			if(type==1)
			{
			ObjRender_SetColor(obj, 255 * alpha, 64 * alpha, 64 * alpha);
			}
			if(type==2)
			{
			ObjRender_SetColor(obj, 255 * alpha, 64 * alpha, 255 * alpha);
			}
			ObjRender_SetPosition(obj, px, py, 0);
			ObjRender_SetAngleXYZ(obj,t/2,t/2, t*5);

			frame++;
		}

		yield;
	}
}

task TExplosion
{
	let path = GetCurrentScriptDirectory() ~ "Explode.png";
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	Obj_SetRenderPriority(obj, 0.60);
	ObjPrim_SetTexture(obj, path);
	ObjSprite2D_SetSourceRect(obj, 0, 0, 64, 64);
	ObjSprite2D_SetDestRect(obj, -32, -32, 32, 32);
	ObjRender_SetPosition(obj, GetPlayerX, GetPlayerY, 0);
	let alpha = 255;
	let scale = 0;
	let dis = 0;
	let px = GetPlayerX;
	let py = GetPlayerY;
	ExplosionCircle;
	DeleteCircle;
	task ExplosionCircle
	{
		loop(30)
		{
			scale += 0.2;
			alpha -= 9;
			ObjRender_SetColor(obj, alpha, alpha, alpha);
			ObjRender_SetPosition(obj, px, py, 0);
			ObjRender_SetScaleXYZ(obj, scale, scale, 1);
			yield;
		}
		Obj_Delete(obj);
	}
	task DeleteCircle
	{
		wait(GetPlayerRebirthFrame);
		if(spelltime==false)
		{
			loop(40)
			{
			let arr = GetShotIdInCircleA2(GetStgFrameWidth/2,GetStgFrameHeight/2,600,TARGET_ENEMY);
			DeleteShotInCircle(TYPE_SHOT, TYPE_ITEM, px, py, dis);
			dis += 25;
			yield;
			}
		}
	}
}

task Homing(obj,h_obj,maxTraverse){  // max. angle of traverse
	let angle = ObjMove_GetAngle(obj);
	let dir = 0;
	let boss = GetIntersectionRegistedEnemyID;
    while(! Obj_IsDeleted(obj) && Obj_GetValueD(h_obj,"HomingOrNot",1)==1 && FindTarget!=-1) {
        ObjMove_SetAngle(obj, angle);
		maxTraverse += 0.2;
		if(length(boss)>=1){
		dir = atan2(ObjMove_GetY(h_obj) - ObjMove_GetY(obj),
                        ObjMove_GetX(h_obj) - ObjMove_GetX(obj));
						if(ObjRender_GetX(h_obj)==0 && ObjRender_GetY(h_obj) ==0){
							if(FindTarget!=-1)
							{
								h_obj = FindTarget;
							}
							else
							{
								break;
							}
						}
						}
        let diff = dir - angle;
        while(diff >= 180) { diff -= 360; }    // adjust the range
        while(diff < -180) { diff += 360; }

        let diffAbs = (|diff|);
        if(diffAbs < maxTraverse) {
            angle = dir;
        } else {
            angle += maxTraverse * diff / diffAbs;
        }
		yield;
    }
}	
	
function FindTarget{
	let enemy_id = GetIntersectionRegistedEnemyID;
	let mindis = 999;
	let h_obj;
	if(length(enemy_id)>0){
	h_obj = enemy_id[0];
	ascent(i in 0..length(enemy_id)){
	let dis = GetDistance(GetPlayerX,GetPlayerY,ObjMove_GetX(enemy_id[i]),ObjMove_GetY(enemy_id[i]));
		if(mindis>dis){
		mindis = dis;
		h_obj = enemy_id[i];
		}
	}
	return h_obj;
	}
	else
	{
	return -1;
	}
}

task PlaySound(str,v,w){
	if(str == "Laser7"){ObjSound_Load(s,GetCurrentScriptDirectory~"Laser7.wav");}
	if(str == "Shot7"){ObjSound_Load(s,GetCurrentScriptDirectory~"Shot7.wav");}
	if(str == "Shot8"){ObjSound_Load(s,GetCurrentScriptDirectory~"Shot8.wav");}
	if(str == "Shot9"){ObjSound_Load(s,GetCurrentScriptDirectory~"Shot9.wav");}
	if(str == "Charge1"){ObjSound_Load(s,GetCurrentScriptDirectory~"Charge1.wav");}
	if(str == "Charge2"){ObjSound_Load(s,GetCurrentScriptDirectory~"Charge2.wav");}
	if(str == "Charge3"){ObjSound_Load(s,GetCurrentScriptDirectory~"Charge3.wav");}
	if(str == "Charge4"){ObjSound_Load(s,GetCurrentScriptDirectory~"Charge4.wav");}
	if(str == "Eff2"){ObjSound_Load(s,GetCurrentScriptDirectory~"Eff2.wav");}
	if(str == "se_shot"){ObjSound_Load(s,GetCurrentScriptDirectory~"se_shot.wav");}
	if(str == "Slash"){ObjSound_Load(s,GetCurrentScriptDirectory~"Slash.wav");}
	if(str == "cardcall"){ObjSound_Load(s,GetCurrentScriptDirectory~"cardcall.wav");}
	if(str == "LenenShot3"){ObjSound_Load(s,GetCurrentScriptDirectory~"LenenShot3.wav");}
	if(str == "bom_06"){ObjSound_Load(s,GetCurrentScriptDirectory~"bom_06.wav");}
	if(str == "bom_05"){ObjSound_Load(s,GetCurrentScriptDirectory~"bom_05.wav");}
	if(str == "bom_07"){ObjSound_Load(s,GetCurrentScriptDirectory~"bom_07.wav");}
	if(str == "bom_10"){ObjSound_Load(s,GetCurrentScriptDirectory~"bom_10.wav");}
	if(str == "j_barrier"){ObjSound_Load(s,GetCurrentScriptDirectory~"j_barrier.wav");}
	if(str == "freeze_00"){ObjSound_Load(s,GetCurrentScriptDirectory~"freeze_00.wav");}
	loop(w){yield;}
	ObjSound_SetSoundDivision(s,SOUND_SE);
	ObjSound_SetVolumeRate(s,v);
	ObjSound_Play(s);
	/*loop(120){yield;}
	Obj_Delete(s);*/
	}

				task ScreenShake(time){
				loop(time/2){
				Set2DCameraFocusX(Get2DCameraX + rand(-8, 8));
				Set2DCameraFocusY(Get2DCameraY + rand(-8, 8));
				yield;
				Reset2DCamera;
				yield;
				}
				Reset2DCamera;
			}	

function wait(t){
	loop(t){yield;}
	}
