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


let objBoss;

let BossX;
let BossY;

let AttackX;
let AttackY;


#include "./Functions/Index.txt"

Diseasecontroller;

@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	renderyamame(objBoss);
	BossShotSound(objBoss, 100, 600);
	FlameAura(objBoss,[255,25,25],2);
	BottomEnemyMarker(objBoss, objBoss);
	MagicRing(objBoss,false);
	DiseaseBoss(objBoss, 4, 70);
	DrawName("Yamame Kurodani", [200, 200, 20], 11);
	ObjMove_SetDestAtWeight(objBoss,GetStgFrameWidth/2,GetStgFrameHeight/4, 5, 4);
	mainTask;
	end;

} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(4500);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(60);
	}
	case(EV_REQUEST_SPELL_SCORE){
		SetScriptResult(1000000);
	}
	case(EV_PLAYER_REBIRTH){
		SetCommonData("Stacks",0);
	}
} 

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	
	AttackX = BossX+10;
	AttackY = BossY-20;
	
	ObjEnemy_SetIntersectionCircleToShot(objBoss,BossX,BossY,21);
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,BossX,BossY,16);
	yield;
} 

@Finalize {

} 

task mainTask { 
wait(70);
	loop{
	let Dis = 0;
	attack = true;
	wait(15);
		ascent(j in 0..80){
			ascent(i in 0..2){
			let obj2 = CreateShotA2(AttackX, AttackY, 4-(j/50), (j*42)+(i*360/2), -0.02, 1, SMALL_BLUE, 10);
			let obj = CreateShotA2(AttackX, AttackY, 4-(j/50), (j*42)+(i*360/2)+360/4, -0.02, 1, SMALL_BLUE, 10);
				if(Dis==1){
				Disease(obj, 1.2, 24); Dis=0;
				Redirect(obj, j, true);
				}
				if(Dis!=1){
				Redirect(obj, j, false);
				}
			}
		Dis++;
		SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smbullet.wav", 60);
		wait(1);
		}
		Dis=0;
		wait(180);
		ascent(j in 0..80){
			ascent(i in 0..2){
			let obj2 = CreateShotA2(AttackX, AttackY, 4-(j/50), (-j*42)+(i*360/2), -0.02, 1, SMALL_BLUE, 10);
			let obj = CreateShotA2(AttackX, AttackY, 4-(j/50), (-j*42)+(i*360/2)+360/4, -0.02, 1, SMALL_BLUE, 10);
				if(Dis==1){
				Disease(obj, 1.2, 24); Dis=0;
				Redirect(obj, j, true);
				}
				if(Dis!=1){
				Redirect(obj, j, false);
				}
			}
		Dis++;
		SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smbullet.wav", 60);
		wait(1);
		}
		Dis=0;
		wait(50);
	attack = false;
	wait(40);
	ObjMove_SetDestAtWeight(objBoss,GetPlayerX,GetStgFrameHeight/3+rand(-50,5), 15, 4);
	wait(180);
	}
}

	
	task Redirect(obj, time, vir){
	wait(120-time);
	ObjMove_SetAcceleration(obj, -0.01);
	ObjMove_SetMaxSpeed(obj, 0);
	wait(70-time/3);
	if(!Obj_IsDeleted(obj)){
	let directed = CreateShotA2(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, 90, 0.01, 100, SMALL_RED, 5);
	if(vir==true){Disease(directed, 1.2, 24);}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/spirit.wav", 60);
	}
	Obj_Delete(obj);
	}

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