//注意
//このファイルは夢終劇仕様ドットアニメライブラリを改変したもので
//引用加工ドット絵に付属している物です。
//オリジナルの動作はこれを使用しないとエラーが出ます。
//通常版と同じように使用できます。
//==============================================================================
//	★ボス共通 アニメライブラリ
//　ボス個別アニメライブラリ冒頭にてインクルードする
//==============================================================================
//　定数、変数
//==============================================================================
//　アクション定数
//　ボスドット絵の各カットの配置番号
//　	1  5  9 13 17 21   25 29
//　	2  6 10 14 18 22   26 30
//　	3  7 11 15 19 23   27 31
//　	4  8 12 16 20 24   28 32
//　各定数におけるアニメパターンは各コメントを参照（*は状況に応じて長く表示）
//------------------------------------------------------------------------------
let _ACT_STANDD1		= -1;	//　立ち（アニメなし）		 1
let _ACT_STANDD3		= 0;	//　立ち＋まばたき（3コマ）	 1-  2-  3-… 1-  5-  6-…
let _ACT_STANDD4		= 1;	//　立ち＋まばたき（4コマ）	 1-  2-  3-  4-… 1-  5-  6-  4-…
let _ACT_STANDD4_B	= 2;	//　立ち＋まばたき（4コマB） 1-  2-  3-  4-… 1-  5-  6-  4-…
let _ACT_MOVEE		= 3;	//　移動（左右自動判定）	
let _ACT_MOVEE_L		= 4;	//　左移動					 9-*10-  9
let _ACT_MOVEE_R		= 5;	//　右移動					11-*12- 11
let _ACT_KICKK		= 6;	//　キック移動（左右自動判定）	
let _ACT_KICKK_L		= 7;	//　左キック移動			11-*12- 11
let _ACT_KICKK_R		= 8;	//　右キック移動			 9-*10-  9
let _ACT_SHOT_AA3	= 9;	//　弾幕A（3コマ）			17-*18- 17
let _ACT_SHOT_AA3_B	= 10;	//　弾幕A（3コマB）			17- 18-*19
let _ACT_SHOT_AA4	= 11;	//　弾幕A（4コマ）			17- 18-*19- 18
let _ACT_SHOT_AA5	= 12;	//　弾幕A（5コマ）			17- 18-*19- 18- 17
let _ACT_SHOT_BB3	= 13;	//　弾幕B（3コマ）			21-*22- 21
let _ACT_SHOT_BB3_B 	= 14;	//　弾幕B（3コマB）			21- 23-*24
let _ACT_SHOT_BB3_C	= 15;	//　弾幕B（3コマC）			23-*24- 23
let _ACT_SHOT_BB4	= 16;	//　弾幕B（4コマ）			21- 22-*23- 22
let _ACT_SHOT_BB5	= 17;	//　弾幕B（5コマ）			21- 22-*23- 22- 21
let _ACT_SHOT_BB5_B	= 18;	//　弾幕B（5コマB）			21- 22-*24- 22- 21
let _ACT_SPELLL3		= 19;	//　スペル発動（3コマ）		13-*14- 13
let _ACT_SPELLL4		= 20;	//　スペル発動（4コマ）		13- 14-*15- 14
let _ACT_SPELLL5		= 21;	//　スペル発動（5コマ）		13- 14-*15- 14- 13
let _ACT_SPELLL5_B	= 22;	//　スペル発動（5コマB）	13- 14- 15-*16- 15
let _ACT_CHARGEE		= 23;	//	溜め					21-*22
let _ACT_SLASH_HH	= 24;	//　横斬り					21-*22- 20- 18- 17
let _ACT_SLASH_VV	= 25;	//　縦斬り					23-*24- 20- 18- 17
let _ACT_TURNN		= 26;	//　ターン					25- 29- 30- 31- 32- 25
let _ACT_PRAYY		= 27;	//　祈祷					25-*(26- 27- 28- 29- 30- 31-…)- 32
let _ACT_SUNN		= 28;	//　太陽					25-*(26- 27-…)-28
let _ACT_MOVE_Tencoo	= 29;	//　天子専用移動（左右自動判定）	
let _ACT_MOVEE_L_Tencoo	= 30;	//　天子専用左移動					 9-*10-  9
let _ACT_MOVE_R_Tencoo	= 31;	//　天子専用右移動					11-*12- 11
let _ACT_SPELL5_CC	= 32;	//　天子専用スペル発動（5コマ）			14- 13- 14- 15-*16
let _ACT_SLASH_H_BB	= 33;	//　天子専用横斬り（4コマ）			21-*22- 23- 24
let _ACT_SPELL4_BB	= 34;	//　スペル発動（4コマB）			13- 14- 15-*16
let _ACT_THORNN		= 35;	//　衣玖専用特殊動作			25- 26- 27-*(28- 29-…)- 30- 31- 32
let _ACT_SHOT_A4_BB	= 36;	//　弾幕A（4コマB）			17- 18- 19-*20
let _ACT_PARASOR_LL	= 37;	//　小傘専用攻撃動作1			17- 18- 19- 20 - 1(繰り返し)
let _ACT_PARASOR_RR	= 38;	//　小傘専用攻撃動作2			17- 18- 19- 20 - 1(繰り返し)

//------------------------------------------------------------------------------
//　カット別矩形座標定数（左上の座標）
//　各定数が示すカットはコメント及びアクション定数のカット配置番号を参照
//------------------------------------------------------------------------------
let RECT_LENGTHH		= 128;
let RECT_STANDD0		= [ 0, 0 ];								//	 1
let RECT_STANDD1		= [ 0, RECT_LENGTHH ];					//	 2
let RECT_STANDD2		= [ 0, 2 * RECT_LENGTHH ];				//	 3
let RECT_STANDD3		= [ 0, 3 * RECT_LENGTHH ];				//	 4
let RECT_BLINKK0		= [ RECT_LENGTHH, 0 ];					//	 5
let RECT_BLINKK1		= [ RECT_LENGTHH, RECT_LENGTHH ];			//	 6
let RECT_BLINKK2		= [ RECT_LENGTHH, 2 * RECT_LENGTHH ];		//	 7
let RECT_MOVEE_L0	= [ 2 * RECT_LENGTHH, 0 ];				//	 9
let RECT_MOVEE_L1	= [ 2 * RECT_LENGTHH, RECT_LENGTHH ];		//	10
let RECT_MOVEE_R0	= [ 2 * RECT_LENGTHH, 2 * RECT_LENGTHH ];	//	11
let RECT_MOVEE_R1	= [ 2 * RECT_LENGTHH, 3 * RECT_LENGTHH ];	//	12
let RECT_SPELLL0		= [ 3 * RECT_LENGTHH, 0 ];				//	13
let RECT_SPELLL1		= [ 3 * RECT_LENGTHH, RECT_LENGTHH ];		//	14
let RECT_SPELLL2		= [ 3 * RECT_LENGTHH, 2 * RECT_LENGTHH ];	//	15
let RECT_SPELLL3		= [ 3 * RECT_LENGTHH, 3 * RECT_LENGTHH ];	//	16
let RECT_SHOT_AA0	= [ 4 * RECT_LENGTHH, 0 ];				//	17
let RECT_SHOT_AA1	= [ 4 * RECT_LENGTHH, RECT_LENGTHH ];		//	18
let RECT_SHOT_AA2	= [ 4 * RECT_LENGTHH, 2 * RECT_LENGTHH ];	//	19
let RECT_SHOT_AA3	= [ 4 * RECT_LENGTHH, 3 * RECT_LENGTHH ];	//	20
let RECT_SHOT_BB0	= [ 5 * RECT_LENGTHH, 0 ];				//	21
let RECT_SHOT_BB1	= [ 5 * RECT_LENGTHH, RECT_LENGTHH ];		//	22
let RECT_SHOT_BB2	= [ 5 * RECT_LENGTHH, 2 * RECT_LENGTHH ];	//	23
let RECT_SHOT_BB3	= [ 5 * RECT_LENGTHH, 3 * RECT_LENGTHH ];	//	24
let RECT_ETCC_A0		= [ 6 * RECT_LENGTHH, 0 ];				//	25
let RECT_ETCC_A1		= [ 6 * RECT_LENGTHH, RECT_LENGTHH ];		//	26
let RECT_ETCC_A2		= [ 6 * RECT_LENGTHH, 2 * RECT_LENGTHH ];	//	27
let RECT_ETCC_A3		= [ 6 * RECT_LENGTHH, 3 * RECT_LENGTHH ];	//	28
let RECT_ETCC_B0		= [ 7 * RECT_LENGTHH, 0 ];				//	29
let RECT_ETCC_B1		= [ 7 * RECT_LENGTHH, RECT_LENGTHH ];		//	30
let RECT_ETCC_B2		= [ 7 * RECT_LENGTHH, 2 * RECT_LENGTHH ];	//	31
let RECT_ETCC_B3		= [ 7 * RECT_LENGTHH, 3 * RECT_LENGTHH ];	//	32

//------------------------------------------------------------------------------
//　キャラ定数
//------------------------------------------------------------------------------
let CHAR_DAIYOUSEI	= 0;
let CHAR_MEIRIN		= 1;
let CHAR_DEVIL		= 2;
let CHAR_PATCHOULII	= 3;
let CHAR_SAKUYA		= 4;
let CHAR_REMILIA	= 5;
let CHAR_FLANDRE	= 6;
let CHAR_ALICE		= 7;
let CHAR_LILY		= 8;
let CHAR_YOUMU		= 9;
let CHAR_YUYUKO		= 10;
let CHAR_CHEN_RAN	= 11;
let CHAR_YUKARI		= 12;
let CHAR_TEWI		= 13;
let CHAR_REISEN		= 14;
let CHAR_EIRIN		= 15;
let CHAR_KAGUYA		= 16;
let CHAR_MOKOU		= 17;
let CHAR_SUIKA		= 18;
let CHAR_AYA		= 19;
let CHAR_MEDICINE	= 20;
let CHAR_YUKA		= 21;
let CHAR_KOMACHI	= 22;
let CHAR_EIKI		= 23;
let CHAR_SHINKI		= 24;
let CHAR_MIMA		= 25;
let CHAR_REIMU		= 26;

//------------------------------------------------------------------------------
//　その他変数
//------------------------------------------------------------------------------
let actionDefault = _ACT_STANDD1;	//　基本アクション
let action = actionDefault;			//　現在のアクション
let actionCount = 0;				//　アクションフレームカウンタ
let actionCountMax = 0;				//　アクション終了までのフレーム数
let stopAnime = false;				//　trueの間はアニメを停止する
let character = CHAR_DAIYOUSEI;		//　動作中のキャラクター

//==============================================================================
//　アクション指示関連関数
//==============================================================================
//　アクション初期設定
//------------------------------------------------------------------------------
task InitializeAction(){
	loop{
		SetAction( actionDefault, 0 );
		while( actionCount < actionCountMax ){
			while( stopAnime ){ yield; }
			actionCount ++;
			yield;
		}
	}
}

//------------------------------------------------------------------------------
//　アクション指定
//　※指定フレーム数が経過すると基本アクションに移行する
//　※「立ち」「幽香回転」はフレーム数固定（指定を無視する）
//------------------------------------------------------------------------------
function SetAction(
	let newAction,		//　アクション定数
	let frame			//　アクション終了までのフレーム数
){
	alternative( newAction )
	case( _ACT_STANDD1, _ACT_STANDD3, _ACT_STANDD4, _ACT_STANDD4_B ){ frame = 216000; }
	case( _ACT_TURNN ){ frame = 42; }
	action = newAction;
	actionCount = 0;
	actionCountMax = frame;
}

//------------------------------------------------------------------------------
//　アニメ一時停止
//　※停止途中にすぐ再開したい場合は0以下のフレーム数を指定する
//------------------------------------------------------------------------------
task StopAnime(
	let frame		//　停止するフレーム数（経過後にアニメ再開）
){
	if( frame > 0 ){
		stopAnime = true;
		loop( frame ){
			if( !stopAnime ){ break; }
			yield;
		}
		stopAnime = false;
	}
	else{ stopAnime = false; }
}

//==============================================================================
//　描画関連関数
//==============================================================================
//　ボスアニメ描画（通常）
//------------------------------------------------------------------------------
function DrawBoss(
	let imageFile		//　画像ファイルパス
){
	_DrawBoss( imageFile, GetX(), GetY() );
}

//------------------------------------------------------------------------------
//　ボスアニメ描画（座標指定）
//------------------------------------------------------------------------------
function _DrawBoss(
	let imageFile,		//　画像ファイルパス
	let x,				//	中心x座標
	let y				//	中心y座標
){
	let rect = [];
	alternative( action )
	//　3コマループ（立ち＋まばたき） --------------------------------
	case( _ACT_STANDD3 ){
		let cutFrame = 12;
		let count = actionCount % ( cutFrame * 12 );
		let number = trunc( count / cutFrame );
		let anime = [ 0, 1, 2, 0, 1, 2, 0, 3, 4, 0, 1, 2, 2 ][ number ];
		rect = [ RECT_STANDD0, RECT_STANDD1, RECT_STANDD2,
			RECT_BLINKK0, RECT_BLINKK1 ][ anime ];
	}
	//　4コマループ（立ち＋まばたき） --------------------------------
	case( _ACT_STANDD4 ){
		let cutFrame = 12;
		let count = actionCount % ( cutFrame * 12 );
		let number = trunc( count / cutFrame );
		let anime = [ 0, 1, 2, 3, 0, 1, 2, 3, 0, 4, 5, 3, 3 ][ number ];
		rect = [ RECT_STANDD0, RECT_STANDD1, RECT_STANDD2, RECT_STANDD3,
			RECT_BLINKK0, RECT_BLINKK1 ][ anime ];
	}
	//　4コマループ（立ち＋まばたきB） -------------------------------
	case( _ACT_STANDD4_B ){
		let cutFrame = 12;
		let count = actionCount % ( cutFrame * 12 );
		let number = trunc( count / cutFrame );
		let anime = [ 0, 1, 2, 3, 0, 1, 2, 3, 0, 4, 5, 6, 6 ][ number ];
		rect = [ RECT_STANDD0, RECT_STANDD1, RECT_STANDD2, RECT_STANDD3,
			RECT_BLINKK0, RECT_BLINKK1, RECT_BLINKK2 ][ anime ];
	}
	//　3コマ移動（左右自動判定） ------------------------------------
	case( _ACT_MOVEE, _ACT_KICKK ,_ACT_MOVE_Tencoo){
		if( absolute( GetSpeed() ) < 0.1 ){ rect = RECT_STANDD0; }
		else{
			let cutFrameA = 10;
			if(action ==_ACT_MOVE_Tencoo){cutFrameA = 7;}
			if( actionCountMax < 30 ){ cutFrameA = trunc( actionCountMax / 3 ); }
			let cutFrameB = actionCountMax - cutFrameA;
			let animePattern = [ 0, 1, 0 ];
			let framePattern = [ cutFrameA, cutFrameB, actionCountMax ];
			let anime = animePattern[ 2 ];
			ascent( let i in 0 .. 3 ){
				if( actionCount < framePattern[ i ] ){
					anime = animePattern[ i ];
					break;
				}
			}
			let moveL = cos( GetAngle() ) <= 0;
			if( action == _ACT_KICKK ){ moveL = !moveL; }
			if( moveL ){ rect = [ RECT_MOVEE_L0, RECT_MOVEE_L1 ][ anime ]; }
			else{ rect = [ RECT_MOVEE_R0, RECT_MOVEE_R1 ][ anime ]; }
		}
	}

	//　3コマ移動（左右指定） ----------------------------------------
	case( _ACT_MOVEE_L, _ACT_MOVEE_R, _ACT_KICKK_L, _ACT_KICKK_R ,_ACT_MOVEE_L_Tencoo, _ACT_MOVE_R_Tencoo){
		let cutFrameA = 10;
		if(action ==_ACT_MOVE_Tencoo){cutFrameA = 7;}
		if( actionCountMax < 30 ){ cutFrameA = trunc( actionCountMax / 3 ); }
		let cutFrameB = actionCountMax - cutFrameA;
		let animePattern = [ 0, 1, 0 ];
		let framePattern = [ cutFrameA, cutFrameB, actionCountMax ];
		let anime = animePattern[ 2 ];
		ascent( let i in 0 .. 3 ){
			if( actionCount < framePattern[ i ] ){
				anime = animePattern[ i ];
				break;
			}
		}
		if( action == _ACT_MOVEE_L || action == _ACT_KICKK_R ){
			rect = [ RECT_MOVEE_L0, RECT_MOVEE_L1 ][ anime ];
		}
		else{ rect = [ RECT_MOVEE_R0, RECT_MOVEE_R1 ][ anime ]; }
	}

	//　3コマ（弾幕A3,B3,B3C,スペル3） -------------------------------
	case( _ACT_SHOT_AA3, _ACT_SHOT_BB3, _ACT_SHOT_BB3_C, _ACT_SPELLL3 ){
		let cutFrameA = 6;
		if( actionCountMax < 24 ){ cutFrameA = trunc( actionCountMax / 4 ); }
		let cutFrameB = actionCountMax - cutFrameA;
		let animePattern = [ 0, 1, 0 ];
		let framePattern = [ cutFrameA, cutFrameB, actionCountMax ];
		let anime = animePattern[ 2 ];
		ascent( let i in 0 .. 3 ){
			if( actionCount < framePattern[ i ] ){
				anime = animePattern[ i ];
				break;
			}
		}
		alternative( action )
		case( _ACT_SHOT_AA3 ){ rect = [ RECT_SHOT_AA0, RECT_SHOT_AA1 ][ anime ]; }
		case( _ACT_SHOT_B3 ){ rect = [ RECT_SHOT_BB0, RECT_SHOT_BB1 ][ anime ]; }
		case( _ACT_SHOT_B3_C ){ rect = [ RECT_SHOT_BB2, RECT_SHOT_BB3 ][ anime ]; }
		others{ rect = [ RECT_SPELLL0, RECT_SPELLL1 ][ anime ]; }
	}
	//　3コマB（弾幕A3B,B3B） ----------------------------------------
	case( _ACT_SHOT_AA3_B, _ACT_SHOTT_B3_B ){
		let cutFrameA = 6;
		if( actionCountMax < 24 ){ cutFrameA = trunc( actionCountMax / 4 ); }
		let cutFrameB = cutFrameA * 2;
		let animePattern = [ 0, 1, 2 ];
		let framePattern = [ cutFrameA, cutFrameB, actionCountMax ];
		let anime = animePattern[ 2 ];
		ascent( let i in 0 .. 3 ){
			if( actionCount < framePattern[ i ] ){
				anime = animePattern[ i ];
				break;
			}
		}
		alternative( action )
		case( _ACT_SHOT_A3_B ){ rect = [ RECT_SHOTT_A0, RECT_SHOTT_A1, RECT_SHOTT_A2 ][ anime ]; }
		others { rect = [ RECT_SHOT_B0, RECT_SHOTT_B2, RECT_SHOTT_B3 ][ anime ]; }
	}
	//　4コマ（弾幕A4,B4,スペル4） -----------------------------------
	case( _ACT_SHOTT_A4, _ACT_SHOTT_B4, _ACT_SPELLL4 ){
		let cutFrameA = 6;
		if( actionCountMax < 30 ){ cutFrameA = trunc( actionCountMax / 5 ); }
		let cutFrameB = cutFrameA * 2;
		let cutFrameC = actionCountMax - cutFrameA;
		let animePattern = [ 0, 1, 2, 1 ];
		let framePattern = [ cutFrameA, cutFrameB, cutFrameC, actionCountMax ];
		let anime = animePattern[ 3 ];
		ascent( let i in 0 .. 4 ){
			if( actionCount < framePattern[ i ] ){
				anime = animePattern[ i ];
				break;
			}
		}
		alternative( action )
		case( _ACT_SHOT_A4 ){ rect = [ RECT_SHOTT_A0, RECT_SHOTT_A1, RECT_SHOTT_A2 ][ anime ]; }
		case( _ACT_SHOT_B4 ){ rect = [ RECT_SHOTT_B0, RECT_SHOTT_B1, RECT_SHOTT_B2 ][ anime ]; }
		others{ rect = [ RECT_SPELLL0, RECT_SPELLL1, RECT_SPELLL2 ][ anime ]; }
	}
	//　4コマ（スペル4B,弾幕A4B） -----------------------------------
	case( _ACT_SPELLL4_B, _ACT_SHOTT_A4_B ){
		let cutFrameA = 6;
		if( actionCountMax < 30 ){ cutFrameA = trunc( actionCountMax / 5 ); }
		let cutFrameB = cutFrameA * 2;
		let cutFrameC = cutFrameA * 3;
		let cutFrameD = actionCountMax - cutFrameA;
		let animePattern = [ 0, 1, 2, 3 ];
		let framePattern = [ cutFrameA, cutFrameB, cutFrameC, cutFrameD ];
		let anime = animePattern[ 3 ];
		ascent( let i in 0 .. 4 ){
			if( actionCount < framePattern[ i ] ){
				anime = animePattern[ i ];
				break;
			}
		}
		alternative( action )
		case( _ACT_SPELL4_B ){ rect = [ RECT_SPELLL0, RECT_SPELLL1, RECT_SPELLL2, RECT_SPELLL3 ][ anime ]; }
		case( _ACT_SHOT_A4_B ){ rect = [RECT_SHOTT_A0, RECT_SHOTT_A1, RECT_SHOTT_A2, RECT_SHOTT_A3 ][ anime ]; }
	}
	//　5コマ（小傘攻撃A,B） -----------------------------------
	case( _ACT_PARASOR_L, _ACT_PARASOR_R ){
		let cutFrame = 6;
		let count = actionCount % ( cutFrame * 4 );
		let number = trunc( count / cutFrame );

		alternative( action )
		case( _ACT_PARASOR_L ){ rect = [ RECT_SHOTT_A0, RECT_SHOTT_A1, RECT_SHOTT_A2, RECT_SHOTT_A3 ][ number ]; }
		case( _ACT_PARASOR_R ){ rect = [RECT_SHOTT_B0, RECT_SHOTT_B1, RECT_SHOTT_B2, RECT_SHOTT_B3 ][ number ]; }
	}
	//　5コマ（弾幕A5,B5,B5B,スペル5） -------------------------------
	case( _ACT_SHOT_A5, _ACT_SHOT_B5, _ACT_SHOT_B5_B, _ACT_SPELL5 ){
		let cutFrameA = 6;
		if( actionCountMax < 36 ){ cutFrameA = trunc( actionCountMax / 6 ); }
		let cutFrameB = cutFrameA * 2;
		let cutFrameC = actionCountMax - cutFrameB;
		let cutFrameD = actionCountMax - cutFrameA;
		let animePattern = [ 0, 1, 2, 1, 0 ];
		let framePattern = [ cutFrameA, cutFrameB, cutFrameC, cutFrameD, actionCountMax ];
		let anime = animePattern[ 4 ];
		ascent( let i in 0 .. 5 ){
			if( actionCount < framePattern[ i ] ){
				anime = animePattern[ i ];
				break;
			}
		}
		alternative( action )
		case( _ACT_SHOT_A5 ){ rect = [ RECT_SHOTT_A0, RECT_SHOTT_A1, RECT_SHOTT_A2 ][ anime ]; }
		case( _ACT_SHOT_B5 ){ rect = [ RECT_SHOTT_B0, RECT_SHOTT_B1, RECT_SHOTT_B2 ][ anime ]; }
		case( _ACT_SHOT_B5_B ){ rect = [ RECT_SHOTT_B0, RECT_SHOTT_B1, RECT_SHOTT_B3 ][ anime ]; }
		others{ rect = [ RECT_SPELLL0, RECT_SPELLL1, RECT_SPELLL2 ][ anime ]; }
	}
	//　5コマB（スペル5B） -------------------------------------------
	case( _ACT_SPELL5_B ){
		let cutFrameA = 6;
		if( actionCountMax < 36 ){ cutFrameA = trunc( actionCountMax / 6 ); }
		let cutFrameB = cutFrameA * 2;
		let cutFrameC = cutFrameA * 3;
		let cutFrameD = actionCountMax - cutFrameA;
		let animePattern = [ 0, 1, 2, 3, 2 ];
		let framePattern = [ cutFrameA, cutFrameB, cutFrameC, cutFrameD, actionCountMax ];
		let anime = animePattern[ 4 ];
		ascent( let i in 0 .. 5 ){
			if( actionCount < framePattern[ i ] ){
				anime = animePattern[ i ];
				break;
			}
		}
		rect = [ RECT_SPELLL0, RECT_SPELLL1, RECT_SPELLL2, RECT_SPELLL3 ][ anime ]; 
		
	}
	//　5コマ （スペル5C） -------------------------------------------
	case( _ACT_SPELL5_C ){
		let cutFrameA = 6;
		if( actionCountMax < 36 ){ cutFrameA = trunc( actionCountMax / 6 ); }
		let cutFrameB = cutFrameA * 2;
		let cutFrameC = cutFrameA * 3;
		let cutFrameD = cutFrameA * 4;
		let cutFrameE = actionCountMax - cutFrameA;
		let animePattern = [1, 0, 1, 2, 3 ];
		let framePattern = [cutFrameA, cutFrameB, cutFrameC, cutFrameD, cutFrameE];
		let anime = animePattern[ 4 ];
		ascent( let i in 0 .. 5 ){
			if( actionCount < framePattern[ i ] ){
				anime = animePattern[ i ];
				break;
			}
		}
		rect = [ RECT_SPELLL0, RECT_SPELLL1, RECT_SPELLL2, RECT_SPELLL3 ][ anime ];
	}
	//　2コマ（溜め） ------------------------------------------------
	case( _ACT_CHARGE ){
		let cutFrame = 6;
		if( actionCountMax < 18 ){ cutFrame = trunc( actionCountMax / 3 ); }
		let anime = [ 0, 1 ][ actionCount >= cutFrame ];
		alternative( action )
		rect = [ RECT_SHOTT_B0, RECT_SHOTT_B1 ][ anime ];
	}
	//　5コマ（縦斬り,横斬り） ---------------------------------------
	case( _ACT_SLASH_H, _ACT_SLASH_V, _ACT_SLASH_H_B ){
		let cutFrameA = 6;
		if( actionCountMax < 36 ){ cutFrameA = trunc( actionCountMax / 6 ); }
		let cutFrameD = actionCountMax - cutFrameA;
		let cutFrameC = cutFrameD - cutFrameA;
		let cutFrameB = cutFrameC - cutFrameA;
		let animePattern = [ 0, 1, 2, 3, 4 ];
		let framePattern = [ cutFrameA, cutFrameB, cutFrameC, cutFrameD, actionCountMax ];
		let anime = animePattern[ 4 ];
		ascent( let i in 0 .. 5 ){
			if( actionCount < framePattern[ i ] ){
				anime = animePattern[ i ];
				break;
			}
		}
		alternative( action )
		case( _ACT_SLASH_H ){ rect = [ RECT_SHOTT_B0, RECT_SHOTT_B1,
			RECT_SHOTT_A3, RECT_SHOTT_A1, RECT_SHOTT_A0 ][ anime ]; }
		case( _ACT_SLASH_V ){ rect = [ RECT_SHOTT_B2, RECT_SHOTT_B3,
			RECT_SHOTT_A3, RECT_SHOTT_A1, RECT_SHOTT_A0 ][ anime ];  }
		others{ rect = [ RECT_SHOTT_B0, RECT_SHOTT_B1,
			RECT_SHOTT_B2, RECT_SHOTT_B3, RECT_SHOTT_B3 ][ anime ]; }
	}
	//　6コマ（ターン） ----------------------------------------------
	case( _ACT_TURN ){
		let cutFrame = 7;
		let number = trunc( actionCount / cutFrame );
		let anime = [ 0, 1, 2, 3, 4, 0, 0 ][ number ];
		rect = [ RECT_ETCC_A0, RECT_ETCC_B0, RECT_ETCC_B1, RECT_ETCC_B2, RECT_ETCC_B3 ][ anime ];
	}
	//　8コマループ（祈祷） ------------------------------------------
	case( _ACT_PRAY ){
		let cutFrame = 6;
		let anime = 0;
		if( actionCountMax < 12 ){ cutFrame = trunc( ( actionCountMax + 1 ) / 2 ); }
		if( actionCount >= cutFrame && actionCount < actionCountMax - cutFrame ){
			anime = trunc( ( actionCount - cutFrame ) / cutFrame ) % 6 + 1;
		}
		rect = [ RECT_ETCC_A0, RECT_ETCC_A1, RECT_ETCC_A2, RECT_ETCC_A3,
			RECT_ETCC_B0, RECT_ETCC_B1, RECT_ETCC_B2, RECT_ETCC_B3 ][ anime ];
	}
	//　8コマループ（衣玖専用特殊動作） ------------------------------------------
	case( _ACT_THORN ){

		let cutFrame = 6;
		let anime = 0;
		if( actionCountMax < 12 ){ cutFrame = trunc( ( actionCountMax + 1 ) / 2 ); }
		if( actionCount<=cutFrame * 3 ){
			anime = trunc( actionCount / 6 ) ;
		}
		if( actionCount >= cutFrame * 3 && actionCount < actionCountMax - cutFrame*3 ){
			anime = trunc( ( actionCount - cutFrame ) / cutFrame ) % 2 + 3;
		}
		if( actionCountMax - actionCount<=cutFrame * 3){
			let number = trunc( ( actionCountMax - actionCount )/ 6 )  ;
			let Aft_anime = [ 7, 6, 5, 5][ number ];
			anime = Aft_anime;
		}
		rect = [ RECT_ETCC_A0, RECT_ETCC_A1, RECT_ETCC_A2, RECT_ETCC_A3,
			RECT_ETCC_B0, RECT_ETCC_B1, RECT_ETCC_B2, RECT_ETCC_B3 ][ anime ];
	}
	//　4コマループ（太陽） ------------------------------------------
	case( _ACT_SUN ){
		let cutFrame = 4;
		let anime = 0;
		if( actionCountMax < 12 ){ cutFrame = trunc( ( actionCountMax + 1 ) / 2 ); }
		if( actionCount >= cutFrame && actionCount < actionCountMax - cutFrame ){
			anime = trunc( ( actionCount - cutFrame ) / cutFrame ) % 2 + 1;
		}
		rect = [ RECT_ETCC_A0, RECT_ETCC_A1, RECT_ETCC_A2, RECT_ETCC_A3][ anime ];
	}
	//　1コマ（立ち＋アニメなし） ------------------------------------
	others{ rect = RECT_STANDD0; }
	//　描画 ---------------------------------------------------------
	SetTexture( imageFile );
	SetGraphicRect( rect[ 0 ], rect[ 1 ], rect[ 0 ] + RECT_LENGTHH, rect[ 1 ] + RECT_LENGTHH );
	DrawGraphic( x, y );
}

