--霊夢ＡＩ（2010/09/12）の改造ＡＩ--ver.2011/04/12--by.しなうす

require("function_command.lua");

VK_F10 = 121;

--新規配列定義
RND = math.random(1000)
flag_kishitu = 0;
muteki = 0;
muteki_sp = 0
graze_atk = 0;
air_atk = 0;
land_atk = 0;
hangeki = 0;
noguard = 0;
nograze = 0;
shot_guard = 0;
my_preact = {};
enemy_preact = {};
my_preframe = {};
enemy_preframe = {};
my_allframe = 0;
enemy_allframe = 0;
graze_wide = 0;
caution_atk = 0;
caution_gatk = 0;
caution_graze = 0;
caution_time = 0;
caution_obj = 0;
caution_range = 200;
caution_akuu = 0;
ex_combo = 0;
base_guard = math.random(2) - 1;
guard_rate = 0;
guard_time = 0;
mekuri = 0;
my_frontside = 0;
enemy_frontside = 0;
prerei = 1000;


------------------------
for i=1,3600,1 do
my_preact[i] = 0;
enemy_preact[i] = 0;
my_preframe[i] = 0;
enemy_preframe[i] = 0;
end
------------------------

old_bt = 0;

old_x = 0;
old_ex = 0;
my_xspeedEX = 0;
enemy_xspeedEX = 0;
old_m_ys = 0;
old_e_ys = 0;
m_gs = 0;
e_gs = 0;

pre0_enemy_obj_n = 0

true_math = 0;
bio_math = 0;
graund_math = 0;
air_math = 0;

enemy_obj_act = {};
enemy_obj_x = {};
enemy_obj_y = {};
enemy_obj_hp = {};
enemy_obj_img = {};
enemy_obj_frame = {};
enemy_obj_xspeed = {};
enemy_obj_yspeed = {};
enemy_obj_id = {};
enemy_obj_attackarea_n = {};
enemy_obj_hit_n = {};

pre0_enemy_obj_act = {};
pre0_enemy_obj_x = {};
pre0_enemy_obj_y = {};
pre0_enemy_obj_hp = {};
pre0_enemy_obj_img = {};
pre0_enemy_obj_frame = {};
pre0_enemy_obj_xspeed = {};
pre0_enemy_obj_yspeed = {};
pre0_enemy_obj_id = {};
pre0_enemy_obj_attackarea_n = {};
pre0_enemy_obj_hit_n = {};

enemy_obj_attackarea_left = {};
enemy_obj_attackarea_top = {};
enemy_obj_attackarea_right = {};
enemy_obj_attackarea_bottom = {};

enemy_obj_xaccel = {};
enemy_obj_yaccel = {};

for i=1,1023,1 do
enemy_obj_act[i] = -1;
enemy_obj_x[i] = 10000;
enemy_obj_y[i] = 10000;
enemy_obj_hp[i] = -10000;
enemy_obj_img[i] = -1;
enemy_obj_frame[i] = -1;
enemy_obj_xspeed[i] = 0;
enemy_obj_yspeed[i] = 0;
enemy_obj_id[i] = -1;
enemy_obj_attackarea_n[i] = 0;
enemy_obj_hit_n[i] = 0;

pre0_enemy_obj_act[i] = -1;
pre0_enemy_obj_x[i] = 10000;
pre0_enemy_obj_y[i] = 10000;
pre0_enemy_obj_hp[i] = -10000;
pre0_enemy_obj_img[i] = -1;
pre0_enemy_obj_frame[i] = -1;
pre0_enemy_obj_xspeed[i] = 0;
pre0_enemy_obj_yspeed[i] = 0;
pre0_enemy_obj_id[i] = -1;
pre0_enemy_obj_attackarea_n[i] = 0;
pre0_enemy_obj_hit_n[i] = 0;

enemy_obj_attackarea_left[i] = 10000;
enemy_obj_attackarea_top[i] = 10000;
enemy_obj_attackarea_right[i] = 10000;
enemy_obj_attackarea_bottom[i] = 10000;

enemy_obj_xaccel[i] = 0;
enemy_obj_yaccel[i] = 0;
end -----------------------------------------------------------------------------

countD = 0; --飛翔用カウント
after_guard_count = 180; --ガード後のカウント
loop_count = 0; --whileループ等のループカウント

my_backside = 0;
enemy_backside = 0;

my_airEX = 0;
enemy_airEX = 0;

recovary_time = 0;
flag_kishitu = 0;

enemy_standup_range = 0;

--rad1、rad2:値が大きいほど、周期が短くなる。
--F1：周期はそのままでは±１なので倍率を掛ける。
--F2：倍率をかけただけでは負の数となるため、下駄を足す
--sin：大きな周期をとる
--cos：小さな周期をとる
function biorhythm(rad1,rad2,F1,F2)
	return math.floor( ((math.sin(math.rad(rad1)*battle_time))*F1 + math.floor((math.cos(math.rad(rad2)*battle_time))*F1) + F2)*bio_math/10000 );
end

function react_wait(f)
	--▼
		if not(stage_number==10 or 
		(my_char== 0 and bgm_number==40) or
		(my_char== 1 and bgm_number==41) or
		(my_char== 2 and bgm_number==12) or
		(my_char== 3 and bgm_number==42) or
		(my_char== 4 and bgm_number==15) or
		(my_char== 5 and bgm_number==14) or
		(my_char== 6 and bgm_number==17) or
		(my_char== 7 and bgm_number==16) or
		(my_char== 8 and bgm_number==18) or
		(my_char== 9 and bgm_number==19) or
		(my_char==10 and bgm_number==20) or
		(my_char==11 and bgm_number==21) or
		(my_char==12 and bgm_number==22) or
		(my_char==13 and bgm_number== 4) or
		(my_char==14 and bgm_number== 5) or
		(my_char==15 and bgm_number==30) or
		(my_char==16 and bgm_number==31) or
		(my_char==17 and bgm_number==32) or
		(my_char==18 and bgm_number==33) or
		(my_char==19 and bgm_number==34)
		
		) and enemy_frame<=1 then
			if biorhythm(1,5,f,f*2)>=1 then
				print(biorhythm(1,5,f,f*2),"モーション反応グレイズ：反応待ち＆４入力");
				if ex<x then key_on(ACT_RIGHT); else key_on(ACT_LEFT); end
				--wait(biorhythm(1,5,f,f*2));
				
				for i=1,biorhythm(1,5,f,f*2),1 do
					yield();
					if enemy_act>=300 and ((my_act>=50 and my_act<=96) or (my_act>=143 and my_act<=166)) then
						break
					end
				end
				
			end
		end
	--▲
end


key_hold_B = 0
key_hold_C = 0
--key_resetEX関数
function key_resetEX()
	if key_hold_B == 0 and key_hold_C ==0 then
		key_reset();
	elseif key_hold_B ==1 and key_hold_C ==0 then
		key_off(ACT_UP);	key_off(ACT_DOWN);	key_off(ACT_LEFT);	key_off(ACT_RIGHT);	key_off(ACT_A);	key_off(ACT_C);	key_off(ACT_D);	key_off(ACT_AB); key_off(ACT_BC);
	elseif key_hold_B ==0 and key_hold_C ==1 then
		key_off(ACT_UP);	key_off(ACT_DOWN);	key_off(ACT_LEFT);	key_off(ACT_RIGHT);	key_off(ACT_A);	key_off(ACT_B);	key_off(ACT_D);	key_off(ACT_AB); key_off(ACT_BC);
	elseif key_hold_B ==1 and key_hold_C ==1 then
		key_off(ACT_UP);	key_off(ACT_DOWN);	key_off(ACT_LEFT);	key_off(ACT_RIGHT);	key_off(ACT_A);	key_off(ACT_D);	key_off(ACT_AB); key_off(ACT_BC);
	end
end

--スペルカード使用用のカードゲージ判定関数（コスト１には不要）
function my_spell_more(cost)
	if (my_spell>=cost or (weather==2 and my_spell>=cost-500)) then
		return true;
	else
		return false;
	end
end

--現在指定カードを持っている場合は真、そうでないなら偽
function card_check(card_ID)--連続で実行するとnillが返るらしい。
	if (get_card_id(0,0)==card_ID or get_card_id(0,1)==card_ID or get_card_id(0,2)==card_ID or get_card_id(0,3)==card_ID or get_card_id(0,4)==card_ID) then
		return true;
	else
		return false;
	end
end

--指定カードを一枚目に持ってくるだけの関数
--処理が停滞しないようにbattle_timeと剰余を利用
function card_1st(card_ID)
	if my_card~=card_ID then
		if battle_time%2==0 then
			key_on(ACT_AB);
		elseif battle_time%2==1 then
			key_off(ACT_AB);
		end
	end
end

--指定カードを一枚目に持ってきて使用する関数（空中使用可能カードに注意）
function card_use(card_ID)
	if my_card==card_ID then
		key_off(ACT_LEFT);
		key_off(ACT_RIGHT);
		key_off(ACT_UP);
		key_off(ACT_DOWN);
		key_event(ACT_BC);
	elseif my_card~=card_ID then
		if battle_time%2==0 then
			key_on(ACT_AB);
		elseif battle_time%2==1 then
			key_off(ACT_AB);
		end
	end
end


--指定範囲内に攻撃オブジェクトの判定が、指定フレーム後に存在するか判定する関数。ｘ軸、ｙ軸対応。非常に重い。妖夢のobjバグには、obj_coming_in関数を利用する事。
function enemy_obj_range_in(range, ff)
	in_of_ranges = 0
	out_of_ranges = 0
	
	for F=0,ff,1 do--指定Ｆ通りの予測にはならない。小さい値程正確で、大きい値程偏差が大きい。というか、処理が間に合ってないかもしれない。10でほぼ仕様通り。30で20F内。60で30F内。
		for  i=0,enemy_obj_n-1,1 do
		
			if enemy_obj_id[i] == pre0_enemy_obj_id[i] then
			
			
			
						for n=1,enemy_obj_attackarea_n[i],1 do
							if enemy_obj_attackarea_n[i]==0 then
								out_of_ranges = out_of_ranges + 1
							elseif x+30  +range +(my_xspeedEX*F)						>= (enemy_obj_attackarea_left[(i+1)*100+(n+1)]) + (enemy_obj_xspeed[i]*enemy_dir*F) + (F*(F-1)*enemy_obj_xaccel[i]/2) and --ここから先が猛烈に重くなる。低スペにはつらい
									x-30  -range +(my_xspeedEX*F)						<= (enemy_obj_attackarea_right[(i+1)*100+(n+1)]) + enemy_obj_xspeed[i]*enemy_dir*F + F*(F-1)*enemy_obj_xaccel[i]/2 and
									y-0	  -range +(my_yspeed*F+(F*((F-1)*m_gs))/2)	<= (enemy_obj_attackarea_top[(i+1)*100+(n+1)]) + enemy_obj_yspeed[i]*F + F*(F-1)*enemy_obj_yaccel[i]/2 and
									y+180 +range +(my_yspeed*F+(F*((F-1)*m_gs))/2) 	>= (enemy_obj_attackarea_bottom[(i+1)*100+(n+1)]) + enemy_obj_yspeed[i]*F + F*(F-1)*enemy_obj_yaccel[i]/2 then
										in_of_ranges = in_of_ranges + 1
							else
								out_of_ranges = out_of_ranges + 1
							end
						end
						
						
			elseif enemy_obj_id[i] ~= pre0_enemy_obj_id[i] then
				for ii=1,pre0_enemy_obj_n,1 do
					if enemy_obj_id[i] == pre0_enemy_obj_id[ii] then
					
						for n=1,enemy_obj_attackarea_n[i],1 do
							if enemy_obj_attackarea_n[i]==0 then
								out_of_ranges = out_of_ranges + 1
							elseif x+30  +range +my_xspeedEX*F						>= (enemy_obj_attackarea_left[(i+1)*100+(n+1)]) + enemy_obj_xspeed[i]*enemy_dir*F + F*(F-1)*enemy_obj_xaccel[i]/2 and
									x-30  -range +my_xspeedEX*F						<= (enemy_obj_attackarea_right[(i+1)*100+(n+1)]) + enemy_obj_xspeed[i]*enemy_dir*F + F*(F-1)*enemy_obj_xaccel[i]/2 and
									y-0	  -range +(my_yspeed*F+(F*((F-1)*m_gs))/2)	<= (enemy_obj_attackarea_top[(i+1)*100+(n+1)]) + enemy_obj_yspeed[i]*F + F*(F-1)*enemy_obj_yaccel[i]/2 and
									y+180 +range +(my_yspeed*F+(F*((F-1)*m_gs))/2) 	>= (enemy_obj_attackarea_bottom[(i+1)*100+(n+1)]) + enemy_obj_yspeed[i]*F + F*(F-1)*enemy_obj_yaccel[i]/2 then
										in_of_ranges = in_of_ranges + 1
							else
								out_of_ranges = out_of_ranges + 1
							end
						end
						
					end
				end
			end
			
		end
	end
	
	if in_of_ranges>=1 then
		return true
	else
		return false
	end
	
end

function caution_state_obj(obj_act,obj_img,X,Y,F1,F2)

	true_math = 0;
	
	for i=1,enemy_obj_n,1 do
		if obj_act==10000 and obj_img~=10000 and enemy_obj_img[i]==obj_img then
			if 	enemy_obj_x[i]-X <= x+ 30 and 
				enemy_obj_x[i]+X >= x- 30 and
				enemy_obj_y[i]-Y <= y+180 and
				enemy_obj_y[i]+Y >= y+  0 and
				enemy_obj_frame[i] >= F1 and
				enemy_obj_frame[i] <= F2 then
					true_math = true_math + 1;
			end
		elseif obj_act~=10000 and obj_img==10000 and enemy_obj_act[i]==obj_act then
			if 	enemy_obj_x[i]-X <= x+ 30 and 
				enemy_obj_x[i]+X >= x- 30 and
				enemy_obj_y[i]-Y <= y+180 and
				enemy_obj_y[i]+Y >= y+  0 and
				enemy_obj_frame[i] >= F1 and
				enemy_obj_frame[i] <= F2 then
					true_math = true_math + 1;
			end
		elseif obj_act~=10000 and obj_img~=10000 and enemy_obj_act[i]==obj_act and enemy_obj_img[i]==obj_img then
			if 	enemy_obj_x[i]-X <= x+ 30 and 
				enemy_obj_x[i]+X >= x- 30 and
				enemy_obj_y[i]-Y <= y+180 and
				enemy_obj_y[i]+Y >= y+  0 and
				enemy_obj_frame[i] >= F1 and
				enemy_obj_frame[i] <= F2 then
					true_math = true_math + 1;
			end
		end
	end
	
	return true_math;
	
end

true_obj_n = 0;
JFP_No = 0;
JFP_hp = 0;--正常に働かなかった

function search_JFP()--水符「ジェリーフィッシュプリンセス」探索
	true_obj_n = 0;
	for i=1,enemy_obj_n,1 do
		if enemy_obj_act[i]==856 then
			JFP_No = i
			true_obj_n = true_obj_n+1;
		end
	end
	if true_obj_n==1 then
		return true;
	else
		return false;
	end
end


-------------------------------------------------------------------------------------------------------------------------------------------

--カードセット。基本的に優先順位はバスター装備＞鬼縛陣＞封印＞宝玉＞株
function card_set()
--妖怪バスター未使用かつ妖怪バスターを持っていれば最優先でセット
	if card_check(104) and get_skill_lv(0,4)<1 and weather~=7 and weather~=11 then
		if my_card~=104 then
			key_reset();
			key_on(ACT_AB);
			wait(2);
			key_reset();
		end
--他に使えるカードが無くて妖怪バスターがあればとりあえずセット
	elseif card_check(104) and card_check(208)==false and card_check(14)==false and card_check(201)==false and weather~=7 and weather~=11 then
		if my_card~=104 then
			key_reset();
			key_on(ACT_AB);
			wait(2);
			key_reset();
		end
--他に使えるカードが無くて明珠暗投があればとりあえずセット
	elseif card_check(208) and card_check(209)==false and card_check(14)==false and card_check(201)==false and weather~=7 and weather~=11 then
		if my_card~=208 then
			key_reset();
			key_on(ACT_AB);
			wait(2);
			key_reset();
		end
--夢想封印が無いか相手の霊力が350以上の時、鬼縛陣があればセット
	elseif card_check(206) and my_spell_more(2000) and (card_check(201)==false or (enemy_rei>=350 and dis>250)) and weather~=7 and weather~=11 then
		if my_card~=206 then
			key_reset();
			key_on(ACT_AB);
			wait(2);
			key_reset();
		end
--夢想封印があればセット
	elseif my_card~=206 and card_check(201) and my_spell_more(2500) and weather~=7 and weather~=11 then
		if my_card~=201 then
			key_reset();
			key_on(ACT_AB);
			wait(2);
			key_reset();
		end
--夢想封印が無いか相手の霊力が350以上の時、陰陽宝玉があればセット。鬼縛陣セット中なら変えない
	elseif my_card~=206 and card_check(209) and my_spell_more(1000) and (card_check(201)==false or (enemy_rei>=350 and dis>250)) and weather~=7 and weather~=11 then
		if my_card~=209 then
			key_reset();
			key_on(ACT_AB);
			wait(2);
			key_reset();
		end
--雪の時は気質・株・陰陽宝玉があればセット。鬼縛陣と夢想封印を守る。
	elseif weather==7 and card_check(14) then
		if my_card~=14 then
			key_reset();
			key_on(ACT_AB);
			wait(2);
			key_reset();
		end
	elseif weather==7 and my_card~=14 and card_check(208) then
		if my_card~=208 then
			key_reset();
			key_on(ACT_AB);
			wait(2);
			key_reset();
		end
	elseif weather==7 and my_card~=14 and my_card~=208 and card_check(209) and my_spell_more(1000) then
		if my_card~=209 then
			key_reset();
			key_on(ACT_AB);
			wait(2);
			key_reset();
		end
	end
end

function kihon()
key_off(ACT_D);key_off(front);key_off(ACT_DOWN);
kihon2();


--●どちらかが体力無くなったら待機
	if (my_hp<=0 and my_act>=50 and my_act<=100) or (enemy_hp<=0 and enemy_act>=50 and enemy_act<=100) then
		key_reset();
		for i=1,10,1 do
		print("セット終了：使えるカードがある場合、使用する");
			if (
			(my_card>=100 and my_card<=114) or 
			(not(my_card>=100 and my_card<=114) and y==0 and (my_card==4 or my_card==5 or my_card==9 or my_card==10 or my_card==18 or (my_card==19 and get_special_data(0,21)<=1)))
			) and is_card_use then
				if battle_time%2==0 then
					key_on(ACT_BC);
				else
					key_off(ACT_BC);
				end
			else
				if battle_time%2==0 then
					key_on(ACT_AB);
				else
					key_off(ACT_AB);
				end
			end
			yield();
		end
		
--▼反射行動▼
--神技「天覇風神脚」
	elseif card_check(214) and my_spell_more(1500) and dis<150 and y==0 and (	(ey==0) or 
																					(ey+enemy_yspeed*15+(15*(14*e_gs))/2>0 and ey+enemy_yspeed*15+(15*(14*e_gs))/2<=120)	) and 
	my_act<=5 and enemy_allframe<=15 and enemy_act>=302 and enemy_act~=303 and enemy_act<700 and is_dir_front and my_card==214 and math.random(32)==1 then
		print("拒否行動：実行　⇒　神技「天覇風神脚」");
		key_reset();
		key_event(ACT_BC);
	elseif card_check(214) and my_spell_more(1500) and dis<350 and y==0 and my_act<=5 and enemy_frame<=10 and enemy_act>=300 and enemy_act<700 and my_card~=214 then
		--print("拒否行動：準備　⇒　神技「天覇風神脚」");
		key_reset();
		card_1st(214);
--神技「八方鬼縛陣」
	elseif card_check(206) and my_spell_more(2000) and dis<150 and y==0 and (	(ey==0) or 
																					(ey+enemy_yspeed*15+(15*(14*e_gs))/2>0 and ey+enemy_yspeed*15+(15*(14*e_gs))/2<=120)	) and 
	my_act<=5 and enemy_allframe<=15 and enemy_act>=302 and enemy_act~=303 and enemy_act<700 and is_dir_front and my_card==206 and math.random(32)==1 then
		print("拒否行動：実行　⇒　神技「八方鬼縛陣」");
		key_reset();
		key_event(ACT_BC);
	elseif card_check(206) and my_spell_more(2000) and dis<350 and y==0 and my_act<=5 and enemy_frame<=10 and enemy_act>=300 and enemy_act<700 and my_card~=206 then
		--print("拒否行動：準備　⇒　神技「八方鬼縛陣」");
		key_reset();
		card_1st(206);
--宝具「陰陽鬼神玉」
	elseif card_check(210) and my_spell_more(2000) and dis>200 and dis<450 and y==0 and (	(ey==0) or 
																					(ey+enemy_yspeed*15+(15*(14*e_gs))/2>0 and ey+enemy_yspeed*15+(15*(14*e_gs))/2<=200)	) and 
	my_act<=5 and enemy_allframe<=5 and enemy_act>=301 and enemy_act~=303 and enemy_act<700 and is_dir_front and my_card==210 and math.random(16)==1 then
		print("拒否行動：実行　⇒　宝具「陰陽鬼神玉」");
		key_reset();
		key_event(ACT_BC);
	elseif card_check(210) and my_spell_more(2000) and dis<350 and y==0 and my_act<=5 and enemy_frame<=10 and enemy_act>=300 and enemy_act<700 and my_card~=210 then
		--print("拒否行動：準備　⇒　宝具「陰陽鬼神玉」");
		key_reset();
		card_1st(210);
--夢符「封魔陣」
	elseif card_check(204) and my_spell_more(1000) and dis<150 and y==0 and (	(ey==0) or 
																					(ey+enemy_yspeed*15+(15*(14*e_gs))/2>0 and ey+enemy_yspeed*15+(15*(14*e_gs))/2<=120)	) and 
	my_act<=5 and enemy_allframe<=15 and enemy_act>=302 and enemy_act~=303 and enemy_act<700 and is_dir_front and my_card==204 and math.random(32)==1 then
		print("拒否行動：実行　⇒　夢符「封魔陣」");
		key_reset();
		key_event(ACT_BC);
	elseif card_check(204) and my_spell_more(1000) and dis<350 and y==0 and my_act<=5 and enemy_frame<=10 and enemy_act>=300 and enemy_act<700 and my_card~=204 then
		--print("拒否行動：準備　⇒　夢符「封魔陣」");
		key_reset();
		card_1st(204);
--昇天脚を狙う。無敵付加されるまでは、上空の相手のみ。無敵付加後は地上相手にも。
	elseif card_check(103) and dis<350 and y==0 and my_act<=5 and enemy_frame<=10 and enemy_act>=300 and enemy_act<700 and my_card~=103 then
		print("拒否準備　⇒　スキルカード：昇天脚");
		key_reset();
		card_1st(103);
	elseif (weather==9 or get_skill_lv(0,3)>=3) and get_skill_lv(0,3)>=0 and dis<150 and y==0 and	
	(	(ey==0) or 
		(ey+enemy_yspeed*15+(15*(14*e_gs))/2>0 and ey+enemy_yspeed*15+(15*(14*e_gs))/2<=180)	) and  
	my_act<=5 and enemy_allframe<=5 and enemy_act>=300 and enemy_act<500 and is_dir_front and my_card==103 and math.random(1)==1 then
		print("拒否行動　⇒　スキルカード：昇天脚");
		key_reset();
		key_event(ACT_BC);
	elseif (weather==9 or get_skill_lv(0,3)>=4) and get_skill_lv(0,3)>=0 and dis<150 and y==0 and 
	(	(ey==0) or 
		(ey+enemy_yspeed*15+(15*(14*e_gs))/2>0 and ey+enemy_yspeed*15+(15*(14*e_gs))/2<=180)	) and 
	my_act<=5 and enemy_allframe<=5 and enemy_act>=300 and enemy_act<500 and is_dir_front and math.random(16)==1 then
		print("拒否行動　⇒　コマンド：昇天脚");
		key_reset();
		lvr623(ACT_B);
		
	elseif (weather~=9 or get_skill_lv(0,3)<=2) and get_skill_lv(0,3)>=0 and dis<150 and y==0 and	
	(	
		(ey+enemy_yspeed*15+(15*(14*e_gs))/2>100 and ey+enemy_yspeed*15+(15*(14*e_gs))/2<=180)	) and  
	my_act<=5 and enemy_allframe<=5 and enemy_act>=300 and enemy_act<500 and is_dir_front and my_card==103 and math.random(1)==1 then
		print("拒否行動　⇒　スキルカード：昇天脚");
		key_reset();
		key_event(ACT_BC);
	elseif (weather~=9 or get_skill_lv(0,3)<=3) and get_skill_lv(0,3)>=0 and dis<150 and y==0 and 
	(	
		(ey+enemy_yspeed*15+(15*(14*e_gs))/2>100 and ey+enemy_yspeed*15+(15*(14*e_gs))/2<=180)	) and 
	my_act<=5 and enemy_allframe<=5 and enemy_act>=300 and enemy_act<500 and is_dir_front and math.random(16)==1 then
		print("拒否行動　⇒　コマンド：昇天脚");
		key_reset();
		lvr623(ACT_B);

--▼簡易受け身▼：	攻撃、回避の両受け身であっても、理想とするポイントや状況は大体決まっている。つまり、受け身できるできないを問うものではない。
--				もちろん、壁バウンドや地面への接触を避けるべき状況。意図的に受け身を行わない状況も、おおよそ決まってくる。
	elseif	y-my_yspeed*3>0 and my_act>=50 and my_act<=107 and 
	not(my_act>=97 and my_act<=99) and 
	(
	(dis>=400 and y<=100 and my_airEX>=1 and my_rei>=400) or
	(weather==18 and my_act==89)
	) and weather2~=13 and
	math.random(after_guard_count)<=2 then
		print("簡易受身の試行");
		if my_backside<=300 and dis<=150 then
			key_on(front);
			yield();
			key_event(ACT_A);
		else
			key_on(back);
			yield();
			key_event(ACT_A);
		end

--台風はよほど優勢でない限り、気質が有れば流す
	elseif weather==13 and (my_hp-enemy_hp)<5000 and weather_time>500 and card_check(14) and flag_kishitu==1 then
		print("天候：台風　⇒　基本的に流す");
		key_reset();
		if my_card==14 and y==0 then
			card_use(14);
			if my_act==691 then
				while my_act==691 do
					flag_kishitu = 2;
					yield();
				end
			end
		elseif my_card~=14 then
			card_1st(14)
		end
--台風になりそうだったらよほど優勢でない限り、株ぶっぱで予報を変える
	elseif weather~=13 and weather2==13 and (my_hp-enemy_hp)<5000 and dis>=250 and enemy_obj_range_in(150,60)==false and weather_time>800 and card_check(208) then
		print("予報：台風　⇒　ブッパで回避");
		key_reset();
		if my_card==208 then
			card_use(208);
		elseif my_card~=208 then
			card_1st(208);
		end

--▼状況を見て、「緋想の剣」を使用▼
	elseif card_check(14) and flag_kishitu==1 and my_card~=14 then
		print("天候フラグＯＮ　⇒　「緋想の剣」準備");
		card_1st(14)
	elseif y==0 and my_act<=10 and card_check(14) and flag_kishitu==1 and my_card==14 then
		print("天候フラグＯＮ　⇒　「緋想の剣」使用");
		key_reset();
		key_event(ACT_BC);
		wait(2);
		if my_act==691 then
			while my_act==691 and my_allframe<=70-5 do
				flag_kishitu = 2;
				yield();
			end
		end

--ゲージ4以上で手札に鬼縛陣も夢想封印も陰陽宝玉も無ければ株ぶっぱでデッキ回し
	elseif dis>=350 and enemy_obj_range_in(150,60)==false and my_spell>=2001 and card_check(14)==false and card_check(201)==false and card_check(209)==false and card_check(208) then
		print("カードゲージ４以上：規定のカード無し　⇒　ブッパでデッキ回し");
		key_reset();
		if my_card==208 then
			card_use(208);
		elseif my_card~=208 then
			card_1st(208);
		end


--▼起き攻め▼
	elseif (enemy_act==97 or enemy_act==98 or enemy_act==197 or enemy_act==198 or enemy_act==199) or (enemy_act>=70 and enemy_act<=107 and my_limit>=100) then
--相手ダウン中
--	elseif (enemy_act==97 or enemy_act==98 or (enemy_act>=70 and enemy_act<=107 and my_limit>=100) or (enemy_act==197 and (stand_front - enemy_allframe)>=14) or (enemy_act==198 and (stand_back - enemy_allframe)>=14) or (enemy_act==199 and (stand_neutral - enemy_allframe)>=14)) then


	--霊力状況が少しでも悪い場合は、さっさと「マジックポーション」を使用
		if card_check(1)==true and not(enemy_act>=197 and enemy_act<=199) and (my_rei<=600 or my_rmax<=600 ) then
			print("起き攻め：システムカード　「マジックポーション」");
			card_use(1);
--敵が倒れてて、自分が画面端でなければ警醒陣で起き攻め。
		elseif (y==0 or y>=150) and my_act<=10 and --dis<600 and dis>120 and 
		my_rei>=601 and my_frontside>=300 and enemy_act==97 and enemy_allframe<15 and (card_check(101) or get_skill_lv(0,1)>=0) then
			print("起き攻め　⇒　警醒陣");
			if dis>300 and my_frontside>=500 and math.random(2)==1 then
				key_reset();
				if card_check(101) and my_card~=101 then
					card_1st(101);
				elseif my_card==101 then
					card_use(101);
				elseif get_skill_lv(0,1)>=0 then
					key_on(ACT_D)
					yield();
					yield();
					key_off(ACT_D);
					lvr214(ACT_C);
				end
			else
				if card_check(101) and my_card~=101 then
					card_1st(101);
				elseif my_card==101 then
					card_use(101);
				elseif get_skill_lv(0,1)>=0 then
					key_reset();
					key_on(ACT_D)
					yield();
					yield();
					key_off(ACT_D);
					lvr214(ACT_B);
				end
			end
--敵が倒れてて、自分が中央より相手を押し込んでいる場合、起動しない程度の距離で、常置陣設置
--離れていても、Ｃ設置で中央付近に設置などする。ただしレベルアップの場合はそのまま使用。
		elseif y==0 and my_act<=10 and --dis>=200 and 
		my_rei>=401 and enemy_act==97 and enemy_allframe<15 and (card_check(109) or get_skill_lv(0,9)>=0) then
			print("起き攻め　⇒　常置陣");
			if dis>300 and my_frontside>=300 then
				key_reset();
				if card_check(109) and my_card~=109 then
					card_1st(109);
				elseif my_card==109 then
					card_use(109);
				elseif get_skill_lv(0,9)>=0 then
					key_on(ACT_D)
					yield();
					yield();
					key_off(ACT_D);
					lvr214(ACT_C);
				end
			else
				if card_check(109) and my_card~=109 then
					card_1st(109);
				elseif my_card==109 then
					card_use(109);
				elseif get_skill_lv(0,9)>=0 then
					key_reset();
					key_on(ACT_D)
					yield();
					yield();
					key_off(ACT_D);
					lvr214(ACT_B);
				end
			end
	--指定の使用カードがない場合、スキル宣言。
		elseif (card_check(100) or card_check(101) or card_check(102) or card_check(103) or card_check(104) or card_check(105) or card_check(106) or card_check(107) or card_check(108) or card_check(109) or card_check(110) or card_check(111) or card_check(112) or card_check(113) or card_check(114)
		) and 
		(	enemy_act==97 or enemy_act==98 or (enemy_act==197 and (stand_front - enemy_allframe)>=70) or (enemy_act==198 and (stand_back - enemy_allframe)>=70) or (enemy_act==199 and (stand_neutral- enemy_allframe)>=70) or my_limit>=100
		) then 
			for i=1,10,1 do 
			print("起き攻め　⇒　スキルカード宣言");
				key_on(back);
				if my_card>=100 and my_card<=114 then
					if battle_time%2==0 then
						key_on(ACT_BC);
					else
						key_off(ACT_BC);
					end
				else
					if battle_time%2==0 then
						key_on(ACT_AB);
					else
						key_off(ACT_AB);
					end
				end
				yield();
			end
	--上記に引き続き、スキカがない場合、システムカードを宣言。
		elseif (card_check(4) or card_check(5) or card_check(9) or card_check(10) or card_check(18) or (card_check(19) and get_special_data(0,21)<=1)
		) and 
		(	enemy_act==97 or enemy_act==98 or (enemy_act==197 and (stand_front - enemy_allframe)>=70) or (enemy_act==198 and (stand_back - enemy_allframe)>=70) or (enemy_act==199 and (stand_neutral- enemy_allframe)>=70) or my_limit>=100
		) then 
			for i=1,10,1 do 
			print("起き攻め　⇒　システムカード宣言");
				if my_card==4 or my_card==5 or my_card==9 or my_card==10 or my_card==18 or my_card==19 then
					if battle_time%2==0 then
						key_on(ACT_BC);
					else
						key_off(ACT_BC);
					end
				else
					if battle_time%2==0 then
						key_on(ACT_AB);
					else
						key_off(ACT_AB);
					end
				end
				yield();
			end
		elseif math.random(3)<=2 then --悩んだ挙句、確率選択。
			while (enemy_act==97 or enemy_act==98 or (enemy_act>=70 and enemy_act<=107 and my_limit>=100) or (enemy_act==197 and (stand_front - enemy_allframe)>=14) or (enemy_act==198 and (stand_back - enemy_allframe)>=14) or (enemy_act==199 and (stand_neutral - enemy_allframe)>=14)) do
		--画面端に居たら前ダッシュで押す
				if y==0 and (my_act<=5 or my_act==200) and my_dir==1 and x<240 then
					print("起き攻め　⇒　画面端：６方向に６Ｄで押す");
					key_reset();
					key_on(ACT_RIGHT);
					key_on(ACT_D);
				elseif y==0 and (my_act<=5 or my_act==200) and my_dir==-1 and x>1040 then
					print("起き攻め　⇒　画面端：４方向に６Ｄで押す");
					key_reset();
					key_on(ACT_LEFT);
					key_on(ACT_D);
		--適当に距離調節
				elseif y==0 and (my_act<=5 or my_act==200) then
					print("起き攻め　⇒　地上：適当に距離調整");
					if my_rei>=300 then
						if dis>=600 then
							key_reset();
							key_on(ACT_D);			
							key_on(front);
							key_on(ACT_UP);
						elseif dis<600 and dis>350 then
							key_reset();
							key_on(ACT_D);	
							key_on(front);
						elseif dis<350 then
							if enemy_backside<=10 and enemy_act>=97 and enemy_act<=98 and enemy_standup_range>=dis+278-10 then
								key_reset();
								key_on(back);
							elseif dis<100 and enemy_act==197 and enemy_allframe<1 then
								if enemy_char~=6 then
									key_reset();
									key_on(ACT_D);	
									key_on(back);
								else
									key_reset();
									key_on(back)
								end
							else
								key_reset();		
								key_on(front);
							end
						end
					else
						key_reset();
						key_on(back);
						wait(3);
					end
				elseif y>=50 and my_air<=1 and my_act~=202 and my_act~=203 and (my_act~=209 or (my_act==209 and my_yspeed<-1)) then
					print("起き攻め　⇒　空中：適当に距離調整");
					if x<140 then
						if enemy_xspeed>=1 and math.random(2)==1 then
							key_reset();
							key_event(ACT_RIGHT);
							key_event(ACT_RIGHT);
						else
							key_reset();
							key_on(ACT_RIGHT);
						end
					elseif x>1140 then
						if enemy_xspeed>=1 and math.random(2)==1 then
							key_reset();
							key_event(ACT_LEFT);
							key_event(ACT_LEFT);
						else
							key_reset();
							key_on(ACT_LEFT);
						end
					elseif my_rei>=400 and dis>=400 then
						key_reset();
						key_event(front);
						key_event(front);
					end
				end
			yield();
			--kihon();
			end
		elseif math.random(3)==3 then --悩んだ挙句、確率選択。
			while (enemy_act==97 or enemy_act==98 or (enemy_act>=70 and enemy_act<=107 and my_limit>=100) or (enemy_act==197 and (stand_front - enemy_allframe)>=14) or (enemy_act==198 and (stand_back - enemy_allframe)>=14) or (enemy_act==199 and (stand_neutral - enemy_allframe)>=14)) do
			--全てが当てはまらない場合、飛び込みJAを重ねる
				if (enemy_act==197 or enemy_act==198 or enemy_act==199) and enemy_xspeed==0 and (my_act==202 or my_act==214) and y<=150 and dis<=300 and is_dir_front and
				(	(enemy_act==197 and stand_front	-	enemy_allframe<=15) or
					(enemy_act==198 and stand_back		-	enemy_allframe<=15) or
					(enemy_act==199 and stand_neutral	-	enemy_allframe<=15) 
				) then
					print("相手起き上がり終了間際　⇒　ＪＡ重ね");
					key_resetEX();
					wait(2);
					key_event(ACT_A);
				elseif (enemy_act==199) and y>0 and my_allframe>=30 and my_air==0 then
					print("相手：その場起き上がり　⇒　相手に向かって低空飛翔");
					key_resetEX();
					key_on(ACT_D);
					if dis<=200 then
						key_on(ACT_DOWN);
					else
						key_on(d_front);
					end
				elseif (enemy_act==197 or enemy_act==198) and y>0 then
					key_resetEX();
					if is_dir_front then
					print("相手正面：移動起き上がり　⇒　相手に向かって低空飛翔");
						key_on(ACT_D);
						key_on(front);
					else
					print("相手背面：移動起き上がり　⇒　相手に向かって低空飛翔");
						key_resetEX();
						wait(10);
						key_on(ACT_D);
						key_on(front);
					end
				elseif (enemy_act==98 or enemy_act==197 or enemy_act==198 or enemy_act==199) and y==0 then
					print("起き上がり確認　⇒　ＨＪ");
					key_resetEX();
					key_event2(ACT_D,ACT_UP);
				elseif (enemy_act==97 or enemy_act==98 or (enemy_act>=70 and enemy_act<=107 and my_limit>=100)) and y==0 then
					print("相手ダウン中　⇒　ダッシュで接近");
					key_resetEX();
					key_on(ACT_D);
					key_on(front);
				end
			yield();
			--kihon();
			end
--どれにも該当しなければ次のフレームへ
		else
		print("kihon：次のフレームへ");
			key_reset();
			yield();
			kihon();
		end
--▲

--コンボ
	elseif dis<=550 and enemy_act>=50 and enemy_act<=96 and my_limit<100 then
		combo();

--スペカ割り各種
--株割り
--画面端でJAから株
	elseif my_card==208 and my_act>=306 and enemy_act==158 and my_frontside<130 and dis<130 and disy>(-60+my_yspeed*10) and disy<(130+my_yspeed*10) and enemy_hitstop>=8 and my_rei>=400 and enemy_rei<500 and weather~=12 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset()
		key_event(ACT_A)
		wait(16)
		key_reset()
		key_on(ACT_BC)
		yield()
--画面端でJCから株
	elseif my_card==208 and my_act>=414 and my_allframe<=22 and enemy_act==158 and my_frontside<110 and dis<110 and disy>(-30+my_yspeed*10) and disy<(180+my_yspeed*10) and enemy_hitstop>=8 and my_rei>=200 and enemy_rei<400 and weather~=12 then
		key_reset()
		key_on(ACT_BC)
		yield()
--宝玉割り
--6Aから2B宝玉
	elseif my_card==209 and card_check(209) and my_spell_more(1000) and my_act==302 and (enemy_act==152 or enemy_act==165) and ((my_frontside>250 and dis<160) or (my_frontside<250 and dis>70)) and my_hitstop==9 and my_rei>=200 and ((enemy_rei>200 and enemy_rei<350) or (enemy_rei>=400 and enemy_rei<450 and my_frontside<200) or (enemy_hp<500 and enemy_rei<450)) and weather~=12 and math.random(2)==1 then
		key_reset()
		key_on(ACT_DOWN)
		wait(7)
		key_event(ACT_B)
		key_reset()
		wait(10)
		key_on(ACT_BC)
		yield()
--端AAAから2B宝玉
	elseif my_card==209 and card_check(209) and my_spell_more(1000) and my_act==321 and (enemy_act==151 or enemy_act==164) and my_frontside<180 and dis<160 and my_hitstop==9 and my_rei>=200 and ((enemy_rei>200 and enemy_rei<350) or (enemy_rei>=400 and enemy_rei<450) or (enemy_hp<500 and enemy_rei<450)) and weather~=12 and math.random(2)==1 then
		key_reset()
		key_on(ACT_DOWN)
		wait(7)
		key_event(ACT_B)
		key_reset()
		wait(10)
		key_on(ACT_BC)
		yield()
--2A誤ガードから2B宝玉
	elseif my_card==209 and card_check(209) and my_spell_more(1000) and my_act==303 and enemy_act==160 and ((my_frontside>250 and dis<160) or (my_frontside<250 and dis>100)) and my_hitstop==2 and my_rei>=200 and ((enemy_rei>200 and enemy_rei<350) or (enemy_rei>=400 and enemy_rei<450 and my_frontside<200) or (enemy_hp<500 and enemy_rei<450)) and weather~=12 and math.random(3)==1 then
		key_reset()
		key_on(ACT_DOWN)
		yield()
		key_event(ACT_B)
		key_reset()
		wait(10)
		key_on(ACT_BC)
		yield()
--DA誤ガードから宝玉
	elseif my_card==209 and card_check(209) and my_spell_more(1000) and my_act==305 and enemy_act==165 and ((my_frontside>250 and dis<160) or (my_frontside<250 and dis>70)) and my_hitstop==9 and (enemy_rei<150 or (enemy_rei>=400 and enemy_rei<450 and my_frontside<200) or (enemy_hp<500 and enemy_rei<250)) and weather~=12 and math.random(2)==1 then
		key_reset()
		key_on(ACT_BC)
		yield()
--端密着打撃から2B2C昇天宝玉
	elseif my_card==209 and card_check(209) and my_spell_more(1000) and (my_act==300 or my_act==303 or my_act==320 or my_act==330) and enemy_act>=150 and enemy_act<170 and my_frontside<90 and (dis<60 or (my_act~=303 and dis<80)) and (my_hitstop==9 or (my_act==303 and my_hitstop==2)) and my_rei>=600 and enemy_rei>=400 and (enemy_rei<550 or (enemy_rei>=600 and enemy_rei<650) or (enemy_hp<700 and enemy_rei<650)) and weather~=12 and math.random(2)==1 then
		key_reset()
		key_on(ACT_DOWN)
		if my_act==303 then
			wait(2)
		else
			wait(8)
		end
		key_event(ACT_B)
		wait(10)
		key_event(ACT_C)
		key_reset()
		wait(15)
		lvr623(ACT_C)
		wait(18)
		key_on(ACT_BC)
		yield()
--鬼縛陣割り
--端6Aから2B鬼縛陣
	elseif my_card==206 and card_check(206) and my_spell_more(2000) and my_act==302 and (enemy_act==152 or enemy_act==165) and my_frontside<160 and dis<130 and my_hitstop==9 and my_rei>=200 and ((enemy_rei>200 and enemy_rei<400) or (enemy_hp<500 and enemy_rei<600)) and weather~=12 and math.random(2)==1 then
		key_reset()
		key_on(ACT_DOWN)
		wait(7)
		key_event(ACT_B)
		key_reset()
		wait(10)
		key_on(ACT_BC)
		yield()
--端AAAから2B鬼縛陣
	elseif my_card==206 and card_check(206) and my_spell_more(2000) and my_act==321 and (enemy_act==151 or enemy_act==164) and my_frontside<160 and dis<140 and my_hitstop==9 and my_rei>=200 and ((enemy_rei>200 and enemy_rei<350) or (enemy_hp<500 and enemy_rei<450)) and weather~=12 and math.random(2)==1 then
		key_reset()
		key_on(ACT_DOWN)
		wait(7)
		key_event(ACT_B)
		key_reset()
		wait(10)
		key_on(ACT_BC)
		yield()
--端2A誤ガードから2B鬼縛陣
	elseif my_card==206 and card_check(206) and my_spell_more(2000) and my_act==303 and enemy_act==160 and my_frontside<160 and dis<130 and my_hitstop==2 and my_rei>=200 and ((enemy_rei>200 and enemy_rei<350) or (enemy_hp<500 and enemy_rei<600)) and weather~=12 and math.random(2)==1 then
		key_reset()
		key_on(ACT_DOWN)
		yield()
		key_event(ACT_B)
		key_reset()
		wait(10)
		key_on(ACT_BC)
		yield()
--端密着打撃から2B2C(昇天)鬼縛陣
	elseif my_card==206 and card_check(206) and my_spell_more(2000) and (my_act==300 or my_act==303 or my_act==320 or my_act==330) and enemy_act>=150 and enemy_act<170 and my_frontside<90 and (dis<60 or (my_act~=303 and dis<80)) and (my_hitstop==9 or (my_act==303 and my_hitstop==2)) and my_rei>=400 and ((enemy_rei>200 and enemy_rei<600) or (enemy_hp<500 and enemy_rei<800)) and weather~=12 and math.random(2)==1 then
		key_reset()
		key_on(ACT_DOWN)
		if my_act==303 then
			wait(2)
		else
			wait(8)
		end
		key_event(ACT_B)
		wait(10)
		key_event(ACT_C)
		if (enemy_act>=150 and enemy_act<170) or (enemy_act>=220 and enemy_act<=226) then
			if my_rei<600 or enemy_rei<400 then 
				key_reset()
				wait(15)
				key_on(ACT_BC)
				yield()
			else
				key_reset()
				wait(15)
				lvr623(ACT_C)
				wait(18)
				key_on(ACT_BC)
				yield()
			end
		end
--封印割り
--端密着打撃から2B2C封印
	elseif my_card==201 and card_check(201) and my_spell_more(2500) and (my_act==300 or my_act==320 or my_act==330) and enemy_act>=150 and enemy_act<170 and my_frontside<65 and dis<50 and my_hitstop==9 and my_rei>=400 and enemy_rei>=400 and enemy_rei<900 and math.random(2)==1 and (enemy_hp<900 or (enemy_char~=5 and enemy_char~=13 and enemy_char~=15 and weather~=12)) then
		key_reset()
		key_on(ACT_DOWN)
		if my_act==303 then
			wait(2)
		else
			wait(8)
		end
		key_event(ACT_B)
		wait(10)
		key_event(ACT_C)
		key_reset()
		wait(15)
		key_on(ACT_BC)
		yield()
--霊力300以下、相手空中でガードモーション中なら夢想封印。花曇では磨耗が強化されるので条件を緩く
	elseif card_check(201) and my_spell_more(2500) and enemy_act==158 and enemy_obj_range_in(150,60)==false and (enemy_rei<100 or (enemy_rei<300 and dis<300) or (enemy_rei<400 and weather==5)) and ey>100 and my_limit<100 and weather~=0 and weather~=4 and weather~=7 and weather~=11 then
		key_reset();
		if my_card==201 and enemy_frame<3 and (ey>180 or (disy>80 and my_frontside<130))then
			key_on(ACT_BC);
			wait(1);
			key_reset();
		elseif my_card~=201 then
			key_on(ACT_AB);
			wait(2);
			key_reset();
		end
--固め・崩し(距離別行動が優先され、失敗する場合がある)

--▼組み込み▼
--DA>妖怪バスター （結界つぶしのディレイつき
	elseif ((my_act==301 and enemy_act>=159 and enemy_act<=166) or (my_act==302 and enemy_backside>=140) or (my_act==303 and enemy_act>=159 and enemy_act<=166) or my_act==305) and enemy_act>=145 and enemy_act<=166 and card_check(104) then
	print("打撃＞妖怪バスター行動１");
		while my_card~=104 and ((my_act==301 and enemy_act>=159 and enemy_act<=166) or (my_act==302 and enemy_backside>=140) or (my_act==303 and enemy_act>=159 and enemy_act<=166) or my_act==305) and my_allframe<=10 do
			card_1st(104)
			yield();
		end
		if math.random(3)==1 and my_hitstop<=3 then
			lvr623(d_front);
			if enemy_act>=220 and enemy_act<=226 then
				key_event(ACT_C);
			else
				key_reset();
				card_use(104);
			end
		else
			key_reset();
			card_use(104);
		end
	elseif ((my_act==301 and enemy_act>=159 and enemy_act<=166) or (my_act==302 and enemy_backside>=140) or (my_act==303 and enemy_act>=159 and enemy_act<=166) or my_act==305) and my_hitstop<=3 and enemy_act>=145 and enemy_act<=166 and get_skill_lv(0,4)>=0 and my_rei>=200 then
	print("打撃＞妖怪バスター行動２");
		if math.random(3)==1 then
			key_reset();	key_on(front); yield(); 
			key_reset(); key_on(ACT_DOWN); yield();
			key_on(front); yield();
			if enemy_act>=220 and enemy_act<=226 then
				key_event(ACT_C);
			else
				key_reset();
				key_on(ACT_D); yield();
				lvr236(ACT_B);
			end
		else
			key_reset();
			key_on(ACT_D); yield();key_reset();
			lvr236(ACT_B);
		end
--▲組み込み▲

--警戒状態では使わない連携
--A6A
	elseif caution_atk==0 and my_act==300 and dis<=200 and my_hitstop==7 and enemy_act>=150 and enemy_act<=170 and math.random(5)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_on(front)
		wait(6);
		key_event(ACT_A);
--AAディレイA、もしくはAA6A
	elseif caution_atk==0 and (my_act==320 or my_act==330) and dis<=200 and my_hitstop==9 and enemy_act>=150 and enemy_act<=170 and math.random(3)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
		if dis<130 and math.random(2)==1 then
			key_reset();
			wait(13+math.random(7))
			key_event(ACT_A);
		else
			key_reset();
			key_on(front)
			wait(7);
			key_event(ACT_A);
		end
--AAがガードされたらランダムで溜め6Aに派生
	elseif caution_atk==0 and (my_act==320 or my_act==330)  and dis<=180 and enemy_act>=150 and enemy_act<=170 and math.random(32)==1 and my_hitstop>6 and my_hitstop<=9 and enemy_rei>=600 and muteki_sp==0 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		yield();
		key_on(ACT_A);
		key_on(front);
		wait(25);
		key_reset();
--AAがガードされたらランダムで溜め3Aに派生
	elseif caution_atk==0 and (my_act==320 or my_act==330)  and dis<=180 and enemy_act>=150 and enemy_act<=170 and math.random(52)==1 and my_hitstop>6 and my_hitstop<=9 and enemy_rei>=600 and muteki_sp==0 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_on(ACT_A);
		key_on(ACT_DOWN);
		key_on(front);
		wait(25);
		key_reset();
--A連がガードされたらランダムで2B射撃に派生
	elseif caution_atk==0 and (my_act==300 or my_act==320 or my_act==321 or my_act==330) and dis>=80 and dis<=150 and enemy_act>=150 and enemy_act<=170 and math.random(12)==1 and my_frame<=11 and my_rei>=200 then
		key_reset();
		key_on(ACT_DOWN)
		yield();
		key_event(ACT_B);
--A連がガードされたらランダムで溜めB射撃に派生
	elseif caution_atk==0 and (my_act==300 or my_act==320 or my_act==321 or my_act==330) and dis>=80 and dis<=150 and enemy_act>=150 and enemy_act<=170 and math.random(73)==1 and my_frame<=11 and my_rei>=200 and muteki_sp==0 then
		key_reset();
		key_on(ACT_B);
		wait(20);
		key_reset();
--AAAがガードされたらランダムでAAAAに派生
	elseif caution_atk==0 and my_act==321 and dis<=200 and enemy_act>=150 and enemy_act<=170 and ((my_hitstop>0 and math.random(16)==1) or (my_frame>=13 and math.random(10)==1)) and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_event(ACT_A);
--2Aがガードされたらランダムで溜めB射撃に派生
	elseif caution_atk==0 and my_act==303 and dis<=200 and enemy_act>=150 and enemy_act<=170 and math.random(76)==1 and my_frame>10 and my_frame<=26 and my_rei>=300 and muteki_sp==0 then
		key_reset();
		key_on(ACT_B);
		wait(20);
		key_reset();
--2Aがガードされたらランダムで2B射撃に派生
	elseif caution_atk==0 and my_act==303 and dis<=200 and enemy_act>=150 and enemy_act<=170 and math.random(17)==1 and my_frame>10 and my_frame<=26 and my_rei>=300 then
		key_reset();
		key_event2(ACT_B,ACT_DOWN);
--2Aがガードされたら高確率で6Aに派生
	elseif caution_atk==0 and my_act==303 and dis<=250 and dis>120 and enemy_act>=150 and enemy_act<=157 and math.random(3)==1 and my_frame<=26 and my_frame>10 and my_rei>=200 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_on(front)
		yield();
		key_event(ACT_A);
--2Aがガードされたらランダムで溜め6Aに派生
	elseif caution_atk==0 and my_act==303 and dis<=180 and enemy_act>=150 and enemy_act<=170 and math.random(32)==1 and my_frame>10 and my_frame<=16 and enemy_rei>=600 and muteki_sp==0 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		yield();
		key_on(ACT_A);
		key_on(front);
		wait(25);
		key_reset();
--2Aがガードされたらランダムで溜め3Aに派生
	elseif caution_atk==0 and my_act==303 and dis<=250 and enemy_act>=150 and enemy_act<=170 and math.random(50)==1 and my_frame>10 and my_frame<=16 and enemy_rei>=600 and muteki_sp==0 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_on(ACT_A);
		key_on(ACT_DOWN);
		key_on(front);
		wait(25);
		key_reset();
--端で近距離なら2BからランダムでCに派生
	elseif caution_atk==0 and my_act==402 and my_frontside<250 and dis<240 and my_allframe==8 and enemy_act>=150 and enemy_act<=170 and math.random(4)==1 and my_rei>300 then
		key_reset()
		yield()
		key_event(ACT_C)
--H6Aをガードされたら警戒
	elseif my_act==302 and enemy_act==153 and caution_atk==0 then
		key_reset()
		caution_atk = 10 + math.random(15)
--H3Aをガードされたら警戒
	elseif my_act==304 and enemy_act==157 and caution_atk==0 then
		key_reset()
		caution_atk = 10 + math.random(15)	
--遠Aがガードされたらランダムで6Aか2B射撃に派生
	elseif caution_atk==0 and my_act==301 and dis<=300 and enemy_act>=150 and enemy_act<=170 and math.random(3)<=2 and my_hitstop>=8 then
		if my_rei>=300 and math.random(2)==1 then
			key_reset();
			key_event2(ACT_B,ACT_DOWN);
		elseif dis<=240-40 then
			key_reset();
			key_on(front)
			wait(math.random(17));
			key_event(ACT_A);
		end
--DAが正ガードされたらランダムで警戒
	elseif caution_atk==0 and my_act==305 and dis<=350 and enemy_act~=165 and math.random(13)==1 and my_frame>=31 and enemy_rei>300 then
		key_reset();
		key_on(back);
		caution_atk = 5 + math.random(10);
		yield();
--JAが地上ガードされたらランダムでJ2B射撃に派生
	elseif caution_atk==0 and my_act==306 and dis<=220 and ((ex>80 and ex<1200) or dis>50) and (y+my_yspeed*14)>=0 and enemy_act>=150 and enemy_act<=170 and enemy_act~=158 and my_rei>=300 and my_hitstop>0 and my_hitstop<8 and my_air<=1 and math.random(6)==1 then
		key_reset();
		key_event2(ACT_B,ACT_DOWN);
--JAが地上ガードされたらランダムでJ6Aに派生。ここからJ2Bを撃って攻める(もしくは結界される)ので霊力400以上と飛翔回数残存を条件に入れる
	elseif caution_atk==0 and my_act==306 and dis<=200 and y<20 and enemy_act>=150 and enemy_act<=170 and enemy_act~=158 and my_rei>=400 and my_air<=1 and math.random(11)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_event2(ACT_A,front);
--低空で行動可能状態ならランダムでJAかJ6Aに派生
	elseif caution_atk==0 and my_act==306 and dis<=200 and y>0 and y<=30 and my_act==9 and enemy_act~=158 and math.random(5)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
		if my_rei>=400 and math.random(4)==1 then
			key_reset();
			key_event2(ACT_A,front);
		else
			key_reset();
			key_event(ACT_A);
		end
--低空J2Bが地上ガードされたら前ダッシュかJCに派生
	elseif caution_atk==0 and my_act==406 and dis<=250 and y<150 and enemy_act>=150 and enemy_act<=170 and enemy_act~=158 and my_allframe>=17 and (math.random(8)==1 or my_allframe>=23) and my_air<=1 then
		if my_rei>300 and math.random(4)==1 then
			key_reset()
			key_event(ACT_C)
		else
			key_reset();
			key_on(front);
			yield();
			key_reset();
			yield();
			key_event(front);
		end
--低空JCから前ダッシュに派生
	elseif caution_atk==0 and my_act==414 and my_allframe>=22 and dis<=250 and y<150 then
		key_reset();
		key_on(front);
		yield();
		key_reset();
		key_event(front); --]]
--警戒状態でも使う連携


--AA
	elseif my_act==300 and dis<=110 and my_hitstop>0 and my_hitstop<8 and enemy_act>=150 and enemy_act<=170 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_event(ACT_A);
--AAA
	elseif caution_atk==0 and my_act==320 and dis<=130 and my_hitstop>0 and enemy_act>=150 and enemy_act<=170 and math.random(2)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_event(ACT_A);
--4AA
	elseif my_act==330 and dis<=80 and my_hitstop>0 and enemy_act>=150 and enemy_act<=170 and math.random(2)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_event2(ACT_A,back);
--AAAAがガードされたらガード仕込み後退
	elseif my_act==322 and dis<=200 and enemy_act>=150 and enemy_act<=170 and my_frame>=16 then
		key_reset();
		key_on(back);
		caution_atk = 15 + math.random(15);
		yield();
--AA止め
	elseif my_act==320 and my_frame==0 and enemy_act>=150 and enemy_act<=170 and (math.random(7)<=3 or dis>140) then
		caution_atk = 1;
		yield();
--4A止め
	elseif my_act==330 and my_frame==0 and enemy_act>=150 and enemy_act<=170 and (math.random(7)<=3 or dis>110) then
		caution_atk = 1;
		yield();
--2A止め
	elseif my_act==303 and dis<200 and my_hitstop==2 and my_frame==8 and enemy_act>=150 and enemy_act<=170 and (math.random(7)==1 or (my_rei<400 and math.random(2)==1)) then
		caution_atk = 1;
		yield();
--遠A止め
	elseif my_act==301 and dis<250 and my_hitstop==2 and my_frame==12 and enemy_act>=150 and enemy_act<=170 and (math.random(7)<=2 or (my_rei<400 and math.random(2)==1)) then
		caution_atk = 1;
		yield();
--AAAがガードされたらランダムで2B射撃に派生
	elseif my_act==321 and dis<=150 and enemy_act>=150 and enemy_act<=170 and math.random(5)==1 and my_frame<=12 and my_rei>=300 then
		key_reset();
		key_on(ACT_DOWN)
		yield();
		key_event(ACT_B);
--2Aが誤ガードされたら高確率で2B射撃に派生
	elseif my_act==303 and dis<=250 and enemy_act>=159 and enemy_act<=170 and math.random(7)==1 and my_frame>10 and my_frame<=26 and my_rei>=400 then
		key_reset();
		key_on(ACT_DOWN)
		yield();
		key_event(ACT_B);
--6Aがガードされたらランダムで2B射撃に派生
	elseif my_act==302 and dis<=300 and enemy_act>=150 and enemy_act<=170 and math.random(4)==1 and my_frame<=20 and my_rei>=300 then
		key_reset();
		key_on(ACT_DOWN)
		yield();
		key_event(ACT_B);
--6Aが誤ガードされたら高確率で2B射撃に派生
	elseif my_act==302 and dis<=300 and enemy_act>=159 and enemy_act<=170 and math.random(2)==1 and my_frame<=26 and my_rei>=300 then
		key_reset();
		yield();
		key_event2(ACT_B,ACT_DOWN);
--3Aがガードされたら博麗アミュでフォロー
	elseif my_act==304 and dis<=250 and enemy_act>=150 and enemy_act<=170 and my_rei>=200 and my_allframe>12 then
		if y>0 then
			if ey==0 and math.random(3)==1 then
				key_reset();
				lvr421(ACT_B);
			else
				key_reset();
				lvr236(ACT_B);
			end
		elseif y==0 then
			key_on(back);
			wait(30);
		end
--J6Aが地上ガードされたらJ2B射撃に派生
	elseif my_act==307 and dis<=150 and enemy_act>=150 and enemy_act<=170 and enemy_act~=158 and my_rei>=200 then
		key_reset();
--		key_event2(ACT_B,ACT_DOWN);
		key_event(ACT_C);
--警戒中に低空J2Bが地上ガードされたら後ダッシュに派生
	elseif caution_atk>0 and (my_act==406 or my_act==414) and dis<=250 and y<120 and enemy_act>=150 and enemy_act<=170 and enemy_act~=158 and my_allframe>=17 and my_air<=1 and math.random(12)==1 then
		key_reset();
		key_on(back);
		yield();
		key_reset();
		yield();
		key_on(back);
--端で上回避結界されたら垂直HJで追うか後ろHJで仕切り直し
	elseif (my_act<=8 or my_act==400 or my_act==402) and (enemy_act==220 or enemy_act==222) and dis<=300 and (x<240 or x>1040) then
		if my_rei>400 and math.random(2)==1 then
			key_reset();
			key_event2(ACT_UP,ACT_D);
			key_reset();
		else
			key_reset();
			key_on(back);
			key_event2(ACT_UP,ACT_D);
			key_reset();
		end
--JAで上回避結界されたらJ6Aで狩る。JAで上結界してくれる人はまず居ないと思うけど…。
	elseif my_act==306 and (enemy_act==220 or enemy_act==222) and dis<=300 and (x<240 or x>1040) and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_on(front);
		wait(1);
		key_event(ACT_A);
		key_reset();
--近距離で前HJしたら低空J6A、低空J2Bに派生
	elseif dis<=350 and my_rei>200 and (my_act==7 or my_act==209 or my_act==212) and y==0 and ey==0 and (my_allframe==0 or my_allframe==1) and enemy_act~=97 and enemy_act~=197 and enemy_act~=198 and enemy_act~=199 then
		if (((enemy_char==2 or enemy_char==5 or enemy_char==6 or enemy_char==9 or enemy_char==10) and ((dis<140 and math.random(2)==1) or (dis<180 and math.random(4)==1))) or
		((enemy_char==0 or enemy_char==1 or enemy_char==3 or enemy_char==4 or enemy_char==7 or enemy_char==11) and ((dis<160 and math.random(2)==1) or (dis<200 and math.random(4)==1))) or 
		((enemy_char==8 or enemy_char==12 or enemy_char==13 or enemy_char==14) and ((dis<180 and math.random(2)==1) or (dis<220 and math.random(4)==1)))) and search_JFP()==false and get_special_data(0,10)<=5 then
			key_reset();
			key_on(front);
			if my_allframe==0 then
				wait(2);
			else
				wait(1);
			end
			key_event(ACT_A);
		elseif dis>80 and (math.random(10)<=7 or (x<340 and my_dir==-1) or (x>940 and my_dir==1)) and enemy_act~=200 then
			if dis>240 and math.random(2)==1 then
				key_reset();
				if my_allframe==0 then
					wait(2);
				else
					wait(1);
				end
				key_event(ACT_C);
			else
				key_reset();
				key_on(ACT_DOWN);
				if my_allframe==0 then
					wait(2);
				else
					wait(1);
				end
				key_event(ACT_B);
			end
		end
--端近くで最低空行動に失敗した場合、最低空じゃないけどJ2BかJC
	elseif dis<=350 and my_rei>200 and (my_act==7 or my_act==209 or my_act==212) and y==0 and ey==0 and (my_allframe==2 or my_allframe==3) and enemy_act~=97 and enemy_act~=197 and enemy_act~=198 and enemy_act~=199 and ((x<340 and my_dir==-1) or (x>940 and my_dir==1)) and math.random(2)==1 then
		if dis>100 and enemy_act~=200 then
			if dis>240 and math.random(2)==1 then
				key_reset();
				wait(1);
				key_event(ACT_C);
			else
				key_reset();
				key_on(ACT_DOWN);
				wait(1);
				key_event(ACT_B);
			end
		end
--台風でAを当てたら最後まで
	elseif weather==13 and my_act==300 and my_hitstop>0 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_event(ACT_A);
	elseif weather==13 and my_act==320 and my_hitstop>0 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_event(ACT_A);
	elseif weather==13 and my_act==321 and my_hitstop>0 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_event(ACT_A);
--台風で3Aを当てたらB亜空穴
	elseif weather==13 and (my_act==304 or my_act==306) and ey<=50 and my_rei>=200 and my_hitstop>0 then
		key_reset();
		lvr421(ACT_B);
--各種隙消し
--JA、J8Aが空中ガードされたらランダムでB射撃かC射撃に派生
	elseif (my_act==306 or my_act==309) and enemy_act==158 and dis<250 and ((dis<=150 and (y-ey)<=80 and (ey-y)<=80) or (dis>150 and (y-ey)<=130 and (ey-y)<=130)) and my_hitstop>0 and my_hitstop<7 and math.random(8)==1 and my_rei>=200 and my_yspeed>-4 then
		if math.random(2)==1 then
			key_reset();
			key_event(ACT_B);
		else
			key_reset()
			key_event(ACT_C)
		end
--JA、J8Aが空中ガードされたらランダムでC射撃に派生
	elseif (my_act==306 or my_act==309) and dis>150 and dis<=250 and enemy_act==158 and (y-ey)<=180 and (ey-y)<=180 and my_hitstop>0 and my_hitstop<7 and math.random(12)==1 and my_rei>=200 and my_yspeed>-4 then
		if math.random(12)==1 then
			key_reset();
			key_on(ACT_C);
			wait(25);
		else
			key_reset();
			key_event(ACT_C);
		end
--J6Aが空中ガードされたらB射撃かCに派生。
	elseif my_act==308 and dis<=250 and enemy_act==158 and my_hitstop>0 and my_hitstop<7 and (y-ey)<=150 and (ey-y)<=150 and my_rei>=200 then
		if math.random(3)<=2 then
			key_reset();
			key_event(ACT_B);
		else
			key_reset();
			key_event(ACT_C)
		end
--JA、J8Aが端かつ近距離で空中ガードされたらJB射撃に派生
	elseif (my_act==306 or my_act==309) and dis<=80 and enemy_act==158 and (y-ey)<=180 and (ey-y)<=250 and my_frontside<150 and my_hitstop>0 and my_hitstop<7 and my_rei>=200 and y>120 and my_yspeed>-5 then
		if disy>-100 and disy<100 and math.random(2)==1 then
			key_reset()
			key_event(ACT_C)
		else
			key_reset();
			key_event(ACT_B);
		end
		if ey>200 then
			key_event(back)
			key_on(back)
			yield()
		end
--J6Aが端かつ近距離で空中ガードされたらJB射撃に派生
	elseif my_act==307 and dis<=80 and enemy_act==158 and (y-ey)<=160 and (ey-y)<=80 and ((x<140 and my_dir==-1) or (x>1140 and my_dir==1)) and my_hitstop>0 and my_hitstop<7 and my_rei>=200 and my_yspeed>-4 then
		if disy>-100 and disy<100 and math.random(2)==1 then
			key_reset()
			key_event(ACT_C)
		else
			key_reset();
			key_event(ACT_B);
		end
--JAが空中ガードされたらランダムでJ8Aに派生
	elseif my_act==306 and dis<=80 and enemy_act==158 and (y-ey)<=0 and (ey-y)<=150 and math.random(5)==1 and my_allframe>9 and my_allframe<=25 and my_yspeed>-3 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_event2(ACT_A,ACT_UP);
--JAが空中ガードされたらランダムでJ6Aに派生
	elseif my_act==306 and dis<=200 and enemy_act==158 and (y-ey)<=70 and (ey-y)<=0 and math.random(20)==1 and my_frame<=22 and my_yspeed>-4 and search_JFP()==false and get_special_data(0,10)<=5 then
		key_reset();
		key_event2(ACT_A,front);
--B射撃から前HJに派生
	elseif weather~=5 and my_act==400 and dis<=300 and my_rei>=200 and my_allframe==26 and ((enemy_act>=150 and enemy_act<=170 and (math.random(5)==1 or (dis<130 and math.random(5)<=2))) or math.random(6)==1) then
		key_reset();
		key_on(ACT_UP);
		key_on(front);
		yield();
		key_reset();
--2B射撃から前HJに派生
	elseif weather~=5 and my_act==402 and dis<=300 and my_rei>=200 and my_allframe==23 and ((enemy_act>=150 and enemy_act<=170 and dis<130 and math.random(7)<=2) or math.random(6)==1) then
		key_reset();
		key_on(ACT_UP);
		key_on(front);
		yield();
		key_reset();
--地上射撃やったときに敵が中距離か背後にいたら前HJ
	elseif (my_act==400 or my_act==401 or my_act==402 or my_act==410 or my_act==412 or my_act==500) and dis<=500 and (y-ey)<300 and (ey-y)<300 and my_rei>200 and (dis>250 or (my_dir+enemy_dir)~=0) and weather~=5 then
		key_reset();
		key_on(ACT_UP);
		key_on(front);
--6B対空から前HJか後HJ
	elseif my_act==401 and dis<500 and weather~=5 then
		if (dis<100 or ey<100) then
			key_reset();
			key_on(ACT_UP);
			key_on(back)
		else
			key_reset();
			key_on(ACT_UP);
			key_on(front)	
		end
--空中射撃中に敵がグレイズで抜けてきたら後方ダッシュか飛翔
	elseif (my_act==404 or my_act==406 or my_act==414 or my_act==416 or my_act==502) and enemy_act>=200 and enemy_act<=214 and enemy_act~=201 and dis<=300 and (y-ey)<240 and (ey-y)<240 and y>=80 and my_air<=1 then
		if (my_act==404 or my_act==406) and ey>20 and enemy_xspeed>4 and dis<250 and my_rei>300 and math.random(2)==1 then
			key_reset()
			wait(math.random(10))
			key_event(ACT_C)
		elseif dis>100 and ey==0 and math.random(2)==1 and my_air==0 and ((x>=540 and my_dir==-1) or (x<=740 and my_dir==1)) then
			key_reset();
			key_on(front)
			key_event2(ACT_UP,ACT_D);
		elseif dis>100 and y>ey and math.random(2)==1 and my_air==0 then
			if math.random(2)==1 then
				key_reset();
				key_on(front);
				key_event2(ACT_UP,ACT_D);
			else
				key_reset();
				key_event2(ACT_UP,ACT_D);
			end
		else
			print("４４");
			key_reset();
			key_event(back);
			key_on(back);
			yield();
		end
--J2B中に敵がこちらより上に居たら後方ダッシュか上飛翔
	elseif my_act==406 and enemy_act~=201 and dis<=300 and ey>=20 and (y-ey)<60 and (ey-y)<400 and my_air<=1 then
		if my_air==0 and math.random(3)==1 then
			key_reset();
			key_event2(ACT_UP,ACT_D);
		else
			print("コマンド４４");
			key_reset();
			key_event(back);
			key_on(back);
			yield();
		end
--JB中に敵が近くに居たら後方ダッシュ
	elseif my_act==404 and dis<70 and y>=20 and ey>=20 and my_air<=1 then
			print("コマンド４４：１");
		key_reset();
		key_event(back);
		key_on(back);
		yield();
--昇りJ2B射撃やったときに敵が近距離・地上にいたらダッシュ
	elseif my_act==404 and my_allframe>=17 and dis<=500 and (dis>=120 or ex<50 or ex>1230) and ey<=20 and my_rei>200 and my_air<=1 and my_yspeed>2 and math.random(3)==1 then
		key_reset();
		key_on(front)
		yield();
		key_reset();
		yield();
		key_event(front);
--空中B射撃やったときに敵が中距離・地上にいたら適当なところでダッシュか6飛翔
	elseif ((my_act==404 and my_allframe>=17) or my_act==406) and dis<=500 and dis>=150 and ey==0 and my_rei>200 and my_air<=1 and (my_yspeed<2 or dis>350) and math.random(10)==1 then
		if dis<370 or y<=150 then
			key_reset();
			key_event2(ACT_D,front);
		elseif y>150 then
			key_reset();
			key_event(front);
			key_event(front);
		end
--空中C射撃・アミュやったときに敵が中距離・地上にいたらダッシュか6飛翔
	elseif (my_act==414 or my_act==416 or my_act==502) and dis<=500 and dis>=250 and ey==0 and my_rei>200 and my_air<=1 and math.random(4)==1 and weather~=5 then
		if dis<370 or y<=180 then
			key_reset();
			key_event2(ACT_D,front);
		elseif y>180 then
			key_reset();
			key_event(front);
			key_event(front);
		end
--空中射撃やったときに敵が中距離、同じくらいの高度にいたらダッシュ
	elseif (my_act==404 or my_act==406 or my_act==414 or my_act==416 or my_act==502) and dis<=400 and dis>=150 and ey>0 and (y-ey)<20 and (ey-y)<120 and my_rei>200 and my_air<=1 and weather~=5 then
		key_reset();
		key_event(front);
		key_event(front);
--空中射撃やったときに近距離で、敵がこちらよりかなり上に居たらバックダッシュ
	elseif (my_act==404 or my_act==406 or my_act==414 or my_act==416 or my_act==502) and y>=20 and dis<=120 and ey>0 and (y-ey)<-150 and (ey-y)<300 and my_air<=1 and weather~=5 and math.random(2)==1 then
			print("コマンド４４：１");
		key_reset();
		key_event(back);
		key_on(back);
		yield();
--空中射撃やったときに敵が中距離、やや高めの高度にいたら9飛翔
	elseif (my_act==404 or my_act==406 or my_act==414 or my_act==416 or my_act==502) and dis<=300 and (dis>=60 or my_frontside<100) and (y-ey)<-50 and (ey-y)<300 and my_rei>200 and enemy_rei<500 and my_air==0 then
		key_reset();
		key_on(front);
		key_event2(ACT_D,ACT_UP);
--地上射撃やったときに敵が上から来てたらダメ元で昇天脚
	elseif is_dir_front and (my_act==400 or my_act==401 or my_act==402 or my_act==410) and dis<=200 and ey<200 and ey>80 and enemy_act>=306 and enemy_act<=309 then
		key_reset();
		lvr623(ACT_B);
		
		
--▼組み込み連携▼
--バスター＞封印割り
	elseif my_act>=505 and my_act<=509 and my_allframe<=10 and enemy_act>=150 and enemy_act<=166 and dis<=300 and card_check(201) and my_spell_more(2500) then
		key_reset();
		card_1st(201);
	elseif my_act>=505 and my_act<=509 and enemy_act>=150 and enemy_act<=166 and my_frontside>=200 and my_frontside<=320 and my_card==201 and my_spell_more(2500) then
	print("バスター＞封印割り：実行");
		key_reset();
		key_event(ACT_BC);
		wait(10);
		while (my_act==601 or my_act==651) do
			--print("神霊「夢想封印」中は待機");
			yield();
		end
		key_reset(); key_on(ACT_D); key_on(front);
		wait(30);
		if ey>0 then
			wait(2);
		end
		key_reset();
		if ((enemy_act>=50 and enemy_act<=89) or (enemy_act>=143 and enemy_act<=145)) then
			if ey>0 then
				while not(ey>0 and ey<=80 and enemy_yspeed<0) do
					yield();
				end
			end
			if ey>0 and ey<=80 and enemy_yspeed<-1 then
				key_reset();		print("A");
				key_event(ACT_A);
				wait(8+7);
				if enemy_act==71 and enemy_frame<=5 then
					print("AA");
					key_event(ACT_A);
					wait(7+7);
					if enemy_act==71 and enemy_frame<=15 then
						print("AAA");
						key_event(ACT_A);
						wait(9+7);
						if enemy_act==71 and enemy_frame<=5 then
							print("6B");
							key_event2(ACT_B,front);
							wait(27);
							if enemy_act==71 and enemy_frame<=5 then
								print("9hjc");
								key_on(u_front);
								wait(5);
								if enemy_act==71 and enemy_frame<=5 then
									print("JA");
									key_reset();
									key_event(ACT_A);
									wait(10+7);
									if enemy_act==71 and enemy_frame<=5 then
										print("J8A");
										key_event2(ACT_A,ACT_UP);
										wait(9+7);
										if enemy_act==71 and enemy_frame<=5 then
											print("JC");
											key_event(ACT_C);
										end
									end
								end
							end
						end
					end
				end
			elseif y==0 then
				key_reset(); print("A");
				key_event(ACT_A);
			end
		end
		
--宝具「陰陽鬼神玉」割り準備：事前２B
	elseif card_check(210) and my_spell_more(2000) and my_frontside>=400 and enemy_rei<=500 and (my_act==302 or my_act==303) and enemy_act>=159 and enemy_act<=166 and enemy_frame<=1 then
		print("割り行動：準備　⇒　誤ガード確認：２B");
		key_reset();
		key_on(ACT_DOWN);
		key_event(ACT_B);
--(打撃誤ガ)＞２B＞青球
	elseif card_check(210) and my_spell_more(2000) and my_frontside>=400 and enemy_rei<=500 and dis<350 and y==0 and my_act==402 and my_allframe<=10 and enemy_act>=159 and enemy_act<=166 and my_card~=210 then
		print("割り行動：準備　⇒　宝具「陰陽鬼神玉」");
		key_reset();
		card_1st(210);
	elseif card_check(210) and my_spell_more(2000) and my_frontside>=400 and enemy_rei<=500 and dis<350 and y==0 and my_act==402 and my_allframe>=11 and enemy_act>=159 and enemy_act<=166 and is_dir_front and my_card==210 then
		print("割り行動：実行　⇒　宝具「陰陽鬼神玉」");
		key_reset();
		key_event(ACT_BC);
--中央
--A or AA>(>JA>)>J2B>JA>J6A>JC>アミュ〜
		elseif dis<=250 and my_act==306 and ey==0 and my_yspeed>=3 and my_hitstop<=3 and my_hitstop>=1 then
print("JA>J2B");
			key_reset();
			key_event2(ACT_B,ACT_DOWN);
		elseif dis<=250 and my_act==406 and enemy_act>=150 and enemy_act<=166 and ey==0 and my_allframe>=23 then
print("J2B>J3D");
			key_reset();
			key_on(ACT_D);
			key_on(d_front);
			elseif dis<=250 and my_act==214 and my_xspeed>=1 and my_yspeed<=-1 and enemy_act>=150 and enemy_act<=166 and ey==0 and my_allframe>=8 and (enemy_char~=13 or enemy_char~=4 or enemy_char~=14 or (enemy_char==4 and search_JFP()==false) or (enemy_char==14 and get_special_data(0,10)<=5)) then
print("J3D>JA");
				key_reset();
				key_event(ACT_A);
--J6A>JC>アミュ>JA>〜
			elseif dis<=80 and my_act==306 and enemy_act>=150 and enemy_act<=166 and dis<=200 and ey-y>=-50 and ey==0 and my_hitstop<=3 and my_hitstop>=1 and search_JFP()==false and get_special_data(0,10)<=5 and math.random(after_guard_count+4)==1 then
print("JA>J6A");
				key_reset();
				key_event2(ACT_A,front);
				elseif dis<=80 and my_act==307 and enemy_act>=150 and enemy_act<=166 and ((dis<=120 and math.random(after_guard_count+4)==1)or(dis<=80)) and ey==0 and my_hitstop<=3 and my_hitstop>=1 then
print("J6A>JC");
					key_reset();
					key_event(ACT_C);
					elseif dis<=150 and my_act==414 and enemy_act>=150 and enemy_act<=166 and enemy_frame<=5 and dis<=200 and my_frontside>=300 and ey==0 then
print("JC>236コマンド");
						key_reset();
						lvr236(ACT_B);
					elseif dis<=250 and my_act>=500 and my_act<=504 and enemy_act>=150 and enemy_act<=166 and ey==0 then
print("236コマンド>J66");
						key_reset();
						key_event(front);
						key_event(front);
						elseif dis<=250 and my_act==202 and enemy_act>=150 and enemy_act<=166 and ey==0 and search_JFP()==false and get_special_data(0,10)<=5 then
print("J66>JA");
							key_reset();
							key_event(ACT_A);

--画面端
--2B>2C>スペカ
	elseif ((my_act==300 or my_act==306 or my_act==320 or my_act==330) or(my_act==302 or my_act==303 or my_act==304 or my_act==321)) and enemy_act>=150 and enemy_act<=166 and ey==0 and my_hitstop<=3 and my_hitstop>=1 and ((my_dir==1 and x>=1140)or(my_dir==-1 and x<=140)) and is_dir_front==true then
print("〜>2B");
		key_reset();
		key_event2(ACT_B,ACT_DOWN);
		elseif my_act==402 and enemy_act>=150 and enemy_act<=166 and ey==0 and my_rei>=200 and ((my_dir==1 and x>=1140)or(my_dir==-1 and x<=140)) and is_dir_front==true then
print("〜>2B>（画面端）2C");
			key_reset();
			key_event2(ACT_C,ACT_DOWN);
			elseif my_act==412 and enemy_act>=150 and enemy_act<=166 and ey==0 and (
			(my_card==200 and enemy_rei<=500) or
			(my_card==201 and enemy_rei<=500) or
			(my_card==204 and enemy_rei<=250) or 
			(my_card==206 and enemy_rei<=420) or 
			(my_card==207 and enemy_rei<=200) or 
			(my_card==209 and enemy_rei<=250)  
			) and is_card_use==true and ((my_dir==1 and x>=1000)or(my_dir==-1 and x<=280)) and is_dir_front==true then
print("〜>2B>（画面端）2C>（霊力少量）スペカ");
				key_reset();
				key_event(ACT_BC);
				elseif my_act==412 and my_allframe<=10 and my_frontside<=240 then
					if card_check(201) and my_spell_more(2500) then
						card_1st(201);
					elseif card_check(200) and my_spell_more(1000) then
						card_1st(200);
					elseif card_check(206) and my_spell_more(2000) then
						card_1st(206);
					elseif card_check(209) and my_spell_more(1000) then
						card_1st(209);
					elseif card_check(204) and my_spell_more(1000) then
						card_1st(204);
					elseif card_check(210) and my_spell_more(2000) then
						card_1st(210);
					elseif card_check(207) and my_spell_more(1500) then
						card_1st(207);
					end
				elseif my_act==402 and my_allframe<=10 and dis<=240 then
					if card_check(201) and my_spell_more(2500) then
						card_1st(201);
					elseif card_check(209) and my_spell_more(1000) then
						card_1st(209);
					elseif card_check(210) and my_spell_more(2000) then
						card_1st(210);
					end

--空中固め
--J6A>JC
	elseif my_act==307 and enemy_act>=150 and enemy_act<=166 and dis<=80 and ey>0 and my_hitstop<=3 and my_hitstop>=1 and math.random(2)==1 then
print("J6A>JC");
		key_reset();
		key_event(ACT_C);
--〜>(JA>J2B or JB)>8飛翔>(JA>JC)>8飛翔>(JA>J8A>JC or JB or J2B)>〜 --要は、ＪＡ＞ＪＣのガードを強要し、割る。前グレイズにはＪ４４＞ＪＡで対応。ＡＩには効かないが、対人には必要。早漏グレイズには＞Ｊ８Ａなどで。
	elseif my_act==306 and enemy_act>=150 and enemy_act<=166 and ey>0 and my_hitstop<=3 and my_hitstop>=1 and math.random(2)<=1 then
		key_reset();
		if ey-y>=-50 then
print("〜>JA>JB");
			key_event(ACT_B);
		else
print("〜>JA>J2B");
			key_event2(ACT_B,ACT_DOWN);
		end --]]

--▲組み込み連携▲
		
--2C撃った後の隙消しHJ
	elseif my_act==412 and dis<=250 then
		if math.random(2)==1 then
			key_reset();
			key_on(ACT_UP)
		else
			key_reset();
			key_on(back);
			key_on(ACT_UP)
		end
--攻撃レベル中・大・特大の攻撃をガードした後、割られそうな感じなら確率的に回避結界
	elseif weather~=12 and (y==0 or y>=80) and enemy_act<600 and (my_act==151 or my_act==152 or my_act==153 or my_act==155 or my_act==156 or my_act==157 or (my_act==158 and (dis>400 or ey>=100))) and my_hitstop==4 and (weather==8 or (my_rmax>=800 and my_rei<400)) and math.random(3)==1 then
		if (weather==8 or enemy_act==306 or my_act==151 or my_act==155) and math.random(2)==1 then
			key_reset()
			yield()
		elseif y==0 then
			if my_frontside<=850 then
				key_reset();
				key_on(ACT_DOWN)
				key_on(back);
				key_event(ACT_D)
				key_event(ACT_D)
				caution_atk = 25 + math.random(15);	
			else
				key_reset();
				key_on(ACT_DOWN)
				key_event(ACT_D)
				key_event(ACT_D)
				caution_atk = 25 + math.random(35);	
			end
		else
			if my_frontside<=850 then
				key_reset();
				key_on(back);
				key_event(ACT_D)
				key_event(ACT_D)
				caution_atk = 15 + math.random(15);
			else
				key_reset();
				key_on(front);
				key_event(ACT_D)
				key_event(ACT_D)
				caution_atk = 15 + math.random(15);
			end
		end
		key_reset();
--上回避結界の後は中央に逃げる。
	elseif (my_act==220 or my_act==222) and my_allframe>=32 and (y-ey)>120 and enemy_yspeed<1 and x<=340 then
		if dis<100 then
			key_reset();
			key_on(ACT_UP);
			key_on(ACT_RIGHT);
			key_on(ACT_D)
			caution_atk = 30;
			wait(10);
		elseif ey<=50 then
			key_reset();
			key_event(ACT_RIGHT);
			key_event(ACT_RIGHT);
		end
	elseif (my_act==220 or my_act==222) and my_allframe>=32 and (y-ey)>120 and enemy_yspeed<1 and x>=940 then
		if dis<100 then
			key_reset();
			key_on(ACT_UP);
			key_on(ACT_LEFT);
			key_on(ACT_D)
		else
			key_reset();
			key_event(ACT_LEFT);
			key_event(ACT_LEFT);
		end --]]
--前結界は最速終了する
	elseif my_act==223 and my_frame>=12 then
		key_reset();
		yield();
	--else
		--card_set();
	end
--固め用警戒解除判定
	if ((my_act==301 and my_frame>=31) or (my_act==303 and my_frame>=36) or (my_act==320 and my_frame>=15) or (my_act==321 and my_frame>=23) or (my_act==330 and my_frame>=14)) and caution_atk==1 then
		caution_atk = 0;
	end
end

--常時行う処理とかはこっちに移動

function kihon2()
--キーリセット
	if (my_act>=200 and my_act<=214) or my_act>=300 then
		key_off(ACT_A);key_off(ACT_B);key_off(ACT_C);key_off(ACT_UP);
	end
--▼飛翔の残り回数の演算▼
	if weather~=10 then
		if my_air==0 then
			my_airEX = 2
		elseif my_air==1 then
			my_airEX = 1
		elseif my_air>=2 then
			my_airEX = 0
		end
	else
		if my_air==0 then
			my_airEX = 3
		elseif my_air==1 then
			my_airEX = 2
		elseif my_air==2 then
			my_airEX = 1
		elseif my_air>=3 then
			my_airEX = 0
		end
	end
	if weather~=10 then
		if enemy_air==0 then
			enemy_airEX = 2
		elseif enemy_air==1 then
			enemy_airEX = 1
		elseif enemy_air>=2 then
			enemy_airEX = 0
		end
	else
		if enemy_air==0 then
			enemy_airEX = 3
		elseif enemy_air==1 then
			enemy_airEX = 2
		elseif enemy_air==2 then
			enemy_airEX = 1
		elseif enemy_air>=3 then
			enemy_airEX = 0
		end
	end
--▼気質フラグの演算▼
	--「緋想の剣」発現中のフラグ維持
	if my_act==691 and flag_kishitu==2 then 
		flag_kishitu = 2
		
	--「緋想の剣」発現後のフラグ維持
	elseif weather == 6 and flag_kishitu==2 then 
		flag_kishitu = 2
	elseif weather == 7 and flag_kishitu==2 then
		flag_kishitu = 2
	elseif weather ==13 and flag_kishitu==2 then
		flag_kishitu = 2
		
	elseif weather2== 5 and flag_kishitu==2 then
		flag_kishitu = 2
	elseif weather2== 6 and flag_kishitu==2 then
		flag_kishitu = 2
	elseif weather2== 8 and flag_kishitu==2 then
		flag_kishitu = 2
	elseif weather2==12 and flag_kishitu==2 then
		flag_kishitu = 2
	elseif weather2==18 and flag_kishitu==2 then
		flag_kishitu = 2
	elseif weather2==21 and flag_kishitu==2 then
		flag_kishitu = 2
		
	--「緋想の剣」フラグＯＮと維持
	elseif weather == 6 and flag_kishitu<=1 and enemy_hp<=6000 and my_hp>enemy_hp+2000 then 
		flag_kishitu = 1
	elseif weather == 7 and flag_kishitu<=1 then
		flag_kishitu = 1
	elseif weather ==13 and flag_kishitu<=1 then
		flag_kishitu = 1
		
	elseif weather2== 5 and flag_kishitu<=1 and enemy_hp<=6000 and my_hp>enemy_hp+2000 then
		flag_kishitu = 1
	elseif weather2== 6 and flag_kishitu<=1 then
		flag_kishitu = 1
	elseif weather2== 8 and flag_kishitu<=1 and my_rmax<=600 then
		flag_kishitu = 1
	elseif weather2==12 and flag_kishitu<=1 then
		flag_kishitu = 1
	elseif weather2==18 and flag_kishitu<=1 then
		flag_kishitu = 1
	elseif weather2==21 and flag_kishitu<=1 and math.random(180)==1 then
		flag_kishitu = 1
		
	--指定条件外になった場合、フラグＯＦＦ
	else
		flag_kishitu = 0
	end
--特殊コンフラグ解除
	if my_act==401 or my_act==412 or enemy_act<50 or enemy_act>100 or enemy_limit>=100 or weather==12 or weather==13 then
		ex_combo = 0;
	end
--割りコンフラグ解除
	if enemy_act~=9 and (enemy_act<50 or enemy_act>170 or enemy_limit>=100 or weather==12 or weather==13) then
		crush_combo = 0;
	end
--夢想封印中の特殊コンフラグ
	if my_act==601 or my_act==651 then
		ex_combo = 2;
	end
--ガードした技が攻撃レベル中以上かつ、ガード時より相手のフレームが大きければ一定確率でactが変わるまでガードしない
--要は簡易反撃設定。誤爆が怖いので通常技だけ
	if enemy_act==enemy_atk_act and enemy_allframe>enemy_atk_allframe and caution_atk==0 and 
	(((my_act==151 or my_act==155) and my_frame==14) or ((my_act==152 or my_act==156) and my_frame==20) or ((my_act==153 or my_act==157) and my_frame==26) or (my_act==158 and my_frame==18) or
	((my_act==160 or my_act==164) and my_frame==16) or ((my_act==161 or my_act==165) and my_frame==24) or ((my_act==162 or my_act==166) and my_frame==28)) and
	((enemy_act>=300 and enemy_act<=330 and math.random(2)==1) or
	enemy_act==408 or enemy_act==418 or enemy_act==695 or enemy_act==696 or enemy_act==698 or 
	(base_chain==3 and enemy_act==321) or (base_chain==4 and enemy_act==322) or (base_chain==5 and enemy_act==323)) then
		noguard = 1;
		caution_atk = 0;
	end
--ガードした技が射撃かつ、ガード時より相手のフレームが大きければ一定確率でactが変わるまでグレイズしない
--上のと同じ。やはり誤爆が怖いので通常射撃だけ
	if enemy_act==enemy_atk_act and enemy_allframe>enemy_atk_allframe and shot_guard==1 and dis<250 and
	(((my_act==151 or my_act==155) and my_frame==14) or ((my_act==152 or my_act==156) and my_frame==20) or ((my_act==153 or my_act==157) and my_frame==26) or (my_act==158 and my_frame==18) or
	((my_act==160 or my_act==164) and my_frame==16) or ((my_act==161 or my_act==165) and my_frame==24) or ((my_act==162 or my_act==166) and my_frame==28)) and
	enemy_act>=400 and enemy_act<=430 and math.random(2)==1 then
		nograze = 1;
		caution_atk = 0;
	end
--上記ガード・グレイズしない判定の解除
	if enemy_act~=enemy_atk_act and (noguard==1 or nograze==1) then
		noguard = 0;
		nograze = 0;
	end
--射撃をガードした時の判定
	if my_rei<prerei and my_act>=150 and my_act<=158 and shot_guard==0 then
		shot_guard = 1;
	end
	prerei = my_rei;
--射撃ガード判定解除
	if shot_guard==1 and (my_act<150 or my_act>170) then
		shot_guard = 0;
	end
--画面端で攻撃をガードした後は50%の確率で警戒
	if my_frontside>1100 and math.random(2)==1 and caution_atk==0 and noguard==0 and nograze==0 and
	(((my_act==151 or my_act==155) and my_frame==14) or ((my_act==152 or my_act==156) and my_frame==20) or ((my_act==153 or my_act==157) and my_frame==26)) then
		caution_atk = math.random(25);
	end
--地上食らいモーション中は警戒状態に移行
	if my_act>=50 and my_act<=65 then
		caution_atk = 2 + math.random(20);
		caution_graze = caution_atk;
	end
--攻撃レベル小の攻撃をガードしたらちょっと警戒
	if (my_act==150 or my_act==154) and my_frame==8 and caution_atk==0 and math.random(10)<=9 then
		caution_atk = 2 + math.random(15);
	end
--近距離で相手が有利状況だったら警戒
	if dis<200 and enemy_act<=5 and math.random(5)<=4 and (((my_act==151 or my_act==155) and my_frame==14) or ((my_act==152 or my_act==156) and my_frame==20) or ((my_act==153 or my_act==157) and my_frame==26)) and caution_atk<10 then
		caution_atk = 10 + math.random(20)
	end
--ガードミスしたら2/3で警戒
	if dis<400 and (((my_act==159 or my_act==163) and my_frame==8) or ((my_act==160 or my_act==164) and my_frame==16) or ((my_act==161 or my_act==165) and my_frame==24) or ((my_act==162 or my_act==166) and my_frame==28)) and caution_atk==0 and math.random(4)<=3 then
		caution_atk = 5 + math.random(20);
		caution_graze = caution_atk;
	end
--空中ガード終了時に相手が行動可能だったら警戒
	if dis<300 and ((y<150 and enemy_act<=5) or (enemy_act>=6 and enemy_act<=9) or (enemy_act>=208 and enemy_act<=214) or enemy_act==202 or (enemy_act==203 and dis<100)) and my_act==158 and my_frame==16 and math.random(4)<=3 then
		caution_atk = 5 + math.random(20);
		caution_graze = caution_atk;
	end
--反撃確定技がヒットしなかったら警戒。ガードが間に合うかも
	if weather~=13 and (my_act==408 or my_act==418 or my_act==540 or my_act==560 or my_act==561 or my_act==606) and (enemy_act<50 or enemy_act>100) and my_allframe>=20 then
		caution_atk = 5 + math.random(10);
		caution_graze = caution_atk;
	end
--着地狩り攻撃を潰されたらしばらく着地狩りを行わない
	if weather~=13 and my_act>=50 and my_act<=100 and (my_preact[1]==302 or my_preact[1]==305 or my_preact[1]==330) and ey>50 and my_allframe==0 and math.random(3)<=2 then
		land_atk = 180 + math.random(500)
		--wait(5)
	end
--グレイズ失敗の設定。近距離かつ未グレイズ時は毎フレーム（graze_rank/1000)の確率でグレイズ禁止状態になる
--ガードモーション中は(graze_rank/750)の確率になる
	if dis<360 and (my_act<200 or my_act>214) and (enemy_act<50 or enemy_act>200) and ((graze_rank>=math.random(1000) and (my_act<150 or my_act>170)) or (graze_rank>=math.random(750) and my_act>=150 and my_act<=170)) and caution_graze<=30 then
		caution_graze = 10 + math.random(30)
		if caution_graze>=38 then
			caution_graze = caution_graze + 3 + math.random(15)
		end
	end
end



--距離別攻撃
function en()
--print("遠距離行動");
--900以上。端と端くらい離れている時。地上ならdashで近づき、たまに座布団や亜空穴。
	if dis>900 then

	--博麗アミュレット
		if my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card~=100 and card_check(100) then
			card_1st(100);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==100 then
			print("スキカ：博麗アミュレット");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,0)>=0 and math.random(60)==1 then
			print("コマンド：博麗アミュレット");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr236(ACT_B);
	--妖怪バスター
		elseif my_act<=10 and my_rei>=600 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x) and enemy_obj_range_in(150,60)==false and my_card~=104 and card_check(104) then
			print("スキカ送り：妖怪バスター");
			card_1st(104);
		elseif my_act<=10 and my_rei>=600 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x) and enemy_obj_range_in(150,60)==false and my_card==104 then
			print("スキカ：妖怪バスター");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x) and enemy_obj_range_in(150,60)==false and get_skill_lv(0,4)>=0 and math.random(60)==1 then
			print("コマンド：妖怪バスター");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr236(ACT_B);
	--拡散アミュレット
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card~=108 and card_check(108) then
			card_1st(108);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==108 then
			print("スキカ：拡散アミュレット");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,8)>=0 and math.random(60)==1 then
			print("コマンド：拡散アミュレット");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr236(ACT_B);
	--警醒陣
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card~=101 and card_check(101) then
			print("スキカ送り：警醒陣");
			card_1st(101);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==101 then
			print("スキカ：警醒陣");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,1)>=0 and math.random(60)==1 then
			print("コマンド：警醒陣");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr214(ACT_C);
	--繋縛陣
		elseif my_act<=10 and my_rei>=600 and enemy_frame<=11 and enemy_obj_range_in(150,60)==false and my_card~=105 and card_check(105) then
			card_1st(105);
		elseif my_act<=10 and my_rei>=600 and enemy_frame<=11 and enemy_obj_range_in(150,60)==false and my_card==105 then
			print("スキカ：繋縛陣");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_frame<=1 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,5)>=0 and math.random(60)==1 then
			print("コマンド：繋縛陣");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr214(ACT_B);
	--常置陣
		elseif my_act<=10 and my_rei>=600 and y==0 and enemy_obj_range_in(150,60)==false and y==0 and my_card~=109 and card_check(109) then
			card_1st(109);
		elseif my_act<=10 and my_rei>=600 and y==0 and enemy_obj_range_in(150,60)==false and my_card==109 then
			print("スキカ：常置陣");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and y==0 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,9)>=0 and math.random(60)==1 then
			print("コマンド：常置陣");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr214(ACT_C);
	--亜空穴
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card~=102 and card_check(102) then
			card_1st(102);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==102 then
			print("スキカ：亜空穴");
			key_reset();
			key_event(ACT_BC);
		--elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,2)>=0 and math.random(60)==1 then
		--	print("コマンド：亜空穴");
		--	key_reset();
		--	lvr421(ACT_B);
	--封魔亜空穴
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card~=106 and card_check(106) then
			card_1st(106);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==106 then
			print("スキカ：封魔亜空穴");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,6)>=0 and math.random(60)==1 then
			print("コマンド：封魔亜空穴");
			key_reset();
			lvr421(ACT_B);
	--刹那亜空穴
		elseif my_act<=10 and my_rei>=600 and y==0 and enemy_obj_range_in(150,60)==false and my_card~=110 and card_check(110) then
			card_1st(110);
		elseif my_act<=10 and my_rei>=600 and y==0 and enemy_obj_range_in(150,60)==false and my_card==110 then
			print("スキカ：刹那亜空穴");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and y==0 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,10)>=0 and math.random(60)==1 then
			print("コマンド：刹那亜空穴");
			key_reset();
			lvr421(ACT_C);
	
	--昇天脚
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card~=103 and card_check(103) then
			card_1st(103);
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card==103 then
			print("スキカ：封魔亜空穴");
			key_reset();
			key_on(back);
			key_event(ACT_BC);
	--抄地昇天脚
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card~=107 and card_check(107) then
			card_1st(107);
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card==107 then
			print("スキカ：抄地昇天脚");
			key_reset();
			key_on(back);
			key_event(ACT_BC);
	--雨乞祈り
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card~=111 and card_check(111) then
			card_1st(111);
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card==111 then
			print("スキカ：雨乞祈り");
			key_reset();
			key_on(back);
			key_event(ACT_BC);
	
	
		elseif my_rei>=800 and my_act<=10 and ((get_skill_lv(0,4)==-1) or (get_skill_lv(0,4)>=0 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x))) and math.random(180)==1 then
			key_reset();
			key_on(ACT_D); yield(); key_off(ACT_D); yield();
			lvr236(ACT_B);
			
		elseif enemy_obj_range_in(150,60)==false and get_skill_lv(0,2)>=0 and 
				my_rei>=600 and weather~=12 and (enemy_char==3 or enemy_char==12 or enemy_char==13) and (caution_akuu==0 or (caution_akuu==1 and (ey>100 or (ey>50 and enemy_yspeed>=0)))) and math.random(500)==1 then
			print("コマンド：亜空穴");
			key_reset();
			lvr421(ACT_B);
		elseif enemy_obj_range_in(150,60)==false and get_skill_lv(0,2)>=0 and 
				my_rei>=600 and weather~=12 and (caution_akuu==0 or (caution_akuu==1 and (ey>100 or (ey>50 and enemy_yspeed>=0)))) and math.random(350)==1 then
			print("コマンド：亜空穴");
			key_reset();
			lvr421(ACT_B);

		elseif y==0 then
			if my_act~=200 then
				key_reset();
			end
			key_on(ACT_D);
			key_on(front);
		end
	end
end

--700-900。霊力足りないなら後ろにHJ。この距離なら博麗アミュ使ってもまず大丈夫。
--気まぐれに亜空穴。
function tyuu()
--print("中距離行動");
	if dis<=900 and dis>700 then

	--博麗アミュレット
		if my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card~=100 and card_check(100) then
			card_1st(100);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==100 then
			print("スキカ：博麗アミュレット");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,0)>=0 and math.random(60)==1 then
			print("コマンド：博麗アミュレット");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr236(ACT_B);
	--妖怪バスター
		elseif my_act<=10 and my_rei>=600 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x) and enemy_obj_range_in(150,60)==false and my_card~=104 and card_check(104) then
			print("スキカ送り：妖怪バスター");
			card_1st(104);
		elseif my_act<=10 and my_rei>=600 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x) and enemy_obj_range_in(150,60)==false and my_card==104 then
			print("スキカ：妖怪バスター");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x) and enemy_obj_range_in(150,60)==false and get_skill_lv(0,4)>=0 and math.random(60)==1 then
			print("コマンド：妖怪バスター");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr236(ACT_B);
	--拡散アミュレット
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card~=108 and card_check(108) then
			card_1st(108);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==108 then
			print("スキカ：拡散アミュレット");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,8)>=0 and math.random(60)==1 then
			print("コマンド：拡散アミュレット");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr236(ACT_B);
	--警醒陣
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card~=101 and card_check(101) then
			print("スキカ送り：警醒陣");
			card_1st(101);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==101 then
			print("スキカ：警醒陣");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,1)>=0 and math.random(60)==1 then
			print("コマンド：警醒陣");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr214(ACT_C);
	--繋縛陣
		elseif my_act<=10 and my_rei>=600 and enemy_frame<=11 and enemy_obj_range_in(150,60)==false and my_card~=105 and card_check(105) then
			card_1st(105);
		elseif my_act<=10 and my_rei>=600 and enemy_frame<=11 and enemy_obj_range_in(150,60)==false and my_card==105 then
			print("スキカ：繋縛陣");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_frame<=1 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,5)>=0 and math.random(60)==1 then
			print("コマンド：繋縛陣");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr214(ACT_B);
	--常置陣
		elseif my_act<=10 and my_rei>=600 and y==0 and enemy_obj_range_in(150,60)==false and my_card~=109 and card_check(109) then
			card_1st(109);
		elseif my_act<=10 and my_rei>=600 and y==0 and enemy_obj_range_in(150,60)==false and my_card==109 then
			print("スキカ：常置陣");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and y==0 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,9)>=0 and math.random(60)==1 then
			print("コマンド：常置陣");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr214(ACT_C);
	--亜空穴
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card~=102 and card_check(102) then
			card_1st(102);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==102 then
			print("スキカ：亜空穴");
			key_reset();
			key_event(ACT_BC);
		--elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,2)>=0 and math.random(60)==1 then
		--	print("コマンド：亜空穴");
		--	key_reset();
		--	lvr421(ACT_B);
	--封魔亜空穴
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card~=106 and card_check(106) then
			card_1st(106);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==106 then
			print("スキカ：封魔亜空穴");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,6)>=0 and math.random(60)==1 then
			print("コマンド：封魔亜空穴");
			key_reset();
			lvr421(ACT_B);
	--刹那亜空穴
		elseif my_act<=10 and my_rei>=600 and y==0 and enemy_obj_range_in(150,60)==false and my_card~=110 and card_check(110) then
			card_1st(110);
		elseif my_act<=10 and my_rei>=600 and y==0 and enemy_obj_range_in(150,60)==false and my_card==110 then
			print("スキカ：刹那亜空穴");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and y==0 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,10)>=0 and math.random(60)==1 then
			print("コマンド：刹那亜空穴");
			key_reset();
			lvr421(ACT_C);
	
	--昇天脚
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card~=103 and card_check(103) then
			card_1st(103);
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card==103 then
			print("スキカ：封魔亜空穴");
			key_reset();
			key_on(back);
			key_event(ACT_BC);
	--抄地昇天脚
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card~=107 and card_check(107) then
			card_1st(107);
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card==107 then
			print("スキカ：抄地昇天脚");
			key_reset();
			key_on(back);
			key_event(ACT_BC);
	--雨乞祈り
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card~=111 and card_check(111) then
			card_1st(111);
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card==111 then
			print("スキカ：雨乞祈り");
			key_reset();
			key_on(back);
			key_event(ACT_BC);
			
			
	--亜空穴2
		elseif enemy_obj_range_in(150,60)==false and get_skill_lv(0,2)>=0 and 
				my_rei>=500 and ey<250 and weather~=12 and (enemy_char==3 or enemy_char==12 or enemy_char==13) and (caution_akuu==0 or (caution_akuu==1 and (ey>100 or (ey>50 and enemy_yspeed>=0)))) and math.random(800)==1 then
			print("コマンド：亜空穴");
			key_reset();
			lvr421(ACT_B);
		elseif enemy_obj_range_in(150,60)==false and get_skill_lv(0,2)>=0 and 
				my_rei>=500 and ey<250 and weather~=12 and (caution_akuu==0 or (caution_akuu==1 and (ey>100 or (ey>50 and enemy_yspeed>=0)))) and math.random(700)==1 then
			print("コマンド：亜空穴");
			key_reset();
			lvr421(ACT_B);
			

		elseif y==0 and my_rei<400 and x>190 and x<1090 and math.random(4)==1 then
			key_reset();
			key_on(ACT_D);
			key_on(ACT_UP)
			key_on(back);
			yield();
		elseif y==0 and my_rei>=400 and math.random(4)==1 then
			key_reset();
			key_on(ACT_D);
			key_event2(ACT_UP,front);
			key_reset();
		elseif (y==0 or y>100) and my_rei>900 and (my_act<=10 or (my_act>=209 and my_act<=214)) and math.random(5)==1 then
			if (y-ey)<150 and (ey-y)<150 then
				key_reset();
				key_event(ACT_C);
			elseif y>100 and enemy_obj_range_in(150,60)==false and enemy_act~=200 and math.random(10)==1 then
				key_reset();
				key_on(ACT_C);
				wait(20);
			elseif ((get_skill_lv(0,4)==-1) or (get_skill_lv(0,4)>=0 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x))) then
				key_reset();
				key_on(ACT_D); yield(); key_off(ACT_D); yield();
				lvr236(ACT_B);
			end
		elseif y<150 and my_rei>700 and (y-ey)<150 and (ey-y)<150 and (my_act<=10 or (my_act>=209 and my_act<=214)) and math.random(5)==1 then
			key_reset();
			key_event(ACT_C);
		elseif y<150 and my_rei>700 and enemy_obj_range_in(150,60)==false and (my_act<=10 or (my_act>=209 and my_act<=214)) and enemy_act~=200 and math.random(15)==1 then
			key_reset();
			key_on(ACT_C);
			wait(20);
		elseif (enemy_char~=1 or (enemy_char==1 and math.random(5)==1)) and my_act==414 and my_rei>=800 and my_frame>=15 and enemy_act~=200 and ((get_skill_lv(0,4)==-1) or (get_skill_lv(0,4)>=0 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x))) then
			key_reset();
			key_on(ACT_D); yield(); key_off(ACT_D); yield();
			lvr236(ACT_B);
		elseif y==0 and (my_act==410 or my_act==500 or my_act==501) and my_allframe>=20 then
			key_reset();
			key_event2(ACT_UP,front);
		elseif y==0 then
			if my_act~=200 then
				key_reset();
			end
			key_on(ACT_D);
			key_on(front);
		
		end
	end
end


function kin()
--print("近距離行動");
--500〜700。大体飛ぶ。すぐ出せて弾速もそこそこ速いC射撃メイン。この後自分か相手が動くはずなので大抵接近戦になる。
--気まぐれに亜空穴。
	if dis<=700 and dis>500 then

	
	--博麗アミュレット
		if my_act<=10 and my_card~=100 and card_check(100) then
			card_1st(100);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==100 then
			print("スキカ：博麗アミュレット");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,0)>=0 and math.random(60)==1 then
			print("コマンド：博麗アミュレット");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr236(ACT_B);
	--妖怪バスター
		elseif my_act<=10 and my_card~=104 and card_check(104) then
			card_1st(104);
		elseif my_act<=10 and my_rei>=600 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x) and enemy_obj_range_in(150,60)==false and my_card==104 then
			print("スキカ：妖怪バスター");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x) and enemy_obj_range_in(150,60)==false and get_skill_lv(0,4)>=0 and math.random(60)==1 then
			print("コマンド：妖怪バスター");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr236(ACT_B);
	--拡散アミュレット
		elseif my_act<=10 and my_card~=108 and card_check(108) then
			card_1st(108);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==108 then
			print("スキカ：拡散アミュレット");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,8)>=0 and math.random(60)==1 then
			print("コマンド：拡散アミュレット");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr236(ACT_B);
	--警醒陣
		elseif my_act<=10 and my_card~=101 and card_check(101) then
			card_1st(101);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==101 then
			print("スキカ：警醒陣");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,1)>=0 and math.random(60)==1 then
			print("コマンド：警醒陣");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr214(ACT_C);
	--繋縛陣
		elseif my_act<=10 and my_card~=105 and card_check(105) then
			card_1st(105);
		elseif my_act<=10 and my_rei>=600 and enemy_frame<=11 and enemy_obj_range_in(150,60)==false and my_card==105 then
			print("スキカ：繋縛陣");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_frame<=1 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,5)>=0 and math.random(60)==1 then
			print("コマンド：繋縛陣");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr214(ACT_B);
	--常置陣
		elseif my_act<=10 and y==0 and my_card~=109 and card_check(109) then
			card_1st(109);
		elseif my_act<=10 and my_rei>=600 and y==0 and enemy_obj_range_in(150,60)==false and my_card==109 then
			print("スキカ：常置陣");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and y==0 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,9)>=0 and math.random(60)==1 then
			print("コマンド：常置陣");
			key_reset();
			key_on(ACT_D);yield();key_off(ACT_D);yield();
			lvr214(ACT_C);
	--亜空穴
		elseif my_act<=10 and my_card~=102 and card_check(102) then
			card_1st(102);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==102 then
			print("スキカ：亜空穴");
			key_reset();
			key_event(ACT_BC);
		--elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,2)>=0 and math.random(60)==1 then
		--	print("コマンド：亜空穴");
		--	key_reset();
		--	lvr421(ACT_B);
	--封魔亜空穴
		elseif my_act<=10 and my_card~=106 and card_check(106) then
			card_1st(106);
		elseif my_act<=10 and my_rei>=600 and enemy_obj_range_in(150,60)==false and my_card==106 then
			print("スキカ：封魔亜空穴");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,6)>=0 and math.random(60)==1 then
			print("コマンド：封魔亜空穴");
			key_reset();
			lvr421(ACT_B);
	--刹那亜空穴
		elseif my_act<=10 and y==0 and my_card~=110 and card_check(110) then
			card_1st(110);
		elseif my_act<=10 and my_rei>=600 and y==0 and enemy_obj_range_in(150,60)==false and my_card==110 then
			print("スキカ：刹那亜空穴");
			key_reset();
			key_event(ACT_BC);
		elseif my_act<=10 and my_rei>=800 and y==0 and enemy_obj_range_in(150,60)==false and get_skill_lv(0,10)>=0 and math.random(60)==1 then
			print("コマンド：刹那亜空穴");
			key_reset();
			lvr421(ACT_C);
	
	--昇天脚
		elseif my_act<=10 and y==0 and my_card~=103 and card_check(103) then
			card_1st(103);
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card==103 then
			print("スキカ：封魔亜空穴");
			key_reset();
			key_on(back);
			key_event(ACT_BC);
	--抄地昇天脚
		elseif my_act<=10 and y==0 and my_card~=107 and card_check(107) then
			card_1st(107);
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card==107 then
			print("スキカ：抄地昇天脚");
			key_reset();
			key_on(back);
			key_event(ACT_BC);
	--雨乞祈り
		elseif my_act<=10 and y==0 and my_card~=111 and card_check(111) then
			card_1st(111);
		elseif my_act<=10 and y==0 and enemy_obj_range_in(150,60)==false and my_card==111 then
			print("スキカ：雨乞祈り");
			key_reset();
			key_on(back);
			key_event(ACT_BC);
	

	--亜空穴2
		elseif enemy_obj_range_in(150,60)==false and get_skill_lv(0,2)>=0 and 
				my_rei>=400 and ey<250 and weather~=12 and (enemy_char==3 or enemy_char==12 or enemy_char==13) and (caution_akuu==0 or (caution_akuu==1 and (ey>100 or (ey>50 and enemy_yspeed>=0)))) and math.random(1200)==1 then
			print("コマンド：亜空穴");
			key_reset();
			lvr421(ACT_B);
		elseif enemy_obj_range_in(150,60)==false and get_skill_lv(0,2)>=0 and 
				my_rei>=400 and ey<250 and weather~=12 and (caution_akuu==0 or (caution_akuu==1 and (ey>100 or (ey>50 and enemy_yspeed>=0)))) and math.random(1100)==1 then
			print("コマンド：亜空穴");
			key_reset();
			lvr421(ACT_B);
		elseif enemy_obj_range_in(150,60)==false and get_skill_lv(0,2)>=0 and 
				my_rei>=400 and math.random(950)==1 and ey==0 then
			print("コマンド：亜空穴");
			key_reset();
			lvr421(ACT_B);
		
		
		elseif y==0 and my_rei<=400 and x>190 and x<1090 and math.random(2)==1 then
			key_reset();
			key_on(ACT_D);
			key_on(ACT_UP)
			key_on(back);
			yield();
		elseif y==0 and my_rei>=400 and math.random(4)==1 then
			key_reset();
			key_on(ACT_D);
			key_event2(ACT_UP,front);
			key_reset();
		elseif (y==0 or y>100) and my_rei>700 and (my_act<=10 or (my_act>=209 and my_act<=214)) and math.random(5)==1 then
			if enemy_char==5 and enemy_act<400 and (y-ey)>150 then
				key_reset();
				key_event2(ACT_B,ACT_DOWN);
			elseif y>100 and enemy_char==5 and enemy_act<400 then
				key_reset();
				key_event(ACT_B);
			elseif (y-ey)<150 and (ey-y)<150 and y>100 then
				key_reset();
				key_event(ACT_C);
			elseif (y-ey)<150 and (ey-y)<150 and y==0 and dis>600 then
				key_reset();
				key_event(ACT_C);
			elseif dis>600 and ey<100 and enemy_act~=200 and ((get_skill_lv(0,4)==-1) or (get_skill_lv(0,4)>=0 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x))) then
				key_reset();
				key_on(ACT_D); yield(); key_off(ACT_D); yield();
				lvr236(ACT_B);
			end
		elseif y<200 and y>50 and my_rei>600 and (y-ey)<150 and (ey-y)<150 and (my_act<=10 or (my_act>=209 and my_act<=214)) and math.random(5)==1 then
			key_reset();
			key_event(ACT_C);
		elseif dis>600 and y==0 and my_rei>600 and (y-ey)<150 and (ey-y)<150 and (my_act<=10 or (my_act>=209 and my_act<=214)) and math.random(5)==1 then
			key_reset();
			key_event(ACT_C);
		elseif y>200 and my_rei>600 and (y-ey)>150 and (my_act<=10 or (my_act>=209 and my_act<=214)) and enemy_act~=200 and math.random(20)==1 then
			key_reset();
			key_on(ACT_C);
			wait(20);
		elseif dis>550 and (enemy_char~=1 or (enemy_char==1 and math.random(5)==1)) and my_act==414 and my_rei>=700 and my_allframe>=15 and enemy_act~=200 then
			if math.random(2)==1 and ((get_skill_lv(0,4)==-1) or (get_skill_lv(0,4)>=0 and (ey-y)<=0.2*my_dir*(ex-x) and (ey-y)<=-0.2*my_dir*(ex-x))) then
				key_reset();
				key_on(ACT_D); yield(); key_off(ACT_D); yield();
				lvr236(ACT_B);
			else
				key_reset();
				wait(5)
				key_event(front)
				key_event(front)
			end	
		elseif y==0 and (my_act==410 or my_act==500 or my_act==501) and my_allframe>=24 then
			key_reset();
			key_event2(ACT_UP,front);
		elseif y==0 then
			if my_act~=200 then
				key_reset();
			end
		end
	end
end

--空対空、空対地。JAを主軸に、相手の上を取ったらJ2Bを撒いたり飛翔からJA振ったりする。
--やたらif math.random…が多いのは飛翔方向を分岐させてるため。
function kuusekkinn()
--print("空接近行動");
	if dis<=500 and y>20 then

		if dis>300 and (my_xspeed+enemy_xspeed)<8 and my_air<=1 and (y-ey)<150 and (ey-y)<150 and my_rei>=200 and air_atk==1 then
			if math.random(2)==1 then
				key_reset();
				key_event(front)
				key_event(front)
			elseif my_rei>=500 then
				key_reset();
				key_event(ACT_C);
			end	
		elseif dis<=500 and dis>420 and (y-ey)<80 and (ey-y)<80 and my_rei>=400 and math.random(10)==1 and my_air<=1 then
			key_reset();
			key_event(ACT_C);
		elseif dis<=420 and dis>350 and (y-ey)<80 and (ey-y)<80 and my_rei>=400 and math.random(10)==1 and my_air<=1 then
			key_reset();
			key_event(ACT_B);
		--JA
		--elseif ((enemy_xspeed<=-4 and ((dis<=250 and my_xspeed>=6) or (dis<=220 and my_xspeed<6 and my_xspeed>2) or (dis<=200 and my_xspeed<2 and my_xspeed>-2) or (dis<=180 and my_xspeed<-2 and my_xspeed>-6) or (dis<=170 and my_xspeed<=-6))) or
		--(enemy_xspeed<=0 and enemy_xspeed>-4 and ((dis<=260 and my_xspeed>=6) or (dis<=230 and my_xspeed<6 and my_xspeed>2) or (dis<=210 and my_xspeed<2 and my_xspeed>-2) or (dis<=200 and my_xspeed<-2 and my_xspeed>-6) or (dis<=180 and my_xspeed<=-6))) or
		--(enemy_xspeed<=4 and enemy_xspeed>0 and ((dis<=270 and my_xspeed>=6) or (dis<=240 and my_xspeed<6 and my_xspeed>2) or (dis<=220 and my_xspeed<2 and my_xspeed>-2) or (dis<=210 and my_xspeed<-2 and my_xspeed>-6) or (dis<=200 and my_xspeed<=-6))) or
		--(enemy_xspeed<=8 and enemy_xspeed>4 and ((dis<=280 and my_xspeed>=6) or (dis<=250 and my_xspeed<6 and my_xspeed>2) or (dis<=240 and my_xspeed<2 and my_xspeed>-2) or (dis<=230 and my_xspeed<-2 and my_xspeed>-6) or (dis<=210 and my_xspeed<=-6))) or
		--(enemy_xspeed>8 and ((dis<=300 and my_xspeed>=6) or (dis<=270 and my_xspeed<6 and my_xspeed>2) or (dis<=250 and my_xspeed<2 and my_xspeed>-2) or (dis<=230 and my_xspeed<-2 and my_xspeed>-6) or (dis<=220 and my_xspeed<=-6)))) and
		--(((y-ey)<70 and (ey-y)<130 and my_yspeed>=11) or ((y-ey)<90 and (ey-y)<100 and my_yspeed<11 and my_yspeed>4) or ((y-ey)<120 and (ey-y)<60 and my_yspeed<4 and my_yspeed>=0) or ((y-ey)<130 and (ey-y)<40 and my_yspeed<0 and my_yspeed>-4) or ((y-ey)<150 and (ey-y)<20 and my_yspeed<-4 and my_yspeed>-9) or ((y-ey)<180 and (ey-y)<10 and my_yspeed<=-9)) and
		--ey>20 and my_act~=306 and search_JFP()==false and get_special_data(0,10)<=5 then
		--	if math.random(2)==1 or my_yspeed<-4 then
		--		key_reset();
		--		yield();
		--		key_event(ACT_A);
		--	else
		--		key_reset();
		--		yield();
		--		key_event(ACT_A);
		--	end
	--ＪＡ
		elseif	is_dir_front and search_JFP()==false and get_special_data(0,10)<=5 and
		(my_act<=10 or (my_act>=180 and my_act<300 and my_act~=202 and my_act~=203 and my_act~=214) or (my_act==202 and my_allframe>=11) or (my_act==203 and my_allframe>=1) or (my_act==214 and my_allframe>=14)) and 
		not(enemy_act>=98 and enemy_act<=98) and not(enemy_act>=197 and enemy_act<=199) and
		enemy_obj_range_in(150,60)==false and
		(y+my_yspeed*12+(12*(11*m_gs))/2)>0 	and
					((ex+enemy_xspeedEX*12)-(x+enemy_xspeedEX*12))*my_dir		<=	180+30 	and
					((ex+enemy_xspeedEX*12)-(x+enemy_xspeedEX*12))*my_dir		>=	20-30 	and
					(ey+enemy_yspeed*12+(12*(11*e_gs))/2)	-	(y+my_yspeed*12+(12*(11*m_gs))/2)	<=	160 	and
					(ey+enemy_yspeed*12+(12*(11*e_gs))/2)	-	(y+my_yspeed*12+(12*(11*m_gs))/2)	>=	60-120 	then
						print("ＪＡ");
						key_reset();
						key_event(ACT_A);
	--Ｊ２Ａ
		elseif	is_dir_front and search_JFP()==false and get_special_data(0,10)<=5 and
		(my_act<=10 or (my_act>=180 and my_act<300 and my_act~=202 and my_act~=203 and my_act~=214) or (my_act==202 and my_allframe>=11) or (my_act==203 and my_allframe>=1) or (my_act==214 and my_allframe>=14)) and 
		not(enemy_act>=98 and enemy_act<=98) and not(enemy_act>=197 and enemy_act<=199) and
		enemy_obj_range_in(150,60)==false and
		(y+my_yspeed*19+(19*(18*m_gs))/2)>50 	and
					((ex+enemy_xspeedEX*19)-(x+enemy_xspeedEX*19))*my_dir		<=	120+30 	and
					((ex+enemy_xspeedEX*19)-(x+enemy_xspeedEX*19))*my_dir		>=	30-30 	and
					(ey+enemy_yspeed*19+(19*(18*e_gs))/2)	-	(y+my_yspeed*19+(19*(18*m_gs))/2)	<=	120 			and
					(ey+enemy_yspeed*19+(19*(18*e_gs))/2)	-	(y+my_yspeed*19+(19*(18*m_gs))/2)	>=	0-120 	then
						print("Ｊ２Ａ");
						key_reset();
						key_event2(ACT_A,ACT_DOWN);
	--Ｊ８Ａ
		elseif	is_dir_front and search_JFP()==false and get_special_data(0,10)<=5 and
		(my_act<=10 or (my_act>=180 and my_act<300 and my_act~=202 and my_act~=203 and my_act~=214) or (my_act==202 and my_allframe>=11) or (my_act==203 and my_allframe>=1) or (my_act==214 and my_allframe>=14)) and 
		not(enemy_act>=98 and enemy_act<=98) and not(enemy_act>=197 and enemy_act<=199) and
		enemy_obj_range_in(150,60)==false and
		(y+my_yspeed*6+(6*(5*m_gs))/2)>0 	and
					((ex+enemy_xspeedEX*11)-(x+enemy_xspeedEX*11))*my_dir		<=	120+30 	and
					((ex+enemy_xspeedEX*11)-(x+enemy_xspeedEX*11))*my_dir		>=	20-30 	and
					(ey+enemy_yspeed*11+(11*(10*e_gs))/2)	-	(y+my_yspeed*6+(6*(5*m_gs))/2)	<=	200+60 		and
					(ey+enemy_yspeed*11+(11*(10*e_gs))/2)	-	(y+my_yspeed*6+(6*(5*m_gs))/2)	>=	80-120 	then
						print("Ｊ８Ａ");
						key_reset();
						key_event2(ACT_A,ACT_UP);
						
		elseif dis<=420 and dis>80 and ((my_act==214 and my_allframe>=15) or (my_act==9 and my_preact[1]==214)) and y>200 and y<500 and enemy_act~=202 and enemy_act~=214 and my_air<=1 and my_rei>=400 and math.random(4)==1 then
			if ey==0 then
				if (caution_akuu==0 or (caution_akuu==1 and (ey>100 or (ey>50 and enemy_yspeed>=0)))) and math.random(400)==1 then
					if math.random(2)==1 and (ex<50 or ex>1230) then
						key_reset();
						lvr421(ACT_C);
					else
						key_reset();
						if card_check(102) then
							while my_card~=102 do
								card_1st(102);
								yield();
							end
							card_use(102);
						else
							lvr421(ACT_B);
						end
					end
				elseif math.random(20)==1 then
					key_reset();
					key_on(ACT_C);
					key_on(ACT_DOWN);
					wait(25);
				elseif math.random(10)==1 then
					key_reset();
					key_on(ACT_DOWN);
					yield();
					key_event(ACT_C);
					key_reset();
				elseif my_act~=406 then
					key_reset();
					key_event2(ACT_B,ACT_DOWN);
				end
			elseif ey>=20 and dis>200 then
				if (y-ey)<300 and (ey-y)<-100 then
					key_reset();
					key_event2(ACT_B,ACT_DOWN);
				elseif ((dis>300 and (y-ey)<200 and (ey-y)<200) or ((y-ey)<200 and (ey-y)<200)) then
					if math.random(3)==1 then
						key_reset();
						key_event(ACT_C);
					else
						key_reset();
						key_event(ACT_B);
					end
				end
			end
		elseif dis<300 and my_act>208 and my_act<212 and (y-ey)>150 and y>200 and (enemy_act<208 or enemy_act>214) and enemy_yspeed<1 and ((x>240 and my_dir==-1) or (x<1040 and my_dir==1)) and my_air==0 and math.random(5)==1 then
			if math.random(2)==1 then
				key_reset();
				key_on(ACT_D)
				key_event2(ACT_UP,front);
			else
				key_reset();
				key_event(front);
				key_event(front);
			end
		elseif dis<=420 and dis>300 and my_act==209 and my_frame==7 and ey==0 and enemy_act~=6 and enemy_act~=7 and enemy_act~=8 and enemy_act~=207 and enemy_act~=208 and enemy_act~=209 and my_air==0 and my_rei>=300 and math.random(8)==1 then
			if math.random(4)==1 then
				key_reset();
				key_event2(ACT_D,ACT_UP);
				key_reset();
			else
				key_reset();
				key_on(front);
				key_event2(ACT_D,ACT_UP);
				key_reset();
			end
		elseif dis<=420 and dis>300 and my_act==209 and my_frame==9 and ey==0 and enemy_act~=6 and enemy_act~=7 and enemy_act~=8 and enemy_act~=207 and enemy_act~=208 and enemy_act~=209 and math.random(5)==1 and my_air<=1 then
			if math.random(7)==1 then
				key_reset();
				key_event(front);
				key_event(front);
			elseif math.random(6)==1 then
				key_reset();
				key_event2(ACT_D,ACT_DOWN);
			elseif math.random(6)==1 and my_rei>=400 then
				key_reset();
				key_event2(ACT_C,ACT_DOWN);
			else
				key_reset();
				key_on(front);
				key_event2(ACT_D,ACT_DOWN);
				key_reset();
			end
		elseif dis<=500 and dis>200 and my_allframe>=9 and my_allframe<=11 and (my_act==210 or my_act==211) and ey==0 then
			if my_rei<200 and enemy_rei>600 then
				key_on(back);
				--wait(5);
			elseif my_rei>=400 and dis>350 and enemy_act~=200 and math.random(4)==1 then
				key_reset();
				key_event(ACT_C);
			elseif dis>360 and my_rei>=200 and math.random(3)==1 then
				key_reset();
				key_event(front);
				key_event(front);
			elseif my_rei>=200 then
				key_reset();
				key_event2(ACT_D,front);
			elseif x>240 and x<1040 then
			print("４４");
				key_event(back);
				key_event(back);
			else
			print("コマンド４");
				key_on(back);
			end
		elseif dis<=320 and dis>220 and y>180 and my_act~=202 and my_act~=214 and ey==0 and my_rei>=401 and my_air<=1 then
			if (caution_akuu==0 or (caution_akuu==1 and (ey>100 or (ey>50 and enemy_yspeed>=0)))) and math.random(180)==1 then
				if enemy_rei<500 and math.random(2)==1 and (ex<50 or ex>1230) then
					key_reset();
					lvr421(ACT_C);
				else
					key_reset();
					if card_check(102) then
						while my_card~=102 do
							card_1st(102);
							yield();
						end
						card_use(102);
					else
						lvr421(ACT_B);
					end
				end
			elseif math.random(33)==1 and my_air==0 then
				key_reset();
				key_on(ACT_C);
				key_on(ACT_DOWN);
				wait(25);
			elseif enemy_char~=12 and enemy_char~=13 and my_act~=406 then
				key_reset();
				key_event2(ACT_B,ACT_DOWN);
			elseif (enemy_char==12 or enemy_char==13) and dis>280 and my_act~=406 then
				key_reset();
				key_event2(ACT_B,ACT_DOWN);
			end
		elseif dis<=300 and (my_xspeed<=0 or my_yspeed<=-6 or dis>30 or y<80 or ex<70 or ex>1210) and y<200 and y>=20 and ey==0 and my_yspeed<=0 and my_act~=306 and search_JFP()==false and get_special_data(0,10)<=5 then
			key_reset();
			key_event(ACT_A);
		elseif dis<=300 and dis>150 and y>170 and (my_act==406 or my_act==414 or my_act==502) and ey==0 and my_rei>=100 and enemy_act~=6 and enemy_act~=7 and enemy_act~=8 and enemy_act~=207 and enemy_act~=208 and enemy_act~=209 then
			if math.random(5)==1 then
				key_reset();
				key_event2(ACT_D,ACT_DOWN);
				key_reset();
			else
				key_reset();
				key_on(front);
				key_event2(ACT_D,ACT_DOWN);
				key_reset();
			end
		elseif dis<=300 and dis>220 and (y-ey)>150 and enemy_yspeed<2 and my_rei>200 and y>200 and (my_act~=202 or (my_act==202 and math.random(10)==1)) and (my_act~=214 or (my_act==214 and my_yspeed>=0 and my_allframe>=15)) and (my_preact[1]~=158 or (my_preact[1]==158 and math.random(3)==1)) and math.random(5)<=2 then
			if my_rei>400 and my_air==0 and math.random(5)==1 then
				if math.random(3)==1 then
					key_reset();
					key_event2(ACT_D,ACT_UP);
					key_reset();
				elseif math.random(2)==1 then
					key_reset();
					key_on(back);
					key_event2(ACT_D,ACT_UP);
					key_reset();
				else
					key_reset();
					key_on(front);
					key_event2(ACT_D,ACT_UP);
					key_reset();
				end
			elseif math.random(5)==1 then
				key_reset();
				key_event2(ACT_D,ACT_DOWN);
				key_reset();
			else
				key_reset();
				key_on(front);
				key_event2(ACT_D,ACT_DOWN);
				key_reset();
			end
		elseif dis<=200 and dis>100 and (y-ey)>150 and enemy_yspeed<2 and my_rei>200 and y>200 and (my_act~=202 or (my_act==202 and math.random(10)==1)) and (my_act~=214 or (my_act==214 and my_yspeed>=0 and my_allframe>=15)) and (my_preact[1]~=158 or (my_preact[1]==158 and math.random(3)==1)) and my_air<=1 then
			if my_rei>300 and my_air==0 and math.random(3)==1 then
				if math.random(3)==1 then
					key_reset();
					key_event2(ACT_D,ACT_UP);
					key_reset();
				elseif math.random(2)==1 then
					key_reset();
					key_on(back);
					key_event2(ACT_D,ACT_UP);
					key_reset();
				else
					key_reset();
					key_on(front);
					key_event2(ACT_D,ACT_UP);
					key_reset();
				end
			else
				key_reset();
				key_on(front);
				key_event2(ACT_D,ACT_DOWN);
				key_reset();
			end
		elseif is_dir_front and (my_dir+enemy_dir)==0 and ((dis<=120 and dis>70 and my_xspeed>=4) or (dis<=110 and dis>50 and my_xspeed<4 and my_xspeed>0) or (dis<80 and dis>40 and my_xspeed<=0 and my_xspeed>-4) or (dis<=60 and dis>0 and my_xspeed<=-4)) and (((y-ey)<-120 and (ey-y)<240 and my_yspeed>=5) or ((y-ey)<-90 and (ey-y)<210 and my_yspeed<5 and my_yspeed>-5) or ((y-ey)<-60 and (ey-y)<170 and my_yspeed<=-5)) and y>40 and my_act~=404 and search_JFP()==false and get_special_data(0,10)<=5 then
			key_reset();
			key_event2(ACT_UP,ACT_A);
		elseif dis<=100 and (y-ey)>150 and enemy_yspeed<2 and my_rei>200 and y>200 and my_air<=1 and my_act~=202 and (my_act~=214 or (my_act==214 and my_yspeed>=0 and my_allframe>=15)) and (my_preact[1]~=158 or (my_preact[1]==158 and math.random(3)==1)) then
			if my_air==0 and math.random(4)==1 then
				key_reset();
				key_on(back);
				key_event2(ACT_D,ACT_DOWN);
				key_reset();
			elseif my_xspeed>2 and math.random(7)==1 then
				key_reset();
				key_event2(ACT_D,back);
			elseif my_air==0 and math.random(5)==1 and ((x>440 and my_dir==-1) or (x<840 and my_dir==1)) then
				key_reset();
				key_on(front);
				key_event2(ACT_D,ACT_UP);
				key_reset();
			elseif math.random(4)==1 and ((x>440 and my_dir==-1) or (x<840 and my_dir==1)) then
				key_reset();
				key_on(front);
				key_event2(ACT_D,ACT_DOWN);
				key_reset();
			elseif y>250 then
				key_reset();
				key_event2(ACT_D,ACT_DOWN);
				key_reset();
			end
		end
	end
end

function titisekkinn()
--print("地対地接近");
--地上接近戦。近距離ならAと2A、少し距離があったら2Aと6AとDA。これに低空J6AとJ2Bが混ざる。鬼縛陣セット中はたまにDB。台風の時はDC厨。
--近距離と中距離の中間ぐらいだとHJ飛翔やダッシュ、前進後退で間合い調節。射撃からの攻めも混ぜる。
	if dis<=500 and y==0 and ey<50 and my_act~=9 and my_act~=209 and my_act~=212 and (my_act~=300 or (my_act==300 and my_frame>=16)) and (my_act~=330 or (my_act==330 and my_frame>=16)) and (my_act~=301 or (my_act==301 and my_frame>=31)) and (my_act~=302 or (my_act==302 and my_frame>=41)) and (my_act~=303 or (my_act==303 and my_frame>=39)) and (my_act~=305 or (my_act==305 and my_frame>=32)) and (my_act~=320 or (my_act==320 and my_frame>=15)) and (my_act~=321 or (my_act==321 and my_frame>=23)) and my_act~=322 and enemy_act~=76 and enemy_act~=77 and enemy_act~=78 and enemy_act~=89 
	--and math.random(after_guard_count/3+1)<=1 
	then

		if weather==13 and dis<=250 and (my_act<=10 or my_act==418) then
			key_reset();
			key_on(ACT_D);
			key_on(front);
		elseif weather==13 and dis<=250 and my_act==200 then
			key_event2(ACT_C,front);
			key_reset();

		elseif my_card==206 and is_card_use and dis<=500 and dis>400 and math.random(45)==1 then
			key_reset();
			key_on(ACT_D);
			key_on(front)
			yield();
			key_event(ACT_B);
			key_reset();
		elseif dis<=500 and dis>450 and my_rei>200 and ey==0 and math.random(6)==1 and enemy_act~=200 then
			if math.random(3)==1 then
				key_reset();
				key_on(back);
				key_event2(ACT_D,ACT_UP);
				wait(4);
				key_reset();
				if math.random(2)==1 then
					key_event(ACT_C);
				else
					key_event(ACT_B)
				end
				key_reset();
			else
				key_on(front);
			end
		elseif dis<=450 and dis>380 and my_rei>200 and math.random(4)==1 and enemy_act~=200 then
			key_reset();
			key_on(front);
			key_event2(ACT_D,ACT_UP);
			key_reset();
		elseif dis<=440 and dis>250 and my_act==5 and my_frame>20 and math.random(4)==1 then
			if math.random(3)==1 then
				key_reset();
				key_on(back);
				key_event(ACT_UP);
			elseif math.random(2)==1 then
				key_reset();
				key_event2(ACT_D,ACT_UP);
			else
				key_reset();
				key_on(front);
				key_event(ACT_UP);
			end
		elseif y==0 and dis<=380 and dis>300 and x>50 and x<1230 then
			if enemy_char~=12 and math.random(4)==1 then
				if math.random(2)==1 then
					key_reset();
					key_on(back);
					key_event(ACT_UP);
				else
					key_reset();
					key_on(front);
					key_event(ACT_UP);
				end
			elseif dis<320 and math.random(2)==1 then
				key_on(front)
				wait(10);
			elseif my_act==0 or my_act==4 then
				key_on(ACT_DOWN)
				key_on(back);
			else
			print("コマンド４");
				key_on(back);
				wait(4);
			end
		elseif dis<=300 and dis>260 and my_rei>200 and math.random(4)==1 and enemy_act~=200 then
			if my_rei>=500 and my_act<=5 and math.random(3)==1 then
				key_reset();
				key_on(ACT_D)
				yield();
				key_off(ACT_D)
				lvr2368(back);
				key_event(ACT_B);
			elseif math.random(3)==1 then
				key_on(front)
				wait(10);
			elseif math.random(3)==1 then
				key_reset();
				key_event2(ACT_D,front);
			else
				key_reset();
				key_on(back);
				key_event2(ACT_D,ACT_UP);
				key_reset();
			end
		elseif dis<=260 and (dis>120 or my_preact[1]==320 or my_act==320) and my_rei>400 and (my_act<=5 or my_act==200 or my_act==204 or my_act==302 or my_act==303 or my_act==305 or my_act==320 or my_act==321 or my_act==400 or my_act==402 or (my_act>=150 and my_act<=170)) and (math.random(14)==1 or ((my_preact[1]==320 or my_act==320) and math.random(5)==1)) and ey==0 and enemy_act~=200 then
			key_reset();
			key_on(ACT_UP);
			key_on(front);
			yield();
		elseif dis<=400 and dis>270 and my_rei>200 and enemy_act<=10 and math.random(10)==1 then
			if math.random(2)==1 then
				key_on(front)
				wait(10);
			else
				key_reset();
				key_on(front);
				key_event(ACT_D);
				key_reset();
			end
		elseif dis<300 and dis>50 and enemy_act==201 and enemy_allframe<12 then
			key_reset();
			key_on(front);
			key_on(ACT_D);
			yield();
		elseif dis<=270 and dis>180 and (my_act<=5 or my_act==200 or my_act==204 or my_act==302 or my_act==303 or my_act==305 or my_act==320 or my_act==321 or (my_act>=150 and my_act<=170)) and (enemy_act<6 or enemy_act>10) and math.random(8)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
			if my_act~=204 and math.random(4)==1 then
				key_off(ACT_DOWN)
				key_on(ACT_D);
				key_on(front)
				yield();
				key_event(ACT_A);
				key_reset();
			elseif my_act~=200 or (my_act==200 and my_allframe>=13) then
				if my_act==200 and my_allframe<13 and math.random(5)<=2 then
					key_reset();
					key_on(ACT_DOWN)
					wait(13-my_allframe)
					if enemy_act<=5 then
						if dis<100 and math.random(5)<=3 then
							key_reset()
							yield()
							key_event(ACT_A)
						else
							key_event(ACT_A)
						end
					end
				elseif (my_act<150 or my_act>170) and math.random(2)==1 then
					key_reset();
					key_event(ACT_A);
				else
					key_reset();
					key_on(ACT_DOWN)
					yield();
					key_event(ACT_A);
					key_reset();
				end
			end
		elseif dis<=250 and dis>180 and (my_act<=5 or my_act==200 or my_act==204 or my_act==302 or my_act==303 or my_act==305 or my_act==320 or my_act==321 or (my_act>=150 and my_act<=170)) and (enemy_act==4 or enemy_act==9) and search_JFP()==false and get_special_data(0,10)<=5 then
			if math.random(3)==1 then
				key_reset();
				key_on(front);
				yield();
				key_event(ACT_A);
			else
				if my_act==200 and my_allframe<13 and math.random(5)<=2 then
					key_reset();
					key_on(ACT_DOWN)
					wait(13-my_allframe)
					if enemy_act<=5 then
						if dis<100 and math.random(5)<=3 then
							key_reset()
							yield()
							key_event(ACT_A)
						else
							key_event(ACT_A)
						end
					end
				elseif (my_act<150 or my_act>170) and math.random(2)==1 then
					key_reset();
					key_event(ACT_A);
				else
					key_reset();
					key_on(ACT_DOWN)
					yield();
					key_event(ACT_A);
					key_reset();
				end
			end
		elseif dis<=280 and dis>160 and (my_act<6 or my_act>10) and (my_act<208 or my_act>212) and my_act~=204 and (enemy_act<300 or air_atk==1) and enemy_yspeed<=0 and math.random(17)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
			key_reset();
			key_on(ACT_D);
			key_on(front);
			yield();
			key_event(ACT_A);
			key_reset();
		elseif dis<=230 and dis>160 and (my_act<6 or my_act>9) and (my_act<208 or my_act>212) and math.random(5)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
			if (my_act==200 or my_act==204 or math.random(3)==1) then
				if math.random(3)==1 then
					key_reset();
					key_event(ACT_A);
				else
					key_reset();
					key_on(ACT_DOWN)
					yield();
					key_event(ACT_A);
					key_reset();
				end
			else
				key_reset();
				yield();
				key_on(ACT_D);
				key_event2(ACT_A,front);
				key_reset();
			end
		elseif dis<=220 and dis>80 and enemy_yspeed<=0 and (my_act<6 or my_act>9) and (my_act<208 or my_act>212) and ((enemy_act>=6 and enemy_act<=10) or (enemy_act>=208 and enemy_act<=215)) and enemy_yspeed<0 and math.random(17)==1 and search_JFP()==false and get_special_data(0,10)<=5 and math.random(after_guard_count)==1 then
			key_reset();
			key_on(ACT_D);
			key_on(front)
			yield();
			key_event(ACT_A);
		elseif dis<=220 and dis>80 and enemy_yspeed<=0 and (my_act<6 or my_act>9) and (my_act<208 or my_act>212) and (enemy_act<6 or enemy_act>10) and math.random(5)==1 and search_JFP()==false and get_special_data(0,10)<=5 and math.random(after_guard_count)==1 then
			if math.random(5)<=2 then
				key_reset();
				key_event(ACT_A);
			else
				key_reset();
				key_on(ACT_DOWN)
				yield();
				key_event(ACT_A);
				key_reset();
			end
		elseif dis<=220 and dis>80 and enemy_yspeed<=0 and (my_act<6 or my_act>9) and (my_act<208 or my_act>212) and enemy_act==5 and search_JFP()==false and get_special_data(0,10)<=5 and math.random(after_guard_count)==1 then
			if my_act~=300 and ((my_act~=320 or my_preact[1]~=320) or ((my_preact[1]==320 or my_act==320) and math.random(2)==1)) and math.random(3)==1 then
				key_reset();
				key_on(ACT_D);
				key_on(front)
				yield();
				key_event(ACT_A);
			elseif enemy_yspeed<=0 then
				key_reset();
				key_on(ACT_DOWN)
				yield();
				key_event(ACT_A)
				key_reset();
			end
		elseif dis<=160 and dis>80 and enemy_yspeed<=0 and (my_act<6 or my_act>9) and (my_act<208 or my_act>212) and (enemy_act<6 or enemy_act>10) and search_JFP()==false and get_special_data(0,10)<=5 and math.random(after_guard_count)==1 then
			if (my_act~=300 and my_act~=320 and (enemy_act>=1 and enemy_act<=3)) and math.random(4)==1 then
				key_reset();
				yield();
				key_event2(ACT_A,front);
			elseif (enemy_act>=6 or enemy_act<=9) and math.random(4)==1 then
				key_reset();
				yield();
				key_event2(ACT_A,front);
			elseif dis>120 and math.random(3)==1 then
				key_reset();
				key_event(ACT_A);
			else
				key_reset();
				key_on(ACT_DOWN)
				yield();
				key_event(ACT_A);
			end
		elseif dis<=80 and (my_act<6 or my_act>9) and (my_act<208 or my_act>212) and search_JFP()==false and get_special_data(0,10)<=5 and
			(my_preact[1]~=197 and my_preact[1]~=198 and my_preact[1]~=199) and my_act<690 then
			if weather==12 then
				print("地対地：距離80以下　→　条件：川霧");
				key_reset();
				key_on(ACT_DOWN);
				yield();
				key_event(ACT_A);
				key_reset();
			elseif my_act<=5 and enemy_act>=197 and enemy_act<=199 and (muteki==0 or (muteki>=1 and math.random(2)==1)) and math.random(3)==1 then
				print("地対地：距離80以下　→　条件１");
				if math.random(2)==1 then
					key_reset();
					key_event2(ACT_A,front);
				else
					key_reset();
					key_event2(ACT_A,ACT_DOWN);
				end
			elseif (enemy_act~=201 or (enemy_act==201 and enemy_allframe>10 and ey==0)) then
				print("地対地：距離80以下　→　条件２");
				if (enemy_xspeed>=-1 or dis<60) then
					key_reset();
					key_event(ACT_A);
				else
					key_reset();
					key_on(ACT_DOWN);
					key_event(ACT_A);
					key_reset();
				end
			end
		end
	end
end

function tikuusekkinn()
--print("地対空接近");
--対空。中距離なら飛び出して空中戦に。下をくぐれそうならくぐる。
--良い位置に居たらたまに6B、2C、3A、B昇天脚で対空してみる。状況によっては4A、2A、6Aで着地狩りも狙う。
--衣玖さんと小町に対しては飛び出す確率を下げる。飛び出した瞬間頭を叩かれる可能性が高いけど、全く飛び出さないと空中が安全になりすぎる。
	if dis<=500 and y==0 and ey>=10 and (enemy_act<70 or enemy_act>97) and enemy_act~=197 and enemy_act~=198 and enemy_act~=199 then

		if weather==13 and dis<=250 and (my_act<=10 or my_act==418) then
			key_reset();
			key_on(ACT_D);
			key_on(front);	
		elseif weather==13 and dis<=250 and my_act==200 then
			key_event2(ACT_C,front);
			key_reset();

		elseif land_atk==0 and weather~=13 and (my_act<=5 or my_act==204) and is_dir_front and (((my_dir+enemy_dir)==0 and dis<(90+enemy_xspeed*7)) or ((my_dir+enemy_dir)~=0 and dis<(90-enemy_xspeed*7)) or my_frontside<100) and ey<(100-enemy_yspeed*8) and enemy_yspeed<3 and (enemy_act==145 or (air_atk==1 and math.random(5)==1) or (my_frontside>=100 and math.random(15)==1) or (my_frontside<100 and math.random(4)==1)) and search_JFP()==false and get_special_data(0,10)<=5 then
			key_reset()
			key_event2(ACT_A,back)
		elseif land_atk==0 and weather~=13 and (my_act<=5 or my_act==204) and is_dir_front and ey<(220-enemy_yspeed*17) and ey>(180-enemy_yspeed*17) and enemy_yspeed<3 and ((my_frontside>=300 and math.random(130)==1) or (my_frontside<300 and math.random(60)==1)) and 
		(((my_dir+enemy_dir)==0 and (dis<(250+enemy_xspeed*17) or my_frontside<300) and (enemy_frontside>1050 or dis>(60+enemy_xspeed*17))) or
		((my_dir+enemy_dir)~=0 and (dis<(250-enemy_xspeed*17) or my_frontside<300) and (enemy_frontside<150 or dis>(60-enemy_xspeed*17)))) and search_JFP()==false and get_special_data(0,10)<=5 then
			key_reset();
			key_on(front);
			yield();
			key_event(ACT_A)
		elseif land_atk==0 and weather~=13 and (my_act<=5 or my_act==204) and is_dir_front and ey<(145-enemy_yspeed*10) and ey>(60-enemy_yspeed*13) and enemy_yspeed<3 and ((air_atk==1 and math.random(10)==1) or (my_frontside>=300 and math.random(80)==1) or (my_frontside<300 and (math.random(30)==1) or (is_card_use and (my_card==201 or my_card==206 or my_card==208) and math.random(15)==1))) and 
		(((my_dir+enemy_dir)==0 and (dis<(300+enemy_xspeed*10) or my_frontside<300) and (enemy_frontside>1050 or dis>(60+enemy_xspeed*10)) and enemy_xspeed<=0) or
		((my_dir+enemy_dir)~=0 and (dis<(300-enemy_xspeed*10) or my_frontside<300) and (enemy_frontside<150 or dis>(60-enemy_xspeed*10)) and enemy_xspeed>=0)) and search_JFP()==false and get_special_data(0,10)<=5 then
			key_reset();
			key_on(front);
			key_on(ACT_D)
			yield();
			key_event(ACT_A)
		elseif weather~=13 and (my_dir+enemy_dir)==0 and is_dir_front and dis<(180+enemy_xspeed*15) and (dis>(70+enemy_xspeed*13) or my_frontside>1190) and ey<=(230-enemy_yspeed*15) and ey>=(100-enemy_yspeed*10) and y==0 and (my_act<=5 or my_act==412 or (my_act>=150 and my_act<=170) or (my_preact[1]>=150 and my_preact[1]<=170)) and (enemy_act==9 or enemy_act==202 or enemy_act==214 or ((enemy_act==306 or enemy_act==308) and (enemy_preact[1]==202 or enemy_preact[1]==214 or enemy_preact[2]==214))) and enemy_xspeed>5 and enemy_yspeed<3 and math.random(13)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
			if (dis>(100+enemy_xspeed*15) or ey<=(150-enemy_yspeed*15)) and math.random(2)==1 then
				key_on(front)
				key_on(ACT_D)
				yield();
				key_event(ACT_C)
			elseif dis>(70+enemy_xspeed*10) and math.random(2)==1 then
				key_on(front)
				yield()
				key_event(ACT_A)
			else
				key_reset();
				lvr623(ACT_B);
			end
		elseif weather~=13 and (my_act<=5 or my_act==204) and is_dir_front and ey>(250-enemy_yspeed*20) and land_atk==0 and math.random(50)==1 and
		(((my_dir+enemy_dir)==0 and dis<(80+enemy_xspeed*20) and enemy_xspeed>=0) or
		((my_dir+enemy_dir)~=0 and dis<(80-enemy_xspeed*20) and enemy_xspeed<=0)) then
			key_reset()
			key_on(ACT_DOWN)
			yield();
			key_event(ACT_C)
		elseif dis<=500 and dis>300 and my_act<=5 and ey<=400 and (ey>180 or (enemy_yspeed>=4 and ey>120) or (enemy_yspeed>=7 and ey>100)) and air_atk==1 then
			key_reset();
			key_on(front);
			key_event2(ACT_D,ACT_UP);
			key_reset();
		elseif dis<=300 and dis>200 and my_act<=5 and ey<=400 and (ey>180 or (enemy_yspeed>=4 and ey>120) or (enemy_yspeed>=7 and ey>100)) and air_atk==1 then
			key_reset();
			key_event2(ACT_UP,front);
		elseif dis<200 and dis>100 and my_act<=5 and ey<=400 and (ey>180 or (enemy_yspeed>=4 and ey>120) or (enemy_yspeed>=7 and ey>100)) and air_atk==1 then
			if enemy_xspeed>4 and (my_dir+enemy_dir)==0 and math.random(5)==1 then
				key_reset();
				key_event2(ACT_D,ACT_UP);
			elseif enemy_xspeed>4 and (my_dir+enemy_dir)==0 and math.random(2)==1 then 
				key_reset();
				key_event(ACT_UP);
			else
				key_reset();
				key_event2(ACT_UP,front);
			end
		elseif dis<100 and ey<=350 and my_act<=5 and enemy_xspeed>4 and (ey>180 or (enemy_yspeed>=4 and ey>120) or (enemy_yspeed>=7 and ey>100)) and air_atk==1 then
			key_reset();
			key_on(back)
			key_event(ACT_UP);	
		elseif enemy_char~=13 and dis<=500 and dis>400 and ey<=300 and ey>150 and (enemy_act<300 or air_atk==1) and math.random(12)==1 then
			if math.random(5)<=3 then
				key_reset();
				key_on(front);
				key_event2(ACT_D,ACT_UP);
				key_reset();
			else
				key_reset();
				key_event2(ACT_UP,front);
			end
		elseif enemy_char==13 and dis<=500 and dis>450 and ey<=300 and ey>150 and (enemy_act<300 or air_atk==1) and math.random(25)==1 then
			key_reset();
			key_on(front);
			key_event2(ACT_D,ACT_UP);
			key_reset();
		elseif dis<=250 and ey>100 and my_act<=5 and (enemy_xspeed>4 or ((enemy_act==202 or enemy_act==214) and enemy_allframe<5)) and enemy_yspeed>=-1 and ((x>990 and my_dir==1) or (x<290 and my_dir==-1)) and (enemy_act<300 or air_atk==1) and math.random(4)==1 then
			key_reset();
			key_on(back);
			key_event(ACT_UP);
			wait(5);
		elseif dis<=400 and ey<=500 and ey>150 and y==0 and my_act<=8 and ((enemy_act>=208 and enemy_act<=212 and enemy_allframe==20) or (enemy_act<=214 and enemy_allframe==8) or (enemy_act>=6 and enemy_act<=8 and enemy_allframe==10)) and enemy_yspeed>=6 and math.random(3)==1 then
			if (enemy_char~=13 or (enemy_char==13 and math.random(3)==1)) and ((enemy_act==214 and (dis<200 or math.random(2)==1)) or (enemy_act~=214 and math.random(2)==1) or (((my_preact[1]>=150 and my_preact[1]<=170) or (my_preact[2]>=150 and my_preact[2]<=170)) and math.random(3)<=2)) then
				if math.random(4)==1 then
					key_reset();
					key_on(front);
					key_event2(ACT_D,ACT_UP);
					key_reset();
				elseif math.random(4)==1 then
					key_reset();
					key_event2(ACT_UP,front);
				elseif math.random(2)==1 then
					key_reset();
					key_event2(ACT_D,ACT_UP);
					key_reset();
				else
					key_reset();
					key_on(back);
					key_event2(ACT_D,ACT_UP);
					key_reset();		
				end
			elseif ey>250 and (dis>200 and enemy_xspeed<=0) or (dis>350 and enemy_xspeed>0) then
				key_reset();
				key_on(front);
				yield();
				key_event(ACT_B);
			end
		elseif dis<=500 and ey<=300 and ey>50 and ((enemy_act==202 and enemy_allframe<=6) or (enemy_act==214 and enemy_allframe<=7)) and enemy_xspeed>=4 and enemy_yspeed<=1 and math.random(6)==1 then 
			if dis>250 then
				if math.random(3)==1 then
					key_reset();
					key_on(front);
					key_event2(ACT_D,ACT_UP);
					key_reset();
				else
					key_reset();
					key_event2(ACT_UP,front);
				end
			elseif dis<250 and dis>100 and y<150 and y>50 and math.random(2)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
				if math.random(2)==1 then
					key_reset()
					key_on(front)
					yield()
					key_event(ACT_A)
				else
					key_reset();
					lvr623(ACT_B);
				end
			end
			
	--対空Ａ
		elseif y==0 and ey>0 and enemy_obj_range_in(150,60)==false and my_act<=10 and not(enemy_act>=97 and enemy_act<=98) and not(enemy_act>=197 and enemy_act<=199) and is_dir_front==true and
		((not(enemy_act>=50 and enemy_act<=166)and math.random(after_guard_count+5)==1) or (enemy_act>=50 and enemy_act<=166)) and
			(	
				(	dis>=120 and
					((ex+enemy_xspeedEX*15)-x)*my_dir		<=	210+30 	and
					((ex+enemy_xspeedEX*15)-x)*my_dir		>=	30-30 	and
					(ey+enemy_yspeed*15+(15*(14*e_gs))/2)	<=	110 		--and
					--(ey+enemy_yspeed*15+(15*(14*e_gs))/2)	>=	80-180
				) or
				(	dis<120 and
					((ex+enemy_xspeedEX*10)-x)*my_dir		<=	100+30 	and
					((ex+enemy_xspeedEX*10)-x)*my_dir		>=	20-30 	and
					(ey+enemy_yspeed*10+(10*(9*e_gs))/2)	<=	130 		--and
					--(ey+enemy_yspeed*10+(10*(9*e_gs))/2)	>=	50-180
				)
			) then
			print("対空Ａ");
			key_event(ACT_A);
	--対空６Ａ
		elseif y==0 and ey>0 and enemy_obj_range_in(150,60)==false and my_act<=10 and not(enemy_act>=97 and enemy_act<=98) and not(enemy_act>=197 and enemy_act<=199) and is_dir_front==true and
		((not(enemy_act>=50 and enemy_act<=166)and math.random(after_guard_count+5)==1) or (enemy_act>=50 and enemy_act<=166)) and
					((ex+enemy_xspeedEX*18)-x)*my_dir		<=	180+90+30 	and
					((ex+enemy_xspeedEX*18)-x)*my_dir		>=	20+90-30 	and
					(ey+enemy_yspeed*18+(18*(17*e_gs))/2)	<=	150 		then --and
					--(ey+enemy_yspeed*18+(18*(17*e_gs))/2) >=	20-180		then
			print("対空６Ａ");
			key_event2(ACT_A,front);
	--対空DＡ
		elseif y==0 and ey>0 and enemy_obj_range_in(150,60)==false and my_act<=10 and not(enemy_act>=97 and enemy_act<=98) and not(enemy_act>=197 and enemy_act<=199) and is_dir_front==true and
		((not(enemy_act>=50 and enemy_act<=166)and math.random(after_guard_count+5)==1) or (enemy_act>=50 and enemy_act<=166)) and
					((ex+enemy_xspeedEX*13)-x)*my_dir		<=	180+90+30 	and
					((ex+enemy_xspeedEX*13)-x)*my_dir		>=	20+90-30 	and
					(ey+enemy_yspeed*13+(13*(12*e_gs))/2)	<=	150 		then --and
					--(ey+enemy_yspeed*18+(18*(17*e_gs))/2) >=	20-180		then
			print("対空DＡ");
			key_reset();
			key_on(ACT_D);
			key_event2(ACT_A,front);
			
		elseif enemy_char~=12 and enemy_char~=13 and dis<=400 and dis>250 and ey<=300 and ey>100 and (enemy_act<300 or air_atk==1) and math.random(8)==1 then 
			if (x<80 or x>1160) then
				if math.random(2)==1 then
					key_reset();
					key_event2(ACT_D,ACT_UP);
				else		
					key_reset();
					key_on(back);
					key_event(ACT_UP);
					wait(10);
				end
			elseif math.random(3)==1 then
				key_reset();
				key_on(front);
				key_event2(ACT_D,ACT_UP);
				key_reset();
			elseif enemy_xspeed>4 then
				if math.random(2)==1 then
					key_reset();
					key_event2(ACT_D,ACT_UP);
				else
					key_reset();
					key_event(ACT_UP);	
				end		
			end
		elseif (enemy_char==12 or enemy_char==13) and enemy_yspeed>0 and dis<=400 and dis>250 and ey<=250 and ey>100 and (enemy_act<300 or air_atk==1) and math.random(20)==1 then
			key_reset();
			key_event2(ACT_UP,front);
			key_reset();
		elseif enemy_char~=12 and enemy_char~=13 and dis<=400 and dis>250 and (enemy_act<300 or air_atk==1) and ey<=250 and ey>150 and x>240 and x<1040 then
			if math.random(3)==1 then
				key_reset();
				key_on(back);
				key_event2(ACT_UP,ACT_D);
			else
				key_reset();
				key_on(back);
				key_event(ACT_UP);
				wait(10);
			end
		elseif (enemy_char==12 or enemy_char==13) and dis<=400 and dis>250 and (enemy_act<300 or air_atk==1) and ey<=200 and ey>100 and x>240 and x<1040 then 
			if math.random(3)==1 then
				key_reset();
				key_on(back);
				key_event2(ACT_UP,ACT_D);
			else
				key_reset();
				key_on(back);
				key_event(ACT_UP);
				wait(10);
			end
		elseif dis<=350 and my_act<=5 and ey<400 and ey>(90-enemy_yspeed*10) and (enemy_xspeed<=0 or enemy_frontside>1150) and enemy_yspeed>-1 and math.random(12)==1 and my_rei>500 and (math.random(7)==1 or enemy_rei<200 or (((card_check(201) and my_spell_more(2500)) or card_check(208)) and enemy_rei<600)) then
			if dis<120 and ey>150 and math.random(5)==1 then
				key_reset()
				key_on(ACT_DOWN)
				yield()
				key_event(ACT_C)
			elseif dis>100 and ey>120 and math.random(5)==1 then
				key_reset()
				key_on(front)
				yield()
				key_event(ACT_B)	
			elseif ey<(250-enemy_yspeed*10) then
				if math.random(4)==1 or ((card_check(208) or (card_check(201) and my_spell_more(2500))) and math.random(2)==1 and enemy_rei<600 and my_rei>enemy_rei) then
					key_reset();
					key_on(ACT_D)
					key_event2(ACT_UP,front);
				else		
					key_reset();
					key_event2(ACT_UP,front);
				end
			end
		elseif enemy_char~=12 and enemy_char~=13 and dis<=300 and dis>200 and ey>300 and (enemy_act<300 or air_atk==1) and math.random(9)==1 then
			if enemy_yspeed>0 then
				key_reset();
				key_event2(ACT_D,ACT_UP);
				key_reset();
			else
				key_reset();
				key_on(back);
				key_event(ACT_UP);
				wait(10);
			end
		elseif (enemy_char==12 or enemy_char==13) and dis<=300 and dis>200 and ey>300 and (enemy_act<300 or air_atk==1) and math.random(22)==1 then
			if enemy_yspeed>0 then
				key_reset();
				key_event2(ACT_D,ACT_UP);
				key_reset();
			else
				key_reset();
				key_on(back);
				key_event(ACT_UP);
				wait(10);
			end
		elseif dis<=300 and ((dis>200 and enemy_xspeed>4 and ey>240) or (dis<100 and enemy_xspeed<-4 and ey>190) or (dis<200 and enemy_xspeed>2 and ey>170 and air_atk==1)) and ey<330 and enemy_yspeed<-3 and (my_dir+enemy_dir)==0 and enemy_act~=308 and enemy_act<400 and ((enemy_act~=180 and enemy_act~=181) or (enemy_act==180 and enemy_allframe>20) or (enemy_act==181 and enemy_allframe>20)) and enemy_attackarea_n==0 and my_frontside>300 and math.random(8)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
			key_reset();
			key_on(front);
			yield();
			key_event2(ACT_A,ACT_DOWN);
		elseif dis<=200 and ((enemy_act>=6 and enemy_act<=8) or (enemy_act>=208 or enemy_act==212)) and enemy_yspeed>=5 and enemy_allframe<10 and math.random(10)==1 then
			if math.random(3)==1 then
				key_reset();
				key_on(front);
				key_event2(ACT_D,ACT_UP);
				key_reset();
			else
				key_reset();
				key_event2(ACT_UP,front);
			end
		elseif (dis<=180 or (dis<100 and ey<100 and enemy_xspeed>-8)) and (dis>80 or (dis>20 and enemy_xspeed<=1)) and ((ey>250 and enemy_yspeed>-6) or (ey>280 and enemy_yspeed<-6)) and ey<320 and enemy_xspeed>=-1 and enemy_xspeed<=8 and enemy_yspeed<=-2 and (my_dir+enemy_dir)==0 and enemy_act~=308 and enemy_act<400 and ((enemy_act~=180 and enemy_act~=181) or (enemy_act==180 and enemy_allframe>20) or (enemy_act==181 and enemy_allframe>20)) and math.random(16)==1 then
			key_reset();
			lvr623(ACT_B);
		elseif dis<=150 and ((ey>320 and enemy_yspeed>-11) or (ey>270 and enemy_yspeed>-7) or (ey>220 and enemy_yspeed>-3)) and my_act<=5 and enemy_yspeed<0 and enemy_xspeed<2 and enemy_xspeed>-2 and enemy_act==214 and math.random(13)==1 then
			if (my_dir+enemy_dir)==0 and dis<100 and (x<=440 and my_dir==1) or (x>840 and my_dir==-1) then
				key_reset();
				key_event2(ACT_D,front);
			elseif math.random(3)==1 then
				key_reset();
				key_on(back);
				key_event(ACT_UP);
			else
				key_reset();
				key_on(back);
				key_event(ACT_UP);	
				wait(30)
			end
		elseif dis<=200 and dis>50 and my_act<=5 and ey>200 and ey<450 and ex>80 and ex<1160 and (enemy_act<300 or air_atk==1) then
			if my_act==0 or my_act==5 then
				key_on(ACT_DOWN)
				key_on(front);
				yield();
				key_off(ACT_DOWN)
			else
				key_on(front);
			end
		elseif (dis<90 or (enemy_air==2 and dis<110)) and (((ey>320 or (enemy_air==2 and ey>270)) and enemy_yspeed>-10) or ((ey>240 or (enemy_air==2 and ey>190)) and enemy_yspeed>-6) or ((ey>200 or (enemy_air==2 and ey>150)) and enemy_yspeed>-2)) and ey<500 and my_act<=5 and enemy_xspeed>0 and enemy_xspeed<8 and enemy_act<500 and (my_dir+enemy_dir)==0 and (math.random(20)==1 or (enemy_air==2 and math.random(5)==1)) then
			key_reset();
			key_event2(ACT_C,ACT_DOWN);
		elseif dis<50 and ey>300 and ey<550 and ((x<50 and my_dir==1) or (x>1150 and my_dir==-1)) then
			key_reset();
			key_on(front);
			key_event(ACT_D);
			key_reset();
		elseif dis<50 and ey>=200 and ey<350 and ((x<140 and my_dir==1) or (x>1140 and my_dir==-1)) and math.random(10)==1 then
			key_reset();
			key_on(front);
			key_event(ACT_D);
			key_reset();
		elseif dis<400 and my_act<=5 and enemy_xspeed<=4 and enemy_xspeed>=-1 and ey<350 and (enemy_act<300 or air_atk==1) then
			if (enemy_char~=13 or (enemy_char==13 and math.random(3)==1)) and dis>100 and ey>100 and enemy_yspeed>5 and (enemy_act<300 or air_atk==1) and math.random(13)==1 then
				if dis>100 then
					if math.random(3)==1 then
						key_reset();
						key_event2(ACT_UP,front)
					else
						key_reset();
						key_on(ACT_D)
						key_event2(ACT_UP,front)
					end
				else
					if math.random(4)==1 then
						key_reset();
						key_on(ACT_D)
						key_event(ACT_UP)
					else
						key_reset();
						key_on(back);
						key_event(ACT_UP)
						wait(10);
					end
				end
			elseif dis<250 and dis>150 and ey<240 and ey>210 and enemy_yspeed<-4 and (enemy_act<300 or air_atk==1) and math.random(14)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
				key_reset();
				yield();
				key_event2(ACT_A,front)
			elseif dis<250 and dis>100 and ey<90 and ey>70 and enemy_yspeed<-3 and air_atk==1 and math.random(8)==1 and search_JFP()==false and get_special_data(0,10)<=5 then
				key_reset();
				yield();
				key_event2(ACT_A,ACT_DOWN)
			end
		elseif enemy_act==145 and dis>60 then
			if dis<120 and my_act==200 then
				key_reset()
			elseif dis>300 or (dis>120 and my_act==200) then
				key_on(ACT_D)
				key_on(front)

			else
				key_on(front)
			end
		end
	end
end

--裏向き時。地上では特に何もしない。低空時は前ダッシュか後ダッシュ。ある程度の高度で空中に居たら下飛翔で降りる。気まぐれにめくり亜空穴。
function ura()
--print("裏向き");
	if dis<=600 then
		if dis<25 and y>60 and y<=200 and ey==0 and (x<60 or x>1220) and (my_act==9 or my_act==214) and search_JFP()==false and get_special_data(0,10)<=5 then
			key_reset();
			key_event(ACT_A);
		elseif dis>=100 and my_rei>=500 and math.random(900)==1 and ey<220 and y>=100 and y<500 and weather~=12 and my_act~=214 and (caution_akuu==0 or (caution_akuu==1 and (ey>100 or (ey>50 and enemy_yspeed>=0)))) and my_air<=1 then
			key_reset();
			lvr623(ACT_B);
		elseif dis>=100 and my_rei>=500 and math.random(1500)==1 and ey<220 and y>=100 and y<500 and weather~=12 and (caution_akuu==0 or (caution_akuu==1 and (ey>100 or (ey>50 and enemy_yspeed>=0)))) and my_air==2 then
			key_reset();
			lvr623(ACT_B);
		elseif dis<=200 and my_rei>200 and y>200 and enemy_act==200 and my_air<=1 then
			key_reset();
			key_on(ACT_DOWN);
			key_on(ACT_D);
			key_reset();
		elseif dis<=300 and my_rei>200 and y>150 and (y-ey)>100 and math.random(3)==1 and my_act~=214 and my_air<=1 then
			if math.random(3)==1 and my_air==0 and x>240 and x<1040 then
				key_reset();
				key_event2(ACT_D,front);
				key_reset();
			elseif math.random(4)==1 then
				key_reset();
				key_on(back);
				key_event2(ACT_D,ACT_DOWN);
				key_reset();
			elseif math.random(2)==1 then
				key_reset();
				key_on(front);
				key_event2(ACT_D,ACT_DOWN);
				key_reset();
			else
				key_reset();
				key_event2(ACT_D,ACT_DOWN);
				key_reset();
			end
		elseif y>=80 and dis<=300 and my_air<=1 and y<250 and ey<=250 and (my_act==9 or my_act==202 or my_act==406 or my_act==414 or my_act==416) then
			if (caution_akuu==0 or (caution_akuu==1 and (ey>100 or (ey>50 and enemy_yspeed>=0)))) and math.random(40)==1 and my_rei>=400 then
				key_reset();
				lvr623(ACT_B);
			elseif math.random(2)==1 and my_rei>=400 and ey<=50 then
				key_reset();
				key_event(front);
				key_event(front);
			else
			print("４４");
				key_reset();
				key_event(back);
				key_event(back);
			end	
		end
	end
end

--開幕時。座って威嚇。近付かれると後ろに下がる。開幕直前で密着されてたらとりあえずガード。
function kaimaku()
	if dis<=900 then
		if dis>=100 and battle_time<140 then
			key_on(ACT_DOWN)
			wait(5);
		elseif dis<100 and battle_time==176 then
			key_reset();
			key_on(back);
			caution_atk = 10 + math.random(20);
		end
	end
end

--警戒状態。自発的には攻撃を行わず、相手の出方を待つ。
function keikai()
	if my_act<=5 or my_act==10 then
		key_on(back);
		key_on(ACT_DOWN);
	elseif my_act==9 then
		key_on(back);
	end
end

function base_states()
--霊夢
	if enemy_char==0 then
		print("Target = 霊夢")
		stand_neutral = 34;
		stand_front = 54;
		stand_back = 54;
		enemy_standup_range = 337;
		caution_range = 320;
		base_chain = 4;
		graze_atk = 2;
		m300_rapid = 8;
--魔理沙
	elseif enemy_char==1 then
		print("Target = 魔理沙")
		stand_neutral = 36;
		stand_front = 52;
		stand_back = 51;
		enemy_standup_range = 362;
		base_chain = 4;
		muteki = 1;
		m300_rapid = 7;
--咲夜
	elseif enemy_char==2 then
		print("Target = 咲夜")
		stand_neutral = 38;
		stand_front = 44;
		stand_back = 46;
		enemy_standup_range = 300;
		base_chain = 4;
		graze_atk = 2;
		m300_rapid = 8;
--アリス
	elseif enemy_char==3 then
		print("Target = アリス")
		stand_neutral = 29;
		stand_front = 49;
		stand_back = 49;
		enemy_standup_range = 465;
		base_chain = 4;
		caution_range = 400;
		m300_rapid = 9;
--パチュリー
	elseif enemy_char==4 then
		print("Target = パチュリー")
		stand_neutral = 27;
		stand_front = 47;
		stand_back = 47;
		enemy_standup_range = 506;
		base_chain = 3;
		m300_rapid = 9;
--妖夢
	elseif enemy_char==5 then
		print("Target = 妖夢")
		stand_neutral = 25;
		stand_front = 57;
		stand_back = 57;
		enemy_standup_range = 445;
		base_chain = 5;
		muteki = 1;
		m300_rapid = 7;
--レミリア
	elseif enemy_char==6 then
		print("Target = レミリア")
		stand_neutral = 29;
		stand_front = 35;
		stand_back = 35;
		enemy_standup_range = 356;
		base_chain = 4;
		muteki = 1;
		graze_atk = 2;
		m300_rapid = 7;
--幽々子
	elseif enemy_char==7 then
		print("Target = 幽々子")
		stand_neutral = 19;
		stand_front = 63;
		stand_back = 63;
		enemy_standup_range = 379;
		base_chain = 3;
		graze_atk = 2;
		m300_rapid = 10;
--紫
	elseif enemy_char==8 then
		print("Target = 紫")
		stand_neutral = 58;
		stand_front = 76;
		stand_back = 76;
		enemy_standup_range = 450;
		base_chain = 4;
		caution_range = 320;
		graze_atk = 2;
		m300_rapid = 9;
--萃香
	elseif enemy_char==9 then
		print("Target = 萃香")
		stand_neutral = 35;
		stand_front = 47;
		stand_back = 47;
		enemy_standup_range = 360;
		base_chain = 4;
		graze_atk = 2;
		m300_rapid = 9;
--文
	elseif enemy_char==11 then
		print("Target = 文")
		stand_neutral = 36;
		stand_front = 46;
		stand_back = 46;
		enemy_standup_range = 390;
		base_chain = 4;
		graze_atk = 2;
		m300_rapid = 7;
--うどんげ
	elseif enemy_char==10 then
		print("Target = うどんげ")
		stand_neutral = 43;
		stand_front = 45;
		stand_back = 58;
		enemy_standup_range = 337;
		base_chain = 4;
		graze_atk = 1;
		m300_rapid = 7;
--小町
	elseif enemy_char==12 then
		print("Target = 小町")
		stand_neutral = 47;
		stand_front = 54;
		stand_back = 54;
		enemy_standup_range = 362;
		base_chain = 4;
		caution_range = 350;
		graze_atk = 1;
		m300_rapid = 9;
--衣玖
	elseif enemy_char==13 then
		print("Target = 衣玖")
		stand_neutral = 39;
		stand_front = 88;
		stand_back = 88;
		enemy_standup_range = 594;
		base_chain = 4;
		caution_range = 350;
		m300_rapid = 8;
--天子
	elseif enemy_char==14 then
		print("Target = 天子")
		stand_neutral = 31;
		stand_front = 42;
		stand_back = 42;
		enemy_standup_range = 362;
		base_chain = 3;
		graze_atk = 2;
		m300_rapid = 9;
--早苗
	elseif enemy_char==15 then
		print("Target = 早苗")
		stand_neutral = 25;
		stand_front = 53;
		stand_back = 58;
		enemy_standup_range = 362;
		base_chain = 4;
		graze_atk = 2;
		m300_rapid = 7;
--チルノ
	elseif enemy_char==16 then
		print("Target = チルノ")
		stand_neutral = 31;
		stand_front = 54;
		stand_back = 54;
		enemy_standup_range = 496;
		base_chain = 4;
		m300_rapid = 6;
--美鈴
	elseif enemy_char==17 then
		print("Target = 美鈴")
		stand_neutral = 26;
		stand_front = 44;
		stand_back = 44;
		enemy_standup_range = 362;
		base_chain = 4;
		graze_atk = 2;
		m300_rapid = 6;
--空
	elseif enemy_char==18 then
		print("Target = 空")
		stand_neutral = 20;
		stand_front = 55;
		stand_back = 55;
		enemy_standup_range = 600;
		base_chain = 4;
		graze_atk = 1;
		m300_rapid = 7;
--諏訪子
	elseif enemy_char==19 then
		print("Target = 諏訪子")
		stand_neutral = 29;
		stand_front = 81;
		stand_back = 81;
		enemy_standup_range = 375;
		base_chain = 4;
		m300_rapid = 7;
	end


--ガード・グレイズ精度。数値が高いほどミスが多くなる
--ステージが博麗神社(倒壊・通常両方)だと超反応モードに
--レミリアはステージ選択が不自由なので、霊夢関連のBGMで超反応モードに
	if stage_number==0 or stage_number==10 then
		guard_rank = 0;
		graze_rank = 0;
		print("★神社ステージ：超反応モードON")
	elseif enemy_char==6 and (bgm_number==0 or bgm_number==10 or bgm_number==40) then
		guard_rank = 0;
		graze_rank = 0;
		print("★(レミリアのみ)BGM霊夢関連：超反応モードON")
	else
		guard_rank = 20;
		graze_rank = 24;
		print("☆通常モード")
	end

--新キャラはまだガード設定が無いので警告表示
	if enemy_char>=15 then
		print("！非想天則追加キャラ：ガードグレイズ設定未実装")
		print("！非想天則追加キャラ：改変により暫定的に対応")
	end
end

function combo()
--夢想封印からの追撃
	if ex_combo==2 then
--夢想封印割りから。AAA6B
		if my_act==601 and my_allframe>=142 and my_frontside<100 and ey<150 and enemy_act==71 then
			key_reset();
			key_event(ACT_A)
			wait(10)
			key_event(ACT_A)
			wait(12)
			key_event(ACT_A)
			wait(15)
			key_on(front)
			yield()
			key_event(ACT_B)
--夢想封印から6Bか2Cで追撃
		elseif my_act<=5 or my_act==204 or (my_act==200 and my_allframe>=13) or ((my_act==601 or my_act==651) and my_allframe>=143) then
			if my_frontside>160 then
				key_reset()
				key_on(front)
				yield()
				key_event(ACT_B)		
			elseif my_frontside<160 and my_frontside>120 then
				key_reset()
				key_on(front)
				yield()
			else
				key_reset()
				key_on(ACT_DOWN)
				yield()
				key_event(ACT_C)
			end
		else
			key_reset()
			yield()
			kihon()
		end
--端の高威力コンボ。B>C>J2BかB>C>2A
	elseif ex_combo==1 then
		if my_act==400 and enemy_act>=50 and enemy_act<=65 and (my_allframe==21 or my_allframe==24) then
			key_reset();
			key_event(ACT_C);
		elseif my_act==410 and (enemy_act==52 or enemy_act==58) and my_limit<65 and my_allframe>=33 and my_rei>=300 then
			key_reset();
			key_on(back);
			key_on(ACT_UP)
			wait(3);
			key_reset();
			key_on(ACT_DOWN);
			yield();
			key_event(ACT_B)
			ex_combo = 0;
		elseif my_act==410 and (enemy_act==64 or my_rei<300 or my_limit>=75) and my_allframe>=50 then
			key_reset();
			key_on(ACT_DOWN);
			yield();
			key_event(ACT_A);
			wait(18);
			ex_combo = 0;
		else
			key_reset();
			yield();
			kihon();
		end
--DCCH確認で鬼縛陣。川霧では距離制限を厳しく
	elseif my_correction==33 and card_check(206) and my_spell_more(2000) and enemy_act==77 and enemy_allframe<35 and ((my_act<=5 and my_preact[1]==418) or (my_act==418 and my_allframe>25)) and ((weather~=12 and (dis<130 or my_frontside<170)) or (weather==12 and dis<90)) then
		key_reset();
		if my_card==206 then
			key_on(ACT_BC);
			wait(1);
			key_reset();
		elseif my_card~=206 then
			key_on(ACT_AB);
			wait(2);
			key_reset();
		end
--3ACH確認で鬼縛陣。川霧では距離制限を厳しく
	elseif my_correction==33 and card_check(206) and my_spell_more(2000) and enemy_act==77 and enemy_allframe<40 and my_act==304 and my_allframe>=33 and ((weather~=12 and (dis<90 or my_frontside<170)) or (weather==12 and dis<60)) then
		key_reset();
		if my_card==206 then
			key_on(ACT_BC);
			wait(1);
			key_reset();
		elseif my_card~=206 then
			key_on(ACT_AB);
			wait(2);
			key_reset();
		end
--DBヒット確認で鬼縛陣
	elseif is_card_use and my_card==206 and enemy_act>=70 and enemy_act<=80 and my_act==408 then
		key_reset();
		if my_card==206 then
			key_on(ACT_BC);
			wait(1);
			key_reset();
		end
--JA圏内に入ったらJAで拾ってみる
	elseif ((my_act==202 and my_allframe>=11) or (my_act==203 and my_allframe>=1) or (my_act==214 and my_allframe>=14) or (my_act==208 and my_allframe>=2) or (my_act==209 and my_allframe>=2) or my_act==212 or (my_act==8 and my_allframe>=2) or (my_act==9 and my_allframe>=2)) and enemy_act>=70 and enemy_act<=80 and my_act~=306 and
	((dis<=250 and my_xspeed>=6) or (dis<=220 and my_xspeed<6 and my_xspeed>2) or (dis<=200 and my_xspeed<2 and my_xspeed>-2) or (dis<=190 and my_xspeed<-2 and my_xspeed>-6) or (dis<=180 and my_xspeed<=-6)) and 
	(((y-ey)<90 and (ey-y)<140 and my_yspeed>=10) or ((y-ey)<100 and (ey-y)<120 and my_yspeed<10 and my_yspeed>5) or ((y-ey)<110 and (ey-y)<80 and my_yspeed<5 and my_yspeed>1) or ((y-ey)<120 and (ey-y)<70 and my_yspeed<1 and my_yspeed>-3) or ((y-ey)<130 and (ey-y)<55 and my_yspeed<-3 and my_yspeed>-6) or ((y-ey)<130 and (ey-y)<35 and my_yspeed<-6 and my_yspeed>-10) or ((y-ey)<160 and (ey-y)<20 and my_yspeed<=-10)) then
		key_reset();
		key_event(ACT_A);
--J8A圏内に入ったらJ8Aで拾ってみる。地上B射撃からの場合はJA拾いに切り替え
	elseif ((my_act==202 and my_allframe>=11) or (my_act==203 and my_allframe>=1) or (my_act==214 and my_allframe>=14) or (my_act==208 and my_allframe>=2) or (my_act==209 and my_allframe>=2) or my_act==212 or (my_act==8 and my_allframe>=2) or (my_act==9 and my_allframe>=2)) and enemy_act>=70 and enemy_act<=80 and my_limit<100 and
	((dis<=160 and my_xspeed>=4) or (dis<=130 and my_xspeed<4 and my_xspeed>-4) or (dis<=100 and my_xspeed<=-4)) and
	(((y-ey)<-140 and (ey-y)<310 and my_yspeed>=10) or ((y-ey)<-120 and (ey-y)<290 and my_yspeed<10 and my_yspeed>5) or ((y-ey)<-80 and (ey-y)<270 and my_yspeed<5 and my_yspeed>1) or ((y-ey)<-70 and (ey-y)<260 and my_yspeed<1 and my_yspeed>-3) or ((y-ey)<-55 and (ey-y)<250 and my_yspeed<-3 and my_yspeed>-6) or ((y-ey)<-35 and (ey-y)<230 and my_yspeed<-6 and my_yspeed<=-9) or ((y-ey)<20 and (ey-y)<200 and my_yspeed<=-10)) then
		if my_act==209 and (my_preact[1]==400 or my_preact[2]==400 or my_preact[1]==402 or my_preact[2]==402) then
			key_reset();
			key_event(ACT_A);
		else
			key_reset();
			key_event2(ACT_A,ACT_UP);
		end
--地上の相手がのけぞってたらJAで突いてみる
	elseif ((my_act==202 and my_allframe>=11) or (my_act==203 and my_allframe>=1) or my_act==208 or my_act==209 or my_act==212 or (my_act==214 and my_allframe>=14) or my_act==9) and ((dis<300 and my_xspeed>4) or dis<200) and ((y<250 and my_yspeed<-5) or y<200) and my_xspeed>=0 and my_yspeed<=1 and enemy_act>=50 and enemy_act<=64 then
		if y>40 and my_yspeed>-1 and (my_act==202 or my_act==214) and my_xspeed>=4 and ((enemy_act==51 and enemy_frame<=4) or ((enemy_act==52 or enemy_act==64) and enemy_frame<=8)) then
			key_reset();
			yield();
			kihon();
		else
			key_reset();
			key_event(ACT_A);
		end
--JAJ8AJBJ8A。前慣性が利いていて、なおかつJAが空中密着ヒットした時のみ狙う
	elseif my_act==306 and enemy_act>=70 and enemy_act<=80 and dis<100 and my_rei>=200 and (y-ey)<0 and x>240 and x<1040 and my_limit==0 and my_xspeed>2 and my_yspeed>=0 and weather~=12 then
		key_reset();
		key_event2(ACT_A,ACT_UP);
		wait(20);
		key_event(ACT_B);
		wait(18);
		key_event(front);
		key_event(front);
		wait(7);
		key_event2(ACT_A,ACT_UP);
		wait(30);
--JA空中ヒットからJ2B、J6A、J8A
	elseif dis<300 and my_act==306 and enemy_act>=70 and enemy_act<=80 and ey>0 and (my_hitstop>0 or my_allframe>=7) then
		if (dis<100 or (dis<150 and my_xspeed>=4) or (dis<200 and my_xspeed>=8)) and (y-ey)>-40 and (ey-y)<250 and my_rate<0.55 and my_xspeed>=0 and my_limit>=60 then
			key_reset();
			key_event2(ACT_A,ACT_UP);
		elseif my_combo==1 and (dis<100 or my_correction==32) and (y-ey)<160 and (ey-y)<40 and my_xspeed>=4 and my_frontside>600 then
			key_reset();
			key_event2(ACT_B,ACT_DOWN);
		elseif (y-ey)<100 and (ey-y)<100 and my_rate>=0.55 then
			key_reset();
			key_event2(ACT_A,front);
		elseif (dis<100 or (dis<150 and my_xspeed>=4) or (dis<200 and my_xspeed>=8)) and (y-ey)<-20 and (ey-y)<250 and my_xspeed>=0 then
			key_reset();
			key_event2(ACT_A,ACT_UP);
		elseif (y-ey)<200 and (ey-y)<-40 and my_xspeed>=3 and my_yspeed>5 and my_rei>=300 and my_rate>=0.80 then
			key_reset();
			key_event2(ACT_B,ACT_DOWN);			
		end
--JA地上ヒット時の繋ぎ。前慣性が利いてて密着なら着地AかJ2B、そうでなければ2AかDAに繋ぐ
	elseif dis<=400 and (my_act<=10 or my_act==306 or my_act==308) and y<=240 and enemy_act>=50 and enemy_act<=64 then
		if ((dis<(120+my_xspeed) and enemy_act==51) or (dis<(170+my_xspeed) and enemy_act==52)) and my_hitstop>0 and my_hitstop<8 and my_xspeed>=0 and my_air<=1 and y>(20-my_yspeed*5) then
			key_reset();
			key_on(ACT_DOWN)
			yield()
			key_event(ACT_B);
		elseif dis<=400 and dis>280 and (y-my_yspeed*2)<=0 and my_hitstop==0 then
			key_reset();
			key_on(ACT_D);
			key_on(front);
		elseif dis<=280 and dis>180 and (y-my_yspeed*2)<=0 and my_hitstop==0 then
			key_reset();
			key_on(ACT_D);
			key_on(front);
			key_event(ACT_A);
		elseif dis<=180 and dis>80 and (y-my_yspeed*2)<=0 and my_hitstop==0 then
			key_reset();
			key_event2(ACT_A,ACT_DOWN);
		elseif dis<=75 and (enemy_act==51 or enemy_act==63) and my_xspeed>=0 and y<=20 and my_hitstop==0 then
			key_reset();
			key_event(ACT_A);
		end
--J6AJ5C。ある程度壁が近いか、カウンターヒットした時だけ繋げる。端付近かつLimit低めなら軽くディレイ掛けて高度確保+接近。
	elseif my_act==307 and enemy_act>=70 and enemy_act<=80 and my_rei>=200 and ((my_hitstop>0 and my_hitstop<8) or my_frame>=15) then
		if ((x<200 and my_dir==1) or (x>1080 and my_dir==-1)) and y>100 and my_combo<=3 and my_limit<=40 and my_frame<28 then
			key_reset();
			wait(11);
			key_event(ACT_C);
		elseif ((x>480 and my_dir==1) or (x<800 and my_dir==-1)) and my_frame<28 then
			key_reset();
			key_event(ACT_C);
		elseif my_combo==1 and (my_dam>850 or (my_dam>800 and enemy_hp<5000)) then
			key_reset();
			key_event(ACT_C);
		end
--J8Aからの繋ぎ。通常ヒット時はJ5Bに、カウンターヒット時は壁までの距離に応じてディレイJ5Cと溜めJ5Cを使い分ける
--画面端でCHした時は繋がる技が無いので、JBを空撃ちしてキャンセル飛翔で追い掛ける
	elseif my_act==309 and enemy_act>=70 and enemy_act<=80 and my_rei>=200 and y<550 and ((my_hitstop>0 and my_hitstop<8) or my_frame>=9) then
		if my_combo==1 and (my_dam>850 or (my_dam>800 and enemy_hp<5000)) and ((x<650 and my_dir==1) or (x>630 and my_dir==-1)) then
			key_reset();
			wait(21);
			key_event(ACT_C);
		elseif my_combo==1 and my_correction==33 and ((x>=1040 and my_dir==1) or (x<=240 and my_dir==-1)) and my_rei>=400 then
			key_reset();
			key_event(ACT_B)
			wait(6);
			key_on(ACT_UP)
			key_on(ACT_D)
			wait(15)
			if dis<80 then
				key_on(back)
			else
				key_on(front)
			end
			wait(20);
			key_reset();
			wait(5)
			key_event(ACT_A)
		elseif my_combo==1 and my_correction==33 and ((x>=740 and my_dir==1) or (x<=540 and my_dir==-1)) then
			key_reset();
			key_on(ACT_C)
			wait(35)
		elseif (y-ey)<110 and (ey-y)<20 then
			key_reset();
			key_event(ACT_B);
			wait(21);
		elseif (y-ey)<-40 and (ey-y)<80 then
			key_reset();
			wait(6);
			key_event(ACT_B);
			wait(15);
		elseif (y-ey)<-80 and (ey-y)<250 and ((x<1090 and my_dir==1) or (x>190 and my_dir==-1)) then
			key_reset();
			wait(9);
			key_event(ACT_B);
			wait(15);
		end
--遠Aからの繋ぎ。2Bか6Aへ
	elseif my_act==301 and enemy_act>=50 and enemy_act<=80 and my_frame>=11 and my_hitstop>0 and my_hitstop<9 then
		if my_rei>=400 and dis<160 and ((x<840 and my_dir==1) or (x>440 and my_dir==-1)) then
			key_reset();
			key_on(ACT_DOWN)
			yield();
			key_event(ACT_B);
		elseif dis<=190 and ((x>=840 and my_dir==1) or (x<=440 and my_dir==-1) or (dis>120 and (enemy_char==12 or enemy_char==14)) or dis>145 or my_frame>=13) then
			key_reset();
			yield();
			key_event2(ACT_A,front);
		elseif enemy_act>=70 then
			key_reset();
			yield();
			key_event2(ACT_A,front);
		else
			key_reset();
			key_on(ACT_DOWN)
			yield();
			key_event(ACT_B);
		end
--2A2Bか2A6A。鬼縛陣セット中か中央なら2B。それ以外では6Aに繋ぐ。遠過ぎる場合は2A全段当て。
--画面端かつ密着で2Aが当たったらBに繋げて画面端コンボに。失敗すると勿体無いので使用条件は厳しく設定
	elseif my_act==303 and enemy_act>=50 and enemy_act<=64 and my_frame>6 then
		if dis<85 and ((ex>1235 and my_dir==1) or (ex<45 and my_dir==-1)) and my_limit<45 and my_rei>=600 and enemy_char~=12 and
		((enemy_act==57 and enemy_char~=2 and enemy_char~=3 and enemy_char~=7 and enemy_char~=14) or
		(enemy_act==63 and enemy_char~=0 and enemy_char~=4 and enemy_char~=5 and enemy_char~=8)) then
			if dis<60 then
				wait(3);
				ex_combo = 1;
				key_reset();
				yield();
				key_event(ACT_B);
			else
				ex_combo = 1;
				key_reset();
				yield();
				key_event(ACT_B);
			end
		elseif my_rei>=400 and dis<160 and my_frontside>400 then
			if (my_preact[1]==306 or my_preact[1]==308) then
				key_reset();
				key_on(ACT_DOWN)
				yield();
				key_event(ACT_B);
			elseif dis<150 and (dis>120 or my_frame>=13) then
				key_reset();
				key_on(ACT_DOWN)
				key_on(ACT_D)
				yield();
				key_off(ACT_D);
				key_event(ACT_B);
			end
		elseif is_card_use and my_rei>=200 and dis<160 and my_card==206 then
			if (my_preact[1]==306 or my_preact[1]==308) then
				key_reset();
				key_on(ACT_DOWN)
				yield();
				key_event(ACT_B);
			elseif dis<150 and (dis>120 or my_frame>=13) then
				key_reset();
				key_on(ACT_DOWN)
				key_on(ACT_D)
				yield();
				key_off(ACT_D);
				key_event(ACT_B);
			end
		elseif dis<=220 and ((my_frontside>120 and my_frontside<=400) or (dis>120 and (enemy_char==12 or enemy_char==14)) or dis>145 or my_frame>=13) then
			key_reset();
			yield();
			key_event2(ACT_A,front);
		elseif my_frame>=14 and enemy_frame<=1 and is_card_use and my_card==209 and dis<280 then
			key_reset();
			key_on(ACT_BC);
			yield();
			key_reset();
		end
--AAA(Aヒット時にAA)
	elseif my_act==300 and enemy_act>=50 and enemy_act<=64 then
		key_reset();
		key_event(ACT_A);
	elseif my_act==320 and enemy_act>=50 and enemy_act<=64 then
		key_reset();
		yield();
		key_event(ACT_A);
--4A。適当に刻んだ後、コンボにはならないが確率で2Bや6Aに連携。たまに不意打ちでクラッシュも狙ってみる
	elseif my_act==330 and enemy_act>=50 and enemy_act<=64 and my_hitstop>0 and my_hitstop<8 then
		if dis<100 and my_combo==1 then
			key_reset();
			key_event2(ACT_A,back)
		elseif my_rei>600 and math.random(4)==1 then
			key_reset();
			key_event2(ACT_B,ACT_DOWN)
		elseif math.random(3)==1 then
			key_reset()
			key_event2(ACT_A,front)
		elseif enemy_rei>=600 and muteki_sp==0 and math.random(20)==1 then
			if math.random(2)==1 then
				key_reset();
				yield();
				key_on(ACT_A);
				key_on(front);
				wait(25);
				key_reset();
			else
				key_reset();
				yield();
				key_on(ACT_A);
				key_on(front);
				key_on(ACT_DOWN)
				wait(25);
				key_reset();
			end
		else
			key_reset();
			wait(15)
		end
--AAABかAAA2BかAAAA。鬼縛陣が有ればAAA2B鬼縛陣。無ければ端までの距離と霊力で決める。空中ヒット時はAAA6B
--AAABはキャラ限定や端限定などの制限事項が多いので使用条件をかなり厳しく
	elseif my_act==321 and enemy_act>=50 and enemy_act<=80 and ((my_hitstop>0 and my_hitstop<8) or my_frame>9) then
		if dis<85 and ((ex>1235 and my_dir==1) or (ex<45 and my_dir==-1)) and my_limit<45 and my_rei>=600 and enemy_act<=64 and enemy_char~=12 and
		((enemy_act==57 and enemy_char~=2 and enemy_char~=3 and enemy_char~=7 and enemy_char~=14) or
		(enemy_act==63 and enemy_char~=0 and enemy_char~=4 and enemy_char~=5 and enemy_char~=8)) then
			ex_combo = 1;
			key_reset();
			yield();
			key_event(ACT_B);
		elseif my_rei>=400 and ((ex>1200 and my_dir==1) or (ex<80 and my_dir==-1)) and my_limit==0 and enemy_act<=64 then
			key_reset();
			key_event(ACT_A);
		elseif is_card_use and my_rei>=200 and my_card==206 and my_limit<40 and enemy_act<=64 then
			key_reset();
			yield();
			key_event2(ACT_B,ACT_DOWN);
		elseif is_card_use and my_card==209 and ((x<=610 and my_dir==-1) or (x>=670 and my_dir==1)) and enemy_act<=64 then
			key_reset();
			key_event(ACT_A);
		elseif is_card_use and my_card==209 and my_rei>=200 and dis<100 and ((x<680 and my_dir==1) or (x>600 and my_dir==-1)) and my_limit<75 and enemy_act<=64 and enemy_char~=5 and enemy_char~=12 and enemy_char~=14 and
		((enemy_act==57 and enemy_char~=2 and enemy_char~=3 and enemy_char~=7) or
		(enemy_act==63 and enemy_char~=0 and enemy_char~=4 and enemy_char~=8)) then
			key_reset();
			yield();
			key_event(ACT_B);
		elseif my_rei>=700 and ((x<680 and my_dir==1) or (x>600 and my_dir==-1)) and my_limit<60 and enemy_act<=64 then
			key_reset();
			yield();
			key_event2(ACT_B,ACT_DOWN);
		elseif ey>=40 then
			key_reset();
			key_on(front)
			yield()
			key_event(ACT_B);
		else
			key_reset()
			key_event(ACT_A)
		end
--2Bからの繋ぎ。八方鬼縛陣をセットしていたら使い、無ければ昇天脚。霧雨もしくは鬼縛陣が引けていない時は宝玉も使用
	elseif my_act==402 and enemy_act>=50 and enemy_act<=80 then
		if is_card_use and (enemy_act<=64 or enemy_xspeed<=1) and my_card==206 and dis<200 then
			key_reset();
			key_on(ACT_BC);
			wait(1);
			key_reset();
		elseif my_card==209 and dis<270 and dis>100 and (weather==1 or my_spell>=2000) then
			key_reset();
			key_on(ACT_BC);
			wait(1);
			key_reset();
		elseif dis<230 and my_allframe>5 then
			key_reset();
			lvr623(ACT_B);
		end
--6Aからの繋ぎ。端近くなら昇天脚。ちょっと端が遠ければ5B、もう少し遠いは5C。CHしたら5Cか溜め6B。端コン中は2C
	elseif my_act==302 and enemy_act>=70 and enemy_act<=80 and my_rei>=200 and ((my_hitstop>0 and my_hitstop<8) or my_frame>=16) then
		if ((x<=160 and my_dir==-1) or (x>=1120 and my_dir==1)) and dis<100 and (my_preact[1]==322 or my_preact[2]==322) and my_rei>=400 then
			key_reset();
			key_event2(ACT_C,ACT_DOWN);
		elseif my_combo==1 and my_correction==34 and my_frontside>=120 and my_frontside<=360 then
			key_reset();
			key_on(front);
			key_on(ACT_B);
			wait(16);
			key_reset();
		elseif my_conbo==1 and my_frontside>120 and my_frontside<220 and ey>50 and my_rei>=200 then
			key_reset();
			key_on(front)
			yield()
			key_event(ACT_B);
		elseif ((x<=390 and x>130 and my_dir==-1) or (x>=890 and x<1150 and my_dir==1)) and dis>150 and dis<270 and my_limit<50 then
			key_reset();
			key_event(ACT_B);
		elseif ((x<=280 and my_dir==-1) or (x>=1000 and my_dir==1)) and dis<200 then
			if my_limit>=60 then
				key_reset();
				lvr623(ACT_C);
			else
				key_reset();
				lvr623(ACT_B);
			end
		elseif (my_combo==1 and (my_dam>750 or (my_dam>800 and enemy_hp<5000))) or ((x<=520 and my_dir==-1) or (x>=760 and my_dir==1)) then
			key_reset();
			key_event(ACT_C);
		elseif my_rei==1000 then
			if ((x<=700 and my_dir==-1) or (x>=580 and my_dir==1)) and math.random(2)==1 then
				key_reset();
				lvr214(ACT_B);
			elseif ((x<=700 and my_dir==-1) or (x>=580 and my_dir==1)) then
				key_reset();
				lvr214(ACT_C);	
			else
				key_reset();
				wait(7+math.random(6));
				lvr214(ACT_C);
			end
		end
--5Bが地上ヒットした時の繋ぎ。スペカか低空J6Aに
	elseif my_act==400 and enemy_act>=50 and enemy_act<=64 and enemy_hitstop>0 then
		if my_allframe>=26 and is_card_use and my_card==206 and dis<200 then
			key_reset();
			key_on(ACT_BC);
			yield();
			key_reset();
		elseif my_allframe>=26 and is_card_use and my_card==209 and dis<300 then
			key_reset();
			key_on(ACT_BC);
			yield();
			key_reset();
		elseif my_allframe==17 and enemy_act==51 and dis<260 then
			key_reset();
			key_on(front)
			key_on(ACT_UP)
			wait(5)
			key_off(ACT_UP)
			key_event(ACT_A)
		end
--A、AA、4Aが空中ヒットしたら3Aに。4Aは空中ガード狩りなので狙える位置なら6Bに繋ぐ
	elseif (((my_act==300 or my_act==330) and my_frame>=5) or (my_act==320 and my_frame>=4)) and my_hitstop>0 and enemy_act>=70 and enemy_act<=80 then
		if my_act==330 and ey>=35 and (my_frontside<100 or dis<=50) then
			key_reset()
			key_event2(ACT_B,front)
		else
			key_reset();
			key_on(ACT_DOWN);
			key_event2(ACT_A,front);
		end
--3A根元ヒットからの繋ぎ。画面端ならC昇天脚。手札に有れば八方鬼縛陣
	elseif my_act==304 and dis<120 and my_allframe<16 and y==0 and my_hitstop>0 and my_hitstop<8 and enemy_act==77 then
		if card_check(206) and my_spell_more(2000) and my_correction==1 then
			key_reset();
			card_use(206);
		elseif ((x<=180 and my_dir==-1) or (x>=1100 and my_dir==1)) and ey<80 then
			key_reset();
			lvr623(ACT_C);
		end
--DA通常ヒットからの繋ぎ。手札にあれば宝玉か鬼縛陣、無ければ昇天脚。しゃがみヒットには距離制限を厳しく。
	elseif my_act==305 and enemy_act>=50 and enemy_act<=80 and enemy_act~=53 and enemy_act~=65 and my_frame>8 then
		if dis>150 and (my_combo>=2 or my_correction==4) and my_hitstop>0 and card_check(209) and my_spell_more(1000) then
			key_reset();
			card_use(209);
		elseif (dis<120 or (weather==12 and dis<70)) and ((enemy_act==52 or enemy_act==64) or (ey>0 and my_frontside<140)) and (my_correction~=32 or ey>50) and my_combo<=2 and my_hitstop>0 and card_check(206) and my_spell_more(2000) then
			key_reset();
			key_on(ACT_BC);
			yield();
			key_reset();
		elseif dis<100 and my_frontside<120 and my_hitstop>0 and ey>20 and my_hitstop<9 and my_limit==0 and (my_combo==1 or (is_card_use and (my_card==201 or my_card==208 or my_card==209))) then
			key_reset();
			lvr623(ACT_C);
		elseif dis<95 and my_hitstop>0 and my_hitstop<9 and ey>0 and (my_combo>1 or my_correction~=32 or (x>1100 and my_dir==1) or (x<180 and my_dir==-1)) then
			key_reset();
			card_use(103);
		elseif dis<95 and my_hitstop>0 and my_hitstop<9 and ey>0 and (my_combo>1 or my_correction~=32 or (x>1100 and my_dir==1) or (x<180 and my_dir==-1)) then
			key_reset();
			lvr623(ACT_B);
		elseif ((dis<130 and enemy_act==52 and enemy_frame>4 and enemy_frame<7) or (dis<90 and enemy_act==64 and enemy_frame>4 and enemy_frame<8) or (dis<70 and enemy_act==52 and enemy_frame==0) or (dis<60 and enemy_act==64 and enemy_frame==0)) and is_card_use and (my_card==209 or ((my_card==201 or my_card==208) and my_frontside<120)) then
			key_reset();
			lvr623(ACT_C);
		elseif (dis<140 and enemy_act==52 and enemy_frame>4 and enemy_frame<7) or (dis<100 and enemy_act==64 and enemy_frame>4 and enemy_frame<8) or (dis<80 and enemy_act==52 and enemy_frame==0) or (dis<60 and enemy_act==64 and enemy_frame==0) then
			key_reset();
			card_use(103);
		elseif (dis<140 and enemy_act==52 and enemy_frame>4 and enemy_frame<7) or (dis<100 and enemy_act==64 and enemy_frame>4 and enemy_frame<8) or (dis<80 and enemy_act==52 and enemy_frame==0) or (dis<60 and enemy_act==64 and enemy_frame==0) then
			key_reset();
			lvr623(ACT_B);
		elseif my_combo==1 and my_frontside<100 and ey>0 and my_frame>=32 then
			key_reset()
			key_event(ACT_A)
		elseif dis<300 and card_check(104) and ((x<940 and my_dir==1) or (x>340 and my_dir==-1)) then
			key_reset();
			print("DA(ch)＞妖怪バスター");
			card_use(104);
		elseif dis<300 and get_skill_lv(0,4)>=0 and ((x<940 and my_dir==1) or (x>340 and my_dir==-1)) then
			key_reset();
			print("DA(ch)＞妖怪バスター");
			key_on(ACT_D);
			wait(2);
			key_reset();
			lvr236(ACT_B);
		end
--DAカウンターヒットからの繋ぎ。陰陽宝玉セット中で端が遠ければ繋げる。端ならAか2Aで追撃。
--妖怪バスタールート追加。
	elseif (my_act<=10 or my_act==305) and (enemy_act==53 or enemy_act==65) then
	print("DA(ch)＞");
		if dis<300 and card_check(104) and card_check(209) and my_spell_more(1500) and ((x<940 and my_dir==1) or (x>340 and my_dir==-1)) then
			key_reset();
			print("DA(ch)＞バスター＞宝玉");
			while (my_act==305 and not(my_act>=505 and my_act<=508)) do
				card_use(104);
				yield();
			end
			while (my_act>=505 and my_act<=508) do
				card_use(209);
				yield();
			end
		elseif dis<300 and get_skill_lv(0,4)>=0 and card_check(209) and my_spell_more(1000) and ((x<940 and my_dir==1) or (x>340 and my_dir==-1)) then
			key_reset();
			print("DA(ch)＞バスター＞宝玉");
			while (my_act==305 and not(my_act>=505 and my_act<=508)) do
				wait(2);
				lvr236(ACT_B);
			end
			while (my_act>=505 and my_act<=508) do
				card_use(209);
				yield();
			end
		elseif dis<300 and card_check(209) and my_spell_more(1000) and ((x<940 and my_dir==1) or (x>340 and my_dir==-1)) then
			key_reset();
			print("DA(ch)＞宝玉");
			loop_count = 0
			while (card_check(209) and my_spell_more(1000) and my_card~=209) do
				card_1st(209);
				yield();
				loop_count = loop_count + 1
			end
			wait(20-loop_count);
			card_use(209);
			yield();
			key_reset();
		elseif dis<300 and card_check(104) and ((x<940 and my_dir==1) or (x>340 and my_dir==-1)) then
			key_reset();
			print("DA(ch)＞妖怪バスター");
			card_use(104);
		elseif dis<300 and get_skill_lv(0,4)>=0 and ((x<940 and my_dir==1) or (x>340 and my_dir==-1)) then
			key_reset();
			print("DA(ch)＞妖怪バスター");
			key_on(ACT_D);
			wait(2);
			key_reset();
			lvr236(ACT_B);
		elseif dis<=260 and (dis>80 or weather==12) and my_frame>=32 then
			key_reset();
			print("DA(ch)＞２Ａ");
			key_event2(ACT_A,ACT_DOWN);
		elseif dis<=80 and my_frame>=32 then
			print("DA(ch)＞５Ａ");
			key_reset();
			key_event(ACT_A);
		end
--2Cからの繋ぎ。Limitが高い場合はコンボ後半と判断して昇天脚で締める
	elseif my_act==412 and enemy_act>=70 and enemy_act<=80 and dis<200 then
		if my_limit>=80 and my_rei>=200 and get_skill_lv(0,3)>=0 then
			key_reset();
			wait(2);
			lvr623(ACT_C);
		elseif my_limit<80 then
			key_reset();
			key_on(ACT_UP);
			wait(1);
			key_event(ACT_A)
		end
--B昇天脚がカウンターヒットした時、夢想封印が有れば繋ぐ
--C昇天脚追加。拡散結界を追加。
	elseif (my_act==560 or my_act==561) and my_correction==34 and my_combo==1 and my_hitstop>0 and card_check(201) and my_spell_more(2500) and my_frontside>300 then
		key_reset();
		wait(14)
		card_use(201);
		key_reset();
	elseif (my_act==560 or my_act==561) and my_correction==34 and my_combo==1 and my_hitstop>0 and card_check(207) and my_spell_more(1500) and my_frontside>300 then
		key_reset();
		wait(14)
		card_use(207);
		key_reset();
--C昇天脚がヒットした時、株・陰陽宝玉・夢想封印が有れば繋ぐ
	elseif my_act==561 and my_hitstop>0 and card_check(208) and dis<150 and my_limit<=40 and my_frontside<150 and (ex<90 or ex>1150) then
		key_reset();
		card_use(208);
	elseif my_act==561 and my_hitstop>0 and card_check(201) and my_spell_more(2500) and dis<150 and my_limit<=40 and my_frontside<150 and (ex<90 or ex>1150) then
		key_reset();
		card_use(201);
	elseif my_act==561 and y==0 and ey<=20 and my_hitstop>0 and card_check(209) and my_spell_more(1000) and dis<250 then
		key_reset();
		card_use(209);
--相手が浮いてたらJAやJ6Aで拾いを試みる(地上)
	elseif (my_act==400 or my_act==401 or my_act==402 or my_act==410 or my_act==500) and enemy_act>=70 and enemy_act<=80 and dis<=550 then
		if dis<330 and (ey>=100 or (my_act==400 and my_allframe>=28) or (my_act==401 and my_allframe>=28)) then
			key_reset();
			key_on(ACT_UP);
			key_on(front);
			yield()
		elseif my_act~=400 and my_act~=401 and dis<330 and ey<100 then
			key_reset();
			key_on(ACT_D);
			key_on(ACT_UP);
			key_on(front);
			wait(5);
			key_reset();
			key_event2(ACT_A,front);
		elseif my_act~=400 and my_act~=401 then
			key_reset();
			key_on(ACT_D);
			key_on(ACT_UP);
			key_on(front);
			yield();
		end
--相手が浮いてたらJAやJ8Aで拾いを試みる(空中・画面端)
	elseif (my_act==9 or (my_allframe>=21 and (my_act==414 or my_act==502))) and enemy_act>=70 and enemy_act<=80 and dis<95 and (x<150 or x>1130) and y>0 and my_air<=1 and weather~=12 then
		if ((y-ey)<30 and (ey-y)<250 and my_rate<0.64) or ((y-ey)<-80 and (ey-y)<250) then
			key_reset();
			key_event(back)
			key_on(back);
			yield();
			key_reset();
			key_on(ACT_UP)
			yield();
			key_event(ACT_A);
		else
			print("４４");
			key_reset();
			key_event(back);
			key_on(back);
			yield();
		end
--相手が浮いてたらとりあえず前ダッシュして拾いに行ってみる(空中)
	elseif (my_act==9 or (my_allframe>=22 and (my_act==414 or my_act==502))) and my_act~=202 and my_preact[1]~=202 and enemy_act>=70 and enemy_act<=80 and my_air<=1 and dis<500 then
		if (y-ey)<300 and (ey-y)<-150 then
			key_reset();
			key_on(ACT_DOWN);
			key_on(ACT_D)
			key_on(front);
			yield();
		else
			key_reset();
			key_event(front);
			key_event(front);
		end
--空中射撃がヒットしたら空中ダッシュか飛翔で追撃に向かう
	elseif ((my_act==404 and my_allframe>=22) or (my_act==406 and my_allframe>=21) or (my_act==414 and my_allframe>=22) or my_act==416 or ((my_act==404 or my_act==406) and (y-my_yspeed*4)<0)) and y>0 and enemy_act>=50 and enemy_act<=80 and my_rei>=100 and my_air<=1 then
		if dis<200 and ((x<100 and my_dir==-1) or (x>1180 and my_dir==1)) and (y-ey)<90 and (ey-y)<100 and enemy_act>=70 then
			print("４４");
			key_reset();
			key_event(back);
			key_on(back);
			yield();
		elseif (y<200 and ey==0 and (dis>300 or (ex<60 or ex>1220))) or (y<120 and ey==0) then
			key_reset();
			key_on(ACT_D);
			key_on(front);
			yield();
		elseif (y-ey)<100 and (ey-y)<150 and y>40 then
			key_reset();
			key_event(front);
			key_event(front);
		elseif (y-ey)<140 and (ey-y)<50 and ey>20 then
			key_reset();
			key_on(ACT_D);
			key_on(front);
			yield();
		elseif (y-ey)<-150 and (ey-y)<260 and dis<300 then
			key_reset();
			key_on(ACT_D);
			key_on(front);
			key_on(ACT_UP)
			yield();
		elseif (((y-ey)<400 and (ey-y)<-100) or (y<400 and ey==0)) and dis<400 then
			key_reset();
			key_on(ACT_D);
			key_on(front);
			key_on(ACT_DOWN)
			yield();
		else
			key_reset();
			key_event(front);
			key_event(front);
		end
--壁バウンドの拾い各種。基本的にJAで拾い、端密着くらいの時のみDAか6Aを使う。真上にバウンドしてきた時は時々拾い損ねる。
--ある程度壁から離れていて、手札に陰陽宝玉があれば繋ぐ。そこから更に拾えそうならDA、DC、昇天脚で追撃するかもしれない
	elseif dis<=400 and ((my_act<=5 and my_preact[1]==322 and my_frame<=1) or (my_act==322 and my_frame>=44)) and (enemy_act==76 or enemy_act==78) and ((x<=530 and x>190 and my_dir==-1) or (x>=750 and x<1090 and my_dir==1)) and my_rate>0.63 and card_check(209) and my_spell_more(1000) then
		key_reset();
		card_use(209);
	elseif dis<=350 and ((my_act<=5 and my_preact[1]==609) or (my_act==609 and my_allframe>110)) and (enemy_act==76 or enemy_act==78) and ((x<=390 and x>120 and my_dir==-1) or (x>=890 and x<1120 and my_dir==1)) then
		if dis<280 and my_rate>0.54 and ey>50 and my_act==609 and card_check(103) then
			key_reset();
			card_use(103);
		elseif dis<280 and my_rate>0.54 and ey>50 and my_act==609 and get_skill_lv(0,3)>=0 then
			key_reset();
			lvr623(ACT_B);
		elseif (my_act<=5 or (my_act==609 and my_allframe>=115)) then
			key_reset();
			key_on(ACT_D);
			key_on(front);
			yield();
			key_event2(ACT_A,front)
			key_reset();
		end
	elseif dis<=250 and ey>50 and ((my_act<=5 and my_preact[1]==322) or (my_act==322 and my_frame>40)) and (enemy_act==76 or enemy_act==78) and ((x<=390 and x>120 and my_dir==-1) or (x>=890 and x<1120 and my_dir==1)) and (my_limit>=60 or my_rate<0.60) and card_check(103) then
		key_reset();
		card_use(103);
	elseif dis<=250 and ey>50 and ((my_act<=5 and my_preact[1]==322) or (my_act==322 and my_frame>40)) and (enemy_act==76 or enemy_act==78) and ((x<=390 and x>120 and my_dir==-1) or (x>=890 and x<1120 and my_dir==1)) and (my_limit>=60 or my_rate<0.60) and get_skill_lv(0,3)>=0 then
		key_reset();
		lvr623(ACT_B);
	elseif dis<=400 and dis>250 and (my_act<=5 or my_act==200 or (my_act==322 and my_frame>=44)) and (enemy_act==76 or enemy_act==78) and ((x<=440 and my_dir==-1) or (x>=840 and my_dir==1)) then
		if my_rate<0.60 or my_preact[1]==322 or my_preact[2]==322 then
			key_reset();
			key_on(ACT_D);
			key_on(front);
			yield();
			key_event2(ACT_C,front)
			key_reset();
		else
			key_reset();
			key_on(ACT_D);
			key_event2(ACT_UP,front);
			wait(3);
			key_event(ACT_A);
			key_reset();
		end
	elseif dis<=250 and dis>100 and (my_act<=5 or (my_act==322 and my_frame>=44)) and (enemy_act==76 or enemy_act==78) and ((x<=440 and my_dir==-1) or (x>=840 and my_dir==1)) then
		key_reset();
		key_event2(ACT_UP,front);
		wait(1);
		key_event(ACT_A);
		key_reset();
	elseif dis<=250 and (my_act<=5 or (my_act==322 and my_frame>=44)) and (enemy_act==76 or enemy_act==78) and ((x>=1040 and my_dir==-1) or (x<=240 and my_dir==1)) then
		key_reset();
		key_on(front);
		key_event(ACT_UP);
		wait(1);
		key_reset();
		key_event(ACT_A);
		key_reset();
	elseif dis<=50 and (my_act<=5 or my_act==200 or (my_act==322 and my_frame>=43)) and (enemy_act==76 or enemy_act==78) and ((x<=120 and my_dir==-1) or (x>=1160 and my_dir==1)) and ey<110 then
		if enemy_char~=2 and enemy_char~=5 and enemy_char~=13 and my_combo<=4 and my_rei>180 and weather~=10 and weather~=12 then
			key_reset();
			wait(11)
			command("A(10)A(10)A(9)");
				if my_hitstop>0 then
					key_on(front)
					yield();
					key_event(ACT_B)
				end
		elseif my_limit<=55 then
			key_reset();
			key_event2(ACT_A,front);
			key_reset();
		else
			key_reset();
			key_on(ACT_D);
			key_on(front);
			yield();
			key_event2(ACT_A,front)
			key_reset();
		end		
	elseif dis<=100 and (my_act<=5 or (my_act==322 and my_frame>=44)) and (enemy_act==76 or enemy_act==78) and ((x<=240 and my_dir==-1) or (x>=990 and my_dir==1)) and ey>=110 then
		if my_rate<0.60 then
			key_reset();
			key_on(ACT_D);
			key_on(front);
			yield();
			key_event2(ACT_A,front)
			key_reset();
		else
			key_reset();
			key_on(back);
			key_event(ACT_UP);
			wait(1);
			key_reset();
			key_event(ACT_A);
			key_reset();
		end
--亜空穴BがカウンターヒットしたらJ2Bで拾う。
	elseif dis<=300 and enemy_act==89 and my_act<=10 then
		if dis<80 and (ex<60 or ex>1180) then
			key_reset();
			key_event(ACT_UP);
			wait(1);
			key_event2(ACT_B,ACT_DOWN);
			wait(18)
			key_event(back)
			key_event(back)
		else
			print("combo：近距離で行動可能時に相手がのけぞっていたら、Ａで追撃");
			key_reset();
			key_event(ACT_UP);
			wait(1);
			key_event2(ACT_B,ACT_DOWN);
			wait(18)
			key_event(front)
			key_event(front)
		end
--近距離で行動可能時に相手がのけぞっていたら適当な技で追撃
	elseif dis<=300 and enemy_act>=50 and enemy_act<=64 and y==0 and (my_act<=5 or my_act==200 or my_act==204) then
		if dis<=300 and dis>240 then
			print("combo：近距離で行動可能時に相手がのけぞっていたら、６Ｄ");
			key_reset();
			key_on(ACT_D);
			key_on(front);
		elseif dis<=220 and dis>160 then
			print("combo：近距離で行動可能時に相手がのけぞっていたら、ＤＡで追撃");
			key_reset();
			key_on(ACT_D);
			key_on(front);
			key_event(ACT_A);
		elseif dis<=160 and dis>70 then
			print("combo：近距離で行動可能時に相手がのけぞっていたら、２Ａで追撃");
			key_reset();
			key_event2(ACT_A,ACT_DOWN);
		elseif dis<=70 then
			print("combo：近距離で行動可能時に相手がのけぞっていたら、Ａで追撃");
			key_reset();
			yield();
			key_event(ACT_A);
		end
--近距離〜中距離で相手が浮いていたら追い掛ける
	elseif dis<=500 and enemy_act>=50 and enemy_act<=80 and y==0 and (my_act<=5 or my_act==200) then
		if enemy_act<=64 or dis>280 then
			print("combo：近距離〜中距離で相手が浮いていたら、６Ｄで追い掛ける");
			key_reset();
			key_on(ACT_D);
			key_on(front);
		elseif dis<=280 and ey>=20 and enemy_frame<=10 then
			print("combo：近距離〜中距離で相手が浮いていたら、９Ｄで追い掛ける");
			key_reset();
			key_on(ACT_D);
			key_on(front);
			key_on(ACT_UP);
		end
		
--▼組み込み▼
	elseif my_act==565 and ((enemy_act>=50 and enemy_act<=89) or (enemy_act>=143 and enemy_act<=145))and my_hitstop<=3 and my_hitstop>=1 then
		while my_act==565 do
			key_event(ACT_B);
		end
	elseif my_act==566 and ((enemy_act>=50 and enemy_act<=89) or (enemy_act>=143 and enemy_act<=145)) and my_hitstop<=3 and my_hitstop>=1 then
		while my_act==566 do
			key_event(ACT_C);
		end
--▲組み込み▲
		
--どの条件にも合わなければ次フレームへ
	else
		--print("combo：次のフレームへ");
		key_reset();
		yield();
		kihon();
	end
end

--グレイズ。射程圏内ならDCやら近AやらJAを刺そうとする。そのせいでよく自滅する。
function graze()
	if y==0 then
		if my_act==10 and weather~=13 then
			print("グレイズ行動・チェック１");
			key_off(ACT_D)
			key_on(back);
			wait(6)
		end
		if ((dis-caution_range)<0 or ((dis-caution_range)<50 and my_act==5)) and ey<=200 and (enemy_act<=9 or enemy_act==200 or enemy_act==204 or enemy_act==214 or (enemy_act>=208 and enemy_act<=212 and enemy_yspeed<=-1)) and weather~=5 and weather~=13 then
			print("グレイズ行動・チェック２");
			key_off(ACT_D)
			key_on(back);
		elseif is_dir_front and (my_act<=5 or my_act==200) and dis<180 and ey<=20 and enemy_allframe<6 and enemy_act>=400 and enemy_act<600 and caution_gatk==0 and enemy_obj_range_in(150,60)==false and RND<400 then
			key_on(ACT_D);
			key_on(front);
			key_event(ACT_C);
			key_reset();
		elseif is_dir_front and my_act==200 and dis<130 and dis>28 and ey<=220 and (ey+enemy_yspeed*13)>0 and (ey+enemy_yspeed*13)<150 and enemy_act>=300 and enemy_act<600 and weather~=5 and caution_gatk==0 and (enemy_allframe<10 or enemy_obj_range_in(150,60)==false) and weather~=13 and enemy_act>=400 and RND<700 then
			key_on(ACT_D);
			key_on(front);
			key_event(ACT_C);
			key_reset();
		elseif is_dir_front and my_act==200 and dis<130 and dis>28 and ey<=220 and (ey+enemy_yspeed*13)>0 and (ey+enemy_yspeed*13)<150 and enemy_act>=300 and enemy_act<600 and weather~=5 and caution_gatk==0 and (enemy_allframe<10 or enemy_obj_range_in(150,60)==false) and weather~=13 and enemy_act>=300 and enemy_act<400 and RND<250 then
			key_on(ACT_D);
			key_on(front);
			key_event(ACT_C);
			key_reset();
		elseif is_dir_front and my_act==200 and dis<(160+enemy_xspeed*10) and dis>28 and (ey+enemy_yspeed*13)>0 and (ey+enemy_yspeed*13)<150 and enemy_act>=200 and enemy_act<=215 and enemy_act~=201 and enemy_allframe<=1 and weather~=5 and caution_gatk==0 and enemy_obj_range_in(150,60)==false and RND<700 then
			key_on(ACT_D);
			key_on(front);
			key_event(ACT_C);
			key_reset();
		elseif is_dir_front and dis<80 and ey<=50 and (enemy_char==3 or caution_obj==0 or (caution_obj>0 and enemy_obj_range_in(150,60)==false)) and weather~=5 and (enemy_act<600 or (enemy_act>600 and enemy_allframe>70)) and caution_gatk==0 then
			if my_act~=300 and my_act~=301 and ((muteki>=1 and (enemy_act<=5 or (enemy_act>=400 and enemy_act<500))) or (muteki_sp==2 and enemy_act<600)) and math.random(2)==1 then
			print("グレイズ行動・チェック３");
				key_off(ACT_D)
				key_on(back);
				caution_graze = 10 + math.random(30);
				caution_atk = caution_graze;
 			elseif enemy_obj_range_in(150,60)==false and my_act==200 and enemy_act<600 and enemy_act>=400 then
				if enemy_obj_range_in(150,60)==false and math.random(5)<=2 then
					key_on(front)
					key_on(ACT_D)
					yield()
					key_event(ACT_C)
				else
					key_on(ACT_D);
					key_on(front);
					if caution_gatk==0 and math.random(2)==1 then
						caution_gatk = 3 + math.random(10)
					end
				end
			elseif enemy_obj_range_in(150,60)==false and search_JFP()==false and get_special_data(0,10)<=5 then
				key_reset();
				key_event(ACT_A);
			end
		elseif is_dir_front and enemy_allframe<=4 and enemy_act>=200 and enemy_act<=214 and dis<60 and ey<=50 and enemy_obj_range_in(150,60)==false and weather~=5 and caution_gatk==0 and search_JFP()==false and get_special_data(0,10)<=5 then
			key_reset();
			key_event(ACT_A);
		elseif dis<500 and ey>=150 and ey<350 and my_act==200 and enemy_obj_range_in(150,60)==false and enemy_act>=400 and enemy_act<600 and enemy_allframe<=20 and weather~=5 then
			if is_dir_front and dis<200 and dis>60 and math.random(8)==1 and caution_gatk==0 then
				key_reset();
				lvr623(ACT_C);
			elseif math.random(2)==1 then
				key_on(ACT_D);
				key_event2(ACT_UP,front);
				key_reset();
			else
				key_on(ACT_D);
				key_event2(ACT_UP,back);
				key_reset();
			end
		elseif (my_act==400 or my_act==401 or my_act==402 or my_act==410 or my_act==412 or my_act==500) then
			if dis<200 then
				if math.random(4)==1 then
					key_event(ACT_UP);
					key_reset();
				else
					key_event2(ACT_UP,back);
					key_reset();
				end
			elseif enemy_obj_range_in(150,60)==false then
				key_event2(ACT_UP,front);
				key_reset();
			end
		elseif dis<400 and my_frontside>=1100 and (my_act<=5 or ((my_act==150 or my_act==154) and my_frame==8) or ((my_act==151 or my_act==155) and my_frame==14) or ((my_act==152 or my_act==156) and my_frame==20) or ((my_act==153 or my_act==157) and my_frame==26)) and math.random(4)==1 then
			key_on(ACT_D)
			key_on(ACT_UP)
			wait(5);
			key_reset();
			wait(10);
			if my_act==208 then
				key_event(front)
				key_event(front)
			end
			caution_atk = 10 + math.random(30);
		elseif dis<300 and my_frontside>=1000 and (my_act<=5 or ((my_act==150 or my_act==154) and my_frame==8) or ((my_act==151 or my_act==155) and my_frame==14) or ((my_act==152 or my_act==156) and my_frame==20) or ((my_act==153 or my_act==157) and my_frame==26)) and math.random(3)==1 then
			key_on(ACT_D)
			key_on(ACT_UP)
			key_on(front)
			wait(5);
			key_reset();
			wait(10);
			caution_atk = 20 + math.random(20);
		elseif my_dir==-1 then
			if my_act~=204 or (my_act==204 and is_dir_front) then
				key_on(ACT_D);
				key_on(ACT_LEFT);
			else
			print("グレイズ行動・チェック４");
				key_reset();
				key_on(back);
			end
		elseif my_dir==1 then
			if my_act~=204 or (my_act==204 and is_dir_front) then
				key_on(ACT_D);
				key_on(ACT_RIGHT);
			else
			print("グレイズ行動・チェック５");
				key_reset();
				key_on(back);
			end
		end
	elseif y>=0 then
		if is_dir_front and dis>=350 and enemy_obj_range_in(150,60)==false or ((y-ey)<50 and (ey-y)<50)) and y>100 and (my_act~=202 or (my_act==202 and my_allframe>=18)) and my_act~=202 and my_act~=214 and my_preact[1]~=214 and my_rei>400 and x>140 and x<1140 and my_air<=1 then
			key_on(front);
			key_on(ACT_D);
		elseif is_dir_front and enemy_obj_range_in(150,60)==false and y>100 and my_act==202 and my_allframe>=18 and my_air<=1 then
			if math.random(2)==1 then
				key_on(front)
				key_on(ACT_D);
				key_on(ACT_DOWN)
			else
				key_on(ACT_D);
				key_on(ACT_DOWN)
			end
		elseif is_dir_front and dis<=150 and y>150 and ey==0 and enemy_obj_range_in(150,60)==false and weather~=5 and my_act~=202 and my_air<=1 then
			if weather~=13 and (x<140 or x>1140) and my_act~=214 then
				key_on(ACT_D);
				key_on(ACT_DOWN)
				key_on(back)
			elseif my_rei>=400 then
				key_on(ACT_D);
				key_on(front)
			else
			print("グレイズ行動・チェック６");
				key_on(back);
				key_off(ACT_D)
			end		
		elseif is_dir_front and dis<=180 and (y>20 or my_yspeed>=0) and ey>50 and (my_act==211 or my_act==212) and enemy_obj_range_in(150,60)==false and (enemy_char==3 or caution_obj==0 or (caution_obj>0 and enemy_obj_range_in(150,60)==false)) and my_allframe<=18 and caution_gatk==0 and weather~=5 and RND<500 and search_JFP()==false and get_special_data(0,10)<=5 then
			if caution_gatk==0 and (y-ey)<100 and (ey-y)<80 and dis>40 then
				key_reset();
				key_event(ACT_A);
			elseif caution_gatk==0 and dis<100 and (dis>20 or ex<=45 or ex>=1235) and (y-ey)<-80 and (ey-y)<240 then
				key_reset();
				key_on(ACT_UP);
				wait(1);
				key_event(ACT_A);
			end
		elseif is_dir_front and dis<=180 and dis>20 and (y>20 or my_yspeed>=0) and ey>50 and (y-ey)<100 and (ey-y)<70 and enemy_obj_range_in(150,60)==false and (enemy_char==3 or caution_obj==0 or (caution_obj>0 and enemy_obj_range_in(150,60)==false)) and my_act~=306 and my_act~=307 and my_act~=309 and caution_gatk==0 and weather~=5 and RND<600 and caution_gatk==0 and search_JFP()==false and get_special_data(0,10)<=5 then
			key_reset();
			key_event(ACT_A);
		elseif is_dir_front and dis<=180 and dis>20 and y>20 and y<140 and ey==0 and (enemy_act<600 or (enemy_act>600 and enemy_allframe>70)) and enemy_obj_range_in(150,60)==false and (enemy_char==3 or caution_obj==0 or (caution_obj>0 and enemy_obj_range_in(150,60)==false)) and my_act~=306 and my_act~=307 and my_act~=309 and caution_gatk==0 and weather~=5 and RND<600 and caution_gatk==0 and search_JFP()==false and get_special_data(0,10)<=5 then
			key_reset();
			key_event(ACT_A);
		elseif my_yspeed<=-1 and (y+my_yspeed)<0 then
			if enemy_obj_range_in(150,60)==false and (dis-caution_range)<0 then
				key_on(front)
				key_on(ACT_D)
			else
			print("グレイズ行動・チェック７");
				key_off(ACT_D);
				key_on(back);
				wait(2);
			end
		elseif dis>300 and y>100 and y<500 and my_act~=202 and my_act~=209 and my_act~=211 and my_act~=212 and my_act~=214 and my_preact[1]~=214 and my_air<=1 then
			key_on(ACT_D);
			key_on(front)
			key_on(ACT_DOWN);
		elseif dis>300 and enemy_obj_range_in(150,60)==false and ((my_act==209 or my_act==211 or my_act==212) and my_allframe>=28) and y<450 and my_air<=1 then
			key_on(ACT_D);
			key_on(front)
			key_on(ACT_DOWN);
		elseif dis<100 and caution_gatk==1 and ey>20 and (enemy_act==9 or (enemy_act>=200 and enemy_act<=214)) then
			print("グレイズ行動・チェック８");
			key_on(back);
		elseif dis<=500 and (my_act==158 or my_preact[1]==158) and my_act~=202 and my_act~=209 and my_air<=1 then
			if dis>100 and (y-ey)<-100 and (ey-y)<250 and math.random(3)==1 then
				key_on(ACT_D);
				key_on(front);
				key_on(ACT_DOWN);
			elseif (y-ey)<100 and (ey-y)<50 and ex>140 and ex<1140 and math.random(2)==1 then
				key_on(ACT_D);
				key_on(front);
			elseif x>340 and x<940 and math.random(3)==1 then
				key_on(ACT_D);
				key_on(back);
				key_on(ACT_DOWN);
			else
				key_on(ACT_D);
				key_on(ACT_DOWN);
			end
		elseif dis<=300 and enemy_obj_range_in(150,60)==false and y>100 and y<450 and my_act~=202 and my_act~=209 and my_act~=211 and my_act~=212 and my_act~=214 and my_preact[1]~=214 and my_air<=1 then
			if dis>100 and ey==0 and math.random(3)==1 then
				key_on(ACT_D);
				key_on(front);
				key_on(ACT_DOWN);
			else
				key_on(ACT_D);
				key_on(ACT_DOWN);
			end
		elseif dis<=300 and enemy_obj_range_in(150,60)==false and ((my_act==209 or my_act==211 or my_act==212 or my_act==214) and my_allframe>=28) and y>150 and y<450 and my_air<=1 then
			if dis>100 and ey==0 and math.random(3)==1 then
				key_on(ACT_D);
				key_on(front);
				key_on(ACT_DOWN);
			else
				key_on(ACT_D);
				key_on(ACT_DOWN);
			end
		elseif enemy_obj_range_in(150,60)==false or dis<250 or my_air==2 or (enemy_act>=600 and enemy_allframe>40) then
			print("グレイズ行動・チェック９");
			key_on(back);
		end
	end
end

function guard_check()

while true do
--1F毎にguard_rateを変動させ、guard_rankを上回ったら正ガードに移行
	if enemy_allframe==0 then
		guard_rate = 0;
	end
	if enemy_act>=300 and guard_rank>guard_rate then
		guard_rate = guard_rate + math.random(9) - 4
		if (base_chain==3 and enemy_act==321) or (base_chain==4 and enemy_act==322) or (base_chain==5 and enemy_act==323) then
			guard_rate = guard_rate + 1
		elseif (base_chain==3 and enemy_act==320) or (base_chain==4 and enemy_act==321) or (base_chain==5 and enemy_act==322) then
			guard_rate = guard_rate + math.random(2) - 1
		end
	end
--基本ガード方向の設定。600F毎にランダム変更
--誤ガード時は一定確率で逆のガード方向に切り替える。一度変更したら60〜120Fの変更不能時間が付く。
	guard_time = guard_time + 1
	if guard_time>=600 then
		base_guard = math.random(2) - 1
		guard_time = 0
	end
	if guard_time>=120 and my_act>=159 and my_act<=170 and math.random(50)==1 then
		if base_guard==0 then
			base_guard = 1;
		elseif base_guard==1 then
			base_guard = 0;
		end
		guard_time = math.random(60)
	end
	yield();
end
end

--立ちガード。見切れてない時はランダム
function s_guard()
	if mekuri>0 then
		yield();
	elseif my_act>5 and (my_act<150 or my_act>300) then
		key_on(back)
		key_on(ACT_DOWN)		
	elseif (y+my_yspeed*2)>0 then
		key_on(back)
		key_on(ACT_DOWN)	
	elseif (guard_rate>=guard_rank) or ey>=50 or (enemy_act>=306 and enemy_act<=310) then
		key_off(ACT_DOWN)
		key_on(back)
	elseif base_guard==0 then
		key_off(ACT_DOWN)
		key_on(back)
	elseif base_guard==1 then
		key_on(back)
		key_on(ACT_DOWN)
	end
end

--しゃがみガード。見切れてない時はランダム
function c_guard()
	if mekuri>0 then
		yield();
	elseif my_act>5 and (my_act<150 or my_act>300) then
		key_on(back)
		key_on(ACT_DOWN)	
	elseif (y+my_yspeed*2)>0 then
		key_on(back)
		key_on(ACT_DOWN)	
	elseif guard_rate>=guard_rank then
		key_on(back)
		key_on(ACT_DOWN)
	elseif base_guard==0 then
		key_off(ACT_DOWN)
		key_on(back)
	elseif base_guard==1 then
		key_on(back)
		key_on(ACT_DOWN)
	end
end

















































































function filter_act()

--▼割り込み行動▼
--汎用下段超反応
	if 	y==0 and 	(my_act<=10 or (my_act==200 and my_char~=19) and
					not(
					(my_act==150 and my_frame+1< 8) or
					(my_act==151 and my_frame+1<14) or
					(my_act==152 and my_frame+1<20) or
					(my_act==153 and my_frame+1<26) or
					(my_act==154 and my_frame+1< 8) or
					(my_act==155 and my_frame+1<14) or
					(my_act==156 and my_frame+1<20) or
					(my_act==157 and my_frame+1<26) or
					(my_act==158 and my_frame+1<18)
					)
					) and
		(	(enemy_char== 0 and (enemy_act==303)) or
			(enemy_char== 1 and (enemy_act==303 or enemy_act==304)) or
			(enemy_char== 2 and (enemy_act==302 or enemy_act==303)) or
			(enemy_char== 3 and (enemy_act==300 or enemy_act==330 or enemy_act==418)) or
			(enemy_char== 4 and (enemy_act==303 or enemy_act==304)) or
			(enemy_char== 5 and (enemy_act==303 or (enemy_act==304 and my_backside>=100))) or
			(enemy_char== 6 and (enemy_act==301 or enemy_act==304)) or
			(enemy_char== 7 and (enemy_act==304)) or 
			(enemy_char== 8 and (enemy_act==303)) or 
			(enemy_char== 9 and (enemy_act==303 or enemy_act==304)) or 
			(enemy_char==10 and (enemy_act==303 or enemy_act==304)) or
			(enemy_char==11 and (enemy_act==303 or enemy_act==304)) or 
			(enemy_char==12 and (enemy_act==302 or enemy_act==303)) or 
			(enemy_char==13 and (enemy_act==303 or enemy_act==304)) or 
			(enemy_char==14 and (enemy_act==303)) or 
			(enemy_char==15 and (enemy_act==301 or enemy_act==303 or enemy_act==304)) or 
			(enemy_char==16 and (enemy_act==304)) or 
			(enemy_char==17 and (enemy_act==303 or enemy_act==304)) or 
			(enemy_char==18 and (enemy_act==302 or enemy_act==303)) or 
			(enemy_char==19 and (enemy_act==301 or enemy_act==303 or enemy_act==305 or enemy_act==331))
		) and enemy_allframe==1 and math.random(6)==1 then
			print("汎用下段回避　⇒　ｈｊ");
			if my_backside<=140 then
				key_event2(ACT_D,ACT_UP);
			else
				key_event2(ACT_D,u_back);
			end

--空対地：超反応９飛翔
	elseif y>100 and ey==0 and dis<=500 and ((my_act>=6 and my_act<=9) or my_act==158 or (my_act>=180 and my_act<=181) or (my_act>=208 and my_act<=214)) and enemy_act>=300 and enemy_act<400 and enemy_allframe<=5 and (my_air<=1 or (my_air<=2 and weather==10)) and math.random(5)==1 then
		print("対地飛翔");
		key_resetEX();
		key_on(ACT_D);
		if is_dir_front and math.random(5)==1 then
			key_event2(ACT_B,ACT_DOWN);
		elseif y>=240 and my_backside<=300 then
			key_on(front);
		elseif my_backside<=300 then
			key_on(u_front);
			yield();
			while ey==0 and my_act==214 and my_allframe<=20 do
				yield();
			end
			key_reset();
		else
			key_reset();
			lvr44();
		end
		
--地対低空飛翔
	elseif y==0 and my_act<300 and not(my_act>=50 and my_act<=199) and enemy_act==214 and enemy_allframe<=5 and dis<=500 and ey<=200 and is_dir_front and math.random(after_guard_count+5)==1 then
		print("低空飛翔割り込み",dis);
		key_resetEX();
		--key_event2(ACT_D,u_front);
		key_event2(ACT_D,ACT_UP);
		wait(2);
--地対真上
	elseif y==0 and my_act<300 and not(my_act>=50 and my_act<=199) and (enemy_act==9 or enemy_act==180 or enemy_act==181 or enemy_act==214) and enemy_allframe<=5 and dis<=200 and ey>=200 and math.random(after_guard_count+5)==1 then
		print("上空追いかけ",dis);
		key_resetEX();
		if is_dir_front then
			key_event2(ACT_D,ACT_UP);
		else
			key_event2(ACT_D,u_back);
		end
--[[
--昇りJA始動動作
	elseif dis>100 and y==0 and my_act<300 and not(my_act>=50 and my_act<=199) and my_limit<100 and enemy_act<300 and (
		(	my_act~=200 and 
			(
			(enemy_act==0 and enemy_char~=19 and math.random(after_guard_count+5)==1) or 
			(enemy_act>=1 and enemy_act<=3 and enemy_char==19) or 
			(enemy_act>=4 and enemy_act<=5 and enemy_char~=19 and math.random(after_guard_count+5)==1) or 
			(enemy_act>=50 and enemy_act<=53 and enemy_char~=19) or 
			(enemy_act>=56 and enemy_act<=59 and enemy_char~=19) or 
			(enemy_act>=62 and enemy_act<=65 and enemy_char==19) or 
			(enemy_act>=150 and enemy_act<=153 and enemy_char~=19) or 
			(enemy_act>=154 and enemy_act<=157 and enemy_char==19) or 
			(enemy_act>=159 and enemy_act<=162 and enemy_char~=19) or
			(enemy_act>=163 and enemy_act<=166 and enemy_char==19)
			) and enemy_frame+1<=5 and dis<=140 
		) or	
		(
			ey>0 and ((enemy_act>=50 and enemy_act<=89) or (enemy_act>=143 and enemy_act<=166)) and my_act~=200 and enemy_frame+1<=10 and dis<=200
		)
	)then
		print("昇りJA始動動作",dis);
		if dis>=100 then
			key_event(u_front);
		else
			key_event(u_back);
		end
--]]

--▼反射行動▼
--神技「天覇風神脚」
	elseif card_check(214) and my_spell_more(1500) and dis<150 and y==0 and (	(ey==0) or 
																					(ey+enemy_yspeed*15+(15*(14*e_gs))/2>0 and ey+enemy_yspeed*15+(15*(14*e_gs))/2<=120)	) and 
	my_act<=5 and enemy_allframe<=5 and enemy_act>=302 and enemy_act~=303 and enemy_act<700 and is_dir_front and my_card==214 and math.random(16)==1 then
		print("拒否行動：実行　⇒　神技「天覇風神脚」");
		key_reset();
		key_event(ACT_BC);
	elseif card_check(214) and my_spell_more(1500) and dis<350 and y==0 and my_act<=5 and enemy_frame<=10 and enemy_act>=300 and enemy_act<700 and my_card~=214 then
		--print("拒否行動：準備　⇒　神技「天覇風神脚」");
		key_reset();
		card_1st(214);
--神技「八方鬼縛陣」
	elseif card_check(206) and my_spell_more(2000) and dis<150 and y==0 and (	(ey==0) or 
																					(ey+enemy_yspeed*15+(15*(14*e_gs))/2>0 and ey+enemy_yspeed*15+(15*(14*e_gs))/2<=120)	) and 
	my_act<=5 and enemy_allframe<=5 and enemy_act>=302 and enemy_act~=303 and enemy_act<700 and is_dir_front and my_card==206 and math.random(16)==1 then
		print("拒否行動：実行　⇒　神技「八方鬼縛陣」");
		key_reset();
		key_event(ACT_BC);
	elseif card_check(206) and my_spell_more(2000) and dis<350 and y==0 and my_act<=5 and enemy_frame<=10 and enemy_act>=300 and enemy_act<700 and my_card~=206 then
		--print("拒否行動：準備　⇒　神技「八方鬼縛陣」");
		key_reset();
		card_1st(206);
--宝具「陰陽鬼神玉」
	elseif card_check(210) and my_spell_more(2000) and dis>200 and dis<450 and y==0 and (	(ey==0) or 
																					(ey+enemy_yspeed*15+(15*(14*e_gs))/2>0 and ey+enemy_yspeed*15+(15*(14*e_gs))/2<=200)	) and 
	my_act<=5 and enemy_allframe<=2 and enemy_act>=301 and enemy_act~=303 and enemy_act<700 and is_dir_front and my_card==210 and math.random(16)==1 then
		print("拒否行動：実行　⇒　宝具「陰陽鬼神玉」");
		key_reset();
		key_event(ACT_BC);
	elseif card_check(210) and my_spell_more(2000) and dis<350 and y==0 and my_act<=5 and enemy_frame<=10 and enemy_act>=300 and enemy_act<700 and my_card~=210 then
		--print("拒否行動：準備　⇒　宝具「陰陽鬼神玉」");
		key_reset();
		card_1st(210);
--夢符「封魔陣」
	elseif card_check(204) and my_spell_more(1000) and dis<150 and y==0 and (	(ey==0) or 
																					(ey+enemy_yspeed*15+(15*(14*e_gs))/2>0 and ey+enemy_yspeed*15+(15*(14*e_gs))/2<=120)	) and 
	my_act<=5 and enemy_allframe<=5 and enemy_act>=302 and enemy_act~=303 and enemy_act<700 and is_dir_front and my_card==204 and math.random(16)==1 then
		print("拒否行動：実行　⇒　夢符「封魔陣」");
		key_reset();
		key_event(ACT_BC);
	elseif card_check(204) and my_spell_more(1000) and dis<350 and y==0 and my_act<=5 and enemy_frame<=10 and enemy_act>=300 and enemy_act<700 and my_card~=204 then
		--print("拒否行動：準備　⇒　夢符「封魔陣」");
		key_reset();
		card_1st(204);
--霊撃 or 霊撃札
	elseif (my_act<=10 or (my_act>=143 and my_act<=166)) and enemy_act>=300 and enemy_act<700 and enemy_allframe<=10 and y==0 and dis<=300 and my_hitstop<=2 and my_card~=0 and card_check(0) and ((card_check(13)==false) or (card_check(13) and not(my_act>=143 and my_act<=166))) and weather~=13 then
		print("拒否行動：霊撃　準備　⇒　手札を霊撃に");
		card_1st(0);
	elseif my_act<=10 and enemy_act>=300 and enemy_act<700 and enemy_allframe<=5 and y==0 and dis<=250 and ((ey==0) or (ey+enemy_yspeed*16+(16*(15*e_gs))/2>=1)) and my_hitstop<=2 and card_check(0)==true and 
	(
	(my_rei<=200) or 
	(my_rei<=400 and math.random(2)<=1) or 
	(my_rei<=600 and math.random(4)==1) or 
	(my_rei<=800 and math.random(8)==1) or 
	(my_rei<=1000 and math.random(16)==1) or
	(weather2==13)
	) and weather~=13 then 
		print("拒否行動：霊撃　⇒　可能ならば使用");
		key_event(ACT_BC);
--▼グレイズ：相手行動に対する反射or一定距離内のオブジェクト感知▼
--モーション反応グレイズ
	elseif (
		(--モーション反応型：近距離におけるグレイズ。
			(
			(enemy_act>=400 and enemy_act<=409 and enemy_act~=408 and 
			not(enemy_char==9 and enemy_act==402)) or 
			((enemy_char==1 or enemy_char==4 or enemy_char==13) and enemy_act==408) or 
			(enemy_act>=410 and enemy_act<=417 and enemy_char~=3) or 
			(enemy_char==19 and enemy_act==418) or 
			(enemy_act>=419 and enemy_act<=499) or
				(enemy_act>=500 and enemy_act<690 and 
					not(	(enemy_char==  0 and ((enemy_act>=530 and enemy_act<=534) or (enemy_act>=540 and enemy_act<=544) or (enemy_act>=560 and enemy_act<=573) or enemy_act==614 or enemy_act==664)) or
								(enemy_char==  1 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=520 and enemy_act<=524) or enemy_act==605 or enemy_act==606 or enemy_act==607 or enemy_act==655 or enemy_act==656 or enemy_act==657)) or
								(enemy_char==  2 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=570 and enemy_act<=574) or enemy_act~=600)) or
								(enemy_char==  3 and ((enemy_act>=545 and enemy_act<=549) or enemy_act==610 or enemy_act==660)) or
								(enemy_char==  4 and ((enemy_act>=510 and enemy_act<=514) or enemy_act==602 or enemy_act==652)) or
								(enemy_char==  5 and ((enemy_act>=520 and enemy_act<=523) or (enemy_act>=540 and enemy_act<=543) or (enemy_act>=545 and enemy_act<=548) or (enemy_act>=550 and enemy_act<=553) or enemy_act==600 or enemy_act==603 or enemy_act==604 or enemy_act==612 or enemy_act==650 or enemy_act==653 or enemy_act==654 or enemy_act==662)) or
								(enemy_char==  6 and ((enemy_act>=500 and enemy_act<=514) or (enemy_act>=520 and enemy_act<=524) or (enemy_act>=540 and enemy_act<=544) or (enemy_act>=560 and enemy_act<=569) or enemy_act==602 or enemy_act==605 or enemy_act==606 or enemy_act==652 or enemy_act==655 or enemy_act==656)) or
								(enemy_char==  7 and ((enemy_act>=510 and enemy_act<=514) or (enemy_act>=560 and enemy_act<=574))) or 
								(enemy_char==  8 and ((enemy_act>=520 and enemy_act<=524) or (enemy_act>=560 and enemy_act<=569))) or 
								(enemy_char==  9 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=510 and enemy_act<=514) or (enemy_act>=520 and enemy_act<=529) or enemy_act==600 or enemy_act==601 or enemy_act==602 or enemy_act==603 or enemy_act==604 or enemy_act==605 or enemy_act==612 or enemy_act==650 or enemy_act==651 or enemy_act==652 or enemy_act==653 or enemy_act==654 or enemy_act==655 or enemy_act==662)) or 
								(enemy_char==10 and enemy_act>=565 and enemy_act<=569) or
								(enemy_char==11 and ((enemy_act>=520 and enemy_act<=529) or (enemy_act>=545 and enemy_act<=549) or  (enemy_act>=550 and enemy_act<=554) or enemy_act==601 or enemy_act==606 or enemy_act==612 or enemy_act==651 or enemy_act==656 or enemy_act==662)) or 
								(enemy_char==12 and ((enemy_act>=525 and enemy_act<=534) or (enemy_act>=550 and enemy_act<=554) or enemy_act==600 or enemy_act==601 or enemy_act==604 or enemy_act==611 or enemy_act==650 or enemy_act==651 or enemy_act==654 or enemy_act==661)) or 
								(enemy_char==13 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=520 and enemy_act<=524) or (enemy_act>=530 and enemy_act<=530) or (enemy_act>=545 and enemy_act<=546) or enemy_act==601 or enemy_act==651 or enemy_act==610 or enemy_act==660)) or 
								(enemy_char==14 and ((enemy_act>=505 and enemy_act<=509) or (enemy_act>=545 and enemy_act<=549) or (enemy_act>=560 and enemy_act<=574) or enemy_act==601 or enemy_act==602 or enemy_act==605 or enemy_act==608 or enemy_act==651 or enemy_act==652 or enemy_act==655 or enemy_act==658)) or 
								(enemy_char==15 and ((enemy_act>=540 and enemy_act<=544) or enemy_act==605 or enemy_act==655)) or 
								(enemy_char==16 and ((enemy_act>=520 and enemy_act<=534) or (enemy_act>=570 and enemy_act<=574) or enemy_act==603 or enemy_act==607 or enemy_act==608 or enemy_act==653 or enemy_act==657 or enemy_act==658)) or 
								(enemy_char==17 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=510 and enemy_act<=514) or (enemy_act>=520 and enemy_act<=529) or (enemy_act>=540 and enemy_act<=544) or  (enemy_act>=550 and enemy_act<=554) or enemy_act==604 or enemy_act==605 or enemy_act==606 or enemy_act==607 or enemy_act==609 or enemy_act==654 or enemy_act==655 or enemy_act==656 or enemy_act==657 or enemy_act==659)) or 
								(enemy_char==18 and ((enemy_act>=505 and enemy_act<=514) or enemy_act==608 or enemy_act==609 or enemy_act==610 or enemy_act==658 or enemy_act==659 or enemy_act==660)) or 
								(enemy_char==19 and ((enemy_act>=520 and enemy_act<=524) or (enemy_act>=525 and enemy_act<=529) or (enemy_act>=540 and enemy_act<=544) or  (enemy_act>=550 and enemy_act<=554) or enemy_act==600 or enemy_act==602 or enemy_act==605 or enemy_act==650 or enemy_act==652 or enemy_act==655))
					)
				)
			)	and dis<600 and (get_fflags(1,64) or dis>=200) and my_hitstop==0
		) or
		(--モーション反応型：レーザー系や判定が反転するなど情報取得がおかしくなるもの
			(
				--(enemy_char==  0 and ((enemy_act>=540 and enemy_act<=544) or (enemy_act>=560 and enemy_act<=573) or enemy_act==614 or enemy_act==664)) or
				(enemy_char==  1 and ((enemy_act>=430 and enemy_act<=432) or (enemy_act>=565 and enemy_act<=568) or enemy_act==600 or enemy_act==602 or enemy_act==604 or enemy_act==619)) or
				--(enemy_char==  2 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=570 and enemy_act<=574))) or
				(enemy_char==  3 and ((enemy_act>=545 and enemy_act<=547) or enemy_act==602 or enemy_act==652 or enemy_act==605 or enemy_act==606 or enemy_act==607 or enemy_act==657 or enemy_act==609 or enemy_act==659)) or
				(enemy_char==  4 and (enemy_act==600 or enemy_act==603)) or
				--(enemy_char==  5 and (enemy_act==565)) or
				--(enemy_char==  6 and ((enemy_act>=500 and enemy_act<=514) or (enemy_act>=540 and enemy_act<=544) or (enemy_act>=560 and enemy_act<=569) or enemy_act==602 or enemy_act==605 or enemy_act==606 or enemy_act==652 or enemy_act==655 or enemy_act==656)) or
				(enemy_char==  7 and (enemy_act>=520 and enemy_act<=524)) or 
				(enemy_char==  8 and ((enemy_act==530 or (enemy_act==531 and enemy_allframe>=15)))) or 
				--(enemy_char==  9 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=510 and enemy_act<=514) or (enemy_act>=520 and enemy_act<=529) or enemy_act==600 or enemy_act==601 or enemy_act==602 or enemy_act==603 or enemy_act==604 or enemy_act==605 or enemy_act==612 or enemy_act==650 or enemy_act==651 or enemy_act==652 or enemy_act==653 or enemy_act==654 or enemy_act==655 or enemy_act==662)) or 
				(enemy_char==10 and (enemy_act==604)) or
				--(enemy_char==11 and ((enemy_act>=520 and enemy_act<=529) or (enemy_act>=545 and enemy_act<=549) or  (enemy_act>=550 and enemy_act<=554) or enemy_act==601 or enemy_act==606 or enemy_act==612 or enemy_act==651 or enemy_act==656 or enemy_act==662)) or 
				--(enemy_char==12 and ((enemy_act>=525 and enemy_act<=534) or (enemy_act>=550 and enemy_act<=554) or enemy_act==600 or enemy_act==601 or enemy_act==604 or enemy_act==611 or enemy_act==650 or enemy_act==651 or enemy_act==654 or enemy_act==661)) or 
				--(enemy_char==13 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=520 and enemy_act<=524) or (enemy_act>=530 and enemy_act<=530) or (enemy_act>=545 and enemy_act<=546) or enemy_act==601 or enemy_act==651 or enemy_act==610 or enemy_act==660)) or 
				(enemy_char==14 and ((enemy_act>=540 and enemy_act<=544) or enemy_act==607)) or 
				(enemy_char==15 and ((enemy_act>=545 and enemy_act<=548) or enemy_act==607)) or 
				--(enemy_char==16 and ((enemy_act>=520 and enemy_act<=534) or (enemy_act>=570 and enemy_act<=574) or enemy_act==603 or enemy_act==607 or enemy_act==608 or enemy_act==653 or enemy_act==657 or enemy_act==658)) or 
				--(enemy_char==17 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=510 and enemy_act<=514) or (enemy_act>=520 and enemy_act<=529) or (enemy_act>=540 and enemy_act<=544) or  (enemy_act>=550 and enemy_act<=554) or enemy_act==604 or enemy_act==605 or enemy_act==606 or enemy_act==607 or enemy_act==609 or enemy_act==654 or enemy_act==655 or enemy_act==656 or enemy_act==657 or enemy_act==659)) or 
				(enemy_char==18 and (enemy_act==601 or enemy_act==614)) --or 
				--(enemy_char==19 and ((enemy_act>=520 and enemy_act<=524) or (enemy_act>=525 and enemy_act<=529) or (enemy_act>=540 and enemy_act<=544) or  (enemy_act>=550 and enemy_act<=554) or enemy_act==600 or enemy_act==602 or enemy_act==605 or enemy_act==650 or enemy_act==652 or enemy_act==655))
			)	--and get_fflags(1,64) and enemy_allframe>=15 
			and my_hitstop==0 
		) or
		(--オブジェクト反応型
		(enemy_char== 0 and (dis>=300 or (enemy_act>=400 and enemy_act~=408 and enemy_act~=418 and not(enemy_act>=560 and enemy_act<=574))) and caution_state_obj(817,196,150,300,40-30,420+5)>=1 ) or --常置陣（B:30F, C:40F）
		(enemy_char== 2 and (dis>=300 or (enemy_act>=400 and enemy_act~=408 and enemy_act~=418 and not(enemy_act>=500 and enemy_act<=504))) and caution_state_obj(850,196,350,350,90-30,90+5)>=1 ) or --幻符「殺人ドール」
		(enemy_char== 6 and (dis>=300 or (enemy_act>=400 and not(enemy_act>=500 and enemy_act<=514))) and enemy_act~=540 and enemy_act~=541 and enemy_act~=602 and enemy_act~=605 and caution_state_obj(815,212,50,50,60-30,60+5)>=1 ) or --サーヴァントフライヤー
		(enemy_char== 7 and (dis>=300 or (enemy_act>=400 and enemy_act~=408 and enemy_act~=418 and not(enemy_act>=560 and enemy_act<=574))) and caution_state_obj(812,172,150,150,90-30,90+5)>=1 ) or --スフィアブルーム
		(enemy_char==13 and (((dis>=300 and ey==0) or (dis>=400 and ey>0)) or (enemy_act>=400 and enemy_act~=418 and enemy_act~=500 and enemy_act~=501 and enemy_act~=530 and enemy_act~=531 and enemy_act~=601)) and caution_state_obj(817,272,200,1200,0,45)>=1 and caution_state_obj(817,168,200,1200,0,45)>=1) --対龍神の怒り
		)
	)	and
	not(
	(my_act==150 and my_frame+1< 8) or
	(my_act==151 and my_frame+1<14) or
	(my_act==152 and my_frame+1<20) or
	(my_act==153 and my_frame+1<26) or
	(my_act==154 and my_frame+1< 8) or
	(my_act==155 and my_frame+1<14) or
	(my_act==156 and my_frame+1<20) or
	(my_act==157 and my_frame+1<26) or
	(my_act==158 and my_frame+1<18)
	
	) and (my_air<=0 or (my_air<=0 and weather==10)) and my_rei>=0 then--近距離時のグレイズ。のさばらせておくと、誤結界の原因となる。ガードの硬直間際ならおｋ
	--▼
		print("チェック１");
		react_wait(7+5)
	--▲
			if enemy_cahr==9 and enemy_act==402 then--萃香２Ｂ対策。
				key_on(d_back);
			elseif 
			not(my_act>=6 and my_act<=8 and y<100 and my_yspeed>=0) and 
			not(my_act>=208 and my_act<=212 and y<100 and my_yspeed>=0) and 
			not(my_act>=50 and my_act<143) and
			not(	(my_act==150 and my_frame+1< 8) or
					(my_act==151 and my_frame+1<14) or
					(my_act==152 and my_frame+1<20) or
					(my_act==153 and my_frame+1<26) or
					(my_act==154 and my_frame+1< 8) or
					(my_act==155 and my_frame+1<14) or
					(my_act==156 and my_frame+1<20) or
					(my_act==157 and my_frame+1<26) or
					(my_act==158 and my_frame+1<18)
			) then
			
		--▼100型：霊紫衣
			if my_char==0 or my_char==8 or my_char==13 then
				if dis>600 then
					if y==0 then
						print("モーション反応　⇒　遠距離：地上　⇒　８ｈｊ");
						key_event2(ACT_D,ACT_UP);
					elseif y>0 and my_yspeed<=0 then
						key_reset();
						key_on(ACT_D);
						if y>100.0 and my_act~=214 then
							print("モーション反応　⇒　遠距離：空中　y>100.0　⇒　２飛翔");
							key_on(ACT_DOWN);
						elseif y>70.8 and my_act~=214 then
							print("モーション反応　⇒　遠距離：空中　y>70.8　⇒　１飛翔");
							key_on(d_back);
						elseif my_act~=214 and my_act~=203 then
							print("モーション反応　⇒　遠距離：空中　y<=70.8　⇒　J４４");
							key_resetEX();
							yield();
							lvr44();
						end
					end
				elseif dis>300 then
					if y==0 and my_act~=200 then
						if ey-y>=1*my_dir*(ex-x) then
							print("モーション反応　⇒　中距離：地上　⇒　６D");
							key_on(ACT_D);
							key_on(front);
						elseif dis<=400 and ey<=200 and my_act~=200 and math.random(4)==1 then
							print("モーション反応　⇒　中距離：地上　⇒　９ｈｊ");
							key_event2(ACT_D,u_front);
						elseif math.random(4)<=3 then
							print("モーション反応　⇒　中距離：地上　⇒　８ｈｊ");
							key_event2(ACT_D,ACT_UP);
						else
							print("モーション反応　⇒　中距離：地上　⇒　７ｈｊ");
							key_event2(ACT_D,ACT_UP);
						end
					elseif y>0 and my_yspeed<=0 then
						key_reset();
						key_on(ACT_D);
						if y>100.0 and my_act~=214 then
							print("モーション反応　⇒　中距離：空中　y>100.0　⇒　２飛翔");
							key_on(ACT_DOWN);
						elseif y>70.8 and my_act~=214 then
							print("モーション反応　⇒　中距離：空中　y>70.8　⇒　３飛翔");
							key_on(d_front);
						elseif my_act~=214 and my_act~=202 then
							print("モーション反応　⇒　中距離：空中　y<=70.8　⇒　J６６");
							key_resetEX();
							yield();
							lvr66();
						end
					end
				else
					if y==0 and my_act~=200 then
						if y>0 and ex<=200 and ey<=200 and my_act~=200 and math.random(4)==1 then
							print("モーション反応　⇒　近距離：地上　⇒　９ｈｊ");
							key_event2(ACT_D,front);
						elseif y>=100 then
							print("モーション反応　⇒　近距離：地上　⇒　６D");
							key_on(ACT_D);
							key_on(front);
						elseif my_backside>=200 then
							print("モーション反応　⇒　近距離：地上　⇒　７ｈｊ");
							key_event2(ACT_D,u_back);
						else
							print("モーション反応　⇒　近距離：地上　⇒　８ｈｊ");
							key_event2(ACT_D,ACT_UP);
						end
					elseif y>0 and my_yspeed<=0 then
						key_reset();
						key_on(ACT_D);
						if y-ey>100.0 and my_backside<=100 and enemy_frontside<=200 and my_act~=214 then
							print("モーション反応　⇒　画面端：空中　飛び越え可能　⇒　６飛翔");
							key_on(front);
						elseif y>100.0 and my_act~=214 then
							print("モーション反応　⇒　近距離：空中　y>100.0　⇒　２飛翔");
							key_on(ACT_DOWN);
						elseif y>70.8 and my_act~=214 then
							print("モーション反応　⇒　近距離：空中　y>70.8　⇒　３飛翔");
							key_on(d_front);
						elseif my_act~=214 and my_act~=202 then
							print("モーション反応　⇒　近距離：空中　y<=70.8　⇒　J６６");
							key_resetEX();
							yield();
							lvr66();
						end
					end
				end
			end
			end

--▼ガード行動：簡易ガードルーチン▼

--ガー反、羽衣使用
	elseif my_act>=143 and my_act<=166 and enemy_act>=300 and enemy_act<700 and enemy_allframe<=5 and y==0 and dis<=300 and my_hitstop<=2 and my_card~=13 and card_check(13)==true and weather~=13 then
		print("拒否行動：龍魚の羽衣　準備　⇒　手札を龍魚の羽衣");
		card_1st(13);
	elseif my_act>=150 and my_act<=157 and enemy_act>=301 and enemy_act<700 and enemy_act~=330 and not(enemy_char==2 and enemy_act==302) and y==0 and dis<=300 and ey==0 and my_hitstop<=2 and my_card==13 and 
	(
	(my_rei<=200) or 
	(my_rei<=400 and math.random(2)<=1) or 
	(my_rei<=600 and math.random(4)==1) or 
	(my_rei<=800 and math.random(8)==1) or 
	(my_rei<=1000 and math.random(16)==1) or
	(weather2==13)
	) and weather~=13 then
		print("拒否行動：龍魚の羽衣　⇒　可能ならば使用");
		key_event(ACT_BC);
		
--回避結界
	elseif my_act>=150 and my_act<=158 and 
	(	(enemy_act>=400 and enemy_act<=409 and enemy_act~=408 and not(enemy_char==9 and enemy_act==402)) or 
		((enemy_char==1 or enemy_char==4 or enemy_char==13) and enemy_act==408) or 
		(enemy_act>=410 and enemy_act<=417 and enemy_char~=3) or 
		(enemy_char==19 and enemy_act==418) or 
		(enemy_act>=419 and enemy_act<=499) or
			(enemy_act>=500 and enemy_act<690 and 
				not(	(enemy_char==  0 and ((enemy_act>=540 and enemy_act<=544) or (enemy_act>=560 and enemy_act<=573) or enemy_act==614 or enemy_act==664)) or
							(enemy_char==  1 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=520 and enemy_act<=524) or enemy_act==605 or enemy_act==606 or enemy_act==607 or enemy_act==655 or enemy_act==656 or enemy_act==657)) or
							(enemy_char==  2 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=570 and enemy_act<=574))) or
							(enemy_char==  3 and ((enemy_act>=545 and enemy_act<=549) or enemy_act==610 or enemy_act==660)) or
							(enemy_char==  4 and ((enemy_act>=510 and enemy_act<=514) or enemy_act==602 or enemy_act==652)) or
							(enemy_char==  5 and ((enemy_act>=520 and enemy_act<=523) or (enemy_act>=540 and enemy_act<=543) or (enemy_act>=545 and enemy_act<=548) or (enemy_act>=550 and enemy_act<=553) or enemy_act==600 or enemy_act==603 or enemy_act==604 or enemy_act==612 or enemy_act==650 or enemy_act==653 or enemy_act==654 or enemy_act==662)) or
							(enemy_char==  6 and ((enemy_act>=500 and enemy_act<=514) or (enemy_act>=540 and enemy_act<=544) or (enemy_act>=560 and enemy_act<=569) or enemy_act==602 or enemy_act==605 or enemy_act==606 or enemy_act==652 or enemy_act==655 or enemy_act==656)) or
							(enemy_char==  7 and (enemy_act>=560 and enemy_act<=574)) or 
							(enemy_char==  8 and ((enemy_act>=520 and enemy_act<=524) or (enemy_act>=560 and enemy_act<=569))) or 
							(enemy_char==  9 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=510 and enemy_act<=514) or (enemy_act>=520 and enemy_act<=529) or enemy_act==600 or enemy_act==601 or enemy_act==602 or enemy_act==603 or enemy_act==604 or enemy_act==605 or enemy_act==612 or enemy_act==650 or enemy_act==651 or enemy_act==652 or enemy_act==653 or enemy_act==654 or enemy_act==655 or enemy_act==662)) or 
							(enemy_char==10 and enemy_act>=565 and enemy_act<=569) or
							(enemy_char==11 and ((enemy_act>=520 and enemy_act<=529) or (enemy_act>=545 and enemy_act<=549) or  (enemy_act>=550 and enemy_act<=554) or enemy_act==601 or enemy_act==606 or enemy_act==612 or enemy_act==651 or enemy_act==656 or enemy_act==662)) or 
							(enemy_char==12 and ((enemy_act>=525 and enemy_act<=534) or (enemy_act>=550 and enemy_act<=554) or enemy_act==600 or enemy_act==601 or enemy_act==604 or enemy_act==611 or enemy_act==650 or enemy_act==651 or enemy_act==654 or enemy_act==661)) or 
							(enemy_char==13 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=520 and enemy_act<=524) or (enemy_act>=530 and enemy_act<=530) or (enemy_act>=545 and enemy_act<=546) or enemy_act==601 or enemy_act==651 or enemy_act==610 or enemy_act==660)) or 
							(enemy_char==14 and ((enemy_act>=505 and enemy_act<=509) or (enemy_act>=545 and enemy_act<=549) or (enemy_act>=560 and enemy_act<=574) or enemy_act==601 or enemy_act==602 or enemy_act==605 or enemy_act==608 or enemy_act==651 or enemy_act==652 or enemy_act==655 or enemy_act==658)) or 
							(enemy_char==15 and ((enemy_act>=540 and enemy_act<=544) or enemy_act==605 or enemy_act==655)) or 
							(enemy_char==16 and ((enemy_act>=520 and enemy_act<=534) or (enemy_act>=570 and enemy_act<=574) or enemy_act==603 or enemy_act==607 or enemy_act==608 or enemy_act==653 or enemy_act==657 or enemy_act==658)) or 
							(enemy_char==17 and ((enemy_act>=500 and enemy_act<=504) or (enemy_act>=510 and enemy_act<=514) or (enemy_act>=520 and enemy_act<=529) or (enemy_act>=540 and enemy_act<=544) or  (enemy_act>=550 and enemy_act<=554) or enemy_act==604 or enemy_act==605 or enemy_act==606 or enemy_act==607 or enemy_act==609 or enemy_act==654 or enemy_act==655 or enemy_act==656 or enemy_act==657 or enemy_act==659)) or 
							(enemy_char==18 and ((enemy_act>=505 and enemy_act<=514) or enemy_act==608 or enemy_act==609 or enemy_act==610 or enemy_act==658 or enemy_act==659 or enemy_act==660)) or 
							(enemy_char==19 and ((enemy_act>=520 and enemy_act<=524) or (enemy_act>=525 and enemy_act<=529) or (enemy_act>=540 and enemy_act<=544) or  (enemy_act>=550 and enemy_act<=554) or enemy_act==600 or enemy_act==602 or enemy_act==605 or enemy_act==650 or enemy_act==652 or enemy_act==655))
				)
			)--or
		--(weather==5)
	) and --enemy_allframe<=200 and my_hitstop<=4 and my_hitstop>=0 and 
	(
	(my_rmax==1000 and	(	(my_rei<=  200 and my_rei>=  0 ) or 
										(my_rei<=  400 and my_rei> 200 and math.random(32)==1) or 
										(my_rei<=  600 and my_rei> 400 and math.random(64)==1) or 
										(my_rei<=  800 and my_rei> 600 and math.random(128)==1) or 
										(my_rei<= 1000 and my_rei> 800 and math.random(256)==1))
	) or
	(my_rmax== 800 and	(	(my_rei<=  200 and my_rei>=  0 ) or 
										(my_rei<=  400 and my_rei> 200 and math.random(64)==1) or 
										(my_rei<=  600 and my_rei> 400 and math.random(128)==1) or 
										(my_rei<=  800 and my_rei> 600 and math.random(256)==1))
	)  or
	(my_rmax== 600 and	(	(my_rei<=  200 and my_rei>=  0 ) or 
										(my_rei<=  400 and my_rei> 200 and math.random(128)==1) or 
										(my_rei<=  600 and my_rei> 400 and math.random(256)==1))
	)  or
	(my_rmax== 400 and	(	(my_rei<=  200 and my_rei>=  0 ) or 
										(my_rei<=  400 and my_rei> 200 and math.random(256)==1))
	)  or
	(my_rmax== 200 and	(	(my_rei<= 200 and my_rei>=  0 ))
	)  or
	((weather==0 or weather==8) and math.random(8)==1
	)
	)
	then
		print("拒否行動：回避結界　⇒　できれば使用");
		key_reset();
		key_on(ACT_D);yield();
		key_off(ACT_D);yield();
		key_on(ACT_D);
		if y==0 then
			if (my_dir==1 and x<=100) or (my_dir==-1 and x>=1180) then
				key_on(ACT_DOWN);
			else
				key_on(d_back);
			end
		elseif y>0 then
			if (my_dir==1 and x<=100) or (my_dir==-1 and x>=1180) then
				key_on(front);
			else
				key_on(back);
			end
		end
		if my_hitstop>=1 then
			wait(my_hitstop);
		else
			yield();
		end
		key_reset();
--▼汎用：宵越しの銭▼とりあえず、必ず使用してみる　⇒　とりあえず。剰余式の確率を導入。どう調整すればいいか分からない。
	elseif dis<=300 and my_act>=143 and my_act<=166 and my_frame<=11 and my_hitstop<=2 and card_check(12) and card_check(13)==false and my_card~=12 then
		print("宵越しの銭：準備");
		card_1st(12);
	elseif dis<=300 and 
	(	(	
			(my_act>=150 and my_act<=157) and my_hitstop<=3 and my_hitstop>=2 and not(x<=40 or x>=1240)
		) or
		(	(	((my_act==153 or my_act==157)	and ((my_frame>=25 and my_frame<=26) or (my_allframe>=25 and my_allframe<=26))) or
				((my_act==152 or my_act==156)	and ((my_frame>=19 and my_frame<=20) or (my_allframe>=19 and my_allframe<=20))) or
				((my_act==151 or my_act==155)	and ((my_frame>=13 and my_frame<=14) or (my_allframe>=13 and my_allframe<=14))) or
				((my_act==150 or my_act==154)	and ((my_frame>= 7 and my_frame<= 8) or (my_allframe>= 7 and my_allframe<= 8)))
			)	and (x<=40 or x>=1240) 
		)
	) and my_card==12 and get_key_stat(ACT_BC)==0 and ((my_rei< 100) or (my_rei> 900)) then
		print("宵越しの銭：使用");
		key_on(ACT_BC);
		yield();
		key_off(ACT_BC);
		
--汎用中下段ガード。基本は行動に対して後退入れ込み。下段のみ抽出して反応。通常射撃も同じく下段で受ける(けどメンドウだから今回は省き)。フラグを抜けてくるものは別個に対応
	elseif dis<=500 and get_special_data(0,10)<=20 and get_aflags(1,32768)==true and weather~=13 then
		print("フラグ確認　⇒　しゃがみガード");
		key_resetEX();
		key_on(d_back);
	elseif dis<=500 and get_special_data(0,10)<=20 and get_aflags(1,16384)==true and weather~=13 then
		print("フラグ確認　⇒　立ちガード");
		key_resetEX();
		key_on(back);
	elseif enemy_act>=300 and --打撃、射撃、スキル、スペル、シスカをすべてフィルタ
	dis<=500 and
	weather~=13 and --台風をフィルタ
	get_special_data(0,10)<=20 and --無念無想をフィルタ
	(get_fflags(1,64) or get_aflags(1,8192) or get_aflags(1,16384) or get_aflags(1,32768)) and --被ＣＨ、空中攻撃判定、中段判定、下段判定をフィルタ
	(
	(enemy_char== 0 and (enemy_act==303 or (enemy_act==304 and enemy_allframe>=20) or enemy_act==408 or enemy_act==541 or enemy_act==565 or enemy_act==566)) or
	(enemy_char== 1 and (enemy_act==303 or enemy_act==304)) or
	(enemy_char== 2 and (enemy_act==302 or enemy_act==303)) or
	(enemy_char== 3 and (enemy_act==300 or enemy_act==303 or enemy_act==305 or enemy_act==320 or enemy_act==321 or enemy_act==330 or enemy_act==418 or enemy_act==610)) or
	(enemy_char== 4 and (enemy_act==303 or enemy_act==304 or enemy_act==305)) or
	(enemy_char== 5 and (enemy_act==300 or enemy_act==303 or enemy_act==304 or enemy_act==311 or enemy_act==320 or enemy_act==322 or enemy_act==330 or enemy_act==408 or ((enemy_act==540 or enemy_act==541)and ey==0) or enemy_act==545 or enemy_act==546)) or
	(enemy_char== 6 and (enemy_act==300 or enemy_act==301 or enemy_act==303 or enemy_act==304)) or
	(enemy_char== 7 and (enemy_act==303 or enemy_act==304 or enemy_act==311)) or 
	(enemy_char== 8 and (enemy_act==301 or enemy_act==303 or enemy_act==304 or enemy_act==418 or enemy_act==565 or enemy_act==566)) or 
	(enemy_char== 9 and (enemy_act==303 or enemy_act==304 or enemy_act==311 or enemy_act==402 or enemy_act==408 or enemy_act==510 or enemy_act==511 or enemy_act==525 or enemy_act==526)) or 
	(enemy_char==10 and (enemy_act==303 or enemy_act==304 or enemy_act==311 or enemy_act==408)) or
	(enemy_char==11 and (enemy_act==303 or enemy_act==304 or enemy_act==311)) or 
	(enemy_char==12 and (enemy_act==302 or enemy_act==303 or enemy_act==408)) or 
	(enemy_char==13 and (enemy_act==303 or enemy_act==304)) or 
	(enemy_char==14 and (enemy_act==303 or enemy_act==320 or enemy_act==322 or enemy_act==408 or enemy_act==505 or enemy_act==560 or enemy_act==561)) or 
	(enemy_char==15 and (enemy_act==301 or enemy_act==303 or enemy_act==304)) or 
	(enemy_char==16 and (enemy_act==303 or enemy_act==304 or enemy_act==418)) or 
	(enemy_char==17 and (enemy_act==303 or enemy_act==304 or enemy_act==418 or enemy_act==540 or enemy_act==541)) or 
	(enemy_char==18 and (enemy_act==302 or enemy_act==303 or enemy_act==321 or enemy_act==510 or enemy_act==511)) or 
	(enemy_char==19 and (enemy_act==300 or enemy_act==301 or enemy_act==303 or enemy_act==309 or enemy_act==320 or enemy_act==330))
	) and weather~=13 then --下段判定をフィルタ
		key_resetEX();
	--▼
		print("チェック２");
		react_wait(7)
	--▲
		print("下段条件確認　⇒　しゃがみガード");
		key_on(d_back);
	elseif dis<=500 and get_special_data(0,10)<=20 and (
	(enemy_char== 0 and ((enemy_act==300 and enemy_frame<=9) or (enemy_act==320 and enemy_frame<=8) or (enemy_act==330 and enemy_frame<=9))) or
	(enemy_char== 1 and ((enemy_act==300 and enemy_frame<=8) or (enemy_act==320 and enemy_frame<=8) or (enemy_act==330 and enemy_frame<=8))) or
	(enemy_char== 2 and ((enemy_act==300 and enemy_frame<=9) or (enemy_act==320 and enemy_frame<=8) or (enemy_act==330 and enemy_frame<=9))) or
	(enemy_char== 3 and ((enemy_act==300 and enemy_frame<=11) or (enemy_act==320 and enemy_frame<=10) or (enemy_act==330 and enemy_frame<=11))) or
	(enemy_char== 5 and ((enemy_act==300 and enemy_frame<=9) or (enemy_act==303 and enemy_frame<=10) or (enemy_act==320 and enemy_frame<=9) or (enemy_act==330 and enemy_frame<=9))) or
	(enemy_char== 6 and ((enemy_act==300 and enemy_frame<=9) or (enemy_act==320 and enemy_frame<=9) or (enemy_act==330 and enemy_frame<=9))) or
	(enemy_char== 8 and ((enemy_act==300 and enemy_frame<=11) or (enemy_act==303 and enemy_frame<=10) or (enemy_act==320 and enemy_frame<=11) or (enemy_act==330 and enemy_frame<=11))) or
	(enemy_char==10 and ((enemy_act==300 and enemy_frame<=8) or (enemy_act==303 and enemy_frame<=8) or (enemy_act==320 and enemy_frame<=8) or (enemy_act==330 and enemy_frame<=8))) or
	(enemy_char==11 and ((enemy_act==300 and enemy_frame<=8) or (enemy_act==303 and enemy_frame<=9) or (enemy_act==320 and enemy_frame<=9) or (enemy_act==330 and enemy_frame<=8))) or
	(enemy_char==12 and ((enemy_act==303 and enemy_frame<=10) or (enemy_act==305 and enemy_frame<=15))) or
	(enemy_char==13 and ((enemy_act==320 and enemy_frame<=12))) or
	(enemy_char==15 and ((enemy_act==300 and enemy_frame<=8) or (enemy_act==303 and enemy_frame<=8) or (enemy_act==330 and enemy_frame<=8))) or
	(enemy_char==16 and ((enemy_act==300 and enemy_frame<=7) or (enemy_act==303 and enemy_frame<=6) or (enemy_act==320 and enemy_frame<=7) or (enemy_act==330 and enemy_frame<=7))) or
	(enemy_char==17 and ((enemy_act==300 and enemy_frame<=7) or (enemy_act==303 and enemy_frame<=8) or (enemy_act==320 and enemy_frame<=7) or (enemy_act==330 and enemy_frame<=7))) or
	(enemy_char==19 and ((enemy_act==300 and enemy_frame<=8) or (enemy_act==302 and enemy_allframe<=14) or (enemy_act==320 and enemy_frame<=9) or (enemy_act==330 and enemy_frame<=8)))
	) and weather~=13 then --フラグを抜けてくるものをフィルタ
		key_resetEX();
	--▼
		print("チェック３");
		react_wait(7)
	--▲
		print("フラグ抜け　⇒　しゃがみガード");
		key_on(d_back);
		
	elseif enemy_act>=300 and dis<=500 and	get_special_data(0,10)<=20 and weather~=13 and --無念無想をフィルタ
	(get_fflags(1,64) or get_aflags(1,8192) or get_aflags(1,16384) or get_aflags(1,32768)) then
		key_resetEX();--以下、何もフィルタされなかった場合、立ちガード
	--▼
		print("チェック４");
		react_wait(7)
	--▲
		print("後退　⇒　立ちガード");
		key_on(back);
		
--オブジェが至近距離の場合、着地直前にｈｊを仕込む、タッチ＆ゴーグレイズ
	elseif y>0 and my_act==214 and y+my_yspeed*6<=0 and enemy_obj_range_in(150,20)==true and
	(dis2>=400 or (weather==5) or enemy_act>=600) and my_rei>=10 then
		print("obj至近距離：着地直前　⇒　グレイズ「タッチ＆ゴー」");
		key_resetEX();
		yield();
		key_on(ACT_DOWN);
		wait(1);
		key_on(u_front);
		wait(1)
		key_off(u_front);
		while (y>0 and my_yspeed<=0) do
			yield();
		end
--[[
	オブジェが至近距離の場合、ガードの前に、離陸
	elseif y==0 and my_act==200 and enemy_obj_range_in(150,20)==true and
	(dis2>=400 or (weather==5) or enemy_act>=600) and my_rei>=10 then
		print("obj至近距離：地上：ダッシュ　⇒　ダッシュ＆テイクオフ");
		key_resetEX();
		key_event(ACT_DOWN);
		key_event(u_front);
	elseif y==0 and my_act==204 and my_allframe>=15 and my_allframe<=16 and enemy_obj_range_in(150,20)==true and --キャラごとに硬直が違う点に注意。問題がでたら修正すること。
	(dis2>=400 or (weather==5) or enemy_act>=600) and my_rei>=10 then
		print("obj至近距離：地上：ブレーキ　⇒　ダッシュ＆テイクオフ");
		key_resetEX();
		key_event2(ACT_D,ACT_UP);
--]]
--オブジェが至近距離の場合、空中から地上へ飛翔　※咲夜：２D：120.0以上、３D：84.9以上必要
	elseif y>0 and  
		not(my_act>=6 and my_act<=8 and y<100 and my_yspeed>=0) and 
		not(my_act>=208 and my_act<=212 and y<100 and my_yspeed>=0) and 
		not(my_act>=50 and my_act<143) and
		not(	(my_act==150 and my_frame+1< 8) or
				(my_act==151 and my_frame+1<14) or
				(my_act==152 and my_frame+1<20) or
				(my_act==153 and my_frame+1<26) or
				(my_act==154 and my_frame+1< 8) or
				(my_act==155 and my_frame+1<14) or
				(my_act==156 and my_frame+1<20) or
				(my_act==157 and my_frame+1<26) or
				(my_act==158 and my_frame+1<18)		) and
		enemy_obj_range_in(150,20)==true and
	(my_air<=0 or (my_air<=0 and weather==10)) and
	(dis2>=400 or (weather==5) or enemy_act>=600) and my_rei>=10 then
		key_reset();
		key_on(ACT_D);
	--▼100型：霊紫衣
		if my_char==0 or my_char==8 or my_char==13 then
			if y>100.0 then
				print("obj至近距離：空中　y>100.0　⇒　２飛翔");
				key_on(ACT_DOWN);
			elseif y>70.8 then
				print("obj至近距離：空中　y>70.8　⇒　３飛翔");
				key_on(d_back);
			else
				print("obj至近距離：空中　y<=70.8　⇒　J４４");
				key_resetEX();
				yield();
				lvr66();
			end

		end
		
--遠距離時のグレイズ
	elseif y==0 and enemy_obj_range_in(150,20)==true and dis>=500 and not(my_act>=150 and my_act<=165) and my_rei>=10 then
		print("オブジェ：至近距離　＆　相手：遠い　＞　グレイズ");
		key_resetEX();
		if weather~=13 then
			key_event2(ACT_D,front);
		else
			key_event2(ACT_D,ACT_UP);
		end
	elseif y>0 and enemy_obj_range_in(150,20)==true and dis>=500 and not(my_act>=150 and my_act<=165) and (my_air<=0 or (my_air<=0 and weather==10)) and my_rei>=10 then
		print("オブジェ：至近距離　＆　相手：遠い　＞　グレイズ");
		key_resetEX();
		key_on(ACT_D);
		if weather~=13 then
			key_on(d_front);
		else
			key_on(d_back);
		end
		
--特定状況におけるガード
	elseif 
	--常置陣
	--マジカル産廃利用ボム
	--魔廃「ディープエコロジカルボム」
	--Ｃ射系人形
	--人形伏兵（優先度は低いがメタが強力
	--大江戸からくり人形
	--人形置操
	--人形振起（始動モーションと合わせて管理
	(enemy_char== 0 and caution_state_obj(817,196,150,100,40-30,420+5)>=1 ) or --常置陣（B:30F, C:40F）
	(enemy_char== 2 and caution_state_obj(850,196,150,150,90-30,90+5)>=1 ) or --幻符「殺人ドール」
	(enemy_char== 6 and caution_state_obj(815,212,50,50,60-30,60+5)>=1 ) or --サーヴァントフライヤー
	(enemy_char== 7 and caution_state_obj(812,172,150,150,90-30,90+5)>=1 ) or --スフィアブルーム
	(enemy_char==13 and caution_state_obj(817,272,200,1200,0,45)>=1 and caution_state_obj(817,168,200,1200,0,45)>=1) --竜神の怒り
	then
		key_on(back);
--オブジェが至近距離の場合、ガード:射撃と打撃を重ねられると、しゃがみガードしてしまう。優先順位の変更が必要
	elseif (
	enemy_obj_range_in(150,20)==true or 
	(my_char==13 and caution_state_obj(817,272,200,1200,44,49)>=1 and caution_state_obj(817,168,200,1200,44,49)>=1)
	) and 
	weather~=13 and 
	get_special_data(0,10)<=20 then
		print("攻撃オブジェ：至近距離　＞　ガード");
		key_resetEX()
		key_on(d_back)
		

--▼移動▼
	--▼対台風時▼：逃げ　⇒　基本後退。近すぎる場合、７ＨＪ。画面端を背にしているなら８ＨＪ。一定以上なら飛び越える。ＨＪ後、相手がすぐに追ってきたら、即座に２飛翔。
	elseif weather==13 and my_act>=208 and my_act<=212 and y<=150 and enemy_act>=208 and enemy_act<=212 and y>ey and my_air==0 and dis<=150 and ((my_dir==1 and x<=200 and x<=ex) or (my_dir==-1 and x>=1080 and ex<=x)) then
		print("台風時：相手ＨＪ確認　⇒　切り替えし飛翔");
		key_event2(ACT_D,ACT_DOWN);
	elseif weather==13 and (
		(y>=ey+150 and enemy_yspeed<=0) or 
		(y<=ey-150 and enemy_yspeed>=0) or 
		(dis_y>=200 and enemy_act>=300)
	) and dis<=120 and my_air==0 and ((my_dir==1 and x<=200 and x<=ex) or (my_dir==-1 and x>=1080 and ex<=x)) then
		print("台風時：画面端　⇒　飛び越しor潜り抜け");
		key_event2(ACT_D,front);
	elseif weather==13 and y==0 and dis<=150 and ((my_dir==1 and x<=200 and x<=ex) or (my_dir==-1 and x>=1080 and ex<=x)) then
		print("台風時：画面端に追い詰められた　⇒　８ＨＪ");
		key_event2(ACT_D,ACT_UP);
	elseif weather==13 and y>0 and dis2<=300 and my_air==0 and ((my_dir==1 and ex>=400 and x<=ex) or (my_dir==-1 and ex<=880 and ex<=x)) and my_hp<enemy_hp then
		print("台風時：空中接近　⇒　７ＨＪ");
		lvr44();
	elseif weather==13 and y==0 and dis2<=300 and ((my_dir==1 and ex>=400 and x<=ex) or (my_dir==-1 and ex<=880 and ex<=x)) and my_hp<enemy_hp then
		print("台風時：地上接近　⇒　７ＨＪ");
		key_event2(ACT_D,u_back);
	elseif weather==13 and y==0 and dis2>300 and my_hp<enemy_hp then
--		print("台風時：地上非接近　⇒　後退");
		key_on(back);
	--▼通常時▼：
	elseif y>0 and dis<=120 and my_air==0 and 
	(
		(y>=ey+180 and enemy_yspeed<=0) or 
		(y<=ey-180 and enemy_yspeed>=0) or 
		(dis_y>=250 and enemy_act>=300)
	) and 
	my_backside<=200 then
		print("移動：通常時　空中：６飛翔");
		key_resetEX();
		key_event2(ACT_D,front);

	--▲組み込んだ汎用ガード＆グレイズ（※組み込み用）▲：既存設定上で無視しても、ここでキャッチする仕組み
			
			
			
	--etc...
	
	elseif (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=200) and (my_act<97 or my_act>99) and (enemy_act<97 or enemy_act>99) and (dis>=700 or (enemy_act~=197 and enemy_act~=198 and enemy_act~=199) or (enemy_act==197 and (stand_front - 9)<=enemy_allframe) or (enemy_act==198 and (stand_back - 9)<=enemy_allframe) or (enemy_act==199 and (stand_neutral- 9)<=enemy_allframe)) and (my_limit<100 or (my_limit>=100 and dis>=700)) then
		if battle_time<180 then
			--print("開幕");
			kaimaku();
		elseif caution_atk>0 then
			--print("警戒");
			keikai();
		elseif is_dir_front then
			--print("各距離行動");
			en();
			tyuu();
			kin();
			kuusekkinn();
			titisekkinn();
			tikuusekkinn();
		else
			--print("裏向き行動");
			ura();
		end --]]
		

		
		
		
	end	
end


















function reimu()
--対霊夢
kihon();

--無敵スペルカード所有判定
	if enemy_card==214 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2)) then
		muteki_sp = 2;
	elseif enemy_card==206 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2)) then
		muteki_sp = 1;
	else
		muteki_sp = 0;
	end
--無敵必殺技所有判定
	if weather==9 then
		muteki = 1;
	else
		muteki = 0;
	end
--亜空穴使用判定
	if enemy_card==206 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2)) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--対空行動可能判定の解除
	if enemy_act~=306 and enemy_act~=307 and enemy_act~=308 and enemy_act~=309 and air_atk==1 then
		air_atk = 0;
	end
--obj警戒・警醒陣。判定発生前のエフェクトの状態からグレイズ用意
	if enemy_act>=520 and enemy_act<=523 then
		caution_obj = 20;
	end
--警戒・起き上がりMAX昇天脚。移動起きから出すのは少し難しいので、移動起き時は警戒率を下げてみる
	if dis<300 and muteki==1 and ((enemy_act==197 and enemy_allframe==45 and math.random(4)==1) or (enemy_act==198 and enemy_allframe==45 and math.random(4)==1) or (enemy_act==199 and enemy_allframe==24 and math.random(3)==1)) then
		caution_atk = 3 + math.random(5);
	end
--警戒・疎雨昇天脚
	if weather==9 and (dis<200 or (my_xspeed>=6 and dis<350)) and (ey==0 or (ey<150 and enemy_yspeed<-4)) and (enemy_act<=10 or (enemy_act>=200 and enemy_act<=214) or (enemy_act>=150 and enemy_act<=170)) and caution_atk==0 and enemy_rei>=200 and math.random(25)==1 then
		caution_atk = 3 + math.random(5);
	end
--警戒・天覇風神脚
	if weather~=13 and (dis<200 or (my_xspeed>=6 and dis<300)) and y<150 and (ey==0 or (ey<150 and enemy_yspeed<-4)) and (enemy_act<=10 or (enemy_act>=200 and enemy_act<=214) or (enemy_act>=150 and enemy_act<=170)) and caution_atk==0 and enemy_card==214 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2)) and math.random(40)==1 then
		caution_atk = 3 + math.random(8);
	end
--警戒・八方鬼縛陣
	if weather~=13 and (dis<300 or (my_xspeed>=6 and dis<400)) and (ey==0 or (ey<150 and enemy_yspeed<-4)) and (enemy_act<=10 or (enemy_act>=200 and enemy_act<=214) or (enemy_act>=150 and enemy_act<=170)) and caution_atk==0 and enemy_card==206 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2)) and math.random(40)==1 then
		caution_atk = 3 + math.random(8);
	end
--警戒・夢想天生
	if weather~=13 and (dis<400 or (my_xspeed>=6 and dis<500)) and (ey==0 or (ey<150 and enemy_yspeed<-4)) and (enemy_act<=10 or (enemy_act>=200 and enemy_act<=214) or (enemy_act>=150 and enemy_act<=170)) and caution_atk==0 and caution_time>0 and math.random(30)==1 then
		caution_atk = 5 + math.random(20);
	end
--近距離でガード硬直中に5Bか2Bを撃たれたらしゃがむ。次の低空J6Aを回避出来るかも
	if dis<300 and (((my_act==150 or my_act==154) and my_frame<=6) or ((my_act==151 or my_act==155) and my_frame<=12) or ((my_act==152 or my_act==156) and my_frame<=18) or ((my_act==153 or my_act==157) and my_frame<=24)) and (enemy_act==400 or enemy_act==402) then
		key_on(ACT_DOWN);
		key_on(back);
	end

--下段ガード汎用
	if weather~=13 and ((dis<=150 and (enemy_act==320 or enemy_act==300 or enemy_act==330) and y<=20) or 
	(dis<=250 and enemy_act==505 and math.abs(ey-y)<150) or 
	(dis<=400 and (enemy_act==565 or enemy_act==566) and math.abs(ey-y)<150)) then
		c_guard();

--中段ガード汎用
	elseif weather~=13 and dis<=200 and enemy_act==321 and y<=20 and enemy_frame<=16 then
		s_guard()

--遠A。リーチが長い。
	elseif weather~=13 and dis<=300 and enemy_act==301 and y<=20 and enemy_frame<=16 then
		s_guard()
--2A。対策しないと冗談抜きに2Aだけで死ぬ。先端部分は誤ガードや後退で間合いを離す。空振りには射撃でカウンター。
	elseif weather~=13 and (my_dir+enemy_dir)==0 and dis<=320 and enemy_act==303 and y<=20 and enemy_frame<=29 then
		c_guard()
	elseif weather~=13 and is_dir_front and dis<=320 and dis>270 and enemy_act==303 and y<=20 and my_act<=5 and my_frontside>1000 and (enemy_frame<=5 or enemy_frame>27) then
		if math.random(2)==1 then
			key_reset();
			key_event2(ACT_D,ACT_UP)
		else
			key_reset();
			key_on(front);
			key_event2(ACT_D,ACT_UP)
		end	
	elseif weather~=13 and is_dir_front and dis<=400 and dis>320 and enemy_act==303 and y<=20 and my_act<=5 and enemy_frame<=7 then
		key_reset();
		key_event2(ACT_B,ACT_DOWN)
--3A。通常は立ちガード、溜めは下段ガード。
	elseif weather~=13 and enemy_act==304 and my_act==152 and my_frame==1 and muteki_sp==2 and math.random(2)==1 then
		key_on(back);
		caution_atk = 30 + math.random(10);
	elseif weather~=13 and dis<=300 and enemy_act==304 and enemy_allframe<25 and (ey-y)<250 and (y-ey)<250 and enemy_img>=97 and enemy_img<=106 then
		s_guard()
	elseif weather~=13 and dis<=400 and enemy_act==304 and y==0 and enemy_allframe>=10 and enemy_allframe<55 and (enemy_img==99 or enemy_img==105 or (enemy_img>=132 and enemy_img<=135)) then
		c_guard()
--6A。強判定かつ持続するので終わるまで我慢。結界設定あり
	elseif weather~=13 and dis<=300 and enemy_act==302 and (my_act<=5 or my_act==200) and enemy_frame<=2 and (enemy_preact[1]==306 or enemy_preact[2]==306 or enemy_preact[1]==400 or enemy_preact[2]==400 or enemy_preact[1]==402 or enemy_preact[2]==402) and math.random(3)==1 then
		if dis<250 and my_act==200 and my_allframe<15 and enemy_frame<2 then
			key_on(ACT_D);
			key_event2(ACT_A,front)
		elseif dis<100 and (my_act==200 and my_frame>=15) or my_act==204 then
			key_reset();
			key_event(ACT_A);
		else
			key_reset();
			yield();
			key_event2(ACT_A,ACT_DOWN);
		end
	elseif weather~=13 and dis<=400 and enemy_act==302 and my_act==152 and my_frame==19 and (muteki>=1 or muteki_sp>=1) and math.random(2)==1 then
		key_on(back);
		caution_atk = 15 + math.random(15);
	elseif weather~=13 and dis<=350 and enemy_act==302 and y<=20 and enemy_frame<=28 then
		s_guard()
--前ダッシュ。DCが厄介過ぎるので空中かつ低空に居たら警戒する
	elseif weather~=13 and (my_dir+enemy_dir)==0 and dis<=400 and dis>100 and y>50 and y<220 and enemy_act==200 then
		key_on(back);
		key_on(ACT_DOWN);
--前ダッシュ終了モーション。近距離なら確率的に警戒
	elseif weather~=13 and (my_dir+enemy_dir)==0 and dis<=200 and dis>100 and y==0 and enemy_act==204 and enemy_frame==0 and math.random(2)==1 then
		caution_atk = 5 + math.random(20);
--DA。前進するのでガード距離を多めに取る。ガード後は3フレーム有利なので色々やってみる。
	elseif weather~=13 and dis<=270 and enemy_act==305 and y<=20 and enemy_frame>12 and my_act==152 and my_frame==19 and math.random(3)<=2 then
		if muteki_sp>=1 and math.random(2)==1 then
			caution_atk = 5 + math.random(20);
		elseif math.random(5)<=2 then
			key_reset();
			key_event2(ACT_A,ACT_DOWN);
		else
			key_on(back);
			caution_atk = 5 + math.random(20);
		end
	elseif weather~=13 and dis<=350 and enemy_act==305 and y<=20 and enemy_frame<=12 then
		s_guard()
--DB。めり込めば9F有利なので反撃可能。
	elseif weather~=13 and dis<=80 and enemy_act==408 and y==0 and my_act==156 and my_frame==19 then
		if muteki_sp==2 and math.random(3)<=2 then
			key_on(back);
			caution_atk = 5 + math.random(20);
		else
			key_reset();
			key_event(ACT_A);
		end
	elseif weather~=13 and dis<=400 and enemy_act==408 and y<=20 then
		c_guard()
--DC。グレイズ+強判定+高速発生。ガードか回避出来れば反撃可能。
	elseif weather~=13 and dis<=80 and enemy_act==418 and (ey-y)<250 and (y-ey)<200 and enemy_allframe>=36 then
		key_reset();
		key_event(ACT_A);
	elseif weather~=13 and dis<=230 and enemy_act==418 and (ey-y)<250 and (y-ey)<200 and enemy_allframe>=36 then
		key_reset();
		key_event2(ACT_A,ACT_DOWN);
	elseif weather~=13 and dis<=350 and enemy_act==418 and (ey-y)<250 and (y-ey)<200 and enemy_allframe<24 then
		s_guard()
--AAAA。ディレイに釣られないようガード距離はしっかりと取る。
	elseif weather~=13 and dis<=400 and enemy_act==322 and my_act==152 and my_frame==19 and muteki_sp>=1 and math.random(2)==1 then
		key_on(back);
		caution_atk = 15 + math.random(15);
	elseif weather~=13 and dis<=350 and enemy_act==322 and y==0 and enemy_frame<=29 then
		key_on(back);
--JA。伝統と実績の超判定。
	elseif weather~=13 and enemy_act==306 and enemy_allframe>48 then
		enemy_preact[1] = 0;
		air_atk = 0;
	elseif weather~=13 and enemy_act==306 and enemy_allframe>20 and my_act~=151 and my_preact[1]~=151 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and dis<=400 and enemy_act==306 and my_act<=5 and ey>20 and (enemy_allframe>20 or (ey>200 and enemy_yspeed>-3 and enemy_allframe>15)) and enemy_allframe<48 and my_act~=151 and my_preact[1]~=151 then
		caution_atk = 0;
		if ey>170 and dis<120 and enemy_xspeed>0 and enemy_yspeed>-4 then
			key_reset();
			key_event2(ACT_D,ACT_UP);
		elseif ey>170 and enemy_yspeed>-4 then
			key_reset();
			key_on(front)
			key_event2(ACT_D,ACT_UP);
		elseif dis<300 and ey<170 and ey>100 and enemy_yspeed<=0 then
			key_reset();
			key_on(ACT_D)
			key_event2(ACT_A,front);
		elseif dis<200 and ey<100 and enemy_yspeed<-2 then
			key_reset();
			yield();
			key_event2(ACT_A,ACT_DOWN);
		end
	elseif weather~=13 and (my_dir+enemy_dir)==0 and is_dir_front and dis<(180+enemy_xspeed*15) and (dis>(70+enemy_xspeed*13) or my_frontside>1180) and ey<=(230-enemy_yspeed*15) and ey>=(90-enemy_yspeed*10) and y==0 and (my_act<=5 or (my_act>=150 and my_act<=170) or ((my_preact[1]>=150 and my_preact[1]<=170)) and ((enemy_act==306 or enemy_act==308) and (enemy_preact[1]==202 or enemy_preact[1]==214 or enemy_preact[2]==214))) and enemy_xspeed>5 and enemy_yspeed<3 and math.random(5)==1 then
		key_reset();
		lvr623(ACT_B);
	elseif weather~=13 and (dis<=(240+enemy_xspeed*10) or (enemy_frontside>1150 and dis<240)) and enemy_act==306 and (ey-y)<220 and (y-ey)<150 and enemy_allframe<=20 then
		key_on(back);
--J6A。刺さると痛いのでちょっと大きめに定義。端の低空J6Aは放って置くと割られるのでしゃがみ避けか前ダッシュ、結界で抜ける
	elseif weather~=13 and enemy_act==307 and enemy_frame>22 and my_act~=152 and my_preact[1]~=152 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and dis<=400 and enemy_act==307 and my_act<=5 and ey>50 and enemy_frame>22 and my_act~=152 and my_preact[1]~=152 then
		caution_atk = 0;
		if is_dir_front and ((ey<140 and dis>100) or ey<100) and dis<300 and enemy_yspeed<=0 then
			key_reset();
			key_on(ACT_D)
			key_event2(ACT_A,front);
		end
	elseif weather~=12 and dis<150 and enemy_act==307 and my_act==152 and my_hitstop==4 and (x<100 or x>1180) and (weather==0 or weather==8 or (my_rmax==1000 or my_rei<350)) and math.random(4)<=3 then
		key_reset();
		if math.random(2)==1 then
			key_on(front);
			caution_atk = 20 + math.random(30);
		else
			key_on(ACT_DOWN);
			caution_atk = 25 + math.random(35);	
		end
		key_event(ACT_D)
		key_event(ACT_D)
		key_reset();
	elseif weather~=13 and dis<=350 and enemy_act==307 and (ey-y)<140 and (y-ey)<220 and enemy_frame<=22 then	
		if (ey>90 or (((enemy_preact[1]>=6 and enemy_preact[1]<=8) or (enemy_preact[1]>=208 and enemy_preact[1]<=212)) and enemy_preact[1]==enemy_preact[2] and enemy_preframe[1]>=1)) and ((enemy_frame<3 and (my_act==0 or my_act==3 or my_act==4 or my_act==5)) or (my_act<=154 and my_act>=157) or my_act==1 or my_act==2) then
			key_on(back);
			key_on(ACT_DOWN)
		else
			key_on(back);
			yield();
		end
--J2A。発生は遅いが強判定。CHが怖い
	elseif weather~=13 and enemy_act==308 and enemy_allframe>50 then
		enemy_preact[1] = 0;
		air_atk = 0;
	elseif weather~=13 and enemy_act==308 and enemy_allframe>23 and my_act~=152 and my_preact[1]~=152 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and dis<=300 and enemy_act==308 and (ey-y)<250 and (y-ey)<50 and enemy_allframe<=23 then
		key_on(back);
--J8A。発生が速く何気に怖い技
	elseif weather~=13 and enemy_act==309 and enemy_frame>14 and my_act~=152 and my_preact[1]~=152 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and dis<=300 and enemy_act==309 and (ey-y)<100 and (y-ey)<300 and enemy_frame<=14 then
		key_on(back);
--●組込み：雨乞祈り。とりあえずガード。
	elseif weather~=13 and dis<=300 and enemy_act>=570 and enemy_act<=573 and (ey-y)<100 and (y-ey)<300 and enemy_allframe>=20 then
		key_on(back);
--●封魔陣
	elseif weather~=13 and dis<=300 and enemy_act==604 and (ey-y)<100 and (y-ey)<300 and enemy_allframe>=56 then
		key_on(back);
--●拡散結界
	elseif weather~=13 and dis<=300 and (enemy_act==607 or enemy_act==657) and (ey-y)<100 and (y-ey)<300 and enemy_allframe>=80 then
		key_on(back);

--亜空穴B。なるべく後退やバクステで回避。後退でかわしたら2Aを刺す。空中に居る時に出されたらJAで迎撃。でもよく失敗する。
	elseif weather~=13 and enemy_act==540 and enemy_allframe>77 then
		enemy_preact[1] = 0;
	elseif weather~=13 and enemy_act==540 and y==0 and ((ey>0 and ey<=30 and dis>100) or (enemy_allframe>=63 and enemy_allframe<68)) and dis<=250 then
		key_reset();
		key_event2(ACT_A,ACT_DOWN);
	elseif weather~=13 and enemy_act==540 and y==0 then
		if is_dir_front and my_frontside>1100 and enemy_allframe==25 and my_act<=5 then
			key_reset();
			lvr623(ACT_C);
		else
			key_on(back);
		end
	elseif weather~=13 and enemy_act==540 and y==0 and (my_act==400 or my_act==402 or my_act==410 or my_act==500 or my_act==520) then
		key_reset();
		key_event2(ACT_D,back);
	elseif weather~=13 and enemy_act==540 and y>=20 and (my_act==404 or my_act==406 or my_act==414 or my_act==502 or my_act==522) then
			print("４４");
		key_reset();
		key_event(back);
		key_event(back);
	elseif weather~=13 and enemy_act==540 and dis<100 and y>0 and enemy_allframe>20 then
		key_on(back);
		wait(10);
	elseif weather~=13 and enemy_act==540 and dis>100 and dis<=300 and y>=200 and enemy_allframe>=15 and enemy_allframe<=30 then
		if enemy_allframe<=20 and my_rei>=200 then
			key_reset();
			key_event(ACT_B);
			wait(18);
		elseif dis<200 and enemy_allframe>20 then
			key_reset();
			key_event(ACT_A);
		end
--亜空穴C。ガード後は8F有利なので反撃。必ずめり込むので川霧でもない限り入るはず。裏周りになったらガードを解く。
	elseif weather~=13 and dis<=100 and enemy_act==541 and my_act==156 and my_frame==19 then
		if muteki_sp==2 and math.random(3)<=2 then
			key_on(back);
			caution_atk = 5 + math.random(20);
		else
			key_reset();
			key_event(ACT_A);
		end
	elseif weather~=13 and (my_dir+enemy_dir)==0 and dis<=300 and enemy_act==541 and (ey-y)<150 and (y-ey)<150 then
		c_guard()
--昇天脚B。間合いを詰めて反撃。空中ガードだとちょっと間に合わないかも。
	elseif weather~=13 and enemy_act==560 then
		if enemy_allframe>67 then
			enemy_preact[1] = 0;
		elseif dis<=400 and (ey-y)<300 and (y-ey)<300 and enemy_allframe<=20 then
			key_on(back);
		elseif y==0 then
			if dis>500 and enemy_allframe>=20 and my_rei>=200 then
				key_reset();
				key_event(ACT_B);
			elseif dis<350 and dis>150 and my_act<=9 and enemy_allframe>20 and enemy_allframe<=30 and weather==5 then
				key_reset();
 				key_on(ACT_B);
				wait(30);
			elseif dis<=500 and dis>350 and enemy_allframe>20 and enemy_allframe<=30 then
				key_reset();
				key_on(front);
			elseif ((dis<=500 and enemy_allframe>30) or (dis<=350 and enemy_allframe>35)) and dis>200 and enemy_allframe<43 then
				key_reset();
				key_on(ACT_D);
				key_on(front);
			elseif dis<=200 and enemy_allframe>20 and enemy_allframe<43 then
				key_reset();
				key_on(front);
			elseif is_dir_front and dis<200 and (my_act<=5 or my_act==200 or my_act==204) and enemy_allframe>=43 and weather==5 then
				key_reset();
  				key_event2(ACT_B,ACT_DOWN);
			elseif is_dir_front and (dis<=70 or (my_act==200 and dis<90)) and enemy_allframe>=43 then
				if my_act==200 then
					key_reset();
					yield();
					key_event(ACT_A);
				else
					key_reset();
					key_event(ACT_A);
				end
			elseif is_dir_front and dis<=250 and enemy_allframe>=48 then
				if my_act<=5 or my_act==200 then
					key_reset();
					key_on(ACT_D)
					key_on(front)
					key_event2(ACT_A,front)
				elseif my_act==204 then
					key_reset();
					key_on(ACT_DOWN)
					yield();
					key_event(ACT_A)
				end
			end
		elseif y>20 then
			if dis<250 and dis>70 and my_act~=214 and enemy_allframe>20 and y>200 and my_rei>=200 then
				key_reset();
				key_on(ACT_D);
				key_on(ACT_DOWN);
			elseif dis<=400 and dis>150 and my_act~=214 and y<400 and y>80 and enemy_allframe>20 and enemy_allframe<38 then
				key_reset();
				key_on(ACT_D);
				key_on(front);
				key_on(ACT_DOWN);
			elseif is_dir_front and dis<170 and y<200 and y>80 and my_act~=306 and enemy_allframe>=43 then
				key_reset();
				key_event(ACT_A);
			elseif y<80 then
				key_reset();
			end
		end
--昇天脚C。間合いを詰めて反撃。空中ガードでも間に合うはず。
	elseif weather~=13 and enemy_act==561 then
		if enemy_allframe>89 then
			key_reset();
			key_on(back);
			enemy_preact[1] = 0;
			yield();
		elseif dis<=500 and (ey-y)<500 and (y-ey)<500 and enemy_allframe<=23 then
			key_on(back);
		elseif y==0 then
			if dis>500 and enemy_allframe>23 and my_rei>=200 then
				key_reset();
				key_event(ACT_B);
			elseif dis<=500 and dis>200 and enemy_allframe>38 and enemy_allframe<60 then
				key_reset();
				key_on(ACT_D);
				key_on(front);
			elseif dis<=500 and enemy_allframe>23 and enemy_allframe<70 then
				key_reset();
				key_on(front);
				yield();
			elseif is_dir_front and dis<200 and (my_act<=5 or my_act==200 or my_act==204) and enemy_allframe>=70 and weather==5 then
				key_reset();
 				key_event2(ACT_B,ACT_DOWN);
			elseif dis<150 and my_act==200 then
				key_reset();
				yield();
			elseif is_dir_front and (dis<=80 or (my_act==200 and dis<90)) and enemy_allframe>=70 then
				if my_act==200 then
					key_reset();
					yield();
					key_event(ACT_A);
				else
					key_reset();
					key_event(ACT_A);
				end
			elseif is_dir_front and dis<=250 and dis>80 and enemy_allframe>=75 then
				if my_act<=5 or my_act==200 then
					key_reset();
					key_on(ACT_D)
					key_on(front)
					key_event2(ACT_A,front)
				elseif my_act==204 then
					key_reset();
					key_on(ACT_DOWN)
					yield();
					key_event(ACT_A)
				end
			end
		elseif y>20 then
			if dis<250 and dis>70 and my_act~=214 and enemy_allframe>23 and y>200 and my_rei>=200 then
				key_reset();
				key_on(ACT_D);
				key_on(ACT_DOWN);
			elseif dis<=500 and dis>150 and my_act~=214 and y<400 and y>80 and enemy_allframe>=23 and enemy_allframe<70 then
				key_reset();
				key_on(ACT_D);
				key_on(front);
				key_on(ACT_DOWN);
			elseif is_dir_front and dis<170 and y<200 and y>80 and my_act~=306 and enemy_allframe>=70 then
				key_reset();
				key_event(ACT_A);
			elseif y<80 then
				key_reset();
			end
		end
--●刹那亜空穴。空振りを確認したら当身持続時間の25Fまで我慢。当身の出始めには気付かない設定なので、当身自体にはよくAを振って引っ掛かる。⇒　改変：出始めに気づくようにしました
	elseif weather~=13 and dis<=500 and enemy_act==550 and enemy_frame>0 and enemy_frame<=25 then
		key_on(back);
		key_on(ACT_DOWN);
--天覇風神脚。無敵技なのでAIの都合上食らいまくるが、もしガード出来たら反撃するかもしれない。
	elseif weather~=13 and enemy_act==614 then
		if (my_dir+enemy_dir)~=0 and y==0 and my_act<=5 and enemy_allframe<=110 then
			key_reset();
			key_on(front);
		elseif dis<=700 and dis>300 and (ey-y)<300 and (y-ey)<300 and enemy_allframe<=110 then
			key_on(ACT_DOWN)
			key_on(back);
		elseif dis<=300 and (ey-y)<300 and (y-ey)<300 and enemy_allframe<=110 then
			key_on(back);
		elseif y==0 then
			if dis>500 and enemy_allframe>73 and enemy_allframe<140 then
				key_reset();
				key_event(ACT_B);
			elseif dis<=500 and dis>150 and enemy_allframe>110 and enemy_allframe<140 then
				key_reset();
				key_on(ACT_D);
				key_on(front);
			elseif dis<=500 and enemy_allframe>110 and enemy_allframe<140 then
				key_reset();
				key_on(front);
			elseif is_dir_front and (dis<=80 or (my_act==200 and dis<90)) and enemy_allframe>=140 then
				if my_act==200 then
					key_reset();
					yield();
					key_event(ACT_A);
				else
					key_reset();
					key_event(ACT_A);
				end
			elseif is_dir_front and dis<=250 and enemy_allframe>=140 then
				if my_act<=5 or my_act==200 then
					key_reset();
					key_on(ACT_D)
					key_on(front)
					key_event2(ACT_A,front)
				elseif my_act==204 then
					key_reset();
					key_on(ACT_DOWN)
					yield();
					key_event(ACT_A)
				end
			end
		elseif y>20 then
			if dis<250 and dis>70 and my_act~=214 and enemy_allframe>140 and y>200 and my_rei>=200 then
				key_reset();
				key_on(ACT_D);
				key_on(ACT_DOWN);
			elseif dis<=400 and dis>70 and my_act~=214 and y<400 and y>50 and enemy_allframe>110 and enemy_allframe<140 then
				key_reset();
				key_on(ACT_D);
				key_on(front);
				key_on(ACT_DOWN);
			elseif is_dir_front and dis<170 and y<200 and y>80 and my_act~=306 and enemy_allframe>=140 then
				key_reset();
				key_event(ACT_A);
			elseif y<80 then
				key_reset();
			end
		end
--八方鬼縛陣。地上ならグレイズ突破、空中なら後方へ退避。磨耗が少ないので霊力が続く限り目一杯グレイズ
	elseif dis<=700 and enemy_act==606 and enemy_allframe<=180 then
		if y==0 and my_rei>(200-enemy_allframe) and (my_act<=10 or my_act==200 or my_act==204) then
			key_reset();
			key_on(front);
			key_on(ACT_D);
		elseif y==0 and (my_act==400 or my_act==401 or my_act==402 or my_act==410 or my_act==412 or my_act==500) then
			key_reset();
			key_on(back);
			key_on(ACT_UP);
		elseif y>=20 and (my_act==404 or my_act==406 or my_act==414 or my_act==416 or my_act==502) then
			if ((x>140 and my_dir==1) or (x<1140 and my_dir==-1)) then
				key_reset();
				key_on(back);
				key_on(ACT_D);
			elseif dis<=100 and y>120 then
				key_reset();
				key_on(front);
				key_on(ACT_D);	
			else
				key_reset();
				key_on(back);
			end	
		elseif dis<350 and y>=50 and my_act==214 and my_xspeed>0 then
			key_reset();
			key_on(back)
		elseif dis<350 and y>=50 and (my_act~=210 or (my_act==210 and my_allframe>20)) then
			if ((x>140 and my_dir==1) or (x<1140 and my_dir==-1)) then
				key_reset();
				key_on(back);
				key_on(ACT_D);
			elseif dis<=100 and y>120 then
				key_reset();
				key_on(front);
				key_on(ACT_D);	
			else
				key_reset();
				key_on(back);
			end		
		elseif dis<300 then
			key_on(back);
		elseif dis>300 and y>=50 then
			key_reset();
		end
--夢想天生。発動モーション+持続時間でとりあえず1000F警戒。台風天生はやめてくださいしんでしまいます
	elseif enemy_act==619 and caution_time==0 then
		caution_time = 1000;
--5B。6A等から連続ガード。ガード後にグレイズ行動を取ると狩られやすいので確率的にグレイズ禁止
--	elseif nograze==0 and dis<500 and enemy_act==400 and enemy_img~=414 and enemy_img~=415 and caution_graze==0 then
--		graze();
	elseif nograze==0 and dis<500 and enemy_act==400 and enemy_img~=414 and enemy_img~=415 and caution_graze>0 then
		key_reset();
		key_on(back);
		key_on(ACT_DOWN);
--2B。発生が速く連続ガードになりやすい。ガード後にグレイズ行動を取ると狩られやすいので確率的にグレイズ禁止
	elseif enemy_act==402 and enemy_allframe>36 then
		enemy_preact[1] = 0;
	elseif dis<500 and enemy_act==402 and enemy_allframe>10 and (my_act==152 or my_act==156) and my_frame==1 and math.random(3)<=2 then
		caution_graze = 25 + math.random(20);
		caution_atk = 15 + math.random(20);	
--	elseif dis<500 and enemy_act==402 and (enemy_allframe<30 or weather==5) and y<=100 and caution_graze==0 then
--		graze();
--5C。普通に殴り掛かると残り物を被弾しやすいのでDCで蹴り飛ばす
	elseif dis<150 and (my_act==200 or my_act==204) and enemy_act==410 and enemy_allframe<=35 and weather~=5 then
		if muteki_sp>=1 and math.random(2)==1 then
			key_reset();
			key_on(back);
			caution_atk = 15 + math.random(15);
			caution_graze = caution_atk;
		else
			key_reset();
			lvr623(ACT_C);
		end
--2C。上に飛ぶ射撃技は汎用のグレイズ処理だと殴れないので、これもDCで蹴り飛ばす
	elseif dis<150 and (my_act==200 or my_act==204) and enemy_act==412 and enemy_allframe<=39 and weather~=5 then
		if muteki_sp>=1 and math.random(2)==1 then
			key_reset();
			key_on(back);
			caution_atk = 15 + math.random(15);
			caution_graze = caution_atk;
		else
			key_reset();
			lvr623(ACT_C);
		end

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=500 and ((enemy_act==414 and enemy_img~=333) or (enemy_act==416 and enemy_img~=333) or enemy_act==412 or enemy_act==410 or enemy_act==401 or (enemy_act==404 and enemy_img~=333) or (enemy_act==406 and enemy_img~=335) or (enemy_act>=500 and enemy_act<=531 and enemy_img~=333) or enemy_act==600 or enemy_act==601 or enemy_act==606 or enemy_act==608 or enemy_act==609)) or 
	(enemy_act==530 or enemy_act==531 or enemy_act==520 or enemy_act==521 or enemy_act==545 or enemy_act==546 or enemy_act==610 or enemy_act==669) or 
	enemy_obj_range_in(150,60)==false and (enemy_act~=402 or (enemy_act==402 and (dis>500 or weather==5)) and (caution_time==0 or (caution_time>0 and dis>400))) or
	(caution_obj>0 and obj_dis2<100))then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function marisa()
--対魔理沙
kihon();

--無敵スペルカード所有判定
	if enemy_card==206 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2)) then
		muteki_sp = 2;
	else
		muteki_sp = 0;
	end
--亜空穴使用判定
	if (enemy_card==200 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2))) or
	((enemy_card==202 or enemy_card==203 or enemy_card==207) and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2))) or
	(enemy_card==206 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2))) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--警戒・起き上がりミアズマ。移動起きから出すのは少し難しいので、移動起き時は警戒率を下げてみる
	if dis<300 and muteki==1 and ((enemy_act==197 and enemy_allframe==43 and math.random(4)==1) or (enemy_act==198 and enemy_allframe==42 and math.random(4)==1) or (enemy_act==199 and enemy_allframe==27 and math.random(3)==1)) then
		caution_atk = 3 + math.random(10);
	end
--下段ガード
	if noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==320 or enemy_act==300 or enemy_act==330) and y<=20) or 
	(dis<=200 and (enemy_act==303) and math.abs(ey-y)<150) or 
	(dis<=400 and (enemy_act==304) and math.abs(ey-y)<150) or 
	(enemy_act==607)) then 
		c_guard()

--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==301 or enemy_act==306 or enemy_act==308 or enemy_act==309) and math.abs(ey-y)<300) or 
	(dis<=200 and (enemy_act==321) and math.abs(ey-y)<150) or 
	(dis<=250 and (enemy_act==307) and math.abs(ey-y)<350) or 
	(dis<=300 and (enemy_act==305 or enemy_act==322 or enemy_act==408 or enemy_act==418 or enemy_act==606 or enemy_act==695 or enemy_act==696) and math.abs(ey-y)<100) or 
	(dis<=400 and (enemy_act==302) and math.abs(ey-y)<250) or 
	(dis<=600 and (enemy_act==500) and math.abs(ey-y)<250) or 
	((enemy_act==605) and math.abs(ey-y)<250)) then 
		s_guard()

--ミアズマB
	elseif enemy_act==520 and enemy_allframe>80 then
		enemy_preact[1] = 0;
	elseif weather~=13 and enemy_act==520 and dis<=300 and (ey-y)<300 and (y-ey)<300 and enemy_allframe<=33 then
		key_on(back);
--ミアズマC
	elseif enemy_act==521 and enemy_allframe>100 then
		enemy_preact[1] = 0;
	elseif weather~=13 and enemy_act==521 and dis<=300 and (ey-y)<300 and (y-ey)<300 and enemy_allframe<=33 then
		key_on(back);
--●マジカル産廃再利用ボム
--●恋符「ノンディレクショナルレーザー」
--●星符「グラビティビート」
--●光符「アースライトレイ」
--●魔廃「ディープエコロジカルボム」
--●儀符「オーレリーズサン」：２枚目

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=350 and (enemy_act==400 or enemy_act==401 or enemy_act==402 or enemy_act==404 or enemy_act==406 or enemy_act==414 or enemy_act==416 or enemy_act==412 or enemy_act==410 or enemy_act==525 or enemy_act==526 or enemy_act==510 or enemy_act==542 or enemy_act==545 or enemy_act==560 or enemy_act==561 or enemy_act==562 or enemy_act==563 or enemy_act==608 or enemy_act==420  or enemy_act==422 or enemy_act==658)) or 
	(enemy_act==411 or enemy_act==415 or enemy_act==565 or enemy_act==566 or enemy_act==567 or enemy_act==568 or enemy_act==570 or enemy_act==571 or enemy_act==600 or enemy_act==611 or enemy_act==430 or enemy_act==432 or enemy_act==602 or enemy_act==603 or enemy_act==619) or 
	(enemy_act==540 and dis<450) or
	(enemy_act==541 and dis>500 and dis<750) or 
	enemy_obj_range_in(150,60)==false) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function sakuya()
--対咲夜
kihon();

--無敵スペルカード所有判定
	if enemy_card==202 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2)) then
		muteki_sp = 2;
	else
		muteki_sp = 0;
	end
--亜空穴使用判定
	if (enemy_card==202 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2))) or
	(enemy_card==205 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2))) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--近距離でガード硬直中に5Bか2Bを撃たれたらしゃがむ
	if dis<300 and (((my_act==150 or my_act==154) and my_frame<=6) or ((my_act==151 or my_act==155) and my_frame<=12) or ((my_act==152 or my_act==156) and my_frame<=18) or ((my_act==153 or my_act==157) and my_frame<=24)) and (enemy_act==400 or enemy_act==402) then
		key_on(ACT_DOWN);
		key_on(back);
	end
--下段ガード
	if noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==320 or enemy_act==300 or enemy_act==330) and y<=20) or 
	(dis<=250 and (enemy_act==303) and math.abs(ey-y)<150) or 
	(dis<=350 and (enemy_act==302) and math.abs(ey-y)<150)) then 
		c_guard()

--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==308 or enemy_act==309) and math.abs(ey-y)<300) or 
	(dis<=200 and (enemy_act==306 or enemy_act==321) and math.abs(ey-y)<200) or 
	(dis<=250 and (enemy_act==301 or enemy_act==305 or enemy_act==307 or enemy_act==500 or enemy_act==501 or enemy_act==502 or enemy_act==503) and math.abs(ey-y)<350) or 
	(dis<=300 and (enemy_act==322 or enemy_act==695 or enemy_act==696) and math.abs(ey-y)<150) or 
	(dis<=350 and (enemy_act==304) and math.abs(ey-y)<150) or 
	(dis<=450 and (enemy_act==418) and math.abs(ey-y)<250) or 
	(dis<=500 and (enemy_act==408) and math.abs(ey-y)<250)) then 
		s_guard()

--時符「咲夜特製ストップウォッチ」(壁際に追い詰められてからやられると弱い)
	elseif y==0 and enemy_act==609 then
		key_reset();
		key_on(ACT_D);
		key_event2(ACT_UP,back);
		key_off(ACT_D);

--「咲夜の世界」
	elseif enemy_act==604 then
		key_reset();
		key_on(ACT_D);
		key_on(ACT_UP);
		wait(75);
		key_reset();
		key_on(back);
		wait(130);
		
		
--●パラレルブレーン
--●プロペリングシルバー：グレイズはともかく、戻ってくる
--●スクウェアリコシェ：専用行動が必要
--●ミスディレクション
--●パーフェクトメイド
--●タイムパラドックス
--●時符「プライベートスクウェア」
--●時符「イマジナリバーチカルタイム」
--●時計「ルナダイアル」
--●幻葬「夜霧の幻影殺人鬼」
--●光速「Ｃ.　リコシェ」

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=350 and (enemy_act==400 or enemy_act==401 or enemy_act==402 or enemy_act==404 or enemy_act==406 or enemy_act==414 or enemy_act==416 or enemy_act==412 or enemy_act==410 or enemy_act==411 or enemy_act==415 or enemy_act==505 or enemy_act==506 or enemy_act==606)) or 
	(enemy_act==540 or enemy_act==541 or enemy_act==542 or enemy_act==543 or enemy_act==411 or enemy_act==415 or enemy_act==608 or enemy_act==602 or enemy_act==607 or enemy_act==605) or 
	(dis<=450 and (enemy_act==412)) or 
	enemy_obj_range_in(150,60)==false) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function alice()
kihon();

--無敵スペルカード所有判定
	if enemy_card==209 and (enemy_spell>=1000 or (enemy_spell>=500 and weather==2)) then
		muteki_sp = 1;
	else
		muteki_sp = 0;
	end
--亜空穴使用判定
	if (enemy_card==203 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2))) or
	(enemy_card==204 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2))) or
	(enemy_card==209 and (enemy_spell>=1000 or (enemy_spell>=500 and weather==2))) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--人形設置判定(暫定)。人形が置かれたら一時的に設置人形もグレイズ対象となる
	if (enemy_act>=410 and enemy_act<=416 and (enemy_frame==18 or enemy_frame==19)) or enemy_act>=500 then
		caution_obj = 90 ;
	end
--対空行動可能判定の解除
	if enemy_act~=306 and enemy_act~=307 and enemy_act~=308 and enemy_act~=309 and air_atk==1 then
		air_atk = 0;
	end
--和蘭人形。直撃よりは割られた方がマシなのでガード
	if weather~=13 and enemy_act==607 and enemy_allframe>40 then
		caution_atk = 160;
		if my_act<400 then
			caution_graze = 160;
		end
	end
--蓬莱人形。距離がある時はグレイズしない
	if weather~=13 and enemy_act==605 and y<20 and my_act<400 and (dis>400 or (dis>200 and my_rei<400)) then
		caution_graze = 20;
	end

--下段ガード
	if noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==320 or enemy_act==300 or enemy_act==330) and y<=20) or 
	(dis<=200 and (enemy_act==311 or enemy_act==303) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=600 and (enemy_act==418) and (ey-y)<150 and (y-ey)<150)) then 
		c_guard()

--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=200 and (enemy_act==321) and (ey-y)<350 and (y-ey)<350) or 
	(dis<=250 and (enemy_act==322) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=300 and (enemy_act==695 or enemy_act==696) and (ey-y)<150 and (y-ey)<250) or 
	(dis<=400 and (enemy_act==304 or enemy_act==545 or enemy_act==547) and (ey-y)<150 and (y-ey)<350) or 
	(dis<=450 and (enemy_act==546 or enemy_act==548) and (ey-y)<250 and (y-ey)<250) or 
	(dis<=600 and (enemy_act==408) and (ey-y)<150 and (y-ey)<350)) then 
		s_guard()

--遠A。射程自体は約400だが、とりあえず距離を取る意味で510。空振りには2Bでカウンター。
	elseif weather~=13 and dis>500 and dis<550 and enemy_act==301 and enemy_frame<30 and y==0 and my_act<=8 and graze_wide==0 and enemy_obj_range_in(150,60)==false then
		key_reset();
		key_event2(ACT_B,ACT_DOWN)
	elseif weather~=13 and dis<=510 and dis>130 and enemy_act==301 and enemy_frame<30 and (ey-y)<150 and (y-ey)<350 then
		key_on(back);
--6A。射程は遠Aとほぼ同じ。判定が分厚いので動こうとしたところによく刺さって死ぬ。
	elseif weather~=13 and dis<=510 and dis>160 and enemy_act==302 and enemy_frame<22 and (ey-y)<250 and (y-ey)<250 then
		key_on(back);
--前ダッシュ。DAとDB対策で速めのガード
	elseif weather~=13 and dis<400 and dis>300 and enemy_act==200 and y==0 then
		key_on(back);
		key_on(ACT_DOWN);
--DA。アリスキック。正ガードで1F有利。近Aの発生差を含めて2F有利。なのでガード後密着かつ人形設置判定が0なら暴れてみる
	elseif weather~=13 and dis<=300 and enemy_act==305 and my_act==152 and y<=20 and my_frame==19 then
		if dis<80 and enemy_frame==28 and graze_wide==0 and enemy_obj_range_in(150,60)==false then
			key_reset();
			key_event(ACT_A);
		else
			key_on(back)
			key_on(ACT_DOWN);
			wait(12);
		end
	elseif dis<=300 and enemy_act==305 and enemy_frame<14 and y==0 then
		key_on(back);
--JA
	elseif weather~=13 and enemy_act==306 and enemy_frame>14 and my_act~=151 and my_preact[1]~=151 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and dis<250 and enemy_act==306 and enemy_frame<14 and (ey-y)<170 and (y-ey)<170 then
		key_on(back);
--J6A。射程は約350だが、ジャンプ慣性を考慮して480。内側の判定が厚いので密着でないとすかせない。
	elseif weather~=13 and enemy_act==307 and enemy_frame>20 and my_act~=152 and my_preact[1]~=152 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and is_dir_front and dis<=550 and dis>450 and enemy_act==307 and enemy_frame<20 and ey<250 and my_act<=10 and my_rei>=400 then
		key_reset();
		key_event(ACT_B);
	elseif weather~=13 and is_dir_front and dis<=400 and enemy_act==307 and ((ey>250 and enemy_frame>=12) or enemy_frame>=28) and ey<400 and my_act<=5 then
		if dis<80 and ey>150 and enemy_frame<=40 and graze_wide==0 then
			key_reset();
			key_event2(ACT_C,ACT_DOWN);	
		elseif dis<300 and ey>150 and enemy_frame<=40 and graze_wide==0 then
			key_reset();
			key_event2(ACT_B,front);
		elseif dis<250 and ey<80 and enemy_frame>=28 and graze_wide==0 then
			key_reset();
			key_on(ACT_D);
			key_on(front);
			yield();
			key_event2(ACT_A,front);	
		elseif ey>150 and enemy_frame>=28 then
			key_reset();
			key_on(ACT_D)
			key_event2(ACT_UP,front);
		end
	elseif weather~=13 and dis<=480 and dis>90 and enemy_act==307 and enemy_frame<28 and (ey-y)<250 and (y-ey)<250 then
		key_on(back);
--J2A。発生が遅く持続があるので引っ掛かりやすい
	elseif weather~=13 and enemy_act==308 and enemy_allframe>50 then
		enemy_preact[1] = 0;
		air_atk = 0;
	elseif weather~=13 and enemy_act==308 and enemy_allframe>25 and my_act~=152 and my_preact[1]~=152 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and is_dir_front and dis<=450 and dis>350 and enemy_act==308 and enemy_allframe<25 and ey<250 and my_act<=10 and my_rei>=400 and graze_wide==0 and enemy_obj_range_in(150,60)==false then
		key_reset();
		key_event(ACT_B);
	elseif weather~=13 and is_dir_front and dis<=400 and enemy_act==308 and enemy_allframe>=34 and ey<400 and my_act<=5 then
		if dis<300 and ey>150 and enemy_allframe<=40 and graze_wide==0 then
			key_reset();
			key_event2(ACT_B,front);
		elseif dis<250 and ey<80 and enemy_allframe>=34 and graze_wide==0 then
			key_reset();
			key_on(ACT_D);
			key_on(front);
			yield();
			key_event2(ACT_A,front);	
		elseif ey>150 and enemy_allframe>=34 then
			key_reset();
			key_on(ACT_D)
			key_event2(ACT_UP,front);
		end
	elseif weather~=13 and dis<=320 and dis>50 and enemy_act==308 and enemy_allframe>5 and enemy_allframe<34 and (ey-y)<300 and (y-ey)<150 then
		key_on(back);
--J8A。発生が遅く持続があるので引っ掛かりやすい
	elseif weather~=13 and enemy_act==309 and enemy_allframe>62 then
		enemy_preact[1] = 0;
		air_atk = 0;
	elseif weather~=13 and enemy_act==309 and enemy_frame>30 and my_act~=152 and my_preact[1]~=152 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and is_dir_front and dis<=450 and dis>350 and enemy_act==309 and enemy_allframe<30 and ey<250 and my_act<=10 and my_rei>=400 and graze_wide==0 and enemy_obj_range_in(150,60)==false then
		key_reset();
		key_event(ACT_B);
	elseif weather~=13 and is_dir_front and dis<=400 and enemy_act==309 and enemy_allframe>=29 and ey<400 and my_act<=5 then
		if dis<300 and ey>150 and enemy_allframe<=40 and graze_wide==0 then
			key_reset();
			key_event2(ACT_B,front);
		elseif dis<250 and ey<80 and enemy_allframe>=29 and graze_wide==0 then
			key_reset();
			key_on(ACT_D);
			key_on(front);
			yield();
			key_event2(ACT_A,front);	
		elseif ey>150 and enemy_frame>=29 then
			key_reset();
			key_on(ACT_D)
			key_event2(ACT_UP,front);
		end
	elseif weather~=13 and dis<=300 and enemy_act==309 and enemy_allframe<29 and (ey-y)<50 and (y-ey)<350 then
		key_on(back);
		
		
		
--●人形伏兵
--●人形弓兵
--●槍符「キューティー大千槍」
--●人形「レミングスパレード」
		
--グレイズ(ガードの比重を大きくしたせいでよく割れるように)
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and 
	(dis<=350 and (enemy_act==400 or enemy_act==401 or enemy_act==402 or enemy_act==404 or enemy_act==406 or enemy_act==530 or enemy_act==531 or enemy_act==505 or enemy_act==506 or enemy_act==507 or enemy_act==508)) or 
	(enemy_act==414 or enemy_act==416 or enemy_act==412 or enemy_act==410 or enemy_act==411 or enemy_act==415 or enemy_act==560 or enemy_act==565 or enemy_act==566 or enemy_act==603 or enemy_act==600 or enemy_act==601 or enemy_act==604 or enemy_act==602 or enemy_act==605 or enemy_act==607 or enemy_act==609) or 
	(caution_obj>0 and obj_dis2<150 and enemy_act~=301 and enemy_act~=302 and enemy_act~=307 and enemy_act~=408 and enemy_act~=418 and enemy_act~=545 and enemy_act~=546) or 
	(enemy_obj_range_in(150,60)==false and enemy_act~=301 and enemy_act~=302 and enemy_act~=307 and enemy_act~=408 and enemy_act~=418 and enemy_act~=545 and enemy_act~=546) or
	(enemy_obj_range_in(150,60)==false and dis>550) or (caution_obj>0 and obj_dis2<150 and dis>550) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function patche()
--対パチェ
kihon();

--無敵スペルカード所有判定
	if (my_hp<1000 and enemy_card==202 and (enemy_spell>=1000 or (enemy_spell>=500 and weather==2))) or
	(enemy_card==204 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2))) then
		muteki_sp = 2;
	else
		muteki_sp = 0;
	end
--亜空穴使用判定
	if (my_hp<1000 and enemy_card==202 and (enemy_spell>=1000 or (enemy_spell>=500 and weather==2))) or
	(enemy_card==204 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2))) or
	(enemy_card==200 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2))) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--下段ガード
	if noguard==0 and weather~=13 and 
	((dis<=200 and (enemy_act==303) and math.abs(ey-y)<150) or 
	(dis<=350 and (enemy_act==305) and math.abs(ey-y)<150) or 
	(dis<=450 and (enemy_act==304) and math.abs(ey-y)<150)) then
		c_guard()

--中段ガード
	elseif noguard==0 and weather~=13 and 
	((dis<=250 and (enemy_act==306 or enemy_act==308 or enemy_act==301 or enemy_act==302 or enemy_act==309) and math.abs(ey-y)<350) or 
	(dis<=300 and (enemy_act==307 or enemy_act==602 or enemy_act==695 or enemy_act==696) and math.abs(ey-y)<200) or 
	(dis<=350 and (enemy_act==304) and math.abs(ey-y)<150) or 
	(dis<=450 and (enemy_act==418) and math.abs(ey-y)<150) or 
	(dis<=500 and (enemy_act==408 or enemy_act==604) and math.abs(ey-y)<150)) then 
		s_guard()

--AAA。ディレイに釣られないよう最後まできっちりガード。
	elseif weather~=13 and dis<=150 and (enemy_act==300 or enemy_act==330) and y<=20 then
		s_guard()
	elseif weather~=13 and dis<=300 and enemy_act==320 and (ey-y)<150 and (y-ey)<150 then
		s_guard()
	elseif noguard==0 and weather~=13 and dis<=400 and enemy_act==321 and (ey-y)<150 and (y-ey)<150 and enemy_frame<19 then
		s_guard()

--ロイヤルフレア。地上なら全力ダッシュ、空中なら素直にガード。でも立ち回りで警戒していないのでよく割れる。
	elseif enemy_act==603 and y>=50 and enemy_allframe<10 and my_air<=1 then
		key_reset();
		key_event2(ACT_D,ACT_DOWN);
	elseif enemy_act==603 and y>=20 and enemy_allframe<230 then
		key_reset();
		key_on(back);
	elseif enemy_act==603 and y==0 and enemy_allframe<230 then
		key_on(ACT_D);
		key_on(front);
		
--●ワイプモイスチャー
--●スタティックグリーン
--●フォールスラッシャー
--●ダイアモンドハードネス
--●スティッキーバブル
--●火水符「フロギスティックピラー」
--●土金符「エメラルドメガロポリス」
--●日月符「ロイヤルダイアモンドリング」

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=350 and (enemy_act==400 or enemy_act==401 or enemy_act==402 or enemy_act==404 or (enemy_act==406 and math.abs(ey-y)<100) or (enemy_act==406 and x<1230 and ex<1230) or enemy_act==407 or enemy_act==409 or (enemy_act==414 and math.abs(ey-y)<100) or (enemy_act==414 and x<1230 and ex<1230) or (enemy_act==416 and math.abs(ey-y)<100) or (enemy_act==416 and x<1230 and ex<1230) or enemy_act==412 or enemy_act==410 or enemy_act==412 or (enemy_act==502 and math.abs(ey-y)<100) or (enemy_act==503 and x<1230 and ex<1230) or (enemy_act==503 and math.abs(ey-y)<100) or (enemy_act==503 and x<1230 and ex<1230) or enemy_act==505 or enemy_act==506 or enemy_act==565 or enemy_act==566 or enemy_act==567 or enemy_act==568 or enemy_act==560 or enemy_act==561 or enemy_act==585 or enemy_act==601)) or 
	(enemy_act==520 or enemy_act==411 or enemy_act==415 or enemy_act==500 or enemy_act==501 or enemy_act==521 or enemy_act==545 or enemy_act==546 or enemy_act==600) or 
	(enemy_obj_range_in(150,60)==false and enemy_act~=307 and enemy_act~=309 and enemy_act~=604)) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function youmu()
--対妖夢
kihon();

--無敵スペルカード所有判定
	if enemy_card==207 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2)) then
		muteki_sp = 2;
	else
		muteki_sp = 0;
	end
--亜空穴使用判定
	if enemy_card==207 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2)) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--対空行動可能判定の解除
	if enemy_act~=306 and enemy_act~=307 and enemy_act~=308 and enemy_act~=309 and air_atk==1 then
		air_atk = 0;
	end
--グレイズ範囲拡大：通常射撃。半霊と射撃を見分けるために設定
	if (enemy_act>=400 and enemy_act<=406) or enemy_act==505 or enemy_act==506 or enemy_act==565 or enemy_act==566 or enemy_act==570 or enemy_act==571 then
		graze_wide = 120;
		caution_obj = 120;
	end
--obj警戒・設置C射撃。発射前の発光している半霊をグレイズ対象に
	if enemy_act==410 or enemy_act==412 or enemy_act==414 or enemy_act==416 then
		graze_wide = 120;
		caution_obj = 30;
	end
--警戒・起き上がり弦月斬。移動起きから出すのは少し難しいので、移動起き時は警戒率を下げてみる
	if dis<300 and muteki==1 and ((enemy_act==197 and enemy_allframe==48 and math.random(4)==1) or (enemy_act==198 and enemy_allframe==48 and math.random(4)==1) or (enemy_act==199 and enemy_allframe==16 and math.random(3)==1)) then
		caution_atk = 3 + math.random(10);
		print("リバサ無敵技警戒",caution_atk)
	end

--下段ガード
	if noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==320 or enemy_act==300 or enemy_act==303 or enemy_act==330) and y<=20) or 
	(dis<=200 and (enemy_act==311) and math.abs(ey-y)<150) or 
	(dis<=250 and (enemy_act==322) and math.abs(ey-y)<150) or 
	(dis<=300 and (enemy_act==304) and math.abs(ey-y)<150) or 
	(dis<=450 and (enemy_act==408) and math.abs(ey-y)<150) or 
	(dis<=900 and (enemy_act==545 or enemy_act==546) and math.abs(ey-y)<150)) then
		c_guard();

--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==308 or enemy_act==309) and math.abs(ey-y)<350) or 
	(dis<=200 and (enemy_act==301 or enemy_act==321) and math.abs(ey-y)<150) or 
	(dis<=300 and (enemy_act==305 or enemy_act==307 or enemy_act==540 or enemy_act==695 or enemy_act==323 or enemy_act==696) and math.abs(ey-y)<250) or 
	(dis<=400 and (enemy_act==601) and math.abs(ey-y)<250) or 
	(dis<=450 and (enemy_act==302 or enemy_act==418) and math.abs(ey-y)<250) or 
	(dis<=700 and (enemy_act==600 or enemy_act==604) and math.abs(ey-y)<250) or 
	((enemy_act==603) and math.abs(ey-y)<250)) then 
		s_guard();

--JA。持続と妖夢自身の速度が合わさってかなりの広範囲。
	elseif weather~=13 and enemy_act==306 and enemy_allframe>16 and my_act~=151 and my_preact[1]~=151 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and dis<=220 and enemy_act==306 and (ey-y)<180 and (y-ey)<160 and enemy_frame<=16 then
		key_on(back);
--弦月斬B
	elseif enemy_act==520 and enemy_allframe>67 then
		enemy_preact[1] = 0;
	elseif weather~=13 and enemy_act==520 and dis<=400 and (ey-y)<300 and (y-ey)<300 and enemy_allframe<=11 then
		key_on(back);
--弦月斬C
	elseif enemy_act==521 and enemy_allframe>95 then
		enemy_preact[1] = 0;
	elseif weather~=13 and enemy_act==521 and dis<=400 and (ey-y)<300 and (y-ey)<300 and enemy_allframe<=35 then
		key_on(back);
		
		
--●燐気斬
--●頭上花剪斬
--●転生剣「円心流転斬」
--●空観剣「六根清浄斬」
		
--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=500 and (enemy_act==400 or enemy_act==401 or enemy_act==402 or enemy_act==404 or enemy_act==406 or enemy_act==412 or enemy_act==410 or enemy_act==414 or enemy_act==416 or enemy_act==411 or enemy_act==415 or enemy_act==505 or enemy_act==506 or enemy_act==570 or enemy_act==571 or enemy_act==565 or enemy_act==566 or enemy_act==607)) or 
	(enemy_act==411 or enemy_act==560 or enemy_act==561 or enemy_act==606) or 
	(graze_wide>0 and)) or
	(caution_obj>0 and obj_dis2<150) or
	() and dis>500)) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
		
--投げ
	elseif enemy_act==525 or enemy_act==526 then
		key_event2(ACT_D,ACT_UP);
		yield();yield();yield();yield();yield();yield();
		key_event2(ACT_DOWN,ACT_C);
		key_event(ACT_DOWN);
		key_event2(ACT_DOWN,front);
		key_event2(front,ACT_C);
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function remi()
kihon();

--無敵スペルカード所有判定
	if (enemy_card==200 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2))) or
	(enemy_card==202 and (enemy_spell>=1000 or (enemy_spell>=500 and weather==2))) or
	(enemy_card==205 and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2))) then
		muteki_sp = 2;
	elseif enemy_card==203 and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2)) then
		muteki_sp = 1;
	else
		muteki_sp = 0;
	end
--亜空穴使用判定
	if (enemy_card==200 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2))) or
	(enemy_card==202 and (enemy_spell>=1000 or (enemy_spell>=500 and weather==2))) or
	((enemy_card==203 or enemy_card==205) and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2))) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--警戒・起き上がりクレイドル。移動起きから出すのは少し難しいので、移動起き時は警戒率を下げてみる
	if dis<300 and muteki==1 and ((enemy_act==197 and enemy_allframe==26 and math.random(4)==1) or (enemy_act==198 and enemy_allframe==26 and math.random(4)==1) or (enemy_act==199 and enemy_allframe==20 and math.random(3)==1)) then
		caution_atk = 3 + math.random(10);
	end
--下段ガード
	if noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==320 or enemy_act==300) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=200 and (enemy_act==303 or enemy_act==301) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=250 and enemy_act==505 and (ey-y)<150 and (y-ey)<150)) then
		c_guard();

--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==306 or enemy_act==308 or enemy_act==309) and (ey-y)<300 and (y-ey)<350) or 
	(dis<=200 and (enemy_act==321) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=300 and (enemy_act==302 or enemy_act==322) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=450 and (enemy_act==307 or enemy_act==500) and (ey-y)<250 and (y-ey)<350) or 
	(enemy_act==560 or enemy_act==561 or enemy_act==501 or enemy_act==565 or enemy_act==566 or enemy_act==606 or enemy_act==602 or enemy_act==605)) then
		s_guard();
	
--3A。めり込まなかった場合は五分〜不利なので我慢。めり込んだ時は大抵有利なので暴れる。根元ガードなら8F有利なので反撃すら可能。あっ昇竜はやめてくださいしんでしまいます
	elseif weather~=13 and dis<=80 and enemy_act==304 and my_act==156 and my_frame==19 then
		key_reset();
		key_event(ACT_A);
	elseif noguard==0 and weather~=13 and dis<=300 and enemy_act==304 and y<=20 then
		c_guard()
--クレイドルB
	elseif enemy_act==540 and enemy_allframe>91 then
		enemy_preact[1] = 0;
	elseif weather~=13 and enemy_act==540 and dis<=300 and (ey-y)<300 and (y-ey)<300 and enemy_allframe<=25 then
		key_on(back);
--クレイドルC
	elseif enemy_act==541 and enemy_allframe>91 then
		enemy_preact[1] = 0;
	elseif weather~=13 and enemy_act==541 and dis<=400 and (ey-y)<300 and (y-ey)<300 and enemy_allframe<=25 then
		key_on(back);
		
		
--●サーヴァントフライヤー
--●トリックスターデビル
--●バンパイアキス
--●チェーンギャング
--●スティグマナイザー
--●「ミレニアムの吸血鬼」
--●悪魔「レミリアストレッチ」

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=350 and (enemy_act==400 or enemy_act==414 or enemy_act==416 or enemy_act==418 or enemy_act==412 or enemy_act==410 or enemy_act==401 or enemy_act==402 or enemy_act==404 or enemy_act==406 or enemy_act==520 or enemy_act==521 or enemy_act==607 or enemy_act==600 or enemy_act==603)) or 
	(enemy_act==530 or enemy_act==531 or enemy_act==545 or enemy_act==546 or enemy_act==601 or enemy_act==604) or
	enemy_obj_range_in(150,60)==false) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function yuyuko()
--対ゆゆこ
kihon();

--無敵スペルカード所有判定
	if ((enemy_card==200 or enemy_card==206) and (enemy_spell>=1000 or (enemy_spell>=500 and weather==2))) or
	(enemy_card==203 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2))) then
		muteki_sp = 2;
	else
		muteki_sp = 0;
	end
--亜空穴使用判定
	if ((enemy_card==200 or enemy_card==206) and (enemy_spell>=1000 or (enemy_spell>=500 and weather==2))) or
	(enemy_card==203 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2))) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--下段ガード
	if noguard==0 and weather~=13 and ((dis<=200 and (enemy_act==303 or enemy_act==311) and math.abs(ey-y)<150) or 
	(dis<=250 and (enemy_act==322) and math.abs(ey-y)<150) or 
	(dis<=300 and (enemy_act==304) and math.abs(ey-y)<150)) then 
		c_guard()

--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==309 or enemy_act==565 or enemy_act==566) and math.abs(ey-y)<350) or 
	(dis<=200 and (enemy_act==300 or enemy_act==306 or enemy_act==330) and y<=20) or 
	(dis<=250 and (enemy_act==308 or enemy_act==320 or enemy_act==321) and math.abs(ey-y)<350) or 
	(dis<=300 and (enemy_act==301 or enemy_act==305 or enemy_act==307 or enemy_act==408 or enemy_act==695 or enemy_act==696) and math.abs(ey-y)<250) or 
	(dis<=350 and (enemy_act==302 or enemy_act==418) and math.abs(ey-y)<250) or 
	(dis<=550 and (enemy_act==560) and math.abs(ey-y)<250) or 
	(dis<=900 and (enemy_act==561) and math.abs(ey-y)<250)) then 
		s_guard()
		--]]
		
--●死還の大地
--●センスオブエレガンス
--●故人のお届け物
--●「反魂蝶」
--●寿命「无寿国への約束手形」/ むじゅこくへのやくそくてがた
--●桜符「センスオブチェリーブロッサム」

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=350 and (enemy_act==400 or enemy_act==401 or enemy_act==402 or enemy_act==404 or enemy_act==406 or enemy_act==414 or enemy_act==416 or enemy_act==412 or enemy_act==410 or enemy_act==411 or enemy_act==415 or enemy_act==540 or enemy_act==541 or enemy_act==545 or enemy_act==546 or enemy_act==600 or enemy_act==601 or enemy_act==651 or enemy_act==603)) or 
	(enemy_act==520 or enemy_act==521 or enemy_act==522 or enemy_act==523 or enemy_act==525 or enemy_act==602 or enemy_act==604 or enemy_act==605 or enemy_act==607 or enemy_act==657 or enemy_act==608) or 
	enemy_obj_range_in(150,60)==false) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function yukari()
--対紫
kihon();

--無敵スペルカード所有判定
	if (enemy_card==200 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2))) or
	(enemy_card==202 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2))) then
		muteki_sp = 2;
	else
		muteki_sp = 0;
	end
--無敵必殺技所有判定
	if weather==9 then
		muteki = 1;
	else
		muteki = 0;
	end
--亜空穴使用判定
	if (enemy_card==200 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2))) or
	(enemy_card==202 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2))) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--下段ガード
	if noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==300 or enemy_act==330) and y<=20) or 
	(dis<=200 and (enemy_act==301 or enemy_act==303 or enemy_act==311) and math.abs(ey-y)<150) or 
	(dis<=300 and (enemy_act==304) and math.abs(ey-y)<150) or  
	(dis<=350 and (enemy_act==418) and math.abs(ey-y)<150) or 
	(dis<=900 and (enemy_act==565 or enemy_act==566) and math.abs(ey-y)<400)) then 
		c_guard()

--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==309) and math.abs(ey-y)<350) or 
	(dis<=250 and (enemy_act==305 or enemy_act==306 or enemy_act==308 or enemy_act==320 or enemy_act==321 or enemy_act==322 or enemy_act==520) and math.abs(ey-y)<350) or 
	(dis<=300 and (enemy_act==408 or enemy_act==695 or enemy_act==696) and math.abs(ey-y)<250) or 
	(dis<=350 and (enemy_act==307 or enemy_act==302) and math.abs(ey-y)<250) or 
	(dis<=500 and (enemy_act==521) and math.abs(ey-y)<250) or 
	((enemy_act==560 or enemy_act==561 or enemy_act==562 or enemy_act==563) and math.abs(ey-y)<350)) then 
		s_guard()

--電車(未完成)
	elseif enemy_act==615 then
		key_on(ACT_D);
		key_on(ACT_UP);
		key_on(front);
		if y>500 then
			key_reset();
			key_event(ACT_C);
		end
		
		
--●知能と脚の境界
--●変容を見る眼
--●肉体分解機
--●キマイラの翼
--●魔眼「ラプラスの魔」

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=350 and (enemy_act==400 or enemy_act==401 or enemy_act==402 or enemy_act==404 or enemy_act==406 or enemy_act==416 or enemy_act==412 or enemy_act==541 or enemy_act==600 or enemy_act==601 or enemy_act==602 or enemy_act==603 or enemy_act==604)) or 
	(enemy_act==606 or enemy_act==605 or enemy_act==410 or enemy_act==411 or enemy_act==414 or enemy_act==415) or 
	enemy_obj_range_in(150,60)==false) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function suika()
--対萃香
kihon();

--無敵スペルカード所有判定
	if enemy_card==203 and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2)) then
		muteki_sp = 2;
	elseif (enemy_card==202 and (enemy_spell>=1000 or (enemy_spell>=500 and weather==2))) or
	(enemy_card==205 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2))) then
		muteki_sp = 1;
	else
		muteki_sp = 0;
	end
--亜空穴使用判定
	if (enemy_card==202 and (enemy_spell>=1000 or (enemy_spell>=500 and weather==2))) or
	(enemy_card==203 and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2))) or
	(enemy_card==205 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2))) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--グレイズ範囲拡大：花火と疎鬼。破裂前の種をグレイズ対象に
	if (enemy_act>=410 and enemy_act<=416) or enemy_act==565 or enemy_act==566 then
		caution_obj = 30;
	end

--下段ガード
	if noguard==0 and weather~=13 and ((dis<=200 and (enemy_act==303 or enemy_act==311) and math.abs(ey-y)<150) or 
	(dis<=250 and (enemy_act==402) and math.abs(ey-y)<150) or 
	(dis<=400 and (enemy_act==408) and math.abs(ey-y)<150) or 
	(dis<=500 and (enemy_act==304) and math.abs(ey-y)<150)) then 
		c_guard()

--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==300 or enemy_act==330) and y<=20) or
	(dis<=150 and (enemy_act==309) and math.abs(ey-y)<350) or 
	(dis<=250 and (enemy_act==306 or enemy_act==308 or enemy_act==320 or enemy_act==321 or enemy_act==322 or enemy_act==500 or enemy_act==501) and math.abs(ey-y)<350) or 
	(dis<=300 and (enemy_act==301 or enemy_act==307 or enemy_act==602 or enemy_act==695 or enemy_act==696) and math.abs(ey-y)<350) or 
	(dis<=350 and (enemy_act==305 or enemy_act==520 or enemy_act==521 or enemy_act==522 or enemy_act==523) and math.abs(ey-y)<350) or 
	(dis<=400 and (enemy_act==302) and math.abs(ey-y)<250) or 
	(dis<=550 and (enemy_act==418 or enemy_act==601 or enemy_act==603 or enemy_act==604) and math.abs(ey-y)<250) or 
	(enemy_act==600)) then 
		s_guard()

--MPP(未完成)
	elseif enemy_act==605 and dis<800 and enemy_obj_range_in(150,60)==false then
		key_reset();
		key_on(back);
	elseif enemy_act==605 and dis<100 and enemy_obj_range_in(150,60)==false then
		key_reset();
		lvr421(ACT_C);

--●鬼符「大江山悉皆殺し」
	elseif y==0 and enemy_act==608 and dis<100 then
		key_reset();
		key_on(ACT_D);
		key_event2(ACT_UP,back);
		key_reset();
		
		
--●踏鞴
--●鬼神燐火術
--●攫鬼
--●霧符「雲集霧散」
--●四天王奥義「三歩壊廃」
--●鬼神「ミッシングパープルパワー」

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=350 and (enemy_act==400 or enemy_act==404 or enemy_act==406 or enemy_act==414 or enemy_act==416 or enemy_act==412 or enemy_act==410 or enemy_act==411 or enemy_act==415 or enemy_act==525 or enemy_act==526 or enemy_act==530 or enemy_act==531 or enemy_act==540 or enemy_act==541 or enemy_act==606 or enemy_act==607)) or 
	(dis<=100 and (enemy_act==505 or enemy_act==506)) or 
	(enemy_act==401 or enemy_act==405 or enemy_act==411 or enemy_act==415) or 
	(enemy_obj_range_in(150,60)==false and enemy_act~=520 and enemy_act~=521 and enemy_act~=522 and enemy_act~=523)) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function udonge()
--対うどんげ
kihon();

--下段ガード
	if noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==320 or enemy_act==300 or enemy_act==303 or enemy_act==330) and y<=20) or 
	(dis<=200 and (enemy_act==311) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=400 and (enemy_act==304) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=450 and (enemy_act==408) and (ey-y)<150 and (y-ey)<150)) then 
		c_guard();

--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==309) and (ey-y)<150 and (y-ey)<350) or 
	(dis<=200 and (enemy_act==301 or enemy_act==306 or enemy_act==321 or enemy_act==322) and (ey-y)<250 and (y-ey)<150) or 
	(dis<=250 and (enemy_act==308) and (ey-y)<350 and (y-ey)<150) or 
	(dis<=300 and (enemy_act==305 or enemy_act==307 or enemy_act==695 or enemy_act==696) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=400 and (enemy_act==565 or enemy_act==566 or enemy_act==567 or enemy_act==568) and (ey-y)<350 and (y-ey)<350) or 
	(dis<=450 and (enemy_act==418) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=500 and (enemy_act==302) and (ey-y)<150 and (y-ey)<150)) then 
		s_guard();

--マインドスターマイン。すっごい残るのでグレイズするよりガードした方が安全。
	elseif (enemy_act==602 or enemy_act==652) and enemy_frame>=35 then
		if weather==13 then
			graze();
		else
			key_on(back);
			caution_atk = 120;
			caution_graze = 120;
		end
		
		
--●アキュラースペクトル
--●長視「赤月下(インフレアドムーン)」
--●短視「超短脳波（エックスウェイブ）」
--●赤眼「望見円月（ルナティックブラスト）」

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=350 and (enemy_act==400 or enemy_act==401 or enemy_act==402 or enemy_act==404 or enemy_act==406 or enemy_act==414 or enemy_act==416 or enemy_act==412 or enemy_act==410 or enemy_act==411 or enemy_act==415 or enemy_act==500 or enemy_act==501 or enemy_act==530 or enemy_act==531 or enemy_act==510 or enemy_act==511 or enemy_act==550 or enemy_act==505 or enemy_act==506 or enemy_act==551 or enemy_act==560 or enemy_act==603 or enemy_act==605 or enemy_act==606 or enemy_act==607 or enemy_act==655 or enemy_act==600 or enemy_act==650)) or 
	(enemy_act==520 or enemy_act==521 or enemy_act==525 or enemy_act==526 or enemy_act==527 or enemy_act==528) or 
	(enemy_obj_range_in(150,60)==false and enemy_act~=565 and enemy_act~=566 and enemy_act~=567 and enemy_act~=568))then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function aya()
--対文
kihon();

--無敵スペルカード所有判定
	if enemy_card==201 and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2)) then
		muteki_sp = 1;
	else
		muteki_sp = 0;
	end
--亜空穴使用判定
	if enemy_card==201 and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2)) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--カラス設置判定
	if enemy_act==560 or enemy_act==561 then
		caution_obj = 130 ;
	end

--下段ガード
	if noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==320 or enemy_act==300 or enemy_act==303 or enemy_act==330) and y<=20) or 
	(dis<=200 and (enemy_act==311) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=400 and (enemy_act==304) and (ey-y)<150 and (y-ey)<150)) then 
		c_guard()

--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==308) and (ey-y)<350 and (y-ey)<150) or 
	(dis<=200 and (enemy_act==301 or enemy_act==306 or enemy_act==321 or enemy_act==322) and (ey-y)<200 and (y-ey)<150) or 
	(dis<=300 and (enemy_act==305 or enemy_act==309 or enemy_act==545 or enemy_act==546 or enemy_act==601 or enemy_act==695 or enemy_act==696) and (ey-y)<500 and (y-ey)<500) or 
	(dis<=350 and (enemy_act==302 or enemy_act==307) and (ey-y)<150 and (y-ey)<200) or 
	(dis<=400 and (enemy_act==408 or enemy_act==418) and (ey-y)<150 and (y-ey)<250) or 
	(dis<=700 and (enemy_act==520 or enemy_act==521 or enemy_act==522 or enemy_act==523 or enemy_act==525 or enemy_act==526 or enemy_act==527 or enemy_act==528) and (ey-y)<500 and (y-ey)<500) or 
	((enemy_act==550 or enemy_act==551 or enemy_act==552 or enemy_act==553 or enemy_act==606 or enemy_act==612 or enemy_act==662) and (ey-y)<500 and (y-ey)<150)) then 
		s_guard()
		--]]
		
--●楓扇風
--●天狗礫
--●風符「天狗報即日限」
--●鴉符｢暗夜のデイメア｣
--●「幻想風靡」

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=350 and (enemy_act==400 or enemy_act==401 or enemy_act==402 or enemy_act==404 or enemy_act==406 or enemy_act==500 or enemy_act==501 or enemy_act==502 or enemy_act==540 or enemy_act==505 or enemy_act==506 or enemy_act==507 or enemy_act==508 or enemy_act==565 or enemy_act==600 or enemy_act==603 or enemy_act==605 or enemy_act==611 or enemy_act==661)) or 
	(enemy_act==530 or enemy_act==532 or enemy_act==414 or enemy_act==416 or enemy_act==412 or enemy_act==410 or enemy_act==411 or enemy_act==415) or 
	(obj_dis2<80 and caution_obj>0) or 
	(enemy_obj_range_in(150,60)==false and enemy_act~=601)) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function komati()
kihon();

--無敵スペルカード所有判定
	if (my_hp-enemy_hp)>3000 and enemy_card==204 and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2)) then
		muteki_sp = 1;
	else
		muteki_sp = 0;
	end
--亜空穴使用判定
	if enemy_card==202 or
	((my_hp-enemy_hp)>3000 and enemy_card==204 and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2))) or
	(enemy_card==206 and (enemy_spell>=2000 or (enemy_spell>=1500 and weather==2))) then 
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--下段ガード
	if noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==300) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=200 and (enemy_act==311 or enemy_act==303) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=350 and (enemy_act==302) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=450 and (enemy_act==408) and (ey-y)<150 and (y-ey)<150)) then 
		c_guard();

--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=200 and (enemy_act==306 or enemy_act==320) and (ey-y)<250 and (y-ey)<150) or 
	(dis<=300 and (enemy_act==305 or enemy_act==304 or enemy_act==321 or enemy_act==525 or enemy_act==695 or enemy_act==696) and (ey-y)<350 and (y-ey)<250) or 
	(dis<=350 and (enemy_act==309 or enemy_act==601 or enemy_act==604) and (ey-y)<400 and (y-ey)<400) or 
	(dis<=400 and (enemy_act==301 or enemy_act==322 or enemy_act==611) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=500 and (enemy_act==550 or enemy_act==551 or enemy_act==526) and (ey-y)<350 and (y-ey)<150) or 
	(dis<=600 and (enemy_act==418) and (ey-y)<150 and (y-ey)<150) or 
	((enemy_act==600) and (ey-y)<150 and (y-ey)<150)) then 
		s_guard();

--遠A。とりあえず硬直と空中ガード不可だけ覚えさせておく
	elseif weather~=13 and dis<=420 and enemy_act==301 and y<=20 and enemy_frame<=20 then
		s_guard();
--J2A。汎用立ち回りだとこの技だけで動けなくなるので、連発を感知したら昇りJAで迎撃。
	elseif weather~=13 and enemy_act==308 then 
		if is_dir_front and dis<300 and (dis>50 or x<80 or x>1200) and ey<250 and ey>80 and (enemy_preact[4]==308 or enemy_preact[5]==308 or enemy_preact[6]==308) and enemy_xspeed>=2 and enemy_yspeed>=-4 and enemy_frame<3 and my_act<=5 then
			if dis<200 then
				key_reset();
				key_event2(ACT_UP,ACT_D);
				wait(5);
				key_event(ACT_A)
			else
				key_reset();
				key_on(ACT_D)
				key_event2(ACT_UP,front);
				key_reset();
				wait(5);
				key_event(ACT_A)
			end	
		elseif dis<=450 and (ey-y)<400 and (y-ey)<200 and enemy_frame<=23 then 
			s_guard();
		end
--J6A。こまっちゃんフルスイング。硬直は長いので認識させておく。大抵射撃か着地でキャンセルされちゃうけど。
	elseif weather~=13 and dis<=400 and enemy_act==307 and (ey-y)<150 and (y-ey)<250 and enemy_frame<=14 then
		s_guard();
	elseif weather~=13 and dis<=350 and dis>150 and enemy_act==307 and ey<350 and ey>200 and my_act<=8 and enemy_frame>14 and enemy_frame<=40 then
		key_reset();
		key_on(ACT_D)
		key_event2(ACT_UP,front)
		key_reset();
	elseif weather~=13 and dis<=300 and enemy_act==307 and ey<150 and my_act<=8 and enemy_frame>14 and enemy_frame<=40 then
		key_reset();
		key_on(ACT_D)
		key_event2(ACT_A,front)
		key_reset();
--自縛霊。この技に対しては個別にDC使用を定義。
	elseif dis<200 and my_act==200 and (enemy_act==520 or enemy_act==521) and enemy_frame<35 and weather~=5 then
		key_on(front);
		wait(1);
		key_event(ACT_C)
		
		
--●三途の舟
--●離魂の鎌
--●無間の道
--●お迎え体験版
--●地獄「無間の狭間」
--●魂符「生魂流離の鎌」

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=350 and (enemy_act==400 or enemy_act==401 or enemy_act==402 or enemy_act==404 or enemy_act==406 or enemy_act==414 or enemy_act==412 or enemy_act==410 or enemy_act==500 or enemy_act==501 or enemy_act==560 or enemy_act==561 or enemy_act==520 or enemy_act==521 or enemy_act==545 or enemy_act==546 or enemy_act==602)) or 
	(enemy_act==412 and enemy_obj_range_in(150,60)==false or 
	(enemy_act==505 or enemy_act==506 or enemy_act==507 or enemy_act==508 or enemy_act==416 or enemy_act==411 or enemy_act==415) or 
	enemy_obj_range_in(150,60)==false) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();--●組込み箇所から下をまとめたもの●
	end
end

function iku()
kihon();

--無敵スペルカード所有判定
	if enemy_card==202 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2)) then
		muteki_sp = 1;
	else
		muteki_sp = 0;
	end
--亜空穴使用判定
	if ((enemy_card==202 or enemy_card==203 or enemy_card==209) and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2))) or
	(enemy_card==210 and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2))) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--対空行動可能判定の解除
	if enemy_act~=306 and enemy_act~=307 and enemy_act~=308 and enemy_act~=309 and air_atk==1 then
		air_atk = 0;
	end
	
	
--下段ガード
	if noguard==0 and weather~=13 and ((dis<=200 and (enemy_act==311) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=250 and (enemy_act==303) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=350 and (enemy_act==304) and (ey-y)<150 and (y-ey)<150)) then 
		c_guard()
--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==300 or enemy_act==330) and y<=20) or
	(dis<=300 and (enemy_act==305 or enemy_act==320 or enemy_act==321 or enemy_act==322 or enemy_act==695 or enemy_act==696) and y<=20) or 
	(dis<=350 and (enemy_act==301) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=450 and (enemy_act==302 or enemy_act==520 or enemy_act==521) and (ey-y)<150 and (y-ey)<250) or 
	(dis<=500 and (enemy_act==418) and (ey-y)<350 and (y-ey)<150) or 
	((enemy_act==601) and (ey-y)<150 and (y-ey)<150)) then 
		s_guard()
--JA。袖の陰に隠れがちだが強判定
	elseif weather~=13 and enemy_act==306 and enemy_frame>13 and my_act~=151 and my_preact[1]~=151 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and dis<=300 and enemy_act==306 and (ey-y)<200 and (y-ey)<170 and enemy_frame<=13 then
		key_on(back);
--J2A。みんな大好き衣玖さんの袖。技後の硬直だけでも認識させておかないとしんでしまいます。
	elseif weather~=13 and enemy_act==308 and enemy_frame>14 and my_act~=152 and my_preact[1]~=152 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and dis<=500 and enemy_act==308 and (ey-y)<360 and (y-ey)<150 and enemy_frame<=14 then
		key_on(back);
--J6A。みんな悶える衣玖さんの袖。こちらも硬直は認識させる。
	elseif weather~=13 and enemy_act==307 and enemy_frame>19 and my_act~=152 and my_preact[1]~=152 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and dis<=450 and enemy_act==307 and (ey-y)<150 and (y-ey)<250 and enemy_frame<=19 then
		key_on(back);
--J8A。ドリル。
	elseif weather~=13 and enemy_act==309 and enemy_allframe>56 then
		enemy_preact[1] = 0;
		air_atk = 0;
	elseif weather~=13 and enemy_act==309 and enemy_allframe>28 and my_act~=152 and my_preact[1]~=152 and air_atk==0 then
		air_atk = 1;
	elseif weather~=13 and dis<=200 and enemy_act==309 and (ey-y)<50 and (y-ey)<350 and enemy_allframe<=28 then
		key_on(back);
--竜魚の一撃。ドリル。根元には判定が無いのでガードしない。
	elseif weather~=13 and (my_dir+enemy_dir)==0 and dis<=500 and dis>70 and enemy_act==500 and y<300 and enemy_frame<=50 then
		key_on(back);
	elseif weather~=13 and (my_dir+enemy_dir)==0 and dis<=600 and dis>70 and enemy_act==501 and y<300 and enemy_frame<=66 then
		key_on(back);
		
		
--●水得の龍魚
--●天女の一撃
--●龍神の髭
--●羽衣「羽衣は時の如く」
--●棘符「雷雲棘魚」
--●羽衣「羽衣は空の如く」
--●珠符「五爪龍の珠」
--●龍魚「龍宮の使い遊泳弾」

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and (dis<=350 and (enemy_act==408 or enemy_act==400 or enemy_act==401 or enemy_act==402 or enemy_act==404 or enemy_act==406 or enemy_act==414 or enemy_act==416 or enemy_act==410 or enemy_act==540 or enemy_act==505 or enemy_act==506 or enemy_act==560 or enemy_act==561 or enemy_act==562 or enemy_act==563 or enemy_act==525 or enemy_act==526 or enemy_act==600 or enemy_act==602 or enemy_act==603 or enemy_act==606 or enemy_act==609 or enemy_act==610)) or 
	(enemy_act==411 or enemy_act==415) or 
	((enemy_obj_range_in(150,60)==false and dis>200) or (enemy_obj_range_in(150,60)==false and dis<=200)) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();
	end
end

function tenko()
kihon();

--無敵スペルカード所有判定
	if (enemy_card==202 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2))) or
	(enemy_card==205 and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2))) then
		muteki_sp = 2;
	else
		muteki_sp = 0;
	end
--亜空穴使用判定
	if (enemy_card==202 and (enemy_spell>=1500 or (enemy_spell>=1000 and weather==2))) or
	(enemy_card==205 and (enemy_spell>=2500 or (enemy_spell>=2000 and weather==2))) then
		caution_akuu = 1;
	else
		caution_akuu = 0;
	end
--下段ガード
	if noguard==0 and weather~=13 and ((dis<=250 and (enemy_act==320) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=200 and (enemy_act==311 or enemy_act==303) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=250 and (enemy_act==322 or enemy_act==560 or enemy_act==561) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=500 and (enemy_act==408) and (ey-y)<150 and (y-ey)<150)) then 
		c_guard()
--中段ガード
	elseif noguard==0 and weather~=13 and ((dis<=150 and (enemy_act==308 or enemy_act==309) and (ey-y)<500 and (y-ey)<350) or 
	(dis<=240 and (enemy_act==321 or enemy_act==306) and (ey-y)<250 and (y-ey)<150) or 
	(dis<=250 and (enemy_act==300 or enemy_act==301 or enemy_act==304 or enemy_act==330) and y<=20) or 
	(dis<=300 and (enemy_act==305 or enemy_act==695 or enemy_act==696) and (ey-y)<150 and (y-ey)<250) or 
	(dis<=350 and (enemy_act==565 or enemy_act==566 or enemy_act==601) and (ey-y)<150 and (y-ey)<150) or 
	(dis<=400 and (enemy_act==302 or enemy_act==307 or enemy_act==602) and (ey-y)<700 and (y-ey)<150) or 
	(dis<=450 and (enemy_act==418) and (ey-y)<150 and (y-ey)<150) or 
	(enemy_act==560 or enemy_act==561 or enemy_act==605)) then 
		s_guard()

--六震。回避可能ならジャンプ、無理そうならしゃがみガード。
	elseif enemy_act==505 and y==0 and enemy_frame<20 and (my_act<=10 or (my_act>=400 and my_act<=412)) then
		key_reset();
		key_event2(ACT_D,ACT_UP);
	elseif enemy_act==505 and y==0 and enemy_frame>=20 and enemy_frame<35 then
		key_on(back);
		key_on(ACT_DOWN);
		wait(25);
		
		
--●緋想の剣気
--●昇天突
--●因果の剣
--●地精の起床
--●剣技「気炎万丈の剣」
--●天気「緋想天促」

--グレイズ
	elseif nograze==0 and (((my_act==150 or my_act==154) and my_frame>=8) or ((my_act==151 or my_act==155) and my_frame>=14) or ((my_act==152 or my_act==156) and my_frame>=20) or ((my_act==153 or my_act==157) and my_frame>=26) or (my_act==158 and my_frame>=18) or my_act<150 or my_act>=180 or (my_act>=159 and my_act<=166)) and ((dis<=350 and (enemy_act==400 or enemy_act==401 or enemy_act==402 or enemy_act==404 or enemy_act==406 or enemy_act==414 or enemy_act==416 or enemy_act==412 or enemy_act==410 or enemy_act==411 or enemy_act==415 or enemy_act==500 or enemy_act==501 or enemy_act==525 or enemy_act==527 or enemy_act==545 or enemy_act==546 or enemy_act==547 or enemy_act==548)) or 
	(enemy_act==540 or enemy_act==600 or enemy_act==604 or enemy_act==607 or enemy_act==657) or 
	enemy_obj_range_in(150,60)==false) then
		if caution_graze==0 then
			key_off(ACT_DOWN);
			graze();
		else
			key_on(back);
		end --]]
	else
		filter_act();
	end
end

function sanae()
--対早苗
kihon();
filter_act();
end

function cirno()
--対チルノ
kihon();
filter_act();
end

function meirin()
--対美鈴
kihon();
filter_act();
end

function utsuho()
--対お空
kihon();
filter_act();
end

function suwako()
--対諏訪子
kihon();
filter_act();
end
















---各種フラグとか色々
function set_preact()
while true do

	if enemy_obj_n>=1 then
		--obj各個変数化
		for i=1,enemy_obj_n,1 do
			enemy_obj_act[i],enemy_obj_x[i],enemy_obj_y[i],enemy_obj_hp[i],enemy_obj_img[i],enemy_obj_frame[i],enemy_obj_xspeed[i],enemy_obj_yspeed[i],enemy_obj_id[i],enemy_obj_attackarea_n[i],enemy_obj_hit_n[i] = get_obj_data(1,i-1);
		end
		--obj攻撃判範囲
		for i=1,enemy_obj_n,1 do
			for n=1,enemy_obj_attackarea_n[i],1 do
				enemy_obj_attackarea_left[(i+1)*100+(n+1)],enemy_obj_attackarea_top[(i+1)*100+(n+1)],enemy_obj_attackarea_right[(i+1)*100+(n+1)],enemy_obj_attackarea_bottom[(i+1)*100+(n+1)] = get_obj_attackarea(1,i-1,n-1);
			end
		end
		--obj加速度
		if battle_time-old_bt>=1 then
			for i=1,enemy_obj_n,1 do
				if enemy_obj_id[i] == pre0_enemy_obj_id[i] and enemy_obj_attackarea_n[i]>=1 then
				
							enemy_obj_xaccel[i] 	= math.floor(((enemy_obj_xspeed[i]-pre0_enemy_obj_xspeed[i])/(battle_time-old_bt))*1000)/1000
							enemy_obj_yaccel[i] 	= math.floor(((enemy_obj_yspeed[i]-pre0_enemy_obj_yspeed[i])/(battle_time-old_bt))*1000)/1000
							
				elseif enemy_obj_id[i] ~= pre0_enemy_obj_id[i] then
				
					for ii=0,pre0_enemy_obj_n-1,1 do
						if enemy_obj_id[i] == pre0_enemy_obj_id[ii] and enemy_obj_attackarea_n[i]>=1 then
						
							enemy_obj_xaccel[i] 	= math.floor(((enemy_obj_xspeed[i]-pre0_enemy_obj_xspeed[ii])/(battle_time-old_bt))*1000)/1000
							enemy_obj_yaccel[i] 	= math.floor(((enemy_obj_yspeed[i]-pre0_enemy_obj_yspeed[ii])/(battle_time-old_bt))*1000)/1000
							
						end
					end
					
				end
			end
		end
	end

search_JFP();

--▼どれくらい地上or空中にいたのかをカウント▼
	if ey==0 then
		air_math = 0;
	elseif ey>0 then
		air_math = air_math+1;
	end
	if ey>0 then
		graund_math = 0;
	elseif ey==0 then
		graund_math = graund_math+1;
	end
	
--▼ガードするごとに初期値にリセットされる変数▼
	if ((my_act>=50 and my_act<=89) or (my_act>=143 and my_act<=166)) and my_frame<=1 then
		after_guard_count = 60;
	elseif after_guard_count>=2 then
		after_guard_count = after_guard_count-1
	elseif after_guard_count<=1 then
		after_guard_count = 1
	end
	
--▼ガード用バオイリズムの制御変数▼
	if bio_math<0 then
		bio_math = 0
	elseif bio_math>10000 then
		bio_math = 10000
	elseif dis<=20 then
		bio_math = 10000
		
	elseif enemy_act>=306 and enemy_act<=309 and air_math>=30 and y<=20 and enemy_allframe==1 and my_hitstop==0  then
		bio_math = 0
		
	elseif my_act==97 then
		bio_math = bio_math+math.random(500)
		
	elseif enemy_act>=300 and enemy_preact[1]>=300 and enemy_preact[1]==enemy_act and enemy_frame<=0 and my_hitstop==0  then
		bio_math = bio_math-4000
	elseif enemy_act>=0 and enemy_preact[1]>=300 and enemy_preact[1]~=enemy_act and enemy_frame<=0 and my_hitstop==0  then
		bio_math = bio_math+8000
		
	elseif enemy_act>=50 and enemy_act<=145 and enemy_frame<=0 and enemy_hitstop==0 then
		bio_math = bio_math+1500
	elseif enemy_act>=150 and enemy_act<=158 and enemy_frame<=0 and enemy_hitstop==0 then
		bio_math = bio_math+1000
	elseif enemy_act>=159 and enemy_act<=166 and enemy_frame<=0 and enemy_hitstop==0 then
		bio_math = bio_math+500
		
	elseif my_act>=50 and my_act<=145 and my_frame+1==1 and my_hitstop==0 then
		bio_math = bio_math-500
	elseif my_act>=150 and my_act<=158 and my_frame+1==1 and my_hitstop==0 then
		bio_math = bio_math-1000
	elseif my_act>=159 and my_act<=166 and my_frame+1==1 and my_hitstop==0 then
		bio_math = bio_math-1500
		
	elseif bio_math<10000 then
		bio_math = bio_math+math.random(64)
	end


--モーション毎に乱数生成。基本動作では変化させない
	if not(my_preact[0] == my_act) then
		if my_act>5 then
			RND = math.random(1000)
		end
	end
--直前actと異なっていたら、もしくは同じact番号でもframeが巻き戻っていたら記録する(自分)
	if not(my_preact[0] == my_act and my_preframe[0] <= my_frame) then
		for i=8,1,-1 do
			my_preact[i] = my_preact[i-1];
			my_preframe[i] = my_preframe[i-1];
		end
	end
--直前actと異なっていたら、もしくは同じact番号でもframeが巻き戻っていたら記録する(相手)
	if not(enemy_preact[0] == enemy_act and enemy_preframe[0] <= enemy_frame) then
		for i=8,1,-1 do
			enemy_preact[i] = enemy_preact[i-1];
			enemy_preframe[i] = enemy_preframe[i-1];
		end
	end
--フレーム総数の記録(自分)
	if my_act == my_preact[0] then
		if my_prehitstop == 0 then
			my_allframe = my_allframe + 1
		end
	else
		my_allframe = 0
	end

--フレーム総数の記録(相手)
	if enemy_act == enemy_preact[0] then
		if enemy_prehitstop == 0 then
			enemy_allframe = enemy_allframe + 1
		end
	else
		enemy_allframe = 0
	end

--妖怪バスターが使えるかどうかの判定
	if get_skill_lv(1,4)>0 or my_card==104 then
		buster = 1;
	end

--相手が右(1)に居るか左(-1)に居るかの判定
	if x <= ex then
		target_front = 1;
	else
		target_front = -1;
	end

--相手の位置が入れ替わると50%の確率で一定フレームの間ガード不能になる
	if target_front ~= prefront and guard_rank>0 and math.random(2)==1 then
		mekuri = math.random(guard_rank) - 5
		if mekuri<=0 then
			mekuri = 0;
		end
	end
--端までの距離計算。0〜1200
	if my_dir == 1 then
		my_frontside = 1240 - x
	else
		my_frontside = x - 40
	end

	if enemy_dir == 1 then
		enemy_frontside = 1240 - ex
	else
		enemy_frontside = ex - 40
	end
	
	if my_dir == 1 then
		my_backside = x - 40
	else
		my_backside = 1240 - x
	end

	if enemy_dir == 1 then
		enemy_backside = ex - 40
	else
		enemy_backside = 1240 - ex
	end
	

--最後にガードした攻撃を記録する
	if my_act>=150 and my_act<=170 and my_frame==0 and enemy_act>=300 then
		enemy_atk_frame = enemy_frame
		enemy_atk_allframe = enemy_allframe
		enemy_atk_act = enemy_act
	end
--Limitリセット
	if my_limit>=100 and (enemy_act<50 or enemy_act>=97) then
		my_limit = 0;
	end
--各種警戒値の減少
	if caution_atk>0 and (enemy_act==143 or enemy_act==145) then
		caution_atk = 0
	elseif caution_atk>0 and my_act<300 then
		caution_atk = caution_atk - 1;	
	end

	if land_atk>0 then
		land_atk = land_atk - 1
	end

	if caution_gatk>0 then
		caution_gatk = caution_gatk - 1;
	end

	if caution_obj>0 then
		caution_obj = caution_obj - 1;
	end

	if caution_graze>0 then
		caution_graze = caution_graze - 1;
	end

	if graze_wide>0 then
		graze_wide = graze_wide - 1;
	end

	if caution_time>0 then
		caution_time = caution_time - 1;
	end

	if mekuri>0 then
		mekuri = mekuri - 1;
	end

--▼絶対座標に対する速度と座標より算出した速度▼
	if battle_time-old_bt==1 then
	
		if x<=40 or x>=1240 then
			my_xspeedEX = 0
		else
			if my_hitstop==0 then
				my_xspeedEX = (x-old_x);
			else
				my_xspeedEX = 0
			end
		end
		
		if ex<=40 or ex>=1240 then
			enemy_xspeedEX = 0
		else
			if enemy_hitstop==0 then
				enemy_xspeedEX = (ex-old_ex);
			else
				enemy_xspeedEX = 0
			end
		end
		
	elseif battle_time-old_bt>=2 then
	
		if x<=40 or x>=1240 then
			my_xspeedEX = 0
		else
			if my_hitstop==0 then
				my_xspeedEX = (x-old_x)/(battle_time-old_bt);
			else
				my_xspeedEX = 0
			end
		end
		
		if ex<=40 or ex>=1240 then
			enemy_xspeedEX = 0
		else
			if enemy_hitstop==0 then
				enemy_xspeedEX = (ex-old_ex)/(battle_time-old_bt);
			else
				enemy_xspeedEX = 0
			end
		end
		
	end
	
--▼落下加速度の演算▼
	if battle_time-old_bt==1 then --更新速度の計測
		if y==0 then
			old_m_ys = 0;
			m_gs = 0;
		elseif y>0 then
			m_gs = my_yspeed - old_m_ys; --瞬間の落下加速度の計測
		end
		if ey==0 then
			old_e_ys = 0;
			e_gs = 0;
		elseif ey>0 then
			e_gs = enemy_yspeed - old_e_ys;
		end
	end
	
old_bt = battle_time;
old_x = x;
old_ex = ex;
old_m_ys = my_yspeed;
old_e_ys = enemy_yspeed;

	my_preact[0] = my_act;
	my_preframe[0] = my_frame;
	enemy_preact[0] = enemy_act;
	enemy_preframe[0] = enemy_frame;
	my_prehitstop = my_hitstop;
	enemy_prehitstop = enemy_hitstop;
	prefront = target_front;
	disy = math.floor(y-ey)
----
----pre_obj変数
for i=1,enemy_obj_n,1 do
	pre0_enemy_obj_act[i] 			= enemy_obj_act[i]
	pre0_enemy_obj_x[i] 			= enemy_obj_x[i]
	pre0_enemy_obj_y[i] 			= enemy_obj_y[i]
	pre0_enemy_obj_hp[i] 			= enemy_obj_hp[i]
	pre0_enemy_obj_img[i] 			= enemy_obj_img[i]
	pre0_enemy_obj_frame[i] 		= enemy_obj_frame[i]
	pre0_enemy_obj_xspeed[i] 		= enemy_obj_xspeed[i]
	pre0_enemy_obj_yspeed[i] 		= enemy_obj_yspeed[i]
	pre0_enemy_obj_id[i] 			= enemy_obj_id[i]
	pre0_enemy_obj_attackarea_n[i] 	= enemy_obj_attackarea_n[i]
	pre0_enemy_obj_hit_n[i] 		= enemy_obj_hit_n[i]
end

for i=1,enemy_obj_n,1 do
	pre0_enemy_obj_attackarea_n[i] = enemy_obj_attackarea_n[i]
end

pre0_enemy_obj_n = enemy_obj_n;
----
	
yield();






end
end

--[[
今後の改変要素について
	射撃の使い分けの徹底
	霊夢AI式カードチェックとカード回しの撤廃。および別方式の導入
	置き攻めをJA一択から、射撃織り交ぜにする。さもなければ、詐欺飛びを完璧にする
	下段透かしの低空J2Bの導入。キャラとモーションを条件に一括して記入するタイプとして導入する。キャラ対策というより、汎用目的。
	妖怪バスターの実装と、コンボの導入。
	神技「八方鬼縛陣」の代わりに宝具「陰陽鬼神玉」の導入
	J6A＞JCが穴になっているので、起動距離と条件を厳しくする。また、裏択や従来択も用意する。
	着地際のスキルや射撃を導入する。警醒陣など
	
	あとは、ある程度仕上がったあとで行う
	他のスキルの搭載など
	
--]]


function main()
base_states()
create_thread("set_preact")
create_thread("guard_check")
	if my_char==0 then
		print("　");
		print("【霊夢ＡＩ（2010/09/12）の改造ＡＩ--ver.2011/09/05--by.しなうす】");
		print("▼　変　更　点　▼");
		print("『非想天則参入キャラ含めた、汎用のガード、グレイズ、霊撃札、龍魚の羽衣、回避結界、宵越しの銭を組込み』");
		print("『一部スキカ、スペカを除き、相手ダウン後にカード使用』など...");
		print("　");
	end
while true do
	--if my_char==0 then
		if enemy_char==0 then
			reimu();
		elseif enemy_char==1 then
			marisa();
		elseif enemy_char==2 then
			sakuya();
		elseif enemy_char==3 then
			alice();
		elseif enemy_char==4 then
			patche();
		elseif enemy_char==5 then
			youmu();
		elseif enemy_char==6 then
			remi();
		elseif enemy_char==7 then
			yuyuko();
		elseif enemy_char==8 then
			yukari();
		elseif enemy_char==9 then
			suika();
		elseif enemy_char==10 then
			udonge();
		elseif enemy_char==11 then
			aya();
		elseif enemy_char==12 then
			komati();
		elseif enemy_char==13 then
			iku();
		elseif enemy_char==14 then
			tenko();
		elseif enemy_char==15 then
			sanae();
		elseif enemy_char==16 then
			cirno();
		elseif enemy_char==17 then
			meirin();
		elseif enemy_char==18 then
			utsuho();
		elseif enemy_char==19 then
			suwako();
		end
	--else
	--	print("！AI側の使用キャラが霊夢ではありません")
	--	if enemy_char==0 then
	--		print("！AIツールが1P側と2P側を誤認しているかもしれません")
	--		print("！F12キーでAIをリロードする事で改善されるかも")
	--	end
	--	wait(9999999)
	--end
	yield();
end
end
