#e
#Title[tuC'est printempsv]
#Text[ǂݕ́uEՂ񂽂v
tXŁutł[v]
#BGM[.\..\bgm\bgm.wav]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{
	
	@Initialize{
		imgBoss = imgBoss_LilyWhite;
		InitializeData();
		InitializeAction();
		
		SetLife(1000);
		Warp(CenterX,MinY + 130,40);
		SetDamageRate(8,3);
		SetCollisionEx(32,16,false,240);
		SetEnemyMarker(true);
		
		TMain();
	}
	
	@MainLoop{
		yield;
	}
	
	@DrawLoop{
		DrawBoss(imgBoss);
	}
	
	@Finalize{
		FinalizeData();
	}
	
	task TMain(){
		FWait(60);
		
		DeclareSpell();
		
		Atack();
	}
	
	function DeclareSpell(){
		SetScore(2600000);
		SetTimer(100);
		CutIn(KOUMA,"tuC'est printempsv",NULL,0,0,0,0);
		SetAction(ACT_SPELL,180);
		FWait(180);
	}
	
	task Atack(){
		let stime = 40;
		let line = 4;
		let angle = 0;
		let wtime = 0;
		let speed = 0;
		let way = 0;
		let lifepc = 0;
		let turn = 1;
		
		SetAction(ACT_SHOT_A,21600);
		
		loop{
			angle = 90 + rand(-45,45);
			lifepc = GetEnemyLife() / 1000;
			way = 34 - truncate( lifepc * 10 );
			wtime = 120 + lifepc * 20;
			speed = 0.62 - lifepc * 0.12;
			
			ascent(i in 0..way){
				ascent(j in 0..line){
					WhiteShot(GetX(),GetY(),speed + j * 0.12,1.6 + speed * 1.3 * rand(0.8,1.2),angle + ( i * 360 / way) * turn,48,PURPLE23,12,45,90 + i * 3);
				}
				FWait(stime / way);
			}
			
			turn *= -1;
			
			FWait(wtime);
		}
	}
	
	task WhiteShot(x,y,speed1,speed2,angle,graph1,graph2,delay1,delay2,wtime){
		let obj = CreateObjShot(x,y,speed1,angle,graph1,delay1);
		let way = 3;
		
		FWait(wtime);
		
		if( !Obj_BeDeleted(obj) ){
			ascent(i in 0..way){
				CreateShot01(Obj_GetX(obj),Obj_GetY(obj),speed2,angle + rand(-14,14) + i * 360 / way,graph2,delay2);
			}
			ObjShot_FadeDelete(obj);
		}
	}
	
	#include_function ".\initialize.txt"
	
	#include_function ".\..\lib\lib_obj.txt"
}