#TouhouDanmakufu[Player]
#ScriptVersion[3]
#ID["SagumeB"]
#Title["Not Sagume Kishin B"]
#Text["Rotation and Lock-on Option Type"]
#Image["./Image/Cutin.png"]
#ReplayName["SagumeB"]

let current = GetCurrentScriptDirectory();

let objPlayer = GetPlayerObjectID();
let renderPlayerObject = ObjPrim_Create(OBJ_SPRITE_2D);
let playerdead = false;
let IsPlayerSpawning = false;
let IsHitboxActive = false;
let optionAlive = true;
let CanShoot = true;

let isspell = false;

let isvisible = true;

let imgPlayer = current ~ "Image/Sagume.png";
let snowflake = current ~ "Image/Focus.png";
let imgOption = current ~ "Image/Shot.png";

@Initialize{
	LoadPlayerShotData(current ~ "Shotdata.dnh");
	SetPlayerAutoItemCollectLine(130);
	ObjPlayer_AddIntersectionCircleA1(objPlayer, 0, 0, 3, 20); 

	SetPlayerSpeed(4.5, 2);
	SetPlayerClip(11,11,GetStgFrameWidth-11,GetStgFrameHeight-18);
	RenderPlayerImage(renderPlayerObject, 0);

	Shoot;
	TMagicCircle;
	Options;
}

@Event{
	alternative(GetEventType())
		case(EV_REQUEST_SPELL)
		{	
			let spell = GetPlayerSpell();
			if(spell >= 1 && IsPermitPlayerSpell()){
				Manage;
				SetScriptResult(true);
				SetPlayerSpell(spell-1);
			}else{
				SetScriptResult(false);
			}
		}
		case(EV_GRAZE){
			PlaySE(current~"Sound/se_graze.wav");
		}
		case(EV_HIT)
		{
			PlayerExplode(current ~ "Image/Explode.png");
			PlaySE(current~"Sound/se_pldead00.wav");
		}
		case(EV_PLAYER_SHOOTDOWN){
			playerdead = true;
			IsHitboxActive = false;
			optionAlive = false;
		}
		case(EV_PLAYER_REBIRTH)
		{
			SetPlayerSpell(3);
			playerdead = false;
			optionAlive = true;
			Options;
			SetPlayerInvincibilityFrame(180);
		}
		case(EV_GET_ITEM)
		{
			let itemType = GetEventArgument(0);
			alternative(itemType)
				case(ITEM_1UP){
					PlaySE(current~"Sound/se_extend.wav");
					SetPlayerLife(GetPlayerLife + 1);
					WriteLog("ITEM_1UP");
				}
				case(ITEM_1UP_S){
					PlaySE(current~"Sound/se_extend.wav");
					SetPlayerLife(GetPlayerLife + 1);
					WriteLog("ITEM_1UP_S");
				}
				case(ITEM_SPELL){
					PlaySE(current~"Sound/se_item00.wav");
					SetPlayerSpell(GetPlayerSpell + 1);
					WriteLog("ITEM_SPELL");
				}
				case(ITEM_SPELL_S){
					PlaySE(current~"Sound/se_item00.wav");
					SetPlayerSpell(GetPlayerSpell + 1);
					WriteLog("ITEM_SPELL_S");
				}
				case(ITEM_POWER){
					PlaySE(current~"Sound/se_item00.wav");
					WriteLog("ITEM_POWER");
				}
				case(ITEM_POWER_S){
					PlaySE(current~"Sound/se_item00.wav");
					WriteLog("ITEM_POWER_S");
				}
				case(ITEM_POINT){
					PlaySE(current~"Sound/se_item00.wav");
					WriteLog("ITEM_POWER");
				}
				case(ITEM_POINT_S){
					PlaySE(current~"Sound/se_item00.wav");
					WriteLog("ITEM_POWER_S");
				}
		}
}

@Loading{
	LoadSound(current~"Sound/se_plst00.wav");
	LoadSound(current~"Sound/se_nep00.wav");
	LoadSound(current~"Sound/se_pldead00.wav");
	LoadSound(current~"Sound/se_graze.wav");
	LoadSound(current~"Sound/se_item00.wav");
	LoadSound(current~"Sound/se_extend.wav");
	LoadSound(current~"Sound/se_boon01.wav");
}

@MainLoop{
	if(GetPlayerState==STATE_DOWN || IsPermitPlayerShot==false){CanShoot = false;}
	if(GetPlayerState==STATE_NORMAL && IsPermitPlayerShot==true){CanShoot = true;}

	//if(GetPlayerState==STATE_DOWN){SetForbidPlayerShot(true); SetForbidPlayerSpell(true);}
	//if(GetPlayerState==STATE_NORMAL){SetForbidPlayerShot(false); SetForbidPlayerSpell(false);}
	SetPlayerClip(11,11,GetStgFrameWidth-11,GetStgFrameHeight-18);
	if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD&&!IsHitboxActive){RenderHitboxImage(objPlayer, 0, 1);}
	yield;
}

@Finalize{

}

task Shoot{
	let count = 0;
	loop{
		if(GetVirtualKeyState(VK_SHOT) != KEY_FREE && count%4 == 0 && !isspell){
			if(CanShoot){
				PlaySE(current~"Sound/se_plst00.wav");
				CreatePlayerShotA1(GetPlayerX + 8, GetPlayerY - 16, 20, 265, 5, 1, 1);
				CreatePlayerShotA1(GetPlayerX - 8, GetPlayerY - 16, 20, 275, 5, 1, 1);
			}
		}
		if(GetVirtualKeyState(VK_SHOT) != KEY_FREE && isspell){
			PlaySE(current~"Sound/se_plst00.wav");
			CreatePlayerShotA1(GetPlayerX + 8, GetPlayerY - 16, 30, 265, 0.5, 1, 1);
			CreatePlayerShotA1(GetPlayerX - 8, GetPlayerY - 16, 30, 275, 0.5, 1, 1);
		}
		count++;
		yield;
	}
}

task Options{

	let dir = -90;
	loop(3){
		Option2(0, 0, dir, 4, 48, [112, 112], 0);
		dir += 120;
	}
	loop(6){
		Option2(0, 0, dir, -4, 32, [96, 112], 1);
		dir += 60;
	}
}

task Option2(x, y, a, a2, rad, rect, type){
	let objOption = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(objOption, 30);
	ObjRender_SetBlendType(objOption, BLEND_ALPHA);
	ObjPrim_SetTexture(objOption, imgOption);
	ObjSprite2D_SetSourceRect(objOption, rect[0], rect[1], rect[0] + 16, rect[1] + 16);
	ObjSprite2D_SetDestCenter(objOption);
	ObjRender_SetPosition(objOption, GetPlayerX, GetPlayerY, 0);
	//ObjRender_SetScaleXYZ(objOption, 0.5, 0.5, 0);

	let destX;
	let destY;
	let dist;
	let dir = -90;
	let dir2 = 0;
	let startrad = rad;

	let count = 0;
	while(!Obj_IsDeleted(objOption)){
		if(!optionAlive){Obj_Delete(objOption);}
		if(GetVirtualKeyState(VK_SLOWMOVE) == KEY_FREE){
			a += a2;
			dir += 3;
		}
		if(isspell){
			a -= a2*2;
			rad += 256/420;
		}else{
			if(rad > startrad){rad -= 256/45;}
		}
		ObjRender_SetPosition(objOption, GetPlayerX + rad*cos(a), GetPlayerY + rad*sin(a), 0);

		if(GetVirtualKeyState(VK_SHOT) != KEY_FREE && count%5 == 0 && !isspell){
			if(CanShoot){
				alternative(type)
				case(0){
					CreatePlayerShotA1(ObjRender_GetX(objOption), ObjRender_GetY(objOption), 20, dir, 6, 1, 3);
					CreatePlayerShotA1(ObjRender_GetX(objOption), ObjRender_GetY(objOption), 20, dir + 5, 6, 1, 3);
					CreatePlayerShotA1(ObjRender_GetX(objOption), ObjRender_GetY(objOption), 20, dir + 10, 6, 1, 3);
				}
				case(1){
					CreatePlayerShotA1(ObjRender_GetX(objOption), ObjRender_GetY(objOption), 20, GetAngleToPlayer(objOption) + 20, 5, 1, 2);
				}
			}
		}
		if(GetVirtualKeyState(VK_SHOT) != KEY_FREE && isspell){
			alternative(type)
			case(0){
				CreatePlayerShotA1(ObjRender_GetX(objOption), ObjRender_GetY(objOption), 5, GetAngleToPlayer(objOption) - dir2, 4, 1, 3);
			}
			case(1){
				CreatePlayerShotA1(ObjRender_GetX(objOption), ObjRender_GetY(objOption), 5, GetAngleToPlayer(objOption) + dir2, 4, 1, 2);
			}
			dir2 += 3;
		}
		count++;
		yield;
	}
}

task RenderHitboxImage(plobj, offx, hitboxnum){
	if(IsHitboxActive){return;}
	while(playerdead){
		if(GetVirtualKeyState(VK_SLOWMOVE)!=KEY_FREE){return;}
		yield;
	}
	IsHitboxActive = true;
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj, BLEND_ALPHA);
	Obj_SetRenderPriority(obj, 0.39);
	ObjRender_SetAlpha(obj, 220);
	ObjPrim_SetTexture(obj, snowflake);
	ObjSprite2D_SetSourceRect(obj, 0, 0, 64, 64);
	ObjSprite2D_SetDestCenter(obj);
	
	let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj2, BLEND_ALPHA);
	Obj_SetRenderPriority(obj2, 0.69);
	ObjRender_SetAlpha(obj2, 220);
	ObjPrim_SetTexture(obj2, snowflake);
	ObjSprite2D_SetSourceRect(obj2, 0, 0, 64, 64);
	ObjSprite2D_SetDestCenter(obj2);
	
	
	let ObjTime = 0;
	
	let AlphaSet = 0;
	let ObjAlpha = 0;
	let ObjScale = 1;
	
	while(GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD){
		if(!isvisible){ObjRender_SetAlpha(obj, 0); ObjRender_SetAlpha(obj2, 0);}else{ObjRender_SetAlpha(obj, 255); ObjRender_SetAlpha(obj2, 255);}

		ObjPrim_SetTexture(obj, snowflake);
		ObjPrim_SetTexture(obj2, snowflake);

		if(ObjScale<1.4&&!playerdead){
			ObjTime+=8;
			ObjScale += 0.125;
			PositionSet;
		}else{break;}
		yield;
	}
	while(GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD){
		if(!isvisible){ObjRender_SetAlpha(obj, 0); ObjRender_SetAlpha(obj2, 0);}else{ObjRender_SetAlpha(obj, 255); ObjRender_SetAlpha(obj2, 255);}

		ObjPrim_SetTexture(obj, snowflake);
		ObjPrim_SetTexture(obj2, snowflake);

		if(ObjScale>1&&!playerdead){
			ObjTime+=8;
			ObjScale -= 0.1;
			PositionSet;
		}else{break;}
		yield;
	}
	ObjScale = 1;
	yield;
	while(GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD){
		if(!isvisible){ObjRender_SetAlpha(obj, 0); ObjRender_SetAlpha(obj2, 0);}else{ObjRender_SetAlpha(obj, 255); ObjRender_SetAlpha(obj2, 255);}

		ObjPrim_SetTexture(obj, snowflake);
		ObjPrim_SetTexture(obj2, snowflake);

		if(!playerdead){
			ObjTime+=3;
			PositionSet;
		}else{break;}
		yield;
	}
	IsHitboxActive = false;
	while(ObjScale>0){
		if(!isvisible){ObjRender_SetAlpha(obj, 0); ObjRender_SetAlpha(obj2, 0);}else{ObjRender_SetAlpha(obj, 255); ObjRender_SetAlpha(obj2, 255);}

		ObjPrim_SetTexture(obj, snowflake);
		ObjPrim_SetTexture(obj2, snowflake);

		ObjTime+=3;
		ObjScale -= 0.25;
		PositionSet;
		yield;
	}

	Obj_Delete(obj);
	Obj_Delete(obj2);
	IsHitboxActive = false;
	
	task PositionSet{
		ObjRender_SetPosition(obj, GetPlayerX, GetPlayerY, 0);
		ObjRender_SetAngleZ(obj, ObjTime);
		ObjRender_SetPosition(obj2, GetPlayerX, GetPlayerY, 0);
		ObjRender_SetScaleXYZ(obj, ObjScale, ObjScale, ObjScale);
		ObjRender_SetScaleXYZ(obj2, ObjScale, ObjScale, ObjScale);
	}
	
}

task RenderPlayerImage(ObjectRender, offset){
	let anim_count = 0;
	let anim_type = 0;
	let Uber = 0;
	let Uberblink = 0;
	
	let x = 32;
	let y = 48;
	let ri = 6;
	let rm = 4;
	let bn = 0;
	
	ObjPrim_SetTexture(ObjectRender, imgPlayer);
	Obj_SetRenderPriority(ObjectRender, 0.45);
	
	loop{

		if(GetPlayerState!=STATE_DOWN && isvisible){
			ObjRender_SetAlpha(ObjectRender, 255);
		}
		if(GetPlayerState==STATE_DOWN || playerdead || !isvisible){ObjRender_SetAlpha(ObjectRender, 0);}
		
		
		ObjRender_SetPosition(ObjectRender, GetPlayerX, GetPlayerY, 0);
		if(!IsPlayerSpawning){
			if(GetPlayerState!=STATE_HIT){
				Blink;
				if(GetVirtualKeyState(VK_RIGHT) == KEY_FREE && GetVirtualKeyState(VK_LEFT) == KEY_FREE){
					if(anim_type != 0){
						bn = 0;
						anim_count = 0;
						anim_type = 0;
					}
				}
				if(GetVirtualKeyState(VK_LEFT) == KEY_PUSH || GetVirtualKeyState(VK_LEFT) == KEY_HOLD){
					if(GetVirtualKeyState(VK_RIGHT) != KEY_HOLD && anim_type != 1){
						bn = 0.85;
						anim_count = 0;
						anim_type = 1;
					}
				}
				if(GetVirtualKeyState(VK_RIGHT) == KEY_PUSH || GetVirtualKeyState(VK_RIGHT) == KEY_HOLD){
					if(anim_type != 2){
						bn = 0.85;
						anim_count = 0;
						anim_type = 2;
					}
				}
				anim_count+=(1+bn);
				if(floor(anim_count) != anim_count && bn == 0){
					anim_count = floor(anim_count);
				}
			}
		}else{
			Blink;
			anim_count+=1;
			if(anim_type != 0){
				anim_count = 0;
				anim_type = 0;
			}
		}
		//0 - Idle; 1 - Left; 2 - Right
		
		if(anim_type==0){
			if(round(anim_count) >= 0){ObjSprite2D_SetSourceRect(ObjectRender, 0, 0+offset, x, y+offset);}
			if(round(anim_count) >= ri){ObjSprite2D_SetSourceRect(ObjectRender, x, 0+offset, x*2, y+offset);}
			if(round(anim_count) >= ri*2){ObjSprite2D_SetSourceRect(ObjectRender, x*2, 0+offset, x*3, y+offset);}
			if(round(anim_count) >= ri*3){ObjSprite2D_SetSourceRect(ObjectRender, x*3, 0+offset, x*4, y+offset);}
			if(round(anim_count) >= ri*4){ObjSprite2D_SetSourceRect(ObjectRender, x*4, 0+offset, x*5, y+offset);}
			if(round(anim_count) >= ri*5){ObjSprite2D_SetSourceRect(ObjectRender, x*5, 0+offset, x*6, y+offset);}
			if(round(anim_count) >= ri*6){ObjSprite2D_SetSourceRect(ObjectRender, x*6, 0+offset, x*7, y+offset);}
			if(round(anim_count) >= ri*7){ObjSprite2D_SetSourceRect(ObjectRender, x*7, 0+offset, x*8, y+offset);}
			if(round(anim_count) >= ri*8-1){anim_count = ri-1;}
		}
		if(anim_type==1){
			if(round(anim_count) >= 0){ObjSprite2D_SetSourceRect(ObjectRender, 0, y+offset, x, y*2+offset);}
			if(round(anim_count) >= rm){ObjSprite2D_SetSourceRect(ObjectRender, x, y+offset, x*2, y*2+offset);}
			if(round(anim_count) >= rm*2){ObjSprite2D_SetSourceRect(ObjectRender, x*2, y+offset, x*3, y*2+offset);}
			if(round(anim_count) >= rm*3){ObjSprite2D_SetSourceRect(ObjectRender, x*3, y+offset, x*4, y*2+offset);}
			if(round(anim_count) >= rm*4){ObjSprite2D_SetSourceRect(ObjectRender, x*4, y+offset, x*5, y*2+offset);bn = 0}
			if(round(anim_count) >= rm*5){ObjSprite2D_SetSourceRect(ObjectRender, x*5, y+offset, x*6, y*2+offset);}
			if(round(anim_count) >= rm*6){ObjSprite2D_SetSourceRect(ObjectRender, x*6, y+offset, x*7, y*2+offset);}
			if(round(anim_count) >= rm*7){ObjSprite2D_SetSourceRect(ObjectRender, x*7, y+offset, x*8, y*2+offset);}
			if(round(anim_count) >= rm*8-1){anim_count = rm*4-1;}
		}
		if(anim_type==2){
			if(round(anim_count) >= 0){ObjSprite2D_SetSourceRect(ObjectRender, 0, y*2+offset, x, y*3+offset);}
			if(round(anim_count) >= rm){ObjSprite2D_SetSourceRect(ObjectRender, x, y*2+offset, x*2, y*3+offset);}
			if(round(anim_count) >= rm*2){ObjSprite2D_SetSourceRect(ObjectRender, x*2, y*2+offset, x*3, y*3+offset);}
			if(round(anim_count) >= rm*3){ObjSprite2D_SetSourceRect(ObjectRender, x*3, y*2+offset, x*4, y*3+offset);}
			if(round(anim_count) >= rm*4){ObjSprite2D_SetSourceRect(ObjectRender, x*4, y*2+offset, x*5, y*3+offset);bn = 0}
			if(round(anim_count) >= rm*5){ObjSprite2D_SetSourceRect(ObjectRender, x*5, y*2+offset, x*6, y*3+offset);}
			if(round(anim_count) >= rm*6){ObjSprite2D_SetSourceRect(ObjectRender, x*6, y*2+offset, x*7, y*3+offset);}
			if(round(anim_count) >= rm*7){ObjSprite2D_SetSourceRect(ObjectRender, x*7, y*2+offset, x*8, y*3+offset);}
			if(round(anim_count) >= rm*8-1){anim_count = rm*4-1;}
		}
		
		
		ObjSprite2D_SetDestCenter(ObjectRender);
		yield;
	}	
	task Blink{
		if(GetPlayerInvincibilityFrame>0){
			if(Uber==0){ObjRender_SetColor(ObjectRender, 255, 255, 255);}
			if(Uber!=0){ObjRender_SetColor(ObjectRender, 32, 32, 255);}
			Uberblink+=1;
			if(Uberblink>1){Uberblink=0;Uber++;if(Uber>1){Uber=0}}
		}else{
			ObjRender_SetColor(ObjectRender, 255, 255, 255);
		}
	}
}

task Spawn{
	let obj = GetPlayerObjectID;
	let y = 0;
	ObjRender_SetX(obj, GetStgFrameWidth/2);
	ObjRender_SetY(obj, GetStgFrameHeight-32);
	SetPlayerSpeed(0,0);
	IsPlayerSpawning = true;
	while(y<82){
		SetPlayerClip(11,11,GetStgFrameWidth-11,GetStgFrameHeight+64);	
		SetPlayerSpeed(0,0);
		ObjRender_SetY(obj, GetStgFrameHeight+32-y);
		y+=2;
		yield;
	}
	IsPlayerSpawning = false;
	SetPlayerSpeed(4,1.75);
}

task PlayerExplode(path){
	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, 63, 63);
	ObjSprite2D_SetDestRect(obj, -32, -32, 32, 32);

	let alpha = 255;
	let scale = 0;
	loop(30){
		scale += 0.2;
		alpha -= 8;
		ObjRender_SetColor(obj, alpha, alpha, alpha);
		ObjRender_SetPosition(obj, GetPlayerX, GetPlayerY, 0);
		ObjRender_SetScaleXYZ(obj, scale, scale, 1);
		yield;
	}
	Obj_Delete(obj);
}

task TMagicCircle{
		let countVertex = 64;
		let listRadius = [];
		loop(countVertex)
		{
			listRadius = listRadius ~ [0];
		}

		let path = current ~ "Image/Default_Player_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.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 = 128;
		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 += 360 / countVertex / 2;
				Obj_SetVisible(obj, true);

				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;
					}

				}

				ObjRender_SetColor(obj, 192 * alpha, 192 * alpha, 255 * alpha);
				ObjRender_SetPosition(obj, px, py, 0);
				ObjRender_SetAngleZ(obj, angleRender);

				frame++;
			}

			yield;
		}
	}

task Manage{
	//CanShoot = false;
	isspell = true;
	SetPlayerInvincibilityFrame(480);

	let objmanage = GetSpellManageObject;
	PlaySE(current~"Sound/se_boon01.wav");

	let obj = ObjSpell_Create;
	ObjSpell_Regist(obj);
	ObjSpell_SetDamage(obj, 0);
	loop(420){
		ObjSpell_SetIntersectionLine(obj, GetPlayerX, GetPlayerY, GetPlayerX, GetPlayerY - 600, 20);
		yield;
	}
	PlaySE(current~"Sound/se_boon01.wav");
	isspell = false;
	Obj_Delete(objmanage);
	Obj_Delete(obj);
}

function GetDist(x1,y1,x2,y2){
	return ((x2-x1)^2+(y2-y1)^2)^0.5;
}

function GetAngle(x1,y1,x2,y2){
	return atan2(y2-y1,x2-x1);
}