
	task PlayerShot01(x,y,angle){
	let Hit      = Obj_Create(OBJ_SHOT);
	let obj      = Obj_Create(OBJ_SHOT);
	let alpha =  0;
	let count=0;
	Obj_SetPosition(obj,x,y);
	Obj_SetSpeed(obj,24);
	Obj_SetAngle(obj,angle);
	Obj_SetAlpha(obj,0);
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetDamage(obj,shot_damage);
	ObjShot_SetPenetration(obj,1);
	ObjShot_ToItem(obj,false);
	ObjShot_SetGraphic(obj,5);
	Obj_SetPosition(Hit,Obj_GetX(obj),Obj_GetY(obj)+24);
	Obj_SetAngle(Hit,Obj_GetAngle(obj));
	Obj_SetSpeed(Hit,Obj_GetSpeed(obj));
	Obj_SetAlpha(Hit,alpha);
	Obj_SetCollisionToPlayer(Hit,false);
	ObjShot_SetBombResist(Hit,true);
	ObjShot_SetGraphic(Hit,1);
	ObjShot_SetDamage(Hit,0);
	ObjShot_SetPenetration(Hit,1);
	ObjShot_ToItem(Hit,false);
	Obj_SetAutoDelete(obj,false);
	Obj_SetAutoDelete(Hit,false);
	alpha=0;
	yield;
	loop{
	alpha=128;
	count++;if(count>=6){Obj_SetAutoDelete(obj,true);}
	if(Obj_IsIntersected(obj)){
	SetCommonData("ShotHit",GetCommonDataDefault("ShotHit",0)+1);
		AddScore(10);
		alpha=255;
		Obj_SetAngle(Hit,Obj_GetAngle(Hit));
		loop(30){
		Obj_SetPosition(Hit,Obj_GetX(Hit)+cos(Obj_GetAngle(Hit))*3,
				Obj_GetY(Hit)+sin(Obj_GetAngle(Hit))*3);
		Obj_SetAngle(Hit,Obj_GetAngle(Hit));
		Obj_SetSpeed(Hit,0);
		ObjShot_SetGraphic(Hit,2);
		Obj_SetAlpha(Hit,alpha);
		Obj_SetCollisionToPlayer(Hit,false);
		ObjShot_SetBombResist(Hit,true);
		ObjShot_SetDamage(Hit,0);
		ObjShot_SetPenetration(Hit,9999);
		ObjShot_ToItem(Hit,false);
		alpha-=8;
		yield;
		}
		Obj_Delete(obj);
		Obj_Delete(Hit);
		return;
		}
		if(Obj_BeDeleted(obj)==true){
		Obj_Delete(obj);
		Obj_Delete(Hit);
		return;
		}
	Obj_SetPosition(Hit,Obj_GetX(obj),Obj_GetY(obj)+24);
	Obj_SetAngle(Hit,Obj_GetAngle(obj));
	Obj_SetSpeed(Hit,Obj_GetSpeed(obj));
	Obj_SetAlpha(Hit,alpha);
	Obj_SetCollisionToPlayer(Hit,false);
	ObjShot_SetBombResist(Hit,true);
	ObjShot_SetGraphic(Hit,1);
	ObjShot_SetDamage(Hit,0);
	ObjShot_SetPenetration(Hit,1);
	ObjShot_ToItem(Hit,false);
	yield;}
	}
	task PlayerShot02(x,y,angle){
	let Hit      = Obj_Create(OBJ_SHOT);
	let obj      = Obj_Create(OBJ_SHOT);
	let alpha =  0;
	let count=0;
	let Y=48;
	Obj_SetPosition(obj,x,y);
	Obj_SetSpeed(obj,36);
	Obj_SetAngle(obj,angle);
	Obj_SetAlpha(obj,0);
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetDamage(obj,pl00_Asub_damage);
	ObjShot_SetPenetration(obj,1);
	ObjShot_ToItem(obj,false);
	ObjShot_SetGraphic(obj,6);
	Obj_SetPosition(Hit,Obj_GetX(obj),Obj_GetY(obj)+Y);
	Obj_SetAngle(Hit,Obj_GetAngle(obj));
	Obj_SetSpeed(Hit,Obj_GetSpeed(obj));
	Obj_SetAlpha(Hit,alpha);
	Obj_SetCollisionToPlayer(Hit,false);
	ObjShot_SetBombResist(Hit,true);
	ObjShot_SetGraphic(Hit,4);
	ObjShot_SetDamage(Hit,0);
	ObjShot_SetPenetration(Hit,1);
	ObjShot_ToItem(Hit,false);
	Obj_SetAutoDelete(obj,false);
	Obj_SetAutoDelete(Hit,false);
	alpha=0;
	yield;
	loop{
	count++;if(count>=6){Obj_SetAutoDelete(obj,true);}
	alpha=128;
	if(Obj_IsIntersected(obj)){
	SetCommonData("ShotHit",GetCommonDataDefault("ShotHit",0)+1);
		AddScore(10);
		Obj_SetPosition(Hit,Obj_GetX(Hit),Obj_GetY(Hit)-Y);
		alpha=160;
		//Obj_SetAngle(Hit,Obj_GetAngle(Hit)+rand(10,-10));
		loop(30){
		Obj_SetPosition(Hit,Obj_GetX(Hit)+cos(Obj_GetAngle(Hit))*5,
				Obj_GetY(Hit)+sin(Obj_GetAngle(Hit))*5);
		Obj_SetAngle(Hit,Obj_GetAngle(Hit));
		Obj_SetSpeed(Hit,0);
		ObjShot_SetGraphic(Hit,4);
		Obj_SetAlpha(Hit,alpha);
		Obj_SetCollisionToPlayer(Hit,false);
		ObjShot_SetBombResist(Hit,true);
		ObjShot_SetDamage(Hit,0);
		ObjShot_SetPenetration(Hit,9999);
		ObjShot_ToItem(Hit,false);
		alpha-=8;
		yield;
		}
		Obj_Delete(obj);
		Obj_Delete(Hit);
		return;
		}
		if(Obj_BeDeleted(obj)==true){
		Obj_Delete(obj);
		Obj_Delete(Hit);
		return;
		}
Obj_SetPosition(Hit,Obj_GetX(obj),Obj_GetY(obj)+Y);
Obj_SetAngle(Hit,Obj_GetAngle(obj));
Obj_SetSpeed(Hit,Obj_GetSpeed(obj));
Obj_SetAlpha(Hit,alpha);
Obj_SetCollisionToPlayer(Hit,false);
ObjShot_SetBombResist(Hit,true);
ObjShot_SetDamage(Hit,0);
ObjShot_SetPenetration(Hit,1);
ObjShot_ToItem(Hit,false);
yield;}
}	task HomingShot(x,y,angle,dmg,nAddAngleBase){
		let hit=false;
		let v = 12;
		let obj = __Amulet( x, y, angle, v, 32, dmg );
		//let dda = 5;
		let da = 0;
		let accMinus = v / 5;//1.0;
		let accPlus = 0.3;//0.5;
		let nDiffLimit = 120;
		let delcount = 0;
		loop(60){
			if(Obj_IsIntersected(obj)){
				SetCommonData("ShotHit",GetCommonDataDefault("ShotHit",0)+1);
			hit=true;break;}
			delcount++;
			let nAddAngle = nAddAngleBase + da;
			let homingId=TargetSet(Obj_GetX(obj), Obj_GetY(obj));
			let minX = GetEnemyInfoDefault( homingId, ENEMY_X, 0 );
			let minY = GetEnemyInfoDefault( homingId, ENEMY_Y, 0 );
		if(32>=minX){//敵が画面内に居ない間はホーミング無し
			minX = 0;
			minY = 0;
		}
		if(minX>=416){
			minX = 0;
			minY = 0;
		}
		if(16>=minY){
			minX = 0;
			minY = 0;
		}
		if(minY>=464){
			minX = 0;
			minY = 0;
		}
			let nAngle = Obj_GetAngle( obj );
			let destAngle = nAngle;

		v += 0.2;
			
			if ( minX != 0 && minY != 0 ) {
				destAngle = GetGapAngle( Obj_GetX( obj ), Obj_GetY( obj ), minX, minY );
			}
			while ( destAngle < 0 ) { destAngle += 360; }
			while ( destAngle > 360 ) { destAngle -= 360; }
			while ( nAngle < 0 ) { nAngle += 360; }
			while ( nAngle > 360 ) { nAngle -= 360; }
			if ( destAngle - 180 > nAngle ) { nAngle += 360; }
			if ( destAngle + 180 < nAngle ) { nAngle -= 360; }

			let nDiffAngle = destAngle - nAngle;
			let nSpeed = Obj_GetSpeed( obj );
			if ( absolute( nDiffAngle ) > nDiffLimit ) {
				//nSpeed -= accMinus;
				nAddAngle /= 2;
			}
			else {
				nSpeed += accPlus;
			}
			
			if ( nSpeed < 0 ) {
				//nSpeed *= -1;
				nAngle = destAngle;
				nDiffAngle = 0;
			}
			else if ( nSpeed > v ) {
				nSpeed = v;
			}

			let nAddAngle2 = [ nAddAngle, nAddAngle * 2 ][ absolute( nDiffAngle ) < 90 ];

			if( ( nDiffAngle > 0 && nDiffAngle <= 180 ) || nDiffAngle <= -180 ){
				if ( absolute( nDiffAngle ) < nAddAngle2 ) {
					nAngle += absolute( nDiffAngle );
				}
				else {
					nAngle += nAddAngle2;
				}
			}
			else if( nDiffAngle > 180 || ( nDiffAngle < 0 && nDiffAngle > -180 ) ){
				if ( absolute( nDiffAngle ) < nAddAngle2 ) {
					nAngle -= absolute( nDiffAngle );
				}
				else {
					nAngle -= nAddAngle2;
				}
			}
			Obj_SetSpeed( obj, nSpeed );
			Obj_SetAngle( obj, nAngle );
			//dda += da;
			yield;
		}
	loop{
	if(Obj_IsIntersected(obj)){
	SetCommonData("ShotHit",GetCommonDataDefault("ShotHit",0)+1);
	hit=true;
		}
	if(hit==true){
		ObjShot_FadeDelete(obj);
		loop(60){
		Obj_SetPosition(obj,Obj_GetX(obj)+cos(Obj_GetAngle(obj))*3,Obj_GetY(obj)+sin(Obj_GetAngle(obj))*3);
		Obj_SetSpeed(obj,0);
		Obj_SetAngle(obj,Obj_GetAngle(obj));
		ObjShot_SetGraphic( obj,11 );
		Obj_SetCollisionToPlayer(obj,false);
		yield;}
		}
		if(Obj_BeDeleted(obj)==true){
		Obj_Delete(obj);
		return;
		}
	yield;}
	}

	function __Amulet( let x, let y, let angle, let v, let type, let dmg ) {
		let obj = Obj_Create( OBJ_SHOT );
		Obj_SetPosition( obj, x, y );
		Obj_SetAngle( obj, angle );
		Obj_SetSpeed( obj, v );
		Obj_SetAlpha( obj, 192 );
		ObjShot_SetBombResist( obj, true );
		ObjShot_SetGraphic( obj, 10 );
		ObjShot_SetDamage( obj, dmg );
		ObjShot_SetPenetration( obj, 9999 );
		ObjShot_ToItem( obj, false );
		return obj;
	}
	function TargetSet( x, y ){//x,yに一番近い敵をロックする
		let TargetID=0;//目標のIDを格納する変数（デフォルトは０＝ボスのID）
		let MinDistance=1000*1000;//距離比較用
		ascent(enemy in EnumEnemyBegin..EnumEnemyEnd){
			let enemyID = EnumEnemyGetID(enemy);//敵ID取得
			let enemyX=GetEnemyInfo(enemyID,ENEMY_X);//enemyIDのID値を持つ敵のX座標取得
			let enemyY=GetEnemyInfo(enemyID,ENEMY_Y);//enemyIDのID値を持つ敵のY座標取得
			let dx=x-enemyX;
			let dy=y-enemyY;
			let distance=dx*dx+dy*dy;//(x,y)からの距離の２乗を求める
			if(MinDistance>distance){//距離２乗の結果が最小だった場合
				MinDistance=distance;//お前がナンバーワンだ
				TargetID=enemyID;
			}
		}//ループを抜けると(x,y)から最も近い敵のIDが分かる
		return TargetID;//その結果を返す
	}

function GetGapAngle(let xA,let yA,let xB,let yB){return atan2( yB - yA, xB - xA );
}

