#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["SP4"]
#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/3, 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("Koma Sign &quot;Faithful Pilgrimage Towards The Shrine&quot;", [40,140,90], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/AunnCutin.png", 25);
Attack(9999999999);
Pattern;
wait(60*5);
Pattern2;
}

task Pattern2{
loop{
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);
	}
let random = rand(0,360);
ascent(i in 0..6){
	ascent(j in 0..6){
	let obj = CreateShotA2(BossX, BossY, 1+i, random+j*360/6+i*7, -0.04, 0, RICE_M_PURPLE, 10);
	Red(obj, i);
	}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
wait(6);
}
wait(60*3);
random = rand(0,360);
ascent(i in 0..6){
	ascent(j in 0..6){
	let obj = CreateShotA2(BossX, BossY, 1+i, random+j*360/6-i*7, -0.04, 0, RICE_M_PURPLE, 10);
	Red(obj, i);
	}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
wait(6);
}
wait(60*3);
}

task Red(obj, i){
let spd = ObjMove_GetSpeed(obj);
wait(120+i*10);
let ang = GetAngleToPlayer(objBoss);
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 60);
ObjMove_AddPatternA2(obj, 0, spd,ang, 0.02, 0, 10);
}
}

task Pattern{
loop{
let random = rand(-1, 1);
let random2 = rand(-10, 10);
let obj = CreateShotB2(BossX, BossY, random+3/2.7, -2.5, 0, 0.02, 10, 10, BALL_M_PURPLE, 10);
let obj2 = CreateShotB2(BossX, BossY, random-3/2.7, -2.5, 0, 0.02, 10, 10, BALL_M_PURPLE, 10);
Fall(obj,random2);
Fall(obj2,random2);
ascent(i in -3..4){
let obj3 = CreateShotB2(BossX, BossY, random+i/2.7, -2.5, 0, 0.02, 10, 10, BALL_S_BLUE, 10);
Fall(obj3,random2);
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 80);
wait(30);
}

	task Fall(obj,random){
	wait(120);
	ObjMove_AddPatternA2(obj, 0, 0.5, 90+random, 0.03, 0, 10);
	}
}

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