
#include "./default_system/MS_Index.txt"

let objBoss;

let BossX; 
let BossY;

SetCommonData("BossAlpha",255);

@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	HitSound(objBoss, 80, 450);
	EnemyMarker(objBoss);
	DamageReduction(objBoss, 0);
	DrawName(" Kana", [122,122,255], 12.7);
	MagicRing(objBoss,true);
	FlameAura(objBoss,[5, 5, 199],3);
	RenderKana(objBoss);
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/4, 10, 4);
	
	if(GetCommonData("IsStage", false)==false){
	BackgroundKana;
	}
	
	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);
	loop{
	ascent(i in 0..4){
	let angle = rand(0,360);
			ascent(j in 0..16){
			let obj = CreateShotA1(BossX, BossY, 5, angle+j*360/16, VORTEX_RED, 15);
			ObjMove_AddPatternA2(obj, 0, NO_CHANGE, NO_CHANGE, -0.1, 2, 1);
			ObjMove_AddPatternA2(obj, 60, NO_CHANGE, NO_CHANGE, 0.1, 0.2, 3);
			Fire(obj, -1, angle+j*360/16);
			}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
		wait(70);
	}
	ascent(i in 0..4){
	let angle = rand(0,360);
			ascent(j in 0..16){
			let obj2 = CreateShotA1(BossX, BossY, 5, angle+j*360/16, VORTEX_RED, 15);
			ObjMove_AddPatternA2(obj2, 0, NO_CHANGE, NO_CHANGE, -0.1, -2, 1);
			ObjMove_AddPatternA2(obj2, 60, NO_CHANGE, NO_CHANGE, 0.1, -0.2, 3);
			Fire(obj2, 1, angle+j*360/16);
			}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
		wait(70);
	}
	}
	
	task Fire(obj, off, angle){
	wait(60);
		ascent(i in 0..6){
			if(ObjMove_GetY(obj) < GetPlayerY && !Obj_IsDeleted(obj) ){
			let obj2 = FireShotA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, 0, FIREBALL_RED, 20);
			ObjMove_AddPatternA2(obj2, 20, 6, angle+(i*7*off), -0.2, 0, 2);
			}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
		wait(7);
		}
	}
	
}


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