
#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/4, 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("Magic Sign &quot;Parallel Symmetrical Diagonal Shot&quot;", [255,10,0], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/Emotions/ell.png", 25, "Ellen");
Pattern1;
wait(120);
Pattern2;
}

task Pattern2{
	loop{
		ascent(i in 0..40){
		FireShotA1(GetCenterX+i*5, 0, 1+rand(0,0.5), 90, SCALE_BLUE, 50-i);
		FireShotA1(GetCenterX-i*5, 0, 1+rand(0,0.5), 90, SCALE_BLUE, 50-i);
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
		wait(3);
		}
	wait(60);
	}
}

task Pattern1{
let angle = 0;
loop{
ascent(i in -60..60){
let obj = CreateShotA1(GetCenterX+i*25, 0, 2+0.5*sin(i*15+90), 90+5*sin(i*15+180), BALL_S_RED, 25);
ObjMove_SetAngularVelocity(obj, 0.05);
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
wait(45);
ascent(i in -60..60){
let obj = CreateShotA1(GetCenterX+i*25, 0, 2+0.5*sin(i*15+90), 90+5*sin(i*15+180), BALL_S_RED, 25);
ObjMove_SetAngularVelocity(obj, -0.05);
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
wait(45);
}
}


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