
#include "./default_system/MS_Index.txt"

let objBoss;

let BossX; 
let BossY;

SetCommonData("BossAlpha",255);
SetCommonData("ForceLifebar", 0);

@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	HitSound(objBoss, 80, 450);
	EnemyMarker(objBoss);
	DamageReduction(objBoss, 0);
	DrawName("Ellen", [255,122,122], 12.7);
	MagicRing(objBoss,true);
	FlameAura(objBoss,[199, 5, 5],3);
	RenderEllen(objBoss);
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2, 10, 4);
	
	if(GetCommonData("IsStage", false)==false){
	BackgroundEllen;
	}
	
	mainTask;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(6000);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(105);
	}
	case(EV_REQUEST_SPELL_SCORE){
		SetScriptResult(1000000);
	}
} 

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),21);
	yield;
} 

@Finalize {
} 


task mainTask { 
SpellCard("Dream Sign &quot;Splash Stars&quot;", [255,10,0], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/Emotions/ell.png", 25, "Ellen");
Pattern;
wait(280);
Pattern2;
}

task Pattern2{
	loop{
		ascent(i in 0..16){
			ascent(j in 0..4){
			FireShotA1(BossX, BossY, 2+j/2, GetAngleToPlayer(objBoss)+i*360/16, STAR_M_YELLOW, 45);
			}
		}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
		wait(30);
		ascent(j in 0..2){
			ascent(i in 0..16){
			FireShotA1(BossX, BossY, 2+j/2, GetAngleToPlayer(objBoss)+i*360/16, STAR_S_YELLOW, 45);
			}
		wait(20);
		}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
		wait(60);
		ascent(i in 0..16){
			ascent(j in 0..4){
			FireShotA1(BossX, BossY, 2+j/2, GetAngleToPlayer(objBoss)+i*360/16, STAR_M_GREEN, 45);
			}
		}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
		wait(30);
		ascent(j in 0..2){
			ascent(i in 0..16){
			FireShotA1(BossX, BossY, 2+j/2, GetAngleToPlayer(objBoss)+i*360/16, STAR_S_GREEN, 45);
			}
		wait(20);
		}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
		wait(60);
	}
}

task Pattern{
let angle = 0;
let angle2 = 0;
let rad = 0;
let switch = 0;
	loop{
		ascent(i in 0..10){
			FireShotA1(BossX+rad*cos(-i*360/10), BossY+rad*sin(-i*360/10), 0.5, -i*360/10+angle, STAR_S_YELLOW, 25);
			FireShotA1(BossX+rad*cos(-i*360/10), BossY+rad*sin(-i*360/10), 0.5, -i*360/10-angle, STAR_S_GREEN, 25);
		}
	if(rad<300 && switch == 0){rad+=25;}
	if(rad>155 && switch == 1){rad-=5;}
	if(rad>290 && switch == 0){switch=1;}
	if(angle<125 && switch == 0){angle+=6;}
	if(angle<125 && switch == 1){angle+=12;}
	if(switch == 0){wait(5);}
	if(switch == 1){wait(15);}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
	}
}


task end{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
} 