let ZakoColor=[255,255,255];
let ZakoMagicColor=[255,255,255];
let BulletNum;
let DrawZakoZAngle=0;
let imgCircle=csd~"..\img\circle.png";
let imgLight=csd ~"..\img/Light.png";
let DamageRate=100;
let BombDamageRate=100;
let EnemyGroundShotSeal=false;
let EnemyGroundShotSealtime=0;
let MagicCircleScale=0;
let SpecialBreak=false;
let OutDamage=false;

let EraseLifeGauge=true;
let DefeatFlag=false;

function SetSkyCollision(x,y,Radius)
{
	MSDSetCollisionA(x,y,Radius);
        MSDSetCollisionB(x,y,Radius/3);
}

function SetGroundCollision(x,y,Radius)
{
	MSDSetCollisionA(x,y,Radius);
}

function SetServantSkyCollision(x,y,Radius)
{
	if(GetCommonDataDefault("MSDPlayer",false)==true)
	{
	MSDSetCollisionA(x,y,Radius);
        MSDSetCollisionB(x,y,Radius/3);
	}
}

function SetServantGroundCollision(x,y,Radius)
{
	if(GetCommonDataDefault("MSDPlayer",false)==true)
	{
	MSDSetCollisionA(x,y,Radius);
	}
}

function SetDummySkyCollision(x,y,Radius)
{
	if(GetCommonDataDefault("MSDPlayer",false)==false)
	{
	MSDSetCollisionA(x,y,Radius);
        MSDSetCollisionB(x,y,Radius/3);
	}
}

function SetDummyGroundCollision(x,y,Radius)
{
	if(GetCommonDataDefault("MSDPlayer",false)==false)
	{
	MSDSetCollisionA(x,y,Radius);
	}
}

function MSDSetCollisionA(x,y,Radius)
{
	SetCollisionA(x,y,Radius);
}

function MSDSetCollisionAForBigEnemy(x,y,Radius)
{
	if(GetDistanceToPlayer<=Radius)
	{
		SetCollisionA(x,y,(GetDistanceToPlayer+Radius)/2);
	}
	else
	{
		SetCollisionA(x,y,Radius);
	}
}

function SetSkyCollisionAForBigEnemy(x,y,Radius)
{
	if(GetDistanceToPlayer<=Radius)
	{
		SetCollisionA(x,y,(GetDistanceToPlayer+Radius)/2);
     		MSDSetCollisionB(x,y,(GetDistanceToPlayer+Radius)/2/3);
	}
	else
	{
		SetCollisionA(x,y,Radius);
		MSDSetCollisionB(x,y,Radius/3);
	}
}

function MSDSetCollisionB(x,y,Radius)
{
	if(GetCommonData("BURSTLEVEL")==0)
	{
		if(GetDistanceToPlayer<=Radius && GetTimeOfPlayerInvincibility==0)
		{
			ItemSet(GetX,GetY,-1);
		}
	}
}

task SetDefeat
{
loop
{
	if(GetLife<=1000)
	{
		DefeatFlag=true;
		VanishEnemy;
	}
yield;
}
}

task LifeSteal
{
loop
{
	if(GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD)
	{
	if(!OnPlayerMissed && GetPlayerLife!=0 && GetCommonDataDefault("MissTime",0)==0)
	{
	if(GetDistanceToPlayer<=GetSpeed*10)
	{
		AddLife(-1);
	}	
	}
	}
	yield;
}
}

task GetDamege//ショットが当たった時色変更
{
GetDamegeItem;
loop
{
	if(GetHitCount!=0)
	{
		ZakoColor=[150,150,255];

		wait(10);
	}
	else
	{
		ZakoColor=[255,255,255];
	}

yield;
}
}

task GetDamegeItem//近接打ち込み
{
//let SRange=GetCommonData("MagicAbsorbShortRange");
let SRange=60;
let BaseSRange=60;
alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
case("Apocalypse")
{
	SRange*=1.2;
}
loop
{
		SRange=BaseSRange*(1+0.2*GetCommonDataDefault("RUSHGAUGE",0)/1000);
		if(MagicCircleScale<1)
		{
			MagicCircleScale+=1/15;
		}
		if(GetHitCount!=0 && GetDistanceToPlayer<=SRange)
		{
		if(GetCommonDataDefault("MSDPlayer",false)==false && GetCommonDataDefault("SELECTEDDIFFICULT","None")!="Arrange")
		{
			AddScore(10000);
			AddPoint(1);
			if(GetTimeOfSuperNaturalBorder>0)
			{
				let SpiritItemRate=trunc(0.5+2.5*GetCommonData("SpiritRank")/10000);
				AddScore(10000*SpiritItemRate);
				AddPoint(1*SpiritItemRate);
			}
			SpiritSet(1.0);
		}
		else
		{
			if(GetCommonData("BURSTLEVEL")==0)
			{
				loop(2)
				{
				ItemSet(GetX,GetY,2);
				}
			}
			if(GetCommonData("BURSTLEVEL")==3)
			{
				loop(2)
				{
				ItemSet(GetX,GetY,8);
				}
			}
		}

		}
		else if(GetHitCount!=0)
		{
			SpiritSet(0.05);
		}
yield;
}
}

task MagicColor//封印時の色変更
{
SealEnemy;
loop
{
	if(!EnemyGroundShotSeal)
	{
		ZakoMagicColor=[255,255,255];
	}
	else
	{
		ZakoMagicColor=[255,150,150];
	}
yield;
}
}

task SealEnemy
{
	loop
	{
		if(GetDistanceToPlayer<=90)
		{
			EnemyGroundShotSealtime=30;
		}
		else
		{
			if(EnemyGroundShotSealtime>0)
			{
			EnemyGroundShotSealtime-=1;
			}
		}
		if(EnemyGroundShotSealtime>0)
		{
			EnemyGroundShotSeal=true;
		}
		else
		{
			EnemyGroundShotSeal=false;
		}
	yield;
	}
}

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

function GetDistanceToPlayer//敵とプレイヤーとの距離を返す
{
	let dis=((GetX-GetPlayerX)^2+(GetY-GetPlayerY)^2)^0.5;
	return(dis);
}

function GetDistanceToPlayerFrom(x,y)//位置とプレイヤーとも距離を返す
{
	let dis=((x-GetPlayerX)^2+(y-GetPlayerY)^2)^0.5;
	return(dis);
}

function SkyCreateShot01(X,Y,Speed,Angle,Graphic,Delay)
{
	if(GetCommonData("BURSTLEVEL")==3)
	{
		Speed=Speed*(1+0.5*GetCommonData("BURSTRANK")/10000);
	}
	if(GetTimeOfSuperNaturalBorder>0)
	{
		Speed=Speed*(1+0.5*GetCommonData("SpiritRank")/10000);
	}
	CreateShot01(X,Y,Speed,Angle,Graphic,Delay);
}

function GroundCreateShot01(X,Y,Speed,Angle,Graphic,Delay)
{//封印されるCreateShot01
	if(GetCommonData("BURSTLEVEL")==3)
	{
		Speed=Speed*(1+0.5*GetCommonData("BURSTRANK")/10000);
	}
	if(GetTimeOfSuperNaturalBorder>0)
	{
		Speed=Speed*(1+0.5*GetCommonData("SpiritRank")/10000);
	}
	if(!EnemyGroundShotSeal)
	{
	CreateShot01(X,Y,Speed,Angle,Graphic,Delay);
	}
}

function FinalizeItemAndShotnumWithoutEraze(num)
{
	let BurstErazeCircleRangeRate=GetCommonData("BurstErazeCircleRangeRate");
	FinalizeItemSet(num);

	if(!BeVanished || DefeatFlag)
	{
		if(!OnBomb)
		{
			alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
			case("Moderate")
			{
				ReturnBurstShotnum((num+1));
			}
			case("Extream")
			{
				ReturnBurstShotnum((num+1));
				ReturnPowerShotnum((num+1));
			}
			case("Apocalypse")
			{
				BurstErazeCircleRangeRate*=1.1;
				ReturnBurstShotnum((num+1));
			}
		if(GetCommonData("BalanceBreak"))
		{
		//	ResistReturnShot(num*5);
		}
		}
	}
}

function FinalizeItemAndShotnum(num)
{
	let BurstErazeCircleRangeRate=GetCommonData("BurstErazeCircleRangeRate");
	FinalizeItemSet(num);

	if(!BeVanished || DefeatFlag)
	{
		if(!OnBomb)
		{
			alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
			case("Moderate")
			{
				ReturnBurstShotnum((num+1));
			}
			case("Extream")
			{
				ReturnBurstShotnum((num+1));
				ReturnPowerShotnum((num+1));
			}
			case("Apocalypse")
			{
				BurstErazeCircleRangeRate*=1.2;
				ReturnBurstShotnum((num+1));
			}
		if(GetCommonData("BalanceBreak"))
		{
		//	ResistReturnShot(num*5);
		}
		}

		if(GetCommonData("BURSTLEVEL")==3)
		{
			let RedBullet=GetEnemyShotCountEx(GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate,9);
			let BlueBullet=GetEnemyShotCountEx(GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate,14);
			let BuleNife=GetEnemyShotCountEx(GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate,150);
			DeleteEnemyShotImmediatelyInCircle(SHOT,GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate);

			EraseBulletItemSet(GetX,GetY,RedBullet+BlueBullet+BuleNife);

			let BMEBN=GetCommonDataDefault("BurstModeErazeBulletNum",[]);//共通データ内容を変数に渡す
			BMEBN=BMEBN~[RedBullet+BuleNife+BlueBullet];//
			SetCommonData("BurstModeErazeBulletNum",BMEBN);//共通データに変更後の配列を渡す

			let BMEBE=GetCommonDataDefault("BurstModeErazeBulletEffect",[]);//共通データ内容を変数に渡す
			BMEBE=BMEBE~[GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate];//
			SetCommonData("BurstModeErazeBulletEffect",BMEBE);//共通データに変更後の配列を渡す
		}
	}
}

function FinalizeItemAndShotnumWithDelete(num)
{
	let BurstErazeCircleRangeRate=GetCommonData("BurstErazeCircleRangeRate");
	FinalizeItemSet(num);

	if(!BeVanished || SpecialBreak || DefeatFlag)
	{
		if(!OnBomb)
		{
			alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
			case("Moderate")
			{
				ReturnBurstShotnum((num+1));
			}
			case("Extream")
			{
				ReturnBurstShotnum((num+1));
				ReturnPowerShotnum((num+1));
			}
			case("Apocalypse")
			{
				BurstErazeCircleRangeRate*=1.2;
				ReturnBurstShotnum((num+1));
			}
		if(GetCommonData("BalanceBreak"))
		{
		//	ResistReturnShot(num*5);
		}
		}
		if(GetCommonData("BURSTLEVEL")==0)
		{
			SetCommonData("DeleteBulletNum",BulletNum);
			SetCommonData("DeleteBulletX",GetX);
			SetCommonData("DeleteBulletY",GetY);
			DeleteEnemyShotToItem(SHOT);
		}
		BurstErazeCircleRangeRate*=1.2;
		if(GetCommonData("BURSTLEVEL")==3)
		{
			let RedBullet=GetEnemyShotCountEx(GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate,9);
			let BlueBullet=GetEnemyShotCountEx(GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate,14);
			let BuleNife=GetEnemyShotCountEx(GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate,150);
			DeleteEnemyShotImmediatelyInCircle(SHOT,GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate);

			EraseBulletItemSet(GetX,GetY,RedBullet+BlueBullet+BuleNife);

			let BMEBN=GetCommonDataDefault("BurstModeErazeBulletNum",[]);//共通データ内容を変数に渡す
			BMEBN=BMEBN~[RedBullet+BuleNife+BlueBullet];//
			SetCommonData("BurstModeErazeBulletNum",BMEBN);//共通データに変更後の配列を渡す
			let BMEBE=GetCommonDataDefault("BurstModeErazeBulletEffect",[]);//共通データ内容を変数に渡す
			BMEBE=BMEBE~[GetX,GetY,(num*5+5)*GetCommonData("BurstErazeCircleRangeRate")];//
			SetCommonData("BurstModeErazeBulletEffect",BMEBE);//共通データに変更後の配列を渡す
		}
		if(GetCommonDataDefault("StrongPlayer",false)==true)
		{
			DeleteEnemyShotToItem(ALL);
		}
	}
}

function FinalizeItemAndShotnumWithDeleteChild(num)
{
	let BurstErazeCircleRangeRate=GetCommonData("BurstErazeCircleRangeRate");
	//FinalizeItemSet(num);

	if(!BeVanished || DefeatFlag)
	{
		if(!OnBomb)
		{
			alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
			case("Moderate")
			{
				ReturnBurstShotnum((num+1));
			}
			case("Extream")
			{
				ReturnBurstShotnum((num+1));
				ReturnPowerShotnum((num+1));
			}
			case("Apocalypse")
			{
				BurstErazeCircleRangeRate*=1.2;
				ReturnBurstShotnum((num+1));
			}
		if(GetCommonData("BalanceBreak"))
		{
		//	ResistReturnShot(num*5);
		}

		}
		if(GetCommonData("BURSTLEVEL")==0)
		{
			SetCommonData("DeleteBulletNum",BulletNum);
			SetCommonData("DeleteBulletX",GetX);
			SetCommonData("DeleteBulletY",GetY);
			DeleteEnemyShotToItem(SHOT);
		}
		BurstErazeCircleRangeRate*=1.2;
		if(GetCommonData("BURSTLEVEL")==3)
		{
			let RedBullet=GetEnemyShotCountEx(GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate,9);
			let BlueBullet=GetEnemyShotCountEx(GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate,14);
			let BuleNife=GetEnemyShotCountEx(GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate,150);
			DeleteEnemyShotImmediatelyInCircle(SHOT,GetX,GetY,(num*5+5)*BurstErazeCircleRangeRate);
			
			EraseBulletItemSet(GetX,GetY,RedBullet+BlueBullet+BuleNife);

			let BMEBN=GetCommonDataDefault("BurstModeErazeBulletNum",[]);//共通データ内容を変数に渡す
			BMEBN=BMEBN~[RedBullet+BuleNife+BlueBullet];//
			SetCommonData("BurstModeErazeBulletNum",BMEBN);//共通データに変更後の配列を渡す
			let BMEBE=GetCommonDataDefault("BurstModeErazeBulletEffect",[]);//共通データ内容を変数に渡す
			BMEBE=BMEBE~[GetX,GetY,(num*5+5)*GetCommonData("BurstErazeCircleRangeRate")];//
			SetCommonData("BurstModeErazeBulletEffect",BMEBE);//共通データに変更後の配列を渡す
			DeleteEnemyShotToItem(CHILD);
		}
	}
}

function EraseBulletItemSet(x,y,num)
{
	loop(num%10)
	{
		ItemSet(x,y,85);
	}
	loop(floor(num/10))
	{
		ItemSet(x,y,85.5);
	}
}

function ReturnBurstShotnum(num)
{//バーストでの撃ち返し発生
	if(GetCommonData("BURSTLEVEL")==3)
	{
		if(GetCommonData("MAGICCOUNTER")>=10000)
		{
			ascent(let i in 0..num)
			{
				CreateShotFromScript( "BurstReturnBigShot",GetX, GetY, 3+rand(-0.75,0.75), GetAngleToPlayer+rand(-30,30), 30, 8);
			}
		}
		else
		{
			ascent(let i in 0..num)
			{
				CreateShotFromScript( "BurstReturnShot",GetX, GetY, 3+rand(-0.75,0.75), GetAngleToPlayer+rand(-30,30), 30, 8);
			}
		}
	}
}

function ReturnPowerShotnum(num)
{//マジック反応弾撃ち返し発生
	if(GetCommonData("BURSTLEVEL")==0)
	{
		ascent(let i in 0..num)
		{
			if(GetCommonDataDefault("SlowMoveSwitch",false))
			{
				ItemSet(GetX,GetY,7);
			}
			else
			{
				ItemSet(GetX,GetY,75);
			}
			if(GetCommonData("MAGICCOUNTER")>=10000)
			{
				if(GetCommonDataDefault("SlowMoveSwitch",false))
				{
					ItemSet(GetX,GetY,7);
				}
				else
				{
					ItemSet(GetX,GetY,75);
				}
			}
		}
	}
}

function ResistReturnShot(num)
{
let Shotnum=10;
let SRange=60;
let LRange=150;
alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
case("Apocalypse")
{
	SRange*=1.2;
	LRange*=1.2;
}
	if(GetDistanceToPlayer<=SRange)
	{
		Shotnum=10;
	}
	else if(GetDistanceToPlayer<=LRange)
	{
		Shotnum=10*(GetDistanceToPlayer-LRange)/(SRange-LRange);
	}
	else
	{
		Shotnum=0;
	}
	Shotnum=10-Shotnum;
	loop(floor(Shotnum/10*num))
	{
	CreateShotFromScript( "ResistReturnShot",GetX, GetY, 3+rand(-0.75,0.75), GetAngleToPlayer+rand(-30,30), 10, 8);
	}
}

function FinalizeItemSet(num)
{
if(GetX<GetClipMinX-16 || GetClipMaxX+16<GetX || GetY<GetClipMinY-16 || GetClipMaxY+16<GetY)
{

}
else
{
let type;
let GreenItem=0;
//let SRange=GetCommonData("MagicAbsorbShortRange");
//let LRange=GetCommonData("MagicAbsorbLongRange");
let SRange=60;
let LRange=150;
alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
case("Extream")
{
	SRange*=1+0.2*GetCommonDataDefault("RUSHGAUGE",0)/1000;
	LRange*=1+0.2*GetCommonDataDefault("RUSHGAUGE",0)/1000;
}
case("Apocalypse")
{
	SRange*=1.2;
	LRange*=1.2;
}
alternative(GetCommonData("BURSTLEVEL"))
case(0)
{
	type=3;
}
case(3)
{
	type=5;
}
		if(!BeVanished || SpecialBreak || DefeatFlag)
		{
		if(GetCommonDataDefault("MSDPlayer",false)==false && GetCommonDataDefault("SELECTEDDIFFICULT","None")!="Arrange")
		{
			loop(num*3)
			{
			CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY+rand(-50,50));
			}
			if(GetTimeOfSuperNaturalBorder>0)
			{
				let SpiritItemRate=0.5+2.5*GetCommonData("SpiritRank")/10000;
				loop(trunc(num*3*SpiritItemRate))
				{
					CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY+rand(-50,50));
				}
			}
			SpiritSet(num*3/1.5);
		}
		else
		{
			loop(num)
			{
				ItemSet(GetX,GetY,type);
			}
		}

		let PurityRate=1;

		if(num==0){num=1;}
		if(GetDistanceToPlayer<=SRange)
		{
			PurityRate=4;
			GreenItem=10;
		}
		else if(GetDistanceToPlayer<=LRange)
		{
			GreenItem=10*(GetDistanceToPlayer-LRange)/(SRange-LRange);
			PurityRate=1+3*(GetDistanceToPlayer-LRange)/(SRange-LRange);
		}
		else
		{
			GreenItem=0;
			PurityRate=1;
		}

		if(GetCommonDataDefault("MSDPlayer",false)==false && GetCommonDataDefault("SELECTEDDIFFICULT","None")!="Arrange")
		{
		loop(num)
		{
			loop(trunc(GreenItem))
			{
				CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY+rand(-50,50));
			}
			if(GetTimeOfSuperNaturalBorder>0)
			{
				let SpiritItemRate=0.5+2.5*GetCommonData("SpiritRank")/10000;
				loop(trunc(GreenItem*SpiritItemRate))
				{
					CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY+rand(-50,50));
				}
			}
			SpiritSet(GreenItem/1.5);
		}
		}
		else
		{
		loop(num)
		{
			if(GetCommonData("MAGICCOUNTER")>=10000)
			{
				ItemSet(GetX,GetY,type);
			}
			if(GetCommonData("MAGICPOWER")>=1000)
			{	
				ItemSet(GetX,GetY,type);
			}
			let BigGreenItem=0;
			if(GreenItem>=6)
			{
				BigGreenItem=GreenItem-5;
				GreenItem-=BigGreenItem*2;
			}
			loop(trunc(GreenItem))
			{
				alternative(GetCommonData("BURSTLEVEL"))
				case(0)
				{
					ItemSet(GetX,GetY,1);
				}
				case(3)
				{
					ItemSet(GetX,GetY,10);
				}
			}
			loop(trunc(BigGreenItem))
			{
				alternative(GetCommonData("BURSTLEVEL"))
				case(0)
				{
					ItemSet(GetX,GetY,1.5);
				}
				case(3)
				{
					ItemSet(GetX,GetY,10.5);
				}
			}
		}
		}

		PurityRateSet(trunc(10*PurityRate)/10);

		}
}
}

function ItemSet(x,y,type)//アイテム生成関数
{
	let XY=GetCommonDataDefault("ItemXY",[]);//共通データ内容を変数に渡す
	XY=XY~[x,y,type];//
	SetCommonData("ItemXY",XY);//共通データに変更後の配列を渡す
}

function PurityRateSet(Rate)//アイテム生成関数
{
	let XY=GetCommonDataDefault("PurityRateArray",[]);//共通データ内容を変数に渡す
	XY=XY~[Rate];//
	SetCommonData("PurityRateArray",XY);//共通データに変更後の配列を渡す
}


function ExtendItemSet(x,y,type)//アイテム生成関数
{

	let XY=GetCommonDataDefault("ExtendItem",[]);//共通データ内容を変数に渡す
	XY=XY~[x,y,type];//
	SetCommonData("ExtendItem",XY);//共通データに変更後の配列を渡す


}

function MagicCircleBreak(x,y,type,scale)//アイテム生成関数
{
	if(!BeVanished || SpecialBreak || DefeatFlag)
	{
	let XY=GetCommonDataDefault("MagicCircleBreak",[]);//共通データ内容を変数に渡す
	XY=XY~[x,y,type,scale];//
	SetCommonData("MagicCircleBreak",XY);//共通データに変更後の配列を渡す
	}
}

function SpiritSet(num)//アイテム生成関数
{
	let XY=GetCommonDataDefault("SpiritGain",[]);//共通データ内容を変数に渡す
	XY=XY~[num];//
	SetCommonData("SpiritGain",XY);//共通データに変更後の配列を渡す
}

task OutDamageRateZero
{
let DamegeCoefficient=0;
let ArrangeDamageRate=0;
let ArrangeBombDamageRate=0;
if(GetCommonDataDefault("StrongPlayer",false)==true)
{
	ArrangeDamageRate=0.4;
	ArrangeBombDamageRate=0.1;
}
else if(GetCommonDataDefault("MSDPlayer",false)==true)
{
	ArrangeDamageRate=1.0;
	ArrangeBombDamageRate=1.0;
}
else if(GetPlayerType!=USER_PLAYER)
{
	ArrangeDamageRate=0.90;
	ArrangeBombDamageRate=0.2;
}
else
{
	ArrangeDamageRate=0.8;
	ArrangeBombDamageRate=0.2;
}
//let SRange=GetCommonData("MagicAbsorbShortRange");
//let LRange=GetCommonData("MagicAbsorbLongRange");
let SRange=60;
let LRange=150;
let BaseSRange=60;
let BaseLRange=150;
alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
case("Apocalypse")
{
	SRange*=1.2;
	LRange*=1.2;
}
loop
{
	SRange=BaseSRange*(1+0.2*GetCommonDataDefault("RUSHGAUGE",0)/1000);
	LRange=BaseLRange*(1+0.2*GetCommonDataDefault("RUSHGAUGE",0)/1000);

	if(!OutDamage && ( GetX<GetClipMinX-16 || GetClipMaxX+16<GetX || GetY<GetClipMinY-16 || GetClipMaxY+16<GetY ) )
	{
		SetDamageRate(0,0);
	}
	else
	{
		if(GetDistanceToPlayer<=SRange)
		{
			DamegeCoefficient=1.2;
		}
		else if(GetDistanceToPlayer<=LRange)
		{
			DamegeCoefficient=1+0.2*(GetDistanceToPlayer-LRange)/(SRange-LRange);
		}
		else
		{
			DamegeCoefficient=1.0;
		}
		SetDamageRate(DamageRate*DamegeCoefficient*ArrangeDamageRate,BombDamageRate*ArrangeBombDamageRate);
	}
	if(GetCommonDataDefault("StrongPlayer",false)==true)
	{
		if(GetTimeOfPlayerInvincibility>=360)
		{
			StrongBomb;

			task StrongBomb
			{
				loop(540)
				{
					ArrangeDamageRate=0.1;
					ArrangeBombDamageRate=0.025;
					yield;
				}
				ArrangeDamageRate=0.4;
				ArrangeBombDamageRate=0.1;
			}
		}
	}
yield;
}
}

task AutoErazeTime(w)
{
ZakoEnemyLifeDisplay;
loop(w)
{
if(GetCommonDataDefault("VanishSignal",false))
{
	break;
}

if(GetX<GetClipMinX-300 || GetClipMaxX+300<GetX || GetY<GetClipMinY-120 || GetClipMaxY+100<GetY)
{
	break;
}

yield;
}
VanishEnemy;
}

task ElementalAutoErazeTime(w)
{
loop(w)
{
if(GetCommonDataDefault("VanishSignal",false))
{
	break;
}

if(GetX<GetClipMinX-300 || GetClipMaxX+300<GetX || GetY<GetClipMinY-120 || GetClipMaxY+100<GetY)
{
	break;
}

yield;
}
VanishEnemy;
}


task ZakoEnemyLifeDisplay//下部に敵のライフを表示
{
ZakoLifeDisplay;
}

task ZakoLifeDisplay//ライフバーのバー部分の設定
{
	let ZakoLifeMax=GetLife;
	if(ZakoLifeMax<=20){return;}
	let scale=0.5;
	let Sscale=0.5;
	let XAdjust=25;

		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, csd ~ "..\img\ber.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, 0, -3);
		ObjEffect_SetVertexXY(obj, 1, 100,  -3);
		ObjEffect_SetVertexXY(obj, 2, 100, 3);
		ObjEffect_SetVertexXY(obj, 3,  0,  3);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  27);
		ObjEffect_SetVertexUV(obj, 1,  206, 27);
		ObjEffect_SetVertexUV(obj, 2, 206,  33);
		ObjEffect_SetVertexUV(obj, 3, 6, 33);
		ObjEffect_SetLayer(obj,2);
		ObjEffect_SetScale(obj, scale,0.16);

		ObjEffect_SetVertexColor(obj,0,150,255,255,0);
		ObjEffect_SetVertexColor(obj,1,150,255,0,0);
		ObjEffect_SetVertexColor(obj,2,150,255,0,0);
		ObjEffect_SetVertexColor(obj,3,150,255,255,0);

		while(GetLife>0)
		{
			Obj_SetPosition(obj,GetX-XAdjust,GetY-16);
			scale=Sscale*GetLife/ZakoLifeMax;
			ObjEffect_SetVertexColor(obj,0,255,255,255,0);
			ObjEffect_SetVertexColor(obj,1,255,255,255-255*GetLife/ZakoLifeMax,0);
			ObjEffect_SetVertexColor(obj,2,255,255,255-255*GetLife/ZakoLifeMax,0);
			ObjEffect_SetVertexColor(obj,3,255,255,255,0);
			if(GetLife==ZakoLifeMax)
			{
			ObjEffect_SetVertexColor(obj,0,0,255,255,0);
			ObjEffect_SetVertexColor(obj,1,0,255,255-255*GetLife/ZakoLifeMax,0);
			ObjEffect_SetVertexColor(obj,2,0,255,255-255*GetLife/ZakoLifeMax,0);
			ObjEffect_SetVertexColor(obj,3,0,255,255,0);
			}
			if(!EraseLifeGauge){break;}
			ObjEffect_SetScale(obj, scale,0.8);
			yield;
		}
		Obj_Delete(obj);
}

task ZakoEffect(R,G,B)
{
if(GetCommonDataDefault("LightMode_ElementalBlur",0)==1)
{
	LightModeZakoEffect1(R,G,B,1);
	LightModeZakoEffect1(R,G,B,-1);
}
loop
{
	ZakoEffect1(R,G,B);
yield;
}
}

task RainbowZakoEffect
{
let R=255;
let B=255;
let G=255;
let HueCount=0;
let MinColor=50;
	if(GetCommonDataDefault("LightMode_ElementalBlur",0)==1)
	{
		LightModeRainbowZakoEffect1(-1);
		LightModeRainbowZakoEffect1(1);
	}
loop
{
	if(0<HueCount && HueCount<=60)
	{
		R=255;
		G=255*(HueCount)/60;
		B=0;
	}
	else if(HueCount<=120)
	{
		R=255*(120-HueCount)/60;
		G=255;
		B=0;
	}
	else if(HueCount<=180)
	{
		R=0;
		G=255;
		B=255*(HueCount-120)/60;
	}
	else if(HueCount<=240)
	{
		R=0;
		G=255*(240-HueCount)/60;
		B=255;
	}
	else if(HueCount<=300)
	{
		R=255*(HueCount-240)/60;
		G=0;
		B=255;
	}
	else if(HueCount<=360)
	{
		R=255;
		G=0;
		B=255*(360-HueCount)/60;
	}
	HueCount+=3;
	if(HueCount>=361){HueCount=1;}
	ZakoEffect1(R,G,B);
yield;
}

}


task LightModeRainbowZakoEffect1(dir)
{
let R=255;
let B=255;
let G=255;
		let scax=1.0;
		let scay=1.0;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
		let alpha=100;
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgCircle);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -128, -128);
	ObjEffect_SetVertexXY(obj, 1,128, -128);
	ObjEffect_SetVertexXY(obj, 2, 128, 128);
	ObjEffect_SetVertexXY(obj, 3, -128, 128);
		
		ObjEffect_SetVertexUV(obj, 0,  256,  256);
		ObjEffect_SetVertexUV(obj, 1,  512, 256);
		ObjEffect_SetVertexUV(obj, 2, 512,  512);
		ObjEffect_SetVertexUV(obj, 3, 256, 512);

		Obj_SetPosition(obj,GetX,GetY);
		//Obj_SetPosition(obj,GetX,GetY);
		ObjEffect_SetScale(obj, 0.2,0.2);

		ObjEffect_SetLayer(obj,2);

		Obj_SetSpeed(obj,1);
		Obj_SetAngle(obj,-90);

			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,alpha,R,G,B);
			}
		let HueCount=0;
		loop
		{
	if(0<HueCount && HueCount<=60)
	{
		R=255;
		G=255*(HueCount)/60;
		B=0;
	}
	else if(HueCount<=120)
	{
		R=255*(120-HueCount)/60;
		G=255;
		B=0;
	}
	else if(HueCount<=180)
	{
		R=0;
		G=255;
		B=255*(HueCount-120)/60;
	}
	else if(HueCount<=240)
	{
		R=0;
		G=255*(240-HueCount)/60;
		B=255;
	}
	else if(HueCount<=300)
	{
		R=255*(HueCount-240)/60;
		G=0;
		B=255;
	}
	else if(HueCount<=360)
	{
		R=255;
		G=0;
		B=255*(360-HueCount)/60;
	}
	HueCount+=3;
	if(HueCount>=361){HueCount=1;}
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,alpha,R,G,B);
			}
			Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetAngle(obj,0,0,Zangle);
			Zangle+=3*dir;
			yield;
		}
		Obj_Delete(obj);
}

task ZakoEffect1(R,G,B)
{
		let randrect=3;
	let XYrect=[];
	loop(8)
	{
	XYrect=XYrect~[48/2+rand(-randrect,randrect)];
	}
	if(GetCommonDataDefault("LightMode_ElementalBlur",0)==1){return;}

		let scax=1.0;
		let scay=1.0;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
		let alpha=150;
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,GetCurrentScriptDirectory~"..\img\CircleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -XYrect[0], -XYrect[1]);
	ObjEffect_SetVertexXY(obj, 1, XYrect[2], -XYrect[3]);
	ObjEffect_SetVertexXY(obj, 2, XYrect[4], XYrect[5]);
	ObjEffect_SetVertexXY(obj, 3, -XYrect[6], XYrect[7]);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  48, 0);
		ObjEffect_SetVertexUV(obj, 2, 48,  48);
		ObjEffect_SetVertexUV(obj, 3, 0, 48);

		Obj_SetPosition(obj,GetX+GetSpeed*cos(GetAngle),GetY+GetSpeed*sin(GetAngle));
		//Obj_SetPosition(obj,GetX,GetY);
		ObjEffect_SetScale(obj, scax,scay);

		ObjEffect_SetLayer(obj,2);

		//Obj_SetSpeed(obj,1);
		//Obj_SetAngle(obj,-90);
		loop(3)
		{
			Obj_SetY(obj,Obj_GetY(obj)-1);
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,alpha,R,G,B);
			}
			ObjEffect_SetScale(obj, scax,scay);
			scax+=0.3/5;
			scay+=0.3/5;
			alpha-=150/5;
			yield;
		}
		Obj_Delete(obj);
}

task LightModeZakoEffect1(R,G,B,dir)
{

		let scax=1.0;
		let scay=1.0;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
		let alpha=100;
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgCircle);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -128, -128);
	ObjEffect_SetVertexXY(obj, 1,128, -128);
	ObjEffect_SetVertexXY(obj, 2, 128, 128);
	ObjEffect_SetVertexXY(obj, 3, -128, 128);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  256, 0);
		ObjEffect_SetVertexUV(obj, 2, 256,  256);
		ObjEffect_SetVertexUV(obj, 3, 0, 256);

		Obj_SetPosition(obj,GetX,GetY);

		ObjEffect_SetScale(obj, 0.2,0.2);

		ObjEffect_SetLayer(obj,2);

		Obj_SetSpeed(obj,1);
		Obj_SetAngle(obj,-90);

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

		loop
		{
			Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetAngle(obj,0,0,Zangle);
			Zangle+=3*dir;
			yield;
		}
		Obj_Delete(obj);
}


function DrawMagicCircle(Color,scale)
{
		SetTexture(imgCircle);
		SetGraphicRect(0,0,256,256);
		if(Color=="WHITE")
		{
		SetColor(ZakoMagicColor[0],ZakoMagicColor[1],ZakoMagicColor[2]);
		}
		if(Color=="BLUE")
		{
		SetColor(63,82,255);
	//	SetColor(30,50,255);
		}
		SetGraphicAngle(0,0,DrawZakoZAngle);
		SetGraphicScale(scale*MagicCircleScale,scale*MagicCircleScale);	
	//	SetRenderState(ADD);
	//	SetAlpha(100);
		DrawGraphic(GetX,GetY);

		SetGraphicAngle(0,0,-DrawZakoZAngle);
		DrawGraphic(GetX,GetY);
		DrawZakoZAngle+=3;
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		SetAlpha(255);
		SetRenderState(ALPHA);
}

task ZakoMagicCircle(let MagicColor,scale)
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, csd~"..\img\circle.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -128, -128);
		ObjEffect_SetVertexXY(obj, 1, 128, -128);
		ObjEffect_SetVertexXY(obj, 2, 128, 128);
		ObjEffect_SetVertexXY(obj, 3, -128, 128);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  256, 0);
		ObjEffect_SetVertexUV(obj, 2, 256, 256);
		ObjEffect_SetVertexUV(obj, 3, 0,  256);
		ObjEffect_SetScale(obj, scale,scale);
//////////////////////////////////////////////////////////
		let obj2 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj2, csd~"..\img\circle.png");
		ObjEffect_SetPrimitiveType(obj2, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj2, ADD); 
		ObjEffect_CreateVertex(obj2, 4);
		ObjEffect_SetVertexXY(obj2, 0, -128, -128);
		ObjEffect_SetVertexXY(obj2, 1, 128, -128);
		ObjEffect_SetVertexXY(obj2, 2, 128, 128);
		ObjEffect_SetVertexXY(obj2, 3, -128, 128);
		
		ObjEffect_SetVertexUV(obj2, 0,  0,  0);
		ObjEffect_SetVertexUV(obj2, 1,  256, 0);
		ObjEffect_SetVertexUV(obj2, 2, 256, 256);
		ObjEffect_SetVertexUV(obj2, 3, 0,  256);

///////////////////////////////////////////////////////////
		ObjEffect_SetLayer(obj,2);
		let ZAngle=0;
		let Sscale=scale;
		let ScaleAngle=90;
		while(GetLife>0)
		{
			Obj_SetPosition(obj,GetX+GetSpeed*cos(GetAngle),GetY+GetSpeed*sin(GetAngle));
			ObjEffect_SetAngle(obj,0,0,ZAngle);
			Obj_SetPosition(obj2,GetX+GetSpeed*cos(GetAngle),GetY+GetSpeed*sin(GetAngle));
			ObjEffect_SetAngle(obj2,0,0,-ZAngle);
			ObjEffect_SetScale(obj, Sscale,Sscale);
			ObjEffect_SetScale(obj2, Sscale,Sscale);
			Sscale=scale*(1+0.05*cos(ScaleAngle));
			ScaleAngle+=1;
			ZAngle+=3;
			if(MagicColor=="WHITE" && GetDistanceToPlayer<=90)
			{
				ascent(let i in 0..4)
				{
				ObjEffect_SetVertexColor(obj,i,100,255,100,100);
				ObjEffect_SetVertexColor(obj2,i,100,255,100,100);
				}
			}
			else
			{
				ascent(let i in 0..4)
				{
				ObjEffect_SetVertexColor(obj,i,100,255,255,255);
				ObjEffect_SetVertexColor(obj2,i,100,255,255,255);
				}
			}

			yield;
		}
		Obj_Delete(obj);
}

function moveToPlayer03(xMove, yAdd, weight,MaxSpeed, left, top, right, bottom)
{

	if(GetX>GetPlayerX)
	{
		xMove=xMove*-1;
	}

	if(GetX+xMove<left || GetX+xMove>right)
	{
		xMove=xMove*-1;
	}

	if(GetY+yAdd<top || GetY+yAdd>bottom)
	{
		yAdd=yAdd*-1;
	}


	SetMovePosition03(GetX+xMove,GetY+yAdd, weight,MaxSpeed)
}

task ElementalEffect(R,G,B,scale)
{
if(GetCommonDataDefault("LightMode_ElementalBlur",0)==1)
{
	LightModeElementalEffect1(R,G,B,scale,1);
	LightModeElementalEffect1(R,G,B,scale,-1);
}
loop
{
	ElementalEffect1(R,G,B,scale);
yield;
}
}

task ElementalEffect1(R,G,B,scale)
{
		let randrect=3;
	let XYrect=[];
	loop(8)
	{
	XYrect=XYrect~[48/2+rand(-randrect,randrect)];
	}
	if(GetCommonDataDefault("LightMode_ElementalBlur",0)==1){return;}

		let scax=scale;
		let scay=scale;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
		let alpha=200;
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,GetCurrentScriptDirectory~"..\img\CircleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -XYrect[0], -XYrect[1]);
	ObjEffect_SetVertexXY(obj, 1, XYrect[2], -XYrect[3]);
	ObjEffect_SetVertexXY(obj, 2, XYrect[4], XYrect[5]);
	ObjEffect_SetVertexXY(obj, 3, -XYrect[6], XYrect[7]);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  48, 0);
		ObjEffect_SetVertexUV(obj, 2, 48,  48);
		ObjEffect_SetVertexUV(obj, 3, 0, 48);

		ObjEffect_SetLayer(obj,2);

		Obj_SetPosition(obj,GetX+GetSpeed*cos(GetAngle),GetY+GetSpeed*sin(GetAngle));
		//Obj_SetPosition(obj,GetX,GetY);
		ObjEffect_SetScale(obj, scax,scay);
		//Obj_SetSpeed(obj,1);
		//Obj_SetAngle(obj,-90);
		loop(3)
		{
			Obj_SetY(obj,Obj_GetY(obj)-1);
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,alpha,R,G,B);
			}
			ObjEffect_SetScale(obj, scax,scay);
			scax+=0.3/5*2;
			scay+=0.3/5*2;
			alpha-=200/5*2;
			yield;
		}
		Obj_Delete(obj);
}

task LightModeElementalEffect1(R,G,B,scale,dir)
{

		let scax=0.2*scale;
		let scay=0.2*scale;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
		let alpha=250;
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgCircle);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -128, -128);
	ObjEffect_SetVertexXY(obj, 1,128, -128);
	ObjEffect_SetVertexXY(obj, 2, 128, 128);
	ObjEffect_SetVertexXY(obj, 3, -128, 128);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  256, 0);
		ObjEffect_SetVertexUV(obj, 2, 256, 256);
		ObjEffect_SetVertexUV(obj, 3, 0,  256);

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

		Obj_SetPosition(obj,GetX,GetY);
		//Obj_SetPosition(obj,GetX,GetY);
		ObjEffect_SetScale(obj, scax,scay);

		ObjEffect_SetLayer(obj,2);

		Obj_SetSpeed(obj,1);
		Obj_SetAngle(obj,-90);
		loop
		{
			Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetAngle(obj,0,0,Zangle);
			Zangle+=3*dir;
			yield;
		}
		Obj_Delete(obj);
}



task ShotElementalEffect(x,y,R,G,B,scale)
{
if(GetCommonDataDefault("LightMode_ElementalBlur",0)==1)
{
	ShotLightModeElementalEffect1(x,y,R,G,B,scale);
}
	ShotElementalEffect1(x,y,R,G,B,scale);
}

task ShotElementalEffect1(x,y,R,G,B,scale)
{
		let randrect=3;
	let XYrect=[];
	loop(8)
	{
	XYrect=XYrect~[48/2+rand(-randrect,randrect)];
	}
	if(GetCommonDataDefault("LightMode",0)==1){return;}

		let scax=scale;
		let scay=scale;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
		let alpha=200;
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,GetCurrentScriptDirectory~"..\img\CircleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -XYrect[0], -XYrect[1]);
	ObjEffect_SetVertexXY(obj, 1, XYrect[2], -XYrect[3]);
	ObjEffect_SetVertexXY(obj, 2, XYrect[4], XYrect[5]);
	ObjEffect_SetVertexXY(obj, 3, -XYrect[6], XYrect[7]);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  48, 0);
		ObjEffect_SetVertexUV(obj, 2, 48,  48);
		ObjEffect_SetVertexUV(obj, 3, 0, 48);

		ObjEffect_SetLayer(obj,2);

		Obj_SetPosition(obj,x+GetSpeed*cos(GetAngle),y+GetSpeed*sin(GetAngle));
		//Obj_SetPosition(obj,GetX,GetY);
		ObjEffect_SetScale(obj, scax,scay);
		Obj_SetSpeed(obj,1);
		Obj_SetAngle(obj,-90);
		loop(3)
		{
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,alpha,R,G,B);
			}
			ObjEffect_SetScale(obj, scax,scay);
			scax+=0.3/5*2;
			scay+=0.3/5*2;
			alpha-=200/5*2;
			yield;
		}
		Obj_Delete(obj);
}

task ShotLightModeElementalEffect1(x,y,R,G,B,scale)
{

		let scax=0.2*scale;
		let scay=0.2*scale;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
		let alpha=250;
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgCircle);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -128, -128);
	ObjEffect_SetVertexXY(obj, 1,128, -128);
	ObjEffect_SetVertexXY(obj, 2, 128, 128);
	ObjEffect_SetVertexXY(obj, 3, -128, 128);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  256, 0);
		ObjEffect_SetVertexUV(obj, 2, 256, 256);
		ObjEffect_SetVertexUV(obj, 3, 0,  256);
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,alpha,R,G,B);
			}

		Obj_SetPosition(obj,x,y);
		//Obj_SetPosition(obj,GetX,GetY);
		ObjEffect_SetScale(obj, scax,scay);

		ObjEffect_SetLayer(obj,2);

		Obj_SetSpeed(obj,1);
		Obj_SetAngle(obj,-90);
		loop(1)
		{
			Obj_SetPosition(obj,x,y);
			yield;
		}
		Obj_Delete(obj);
}


/*
task ShotEffect(x,y,delay,Alpha,R,G,B)
{
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,csd~"..\img\Light.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

		ObjEffect_SetVertexXY(obj, 0, -32, -32);
		ObjEffect_SetVertexXY(obj, 1,32, -32);
		ObjEffect_SetVertexXY(obj, 2, 32, 32);
		ObjEffect_SetVertexXY(obj, 3, -32, 32);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  64, 0);
		ObjEffect_SetVertexUV(obj, 2, 64, 64);
		ObjEffect_SetVertexUV(obj, 3, 0,  64);
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}

		Obj_SetPosition(obj,x,y);

		ObjEffect_SetLayer(obj,2);

		let Scale=1;

		loop(delay)
		{
			ObjEffect_SetScale(obj, Scale, Scale);
			Scale-=1/delay;
			yield;
		}
		Obj_Delete(obj);
}
*/