
#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(60);
	}
	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("Chaos Sign &quot;Wild Poltergeist&quot;", [10,10,255], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/Emotions/kan.png", 25, "Kana");
loop{
let random = truncate(rand(0, 5));
if(random == 0){Pattern1;}
if(random == 1){Pattern2;}
if(random == 2){Pattern3;}
if(random == 3){Pattern4;}
if(random == 4){Pattern5;}
wait(90);
}

}

task Pattern1{
ascent(j in 0..16){
	ascent(i in 0..5){
	FireShotA1(BossX, BossY, 4, i*360/5+j*8, RICE_S_GRAY, 20);
	}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
wait(10);
}
}

task Pattern2{
ascent(j in 0..12){
	ascent(i in 0..11){
	FireShotA1(BossX, BossY, 2, i*360/11+j*24, BEAM_GREEN, 20);
	}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
wait(15);
}
}

task Pattern3{
let count = 0;
let count2 = 0;
ascent(j in 0..64){
	ascent(i in 0..2){
	FireShotA1(BossX, BossY, 3, i*360/2+count, BALL_S_PURPLE, 20);
	}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 80);
count+=180*sin(count2);
count2++;
wait(2);
}
}

task Pattern4{
	ascent(j in 0..3){
		ascent(i in 0..48){
		FireShotA1(BossX, BossY, 2, i*360/48+j*24, STAR_S_RED, 20);
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
	wait(40);
	}
}

task Pattern5{
	ascent(j in 0..2){
		ascent(i in 0..48){
		let obj = CreateShotA1(BossX, BossY, 3, i*360/32+j*24, BALL_BS_ORANGE, 20);
		let obj2 = CreateShotA1(BossX, BossY, 3, i*360/32+j*24, BALL_BS_ORANGE, 20);
		ObjMove_AddPatternA2(obj, 0, NO_CHANGE, NO_CHANGE, 0, 0.2, 10);
		ObjMove_AddPatternA2(obj2, 0, NO_CHANGE, NO_CHANGE, 0, -0.2, 10);
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
	wait(60);
	}
}

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