
#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);
	ObjMove_SetPosition(objBoss, GetCommonData("BossX", 1), 	GetCommonData("BossY", 1));
	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(4000);
     	}
	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("Spell background test!", [255,10,0], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/Emotions/Koi1.png", 25);
wait(120);	
Fire;
loop{
let angle = 0;
	ascent(i in 0..999999999){
		ascent(j in 0..19){
		FireShotA2(BossX+100*cos(angle), BossY+100*sin(angle), 1, j*360/19+i*12, 0.1, 5, SCALE_RED, 15);
		FireShotA2(BossX+100*cos(angle+180), BossY+100*sin(angle+180), 1, j*360/19+i*12, 0.1, 5, SCALE_RED, 15);
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
	angle+=360/24;
	wait(25);
	}
}
}

task Fire{
	loop{
		let red = 22.5;
		ascent(i in 0..5){
		FireShotA1(BossX, BossY, 1.5, GetAngleToPlayer(objBoss)+red-i*red/2, BALL_M_RED, 15);
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
	wait(120);
	}
}


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