
#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("Memories &quot;Psyche Doll&quot;", [255,10,0], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/Emotions/ell.png", 25, "Ellen");
Pattern1;
Pattern2;
Pattern3;
}
task Pattern3{
	loop{
	let random = rand(0,360);
	let random2 = rand(1, 2);
		ascent(j in 0..16){
		FireShotA1(BossX, BossY, random2, random+j*360/16, SCALE_RED, 10);
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
	wait(60);
	}
}


task Pattern2{
	loop{
		ascent(i in 0..6){
			ascent(k in 0..4){
				ascent(j in 0..18){
				FireShotA1(BossX, BossY, 4, j*360/18-(k*1.5)-i*12, RICE_S_RED, 20);
				}
				PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
				wait(4);
			}
		wait(12);
		}
		ascent(i in 0..6){
			ascent(k in 0..4){
				ascent(j in 0..18){
				FireShotA1(BossX, BossY, 4, j*360/18+(k*1.5)+i*12, RICE_S_RED, 20);
				}
				PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
				wait(4);
			}
		wait(12);
		}
	}
}

task Pattern1{
let angle = 0;
loop{
	loop(30){
		ascent(j in 0..2){
			ascent(i in 0..5){
			let obj = CreateShotA1(BossX, BossY, 1.5, angle+i*360/5, BALL_M_RED, 5);
			ObjMove_AddPatternA2(obj, 0, NO_CHANGE, NO_CHANGE, 0, 2, 10);
			ObjMove_AddPatternA2(obj, 60, 0, NO_CHANGE, 0, 1, 10);
			ObjMove_AddPatternA2(obj, 190, 1.5, ObjMove_GetAngle(obj)+90, 0.01, 0, 10);
			}
		}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
		angle+=15;
		wait(15);
	}
	loop(30){
		ascent(j in 0..2){
			ascent(i in 0..5){
			let obj = CreateShotA1(BossX, BossY, 1.5, angle-i*360/5, BALL_M_RED, 5);
			ObjMove_AddPatternA2(obj, 0, NO_CHANGE, NO_CHANGE, 0, -2, 10);
			ObjMove_AddPatternA2(obj, 60, 0, NO_CHANGE, 0, 1, 10);
			ObjMove_AddPatternA2(obj, 190, 1.5, ObjMove_GetAngle(obj)-90, 0.01, 0, 10);
			}
		}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
		angle-=15;
		wait(15);
	}
}
}


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