
script_spell StellaWind //星符「ステラウインド」スクリプト
{

let imgMarisaShot = GetCurrentScriptDirectory~"..\img\Marisa_shots.png";
	let imgBorderLine = GetCurrentScriptDirectory~"..\img\SampleEC01a.png";
	let imgNebura = GetCurrentScriptDirectory~"..\img\nebura.png";
	let imgWind = GetCurrentScriptDirectory~"..\img\nebura.png";
let SE=["se\seBomb_ReimuB.wav"];
let BombX;
let BombY;
    @Initialize {
	BombX=GetPlayerX;
	BombY=GetPlayerY;
        SetPlayerInvincibility(270);
	TMain;
    }

    @Finalize {
    }

    @MainLoop {
	CollectItems;
        yield;
    }

   task TMain {
//	PlaySE(SE[0]);
	WindEffect;
	Star;
//	Border;
//	Nebura;
        loop(240){yield;}
        End;
    }

task WindEffect
{
		let R=255;let G=255; let B=255;
		let Angle=-90;
		let Speed=rand(0.2,0.4);
		let RotateAngle=rand(2,10);
		let Zangle=rand(0,360);
		let dir=rand_int(0,1)*2-1;
		let Scale=2.0;
		let Alpha=0;
		let AlphaMax=100;

		let obj = Obj_Create(OBJ_SPELL);
		ObjEffect_SetTexture(obj, imgWind);
	//	ObjEffect_SetTexture(obj, imgNebura);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	//	ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -320, -240);
		ObjEffect_SetVertexXY(obj, 1, 320,  -240);
		ObjEffect_SetVertexXY(obj, 2, 320, 240);
		ObjEffect_SetVertexXY(obj, 3,  -320,  240);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  640, 0);
		ObjEffect_SetVertexUV(obj, 2, 640,  480);
		ObjEffect_SetVertexUV(obj, 3, 0, 480);
		ObjEffect_SetLayer(obj,3);
		ObjEffect_SetScale(obj, Scale,Scale);
		
		ascent(i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}

		Obj_SetPosition(obj,GetCenterX,GetCenterY);

	//	if(GetCommonDataDefault("LightMode_SpecialEffect",0)==1){Obj_Delete(obj);return;}

		let EfX=rand(0,640);
		let EfY=0;
		let WindSpeed=10;
	//	WindAngle;
	//	WindMomiji;
	//	WindMove;
		loop(180)
		{
			if(Alpha<AlphaMax)
			{
			Alpha+=AlphaMax/60;
			}
			ObjEffect_SetAngle(obj,0,0,Angle+90);
			ObjEffect_SetVertexUV(obj, 0,  EfX+0,  EfY+0);
			ObjEffect_SetVertexUV(obj, 1,  EfX+640, EfY+0);
			ObjEffect_SetVertexUV(obj, 2, EfX+640,  EfY+480);
			ObjEffect_SetVertexUV(obj, 3, EfX+0, EfY+480);
		ascent(i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}
			EfY+=WindSpeed;
			ObjSpell_SetIntersecrionCircle(obj,GetCenterX,GetCenterY,300,0.25,true);
			yield;
		}
		loop(60)
		{
			if(Alpha>0)
			{
			Alpha-=AlphaMax/60;
			}
			ObjEffect_SetAngle(obj,0,0,Angle+90);
			ObjEffect_SetVertexUV(obj, 0,  EfX+0,  EfY+0);
			ObjEffect_SetVertexUV(obj, 1,  EfX+640, EfY+0);
			ObjEffect_SetVertexUV(obj, 2, EfX+640,  EfY+480);
			ObjEffect_SetVertexUV(obj, 3, EfX+0, EfY+480);
		ascent(i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}
			EfY+=WindSpeed;
			ObjSpell_SetIntersecrionCircle(obj,GetCenterX,GetCenterY,300,0.25,true);
			yield;
		}
		Obj_Delete(obj);
		Alpha=0;

		task WindAngle
		{
			Angle=26;
			loop(145)
			{
				Angle+=(-23-26)/130;
				yield;
			}
			wait(15);
			loop(160)
			{
				Angle+=(50+23)/145;
				yield;
			}
			loop(45)
			{
				Angle+=(90-50)/45;
				yield;
			}
		}
}


task Star
{
let t=0;
loop(60)
{
	StarEfect(9+t%7);
	loop(3){yield;};
	t+=1;
}
}

task StarEfect(graphic)
{
		let R;let G;let B;
		if(graphic==9){R=255;G=0;B=0;}
		if(graphic==10){R=255;G=100;B=0;}
		if(graphic==11){R=255;G=255;B=0;}
		if(graphic==12){R=0;G=255;B=0;}
		if(graphic==13){R=0;G=255;B=255;}
		if(graphic==14){R=0;G=0;B=255;}
		if(graphic==15){R=160;G=32;B=240;}

		let Xangle=rand(0,360)*0;
		let Yangle=rand(0,360)*0;
		let Zangle=rand(0,360);

		let XanglePlus=rand(-10,10);
		let YanglePlus=rand(-10,10);
		let ZanglePlus=rand(5,10)*(rand_int(0,1)*2-1);

		let Scale=rand(0.2,0.4);

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,rand(GetClipMinX,GetClipMaxX),GetClipMaxY);
		ObjEffect_SetTexture(obj, imgMarisaShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,  64, -64);
		ObjEffect_SetVertexXY(obj, 2,  64, 64);
		ObjEffect_SetVertexXY(obj, 3, -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  384);
		ObjEffect_SetVertexUV(obj, 1,  128, 384);
		ObjEffect_SetVertexUV(obj, 2, 128,  512);
		ObjEffect_SetVertexUV(obj, 3, 0, 512);

		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,120,R,G,B);
		}

		let speed=rand(9,15);
		let angle=rand(225,315);
		Obj_SetSpeed(obj,speed);
		Obj_SetAngle(obj,angle);

		let ShadowCount=0;
		while(!Obj_BeDeleted(obj))
		{
			if(ShadowCount%1==0 && GetCommonDataDefault("LightMode_BombEffect",0)==0)
			{
			StarShadowEfect(Obj_GetX(obj),Obj_GetY(obj),speed,angle,Scale,Xangle,Yangle,Zangle,R,G,B);
			}
			ObjEffect_SetScale(obj,Scale,Scale);
			ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
		//	Xangle+=XanglePlus;
		//	Yangle+=YanglePlus;
			Zangle+=ZanglePlus;
			Scale+=0.00;
			ShadowCount++;
			yield;
		}
}


task StarShadowEfect(X,Y,speed,angle,Scale,Xangle,Yangle,Zangle,R,G,B)
{

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,X,Y);
		ObjEffect_SetTexture(obj, imgMarisaShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,  64, -64);
		ObjEffect_SetVertexXY(obj, 2,  64, 64);
		ObjEffect_SetVertexXY(obj, 3, -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  384);
		ObjEffect_SetVertexUV(obj, 1,  128, 384);
		ObjEffect_SetVertexUV(obj, 2, 128,  512);
		ObjEffect_SetVertexUV(obj, 3, 0, 512);

		let Alpha=60;
		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}

		ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);

		loop(5)
		{
			ObjEffect_SetScale(obj,Scale,Scale);
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}
			Scale+=0.02;
			Alpha-=60/5;
			yield;
		}
		Obj_Delete(obj);
}


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

}

script_spell MicroHole //魔符「マイクロホール」スクリプト
{
	let imgBorderLine = GetCurrentScriptDirectory~"..\img\SampleEC01a.png";
	let imgNebura = GetCurrentScriptDirectory~"..\img\nebura.png";
let SE=["se\seBomb_ReimuB.wav"];
let BombX;
let BombY;
let PowerRate=1;
    @Initialize {
	if(GetCommonDataDefault("AutoBombMode",0)==1)
	{
	PowerRate=1.5;
	}
	BombX=GetPlayerX;
	BombY=GetPlayerY;
        SetPlayerInvincibility(120);
	TMain;
    }

    @Finalize {
    }

    @MainLoop {
	CollectItems;
        yield;
    }

   task TMain {
//	PlaySE(SE[0]);
	Border;
	Nebura;
        loop(90){yield;}
        End;
    }

task Border
{
let r1=-25;
let r2=25;
let angle=0;
let Alpha=100;

	loop(15)
	{
		BorderEffect(r1,r2,angle,Alpha);
		if(r1<90*PowerRate)
		{
			r1+=3*5*PowerRate;
			r2+=3*5*PowerRate;
		}
		angle+=6;
		yield;
		yield;
		yield;
	}
	loop(15)
	{
		BorderEffect(r1,r2,angle,Alpha);
		r1-=1.5*3*PowerRate;
		r2-=1.5*3*PowerRate;
		angle+=6;
		Alpha-=100/60;
		yield;
		yield;
		yield;
	}
}

task Nebura
{
		let r=0;
		let VertexNum=16;
		let UVX=rand(0,512);
		let UVY=rand(0,512);
  		let obj = Obj_Create(OBJ_SPELL);
		Obj_SetPosition(obj,BombX,BombY);
		ObjEffect_SetTexture(obj, imgNebura);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, VertexNum);

		ObjEffect_SetVertexXY(obj, 0, 0, 0);

		ObjEffect_SetVertexUV(obj, 0,0,0);
		ObjEffect_SetLayer(obj,2);

		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexColor(obj,i,100,196,196,255);
		}

		loop(30)
		{
			if(r<115*PowerRate)
			{
				r+=5*PowerRate;
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,1.0*PowerRate,true);
			UVX+=3;
			UVY+=3;
			yield;
		}
		loop(15)
		{
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,1.0*PowerRate,true);
			UVX+=3;
			UVY+=3;
			yield;
		}
		let Alpha=100;
		loop(45)
		{
			if(r>0)
			{
				r-=1.5*PowerRate;
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,196,196,255);
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,1.0*PowerRate,true);
			UVX+=3;
			UVY+=3;
			Alpha-=45/50;
			yield;
		}
		Obj_Delete(obj);
}

task BorderEffect(r1,r2,angle,Alpha)
{
		let randvertex=rand_int(0,5);
		let VertexNum=16;
		let Radius=[r1,r2];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgBorderLine);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{
			ObjEffect_SetVertexXY(obj, i-randvertex, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{	
			ObjEffect_SetVertexUV(obj, i-randvertex,  256/(VertexNum)*i,  16*(i%2));
		}


		ObjEffect_SetLayer(obj,3);

		let Scale=1;
		let Zangle=0;
		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,BombX,BombY);
	//	let Alpha=100;
		//let angle=0;

		let StandardX=GetCenterX;
		let StandardY=GetCenterY+32;

		loop(5)
		{
		if(r1<60)
		{
			r1+=2.5;
			r2+=2.5;
			Radius=[r1,r2];
		}
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i+angle), Radius[i%2]*sin(360/(VertexNum-2)*i+angle));
		}
		ascent(let i in 0..VertexNum)
		{			
			ObjEffect_SetVertexColor(obj, i,Alpha,255,0,255*(i%3));
		}
		ObjEffect_SetScale(obj,Scale,Scale);
		angle+=2;
		Alpha-=20;
		Scale+=0.01;
		yield;
		}
		Obj_Delete(obj);
}


}

script_spell NeburaReverie //魔符「ネビュラレヴァリエ」スクリプト
{
	let imgNebura = GetCurrentScriptDirectory~"..\img\nebura.png";
let imgMarisaShot = GetCurrentScriptDirectory~"..\img\Marisa_shots.png";
	let imgBorderLine = GetCurrentScriptDirectory~"..\img\SampleEC01a.png";
let SE=["se\seBomb_ReimuB.wav"];
let BombX;
let BombY;
let BMove=120;
    @Initialize {
	BombX=GetCenterX;
	BombY=GetCenterY;

        SetPlayerInvincibility(210);
	TMain;
    }

    @Finalize {
    }

    @MainLoop {
	CollectItems;
        yield;
    }

   task TMain {
//	PlaySE(SE[0]);
	StartStar;
	loop(30){yield;}
	Border;
	Star;
	Nebura;
        loop(150){yield;}
        End;
    }

task StartStar
{
	let X=GetPlayerX;
	let Y=GetPlayerY;
	let i=0;
	let r=240;
	let angle=rand(0,360);
	loop(30)
	{
		ascent(let k in 0..7)
		{
			StartStarEffect(X-((X-BombX)/30)*i,Y-((Y-BombY)/30)*i,r,angle+360/7*k,9+k);
		}
	yield;
	i+=1;
	r-=240/30;
	angle+=4.5;
	}
}
task StartStarEffect(X,Y,Radius,Angle,graphic)
{
		let R;let G;let B;
		if(graphic==9){R=255;G=0;B=0;}
		if(graphic==10){R=255;G=100;B=0;}
		if(graphic==11){R=255;G=255;B=0;}
		if(graphic==12){R=0;G=255;B=0;}
		if(graphic==13){R=0;G=255;B=255;}
		if(graphic==14){R=0;G=0;B=255;}
		if(graphic==15){R=160;G=32;B=240;}

		let Scale=0.6;

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,X+Radius*cos(Angle),Y+Radius*sin(Angle));
		ObjEffect_SetTexture(obj, imgMarisaShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,  64, -64);
		ObjEffect_SetVertexXY(obj, 2,  64, 64);
		ObjEffect_SetVertexXY(obj, 3, -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  384);
		ObjEffect_SetVertexUV(obj, 1,  128, 384);
		ObjEffect_SetVertexUV(obj, 2, 128,  512);
		ObjEffect_SetVertexUV(obj, 3, 0, 512);

		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,200,R,G,B);
		}
		if(GetCommonDataDefault("LightMode_BombEffect",0)==0)
		{
		loop(30)
		{
			ObjEffect_SetScale(obj,Scale,Scale);
			Scale-=0.02;
			yield;
		}
		}
		else
		{
		loop(10)
		{
			ObjEffect_SetScale(obj,Scale,Scale);
			Scale-=0.06;
			yield;
		}
		}
		Obj_Delete(obj);
}

task Nebura
{
		let r=0;
		let VertexNum=16;
		let UVX=rand(0,256);
		let UVY=rand(0,256);
  		let obj = Obj_Create(OBJ_SPELL);
		Obj_SetPosition(obj,BombX,BombY);
		ObjEffect_SetTexture(obj, imgNebura);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, VertexNum);
		ObjEffect_SetScale(obj,2,2);
		ObjEffect_SetLayer(obj,2);

		ascent(let i in 0..VertexNum)
		{
		ObjEffect_SetVertexColor(obj,i,100,196,196,255);
		}

		loop(90)
		{
		if(r<120)
		{
			r+=4;
		}
			ascent(let i in 0..VertexNum)
			{
			ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
			ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r*2,3,true);
			UVX+=3;
			UVY+=3;
			yield;
		}

		loop(30)
		{
		if(r>0)
		{
			r-=4;
		}
			ascent(let i in 0..VertexNum)
			{
			ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
			ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r*2,3,true);
			UVX+=3;
			UVY+=3;
			yield;
		}
		Obj_Delete(obj);
}

task Star
{
let t=0;
loop(45)
{
	StarEfect(9+t%7);
	loop(2){yield;};
	t+=1;
}
}

task StarEfect(graphic)
{
		let R;let G;let B;
		if(graphic==9){R=255;G=0;B=0;}
		if(graphic==10){R=255;G=100;B=0;}
		if(graphic==11){R=255;G=255;B=0;}
		if(graphic==12){R=0;G=255;B=0;}
		if(graphic==13){R=0;G=255;B=255;}
		if(graphic==14){R=0;G=0;B=255;}
		if(graphic==15){R=160;G=32;B=240;}

		let Xangle=rand(0,360);
		let Yangle=rand(0,360);
		let Zangle=rand(0,360);

		let XanglePlus=rand(-10,10);
		let YanglePlus=rand(-10,10);
		let ZanglePlus=rand(-10,10);

		let Scale=0.1;

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,BombX,BombY);
		ObjEffect_SetTexture(obj, imgMarisaShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,  64, -64);
		ObjEffect_SetVertexXY(obj, 2,  64, 64);
		ObjEffect_SetVertexXY(obj, 3, -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  384);
		ObjEffect_SetVertexUV(obj, 1,  128, 384);
		ObjEffect_SetVertexUV(obj, 2, 128,  512);
		ObjEffect_SetVertexUV(obj, 3, 0, 512);

		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,200,R,G,B);
		}

		let speed=rand(6,10);
		let angle=rand(0,360);
		Obj_SetSpeed(obj,speed);
		Obj_SetAngle(obj,angle);

		let ShadowCount=0;
		while(!Obj_BeDeleted(obj))
		{
			if(ShadowCount%3==0 && GetCommonDataDefault("LightMode_BombEffect",0)==0)
			{
			StarShadowEfect(Obj_GetX(obj),Obj_GetY(obj),speed,angle,Scale,Xangle,Yangle,Zangle,R,G,B);
			}
			ObjEffect_SetScale(obj,Scale,Scale);
			ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
			Xangle+=XanglePlus;
			Yangle+=YanglePlus;
			Zangle+=ZanglePlus;
			Scale+=0.05;
			ShadowCount++;
			yield;
		}
}


task StarShadowEfect(X,Y,speed,angle,Scale,Xangle,Yangle,Zangle,R,G,B)
{

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,X,Y);
		ObjEffect_SetTexture(obj, imgMarisaShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,  64, -64);
		ObjEffect_SetVertexXY(obj, 2,  64, 64);
		ObjEffect_SetVertexXY(obj, 3, -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  384);
		ObjEffect_SetVertexUV(obj, 1,  128, 384);
		ObjEffect_SetVertexUV(obj, 2, 128,  512);
		ObjEffect_SetVertexUV(obj, 3, 0, 512);

		let Alpha=100;
		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}

		ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);

		loop(3)
		{
			ObjEffect_SetScale(obj,Scale,Scale);
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}
			Scale+=0.05;
			Alpha-=20;
			yield;
		}
		Obj_Delete(obj);
}

task Border
{
let r1=-25;
let r2=25;
let angle=0;
let Alpha=100;
	loop(30)
	{
		BorderEffect(r1,r2,angle,Alpha);
		if(r1<200)
		{
			r1+=24;
			r2+=24;
		}
		angle+=6;
		loop(3){yield;};
	}
	loop(10)
	{
		BorderEffect(r1,r2,angle,Alpha);
		r1-=24;
		r2-=24;
		angle+=6;
		Alpha-=100/60;
		loop(3){yield;};
	}
}

task BorderEffect(r1,r2,angle,Alpha)
{
		let randvertex=rand_int(0,5);
		let VertexNum=16;
		let Radius=[r1,r2];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgBorderLine);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{
			ObjEffect_SetVertexXY(obj, i-randvertex, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{	
			ObjEffect_SetVertexUV(obj, i-randvertex,  256/(VertexNum)*i,  16*(i%2));
		}


		ObjEffect_SetLayer(obj,3);

		let Scale=1;
		let Zangle=0;
		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,BombX,BombY);

		loop(5)
		{
		if(r1<250)
		{
			r1+=10;
			r2+=10;
			Radius=[r1,r2];
		}
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i+angle), Radius[i%2]*sin(360/(VertexNum-2)*i+angle));
		}
		ascent(let i in 0..VertexNum)
		{			
			ObjEffect_SetVertexColor(obj, i,Alpha,255,0,255*(i%3));
		}
		ObjEffect_SetScale(obj,Scale,Scale);
		angle+=2;
		Alpha-=20;
		Scale+=0.01;
		yield;
		}
		Obj_Delete(obj);
}

}


script_spell StardustFixer //魔符「スターダストフィクサー」スクリプト
{
	let imgNebura = GetCurrentScriptDirectory~"..\img\nebura.png";
let imgMarisaShot = GetCurrentScriptDirectory~"..\img\Marisa_shots.png";
	let imgBorderLine = GetCurrentScriptDirectory~"..\img\SampleEC01a.png";
let SE=["se\seBomb_ReimuB.wav"];
let BombX;
let BombY;
let HiSpeed=GetPlayerInfo(PLAYER_SPEED_HIGH);
let LowSpeed=GetPlayerInfo(PLAYER_SPEED_LOW);
    @Initialize {
	BombX=GetPlayerX;
	BombY=GetClipMaxY;
        SetPlayerInvincibility(270);
	SetSpeed(HiSpeed/2,LowSpeed/2);
	TMain;
    }

    @Finalize {
    }

    @MainLoop {
	CollectItems;
        yield;
    }

   task TMain {
//	PlaySE(SE[0]);
	StartStar;
	loop(30){yield;}
	Border;
	Star;
	Nebura;
        loop(210){yield;}
	SetSpeed(HiSpeed,LowSpeed);
        End;
    }

task StartStar
{
	let X=GetPlayerX;
	let Y=GetPlayerY;
	let i=0;
	let r=240;
	let angle=rand(0,360);
	loop(30)
	{
		ascent(let k in 0..7)
		{
			StartStarEffect(X-((X-BombX)/30)*i,Y-((Y-BombY)/30)*i,r,angle+360/7*k,9+k);
		}
	yield;
	i+=1;
	r-=240/30;
	angle+=4.5;
	}
}
task StartStarEffect(X,Y,Radius,Angle,graphic)
{
		let R;let G;let B;
		if(graphic==9){R=255;G=0;B=0;}
		if(graphic==10){R=255;G=100;B=0;}
		if(graphic==11){R=255;G=255;B=0;}
		if(graphic==12){R=0;G=255;B=0;}
		if(graphic==13){R=0;G=255;B=255;}
		if(graphic==14){R=0;G=0;B=255;}
		if(graphic==15){R=160;G=32;B=240;}

		let Scale=0.6;

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,X+Radius*cos(Angle),Y+Radius*sin(Angle));
		ObjEffect_SetTexture(obj, imgMarisaShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,  64, -64);
		ObjEffect_SetVertexXY(obj, 2,  64, 64);
		ObjEffect_SetVertexXY(obj, 3, -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  384);
		ObjEffect_SetVertexUV(obj, 1,  128, 384);
		ObjEffect_SetVertexUV(obj, 2, 128,  512);
		ObjEffect_SetVertexUV(obj, 3, 0, 512);

		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,200,R,G,B);
		}
		if(GetCommonDataDefault("LightMode_BombEffect",0)==0)
		{
		loop(30)
		{
			ObjEffect_SetScale(obj,Scale,Scale);
			Scale-=0.02;
			yield;
		}
		}
		else
		{
		loop(10)
		{
			ObjEffect_SetScale(obj,Scale,Scale);
			Scale-=0.06;
			yield;
		}
		}
		Obj_Delete(obj);
}

task Nebura
{
		let r=0;
		let VertexNum=4;
		let UVX=rand(0,256);
		let UVY=rand(0,256);
  		let obj = Obj_Create(OBJ_SPELL);
		Obj_SetPosition(obj,BombX,BombY);
		ObjEffect_SetTexture(obj, imgNebura);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, VertexNum);
		ObjEffect_SetScale(obj,2,2);
		ObjEffect_SetLayer(obj,2);

		ascent(let i in 0..VertexNum)
		{
		ObjEffect_SetVertexColor(obj,i,100,196,196,255);
		}

		loop(120)
		{
		if(r<32)
		{
			r+=0.5;
		}
			ObjEffect_SetVertexXY(obj, 0,-r,-224);
			ObjEffect_SetVertexXY(obj, 1,r,-224);
			ObjEffect_SetVertexXY(obj, 2,r,224);
			ObjEffect_SetVertexXY(obj, 3,-r,224);


			ObjEffect_SetVertexUV(obj, 0,UVX-r,UVY-224);
			ObjEffect_SetVertexUV(obj, 1,UVX+r,UVY-224);
			ObjEffect_SetVertexUV(obj, 2,UVX+r,UVY+224);
			ObjEffect_SetVertexUV(obj, 3,UVX-r,UVY+224);

			ObjSpell_SetIntersecrionLine(obj,BombX,GetClipMinY,BombX,GetClipMaxY,r,2,true);

			UVX+=3;
			UVY+=3;
			yield;
		}

		loop(60)
		{
		if(r>0)
		{
			r-=0.5;
		}
			ObjEffect_SetVertexXY(obj, 0,-r,-224);
			ObjEffect_SetVertexXY(obj, 1,r,-224);
			ObjEffect_SetVertexXY(obj, 2,r,224);
			ObjEffect_SetVertexXY(obj, 3,-r,224);

			ObjEffect_SetVertexUV(obj, 0,UVX-r,UVY-224);
			ObjEffect_SetVertexUV(obj, 1,UVX+r,UVY-224);
			ObjEffect_SetVertexUV(obj, 2,UVX+r,UVY+224);
			ObjEffect_SetVertexUV(obj, 3,UVX-r,UVY+224);

			ObjSpell_SetIntersecrionLine(obj,BombX,GetClipMinY,BombX,GetClipMaxY,r,2,true);

			UVX+=3;
			UVY+=3;
			yield;
		}
		Obj_Delete(obj);
}

task Star
{
let t=0;
loop(60)
{
	StarEfect(9+t%7);
	loop(2){yield;};
	t+=1;
}
}

task StarEfect(graphic)
{
		let R;let G;let B;
		if(graphic==9){R=255;G=0;B=0;}
		if(graphic==10){R=255;G=100;B=0;}
		if(graphic==11){R=255;G=255;B=0;}
		if(graphic==12){R=0;G=255;B=0;}
		if(graphic==13){R=0;G=255;B=255;}
		if(graphic==14){R=0;G=0;B=255;}
		if(graphic==15){R=160;G=32;B=240;}

		let Xangle=rand(0,360);
		let Yangle=rand(0,360);
		let Zangle=rand(0,360);

		let Xangle=0;
		let Yangle=0;
		let Zangle=0;

		let XanglePlus=rand(-10,10);
		let YanglePlus=rand(-10,10);
		let ZanglePlus=rand(10,20)*(rand_int(0,1)*2-1);

		let Scale=0.1;

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,BombX,GetClipMaxY);
		ObjEffect_SetTexture(obj, imgMarisaShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,  64, -64);
		ObjEffect_SetVertexXY(obj, 2,  64, 64);
		ObjEffect_SetVertexXY(obj, 3, -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  384);
		ObjEffect_SetVertexUV(obj, 1,  128, 384);
		ObjEffect_SetVertexUV(obj, 2, 128,  512);
		ObjEffect_SetVertexUV(obj, 3, 0, 512);

		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,200,R,G,B);
		}

		let speed=rand(7,10);
		let speed=10;
		let angle=rand(0,360);
	//	Obj_SetSpeed(obj,speed);
	//	Obj_SetAngle(obj,angle);
		ObjEffect_SetScale(obj,Scale,Scale);

		let Width=56;
		let WidthAngle=rand(0,360);
	//	let WidthAngle=rand_int(0,3)*90;
		let WidthAnglePlus=rand(5,10)*(rand_int(0,1)*2-1);
		let WidthAnglePlus=10;

		let ShadowCount=0;
		loop(48)
		{
			Obj_SetPosition(obj,BombX+Width*cos(WidthAngle),BombY-speed*ShadowCount);
			WidthAngle+=WidthAnglePlus;
			if(GetCommonDataDefault("LightMode",0)==0)
			{
			StarShadowEfect(Obj_GetX(obj),Obj_GetY(obj),speed,angle,Scale,Xangle,Yangle,Zangle,R,G,B);
			}
			ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
			Zangle+=ZanglePlus;
			ShadowCount++;
			yield;
		}
		Obj_Delete(obj);
}


task StarShadowEfect(X,Y,speed,angle,Scale,Xangle,Yangle,Zangle,R,G,B)
{

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,X,Y);
		ObjEffect_SetTexture(obj, imgMarisaShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,  64, -64);
		ObjEffect_SetVertexXY(obj, 2,  64, 64);
		ObjEffect_SetVertexXY(obj, 3, -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  384);
		ObjEffect_SetVertexUV(obj, 1,  128, 384);
		ObjEffect_SetVertexUV(obj, 2, 128,  512);
		ObjEffect_SetVertexUV(obj, 3, 0, 512);

		let Alpha=100;
		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}

		ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);

		loop(4)
		{
			ObjEffect_SetScale(obj,Scale,Scale);
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}
			Scale+=0.05;
			Alpha-=20;
			yield;
		}
		Obj_Delete(obj);
}

task Border
{
let x=0;
let y=0;
let r1=-25;
let r2=25;
let angle=0;
let Alpha=100;
let EffectCount=0;
	loop(120)
	{
		if(EffectCount%3==0)
		{
		BorderEffect(x,y,angle,Alpha);
		BorderEffect(-x,y,angle,Alpha);
		}
		if(x<64)
		{
			x+=1.0;
		}
		angle+=2;
		EffectCount+=1;
		loop(1){yield;};
		
	}
	loop(60)
	{
		if(EffectCount%3==0)
		{
		BorderEffect(x,y,angle,Alpha);
		BorderEffect(-x,y,angle,Alpha);
		}
		x-=1.0;
		angle+=2;
		Alpha-=100/180;
		EffectCount+=1;
		loop(1){yield;};
	}
}

task BorderEffect(x,y,angle,Alpha)
{
		let randvertex=rand_int(0,5);
		let VertexNum=4;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgBorderLine);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);


			ObjEffect_SetVertexXY(obj, 0, -128*2, -8*3);
			ObjEffect_SetVertexXY(obj, 1, 128*2, -8*3);
			ObjEffect_SetVertexXY(obj, 2, 128*2, 8*3);
			ObjEffect_SetVertexXY(obj, 3, -128*2, 8*3);

			ObjEffect_SetVertexUV(obj, 0,  0,  0);
			ObjEffect_SetVertexUV(obj, 1,  256, 0);
			ObjEffect_SetVertexUV(obj, 2,  256, 16);
			ObjEffect_SetVertexUV(obj, 3,  0,  16);


		ObjEffect_SetLayer(obj,3);

		let Scale=1;
		let Zangle=0;
		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,BombX+x,GetCenterY+y);
		
		let Dir=-1;
		if(x>0){Dir=1;}
		ObjEffect_SetAngle(obj,0,0,180+Dir*90);

		loop(5)
		{
			ObjEffect_SetVertexUV(obj, 0,  0+angle,  0);
			ObjEffect_SetVertexUV(obj, 1,  256+angle, 0);
			ObjEffect_SetVertexUV(obj, 2,  256+angle, 16);
			ObjEffect_SetVertexUV(obj, 3,  0+angle,  16);
		ascent(let i in 0..VertexNum)
		{			
			ObjEffect_SetVertexColor(obj, i,Alpha,255,0,255*(i%3));
		}
		ObjEffect_SetScale(obj,Scale,Scale);
		angle+=2*Dir;
		Alpha-=20;
		Scale+=0.01;
		yield;
		}
		Obj_Delete(obj);

}

}


script_spell ElectricMS //恋符「エレクトリックMS」スクリプト
{
	let ColorRed=255;
	let ColorGreen=255;
	let ColorBlue=255;
	let imgNebura = GetCurrentScriptDirectory~"..\img\nebura.png";
let imgMarisaShot = GetCurrentScriptDirectory~"..\img\Marisa_shots.png";
	let imgBorderLine = GetCurrentScriptDirectory~"..\img\SampleEC01a.png";

let SE=["se\seBomb_ReimuB.wav"];
let BombX;
let BombY;
let HiSpeed=GetPlayerInfo(PLAYER_SPEED_HIGH);
let LowSpeed=GetPlayerInfo(PLAYER_SPEED_LOW);
    @Initialize {
	BombX=GetPlayerX;
	BombY=GetPlayerY;
	SetCommonData("OnMS",true);
	ForbidShot(true);
        SetPlayerInvincibility(330);
	SetSpeed(HiSpeed/5,LowSpeed/5);
	TMain;
    }

    @Finalize {
    }

    @MainLoop {
	BombX=GetPlayerX;
	BombY=GetPlayerY;
	CollectItems;
        yield;
    }

   task TMain {
//	PlaySE(SE[0]);
	MastarSpark;
	Thunder;
	wait(30);
	Star;
	Border;
        wait(270);
	SetCommonData("OnMS",false);
	ForbidShot(false);
	SetSpeed(HiSpeed,LowSpeed);
        End;
    }


task Star
{
let t=0;
loop(84)
{
	StarEfect(9+t%7);
	loop(2){yield;};
	t+=1;
}
}

task StarEfect(graphic)
{
		let R;let G;let B;
		if(graphic==9){R=255;G=0;B=0;}
		if(graphic==10){R=255;G=100;B=0;}
		if(graphic==11){R=255;G=255;B=0;}
		if(graphic==12){R=0;G=255;B=0;}
		if(graphic==13){R=0;G=255;B=255;}
		if(graphic==14){R=0;G=0;B=255;}
		if(graphic==15){R=160;G=32;B=240;}

		let Xangle=rand(0,360);
		let Yangle=rand(0,360);
		let Zangle=rand(0,360);

		let Xangle=0;
		let Yangle=0;
		let Zangle=0;

		let XanglePlus=rand(-10,10);
		let YanglePlus=rand(-10,10);
		let ZanglePlus=rand(10,20)*(rand_int(0,1)*2-1);

		let Scale=0.15;

  		let obj = Obj_Create(OBJ_SPELL);
		Obj_SetPosition(obj,BombX,GetClipMaxY);
		ObjEffect_SetTexture(obj, imgMarisaShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,  64, -64);
		ObjEffect_SetVertexXY(obj, 2,  64, 64);
		ObjEffect_SetVertexXY(obj, 3, -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  384);
		ObjEffect_SetVertexUV(obj, 1,  128, 384);
		ObjEffect_SetVertexUV(obj, 2, 128,  512);
		ObjEffect_SetVertexUV(obj, 3, 0, 512);

		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,200,R,G,B);
		}

		let speed=rand(7,10);
		let speed=10;
		let angle=rand(0,360);
	//	Obj_SetSpeed(obj,speed);
	//	Obj_SetAngle(obj,angle);
		ObjEffect_SetScale(obj,Scale,Scale);

		let Width=56*0+12;
		let WidthAngle=rand(0,360);
	//	let WidthAngle=rand_int(0,3)*90;
		let WidthAnglePlus=rand(5,10)*(rand_int(0,1)*2-1);
		let WidthAnglePlus=10;

		let ShadowCount=0;
		loop(48)
		{
			Obj_SetPosition(obj,BombX+Width*cos(WidthAngle),BombY-speed*ShadowCount);
			WidthAngle+=WidthAnglePlus;
			if(GetCommonDataDefault("LightMode",0)==0)
			{
			StarShadowEfect(Obj_GetX(obj),Obj_GetY(obj),speed,angle,Scale,Xangle,Yangle,Zangle,R,G,B);
			}
			ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
			Zangle+=ZanglePlus;
			ShadowCount++;
			Width+=3;
			ObjSpell_SetIntersecrionCircle(obj,Obj_GetX(obj),Obj_GetY(obj),8,0.3,true);
			yield;
		}
		Obj_Delete(obj);
}


task StarShadowEfect(X,Y,speed,angle,Scale,Xangle,Yangle,Zangle,R,G,B)
{

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,X,Y);
		ObjEffect_SetTexture(obj, imgMarisaShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,  64, -64);
		ObjEffect_SetVertexXY(obj, 2,  64, 64);
		ObjEffect_SetVertexXY(obj, 3, -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  384);
		ObjEffect_SetVertexUV(obj, 1,  128, 384);
		ObjEffect_SetVertexUV(obj, 2, 128,  512);
		ObjEffect_SetVertexUV(obj, 3, 0, 512);

		let Alpha=100;
		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}

		ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);

		loop(4)
		{
			ObjEffect_SetScale(obj,Scale,Scale);
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}
			Scale+=0.05;
			Alpha-=20;
			yield;
		}
		Obj_Delete(obj);
}

task Thunder
{
	ascent(i in 0..4)
	{
	ThunderEffect(90*i);
	}
}

task ThunderEffect(angle)
{
	let distance=500;
	let objE = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(objE, GetCurrentScriptDirectory~"..\img\Thunder.png");
	ObjEffect_SetPrimitiveType(objE, PRIMITIVE_TRIANGLEFAN);
	Obj_SetPosition(objE,GetPlayerX,GetPlayerY);
	ObjEffect_CreateVertex(objE, 4);
	ObjEffect_SetRenderState(objE,ADD);
	ObjEffect_SetLayer(objE,2);
	
	ObjEffect_SetVertexXY(objE, 0, -24, -0);
	ObjEffect_SetVertexXY(objE, 1, 24, -0);
	ObjEffect_SetVertexXY(objE, 2, 24, distance);
	ObjEffect_SetVertexXY(objE, 3, -24, distance);

	let randrect=rand(0,256);
	ObjEffect_SetVertexUV(objE, 0, 0, 0);
	ObjEffect_SetVertexUV(objE, 1, 48, 0);
	ObjEffect_SetVertexUV(objE, 2, 48, randrect);
	ObjEffect_SetVertexUV(objE, 3, 0, randrect);

	ObjEffect_SetScale(objE,1,1);
	ObjEffect_SetAngle(objE,0,0,angle+90);
	let Grad=0;

	let Alpha=120*0;
	let R=255;
	let G=50;
	let B=255;
	ascent(i in 0..4)
	{
		ObjEffect_SetVertexColor(objE, i,Alpha, R, G, B);
	}

	loop(210)
	{
		if(Alpha<120)
		{
			Alpha+=4;
		}
		if(Grad<15 && Alpha==120)
		{
			Grad+=0.5;
		}
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(objE, i,Alpha, R, G, B);
		}
		Obj_SetPosition(objE,GetPlayerX,GetPlayerY);
		ObjEffect_SetAngle(objE,0,0,180+Grad*cos(angle));
		ObjEffect_SetVertexUV(objE, 0, 0, 0);
		ObjEffect_SetVertexUV(objE, 1, 48, 0);
		ObjEffect_SetVertexUV(objE, 2, 48, randrect);
		ObjEffect_SetVertexUV(objE, 3, 0, randrect);
		randrect=rand(0,256);
		angle+=6;
		yield;
	}
	loop(60)
	{
		Grad-=0.25;
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(objE, i,Alpha, R, G, B);
		}
		Obj_SetPosition(objE,GetPlayerX,GetPlayerY);
		ObjEffect_SetAngle(objE,0,0,180+Grad*cos(angle));
		ObjEffect_SetVertexUV(objE, 0, 0, 0);
		ObjEffect_SetVertexUV(objE, 1, 48, 0);
		ObjEffect_SetVertexUV(objE, 2, 48, randrect);
		ObjEffect_SetVertexUV(objE, 3, 0, randrect);
		randrect=rand(0,256);
		angle+=6;
		yield;
	}
	Obj_Delete(objE);
}

let G_Counter=60;

task MastarSpark
{
	let angle=270;
	let wide=0;
	let leng=300;
	let width=0;
	let shotangle=270;
	let speedplus=0.025;

	loop(210)
	{
		shotangle=angle+rand(-wide,wide);
		SparkShot(angle+rand(-wide,wide),leng,width,speedplus);
		if(width<240)
		{
			width+=6;
		}
		if(wide<15)
		{
			wide+=1;
		}
		if(speedplus>0.0125)
		{
			speedplus-=0.0005;
		}
		wait(1);
	}

	loop(60)
	{
		G_Counter-=1;
		shotangle=angle+rand(-wide,wide);
		SparkShot(angle+rand(-wide,wide),leng,width,speedplus);
		if(width>0)
		{
			width-=6;
		}
		if(wide>0)
		{
			wide-=0.5;
		}
		wait(1);
	}
}

task SparkShot(angle,Maxleng,Maxwidth,aaspped)
{
	let x = 0;
	let y = 0;
	let leng=0;
	let width=0;
	let speed=0;
	let Aspeed=0;
	let Damage=0.35;
	
	let obj = Obj_Create(OBJ_LASER);
	ObjShot_SetGraphic(obj,5);
	ObjShot_SetDelay(obj,5);
	ObjShot_SetDamage(obj,Damage);

	Obj_SetPosition(obj,GetPlayerX+x,GetPlayerY+y);
	Obj_SetAngle(obj,angle);
	ObjLaser_SetLength(obj,leng);
	ObjLaser_SetWidth(obj,width);
	ObjLaser_SetSource(obj,false);

	while(!Obj_BeDeleted(obj))
	{
		if(leng<Maxleng)
		{
			leng+=6;
		}
		if(width<Maxwidth)
		{
			width+=3;
		}
		ObjShot_SetDamage(obj,Damage);

		if(Damage<0.55){Damage+=0.005;}
		speed += Aspeed;

		Obj_SetPosition(obj,GetPlayerX+x,GetPlayerY+y);
		ObjLaser_SetLength(obj,leng*G_Counter/60);
		ObjLaser_SetWidth(obj,width*G_Counter/60);
		x+=cos(angle)*speed;
		y+=sin(angle)*speed;
		if(angle>270){angle-=0.5;}
		else{angle+=0.5;}
		Aspeed+=aaspped;
		if(G_Counter==0){break;}
		yield;
	}
	Obj_Delete(obj);
    }

task Border
{
	loop(42)
	{
		BorderEffect;
		wait(5);
	}
}

task BorderEffect
{
		let r1=-25+210;
		let r2=25+210;
		let randvertex=rand_int(0,5);
		let VertexNum=8;
		let Radius=[r1,r2];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgBorderLine);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{
			ObjEffect_SetVertexXY(obj, i-randvertex, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{	
			ObjEffect_SetVertexUV(obj, i-randvertex,  256/(VertexNum)*i,  16*(i%2));
		}


		ObjEffect_SetLayer(obj,3);

		let Scale=0;
		let Zangle=0;
		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		let Alpha=150;
		let angle=0;

		let StandardX=GetCenterX;
		let StandardY=GetCenterY+32;

		let Xangle=rand(0,360);
		let Yangle=rand(0,360);
		let Zangle=rand(0,360);

		ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);

		if(GetCommonDataDefault("LightMode_BombEffect",0)==1){Obj_Delete(obj);return;}
		loop(30)
		{
		ascent(let i in 0..VertexNum)
		{			
			ObjEffect_SetVertexColor(obj, i,Alpha,255,0,255*(i%3));
		}
		ObjEffect_SetScale(obj,Scale,Scale);
		Alpha-=5;
		Scale+=0.05;
		yield;
		}
		Obj_Delete(obj);
}

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

script_spell StardustPulsar //星符「スターダストパルサー」スクリプト
{

let NsScore = "SAVE_SCORE";	//スコア
let NsHi = "HI_SCORE";	//ハイスコア(NsScore)


	function NumToStringNoComplete(let num)
	{
		if(num==0)
		{
			num=0.1;
		}
		let leng = trunc(log10(num))+1;//整数部分の桁数を求める
		let string = ToString(num);//数字を文字列に変える
		return string[0..leng];//文字列をスライシングして返す
	}

	let ColorRed=255;
	let ColorGreen=255;
	let ColorBlue=255;
	let imgNebura = GetCurrentScriptDirectory~"..\img\nebura.png";
let imgMarisaShot = GetCurrentScriptDirectory~"..\img\Marisa_shots.png";
	let imgBorderLine = GetCurrentScriptDirectory~"..\img\SampleEC01a.png";
	let imgWhite = GetCurrentScriptDirectory~"..\img\White.png";

let SE=["se\seBomb_ReimuB.wav"];
let HiSpeed=GetPlayerInfo(PLAYER_SPEED_HIGH);
let LowSpeed=GetPlayerInfo(PLAYER_SPEED_LOW);
let OpX=[GetPlayerX-30,GetPlayerX+30,GetPlayerX-60,GetPlayerX+60,GetPlayerX-90,GetPlayerX+90];
let OpY=[GetPlayerY,GetPlayerY,GetPlayerY+5,GetPlayerY+5,GetPlayerY+10,GetPlayerY+10];
let TargetX=GetCommonDataDefault("TargetX",[0,0,0,0,0,0]);
let TargetY=GetCommonDataDefault("TargetY",[0,0,0,0,0,0]);
let InvincibleFlag=[1,1,1,1,1,1];
let Invincible=6;

let BombTimeCount=0;

let BombX;
let BombY;

    @Initialize {
	SetCommonData("OnDtypeBomb",true);
        SetPlayerInvincibility(210);
	TMain;
    }

    @Finalize {
SetCommonData("OnDtypeBomb",false);
if(BombTimeCount>=600)
{
	SetCommonDataEx(NsScore,"Achievement_"~NumToStringNoComplete(81),1);
}
    }

    @MainLoop {
	BombTimeCount+=1;
	CollectItems;
        yield;
    }

   task TMain {
//	PlaySE(SE[0]);
	//MastarSpark;
	Dark;
	Border(0);
	Border(1);
	Border(2);
	Border(3);
	//Border(4);
	//Border(5);
	loop(150)
	{
		//SetPlayerInvincibility(61);
		Invincible=0;
		ascent(i in 0..4)
		{
			Invincible+=InvincibleFlag[i];
		}
		//if(Invincible==0){break;}
		yield;
	}
        wait(30);
        End;
    }
task Dark
{
	wait(90);
	BombX=GetPlayerX;
	BombY=GetPlayerY;
	DarkBorder;
	DarkNebura;
}

task Border(num)
{
	let ShotAngleAdjust=atan2(TargetY[num]-GetPlayerY,TargetX[num]-GetPlayerX);
	let StartX=OpX[num];
	let EndX=TargetX[num];
	let StartY=OpY[num];
	let EndY=TargetY[num];
	let angle=atan2(TargetY[num]+50*sin(ShotAngleAdjust)-OpY[num],TargetX[num]+50*cos(ShotAngleAdjust)-OpX[num]);

	let ShotAngle=[267.5,272.5,265,275,260,280];
	if(TargetX[num]==-1){angle=ShotAngle[num];}

	let speed=15;

	let obj = Obj_Create(OBJ_EFFECT);
	Obj_SetPosition(obj,StartX,StartY);
	Obj_SetSpeed(obj,speed);
	Obj_SetAngle(obj,angle);
	ObjShot_SetDamage(obj,0);
	ObjShot_SetPenetration(obj,1);
	//ObjShot_SetGraphic(obj,Type+1);
	Obj_SetAutoDelete(obj,false);
	Obj_SetAlpha(obj,100);
	let count=0;
	if(GetCommonDataDefault("BombOffset",false))
	{
	EndX=(StartX+EndX)/2;
	EndY=(StartY+EndY)/2;
	while(!Obj_BeDeleted(obj))
	{
		if(TargetX[num]==-1 && count>=10){break;}
		if(count%3==0)
		{
		BorderEffect(Obj_GetX(obj),Obj_GetY(obj));
		}
		if(((Obj_GetX(obj)-EndX)^2+(Obj_GetY(obj)-EndY)^2)^0.5<=24)
		{
			break;
		}
		if(Obj_GetY(obj)<GetClipMinY)
		{
			break;
		}
		if(Obj_GetY(obj)>GetClipMaxY)
		{
			break;
		}
		count+=1;
		yield;
	}
	}
	else
	{
	while(!Obj_BeDeleted(obj))
	{
		if(TargetX[num]==-1 && count>=20){break;}
		if(count%3==0)
		{
		BorderEffect(Obj_GetX(obj),Obj_GetY(obj));
		}
		if(((Obj_GetX(obj)-EndX)^2+(Obj_GetY(obj)-EndY)^2)^0.5<=24)
		{
			break;
		}
		if(Obj_GetY(obj)<GetClipMinY)
		{
			break;
		}
		if(Obj_GetY(obj)>GetClipMaxY)
		{
			break;
		}
		if(count>7)
		{
		if(Obj_GetX(obj)<GetClipMinX)
		{
			Obj_SetX(obj, GetClipMinX*2-Obj_GetX(obj));
			Obj_SetAngle(obj,180-Obj_GetAngle(obj));
        	}
		if(Obj_GetX(obj)>GetClipMaxX)
		{
			Obj_SetX(obj, GetClipMaxX*2-Obj_GetX(obj));
			Obj_SetAngle(obj,180-Obj_GetAngle(obj));
        	}
		if(GetCommonDataDefault("SectionShift",false)==true)
		{
			break;
		}
		}
		count+=1;
		yield;
	}
	}
	Border2(Obj_GetX(obj),Obj_GetY(obj));
	Nebura(Obj_GetX(obj),Obj_GetY(obj));
	Obj_Delete(obj);
	wait(120);
	InvincibleFlag[num]=0;

}

task BorderEffect(x,y)
{
		let r1=-25;
		let r2=25;
		let randvertex=rand_int(0,5);
		let VertexNum=16;
		let Radius=[r1,r2];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgBorderLine);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{
			ObjEffect_SetVertexXY(obj, i-randvertex, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{	
			ObjEffect_SetVertexUV(obj, i-randvertex,  256/(VertexNum)*i,  16*(i%2));
		}


		ObjEffect_SetLayer(obj,3);

		let Scale=1;
		let Zangle=0;
		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,x,y);
		let Alpha=200;
		let angle=0;

		let StandardX=GetCenterX;
		let StandardY=GetCenterY+32;

		let Xangle=rand(0,360);
		let Yangle=rand(0,360);
		let Zangle=rand(0,360);

		ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);


		loop(10)
		{
			r1+=5;
			r2+=5;
			Radius=[r1,r2];
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i+angle), Radius[i%2]*sin(360/(VertexNum-2)*i+angle));
		}
		ascent(let i in 0..VertexNum)
		{			
			ObjEffect_SetVertexColor(obj, i,Alpha,255,0,255*(i%3));
		}
		ObjEffect_SetScale(obj,Scale,Scale);
		angle+=2;
		Alpha-=10;
		Scale+=0.01;
		yield;
		}
		Obj_Delete(obj);
}

task Border2(BombX,BombY)
{
let r1=-25;
let r2=25;
let angle=0;
let Alpha=100;
	loop(15)
	{
		BorderEffect2(BombX,BombY,r1,r2,angle,Alpha);
		if(r1<45)
		{
			r1+=3*4;
			r2+=3*4;
		}
		angle+=8;
		wait(4);
	}
	loop(15)
	{
		BorderEffect2(BombX,BombY,r1,r2,angle,Alpha);
		r1-=0.75*4;
		r2-=0.75*4;
		angle+=8;
		Alpha-=100/60;
		wait(4);
	}
}

task Nebura(BombX,BombY)
{
		let r=0;
		let VertexNum=16;
		let UVX=rand(0,512);
		let UVY=rand(0,512);
  		let obj = Obj_Create(OBJ_SPELL);
		Obj_SetPosition(obj,BombX,BombY);
		ObjEffect_SetTexture(obj, imgNebura);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, VertexNum);

		ObjEffect_SetVertexXY(obj, 0, 0, 0);

		ObjEffect_SetVertexUV(obj, 0,0,0);
		ObjEffect_SetLayer(obj,2);

		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexColor(obj,i,100,196,196,255);
		}

		loop(45)
		{
			if(r<75)
			{
				r+=3;
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,1.0,true);
			UVX+=3;
			UVY+=3;
			yield;
		}
		loop(15)
		{
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,1.0,true);
			UVX+=3;
			UVY+=3;
			yield;
		}
		let Alpha=100;
		loop(60)
		{
			if(r>0)
			{
				r-=0.75;
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,196,196,255);
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,1.0,true);
			UVX+=3;
			UVY+=3;
			Alpha-=45/50;
			yield;
		}
		Obj_Delete(obj);
}

task BorderEffect2(BombX,BombY,r1,r2,angle,Alpha)
{
		let randvertex=rand_int(0,5);
		let VertexNum=16;
		let Radius=[r1,r2];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgBorderLine);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{
			ObjEffect_SetVertexXY(obj, i-randvertex, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{	
			ObjEffect_SetVertexUV(obj, i-randvertex,  256/(VertexNum)*i,  16*(i%2));
		}


		ObjEffect_SetLayer(obj,3);

		let Scale=1;
		let Zangle=0;
		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,BombX,BombY);
	//	let Alpha=100;
		//let angle=0;

		let StandardX=GetCenterX;
		let StandardY=GetCenterY+32;

		loop(2)
		{
		if(r1<40)
		{
			r1+=2.0;
			r2+=2.0;
			Radius=[r1,r2];
		}
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i+angle), Radius[i%2]*sin(360/(VertexNum-2)*i+angle));
		}
		ascent(let i in 0..VertexNum)
		{			
			ObjEffect_SetVertexColor(obj, i,Alpha,255,0,255*(i%3));
		}
		ObjEffect_SetScale(obj,Scale,Scale);
		angle+=2;
		Alpha-=20;
		Scale+=0.01;
		yield;
		}
		Obj_Delete(obj);
}

task DarkBorder
{
let r1=-25;
let r2=25;
let angle=0;
let Alpha=100;
	loop(60)
	{
		DarkBorderEffect(r1,r2,angle,Alpha);
		r1+=6*3*2;
		r2+=6*3*2;
		angle+=6;
		yield;
		yield;
		yield;
	}
}

task DarkNebura
{
		let r=0;
		let VertexNum=64;
		let UVX=rand(0,512);
		let UVY=rand(0,512);
  		let obj = Obj_Create(OBJ_SPELL);
		Obj_SetPosition(obj,BombX,BombY);
		ObjEffect_SetTexture(obj, imgWhite);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, SUBTRACT);
		ObjEffect_CreateVertex(obj, VertexNum);

		ObjEffect_SetVertexXY(obj, 0, 0, 0);

		ObjEffect_SetVertexUV(obj, 0,0,0);
		ObjEffect_SetLayer(obj,2);

		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexColor(obj,i,200,255,255,255);
		}
		let Alpha=255;
		loop(60)
		{
			r+=5.6*2;
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,0.25,true);
			UVX+=3;
			UVY+=3;
			Alpha-=255/60;
			ascent(let i in 0..VertexNum)
			{			
				ObjEffect_SetVertexColor(obj, i,Alpha,255,255,255);
			}
			yield;
		}
		Obj_Delete(obj);
}

task DarkBorderEffect(r1,r2,angle,Alpha)
{
		let randvertex=rand_int(0,5);
		let VertexNum=16;
		let Radius=[r1,r2];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgBorderLine);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{
			ObjEffect_SetVertexXY(obj, i-randvertex, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{	
			ObjEffect_SetVertexUV(obj, i-randvertex,  256/(VertexNum)*i,  16*(i%2));
		}


		ObjEffect_SetLayer(obj,3);

		let Scale=1;
		let Zangle=0;
		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,BombX,BombY);
	//	let Alpha=100;
		//let angle=0;

		let StandardX=GetCenterX;
		let StandardY=GetCenterY+32;

		loop(5)
		{
		if(r1<60)
		{
			r1+=2.5;
			r2+=2.5;
			Radius=[r1,r2];
		}
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i+angle), Radius[i%2]*sin(360/(VertexNum-2)*i+angle));
		}
		ascent(let i in 0..VertexNum)
		{			
			ObjEffect_SetVertexColor(obj, i,Alpha,255,0,255*(i%3));
		}
		ObjEffect_SetScale(obj,Scale,Scale);
		angle+=2;
		Alpha-=20;
		Scale+=0.01;
		yield;
		}
		Obj_Delete(obj);
}
function wait(w)
{
	loop(w){yield;}
}
}


script_spell DarkNebura //魔符「ダークネビュラ」スクリプト
{
	let imgBorderLine = GetCurrentScriptDirectory~"..\img\SampleEC01a.png";
	let imgNebura = GetCurrentScriptDirectory~"..\img\nebura.png";
	let imgWhite = GetCurrentScriptDirectory~"..\img\White.png";
let SE=["se\seBomb_ReimuB.wav"];
let BombX;
let BombY;
    @Initialize {
	BombX=GetPlayerX;
	BombY=GetPlayerY;
        SetPlayerInvincibility(180);
	TMain;
    }

    @Finalize {
    }

    @MainLoop {
	CollectItems;
        yield;
    }

   task TMain {
//	PlaySE(SE[0]);
	Border;
	Nebura;
        loop(360){yield;}
        End;
    }

task Border
{
let r1=-25;
let r2=25;
let angle=0;
let Alpha=100;
	loop(100)
	{
		BorderEffect(r1,r2,angle,Alpha);
		if(r1<150)
		{
			r1+=3*3;
			r2+=3*3;
		}
		angle+=6;
		yield;
		yield;
		yield;
	}
	loop(20)
	{
		BorderEffect(r1,r2,angle,Alpha);
		r1-=2.75*3;
		r2-=2.75*3;
		angle+=6;
		Alpha-=100/60;
		yield;
		yield;
		yield;
	}
}

task Nebura
{
		let r=0;
		let VertexNum=64;
		let UVX=rand(0,512);
		let UVY=rand(0,512);
  		let obj = Obj_Create(OBJ_SPELL);
		Obj_SetPosition(obj,BombX,BombY);
		ObjEffect_SetTexture(obj, imgWhite);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, SUBTRACT);
		ObjEffect_CreateVertex(obj, VertexNum);

		ObjEffect_SetVertexXY(obj, 0, 0, 0);

		ObjEffect_SetVertexUV(obj, 0,0,0);
		ObjEffect_SetLayer(obj,2);

		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexColor(obj,i,200,255,255,255);
		}

		loop(90)
		{
			if(r<174)
			{
				r+=2.8;
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,0.25,true);
			UVX+=3;
			UVY+=3;
			yield;
		}
		loop(210)
		{
		/*	ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
		*/	ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,0.25,true);
			UVX+=3;
			UVY+=3;
			yield;
		}
		let Alpha=100;
		loop(60)
		{
			if(r>0)
			{
				r-=2.9;
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexColor(obj,i,200,255,255,255);
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,0.25,true);
			UVX+=3;
			UVY+=3;
			Alpha-=45/50;
			yield;
		}
		Obj_Delete(obj);
}

task BorderEffect(r1,r2,angle,Alpha)
{
		let randvertex=rand_int(0,5);
		let VertexNum=16;
		let Radius=[r1,r2];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgBorderLine);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{
			ObjEffect_SetVertexXY(obj, i-randvertex, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{	
			ObjEffect_SetVertexUV(obj, i-randvertex,  256/(VertexNum)*i,  16*(i%2));
		}


		ObjEffect_SetLayer(obj,3);

		let Scale=1;
		let Zangle=0;
		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,BombX,BombY);
	//	let Alpha=100;
		//let angle=0;

		let StandardX=GetCenterX;
		let StandardY=GetCenterY+32;

		loop(5)
		{
		if(r1<60)
		{
			r1+=2.5;
			r2+=2.5;
			Radius=[r1,r2];
		}
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i+angle), Radius[i%2]*sin(360/(VertexNum-2)*i+angle));
		}
		ascent(let i in 0..VertexNum)
		{			
			ObjEffect_SetVertexColor(obj, i,Alpha,255,0,255*(i%3));
		}
		ObjEffect_SetScale(obj,Scale,Scale);
		angle+=2;
		Alpha-=20;
		Scale+=0.01;
		yield;
		}
		Obj_Delete(obj);
}

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

}