
#include "./default_system/MS_Index.txt"

let objBoss;
let ellen;

let BossX; 
let BossY;

SetCommonData("BossAlpha",255);
SetCommonData("ForceLifebar", 0);

@Initialize {
	objBoss = Cat(-50, -50);
	EnemyMarker(objBoss);
	ellen = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(ellen);
	ObjMove_SetPosition(ellen, GetCommonData("BossX", 1), 	GetCommonData("BossY", 1));
	HitSound(objBoss, 80, 450);
	DamageReduction(objBoss, 0);
	DrawName("Ellen", [255,122,122], 12.7);
	MagicRing(ellen,true);
	FlameAura(ellen,[199, 5, 5],3);
	RenderEllen(ellen);
	ObjMove_SetDestAtWeight(ellen, GetStgFrameWidth/2, GetStgFrameHeight/4, 10, 4);
	
	if(GetCommonData("IsStage", false)==false){
	BackgroundEllen;
	}
	
	Move(objBoss);
	mainTask;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(6000);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(105);
	}
	case(EV_REQUEST_SPELL_SCORE){
		SetScriptResult(1000000);
	}
} 

task Move(objBoss){
SetCommonData("Catalpha",0);
loop(120){ObjMove_SetPosition(objBoss, ObjMove_GetX(ellen), ObjMove_GetY(ellen)); yield;}
SetCommonData("Catalpha",255);
}

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),21);
	yield;
} 

@Finalize {
} 


task mainTask { 
SpellCard("Partner &quot;Sokrates&quot;", [255,10,0], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/Emotions/ell.png", 25, "Sokrates");
ObjMove_SetDestAtWeight(ellen, -220, -220, 10, 4);
ObjMove_SetPosition(objBoss, ObjMove_GetX(ellen), ObjMove_GetY(ellen));
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/kitty.wav", 80);
wait(120);
Mobe;
}

task Mobe{
loop{
	loop(2){
	Strike(1);
	Ring;
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+150, GetStgFrameHeight/3, 10, 4);wait(120);
	Strike(-1);
	Ring;
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2-150, GetStgFrameHeight/3, 10, 4);wait(120);
	Strike(1);
	Ring;
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/4, 10, 4);wait(180);
		loop(6){
		Ring2;
		wait(15);
		}
	wait(120);
	}
	Strike(1);
	Ring;
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+150, GetStgFrameHeight/2, 10, 7);wait(30);
	Strike(-1);
	Ring;
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2-150, GetStgFrameHeight/3, 10, 7);wait(30);
	Strike(1);
	Ring;
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+150, GetStgFrameHeight/3, 10, 7);wait(30);
	Strike(1);
	Ring;
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2-150, GetStgFrameHeight/2, 10, 7);wait(30);
	Strike(1);
	Ring;
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/4, 10, 7);wait(120);
		loop(15){
		Ring2;
		wait(20);
		}
	wait(120);
	}
}

task Ring{
let ran = rand(0,360);
	ascent(i in 0..48){
	FireShotA1(BossX, BossY, 1.5, ran+i*360/48, STAR_M_YELLOW, 10);
	}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
}

task Ring2{
let ran = rand(0,360);
	ascent(i in 0..32){
	FireShotA2(BossX, BossY, 2.5, ran+i*360/32, 0.02, 10, STAR_M_YELLOW, 10);
	}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 80);
}

function Strike(mul){
let angle = 0;
	loop(15){
		ascent(j in 0..2){
			ascent(i in 0..5){
			let obj = CreateShotA1(BossX, BossY, 1.5, angle+i*360/5, STAR_M_ORANGE, 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+angle, 0.01, 0, 10);
			}
		}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 80);
		angle+=15*mul;
		wait(2);
	}
}


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