--****************************************************************************** --[[ @brief 130_BFF_SNIPER @author Yoshikazu KOIDE ]] --****************************************************************************** --▼ 依存ファイル xxxの部分にミッションidを入れてください dofile("game:\\common\\airesource\\script\\include\\include.lua"); dofile("game:\\common\\event\\include\\m130\\pointid.lua"); dofile("game:\\common\\event\\include\\m130\\entityid.lua"); dofile("game:\\common\\event\\include\\m130\\constvalue.lua"); -- ▼本ミッション用定数 CONST__TARGETTING_PARAM = -- ターゲット捕捉のパラメータ { LADER = -- レーダー { DISTANCE = 500; -- レーダーの距離 ANGLE = 180; -- レーダーの角度(真正面を0度とした円錐の側面までの角度(度)) }; LADER_SNIP = -- 狙撃時のレーダー { DISTANCE = 450; -- レーダーの距離 ANGLE = 30; -- レーダーの角度(真正面を0度とした円錐の側面までの角度(度)) }; }; CONST__BOOST_PARAM = -- ブーストのパラメータ { RATIO = -- 歩きとダッシュの比率 { WALK = 0.5; -- 歩き係数(0〜1) DASH = 0.5; -- ダッシュ係数(0〜1) }; RATE = -- 歩きとダッシュの率 { ENERGY = -- エネルギー率 { MIN = 0; -- エネルギー下限(0〜エネルギー上限) MAX = 1; -- エネルギー上限(下限〜1) }; DASH = -- ダッシュ率 { MIN = 0.2; -- ダッシュ率下限(0〜エネルギー上限) MAX = 0.6; -- ダッシュ率上限(下限〜1) }; }; }; CONST__ALT_PARAM = -- 高度調節のパラメータ { SELF = { ABSOLUTE = 0; -- 絶対高度 RELATIVE = 90; -- 相対高度 GROUND = 0; -- 対地相対高度 }; GROUND = -- 長距離時の飛行割合 { TIME_JUMP = 0; -- 飛行時間 TIME_WALK = 9; -- 地上時間 }; FLOAT = -- 中距離時の飛行割合 { TIME_JUMP = 10; -- 飛行時間 TIME_WALK = 5; -- 地上時間 }; AERIAL = -- 短距離時の飛行割合 { TIME_JUMP = 9; -- 飛行時間 TIME_WALK = 0; -- 地上時間 }; }; CONST__MOVE_PARAM = -- 移動時のパラメータ { DIST_PIVOT = 500; -- 遠距離/近距離の分水嶺(※移動系 }; CONST__MAIN_ATK_PARAM = -- メイン武器攻撃時のパラメータ { DISTANCE = -- 攻撃頻度切り替えの距離パラメータ { MAX = 300; -- 攻撃限界距離(長) LONG = 100; -- 適正距離限界 MIDDLE = 50; -- 適正距離最小 MIN = 0; -- 攻撃限界距離(短) }; LONG = -- 遠距離時のShootパラメータ { WAIT_MIN = 0.0; -- 最小待ち時間(秒) WAIT_MAX = 0.1; -- 最大待ち時間(秒) TRIGGER_MIN = 0.1; -- 最小トリガー時間(秒)※マシンガンのみ TRIGGER_MAX = 0.3; -- 最大トリガー時間(秒)※マシンガンのみ RELOAD_TIME = 3; -- マガジンリロードに要する時間 MULTI_LOCK_TIME = 2; -- マルチロック待ち時間 ※ミサイルのみ LOS_FLG = false; -- 射線判定フラグ(射撃時に射線を取るのならばtrue) LOCK_FLG = false; }; MIDDLE = -- 適正距離時のShootパラメータ { WAIT_MIN = 0; -- 最小待ち時間(秒) WAIT_MAX = 0; -- 最大待ち時間(秒) TRIGGER_MIN = 0.3; -- 最小トリガー時間(秒)※マシンガンのみ TRIGGER_MAX = 0.6; -- 最大トリガー時間(秒)※マシンガンのみ RELOAD_TIME = 3; -- マガジンリロードに要する時間 MULTI_LOCK_TIME = 2; -- マルチロック待ち時間 ※ミサイルのみ LOS_FLG = true; -- 射線判定フラグ(射撃時に射線を取るのならばtrue) LOCK_FLG = true; }; SHORT = -- 短距離時のShootパラメータ { WAIT_MIN = 0.0; -- 最小待ち時間(秒) WAIT_MAX = 0.1; -- 最大待ち時間(秒) TRIGGER_MIN = 0.1; -- 最小トリガー時間(秒)※マシンガンのみ TRIGGER_MAX = 0.3; -- 最大トリガー時間(秒)※マシンガンのみ RELOAD_TIME = 3; -- マガジンリロードに要する時間 MULTI_LOCK_TIME = 2; -- マルチロック待ち時間 ※ミサイルのみ LOS_FLG = true; -- 射線判定フラグ(射撃時に射線を取るのならばtrue) LOCK_FLG = false; }; }; CONST__DIST_OF_ENEMY = 110; -- ひょいひょいの敵がひょいひょいをやめる距離 CONST__DIST_OF_ENEMY_IN_BACK = 150; -- 通路内で後ろにプレイヤーが回り込んできたことに気付く距離 CONST__AI_COMMON_PARAM_ID = 0; CONST__ID_OF_ENE_1 = 1; -- ひょいひょい CONST__ID_OF_ENE_2 = 2; -- 通路 CONST__ID_OF_ENE_3 = 3; -- 通路 CONST__ID_OF_ENE_4 = 4; -- 潜んでる CONST__ID_OF_ENE_5 = 5; -- 潜んでる --▼ 変数 g_bFlgHyoiHyoi = 1; -- トンネル出口でひょいひょいをやめる --▼ スクリプト初期化 function InitialSetup( context) AddGlobalValue( context , "HyoiHyoi" , true ); --▼ 最初のオペレーションレイヤーを作成する。 --▽ 移動 AddInitialLayer( context , "InitMove" , "Move" , 0.1 ); --▽ メイン攻撃 AddInitialLayer( context , "InitMainAttack" , "MainAttack" , 0.1 ); --▼ 高度調整 DefaultSetup( context , true ); SetAdjustAltitudeBase( context , ADJUST_ALTITUDE_BASE__RELATIVE ); --<< 対地相対高度を見る SetAltitudeParam( context , CONST__ALT_PARAM.SELF.ABSOLUTE , CONST__ALT_PARAM.SELF.GROUND ); -- ▼ジャンプ SetTimeLengthJump( context , 0 , 1 ); -- ▼初ロックを通知用 AddSharedGlobalValue( context, m130_CONST__OF_SHARED_GLOBAL_VALUE__LOCK , m130_CONST__FLG__CLEAR ); -- ▼ターゲッティング Targetting_CatchUpWithConeInSide( context , CONST__TARGETTING_PARAM.LADER.DISTANCE , CONST__TARGETTING_PARAM.LADER.ANGLE ); end --▼ 初期化する。 RegistInitializeFuncitonName( "InitialSetup"); --///////////////////////////////////////////////////////////////////////////////////////////// --///////////////////////////////////////////////////////////////////////////////////////////// --///////////////////////////////////////////////////////////////////////////////////////////// ----------------------------------------------------------------------------------- -- 移動 ----------------------------------------------------------------------------------- function InitMove() debug_out("testメイン関数初期化。"); end function Move( context) -- ▼ロックをイベントへ通知 if ( SelfIsLocked( context )) then ModifySharedGlobalValue( context , m130_CONST__OF_SHARED_GLOBAL_VALUE__LOCK , m130_CONST__FLG__LOCK ); end -- ▼パラメータによってオペレーションを分岐 if GetCommonParam( context , CONST__AI_COMMON_PARAM_ID ) == CONST__ID_OF_ENE_1 then if GetToTargetDistance( context ) <= CONST__DIST_OF_ENEMY then g_bFlgHyoiHyoi = 0; end ModifyGlobalValue( context , "HyoiHyoi" , g_bFlgHyoiHyoi ); if ( g_bFlgHyoiHyoi == 1 ) then --▼ ブースト頻度 SetEstimation_WalkDashRate( context , 1 , 0 ); -- ▼トンネル出口でひょいひょい Op_LoopQueue( context , OperationIdentifier( 101 ) , 2 , 10 , 1 , nil , "LoopQueue_Construct_Exit" , "LoopQueue_Update_Exit" , nil , nil , "ループキュー" ); else -- ▼ひょいひょいやめる AttackMove( context ); end elseif ( GetCommonParam( context , CONST__AI_COMMON_PARAM_ID ) == CONST__ID_OF_ENE_2 ) or ( GetCommonParam( context , CONST__AI_COMMON_PARAM_ID ) == CONST__ID_OF_ENE_3 ) then -- ▼プレイヤーに後ろから回りこまれた場合は通常の移動に変更(正面も向ける) Op_LoopQueue( context , OperationIdentifier( 102 ) , 2 , 10 , 1 , nil , "LoopQueue_Construct_Tunnel" , "LoopQueue_Update_Tunnel" , nil , nil , "ループキュー" ); elseif ( GetCommonParam( context , CONST__AI_COMMON_PARAM_ID ) == CONST__ID_OF_ENE_4 ) or ( GetCommonParam( context , CONST__AI_COMMON_PARAM_ID ) == CONST__ID_OF_ENE_5 ) then -- ▼潜む Op_LoopQueue( context , OperationIdentifier( 103 ) , 2 , 10 , 1 , nil , "LoopQueue_Construct_Snip" , "LoopQueue_Update_Snip" , nil , nil , "ループキュー" ); else LogAI( "■AI(スナイパー):非対応のパラメータが存在します。" ); end end ----------------------------------------------------------------------------------- -- 攻撃用の移動 ----------------------------------------------------------------------------------- function AttackMove( context ) --▼ ブースト頻度 SetEstimation_WalkDashRate( context , CONST__BOOST_PARAM.RATIO.WALK , CONST__BOOST_PARAM.RATIO.DASH ); SetEstimation_BoostEnableEnergyRange( context , CONST__BOOST_PARAM.RATE.ENERGY.MIN , CONST__BOOST_PARAM.RATE.ENERGY.MAX , CONST__BOOST_PARAM.RATE.DASH.MIN , CONST__BOOST_PARAM.RATE.DASH.MAX ); SetTimeLengthJump( context , CONST__ALT_PARAM.FLOAT.TIME_JUMP , CONST__ALT_PARAM.FLOAT.TIME_WALK ); -- ▼ローカル変数 local dist = GetToTargetDistance( context ); -- ターゲットとの距離 local decent = ( CONST__MAIN_ATK_PARAM.DISTANCE.LONG + CONST__MAIN_ATK_PARAM.DISTANCE.MIDDLE ) * 0.5; -- 適正距離(指針値) if ( dist < 500 ) then local rand = RandomRangeInt( -1*decent*0.5 , 0 ); Op_MoveTargetRelation( context , OperationIdentifier( 1 ) , 6.0 , 8.0 , 1 , nil , decent + rand , 10 , 20 , 0 , false ); Op_RoundRear( context , OperationIdentifier( 2 ) , 4.0 , 7.0 , 1 , nil ); Op_Nothing( context , OperationIdentifier( 4 ) , 1.0 , 1.5 , 1 , nil ); else Op_Nothing( context , OperationIdentifier( 5 ) , 2 , 4 , 1 , nil ); end end function EvalDummy( context ) end ----------------------------------------------------------------------------------- --********************************************************************************* -- 攻撃(メイン) --********************************************************************************* ----------------------------------------------------------------------------------- function InitMainAttack() end function MainAttack( context) -- ▼ローカル変数 local dist = GetToTargetDistance( context ); local rand = RandomRangeInt( 0 , 3 ); local consent = true; if ( GetCommonParam( context , 0 ) == CONST__ID_OF_ENE_1 and GetToPointDistance( context , m130_PT_HYOIHYOI_03 ) > 10 and GetGlobalValue( context , "HyoiHyoi" ) == 1 ) then consent = false; end if ( CONST__MAIN_ATK_PARAM.DISTANCE.MAX < dist or consent == false ) then --<< 攻撃限界よりも遠くにいる Op_Nothing( context , OperationIdentifier( 51 ) , 2 , 2 , 1 , nil ); elseif ( CONST__MAIN_ATK_PARAM.DISTANCE.LONG < dist and dist < CONST__MAIN_ATK_PARAM.DISTANCE.MAX ) then --<< 威嚇射撃(遠距離 Op_ShootRifle( context , OperationIdentifier( 52 ) , 8 , 10 , 1 , nil , 0 , CONST__MAIN_ATK_PARAM.LONG.WAIT_MIN , CONST__MAIN_ATK_PARAM.LONG.WAIT_MAX , CONST__MAIN_ATK_PARAM.LONG.RELOAD_TIME , CONST__MAIN_ATK_PARAM.LONG.LOS_FLG, CONST__MAIN_ATK_PARAM.LONG.LOCK_FLG ); elseif ( CONST__MAIN_ATK_PARAM.DISTANCE.MIDDLE < dist and dist < CONST__MAIN_ATK_PARAM.DISTANCE.LONG ) then --<< 適正距離内 Op_ShootRifle( context , OperationIdentifier( 53 ) , 8 , 10 , 1 , nil , 0 , CONST__MAIN_ATK_PARAM.MIDDLE.WAIT_MIN , CONST__MAIN_ATK_PARAM.MIDDLE.WAIT_MAX , CONST__MAIN_ATK_PARAM.MIDDLE.RELOAD_TIME , CONST__MAIN_ATK_PARAM.MIDDLE.LOS_FLG, CONST__MAIN_ATK_PARAM.MIDDLE.LOCK_FLG ); elseif ( CONST__MAIN_ATK_PARAM.DISTANCE.MIN < dist and dist < CONST__MAIN_ATK_PARAM.DISTANCE.MIDDLE ) then --<< 焦る(短距離) Op_ShootRifle( context , OperationIdentifier( 54 ) , 8 , 10 , 1 , nil , 0 , CONST__MAIN_ATK_PARAM.SHORT.WAIT_MIN , CONST__MAIN_ATK_PARAM.SHORT.WAIT_MAX , CONST__MAIN_ATK_PARAM.SHORT.RELOAD_TIME , CONST__MAIN_ATK_PARAM.SHORT.LOS_FLG, CONST__MAIN_ATK_PARAM.SHORT.LOCK_FLG ); else --<< 攻撃限界よりも近くにいる Op_Nothing( context , OperationIdentifier( 55 ) , 2 , 2 , 1 , nil ); end end ----------------------------------------------------------------------------------- -- ループキュー(通路出口) ----------------------------------------------------------------------------------- function LoopQueue_Construct_Exit( context ) LogAI( "■AI(AC):ループキュー(通路出口)" ); -- ▼移動 Queue_Layer( context , 0 , 0 , nil , nil , "EvalRight" , "Right" , nil , "ポイント右" ); -- ▼待機 Queue_Nothing( context , 0.5 , 3.5 , nil , nil , nil ); -- ▼移動 Queue_Layer( context , 0 , 0 , nil , nil , "EvalCenter" , "Center" , nil , "ポイント中" ); -- ▼待機 Queue_Nothing( context , 1.0 , 1.5 , nil , nil , nil ); -- ▼移動 Queue_Layer( context , 0 , 0 , nil , nil , "EvalLeft" , "Left" , nil , "ポイント左" ); -- ▼待機 Queue_Nothing( context , 1.0 , 2.5 , nil , nil , nil ); -- ▼移動 Queue_Layer( context , 0 , 0 , nil , nil , "EvalCenter" , "Center" , nil , "ポイント中" ); -- ▼待機 Queue_Nothing( context , 1.0 , 1.1 , nil , nil , nil ); end ----------------------------------------------------------------------------------- -- ループキュー更新 ----------------------------------------------------------------------------------- function LoopQueue_Update_Exit( context ) end ----------------------------------------------------------------------------------- -- 関数 ----------------------------------------------------------------------------------- function Right( context ) Op_MoveToPoint( context , OperationIdentifier( 71 ) , 5 , 10 , 1 , nil , m130_PT_HYOIHYOI_01 ); end function EvalRight( context ) if IsIntersectRegion( context , m130_PT_HYOIHYOI_01 ) then context:Complete(); end end function Left( context ) Op_MoveToPoint( context , OperationIdentifier( 72 ) , 5 , 10 , 1 , nil , m130_PT_HYOIHYOI_02 ); end function EvalLeft( context ) if IsIntersectRegion( context , m130_PT_HYOIHYOI_02 ) then context:Complete(); end end function Center( context ) Op_MoveToPoint( context , OperationIdentifier( 73 ) , 5 , 10 , 1 , nil , m130_PT_HYOIHYOI_03 ); end function EvalCenter( context ) if IsIntersectRegion( context , m130_PT_HYOIHYOI_03 ) then context:Complete(); end end ----------------------------------------------------------------------------------- -- ループキュー(通路) ----------------------------------------------------------------------------------- function LoopQueue_Construct_Tunnel( context ) LogAI( "■AI(AC):ループキュー(通路)" ); -- ▼プレイヤー監視 Queue_Layer( context , 0 , 0 , nil , nil , "EvalNormal" , "Normal" , nil , "通常" ); -- ▼移動中 Queue_Layer( context , 0 , 0 , nil , nil , "EvalDummy" , "AttackMove" , nil , "移動中" ); end ----------------------------------------------------------------------------------- -- ループキュー更新 ----------------------------------------------------------------------------------- function LoopQueue_Update_Tunnel( context ) end ----------------------------------------------------------------------------------- -- 関数 ----------------------------------------------------------------------------------- function Normal( context ) -- ▼プレイヤーに正面を向けない SetEnableTurnToTarget( context , false ); Op_Nothing( context , OperationIdentifier( 81 ) , 2 , 4 , 1 , nil ); end function EvalNormal( context ) if GetToTargetDistance( context ) <= CONST__DIST_OF_ENEMY_IN_BACK then -- ▼プレイヤーに正面を向ける SetEnableTurnToTarget( context , true ); context:Complete(); end end --[[ if ( IsInTargetPartialSphere( context, 90, -90, -90 , -180) ) or ( IsInTargetPartialSphere( context, 90, -90, 180, 90) ) then LogAI( "■AI(AC):後ろに回り込まれた(通路のAC)" ); -- ▼プレイヤーに正面を向ける SetEnableTurnToTarget( context , true ); context:Complete(); end end end ]] ----------------------------------------------------------------------------------- -- ループキュー(潜んでる) ----------------------------------------------------------------------------------- function LoopQueue_Construct_Snip( context ) LogAI( "■AI(AC):ループキュー(潜んでる)" ); -- ▼プレイヤー監視 Queue_Layer( context , 0 , 0 , nil , nil , "EvalWaitTime" , "WaitTime" , nil , "監視中" ); -- ▼移動中 Queue_Layer( context , 0 , 0 , nil , nil , "EvalDummy" , "AttackMove" , nil , "移動中" ); end ----------------------------------------------------------------------------------- -- ループキュー更新 ----------------------------------------------------------------------------------- function LoopQueue_Update_Snip( context ) end ----------------------------------------------------------------------------------- -- 関数 ----------------------------------------------------------------------------------- function WaitTime( context ) if GetEntityAltitude( context , ENTITY_ID__PLAYER ) < GetCurrAltitude( context ) then -- ▼ターゲッティング(狙撃時) -- Targetting_CatchUpWithConeInSide( context , CONST__TARGETTING_PARAM.LADER_SNIP.DISTANCE , CONST__TARGETTING_PARAM.LADER_SNIP.ANGLE ); --[[ ◆動的にターゲッティングのパラメータを変更することが難しくなりました なんらか障害が出るようであれば、別途方法を考える(1027/koide) ]] -- ▼プレイヤーに正面を向ける SetEnableTurnToTarget( context , true ); -- ▼プレイヤーに視線を向ける SetEnableViewTurn( context , true ); else -- ▼プレイヤーに正面を向けない SetEnableTurnToTarget( context , false ); -- ▼プレイヤーに視線を向けない SetEnableViewTurn( context , false ); end Op_Nothing( context , OperationIdentifier( 91 ) , 2 , 4 , 1 , nil ); end function EvalWaitTime( context ) if SelfIsLocked( context ) then -- ▼プレイヤーに正面を向ける SetEnableTurnToTarget( context , true ); -- ▼プレイヤーに視線を向ける SetEnableViewTurn( context , true ); context:Complete(); end end