script_enemy_main{

let shot1=0;
let bullet1=[];
let timer1=[];

let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

@Initialize{
	SetScore(1);
	SetLife(100);
}
	
@MainLoop{

if(GetX<=minx-100 || GetX>=maxx+100 || GetY<=miny-100 || GetY>=maxy+100 && frame>=60){ VanishEnemy; }

if(GetCommonData("Difficulty")==1){

SetSpeed(1.75);
SetAngle(GetArgument);

let shot1=0;
	loop(2){
	CreateShotA(shot1,GetX,GetY,0);
	SetShotDataA(shot1,0,rand(1.5,3.5),rand(0,360),0,-0.05,0,47);
	SetShotKillTime(shot1,rand_int(20,30));
	FireShot(shot1);
	}
let shot1=0;
	loop(2){
	shot1=(Obj_Create(OBJ_LASER));
	Obj_SetPosition(shot1,GetX,GetY);
	Obj_SetAngle(shot1,rand(0,360));
	ObjLaser_SetLength(shot1,rand_int(0,60));
	ObjLaser_SetWidth(shot1,5);
	ObjLaser_SetSource(shot1,false);
	ObjShot_SetGraphic(shot1,195);
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
	}

let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){
	bullet1=erase(bullet1,i); timer1=erase(timer1,i);
	i--;
	}
	else{
	if(timer1[i]>=7){ Obj_Delete(bullet1[i]); }
	Obj_SetPosition(bullet1[i],GetX,GetY);
	timer1[i]=timer1[i]+1;
	}
i++;
}

} //Easy

//================================================================================================

if(GetCommonData("Difficulty")==2){

SetSpeed(1.5);
SetAngle(GetArgument);

let shot1=0;
	loop(2){
	CreateShotA(shot1,GetX,GetY,0);
	SetShotDataA(shot1,0,rand(1.5,3.5),rand(0,360),0,-0.05,0,47);
	SetShotKillTime(shot1,rand_int(20,30));
	FireShot(shot1);
	}
let shot1=0;
	loop(2){
	shot1=(Obj_Create(OBJ_LASER));
	Obj_SetPosition(shot1,GetX,GetY);
	Obj_SetAngle(shot1,rand(0,360));
	ObjLaser_SetLength(shot1,rand_int(0,60));
	ObjLaser_SetWidth(shot1,5);
	ObjLaser_SetSource(shot1,false);
	ObjShot_SetGraphic(shot1,195);
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
	}

let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){
	bullet1=erase(bullet1,i); timer1=erase(timer1,i);
	i--;
	}
	else{
	if(timer1[i]>=7){ Obj_Delete(bullet1[i]); }
	Obj_SetPosition(bullet1[i],GetX,GetY);
	timer1[i]=timer1[i]+1;
	}
i++;
}

} //Normal

//================================================================================================

if(GetCommonData("Difficulty")==3){

SetSpeed(1.25);
SetAngle(GetArgument);

let shot1=0;
	loop(2){
	CreateShotA(shot1,GetX,GetY,0);
	SetShotDataA(shot1,0,rand(1.5,3.5),rand(0,360),0,-0.05,0,47);
	SetShotKillTime(shot1,rand_int(20,30));
	FireShot(shot1);
	}
let shot1=0;
	loop(2){
	shot1=(Obj_Create(OBJ_LASER));
	Obj_SetPosition(shot1,GetX,GetY);
	Obj_SetAngle(shot1,rand(0,360));
	ObjLaser_SetLength(shot1,rand_int(0,60));
	ObjLaser_SetWidth(shot1,5);
	ObjLaser_SetSource(shot1,false);
	ObjShot_SetGraphic(shot1,195);
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
	}

let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){
	bullet1=erase(bullet1,i); timer1=erase(timer1,i);
	i--;
	}
	else{
	if(timer1[i]>=7){ Obj_Delete(bullet1[i]); }
	Obj_SetPosition(bullet1[i],GetX,GetY);
	timer1[i]=timer1[i]+1;
	}
i++;
}

} //Hard

//================================================================================================

if(GetCommonData("Difficulty")==4){

SetSpeed(1);
SetAngle(GetArgument);

let shot1=0;
	loop(2){
	CreateShotA(shot1,GetX,GetY,0);
	SetShotDataA(shot1,0,rand(1.5,3.5),rand(0,360),0,-0.05,0,47);
	SetShotKillTime(shot1,rand_int(20,30));
	FireShot(shot1);
	}
let shot1=0;
	loop(2){
	shot1=(Obj_Create(OBJ_LASER));
	Obj_SetPosition(shot1,GetX,GetY);
	Obj_SetAngle(shot1,rand(0,360));
	ObjLaser_SetLength(shot1,rand_int(0,60));
	ObjLaser_SetWidth(shot1,5);
	ObjLaser_SetSource(shot1,false);
	ObjShot_SetGraphic(shot1,195);
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
	}

let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){
	bullet1=erase(bullet1,i); timer1=erase(timer1,i);
	i--;
	}
	else{
	if(timer1[i]>=7){ Obj_Delete(bullet1[i]); }
	Obj_SetPosition(bullet1[i],GetX,GetY);
	timer1[i]=timer1[i]+1;
	}
i++;
}

} //Lunatic


time++;
frame++;

}

@DrawLoop{
}

@Finalize{
let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){
	bullet1=erase(bullet1,i); timer1=erase(timer1,i);
	i--;
	}
	else{
	Obj_Delete(bullet1[i]);
	}
i++;
}
}

}