
#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("Ellen &quot;Timeline of Forgotten Memories&quot;", [255,10,0], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/Emotions/ell.png", 25, "Ellen");
Pattern;
wait(120);
Pattern2;
}

task Pattern2{
let angle = 270;
let count = 0;
loop{
	ascent(i in 0..5){
	FireShotA1(BossX+200*cos(angle), BossY+200*sin(angle), 2, count*25+i*360/5, BALL_M_RED_INV, 25);
	}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
angle=270+90*sin(count*5);
count++;
wait(10);
}
}

task Pattern{
let count = 0;
	loop{
		ascent(i in 0..6){
		FireShotA1(BossX, BossY, 1.7, GetAngleToPlayer(objBoss)+count*10+i*360/6, SCALE_RED, 15); 
		FireShotA1(BossX, BossY, 1.7, GetAngleToPlayer(objBoss)+-count*10-i*360/6, SCALE_RED, 15); 
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
	count++;
	wait(20);
	}
}


task end{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
	SetCommonData("BossAlpha",255);
	SetCommonData("ForceLifebar", 0);
	StartSlow(TARGET_ALL, 15);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/deathstart.wav", 80);
	loop(45){
	ExplodeEffectT(BossX, BossY, rand(1, 20), 1, "Cherry", [255, 10, 10], 10);
	ExplodeEffectT(BossX, BossY, rand(1, 20), 1, "Cherry", [155, 10, 155], 10);
	yield;
	}
	SetCommonData("BossX", BossX);
	SetCommonData("BossY", BossY);
	SetCommonData("SatoriIsDed", 1);
	StopSlow(TARGET_ALL);
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
} 