#東方弾幕風[Player]
#ScriptVersion[3]	
#ID["TM_Reimu"]
#Title["MoF Reimu"]
#Text["3 Shot Type. Switch by pressing C"]
#Image["./Reimu.png"]
#ReplayName["Reimu"]

let objPlayer = GetPlayerObjectID();
let objSlowShot = ID_INVALID;
let current = GetCurrentScriptDirectory();
let enemy;
let focus = false;
let type = 0;
let vx = 4.5;
let vy = 2;
let spelltime = false;
@Initialize
{
	SetPlayerSpeed(vx, vy);
	SetPlayerClip(12,12,GetStgFrameWidth-12,GetStgFrameHeight-12);
	SetPlayerDownStateFrame(60);
	SetPlayerRebirthFrame(20);
	let path = current ~ "ReimuShotData.txt";
	LoadPlayerShotData(path); //自弾画像ロード

	ObjPlayer_AddIntersectionCircleA1(objPlayer, 0, 0, 1, 20);
	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.wav");
	TImage();
	TShot();
	TMagicCircle();
	HitBox;
}

@MainLoop
{
	enemy = GetAllEnemyID;
	yield;
}

@Finalize
{
}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_SPELL)
	{
		//スペルカード要求
		let spell = GetPlayerSpell();
		if(spell >= 1)
		{
			SetScriptResult(true);
			SetPlayerSpell(spell-1);
			if(type==0){
			TSpell1;
			}
			if(type==1){
			TSpell2;
			}
			if(type==2){
			TSpell3;
			}
		}
		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);
	}
	
}

task TImage
{
	let f = 0;
	let f2 = 0;
	let px = 32;
	let py = 48;
	Orb;
	let path = GetCurrentScriptDirectory() ~ "pl00.png";
	ObjPrim_SetTexture(objPlayer, path);
	loop
	{
		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, 0, px, 48);}
			if(f>=6&& f<=12){ObjSprite2D_SetSourceRect(objPlayer, px, 0, px*2, 48);}
			if(f>=12 && f<=18){ObjSprite2D_SetSourceRect(objPlayer, px*2, 0, px*3, 48);}
			if(f>=18 && f<=24){ObjSprite2D_SetSourceRect(objPlayer, px*3, 0, px*4, 48);}
			if(f>=24 && f<=30){ObjSprite2D_SetSourceRect(objPlayer, px*4, 0, px*5, 48);}
			if(f>=30 && f<=36){ObjSprite2D_SetSourceRect(objPlayer, px*5, 0, px*6, 48);}
			if(f>=36 && f<=42){ObjSprite2D_SetSourceRect(objPlayer, px*6, 0, px*7, 48);}
			if(f>=42){ObjSprite2D_SetSourceRect(objPlayer, px*7, 0, px*8, 48);}
			if(f>=48){f=0;}
			f++;
			f2 = 0;
		}
		ObjSprite2D_SetDestCenter(objPlayer);
		yield;
	}

}

task TShot
{
	let shotCount = -1;
	let bNextShot = false;
	let objShot = ID_INVALID;
	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_HOLD && shotCount>0)
		{
			bNextShot = true;
		}
		if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_PUSH || GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD && GetPlayerState == STATE_NORMAL && IsPermitPlayerShot)
		{
			focus = true;
			if(shotCount%5 == 0)
			{
			if(type==0 || (type==1 && spelltime ==false) && type!=2 && type!=1){
			S_Amulet(GetPlayerX-10,GetPlayerY,20,270,4,1);
			S_Amulet(GetPlayerX+10,GetPlayerY,20,270,4,1);
			}
				if(type==0){
				H_Amulet(GetPlayerX+10,GetPlayerY+20,13,285,2.5,0.75); // Focus
				H_Amulet(GetPlayerX+20,GetPlayerY+10,13,300,2.5,0.75);
				H_Amulet(GetPlayerX-10,GetPlayerY+20,13,255,2.5,0.75);
				H_Amulet(GetPlayerX-20,GetPlayerY+10,13,240,2.5,0.75);
				}
				if(type==1 && spelltime == false){
				Needle(GetPlayerX+5,GetPlayerY-35,20,270,1.5,1.5); // Focus
				Needle(GetPlayerX+15,GetPlayerY-35,20,270,1.5,1.5);
				Needle(GetPlayerX+25,GetPlayerY-15,20,270,1.5,1.5);
				Needle(GetPlayerX+15,GetPlayerY-15,20,270,1.5,1.5);
				Needle(GetPlayerX-5,GetPlayerY-35,20,270,1.5,1.5);
				Needle(GetPlayerX-15,GetPlayerY-35,20,270,1.5,1.5);
				Needle(GetPlayerX-15,GetPlayerY-15,20,270,1.5,1.5);
				Needle(GetPlayerX-25,GetPlayerY-15,20,270,1.5,1.5);
				}
				if(type==2 && spelltime == false){
				ascent(i in 0..2){
				Buster(GetPlayerX,GetPlayerY,25,250+i*10,2,1.5);
				Buster(GetPlayerX-10+i*20,GetPlayerY-10,25,270,4,1.5);
				Buster(GetPlayerX,GetPlayerY,25,280+i*10,2,1.5);
				}
				}
			}
			if(shotCount%4 == 0)
			{
			PlaySound("se_shot",98,0);
			}
		}
		else
		{	if(GetPlayerState == STATE_NORMAL && IsPermitPlayerShot){
		
			focus = false;
			Obj_Delete(objSlowShot);
			if(shotCount%5 == 0)
			{
			if(type==0 || (type==1 && spelltime ==false) || (type==2 && spelltime ==false)){
			S_Amulet(GetPlayerX-10,GetPlayerY,20,270,4,1);
			S_Amulet(GetPlayerX+10,GetPlayerY,20,270,4,1);
			}
				if(type==0){
				H_Amulet(GetPlayerX+20,GetPlayerY+35,13,300-5,2.5,0.75);
				H_Amulet(GetPlayerX+40,GetPlayerY+15,13,330-10,2.5,0.75);
				H_Amulet(GetPlayerX-20,GetPlayerY+35,13,240+5,2.5,0.75);
				H_Amulet(GetPlayerX-40,GetPlayerY+15,13,210+10,2.5,0.75);
				}
				if(type==1 && spelltime == false){
				Needle(GetPlayerX+20,GetPlayerY-35,20,270,1.9,1.5);
				Needle(GetPlayerX+40,GetPlayerY-15,20,270,1.9,1.5);
				Needle(GetPlayerX-20,GetPlayerY-35,20,270,1.9,1.5);
				Needle(GetPlayerX-40,GetPlayerY-15,20,270,1.9,1.5);
				}
				if(type==2  && spelltime == false){
				PNeedle(GetPlayerX+55,GetPlayerY,17,270,2.5,1.5);
				PNeedle(GetPlayerX+25,GetPlayerY,17,270,2.5,1.5);
				PNeedle(GetPlayerX-65,GetPlayerY,17,270,2.5,1.5);
				PNeedle(GetPlayerX-35,GetPlayerY,17,270,2.5,1.5);
				}
			}
						if(shotCount%4 == 0)
			{
			PlaySound("se_shot",98,0);
			}
			}
		}

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

task HitBox{
		let obj=ObjPrim_Create(OBJ_SPRITE_2D); 
		let img = GetCurrentScriptDirectory~"eff2.png";
		let c = 0;
		let alpha = 0;
		ObjPrim_SetTexture(obj,img);
		ObjSprite2D_SetSourceRect(obj,0,16,64,80);
		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+=3;
		yield;
		}
	}

task Orb{
	Ball1;//1
	Ball2;//1
	Ball3;//1
	Ball4;//1
	Ball5;//2
	Ball6;//2
	Ball7;//2
	Ball8;//2
	Ball9;//3
	Ball10;//3
	Ball11;//3
	Ball12;//3
	task Ball1{
		let obj = setball(0);
		let px = 25;
		let py = 40;
		while(!Obj_IsDeleted(obj)){
		if(focus==false){
		if(px<20){px+=5;}
		if(py<35){py+=5;}
		}
		if(focus==true){
		if(px>10){px-=5;}
		if(py>20){py-=5;}
		}
		ObjRender_SetPosition(obj,GetPlayerX+px,GetPlayerY+py+5,0);
		yield;
		}
	}
	task Ball2{
		let obj = setball(0);
		let px = 50;
		let py = 20;
		while(!Obj_IsDeleted(obj)){
		if(focus==false){
		if(px<40){px+=5;}
		if(py<15){py+=5;}
		}
		if(focus==true){
		if(px>20){px-=5;}
		if(py>10){py-=5;}
		}
		ObjRender_SetPosition(obj,GetPlayerX+px,GetPlayerY+py+5,0);
		yield;
		}
	}
	task Ball3{
		let obj = setball(0);
		let px = 25;
		let py = 40;
		while(!Obj_IsDeleted(obj)){
		if(focus==false){
		if(px<20){px+=5;}
		if(py<35){py+=5;}
		}
		if(focus==true){
		if(px>10){px-=5;}
		if(py>20){py-=5;}
		}
		ObjRender_SetPosition(obj,GetPlayerX-px,GetPlayerY+py+5,0);
		yield;
		}
	}
	task Ball4{
		let obj = setball(0);
		let px = 50;
		let py = 20;
		while(!Obj_IsDeleted(obj)){
		if(focus==false){
		if(px<40){px+=5;}
		if(py<15){py+=5;}
		}
		if(focus==true){
		if(px>20){px-=5;}
		if(py>10){py-=5;}
		}
		ObjRender_SetPosition(obj,GetPlayerX-px,GetPlayerY+py+5,0);
		yield;
		}
	}
	
	task Ball5{
		let obj = setball(1);
		let px = 20;
		let py = 35;
		while(!Obj_IsDeleted(obj)){
		if(focus==false){
		if(px<20){px+=5;}
		if(py<35){py+=5;}
		}
		if(focus==true){
		if(px>10){px-=5;}
		if(py>30){py-=5;}
		}
		ObjRender_SetPosition(obj,GetPlayerX+px,GetPlayerY-py,0);
		yield;
		}
	}
	task Ball6{
		let obj = setball(1);
		let px = 40;
		let py = 15;
		while(!Obj_IsDeleted(obj)){
		if(focus==false){
		if(px<40){px+=5;}
		if(py>5){py-=5;}
		}
		if(focus==true){
		if(px>20){px-=5;}
		if(py<15){py+=5;}
		}
		ObjRender_SetPosition(obj,GetPlayerX+px,GetPlayerY-py,0);
		yield;
		}
	}
	task Ball7{
		let obj = setball(1);
		let px = 20;
		let py = 35;
		while(!Obj_IsDeleted(obj)){
		if(focus==false){
		if(px<20){px+=5;}
		if(py<35){py+=5;}
		}
		if(focus==true){
		if(px>10){px-=5;}
		if(py>30){py-=5;}
		}
		ObjRender_SetPosition(obj,GetPlayerX-px,GetPlayerY-py,0);
		yield;
		}
	}
	task Ball8{
		let obj = setball(1);
		let px = 40;
		let py = 15;
		while(!Obj_IsDeleted(obj)){
		if(focus==false){
		if(px<40){px+=5;}
		if(py>5){py-=5;}
		}
		if(focus==true){
		if(px>20){px-=5;}
		if(py<15){py+=5;}
		}
		ObjRender_SetPosition(obj,GetPlayerX-px,GetPlayerY-py,0);
		yield;
		}
	}
	
	task Ball9{
		let obj = setball(2);
		let px = 60;
		let py = 0;
		while(!Obj_IsDeleted(obj)){
		if(focus==false){
		if(px<60){px+=10;}
		}
		if(focus==true){
		if(px>0){px-=10;}
		}
		ObjRender_SetPosition(obj,GetPlayerX+px,GetPlayerY,0);
		yield;
		}
	}
	task Ball10{
		let obj = setball(2);
		let px = 30;
		while(!Obj_IsDeleted(obj)){
		if(focus==false){
		if(px<30){px+=5;}
		}
		if(focus==true){
		if(px>0){px-=5;}
		}
		ObjRender_SetPosition(obj,GetPlayerX+px,GetPlayerY,0);
		yield;
		}
	}
	task Ball11{
		let obj = setball(2);
		let px = 60;
		while(!Obj_IsDeleted(obj)){
		if(focus==false){
		if(px<60){px+=10;}
		}
		if(focus==true){
		if(px>0){px-=10;}
		}
		ObjRender_SetPosition(obj,GetPlayerX-px,GetPlayerY,0);
		yield;
		}
	}
	task Ball12{
		let obj = setball(2);
		let px = 30;
		while(!Obj_IsDeleted(obj)){
		if(focus==false){
		if(px<30){px+=5;}
		}
		if(focus==true){
		if(px>0){px-=5;}
		}
		ObjRender_SetPosition(obj,GetPlayerX-px,GetPlayerY,0);
		yield;
		}
	}
	
		function setball(style){
		let obj=ObjPrim_Create(OBJ_SPRITE_2D); 
		let img = GetCurrentScriptDirectory~"pl00.png";
		let c = 0;
		ObjPrim_SetTexture(obj,img);
		if(style==0){ObjSprite2D_SetSourceRect(obj,65,145,80,160);}
		if(style==1){ObjSprite2D_SetSourceRect(obj,81,145,96,160);}
		if(style==2){ObjSprite2D_SetSourceRect(obj,97,145,112,160);}
		ObjSprite2D_SetDestCenter(obj);
		ObjRender_SetBlendType(obj,BLEND_ALPHA);
		Obj_SetRenderPriority(obj,0.25);
		Control;
		return obj;
			task Control{
				while(!Obj_IsDeleted(obj)){
					if(style==type && GetPlayerState == STATE_NORMAL){ObjRender_SetAlpha(obj,255);}
					else{ObjRender_SetAlpha(obj,0);}
						ObjRender_SetAngleXYZ(obj,0,0,c);
						c+=5;
					yield;
				}
			}
		}
	}

task S_Amulet(x,y,spd,dir,dmg,pdmg){
	let mainobj;
	mainobj = CreatePlayerShotA1(x,y,spd,dir,dmg,pdmg,1);
	let count = 0;
	ObjRender_SetColor(mainobj,0,0,0);
	let obj=ObjPrim_Create(OBJ_SPRITE_2D); // graphic
	let img = GetCurrentScriptDirectory~"pl00.png";
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,176,64,192);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetAngleXYZ(obj,0,0,-90);
	ObjRender_SetColor(obj,192,192,192);
	while(!Obj_IsDeleted(mainobj) && count<75){
	ObjRender_SetPosition(obj,ObjRender_GetX(mainobj),ObjRender_GetY(mainobj),0);
	count++;
	yield;
	}
	let px = ObjRender_GetX(obj);
	let py = ObjRender_GetY(obj);
	let c = 0;
	descent(i in 0..20){
	ObjRender_SetPosition(obj,px,py-c,0);
	ObjRender_SetColor(obj,i*8,i*8,i*8);
	c++;
	yield;
	}
	Obj_Delete(obj);
	}
	
task H_Amulet(x,y,spd,dir,dmg,pdmg){
	let mainobj = CreatePlayerShotA1(x,y,spd,dir,dmg,pdmg,1);
	let count = 0;
	ObjRender_SetColor(mainobj,0,0,0);
	let obj=ObjPrim_Create(OBJ_SPRITE_2D); // graphic
	let img = GetCurrentScriptDirectory~"pl00.png";
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,160,16,176);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetAngleXYZ(obj,0,0,-90);
	ObjRender_SetColor(obj,128,128,128);
	if(FindTarget!=-1)
	{
	let h_obj = FindTarget;
	Homing(mainobj,h_obj,1.5);
	}
	while(!Obj_IsDeleted(mainobj) && count<=75){
	ObjRender_SetPosition(obj,ObjRender_GetX(mainobj),ObjRender_GetY(mainobj),0);
	count++;
	yield;
	}
	let px = ObjRender_GetX(obj);
	let py = ObjRender_GetY(obj);
	let c = 0;
	color;
	ascent(i in 0..10){
	ObjRender_SetScaleXYZ(obj,1+i/10,1+i/10,0);
	yield;
	}
		task color{
		descent(i in 0..10){
		ObjRender_SetPosition(obj,px,py,0);
		ObjRender_SetColor(obj,i*8,i*8,i*8);
		c++;
		yield;
		}
		}
	Obj_Delete(obj);
	}

task Homing(obj,h_obj,maxTraverse){  // max. angle of traverse
	let angle = ObjMove_GetAngle(obj);
	let dir = 0;
	let speed = ObjMove_GetSpeed(obj);
	let boss = GetIntersectionRegistedEnemyID;
    while(! Obj_IsDeleted(obj) && Obj_GetValueD(h_obj,"HomingOrNot",1)==1 && FindTarget!=-1) {
        ObjMove_SetAngle(obj, angle);
		maxTraverse += 1;
		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;
							}
						}
						}
						
        // direction angle to player's character

        // difference between 'dir' and 'angle'
        let diff = dir - angle;
        while(diff >= 180) { diff -= 360; }    // adjust the range
        while(diff < -180) { diff += 360; }

        let diffAbs = (|diff|);
        if(diffAbs < maxTraverse) {
            // if the difference is small,
            // the bullet turns to the player's character
            angle = dir;
        } else {
            // otherwise, the bullet turns 'maxTraverse' degrees
            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 Needle(x,y,spd,dir,dmg,pdmg){
	let mainobj = CreatePlayerShotA1(x+5,y-20,spd,dir,dmg,pdmg,1);
	let count = 0;
	ObjRender_SetColor(mainobj,0,0,0);
	let obj=ObjPrim_Create(OBJ_SPRITE_2D); // graphic
	let img = GetCurrentScriptDirectory~"pl00.png";
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,64,176,128,192);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetAngleXYZ(obj,0,0,-90);
	ObjRender_SetColor(obj,192,192,192);
	while(!Obj_IsDeleted(mainobj) && count<75){
	ObjRender_SetPosition(obj,ObjRender_GetX(mainobj),ObjRender_GetY(mainobj),0);
	count++;
	yield;
	}
	let px = ObjRender_GetX(obj);
	let py = ObjRender_GetY(obj);
	let c = 0;
	descent(i in 0..20){
	ObjRender_SetPosition(obj,px,py-c,0);
	ObjRender_SetColor(obj,i*8,i*8,i*8);
	c++;
	yield;
	}
	Obj_Delete(obj);
	}
	
task PNeedle(x,y,spd,dir,dmg,pdmg){
	let mainobj = CreatePlayerShotA1(x+5,y-20,spd,dir,dmg,pdmg,1);
	let count = 0;
	ObjRender_SetColor(mainobj,0,0,0);
	let obj=ObjPrim_Create(OBJ_SPRITE_2D); // graphic
	let img = GetCurrentScriptDirectory~"pl00.png";
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,128,145,143,151);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetAngleXYZ(obj,0,0,-90);
	while(!Obj_IsDeleted(mainobj) && count<75){
	ObjRender_SetPosition(obj,ObjRender_GetX(mainobj),ObjRender_GetY(mainobj),0);
	count++;
	yield;
	}
	let px = ObjRender_GetX(obj);
	let py = ObjRender_GetY(obj);
	let c = 0;
	descent(i in 0..20){
	ObjRender_SetPosition(obj,px,py-c,0);
	ObjRender_SetColor(obj,i*8,i*8,i*8);
	c++;
	yield;
	}
	Obj_Delete(obj);
	}
	
task Buster(x,y,spd,dir,dmg,pdmg){
	let mainobj = CreatePlayerShotA1(x,y-10,spd,dir,dmg,pdmg,1);
	let count = 0;
	ObjRender_SetColor(mainobj,0,0,0);
	let obj=ObjPrim_Create(OBJ_SPRITE_2D); // graphic
	let img = GetCurrentScriptDirectory~"pl00.png";
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,136,176,194,192);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetAngleXYZ(obj,0,0,dir);
	ObjRender_SetColor(obj,128,128,128);
	ObjRender_SetScaleXYZ(obj,1.1,1.1,0);
	while(!Obj_IsDeleted(mainobj) && count<75){
	ObjRender_SetPosition(obj,ObjRender_GetX(mainobj),ObjRender_GetY(mainobj),0);
	count++;
	yield;
	}
	let px = ObjRender_GetX(obj);
	let py = ObjRender_GetY(obj);
	let c = 0;
	descent(i in 0..20){
	ObjRender_SetPosition(obj,px+c*cos(dir),py+c*sin(dir),0);
	ObjRender_SetColor(obj,i*6,i*6,i*6);
	c++;
	yield;
	}
	Obj_Delete(obj);
	}

task TMagicCircle
{


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

	let path = current ~ "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 TExplosion
{
	let path = GetCurrentScriptDirectory() ~ "eff2.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, 128, 16, 192, 79);
	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 TSpell1
{
	spelltime = true;
	let objManage = GetSpellManageObject();
	SetPlayerInvincibilityFrame(240);
	PlaySE(GetCurrentScriptDirectory~"Charge1.wav");
	ascent(i in 1..5){
	PlaySound("Eff2",90,0);
	TShot(GetPlayerX+150*cos(i*30+270-10),GetPlayerY+150*sin(i*30+270-10));
	TShot(GetPlayerX+150*cos(-i*30+270+10),GetPlayerY+150*sin(-i*30+270+10));
	wait(8);
	}
	wait(210);
	Obj_Delete(objManage);
	spelltime = false;
	task TShot(px,py){
	let shot = CreateShotA1(GetPlayerX,GetPlayerY,0,0,1,0);
	let spell = ObjSpell_Create;
	ObjSpell_Regist(spell);
	ObjSpell_SetDamage(spell,0);
	ObjRender_SetColor(shot,0,0,0);
	ObjShot_SetAutoDelete(shot,false);
	graphic(shot,spell,1,0);
	ManageShot;
	task ManageShot{
	ObjMove_SetDestAtWeight(shot,px,py,10,5);
	wait(60);
	let target = GetIntersectionRegistedEnemyID;
	let angle = 270;
	let mindis = 999;
	let t_obj;
	let sx = 0;
	let sy = 0;
		if(length(target)>0){
			ascent(i in 0..length(target)){
			let dis = GetDistance(ObjMove_GetX(shot),ObjMove_GetY(shot),ObjMove_GetX(target[i]),ObjMove_GetY(target[i]));
				if(mindis>dis){
				mindis = dis;
				t_obj = target[i];
				}
			}
				let spell = ObjSpell_Create;
				ObjSpell_Regist(spell);
				ObjSpell_SetDamage(spell,4);
			while(!Obj_IsDeleted(shot) && !Obj_IsDeleted(t_obj) && Obj_GetValueD(t_obj,"HomingOrNot",1)==1){
			sx = ObjMove_GetX(shot);
			sy = ObjMove_GetY(shot);
			angle=atan2(ObjMove_GetY(t_obj)-ObjMove_GetY(shot),ObjMove_GetX(t_obj)-ObjMove_GetX(shot));
			ObjMove_AddPatternA2(shot,0,NO_CHANGE,angle,0.1,0,10);
			ObjSpell_SetIntersectionCircle(spell,ObjRender_GetX(shot),ObjRender_GetY(shot),50);
			wait(1);
			}
				ObjSpell_SetDamage(spell,6.5);
				ascent(i in 0..30){
				ObjSpell_SetIntersectionCircle(spell,sx,sy,100);
				yield;
				}
				Obj_Delete(spell);
				Obj_Delete(shot);
			}
		}
	}
}

task TSpell2
{
		let img = GetCurrentScriptDirectory() ~ "pl00.png";
		LoadTexture(img);
		spelltime = true;
		let objManage = GetSpellManageObject();
		SetPlayerInvincibilityFrame(245);
		PlaySE(GetCurrentScriptDirectory~"SpellCard.wav");
		CircleEff(GetPlayerX,GetPlayerY,1.5);
		CircleEff(GetPlayerX,GetPlayerY,1);
		CircleEff(GetPlayerX,GetPlayerY,0.5);
		TCharge01(GetPlayerX,GetPlayerY,3,30,255,128,0);
		//wait(40);
		ScreenShake(180);
		ascent(n in 0..70){
		SetPlayerSpeed(vx*0.5,vy*0.5);
		PlaySE(GetCurrentScriptDirectory~"Shot6.wav");
		ascent(i in 0..3){
		RealSpell(GetPlayerX+(10+i*25)*sin(n*20),i);
		RealSpell(GetPlayerX+(10+i*25)*sin(-n*20),i);
		}
		wait(3);
		}
		SetPlayerSpeed(vx,vy);
		wait(30);
		spelltime = false;
		Obj_Delete(objManage);
		
					task RealSpell(px,i){
				let obj = ObjPrim_Create(OBJ_SPRITE_2D);
				let c = 0;
				ObjPrim_SetTexture(obj, img);
				Obj_SetRenderPriority(obj, 0.30);
				ObjSprite2D_SetSourceRect(obj,0,176,64,192);
				ObjSprite2D_SetDestCenter(obj);
				ObjRender_SetAngleXYZ(obj,0,0,-90);
				ObjRender_SetPosition(obj,px,464,0);
				ObjRender_SetColor(obj,255,i*100,i*100);
				let spell = ObjSpell_Create;
				ObjSpell_Regist(spell);
				ObjSpell_SetDamage(spell,1.50);
					while(ObjRender_GetY(obj)>0){
					ObjRender_SetPosition(obj,ObjRender_GetX(obj),ObjRender_GetY(obj)-25,0);
					ObjSpell_SetIntersectionCircle(spell,ObjRender_GetX(obj),ObjRender_GetY(obj),50);
					yield;
					}
					Obj_Delete(obj);
					Obj_Delete(spell);
				}
}

task TSpell3{
		let img = GetCurrentScriptDirectory() ~ "bigInyou.png";
		LoadTexture(img);
		spelltime = true;
		let objManage = GetSpellManageObject();
		SetPlayerInvincibilityFrame(270);
		PlaySE(GetCurrentScriptDirectory~"Laser7.wav");
		RealSpell;
		task RealSpell{
				let obj = ObjPrim_Create(OBJ_SPRITE_2D);
				let r = 0;
				let scale = 0;
				let acc = 0.2;
				let a_acc = 0;
				let ang = 0;
				let c = 0;
				ObjPrim_SetTexture(obj, img);
				Obj_SetRenderPriority(obj, 0.30);
				ObjSprite2D_SetSourceRect(obj,0,0,256,256);
				ObjSprite2D_SetDestCenter(obj);
				ObjRender_SetPosition(obj,GetPlayerX,GetPlayerY,0);
				let shot = CreateShotA1(GetPlayerX,GetPlayerY,0,0,1,0);
				ObjShot_SetAutoDelete(shot,false);
				ObjShot_SetIntersectionEnable(shot,false);
				ObjShot_SetSpellResist(shot,true);
				ObjMove_SetDestAtWeight(shot,GetStgFrameWidth()/2,GetStgFrameHeight/2,20,5);
				let spell = ObjSpell_Create;
				ObjSpell_Regist(spell);
				ObjSpell_SetDamage(spell,15);
				ascent(n in 0..225){
				if(acc>0){
				scale += acc/10;
				acc -= 0.001;
				}
				ObjSpell_SetIntersectionCircle(spell,ObjRender_GetX(obj),ObjRender_GetY(obj),scale*101);
				ObjRender_SetPosition(obj,ObjMove_GetX(shot),ObjMove_GetY(shot),0);
				ObjRender_SetScaleXYZ(obj,scale,scale,0);
				ObjRender_SetAngleXYZ(obj,0,0,ang);
				ObjRender_SetColor(obj,255,255,255);
				ang += a_acc;
				if(a_acc<15){a_acc+=0.1;}
				if(n%2==0){Graphic(ObjRender_GetX(obj),ObjRender_GetY(obj),ang,scale)}
				yield;
				}
				descent(n in 0..30){
				scale += 0.2;
				ObjRender_SetScaleXYZ(obj,scale,scale,0);
				ObjRender_SetAlpha(obj,n*8);
				ObjSpell_SetIntersectionCircle(spell,ObjRender_GetX(obj),ObjRender_GetY(obj),scale*100);
				ObjRender_SetAngleXYZ(obj,0,0,ang);
				ang += a_acc/10;
				if(a_acc<15){a_acc+=0.1;}
				yield;
				}
				Obj_Delete(shot);
				Obj_Delete(obj);
				Obj_Delete(spell);
				wait(20);
				spelltime = false;
				wait(10);
				Obj_Delete(objManage);
				
				}
			task Graphic(px,py,angle,size){
				let img = GetCurrentScriptDirectory() ~ "bigInyou.png";
				let obj = ObjPrim_Create(OBJ_SPRITE_2D);
				let value = 0;
				ObjPrim_SetTexture(obj, img);
				Obj_SetRenderPriority(obj, 0.30);
				ObjSprite2D_SetSourceRect(obj,0,0,256,256);
				ObjSprite2D_SetDestCenter(obj);
				descent(n in 0..10){
				ObjRender_SetScaleXYZ(obj,size+value*size/10,size+value*size/10,0);
				ObjRender_SetPosition(obj,px,py,0);
				ObjRender_SetAngleXYZ(obj,0,0,angle);
				ObjRender_SetAlpha(obj,n*15);
				value++;
				yield;
				}
				Obj_Delete(obj);
			}
	}

	task graphic(shot,spell,size,kind){
		let img = GetCurrentScriptDirectory() ~ "pl00.png";
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
		Obj_SetRenderPriority(obj, 0.30);
		ObjPrim_SetTexture(obj, img);
		ObjSprite2D_SetSourceRect(obj, 1, 193, 64, 256);
		ObjSprite2D_SetDestCenter(obj);
		realtask;
		task realtask{
		let c = 0;
		let count = 0;
		Control;
		Scale;
			task Control{
				while(!Obj_IsDeleted(shot) && count <=180){
					ObjRender_SetPosition(obj,ObjMove_GetX(shot),ObjMove_GetY(shot),0);
					ObjRender_SetAngleXYZ(obj,0,0,c);
					c+=6;
					ObjSpell_SetIntersectionCircle(spell,ObjMove_GetX(shot),ObjMove_GetY(shot),75);
					count++;
					//if(count%2==0 && kind == 1){minortask(ObjMove_GetX(shot),ObjMove_GetY(shot),c);}
					yield;
				}
				if(ObjRender_GetX(obj) > -30 && ObjRender_GetX(obj) < GetStgFrameWidth+30 && ObjRender_GetY(obj) > -30 && ObjRender_GetY(obj) < GetStgFrameHeight+30){
				PlaySound("Shot8",90,0);
				CircleEff(ObjRender_GetX(obj),ObjRender_GetY(obj),size);
				
				
				let spell2 = ObjSpell_Create;
				ObjSpell_Regist(spell2);
				ObjSpell_SetDamage(spell2,0);
				ObjSpell_SetIntersectionCircle(spell,ObjRender_GetX(obj),ObjRender_GetY(obj),120);
				Obj_Delete(spell2);
			ascent(i in 0..20){
			ObjRender_SetScaleXYZ(obj,(1.5+i/7)*size,1.5+i/7*size,0);
			if(kind==0){ObjRender_SetColor(obj,255-i*12,255-i*12,255-i*12);}
			if(kind==1){ObjRender_SetColor(obj,(255-i*12)/8,(255-i*12)/8,(255-i*12)/8);}
			yield;
			}
			}
			Obj_Delete(obj);
			Obj_Delete(shot);
			}
			task Scale{
			ascent(i in 0..30){
			ObjRender_SetScaleXYZ(obj,i/20*size,i/20*size,0);
			yield;
			}
			}
		}
	}
	
		task CircleEff(x,y,size){
		 	let img = GetCurrentScriptDirectory() ~ "charge.png";
			let obj = ObjPrim_Create(OBJ_SPRITE_2D);
			let c = 0;
			ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
			Obj_SetRenderPriority(obj, 0.30);
			ObjPrim_SetTexture(obj, img);
			ObjSprite2D_SetSourceRect(obj, 0, 0, 128, 128);
			ObjSprite2D_SetDestCenter(obj);
			ascent(i in 0..40){
			ObjRender_SetPosition(obj,x,y,0);
			ObjRender_SetScaleXYZ(obj,i/10*size,i/10*size,0);
			ObjRender_SetColor(obj,(255-i*6.5),((255-i*6.5)/2),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 PlaySound(str,v,w){
	let s = ObjSound_Create;
	if(str == "Shot1"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Shot1.wav");}
	if(str == "Shot2"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Shot2.wav");}
	if(str == "Shot3"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Shot3.wav");}
	if(str == "Shot4"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Shot4.wav");}
	if(str == "Shot5"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Shot5.wav");}
	if(str == "Shot6"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Shot6.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 == "Laser1"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Laser1.wav");}
	if(str == "Laser2"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Laser2.wav");}
	if(str == "Laser3"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Laser3.wav");}
	if(str == "Laser4"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Laser4.wav");}
	if(str == "Laser5"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Laser5.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 == "Weird1"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Weird1.wav");}
	if(str == "Weird2"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Weird2.wav");}
	if(str == "Weird3"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Weird3.wav");}
	if(str == "BulletWave"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/BulletWave.wav");}
	if(str == "bright"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/bright.wav");}
	if(str == "Eff1"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Eff1.wav");}
	if(str == "Eff2"){ObjSound_Load(s,GetCurrentScriptDirectory~"Eff2.wav");}
	if(str == "Eff3"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Eff3.wav");}
	if(str == "Eff4"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Eff4.wav");}
	if(str == "Eff5"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Eff5.wav");}
	if(str == "fam"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/fam.wav");}
	if(str == "stars"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/stars.wav");}
	if(str == "Enep1"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Enep1.wav");}
	if(str == "Hidden"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Sudden.wav");}
	if(str == "famdie"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/famdie.wav");}
	if(str == "nonfinish"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/nonfinish.wav");}
	if(str == "cardcall"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/cardcall.wav");}
	if(str == "piss"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/piss.wav");}
	if(str == "Heal"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/Heal.wav");}
	if(str == "enemoff"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/enemoff.wav");}
	if(str == "byoro07"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/byoro07.wav");}
	if(str == "time1"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/time1.wav");}
	if(str == "time2"){ObjSound_Load(s,GetCurrentScriptDirectory~"sound/time2.wav");}
	if(str == "se_shot"){ObjSound_Load(s,GetCurrentScriptDirectory~"se_shot.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(-3, 3));
				Set2DCameraFocusY(Get2DCameraY + rand(-3, 3));
				yield;
				Reset2DCamera;
				yield;
				}
				Reset2DCamera;
			}	

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