let char_title_b = GetCurrentScriptDirectory~"subE/enemy_sect_waku_00.png";
let char_name_b = GetCurrentScriptDirectory~"subE/enemy_name_waku_00.png";
let sub_e_b = GetCurrentScriptDirectory~"subE/sub_event_waku_00.png";

let char_title = GetCurrentScriptDirectory~"subE/boss_sub.png";
let char_title_Suku = GetCurrentScriptDirectory~"subE/boss_sub_Sukune.png";
let char_title_Ao = GetCurrentScriptDirectory~"subE/boss_sub_Ao.png";
let char_title_Hook = GetCurrentScriptDirectory~"subE/boss_sub_Hooaka.png";
let char_title_Kuro = GetCurrentScriptDirectory~"subE/boss_sub_Kuroji.png";
let char_title_Shion = GetCurrentScriptDirectory~"subE/boss_sub_Shion.png";
let char_title_XenoA = GetCurrentScriptDirectory~"subE/boss_sub_XenoA.png";

let char_name = GetCurrentScriptDirectory~"subE/boss_name.png";
let char_name_Suku = GetCurrentScriptDirectory~"subE/boss_name_Sukune.png";
let char_name_Ao = GetCurrentScriptDirectory~"subE/boss_name_Ao.png";
let char_name_Hook = GetCurrentScriptDirectory~"subE/boss_name_Hooaka.png";
let char_name_Kuro = GetCurrentScriptDirectory~"subE/boss_name_Kuroji.png";
let char_name_Shion = GetCurrentScriptDirectory~"subE/boss_name_Shion.png";
let char_name_XenoA = GetCurrentScriptDirectory~"subE/boss_name_XenoA.png";

let sub_e0 = GetCurrentScriptDirectory~"subE/event_4.png";
let sub_e1 = GetCurrentScriptDirectory~"subE/event_0.png";
let sub_e2 = GetCurrentScriptDirectory~"subE/event_1.png";
let sub_e3 = GetCurrentScriptDirectory~"subE/event_2.png";
let sub_e4 = GetCurrentScriptDirectory~"subE/event_3.png";
let sub_e5 = GetCurrentScriptDirectory~"subE/event_4.png";

let sub_eK = GetCurrentScriptDirectory~"subE/event_Kuro.png";

let sub_eShion1 = GetCurrentScriptDirectory~"subE/event_Shion1.png";
let sub_eShion2 = GetCurrentScriptDirectory~"subE/event_Shion2.png";
let sub_eShion3 = GetCurrentScriptDirectory~"subE/event_Shion3.png";
let sub_eShion4 = GetCurrentScriptDirectory~"subE/event_Shion4.png";
/*
..
..
..
*/

LoadTexture( char_title_b );
LoadTexture( char_name_b );
LoadTexture( sub_e_b );
LoadTexture( char_title );
LoadTexture( char_name );
LoadTexture( sub_e1 );
LoadTexture( sub_e2 );
LoadTexture( sub_e3 );
LoadTexture( sub_e4 );
LoadTexture( sub_e5 );
/*
..
..
..
*/

	task le_waku( color, event_num, name, title, e1, e2, e3, e4 ){
        let color_v;
        if( color == "RED" ){ color_v = 0; }
        if( color == "YELLOW" ){ color_v = 1; }
        if( color == "PURPLE" ){ color_v = 2; }
        charname( color_v, char_name_b );
        chartitle( color_v, char_title_b );
        charname( color_v, name );
        chartitle( color_v, title );
        subevent( color_v, sub_e_b, event_num );
        subeventtext( event_num, e1, e2, e3, e4 );
    }

		task chartitle( color_v, img ){
			let obj = ObjPrim_Create( OBJ_SPRITE_2D );
			ObjPrim_SetTexture( obj, img );
			Obj_SetRenderPriority( obj, 0.9 );
			ObjSprite2D_SetSourceRect( obj, 0, 40*color_v, 290, 40*( color_v + 1 ) );
			ObjSprite2D_SetDestCenter( obj );
			ObjRender_SetBlendType( obj, BLEND_ALPHA );
			ObjRender_SetPosition(obj, 640/2+126, 90, 0);
			b_move_01( obj );
			int_alpha( obj );
		}
		
		task charname( color_v, img ){
			let obj = ObjPrim_Create( OBJ_SPRITE_2D );
			ObjPrim_SetTexture( obj, img );
			Obj_SetRenderPriority( obj, 0.9 );
			ObjSprite2D_SetSourceRect( obj, 0, 90*color_v, 350, 90*( color_v + 1 ) );
			ObjSprite2D_SetDestCenter( obj );
			ObjRender_SetBlendType( obj, BLEND_ALPHA );
			ObjRender_SetPosition(obj, 640/2-126, 90 + 51, 0);
			b_move_02( obj );
			int_alpha( obj );
		}
		
		task subevent( color_v, img, event_num ){
			let num = 0;
			loop( event_num ){
				let obj = ObjPrim_Create( OBJ_SPRITE_2D );
				ObjPrim_SetTexture( obj, img );
				Obj_SetRenderPriority( obj, 0.9 );
				ObjRender_SetBlendType( obj, BLEND_ALPHA );
				ObjRender_SetPosition(obj, 640/2-126, 90 + 121 + 50*num - 25, 0);
				b_move_02( obj );
				sub_e_anm_op( obj, color_v, num );
				sub_e_anm_en( obj, color_v, num );
				num++;
			}
		}
		
	task subeventtext( event_num, img1, img2, img3, img4 ){
		if( event_num == 1 ){ 
			text_01( img1 );
		}
		if( event_num == 2 ){ 
			text_01( img1 );
			text_02( img2 );
		}
		if( event_num == 3 ){ 
			text_01( img1 );
			text_02( img2 );
			text_03( img3 );
		}
		if( event_num == 4 ){ 
			text_01( img1 );
			text_02( img2 );
			text_03( img3 );
			text_04( img4 );
		}
	}
	
			task text_01( img1 ){
				let num = 0;
				let obj = ObjPrim_Create( OBJ_SPRITE_2D );
				ObjPrim_SetTexture( obj, img1 );
				Obj_SetRenderPriority( obj, 0.9 );
				ObjRender_SetBlendType( obj, BLEND_ALPHA );
				ObjRender_SetPosition(obj, 640/2-126, 90 + 121 + 50*num - 20, 0);
				b_move_02( obj );
				sub_e_anm_op( obj, 0, num );
				sub_e_anm_en( obj, 0, num );
			}
			task text_02( img2 ){
				let num = 1;
				let obj = ObjPrim_Create( OBJ_SPRITE_2D );
				ObjPrim_SetTexture( obj, img2 );
				Obj_SetRenderPriority( obj, 0.9 );
				ObjRender_SetBlendType( obj, BLEND_ALPHA );
				ObjRender_SetPosition(obj, 640/2-126, 90 + 121 + 50*num - 20, 0);
				b_move_02( obj );
				sub_e_anm_op( obj, 0, num );
				sub_e_anm_en( obj, 0, num );
			}
			task text_03( img3 ){
				let num = 2;
				let obj = ObjPrim_Create( OBJ_SPRITE_2D );
				ObjPrim_SetTexture( obj, img3 );
				Obj_SetRenderPriority( obj, 0.9 );
				ObjRender_SetBlendType( obj, BLEND_ALPHA );
				ObjRender_SetPosition(obj, 640/2-126, 90 + 121 + 50*num - 20, 0);
				b_move_02( obj );
				sub_e_anm_op( obj, 0, num );
				sub_e_anm_en( obj, 0, num );
			}
			task text_04( img4 ){
				let num = 3;
				let obj = ObjPrim_Create( OBJ_SPRITE_2D );
				ObjPrim_SetTexture( obj, img4 );
				Obj_SetRenderPriority( obj, 0.9 );
				ObjRender_SetBlendType( obj, BLEND_ALPHA );
				ObjRender_SetPosition(obj, 640/2-126, 90 + 121 + 50*num - 20, 0);
				b_move_02( obj );
				sub_e_anm_op( obj, 0, num );
				sub_e_anm_en( obj, 0, num );
			}
		
	task sub_e_anm_op( obj, color_v, num ){
	wait( 35 + 32*num );
	if( num == 0 ){ PlaySound("subev0",92,0); }
	if( num == 1 ){ PlaySound("subev1",92,0); }
	if( num == 2 ){ PlaySound("subev2",92,0); }
	if( num == 3 ){ PlaySound("subev3",92,0); }
		ascent( i in 0..( 50/2 )/1.555 ){
			ObjSprite2D_SetSourceRect( obj, 300*color_v, 50*num, 300*( color_v + 1 ), 50*num+i*2*1.555 );
			ObjSprite2D_SetDestRect( obj, -300/2, 0, 300/2, i*2*1.555 );
			yield;
		}
	}	
	
	task sub_e_anm_en( obj, color_v, num ){
	wait( 266 + 40 - 15*num );
		descent( i in 0..( 50/2 )/1.471 ){
			ObjSprite2D_SetSourceRect( obj, 300*color_v, 50*num, 300*( color_v + 1 ), 50*num+i*2*1.471 );
			ObjSprite2D_SetDestRect( obj, -300/2, 0, 300/2, i*2*1.471 );
			yield;
		}
	Obj_Delete( obj );
	}
		
	task b_move_01( obj ){
		let a = 2.85;
		while( a >= 0.29 ){
			ObjRender_AddPatternA1( obj, 0, a, 180, 1 );
			a -= 0.05;
			yield;
			}
		ObjRender_AddPatternA1( obj, 0, 0.29, 180, 266 );
		wait( 266 );
		a = 0;
		end_alpha( obj );
		while( !Obj_IsDeleted( obj )){
			ObjRender_AddPatternA1( obj, 0, 0.29 + a, 180, 1 );
			a += 0.08;
			yield;
		}
	}
	
	task b_move_02( obj ){
		let a = 2.85;
		while( a >= 0.29 ){
			ObjRender_AddPatternA1( obj, 0, a, 0, 1 );
			a -= 0.05;
			yield;
			}
		ObjRender_AddPatternA1( obj, 0, 0.29, 0, 253 );
		wait( 253 );
		a = 0;
		end_alpha( obj );
		while( !Obj_IsDeleted( obj )){
			ObjRender_AddPatternA1( obj, 0, 0.29 + a, 0, 1 );
			a += 0.08;
			yield;
		}
	}
		
	task int_alpha( obj ){
		ascent( i in 0..255/7.5 ){
			ObjRender_SetAlpha( obj, i*7.5 );
			yield;
		}
	}
	
	task end_alpha( obj ){
		descent( i in 0..255/5 ){
			ObjRender_SetAlpha( obj, i*5 );
			yield;
		}
	Obj_Delete( obj );
	}
	
	task ObjRender_AddPatternA1(obj,frame,v,angle,time)
	{
    wait(frame);
    loop( time )
    {
        let ox = ObjRender_GetX(obj);
        let oy = ObjRender_GetY(obj);
        ObjRender_SetX(obj,ox+v*cos(angle));
        ObjRender_SetY(obj,oy+v*sin(angle));
        yield;
    }
	}
	

task MusicName(Music){ 
	let value = 0;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj,91);
	ObjPrim_SetTexture(obj,Music);
	ObjSprite2D_SetSourceRect(obj,0,0,800,40);
	ObjSprite2D_SetDestRect(obj,-800,-40,800,40);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,0.5,0.5,0);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetPosition(obj,GetStgFrameWidth/2+40,455,0);
	Appear( obj );
	Fade( obj, 240 );
	while( !Obj_IsDeleted(objBoss)){
	yield;
	}
	Obj_Delete(obj);
}

task Appear( obj ){
	ascent( i in 0..255/3 ){
	ObjRender_SetAlpha( obj, i*3 );
	yield;
	}
	ObjRender_SetAlpha( obj, 255 );
	}	

	task Fade( obj, t ){
	wait( t );
	descent( i in 0..255/3 ){
	ObjRender_SetAlpha( obj, i*3 );
	yield;
	}
	Obj_Delete( obj );
	}