script_enemy_main {

	#include_function ".\boss1anim.txt";
    #include_function ".\..\lib\enemyfunctions.txt"
	#include_function ".\spellcard.txt";
	let frame=0;

	@Initialize {
		SetInvincibility(200);
		LoadUserShotData(GetCurrentScriptDirectory~"supershot.txt");
		EnemyInit(25, 10);
		SetCommonData("ROBOARM2", "ALIVE");
		Lifebar;
	}
	
	@MainLoop{
		SetCollisionA(GetX, GetY, 12);
		SetCollisionB(GetX, GetY, 12);
		frame++;
		if(GetCommonData("ROBOARMS")=="ATTACK1" && frame%15==0){
			if(GetCommonData("DIFFICULTY")=="EASY"){
				CreateShot01(GetX, GetY, 2, GetAngleToPlayer, 228, 5);
			}
			if(GetCommonData("DIFFICULTY")=="NORMAL"){
				CreateShot01(GetX, GetY, 2, GetAngleToPlayer+rand(-5, 5), 228, 5);
			}
			if(GetCommonData("DIFFICULTY")=="HARD"){
				CreateShot01(GetX, GetY, 2, GetAngleToPlayer+rand(-15, 15), 228, 5);
			}
			if(GetCommonData("DIFFICULTY")=="LUNATIC"){
				CreateShot01(GetX, GetY, 2, GetAngleToPlayer+rand(-25, 25), 228, 5);
			}
		}
		if(GetCommonData("ROBOARMS")=="ATTACK2" && frame%60==0){
			if(GetCommonData("DIFFICULTY")=="EASY"){
				ascent(i in 0..6){
					CreateShot01(GetX, GetY, 2, GetAngleToPlayer+i*60, 236, 5);
				}
			}
			if(GetCommonData("DIFFICULTY")=="NORMAL"){
				ascent(i in 0..12){
					CreateShot01(GetX, GetY, 2, GetAngleToPlayer+i*30, 236, 5);
				}
			}
			if(GetCommonData("DIFFICULTY")=="HARD"){
				ascent(i in 0..18){
					CreateShot01(GetX, GetY, 2, GetAngleToPlayer+i*20, 236, 5);
				}
			}
			if(GetCommonData("DIFFICULTY")=="LUNATIC"){
				ascent(i in 0..24){
					CreateShot01(GetX, GetY, 2, GetAngleToPlayer+i*15, 236, 5);
				}
			}
		}
		if(GetCommonData("ROBOARMS")=="LASERS" && frame%10==0){
			if(GetCommonData("DIFFICULTY")=="EASY"){
				CreateLaserC(1, GetX, GetY, 10, 20, 236, 10);
				SetLaserDataC(1, 0, 4, GetAngleToPlayer+25, 0, 0, 0);
				FireShot(1);
			}
			if(GetCommonData("DIFFICULTY")=="NORMAL"){
				CreateLaserC(1, GetX, GetY, 12, 20, 236, 10);
				SetLaserDataC(1, 0, 4, GetAngleToPlayer+15, 0, 0, 0);
				FireShot(1);
			}
			if(GetCommonData("DIFFICULTY")=="HARD"){
				CreateLaserC(1, GetX, GetY, 15, 20, 236, 10);
				SetLaserDataC(1, 0, 4, GetAngleToPlayer-25, 0, 0, 0);
				FireShot(1);
				CreateLaserC(1, GetX, GetY, 15, 20, 236, 10);
				SetLaserDataC(1, 0, 4, GetAngleToPlayer+25, 0, 0, 0);
				FireShot(1);
			}
			if(GetCommonData("DIFFICULTY")=="LUNATIC"){
				CreateLaserC(1, GetX, GetY, 18, 20, 236, 10);
				SetLaserDataC(1, 0, 4, GetAngleToPlayer-15, 0, 0, 0);
				FireShot(1);
				CreateLaserC(1, GetX, GetY, 18, 20, 236, 10);
				SetLaserDataC(1, 0, 4, GetAngleToPlayer+15, 0, 0, 0);
				FireShot(1);
			}
		}
		if(GetCommonData("ROBOARMS")=="ATTACK3" && frame%5==0){
			if(GetCommonData("DIFFICULTY")=="EASY"){
				CreateShot01(GetX+rand(-5, 5), GetY+rand(-5, 5), 6, GetAngleToPlayer+15, 222, 5);
				CreateShot01(GetX+rand(-5, 5), GetY+rand(-5, 5), 6, GetAngleToPlayer-15, 222, 5);
			}
			if(GetCommonData("DIFFICULTY")=="NORMAL"){
				CreateShot01(GetX+rand(-5, 5), GetY+rand(-5, 5), 6, GetAngleToPlayer+13, 222, 5);
				CreateShot01(GetX+rand(-5, 5), GetY+rand(-5, 5), 6, GetAngleToPlayer-13, 222, 5);
			}
			if(GetCommonData("DIFFICULTY")=="HARD"){
				CreateShot01(GetX+rand(-5, 5), GetY+rand(-5, 5), 6, GetAngleToPlayer+11, 222, 5);
				CreateShot01(GetX+rand(-5, 5), GetY+rand(-5, 5), 6, GetAngleToPlayer-11, 222, 5);
			}
			if(GetCommonData("DIFFICULTY")=="LUNATIC"){
				CreateShot01(GetX+rand(-5, 5), GetY+rand(-5, 5), 6, GetAngleToPlayer+8, 222, 5);
				CreateShot01(GetX+rand(-5, 5), GetY+rand(-5, 5), 6, GetAngleToPlayer-8, 222, 5);
			}
		}
        yield;
	}
		
	@DrawLoop {
		animb_idle;
	}
	
	@Finalize {
		SetCommonData("ROBOARM2", "DEAD");
	}
}