
#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("Basic Attack &quot;Lone Needle&quot;", [255,10,0], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/Emotions/ell.png", 25, "Ellen");
Pattern;
Pattern2;
Movement;
}

task Movement{
	loop{
	wait(60*4);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/charge.wav", 80);
	loop(3){
	Concentrate(BossX, BossY, 0, 6, 4, 1, "Cherry", 200, -2, [255, 15, 15]);
	Concentrate(BossX, BossY, 0, 6, 4, 1, "Cherry", 200, 2, [255, 15, 15]);
	wait(5);
	}
	wait(30);
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-100,100), GetStgFrameHeight/4+rand(-50,50), 10, 2);
	ascent(i in 0..16){
		ascent(j in 0..4){
		FireShotA1(BossX, BossY, 2+j/2, GetAngleToPlayer(objBoss)+i*360/16-j*10, BALL_M_RED, 15);
		}
	}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
	}
}

task Pattern2{
ascent(i in -9..10){
let obj = CreateStraightLaserA1(BossX, BossY, 270, 600, 25, 99999, BEAM_RED, 0);
MoveLas(obj, i);
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/laser1.wav", 80);
	task MoveLas(obj, off){
	let angle = 270;
	let count = 0;
		loop{
		ObjStLaser_SetAngle(obj, angle+(off*18)*sin(count/1.8));
		ObjMove_SetPosition(obj, BossX, BossY);
		count++;
		yield;
		}
	}
}

task Pattern{
	loop{
		ascent(j in -2..3){
		FireShotA1(BossX, BossY, 2, GetAngleToPlayer(objBoss)-11.25*j, SCALE_ORANGE, 15);
		}
		ascent(i in -2..3){
		FireShotA1(BossX, BossY, 2+i/2, GetAngleToPlayer(objBoss), SCALE_ORANGE, 15);
		}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.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());
} 