script_enemy_main{

let SEfire1=("script\SoundEffects\fire1.wav");
let SElaserm2=("script\SoundEffects\laserm2.wav");
let SEshotm7=("script\SoundEffects\shotm7.wav");
let SEshotb7=("script\SoundEffects\shotb7.wav");
let SEshots6=("script\SoundEffects\shots6.wav");

let angle2=rand(0,360);

let red=0;
let green=0;
let blue=0;
let angle=0;
let type=GetArgument[0];
if(type==0){ red=255; green=80; blue=80; } //Fire
if(type==1){ red=255; green=255; blue=255; } //Metal
if(type==2){ red=0; green=255; blue=255; } //Wood
if(type==3){ red=255; green=255; blue=100; } //Earth
if(type==4){ red=50; green=50; blue=50; } //Water
let angle=GetArgument[1];
let radius=0;

let usespell=0;
let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;
let GRfamiliar=("\script\Images\OtherEffects\SpellCircle1a.png");

@Initialize{
	LoadGraphic(GRfamiliar);

	SetScore(100);
	SetLife(100);
	MagicCircle(false);
}
	
@MainLoop{

if(GetCommonDataDefault("EnemyDead",0)==1){ VanishEnemy; }


if(type==0){
	if(time%120==0 && time>=60){
	let angle1=GetAngleToPlayer;
	let shot1=0;
	let shot2=1 ;
		loop(6){
		CreateShotA(shot1,GetX,GetY,10);
		SetShotDataA(shot1,0,3,angle1,0,0,0,73);
		let delay=0;
			loop(130){
			let radius=rand(0,30);
			let angle2=rand(0,360);
			CreateShotA(shot2,radius*cos(angle2),radius*sin(angle2),10);
			SetShotDataA(shot2,0,0.2,angle1+rand(-20,20),0,0,0,61);
			SetShotKillTime(shot2,30);
			AddShot(delay,shot1,shot2,0);
			delay++;
			}
		FireShot(shot1);
		angle1+=360/6;
		}
	PlaySE(SEfire1);
	}
}

if(type==1){
	if(time%10==0 && time>=40){
		loop(4){
		CreateLaser01(GetX,GetY,4,angle2,100,10,95,0);
		angle2+=360/4;
		}
	angle2+=15;
	PlaySE(SElaserm2);
	}
}

if(type==2){
	if(time%60==0 && time>=60){
	let angle3=rand(0,360);
		loop(6){
		let anglex=rand(0,360);
			loop(10){
			CreateShot02(GetX+20*cos(anglex),GetY+20*sin(anglex),1,angle3,0.05,3,102,10);
			anglex+=360/10;
			}
		angle3+=360/12;
		let anglex=rand(0,360);
			loop(10){
			CreateShot02(GetX+20*cos(anglex),GetY+20*sin(anglex),2,angle3,0.05,4,103,10);
			anglex+=360/10;
			}
		angle3+=360/12;
		}
	PlaySE(SEshotm7);
	}
}

if(type==3){
	if(time%120==0 && time>=120){
	let angle=rand(0,360);
		loop(100){
		CreateShot01(GetX,GetY,rand(1.25,2.5),angle+rand(-3,3),111,10);
		angle+=360/100;
		}
	PlaySE(SEshotb7);
	}
}

if(type==4){
	if(frame>=90 && frame<120 && time%4==0){
	let angle=GetAngleToPlayer+180+60;
	let shot1=0;
		loop(5){
		CreateShotA(shot1,GetX,GetY,10);
		SetShotDataA(shot1,0,3,angle,0,-0.05,0,132);
		SetShotDirectionType(PLAYER);
		SetShotDataA(shot1,60,4,0,0,0,0,132);
		SetShotDirectionType(ABSOLUTE);
		FireShot(shot1);
		angle-=30;
		}
	PlaySE(SEshots6);
	}
if(frame==120){ frame=0; }
}


if(GetCommonData("IncreasePhase")==1){ VanishEnemy; }


SetX(GetCommonData("Boss1X")+radius*cos(angle));
SetY(GetCommonData("Boss1Y")+(radius*cos(time/2))*sin(angle));

if(radius<100){ radius++; }
angle-=1;


time++;
frame++;

}

@DrawLoop{
	SetGraphicScale(0.25,0.25);
	SetTexture(GRfamiliar);
	SetGraphicAngle(0,0,time*2);
	SetColor(red,green,blue);
	SetRenderState(ALPHA);
	SetAlpha(255);
	SetGraphicRect(0,0,200,200);
	DrawGraphic(GetX,GetY);
}

@Finalize{
DeleteEnemyShot(ALL);
}

}