function EnemyBossMainLoopSystem(let r,let inv)
{
	SetShotDirectionType(ABSOLUTE);
	
	if(inv)
	{
		SetDamageRate(0,0);
	}
	else
	{
		if(!OnEnemySpell){SetDamageRate(100,50);}
		else
		{
			SetDamageRate(20,10);
			if(GetMissCountInThisSpell>0||GetBombCountInThisSpell>0)
			{
				spellbonus=0;
				spell_getflg=false;
			}
		}
		if(r>0)
		{
			SetCollisionA(GetX,GetY,r);
			SetCollisionB(GetX,GetY,r*0.3);
		}
		
		if(GetHitCount>1)
		{
			SetCommonData("EnemyHitCount",GetCommonDataDefault("EnemyHitCount",0)+GetHitCount);
		}
	}
	enemylife=GetEnemyLife;
	spelltimer=GetTimer;
	if(spelltimer<=0){AddLife(-GetEnemyLife);}
}


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);}