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


let objBoss;

let BossX;
let BossY;

#include "./Functions/Index.txt"


@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	rendernue(objBoss);
	BossShotSound(objBoss, 100, 600);
	BottomEnemyMarker(objBoss, objBoss);
	FlameAura(objBoss,[255,255,255],3);
	ObjMove_SetDestAtWeight(objBoss,384/2,150,2,6);
	mainTask;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(4500);
     	}
	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,BossX,BossY,21);
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,BossX,BossY,16);
	yield;
} 

@Finalize {

} 

task mainTask { 
	wait(60);
	let count = 0;
	let reverse = 1;
	loop{
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/chargelong.wav", 70);
	wait(40);
	attack=true;
	wait(20);
	let ang = 90+45;
	let angle = rand(0, 360);
	ascent(j in 0..15){
		loop(40){
		let obj = CreateShotA2(BossX, BossY, (0.1+1.5*cos(angle*3))+5-(j/4), angle+(ang*2), 0.01, 50, AMULET_BLUE, 0);
		ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
		angle+=360/40;
		}
	angle-=1*reverse;
	ang-=1*reverse;
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/spirit.wav", 70);
	wait(4);
	}
	attack=false;
	wait(60);
	ascent(j in 0..10){
		ascent(i in 0..60){
		CreateShotA2(-100+((j*15)*(reverse*-1))+(i*70), 0,4.2-(j/2), 90, 0.03, 10, LARGE_RED, 5);
		}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smbullet.wav", 70);
	wait(5);
	}
		if(reverse==-1){reverse=1;}
		else{reverse=-1;}
	wait(60);
	}
}

function SpellCard(name){
	let Cutin = GetCurrentScriptDirectory ~ "Functions/img/Cutin.png";
	ObjCutin_SetSpellcardS3(name, 25, 25, 25);
	ObjCutin_LaunchS3("KANAKO", Cutin, "Normal");
	TCallBg;
	bspell = true;
	let objScene = GetEnemyBossSceneObjectID();
	ObjEnemyBossScene_StartSpell(objScene);
	wait(210);
}

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());
} 
