function EnemyMainLoopSystem(let r)
{
	SetShotDirectionType(ABSOLUTE);
	
	if(!vanishflg)
	{
		SetCollisionA(GetX,GetY,r);
		SetCollisionB(GetX,GetY,r*0.3);
		SetDamageRate(100,50);
	
		if(GetHitCount>1)
		{
			SetCommonData("EnemyHitCount",GetCommonDataDefault("EnemyHitCount",0)+GetHitCount);
		}
	}
	
	if(GetLife<lifelimit){vanishflg=true;}
	
	let limit=40;
	if(GetX<=minX-limit || GetX>=maxX+limit || GetY<=minY-limit || GetY>=maxY+limit){vanishflg=true;VanishEnemy;}
}



function schMove(let x,let y,let sch)
{
	let toAngle=atan2(y-GetY,x-GetX);
	let dangle=sch;
	let ret=toAngle-enemyangle;
	if((ret>0&&ret<=180)||(ret<0&&ret<=-180)){enemyangle+=dangle;}
	else if((ret>0&&ret>180)||(ret<0&&ret>-180)){enemyangle+=-dangle;}
	if(enemyangle>=180){enemyangle+=-360;}
	if(enemyangle<-180){enemyangle+=360;}
	SetAngle(enemyangle);
}



function wait(n){loop(n){yield;}}
function GetGapLength(x1,y1,x2,y2){return((x2-x1)^2+(y2-y1)^2)^0.5;}
function GetGapX(x,gapLength,gapAngle){return x+gapLength*cos(gapAngle);}
function GetGapY(y,gapLength,gapAngle){return y+gapLength*sin(gapAngle);}