	#e[Player]	//@XNvgł邱Ƃ܂
	#ScriptVersion[2]	//XNvgo[W2K{ł
	#Menu[o]	//@Iʂŕ\郁j[ł
	#Text[p[Abv@\ڌ^]//@Iʂŕ\eLXgł
	#Image[.\cut_in.png]//@Iʂŕ\摜t@Cւ̃pXł
	#ReplayName[pkoa]//vCIɕ\镶łB8ȓłB
	
script_player_main
{
let GCP=GetCurrentScriptDirectory;
let bNextShot = false;//񉟂łeA˂邽߂̕ϐ(Â炢)
let shotCount = -1;//eAŔ˂邽߂̕ϐ
let level=0;
let bomb_angle= 0;

let OPtype= 0;
let OPX1=0;let OPY1=0;
let EPX1=0;let EPY1=0;
let OPX2=0;let OPY2=0;
let EPX2=0;let EPY2=0;
let OPX3=0;let OPY3=0;
let EPX3=0;let EPY3=0;
let OPX4=0;let OPY4=0;
let EPX4=0;let EPY4=0;

SetCommonData("GCP",GetCurrentScriptDirectory);
	@Initialize
	{
	SetSpeed(4.5, 2.5);//ړxݒ
	SetGrazeCircle(50);
	LoadGraphic(GCP~ ".\PowerMyShip.png");
	LoadGraphic(GCP~ ".\life.PNG");
	SetTexture(GCP~ ".\PowerMyShip.png");
	LoadPlayerShotData(GCP~"shot_core.txt");
	SetGraphicRect(0, 0, 64, 64);
	SetPlayerLifeImage(GCP~".\life.PNG", 1,  1, 32, 32);
        SetItemCollectLine(150);
	SetRebirthFrame(10);
	SetInitialBombCount(level);
	SetAutoEffect(true);
	Tmove;
	Tpause;
	op_output;
	}
	
	@MainLoop
	{
	SetIntersectionCircle(GetPlayerX, GetPlayerY, 2);//蔻o^
		//t[s镔ł
	if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && shotCount==-1)
		{
		shotCount = 0;
		bNextShot = false;
		}
	if(OnMissed==false)
		{
		if(shotCount%5 == 0)
			{
			PlaySE("sePlayerShot01.wav");
			CreatePlayerShot01(GetPlayerX+10, GetPlayerY, 15, 270, 1.5, 3, 1);
			CreatePlayerShot01(GetPlayerX-10, GetPlayerY, 15, 270, 1.5, 3, 1);
			}
		}
	if(shotCount >= 0){shotCount=shotCount+1};
	if(shotCount == 45){shotCount=-1};
	SetInitialBombCount(level);
	yield;
	}
	@Missed
	{
	
	MainLoop;
		//@Ď"@MainLoop"̑ɌĂ΂܂
		//MainLoopƓł悯
		//@Missed{MainLoop}
		//Ƃ΁A@MainLoopƓɂȂ܂B
		//AĎɓeĂƕςȂ̂
		//OnMissed֐ŌĒ𔻒fĂ
	}
	@SpellCard
	{
	AddPoint(-50);
	let time=180;
	if(IsLastSpell==true){time=180};
	UseSpellCard("drive_shoot",time);
        CutIn(KOUMA, "uT[NVbgv",GetCurrentScriptDirectory~ ".\cut_in.png");
		//XyJ[h𔭓uԂɌĂ΂镔ł
		//GetKeyStateňړԂ𔻒f肵
		//ĂяoXyIт܂
	Tbomb;
	}
	@DrawLoop
	{
	DrawGraphic(GetPlayerX,GetPlayerY);
		//`惋[vBXLbvȂ1t[1s܂
	}
	
	@Finalize
	{
		//XNvgIɈ񂾂Ăяo镔ł
	}

let recty=0;
task Tpause
{
loop
	{
	recty=0;
	if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD){recty=32};
	if(GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_HOLD){recty=64};
	yield;
	}
}

task Tmove
{
loop
	{
	SetGraphicRect(0, 0, 32, 32);
	loop(6){yield};
/*
	SetGraphicRect(32, recty, 64, recty+32);
	loop(6){yield};
	SetGraphicRect(64, recty, 96, recty+32);
	loop(6){yield};
*/
	}
}

task Tbomb
{
SetCommonData("power",GetCommonDataDefault("power",0)-20);
SetPlayerInvincibility(180);
let rad=100;
let angle=90;
let SX=GetPlayerX;
let SY=GetPlayerY;
loop(180)
	{
	Tshoot(SX,SY,rad,angle);
	angle=angle+4;
	yield;
	}
}

task Tshoot(SX,SY,rad,angle)
{
let shot=CreatePlayerShot01(SX,SY,20,angle,1,120,3);
loop(5){yield};
Obj_SetSpeed(shot,0);
loop(45){yield};
let sangle=angle;
let rad=500;
ascent(enemy in EnumEnemyBegin..EnumEnemyEnd)
	{
	let enemyID = EnumEnemyGetID(enemy);
	let EX = GetEnemyInfo(enemyID, ENEMY_X);
	let EY = GetEnemyInfo(enemyID, ENEMY_Y);
	if(rad>((Obj_GetX(shot)-EX)^2+(Obj_GetY(shot)-EY)^2)^0.5 )
		{
		sangle=atan2(EY-Obj_GetY(shot),EX-Obj_GetX(shot));
		}
	}

Obj_SetAngle(shot,sangle);
Obj_SetSpeed(shot,20);
while(Obj_BeDeleted(shot)==false)
	{
	if(Obj_IsIntersected(shot)==true){Obj_SetAngle(shot,Obj_GetAngle(shot)+rand(-60,60))};
	yield;
	}
}

function GetAngleToCenter(CX,CY)
{
let Cangle=atan2(CY-GetPlayerY,CX-GetPlayerX);
return(Cangle);
}

function DifferenceToCenter
{
let dcenter=absolute(((GetCenterX-GetPlayerX)^2+(GetCenterY+80-GetPlayerY)^2)^(1/2));
return(dcenter);
}

task op_output
{
Toption1;
Toption2;
Toption3;
Toption4;
loop
	{
	level=(trunc(GetCommonDataDefault("power",0)/20));
	yield;
	}
}

#include_function".\op1.txt"
#include_function".\op2.txt"
#include_function".\op3.txt"

}



script_spell drive_shoot
{
	@Initialize
	{
	Tmain;
	}
	@MainLoop
	{
	yield;
	}
	@Finalize
	{
	}

task Tmain
	{
	let time=GetArgument;
	loop(50){yield};
	SetPlayerInvincibility(time);
	let CX=GetPlayerX;
	let CY=GetPlayerY;
	let rad=100;
	loop(time)
		{
		SetIntersectionCircle(CX,CY,100,0,true);
		yield;
		}
	End;
	}


}