
#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/2, 10, 4);
	
	if(GetCommonData("IsStage", false)==false){
	BackgroundKana;
	}
	
	mainTask;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(6000);
     	}
	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 {
} 

let pointer;
task mainTask { 
SpellCard("Insanity Sign &quot;Abandon Lonliness[sic]&quot;", [10,10,255], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/Emotions/kan.png", 25, "Kana");

pointer = CreateShotA1(GetPlayerX, GetPlayerY, 0, 0, 0, 0);
Knives(pointer);
wait(60*3);
ObjMove_SetDestAtWeight(pointer, BossX, BossY, 10, 1);
Movement(pointer);
wait(60*4);
Pattern1;
wait(60*2);
Pattern2;
}

task Movement(obj){
	loop{
	ObjMove_SetDestAtWeight(pointer, BossX, BossY, 10, 1);
	wait(60*5);
	ObjMove_SetDestAtWeight(pointer, GetPlayerX, GetPlayerY, 10, 1);
	wait(60*5);
	}
}

task Pattern1{
	loop{
		ascent(i in 0..6){
		FireShotA1(BossX, BossY, 0.8, GetAngleToPlayer(objBoss)+i*360/6, BILL_RED, 10);
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
	wait(15);
	}
}

task Pattern2{
	loop{
	let random = rand(0,360);
		ascent(i in 0..17){
		FireShotA1(BossX, BossY, 0.8, random+i*360/17, BALL_BS_BLUE, 10);
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
	wait(60);
	}
}

task Knives(obj){
let count = 0;
let rad = 500;
loop{
ascent(i in 0..64){
FireShotA1(ObjMove_GetX(pointer)+rad*cos(i*360/64+count*20), ObjMove_GetY(pointer)+rad*sin(i*360/64+count*20), 7, i*360/64+count*20, KNIFE_GREEN, 20);
}
if(rad>100){rad-=15;}
count++;
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 40);
wait(4);
}
}

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