#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Afro non-spell 01 lunatic"]
#Text["Afro non-spell 01 lunatic"]

#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(2);
	setAura(bossObj,64,64,255);
	SetCommonData("bossAttackType",1);
	SetCommonData("bossCircleType",0);
	setInvulnerableTime(bossObj,480);
	
	ObjMove_SetPosition(bossObj,GetCenterX,GetClipMinY-32);
	SetAutoDeleteObject(true);
	mainTask;
}  

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

@MainLoop { yield; } 
@Finalize { } 

task mainTask { 
	yield;
	scriptEnding;	
	ObjMove_SetDestAtSpeed(bossObj,GetCenterX,120,0.4);	
	while(ObjMove_GetSpeed(bossObj) > 0) { yield; } 
	bossAttack = 3;
	PlaySFX(SFX_CH00);
	PlaySFX(SFX_POWER0);		
	concenEffect(bossObj,15,4,64,64,255);
	concenEffect(bossObj,15,4,255,64,64);
	concenEffect(bossObj,15,4,64,255,64);
	concenEffect(bossObj,15,4,255,255,64);
	concenEffect(bossObj,30,3,155,32,255);
	concenEffect(bossObj,30,3,255,255,255);
	concenEffect(bossObj,30,3,255,255,64);		
	wait(90);
	bossAttack = 0;	
	vuur;
} 

task vuur{
	let r = 0;
	let s = 1;
	let dir = 0;
	let dir2 = 0;
	let kleur = 225;
	let c = 0;
	while(!Obj_IsDeleted(bossObj)) { 
		loop(90) { 
			PlaySFX(SFX_TAN00);
			ascent(i in 0..4) { 
				let feverShot = CreateShotA(GetEnemyX-25+r*cos(dir),GetEnemyY-50+r*sin(dir),15);
				let feverShot2 = CreateShotA(GetEnemyX-25+r*cos(dir),GetEnemyY-50+r*sin(dir),15);
				let feverShot3 = CreateShotA(GetEnemyX-25+r*cos(dir),GetEnemyY-50+r*sin(dir),15);
				let feverShot4 = CreateShotA(GetEnemyX-25+r*cos(dir2),GetEnemyY-50+r*sin(dir2),15);
				
				SetShotDataA(feverShot,0,2,dir,0,0,2,225);
				SetShotDataA(feverShot2,0,2,dir+1,0,0.03,2.2,225);
				SetShotDataA(feverShot3,0,2,dir+2,0,0.03,2.4,225);
				
				SetShotDataA(feverShot,5,2,dir,0,0,2,225);
				SetShotDataA(feverShot2,5,2,dir+1,0,0.03,2.2,225);
				SetShotDataA(feverShot3,5,2,dir+2,0,0.03,2.4,225);
				SetShotDataA(feverShot4,0,3,dir2,0,0,0,223);
					
				dir-=360/3 + s * 5;
				dir2+=360/3 + s * 2;
			}
			if(c < 20) { r+=0.5; } 
			if(c >= 20) { r+=1; } 
			c++; 
			wait(4);
		}	
		c = 0;
		loop(90) { 
			PlaySFX(SFX_TAN00);
			ascent(i in 0..4) { 
				let feverShot = CreateShotA(GetEnemyX-25+r*cos(dir),GetEnemyY-50+r*sin(dir),15);
				let feverShot2 = CreateShotA(GetEnemyX-25+r*cos(dir),GetEnemyY-50+r*sin(dir),15);
				let feverShot3 = CreateShotA(GetEnemyX-25+r*cos(dir),GetEnemyY-50+r*sin(dir),15);
				let feverShot4 = CreateShotA(GetEnemyX-25+r*cos(dir2),GetEnemyY-50+r*sin(dir2),15);
				
				SetShotDataA(feverShot,0,3.5,dir,0,0,4.5,228);
				SetShotDataA(feverShot2,0,3.5,dir+1,0,4,3.7,228);
				SetShotDataA(feverShot3,0,3.5,dir+2,0,4,3.9,228);
				
				SetShotDataA(feverShot4,0,4,dir2,0,0,0,227);
					
				dir+=360/3 + s * 5;
				dir2-=360/3 + s * 4;
			}
			if(c < 20) { r-=1; } 
			if(c >= 20) { r-=1.5; } 
			c++; 
			wait(4);
		}			
		c = 0; r = 0; dir = 0; dir2 = 0;
		wait(120);
	}
}

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

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

	CloseScript(GetOwnScriptID());
}
 