#東方弾幕風[Single]
#ScriptVersion[3]
#Title["SP7"]
#Text["Blep"]
#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);
	
	EnemyMarker(objBoss);
	HitSound(objBoss, 50, 450);
	RenderCharacter(objBoss);
	DamageReduction(objBoss, 320);
	
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2-120, 10, 4);
	
	if(GetCommonData("IsStage", false)==false){
	LoadAssets;}
	
	Main;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(5000);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(55);
	}
	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);
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),24);
	yield;
} 

@Finalize {
} 

task Main { 
	let path = GetCurrentScriptDirectory ~ "./default_system/img/Ingame/cutin.png";
	SpellCard(210, "", [255, 60, 60], path, path, 20, 0.75, "Okina");
	
	loop{
	ascent(j in 0..6){
	ReimuSpread(j*360/6, 3, 4);
	wait(3);
	}
	wait(90);
	Ring1;
	Ring2;
	}
}

task Ring2{
let random = truncate(rand(-2, 2));
let random2 = rand(0,360);
ascent(i in 0..32){
let obj = FireShotA1(BossX, BossY, 2, random2+i*360/32, ORB_M_PURPLE, 10);
Angular(obj, random/2);
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
}

task Ring1{
let random = rand(0,360);
ascent(j in 0..4){
ascent(i in 0..48){
FireShotA1(BossX, BossY, 1+j/2, random+i*360/48, RICE_S_PINK, 10);
}
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
}

task ReimuSpread(ang, spd, mult){
let rad = 5;
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 90, 0);
	ascent(j in 0..5){
		ascent(k in 0..5){
		let obj = FireShotA2(BossX, BossY, spd+j/mult, ang+10-k*5, -0.05, 0, AMULET_PURPLE, 10);
		Redirect(obj);
		}
	}
	
	task Redirect(obj){
	wait(60);
	ObjShot_SetGraphic(obj, ORB_S_PURPLE);
	wait(10);
	ObjMove_AddPatternA2(obj, 0, 3, GetAngleToPlayer(obj), -0.075, 0, 0);
	ObjShot_SetGraphic(obj, AMULET_WHITE);
	wait(60);
	ObjShot_SetGraphic(obj, ORB_S_WHITE);
	wait(10);
	ObjMove_AddPatternA2(obj, 0, 4, GetAngleToPlayer(obj), 0, 0, 5);
	ObjShot_SetGraphic(obj, AMULET_PURPLE);
	}
}

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


