#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["SP3"]
#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("Spinning Top &quot;Koma-Inu's Unrelenting Grounds", [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;
}

task Pattern{
loop{
let random = rand(0,360);
	ascent(i in 0..7){
	let obj = CreateCurveLaserA1(BossX, BossY, 2, random+i*360/7, 75, 30, LASER_RED, 10);
	ObjCrLaser_SetTipDecrement(obj, 0);
	Curv(obj, 1);
	}
	descent(i in 0..7){
	let obj = CreateCurveLaserA1(BossX, BossY, 3.5, random+i*360/7, 75, 30, LASER_RED, 10);
	ObjCrLaser_SetTipDecrement(obj, 0);
	Curv(obj, -1);
	}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/laser1.wav", 70);
	wait(30);
	ascent(k in 0..12){
		ascent(i in 0..3){
			ascent(j in 0..24){
			let obj = CreateShotA2(BossX+50*cos(random+j*360/24), BossY+50*sin(random+j*360/24), 1.8, random+j*360/24, -0.03, 0, RICE_S_RED, 15);
			Redirect(obj, j*360/24+k*7);
			}
			PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 80);
			wait(5);
		}
	}
	wait(180);
}
	
task Redirect(obj, off){
let ang = ObjMove_GetAngle(obj);
wait(80);
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 60);
ObjMove_AddPatternA2(obj, 0, 3, ang+off, 0.01, 0, 10);
}
	
task Curv(obj, mult){
ObjMove_SetAngularVelocity(obj, 3*mult);
wait(60);
ObjMove_SetAngularVelocity(obj, 1.5*mult);
wait(60*3);
ObjMove_SetAngularVelocity(obj, 6*mult);
wait(60);
ObjMove_SetAcceleration(obj, 0.04);
ObjMove_SetMaxSpeed(obj, 10);
ascent(i in 0..10){
ObjMove_SetAngularVelocity(obj, (1-i/10)*mult);
wait(10);
}
}
}

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