From 06478266d0fea43f1d875a8a1e6c4848ccdc96ac Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Fri, 18 Aug 2023 23:11:39 +0300 Subject: [PATCH] Moved armed vehicle/robot in gas check into function Originally placed in DecideAction(green/yellow/red/black) functions separately --- TacticalAI/AIUtils.cpp | 12 ++++++++++++ TacticalAI/DecideAction.cpp | 18 ------------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/TacticalAI/AIUtils.cpp b/TacticalAI/AIUtils.cpp index 2f947a9fe..4a6f1c29f 100644 --- a/TacticalAI/AIUtils.cpp +++ b/TacticalAI/AIUtils.cpp @@ -2253,6 +2253,12 @@ BOOLEAN InWaterGasOrSmoke( SOLDIERTYPE *pSoldier, INT32 sGridNo ) BOOLEAN InGasOrSmoke( SOLDIERTYPE *pSoldier, INT32 sGridNo ) { + // Armed vehicles and robots do not care about gas or smoke + if (ARMED_VEHICLE(pSoldier) || ENEMYROBOT(pSoldier)) + { + return FALSE; + } + // smoke if ( gpWorldLevelData[sGridNo].ubExtFlags[pSoldier->pathing.bLevel] & (MAPELEMENT_EXT_SMOKE | MAPELEMENT_EXT_SIGNAL_SMOKE | MAPELEMENT_EXT_DEBRIS_SMOKE | MAPELEMENT_EXT_FIRERETARDANT_SMOKE ) ) return TRUE; @@ -2300,6 +2306,12 @@ BOOLEAN InGas(SOLDIERTYPE *pSoldier, INT32 sGridNo) if (TileIsOutOfBounds(sGridNo)) return FALSE; + // Armed vehicles and robots do not care about gas or smoke + if (ARMED_VEHICLE(pSoldier) || ENEMYROBOT(pSoldier)) + { + return FALSE; + } + if (InGasSpot(pSoldier, sGridNo, pSoldier->pathing.bLevel)) { return TRUE; diff --git a/TacticalAI/DecideAction.cpp b/TacticalAI/DecideAction.cpp index 3967c2812..ed30f0369 100644 --- a/TacticalAI/DecideAction.cpp +++ b/TacticalAI/DecideAction.cpp @@ -807,12 +807,6 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier) // check if standing in tear gas without a gas mask on, or in smoke bInGas = InGasOrSmoke( pSoldier, pSoldier->sGridNo ); - // Flugente: tanks do not care about gas - if ( ARMED_VEHICLE( pSoldier ) || ENEMYROBOT( pSoldier ) ) - { - bInGas = FALSE; - } - // if real-time, and not in the way, do nothing 90% of the time (for GUARDS!) // unless in water (could've started there), then we better swim to shore! @@ -2589,12 +2583,6 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier) // check if standing in tear gas without a gas mask on bInGas = InGasOrSmoke( pSoldier, pSoldier->sGridNo ); - // Flugente: tanks do not care about gas - if ( ARMED_VEHICLE( pSoldier ) || ENEMYROBOT( pSoldier ) ) - { - bInGas = FALSE; - } - //////////////////////////////////////////////////////////////////////////// // WHEN LEFT IN GAS, WEAR GAS MASK IF AVAILABLE AND NOT WORN //////////////////////////////////////////////////////////////////////////// @@ -5042,12 +5030,6 @@ INT16 ubMinAPCost; // check if standing in tear gas without a gas mask on bInGas = InGasOrSmoke( pSoldier, pSoldier->sGridNo ); - // Flugente: tanks do not care about gas - if ( ARMED_VEHICLE( pSoldier ) || ENEMYROBOT( pSoldier ) ) - { - bInGas = FALSE; - } - // calculate our morale pSoldier->aiData.bAIMorale = CalcMorale(pSoldier);