
#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(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;Ghosty Trickster&quot;", [10,10,255], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/Emotions/kan.png", 25, "Kana");

Knives;

	loop{
	wait(60*4);
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-100,100), GetStgFrameHeight/4+rand(-50,50), 10, 4);
	Pattern1;
	Pattern2(1);
	wait(60*4);
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-100,100), GetStgFrameHeight/4+rand(-50,50), 10, 4);
	Pattern1;
	Pattern2(-1);
	}
}

task Pattern1{
ascent(i in 0..32){
FireShotA1(BossX, BossY, 3, i*360/32, RICE_S_GRAY, 20);
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
}

task Pattern2(mult){
	ascent(j in 0..22){
		ascent(i in 0..22){
		FireShotA1(BossX, BossY, 2+j/10, i*360/22+j*1*mult, SCALE_RED, 20);
		}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 80);
		wait(6);
	}
}

task Knives{
	loop{
	FireShotA1(GetPlayerX+rand(-50, 50), 50, rand(1, 3), 90, KNIFE_BLUE_INV, 10);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
	wait(5);
	}
}

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