--****************************************************************************** --[[ @file Operations.lua @date \$Date: 2006/5/19 13:14:08 $ @author 長谷川 (\$Author: hasem $) @version \$Revision: 0 $ @brief オペレーション作成関数群 ]] --****************************************************************************** -------------------------------------------------------------------------------- -- 選択評価用関数 -------------------------------------------------------------------------------- --============================================================================== --[[ @brief 常に1 @note 選択評価関数が設定されていない場合、 この関数を使用する。 ]] --============================================================================ function Eval_AlwaysTrue( mtstate) return 1; end -------------------------------------------------------------------------------- -- 初期オペレーション登録 -------------------------------------------------------------------------------- --****************************************************************************** --[[ @brief なにもしない ]] --****************************************************************************** function IniOp_Nothing( initContext) -- 実行時間制御 local scheduler = OperationExecuteScheduler( 0, 0, 0, false); local desc = initContext:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = initContext:GetOperationFactory(); local operation = factory:CreateNothing( desc); initContext:AddRootOperation( operation, 1); end --****************************************************************************** --[[ @brief ターゲットが範囲内に入ったら、射撃(マシンガン) ]] --****************************************************************************** function IniOp_ShootMachinegunInRange( initContext, idWeapon, minWait, maxWait, minTrigger, maxTrigger, needLOS, needLock, range, margin) -- 実行時間制御 local scheduler = OperationExecuteScheduler( 0, 0, 0, false); local desc = initContext:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = initContext:GetOperationFactory(); local shootdesc = ShootDesc( idWeapon, 100, needLock, maxTrigger, minTrigger, 0, 0); shootdesc:SetWaitTime( minWait, maxWait); local operation = factory:CreateShootInRange( desc, shootdesc, GetMagazineReloadTime( initContext, idWeapon), needLOS, range, margin); initContext:AddRootOperation( operation, 1); end --****************************************************************************** --[[ @brief ターゲットが範囲内に入ったら、射撃(ライフル) ]] --****************************************************************************** function IniOp_ShootRifleInRange( initContext, idWeapon, minWait, maxWait, minTrigger, maxTrigger, needLOS, needLock, range, margin) -- 実行時間制御 local scheduler = OperationExecuteScheduler( 0, 0, 0, false); local desc = initContext:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = initContext:GetOperationFactory(); local shootdesc = ShootDesc( idWeapon, 100, needLock, 0, 0, 0, 0); shootdesc:SetWaitTime( minWait, maxWait); local operation = factory:CreateShootInRange( desc, shootdesc, 0, needLOS, range, margin); initContext:AddRootOperation( operation, 1); end --****************************************************************************** --[[ @brief 雑魚ヘリ移動用 ]] --****************************************************************************** function IniOp_ZakoHeriMove( initContext, KD_dist, KD_margin, maxWait, minWait, maxKeepDist, minKeepDist, maxRoundRear, minRoundRear) local scheduler = OperationExecuteScheduler( 0, 0, 0, false); local desc = initContext:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = initContext:GetOperationFactory(); local param = ZakoHeriMoveParameter(); param:SetWaitTime( maxWait, minWait); param:SetRoundRearTime( maxRoundRear, minRoundRear); param:SetKeepDistTime( maxKeepDist, minKeepDist); local operation = factory:CreateZakoHeriMove( desc, param, KD_dist, KD_margin); initContext:AddRootOperation( operation, 1); end --****************************************************************************** --[[ @brief うろつく @param radius うろつく範囲 @param timerange 移動方向がランダムで決定された後、その方向に移動する時間 ]] --****************************************************************************** function IniOp_RandomWalk( initContext, radius, timerange) local scheduler = OperationExecuteScheduler( 0, 0, 0, false); local desc = initContext:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = initContext:GetOperationFactory(); local operation = factory:CreateRandomWalk( desc, radius, timerange); initContext:AddRootOperation( operation, 1); end --****************************************************************************** --[[ @brief 前進 ]] --****************************************************************************** function IniOp_GoForward( initContext) local scheduler = OperationExecuteScheduler( 0, 0, 0, false); local desc = initContext:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = initContext:GetOperationFactory(); local operation = factory:CreateGoForward( desc); initContext:AddRootOperation( operation, 1); end --****************************************************************************** --[[ @brief ルート移動 @param StartPointID たどるルートの開始ポイントID @param GoalPointID ルートの到達目標ポイントID @param isTurnPoint ポイントに向かって旋回するかどうか ]] --****************************************************************************** function IniOp_FollowRoute( initContext, StartPointID, GoalPointID, isTurnPoint) local scheduler = OperationExecuteScheduler( 0, 0, 0, false); local desc = initContext:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = initContext:GetOperationFactory(); local operation = factory:CreateFollowRoute( desc, StartPointID, GoalPointID, isTurnPoint); initContext:AddRootOperation( operation, 1); end --****************************************************************************** --[[ @brief 旋回(エンティティ指定版) @note ターゲット未捕捉時オペレーション @param minRad 最小旋回半径 @param maxRad 最大旋回半径 @param margin 旋回半径からずれていい量 @param idEntity 旋回中心エンティティID(0は無効) @note 実際の旋回半径は、minRad〜maxRadの間で決まる。 ]] --****************************************************************************** function IniOp_CircularMoveEntity( initContext, minRad, maxRad, margin, idEntity) local scheduler = OperationExecuteScheduler( 0, 0, 0, false); local desc = initContext:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = initContext:GetOperationFactory(); local operation = factory:CreateCircularMoveEntity( desc, minRad, maxRad, margin, idEntity); initContext:AddRootOperation( operation, 1); end -------------------------------------------------------------------------------- -- オペレーション作成ラップ関数群 -------------------------------------------------------------------------------- --****************************************************************************** --[[ @brief なにもしない ]] --****************************************************************************** function Op_Nothing( selectionContext, line, minTime, maxTime, weight, funcSelection) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateNothing( desc); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief 前進 ]] --****************************************************************************** function Op_GoForward( selectionContext, line, minTime, maxTime, weight, funcSelection) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateGoForward( desc); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief 距離を保つ @param dist ターゲットとの間に保とうとする距離。 @param margin distの境界で振動しないように、 ]] --****************************************************************************** function Op_KeepDist( selectionContext, line, minTime, maxTime, weight, funcSelection, dist, margin) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); -- LogAI("フィルタのファクトリをまだ作成していないので、選択評価は常に1"); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateKeepDist( desc, dist, margin); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief 後ろに回りこむ ]] --****************************************************************************** function Op_RoundRear( selectionContext, line, minTime, maxTime, weight, funcSelection) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateRoundRear( desc); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief メイン武器で射撃 ]] --****************************************************************************** function Op_Shoot( selectionContext, line, minTime, maxTime, weight, funcSelection, prob, isLock, maxTrigger, maxNeutral) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__MAIN, prob, isLock, maxTrigger, 0, maxNeutral, 0); local operation = factory:CreateShoot( desc, shootdesc); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief メイン武器で射撃 @param isLock @param minTrigger @param maxTrigger @param minNeutral @param maxNeutral ]] --****************************************************************************** function Op_Shoot2( selectionContext, line, minTime, maxTime, weight, funcSelection, prob, isLock, minTrigger, maxTrigger, minNeutral, maxNeutral) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__MAIN, prob, isLock, maxTrigger, minTrigger, maxNeutral, minNeutral); local operation = factory:CreateShoot( desc, shootdesc); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief サブ武器で射撃 ]] --****************************************************************************** function Op_SubShoot( selectionContext, line, minTime, maxTime, weight, funcSelection, prob, isLock, maxTrigger, maxNeutral) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__SUB, prob, isLock, maxTrigger, 0, maxNeutral, 0); local operation = factory:CreateShoot( desc, shootdesc); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief サブ武器で射撃 ]] --****************************************************************************** function Op_SubShoot2( selectionContext, line, minTime, maxTime, weight, funcSelection, prob, isLock, minTrigger, maxTrigger, minNeutral, maxNeutral) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__SUB, prob, isLock, maxTrigger, minTrigger, maxNeutral, minNeutral); local operation = factory:CreateShoot( desc, shootdesc); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief サード武器で射撃 ]] --****************************************************************************** function Op_ThirdShoot( selectionContext, line, minTime, maxTime, weight, funcSelection, prob, isLock, maxTrigger, maxNeutral) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__THIRD, prob, isLock, maxTrigger, 0, maxNeutral, 0); local operation = factory:CreateShoot( desc, shootdesc); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief フォース武器で射撃 ]] --****************************************************************************** function Op_FourthShoot( selectionContext, line, minTime, maxTime, weight, funcSelection, prob, isLock, maxTrigger, maxNeutral) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__FOURTH, prob, isLock, maxTrigger, 0, maxNeutral, 0); local operation = factory:CreateShoot( desc, shootdesc); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief ターゲットを通過 ]] --****************************************************************************** function Op_PassThrough( selectionContext, line, minTime, maxTime, weight, funcSelection, distArrival, angle, timeOverrun) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreatePassThrough( desc, distArrival, angle, timeOverrun); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief 目的地に移動 ]] --****************************************************************************** function Op_MoveToMoveTarget( selectionContext, line, minTime, maxTime, weight, funcSelection, distArrival) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateMoveToMoveTarget( desc, distArrival); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief ポイントに向かって移動 @param idPoint 移動目標ポイントID @param distArrival 到着判定する距離 ]] --****************************************************************************** function Op_MoveToPoint( selectionContext, line, minTime, maxTime, weight, funcSelection, idPoint) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateMoveToPoint( desc, idPoint); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); -- end --****************************************************************************** --[[ @brief ルートをたどって移動 @param StartPointID たどるルートの開始ポイントID @param GoalPointID ルートの到達目標ポイントID @param isTurnPoint ポイントに向かって旋回するかどうか ]] --****************************************************************************** function Op_FollowRoute( selectionContext, line, minTime, maxTime, weight, funcSelection, StartPointID, GoalPointID, isTurnPoint) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateFollowRoute( desc, StartPointID, GoalPointID, isTurnPoint); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief エンティティを追尾 ]] --****************************************************************************** function Op_Follow( selectionContext, line, minTime, maxTime, weight, funcSelection, idFollow, x, y, z, distArrival) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateFollow( desc, idFollow, x, y, z, distArrival); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief 初期配置位置の相対を保ったまま追従する。 @param idFollow 追尾対象のエンティティID ]] --****************************************************************************** function Op_FollowInitialDisposition( selectionContext, line, minTime, maxTime, weight, funcSelection, idFollow) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateFollowInitialDisposition( desc, idFollow); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief 降下頭上攻撃(航空機専用) @param DescentRange 降下開始距離。この距離より近づくと、降下を開始します。 また、この距離より離れると、離脱できたと見なし旋回捕捉に移行します。(XZ平面距離) @param AttackRange 攻撃開始距離。降下中にこの距離より近づくと、攻撃を開始します。(直線距離XYZ) @param CatchAngle 捕捉範囲角(XZ平面で、前方を0とした扇状に360度単位)。 @param RelAltitude 目標高度。ターゲットの高度+この高さの位置を目標に降下します。 @param AttackTime 攻撃時間(秒単位)。射撃を継続する時間。経過すると離脱行動に入ります。 @param prob 射撃確率。Op_Shootと同様です。 @param isMain メイン武器で射撃するかどうか。 @param isLock ロックしてから射撃するかどうか。 @note このオペレーションは、次の4つの状態を繰り返します。 [旋回] ターゲット捕捉すると[接近]へ。 [接近] 攻撃距離に入ると[攻撃]へ、捕捉が外れると[離脱]。 [攻撃] 射撃時間経過で[離脱]へ。 [離脱] 降下距離より離れたら[旋回]へ。 ]] --****************************************************************************** function Op_DescentAttack( selectionContext, line, minTime, maxTime, weight, funcSelection, DescentRange, AttackRange, CatchAngle, RelAltitude, AttackTime, prob, isMain, isLock ) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local WepID = 0; if ( isMain == false ) then WepID = 1; end local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( WepID, prob, isLock, AttackTime, AttackTime, 0, 0); local operation = factory:CreateDescentAttack( desc, DescentRange, AttackRange, CatchAngle, RelAltitude, AttackTime, shootdesc); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief ランダムに歩く @note ターゲット未捕捉時オペレーション @param radius うろつく範囲 @param timerange 移動方向がランダムで決定された後、その方向に移動する時間 ]] --****************************************************************************** function Op_RandomWalk( selectionContext, line, minTime, maxTime, weight, funcSelection, radius, timerange) -- 選択評価算出関数 function Op_RandomWalk_SelectEval( evalContext) local exist = IsExistTarget( evalContext); if ( exist == true ) then return 0; else return 1; end end -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateEvalImplInLua( "Op_RandomWalk_SelectEval"); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateRandomWalk( desc, radius, timerange); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief 旋回 @note ターゲット未捕捉時オペレーション @param minRad 最小旋回半径 @param maxRad 最大旋回半径 @param margin 旋回半径からずれていい量 @param idPoint 旋回中心ポイントID(0は無効) @note 実際の旋回半径は、minRad〜maxRadの間で決まる。 ]] --****************************************************************************** function Op_CircularMove( selectionContext, line, minTime, maxTime, weight, funcSelection, minRad, maxRad, margin, idPoint) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateTargetExist(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateCircularMove( desc, minRad, maxRad, margin, idPoint); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief 旋回(エンティティ指定版) @note ターゲット未捕捉時オペレーション @param minRad 最小旋回半径 @param maxRad 最大旋回半径 @param margin 旋回半径からずれていい量 @param idEntity 旋回中心エンティティID(0は無効) @note 実際の旋回半径は、minRad〜maxRadの間で決まる。 ]] --****************************************************************************** function Op_CircularMoveEntity( selectionContext, line, minTime, maxTime, weight, funcSelection, minRad, maxRad, margin, idEntity) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateTargetExist(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateCircularMoveEntity( desc, minRad, maxRad, margin, idEntity); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief ターゲット相対位置移動 @param radius ターゲットからの距離 @param angle ターゲット正面からの角度(右+、左ー) @param margin 目標地点移動達成率上昇距離 @param coursetype 移動経路(未実装 060519) @param keepBoostAngle 移動方向と自分の向きがブーストできる角度を保つか?(true / false) ]] --****************************************************************************** function Op_MoveTargetRelation( selectionContext, line, minTime, maxTime, weight, funcSelection, radius, angle, margin, coursetype, keepBoostAngle) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); -- 選択評価ファンクタ local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateTargetExist(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateMoveTargetRelaitonPos( desc, radius, angle, margin, coursetype, keepBoostAngle); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief 高度調整 @note ヘリ|MT系は勝手に判定 ]] --****************************************************************************** function Op_AdjustAltitude( selectionContext, line, minTime, maxTime, weight, funcSelection, margin) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = nil; if ( 1==MyBehaviorIsHeri( selectionContext)) then -- ヘリ制御の場合 operation = factory:CreateLiftUpDown( desc, margin); else -- デフォルト operation = factory:CreateAltitudeAdjust( desc, margin); end selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief マシンガン射撃 @param idWeapon 武器ID @param minWait 最低待ち時間の設定 @param maxWait 最長待ち時間の設定 @param minTrigger 最低トリガー時間 @param maxTrigger 最長トリガー時間 @param needLOS 射線判定を取るか? @param needLock ロックしている必要があるか? @note alienbrain://AB-TEST/AC4/doc/PG/NPC関連/Shoot3発注用まとめ.xls ]] --****************************************************************************** function Op_ShootMachinegun( selectionContext, line, minTime, maxTime, weight, funcSelection, idWeapon, minWait, maxWait, minTrigger, maxTrigger, needLOS, needLock) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( idWeapon, 100, needLock, maxTrigger, minTrigger, 0, 0); -- local shootdesc = ShootDesc( idWeapon, prob, true, maxTrigger, minTrigger, 0, 0); shootdesc:SetWaitTime( minWait, maxWait); local operation = factory:CreateShootMachinegun( desc, shootdesc, GetMagazineReloadTime( selectionContext, idWeapon), needLOS); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief ノーロック射撃 @param idWeapon 武器ID @param minWait 最低待ち時間の設定 @param maxWait 最長待ち時間の設定 @param minTrigger 最低トリガー時間 @param maxTrigger 最長トリガー時間 @param needLOS 射線判定を取るか? @param range 射撃距離 @param angle 角度(度) @see http://server-cgi/web/cbdb/db.exe?page=DBRecord&did=472&qid=376&vid=543&rid=83&Head=&hid=&sid=23&rev=&ssid= ]] --****************************************************************************** function Op_ShootNolock( selectionContext, line, minTime, maxTime, weight, funcSelection, idWeapon, minWait, maxWait, minTrigger, maxTrigger, needLOS, range, angle) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( idWeapon, 100, needLock, maxTrigger, minTrigger, 0, 0); shootdesc:SetWaitTime( minWait, maxWait); local operation = factory:CreateShootNolock( desc, shootdesc, GetMagazineReloadTime( selectionContext, idWeapon), needLOS, range, angle); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief ライフル射撃 @param idWeapon 武器ID @param minWait 最低待ち時間の設定 @param maxWait 最長待ち時間の設定 @param magReload (予約)マガジンリロードに要する時間 @param needLOS 射線判定を取るか? @param needLock ロックしている必要があるか? @note alienbrain://AB-TEST/AC4/doc/PG/NPC関連/Shoot3発注用まとめ.xls ]] --****************************************************************************** function Op_ShootRifle( selectionContext, line, minTime, maxTime, weight, funcSelection, idWeapon, minWait, maxWait, magReload, needLOS, needLock) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( idWeapon, 100, needLock, 0, 0, 0, 0); shootdesc:SetWaitTime( minWait, maxWait); local operation = factory:CreateShootMachinegun( desc, shootdesc, 0, needLOS); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief 連動ミサイル @note 0.1秒だけ、トリガーを引いて9999秒間のニュートラル時間がある、 ノーロック射撃。 @note alienbrain://AB-TEST/AC4/doc/PG/NPC関連/Shoot3発注用まとめ.xls ]] --****************************************************************************** function Op_TriggerLinkedMissile( selectionContext, line, minTime, maxTime, weight, funcSelection) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__SHOULDER, 100, false, 0, 0.1, 0, 0); shootdesc:SetWaitTime( 0, 0); local operation = factory:CreateShootNolock( desc, shootdesc, 9999, false, 9999, 180); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief コジマ兵器射撃 @param idWeapon 武器ID @param minWait 最低待ち時間の設定 @param maxWait 最長待ち時間の設定 @param timeTrigger トリガー引きっぱなし時間 @param needLOS 射線判定を取るか? @param needLock ロックしている必要があるか? @note alienbrain://AB-TEST/AC4/doc/PG/NPC関連/Shoot3発注用まとめ.xls ]] --****************************************************************************** function Op_ShootKojima( selectionContext, line, minTime, maxTime, weight, funcSelection, idWeapon, minWait, maxWait, timeTrigger, needLOS, needLock) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( idWeapon, 100, needLock, timeTrigger, timeTrigger, 2, 2); shootdesc:SetWaitTime( minWait, maxWait); local operation = factory:CreateShootMachinegun( desc, shootdesc, 0, needLOS); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief ミサイル射撃 @param idWeapon 武器ID @param minWait 最低待ち時間の設定 @param maxWait 最長待ち時間の設定 @param timeMultiLock マルチロック待ち時間 @param needLOS 射線判定を取るか? @param needLock ロックしている必要があるか? @note alienbrain://AB-TEST/AC4/doc/PG/NPC関連/Shoot3発注用まとめ.xls ]] --****************************************************************************** function Op_ShootMssl( selectionContext, line, minTime, maxTime, weight, funcSelection, idWeapon, minWait, maxWait, timeMultiLock, needLOS, needLock) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( idWeapon, 100, needLock, 0, 0, 0, 0); -- local shootdesc = ShootDesc( idWeapon, prob, true, 0, 0, 0, 0); shootdesc:SetWaitTime( minWait, maxWait); local operation = factory:CreateShootMachinegun( desc, shootdesc, 0, needLOS); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end --****************************************************************************** --[[ @brief ブレード攻撃 @param idWeapon 武器ID @param minWait 最低待ち時間の設定 @param maxWait 最長待ち時間の設定 @param needLOS 射線判定を取るか? @param needLock ロックしている必要があるか? @note alienbrain://AB-TEST/AC4/doc/PG/NPC関連/Shoot3発注用まとめ.xls ]] --****************************************************************************** function Op_ShootBlade( selectionContext, line, minTime, maxTime, weight, funcSelection, idWeapon, minWait, maxWait, needLOS, needLock) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local evalFactory = selectionContext:GetEvaluationFactory(); local eval = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local shootdesc = ShootDesc( idWeapon, 100, needLock, 0, 0, 0, 0); shootdesc:SetWaitTime( minWait, maxWait); local operation = factory:CreateShootMachinegun( desc, shootdesc, 0, needLOS); selectionContext:AddCandidacy( operation, eval, funcSelection, weight); end -------------------------------------------------------------------------------- -- 特殊オペレーション作成ラップ関数群 -------------------------------------------------------------------------------- --****************************************************************************** --[[ @brief 順次実行オペレーションキュー @param funcConstruct 初期化関数名。ループキューを構築する。 @param funcUpdate 更新関数名(毎フレーム) @param funcSelectEval 選択時評価関数。(0〜1)を返す関数名 @param funcAchiveEval 実行時評価関数。(0〜1)を返す関数名 @param name オペレーションの名前 ]] --****************************************************************************** function Op_LoopQueue( selectionContext, line, minTime, maxTime, weight, funcSelection, funcConstruct, funcUpdate, funcSelectEval, funcAchiveEval, name) local evalSelect = nil; local evalAchive = nil; -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); -- 選択評価ファンクタ local evalFactory = selectionContext:GetEvaluationFactory(); -- 選択評価ファンクタ if ( nil == funcSelectEval)then evalSelect = evalFactory:CreateAlwaysTrue(); else evalSelect = evalFactory:CreateEvalImplInLua(funcSelectEval); end -- 実行時選択評価ファンクタ if ( nil == funcAchiveEval) then evalAchive = evalFactory:CreateAlwaysTrue(); else evalAchive = evalFactory:CreateEvalImplInLua(funcSelectEval); end local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateOperationLoopQueue( desc, funcConstruct, funcUpdate, evalAchive, name); selectionContext:AddCandidacy( operation, evalSelect, funcSelection, weight); end --****************************************************************************** --[[ @brief オペレーションにレイヤーを追加 ]] --****************************************************************************** function Op_Layer( selectionContext, line, minTime, maxTime, weight, funcSelection, funcUpdate, eval, nameLayer) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); -- 選択評価ファンクタ local evalFactory = selectionContext:GetEvaluationFactory(); -- 達成度評価がない場合は作る local evalAchieve = nil; if (eval==nil) then evalAchieve = evalFactory:CreateAlwaysTrue(); else evalAchieve = eval; end -- 評価関数の作成 local evalSelection = evalFactory:CreateAlwaysTrue(); local desc = selectionContext:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__SELECTOR_TEMPORARY, nil, nil); local factory = selectionContext:GetOperationFactory(); local operation = factory:CreateOperationLayer( desc, funcUpdate, evalAchieve, "RootLayer"); selectionContext:AddCandidacy( operation, evalSelection, funcSelection, weight); end -------------------------------------------------------------------------------- --[[ キューオペレーション作成ラップ関数群 @note 共通引数は以下のとおり queueConstructor キューを構築する再に必要 minTime 最小実行時間 maxTime 最大実行時間 funcEnter 実行開始時コールバック関数名 funcExit 実行終了時コールバック関数名 funcStateTransit 終了チェック関数名 @note キューの作成に使用するメモリは、 OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC からとる。 ]] -------------------------------------------------------------------------------- --****************************************************************************** --[[ @brief なにもしない ]] --****************************************************************************** function Queue_Nothing( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit ) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = opfactory:CreateNothing( desc); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief 前進 ]] --****************************************************************************** function Queue_GoForward( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit ) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = opfactory:GoForward( desc); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief 距離を保つ @param dist ターゲットとの間に保とうとする距離。 @param margin distの教会で振動しないように、 ]] --****************************************************************************** function Queue_KeepDist( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, dist, margin) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = opfactory:CreateKeepDist( desc, dist, margin); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief 後ろに回りこむ ]] --****************************************************************************** function Queue_RoundRear( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = opfactory:CreateRoundRear( desc, dist, margin); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief メイン武器で射撃 ]] --****************************************************************************** function Queue_Shoot( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, prob, isLock, maxTrigger, maxNeutral) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__MAIN, prob, isLock, maxTrigger, 0, maxNeutral, 0); local operation = opfactory:CreateShoot( desc, shootdesc); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief メイン武器で射撃 @param isLock @param minTrigger @param maxTrigger @param minNeutral @param maxNeutral ]] --****************************************************************************** function Queue_Shoot2( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, prob, isLock, minTrigger, maxTrigger, minNeutral, maxNeutral) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__MAIN, prob, isLock, maxTrigger, minTrigger, maxNeutral, minNeutral); local operation = opfactory:CreateShoot( desc, shootdesc); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief サブ武器で射撃 ]] --****************************************************************************** function Queue_SubShoot( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, prob, isLock, maxTrigger, maxNeutral) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__SUB, prob, isLock, maxTrigger, 0, maxNeutral, 0); local operation = opfactory:CreateShoot( desc, shootdesc); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief サブ武器で射撃 ]] --****************************************************************************** function Queue_SubShoot2( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, prob, isLock, minTrigger, maxTrigger, minNeutral, maxNeutral) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__SUB, prob, isLock, maxTrigger, minTrigger, maxNeutral, minNeutral); local operation = opfactory:CreateShoot( desc, shootdesc); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief サード武器で射撃 ]] --****************************************************************************** function Queue_ThirdShoot( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, prob, isLock, maxTrigger, maxNeutral) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__SUB, prob, isLock, maxTrigger, minTrigger, maxNeutral, minNeutral); local operation = opfactory:CreateShoot( desc, shootdesc); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief フォース武器で射撃 ]] --****************************************************************************** function Queue_FourthShoot( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, prob, isLock, maxTrigger, maxNeutral) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local shootdesc = ShootDesc( WEAPON_ID__FOURTH, prob, isLock, maxTrigger, 0, maxNeutral, 0); local operation = opfactory:CreateShoot( desc, shootdesc); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief ターゲットを通過 ]] --****************************************************************************** function Queue_PassThrough( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, distArrival, angle, timeOverrun) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = opfactory:CreatePassThrough( desc, distArrival, angle, timeOverrun); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief 目的地に移動 ]] --****************************************************************************** function Queue_MoveToMoveTarget( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, distArrival) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = opfactory:CreateMoveToMoveTarget( desc, distArrival); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief ポイントに向かって移動 @param idPoint 移動目標ポイントID @param distArrival 到着判定する距離 ]] --****************************************************************************** function Queue_MoveToPoint( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, idPoint) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = opfactory:CreateMoveToPoint( desc, idPoint); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief ルートをたどって移動 @param StartPointID たどるルートの開始ポイントID @param GoalPointID ルートの到達目標ポイントID @param isTurnPoint ポイントに向かって旋回するかどうか ]] --****************************************************************************** function Queue_FollowRoute( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, StartPointID, GoalPointID, isTurnPoint) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = opfactory:CreateFollowRoute( desc, StartPointID, GoalPointID, isTurnPoint); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief エンティティを追尾 ]] --****************************************************************************** function Queue_Follow( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, idFollow, x, y, z, distArrival) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = opfactory:CreateFollow( desc, idFollow, x, y, z, distArrival); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief 降下頭上攻撃(航空機専用) @param DescentRange 降下開始距離。この距離より近づくと、降下を開始します。 また、この距離より離れると、離脱できたと見なし旋回捕捉に移行します。(XZ平面距離) @param AttackRange 攻撃開始距離。降下中にこの距離より近づくと、攻撃を開始します。(直線距離XYZ) @param CatchAngle 捕捉範囲角(XZ平面で、前方を0とした扇状に360度単位)。 @param RelAltitude 目標高度。ターゲットの高度+この高さの位置を目標に降下します。 @param AttackTime 攻撃時間(秒単位)。射撃を継続する時間。経過すると離脱行動に入ります。 @param prob 射撃確率。Op_Shootと同様です。 @param isMain メイン武器で射撃するかどうか。 @param isLock ロックしてから射撃するかどうか。 @note このオペレーションは、次の4つの状態を繰り返します。 [旋回] ターゲット捕捉すると[接近]へ。 [接近] 攻撃距離に入ると[攻撃]へ、捕捉が外れると[離脱]。 [攻撃] 射撃時間経過で[離脱]へ。 [離脱] 降下距離より離れたら[旋回]へ。 ]] --****************************************************************************** function Queue_DescentAttack( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, DescentRange, AttackRange, CatchAngle, RelAltitude, AttackTime, prob, isMain, isLock ) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local WepID = 0; if ( isMain == false ) then WepID = 1; end local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local shootdesc = ShootDesc( WepID, prob, isLock, AttackTime, AttackTime, 0, 0); local operation = opfactory:CreateDescentAttack( desc, DescentRange, AttackRange, CatchAngle, RelAltitude, 20, shootdesc); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief ランダムに歩く @note ターゲット未捕捉時オペレーション @param radius うろつく範囲 @param timerange 移動方向がランダムで決定された後、その方向に移動する時間 ]] --****************************************************************************** function Queue_RandomWalk( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, radius, timerange) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = opfactory:CreateRandomWalk( desc, radius, timerange); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief 旋回 @note ターゲット未捕捉時オペレーション @param minRad 最小旋回半径 @param maxRad 最大旋回半径 @param margin 旋回半径からずれていい量 @param idPoint 旋回中心ポイントID(0は無効) @note 実際の旋回半径は、minRad〜maxRadの間で決まる。 ]] --****************************************************************************** function Queue_CircularMove( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, minRad, maxRad, margin, idPoint) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = opfactory:CreateCircularMove( desc, minRad, maxRad, margin, idPoint); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief ターゲット相対位置移動 @param radius ターゲットからの距離 @param angle ターゲット正面からの角度(右+、左ー) @param margin 目標地点移動達成率上昇距離 @param coursetype 移動経路(未実装 060519) @param keepBoostAngle 移動方向と自分の向きがブーストできる角度を保つか?(true / false) ]] --****************************************************************************** function Queue_MoveTargetRelation( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, radius, angle, margin, coursetype, keepBoostAngle) local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = opfactory:CreateMoveTargetRelaitonPos( desc, radius, angle, margin, coursetype, keepBoostAngle); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief オペレーションにレイヤーを追加 ]] --****************************************************************************** function Queue_Layer( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, funcUpdate, eval, nameLayer) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); -- 選択評価ファンクタ local evalFactory = queueConstructor:GetEvaluationFactory(); -- 達成度評価がない場合は作る local evalAchieve = nil; if (eval==nil) then evalAchieve = evalFactory:CreateAlwaysTrue(); else evalAchieve = eval; end local desc = queueConstructor:SetupCreationDesc( nil, scheduler, line, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = queueConstructor:GetOperationFactory(); local operation = factory:CreateOperationLayer( desc, funcUpdate, evalAchieve, nameLayer); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief 高度調整 @param margin 高度マージン @note ヘリ|MT系は勝手に判定 ]] --****************************************************************************** function Queue_AdjustAltitude( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, margin) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local opfactory = queueConstructor:GetOperationFactory(); local operation = nil; if ( 1==MyBehaviorIsHeri( queueConstructor)) then -- ヘリ制御の場合 operation = opfactory:CreateLiftUpDown( desc, margin); else -- デフォルト operation = opfactory:CreateAltitudeAdjust( desc, margin); end queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief マシンガン射撃 @param idWeapon 武器ID @param minWait 最低待ち時間の設定 @param maxWait 最長待ち時間の設定 @param minTrigger 最低トリガー時間 @param maxTrigger 最長トリガー時間 @param needLOS 射線判定を取るか? @note alienbrain://AB-TEST/AC4/doc/PG/NPC関連/Shoot3発注用まとめ.xls ]] --****************************************************************************** function Queue_ShootMachinegun( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, idWeapon, minWait, maxWait, minTrigger, maxTrigger, needLOS) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = queueConstructor:GetOperationFactory(); -- local shootdesc = ShootDesc( idWeapon, prob, isLock, maxTrigger, minTrigger, 0, 0); local shootdesc = ShootDesc( idWeapon, prob, true, maxTrigger, minTrigger, 0, 0); shootdesc:SetWaitTime( minWait, maxWait); local operation = factory:CreateShootMachinegun( desc, shootdesc, GetMagazineReloadTime( queueConstructor, idWeapon), needLOS); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief ライフル射撃 @param idWeapon 武器ID @param minWait 最低待ち時間の設定 @param maxWait 最長待ち時間の設定 @param magReload (予約)マガジンリロードに要する時間 @param needLOS 射線判定を取るか? @note alienbrain://AB-TEST/AC4/doc/PG/NPC関連/Shoot3発注用まとめ.xls ]] --****************************************************************************** function Queue_ShootRifle( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, idWeapon, minWait, maxWait, magReload, needLOS) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = queueConstructor:GetOperationFactory(); -- local shootdesc = ShootDesc( idWeapon, prob, isLock, 0, 0, 0, 0); local shootdesc = ShootDesc( idWeapon, prob, true, 0, 0, 0, 0); shootdesc:SetWaitTime( minWait, maxWait); local operation = factory:CreateShootMachinegun( desc, shootdesc, 0, needLOS); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief コジマ射撃 @param idWeapon 武器ID @param minWait 最低待ち時間の設定 @param maxWait 最長待ち時間の設定 @param timeTrigger トリガー引きっぱなし時間 @param needLOS 射線判定を取るか? @note alienbrain://AB-TEST/AC4/doc/PG/NPC関連/Shoot3発注用まとめ.xls ]] --****************************************************************************** function Queue_ShootKojima( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, idWeapon, minWait, maxWait, timeTrigger, needLOS) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = queueConstructor:GetOperationFactory(); local shootdesc = ShootDesc( idWeapon, prob, true, timeTrigger, timeTrigger, 0, 0); shootdesc:SetWaitTime( minWait, maxWait); local operation = factory:CreateShootMachinegun( desc, shootdesc, 0, needLOS); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end --****************************************************************************** --[[ @brief ミサイル射撃 @param idWeapon 武器ID @param minWait 最低待ち時間の設定 @param maxWait 最長待ち時間の設定 @param timeMultiLock マルチロック待ち時間 @param needLOS 射線判定を取るか? @note alienbrain://AB-TEST/AC4/doc/PG/NPC関連/Shoot3発注用まとめ.xls ]] --****************************************************************************** function Queue_ShootMssl( queueConstructor, minTime, maxTime, funcEnter, funcExit, funcStateTransit, idWeapon, minWait, maxWait, timeMultiLock, needLOS) -- 実行時間制御 local scheduler = OperationExecuteScheduler( minTime, maxTime, 0, false); local desc = queueConstructor:SetupCreationDesc( nil, scheduler, 0, OPERATION_MEMORY_ALLOCATE_HOST_ID__LOGIC, nil, nil); local factory = queueConstructor:GetOperationFactory(); -- local shootdesc = ShootDesc( idWeapon, prob, isLock, 0, 0, 0, 0); local shootdesc = ShootDesc( idWeapon, prob, true, 0, 0, 0, 0); shootdesc:SetWaitTime( minWait, maxWait); local operation = factory:CreateShootMachinegun( desc, shootdesc, 0, needLOS); queueConstructor:AddQueue( operation, funcEnter, funcExit, funcStateTransit); end