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

Rain;
Movement;
Pattern(ARROW_RED);
wait(120*3+50);
Pattern(ARROW_BLUE);
wait(120*3+50);
Pattern(ARROW_YELLOW);
}

task Movement{
loop{
wait(60*4);
ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-75,75), GetStgFrameHeight/4+rand(-25,25), 10, 4);
}
}
task Rain{
let counter = 75;
loop{
let random = rand(-10, 10);
	ascent(i in 0..12){
	FireShotA2(random+GetCenterX+i*10*tan(counter), 0, 5, 90, -0.07, 1, RICE_S_GRAY, 20);
	FireShotA2(random+GetCenterX-i*10*tan(counter), 0, 5, 90, -0.07, 1, RICE_S_GRAY, 20);
	yield;
	}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
	wait(40);
}
}
task Pattern(Graph){
wait(180);
	loop{
		let red = 45;
		ascent(j in 0..6){
			ascent(i in 0..9){
			let obj = FireShotA2(BossX, BossY, 1+j, GetAngleToPlayer(objBoss)+red-i*red/4, -j/50, 0, Graph, 15);
			ObjMove_AddPatternA2(obj, 60, NO_CHANGE, NO_CHANGE, 0.1, 0, 10);
			}
			PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
			PlaySoundTime(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 80, 60);
			yield;
		}
	wait(120);
	}
}

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