#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Fifi-chan non-spell 01 hard"]
#Text["Fifi-chan non-spell 01 hard"]

let freeze = false;

#include "script/thdcs/system/shotlibrary.txt"
#include "script/thdcs/functions/function_common.txt"
#include "script/thdcs/functions/function_global.txt"
#include "script/thdcs/functions/function_bosseff.txt"

@Initialize {
	renderBoss(11);
	setAura(bossObj,255,64,64);
	SetCommonData("bossAttackType",1);
	SetCommonData("bossCircleType",0);
	setInvulnerableTime(bossObj,120);
	
	ObjMove_SetDestAtSpeed(bossObj,192,120,5);
	SetShotAutoDeleteClip(16,16,16,16);	
	SetAutoDeleteObject(true);
	mainTask;
} 

@Event { 
	alternative(GetEventType()) 
	case(EV_REQUEST_LIFE) { 
		SetScriptResult(300);
	}
	case(EV_REQUEST_TIMER) { 
		SetScriptResult(43);
	}
} 

@MainLoop { yield; } 
@Finalize { } 


task mainTask { 
	yield;
	scriptEnding;		
	wait(90);
	fire;
} 

task fire {
	let dir = 270;
	bossAttack = 1;
	wait(30);
	while(!Obj_IsDeleted(bossObj)) {
		PlaySFX(SFX_TAN00);
		ascent(i in 0..4) { 
			let fifiShot00 = CreateShotA1(bossX-18,bossY-40,4+(i/3),dir,209,5);
			fifiShotHandle(fifiShot00,dir);
		}
		dir+=360/23.5;
		wait(8);
	}
}

task fifiShotHandle(obj,dir) {
	ObjMove_SetAcceleration(obj,-0.04);
	ObjMove_SetMaxSpeed(obj,0);
	wait(60);
	let fifiShot01 = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,dir,210,15);
	let fifiShot02 = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,dir,210,15);
	Obj_Delete(obj);
	PlaySFX(SFX_KIRA00);
	ObjMove_SetAcceleration(fifiShot01,0.04);
	ObjMove_SetMaxSpeed(fifiShot01,1.5);
	ObjMove_SetAngularVelocity(fifiShot01,rand(0.3,2.8));
	
	ObjMove_SetAcceleration(fifiShot02,0.04);
	ObjMove_SetMaxSpeed(fifiShot02,1.5);	
	ObjMove_SetAngularVelocity(fifiShot02,-rand(0.3,2.8));	
	
	wait(60);
	ObjMove_SetAngularVelocity(fifiShot01,0.3);
	ObjMove_SetAngularVelocity(fifiShot02,0.3);
}

task scriptEnding {
	while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0) {
		yield;
	}

	DeleteShotAll(TYPE_ALL, TYPE_ITEM);
	Obj_Delete(bossObj);

	CloseScript(GetOwnScriptID());
}
 