#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Nonspell1"]
#Text["Woop"]


let objBoss;

let BossX;
let BossY;


#include "./Functions/Index.txt"
#include "./Functions/Dialogue.txt"


@Initialize {

	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	renderkanako(objBoss);
	BossShotSound(objBoss, 100, 600);
//	MagicRing(objBoss,true);
	KanakoAura(objBoss, true);
	BottomEnemyMarker(objBoss, objBoss);
	DrawName("Kanako Yasaka", [20, 20, 200], 11);
	ObjMove_SetPosition(objBoss,  GetStgFrameWidth/2, GetStgFrameHeight/3);
	Maintask;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(5000);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(50);
	}
	case(EV_REQUEST_SPELL_SCORE){
		SetScriptResult(1000000);
	}
} 

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	
	if(invisible==false){
	ObjEnemy_SetIntersectionCircleToShot(objBoss,BossX,BossY,21);
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,BossX,BossY,16);
	}
	
	if(GetPlayerInvincibilityFrame<=0){invisible=false;}
	else{invisible=true;}
	
	yield;
} 

@Finalize {

} 


task Maintask{
wait(60);
Sticks(objBoss, true);
wait(180);
Pattern;
}

task Pattern{
loop{
	ascent(i in 0..32){
		ascent(j in 0..4){
		let obj = CreateShotA2(BossX+60, BossY-20, 4, -50+(j*6), -0.08, 0, ICE_RED, 10);
		let obj2 = CreateShotA2(BossX-60, BossY-20, 4, 180+50-(j*6), -0.08, 0, ICE_RED, 10);
		ObjMove_AddPatternA3(obj, 60, 2, 0+i*12, 0.02, 0, 5, NO_CHANGE);
		ObjMove_AddPatternA3(obj2, 60, 2, 0+i*12, 0.02, 0, 5, NO_CHANGE);
		}
		SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smbullet.wav", 60);
		wait(1);
	}
	wait(10);
	ascent(i in 0..6){
		ascent(j in 0..8){
		let obj = CreateShotA2(BossX+60, BossY-20, 4, -70+(j*10), -0.08, 0, ICE_GREEN, 10);
		let obj2 = CreateShotA2(BossX-60, BossY-20, 4, 180+70-(j*10), -0.08, 0, ICE_GREEN, 10);
		Redirect(obj);
		Redirect(obj2);
		}
		SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smbullet.wav", 60);
		wait(4);
	}
	wait(20);
	ascent(i in 0..32){
		ascent(j in 0..4){
		let obj = CreateShotA2(BossX+60, BossY-20, 4, -50+(j*6), -0.08, 0, ICE_BLUE, 10);
		let obj2 = CreateShotA2(BossX-60, BossY-20, 4, 180+50-(j*6), -0.08, 0, ICE_BLUE, 10);
		ObjMove_AddPatternA3(obj, 60, 2, 180-i*12, 0.02, 0, 5, NO_CHANGE);
		ObjMove_AddPatternA3(obj2, 60, 2, 180-i*12, 0.02, 0, 5, NO_CHANGE);
		}
		SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smbullet.wav", 60);
		wait(1);
	}
	wait(10);
	ascent(i in 0..6){
		ascent(j in 0..8){
		let obj = CreateShotA2(BossX+60, BossY-20, 4, -70+(j*10), -0.08, 0, ICE_GREEN, 10);
		let obj2 = CreateShotA2(BossX-60, BossY-20, 4, 180+70-(j*10), -0.08, 0, ICE_GREEN, 10);
		Redirect(obj);
		Redirect(obj2);
		}
		SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smbullet.wav", 60);
		wait(4);
	}
	wait(20);
}

	task Redirect(obj){
	wait(60);
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/spirit.wav", 60);
	ObjMove_AddPatternA3(obj, 0, 2, GetAngleToPlayer(obj), 0.07, 0, 8, NO_CHANGE);
	}
}


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