#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["SP1"]
#Text["Baaaaaaaaaap"]
#System["./default_system/Default_System.txt"]
#include "./default_system/MS_Index.txt"

let objBoss;

let BossX; 
let BossY;

@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	HitSound(objBoss, 80, 450);
	EnemyMarker(objBoss);
	DamageReduction(objBoss, 1);
	DrawName("Aunn Komano", [40,140,90], 12.7);
	MagicRing(objBoss,true);
	RenderCharacter(objBoss);
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2.85, 10, 4);
	mainTask;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(4000);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(105);
	}
	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("Guard Sign &quot;Anti-Spirit Ward&quot;", [40,140,90], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/AunnCutin.png", 25);
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/charge.wav", 255);
	loop(8){
	Concentrate(BossX, BossY, 0, 4, 4, 1, "Cherry", 200, -2, [125, 15, 125]);
	Concentrate(BossX, BossY, 0, 4, 4, 1, "Cherry", 200, 2, [255, 255, 255]);
	wait(5);
	}
Pattern;
}

let point;
task Pattern{
point = CreateShotA1(GetStgFrameWidth/2, 50, 0, 0, 0, 0);
Move(point);

loop{
Attack(7*12);
ascent(i in 0..5){
	ascent(j in 0..12){
	let obj = CreateShotA2(BossX+25*cos(j*360/12+i*4), BossY+25*sin(j*360/12+i*4), 2, j*360/12+i*4, -0.05, 0, RICE_M_PURPLE, 15);
	Redirect(obj, j*360/12);
	}
	ascent(j in 0..12){
	let obj = CreateShotA2(BossX+25*cos(j*360/12-i*4), BossY+25*sin(j*360/12-i*4), 2, j*360/12-i*4, -0.05, 0,  RICE_M_YELLOW, 15);
	Redirect(obj, j*360/12);
	}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
	wait(7);
}
ascent(i in 0..16){
CreateShotA1(BossX, BossY, 3, i*360/16, RICE_S_GRAY, 10); CreateShotA1(BossX, BossY, 3.5, i*360/16, RICE_S_GRAY, 10);
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
wait(30);
ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-50, 50), GetStgFrameHeight/2.85+rand(-25, 25), 15, 3);
}

task Redirect(obj, off){
let ang = ObjMove_GetAngle(obj);
wait(60);
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
ObjMove_SetDestAtWeight(obj, ObjMove_GetX(point)+50*cos(off), ObjMove_GetY(point)+50*sin(off), 15, 3);
wait(90);
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
ObjMove_AddPatternA2(obj, 0, 1, ang, 0.02, 0, 4);
}

task Move(point){
let counter = 0;
while(!Obj_IsDeleted(point)){
ObjMove_SetPosition(point, GetStgFrameWidth/2+125*sin(counter) ,50);
counter++;
yield;
}
}
}

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