#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Nonspell 1 L"]
#Text["Wooooooop"]

let objBoss;
#include "./Functions/Index.txt"


@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	ObjEnemy_SetDamageRate(objBoss,0,0);
	//ObjMove_SetDestAtSpeed(objBoss,384/2,150,6);
	
	mainTask;	
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(2500);
        }
	case(EV_REQUEST_TIMER){
		SetScriptResult(40);
	}
	case(EV_REQUEST_SPELL_SCORE){
		SetScriptResult(1000000);
	}
} 

let BossX = 0;
let BossY = 0;

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	
	ObjEnemy_SetIntersectionCircleToShot(objBoss,BossX,BossY,24);
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,BossX,BossY,24);
	
	yield;
} 

@Finalize {

} 

task mainTask { 
	renderdiancie(objBoss);
	BottomEnemyMarker(objBoss, objBoss);
	end;
	action;
	BossShotSound(objBoss, 75, 300);
} 

task action{
wait(60);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/charge.wav", 100);
ConcentrationA1(objBoss,"MAGIC",90,4,120,[255,150,255]);
wait(90);
DestroyThePlayerByStormingHimWithALotOfReallyInaccurateBullets;
ObjEnemy_SetDamageRate(objBoss,60,40);
}

task DestroyThePlayerByStormingHimWithALotOfReallyInaccurateBullets {
	let ang = 0;
	let speed = 1.5;
	let modi = 0;
	let angular = 0.01;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
		loop(5){
		let obj = CreateShotA1(ObjMove_GetX(objBoss)+25*cos(ang), ObjMove_GetY(objBoss)+25*sin(ang), speed-0.05, ang, ICE_PINK, 5);
		let obj2 = CreateShotA1(ObjMove_GetX(objBoss)+25*cos(ang), ObjMove_GetY(objBoss)+25*sin(ang), speed, ang, ICE_PINK, 5);
		SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smbullet.wav", 60);
		ObjMove_SetAngularVelocity(obj,angular);
		Gogo(obj,angular);
		ObjMove_SetAngularVelocity(obj2,angular);
		Gogo(obj2,angular);
		ang += 360/5
		}
		ang += 0.5*cos(modi);
		//speed += 0.1*cos(sinn);
		modi += 1;
		angular += 0.1*cos(modi);
		wait(2);
	}
	task Gogo(tar, ang){
	wait(90);
	ObjMove_SetAngularVelocity(tar,ang/2);
	wait(60);
	ObjMove_SetAngularVelocity(tar,ang/4);
	wait(60);
	ObjMove_SetAngularVelocity(tar,0);
	}
}


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

