diff --git a/TacticalAI/AIMain.cpp b/TacticalAI/AIMain.cpp index 2266f255..9d6bdee3 100644 --- a/TacticalAI/AIMain.cpp +++ b/TacticalAI/AIMain.cpp @@ -1462,6 +1462,12 @@ void CancelAIAction(SOLDIERTYPE *pSoldier, UINT8 ubForce) pSoldier->aiData.bBypassToGreen = FALSE; ActionDone(pSoldier); + + // sevenfm: reset next action + pSoldier->aiData.bNextAction = AI_ACTION_NONE; + pSoldier->aiData.usNextActionData = 0; + pSoldier->aiData.bNextTargetLevel = 0; + pSoldier->iNextActionSpecialData = 0; } @@ -1653,6 +1659,12 @@ void TurnBasedHandleNPCAI(SOLDIERTYPE *pSoldier) } else { + // sevenfm: clear next action data before making decisions + pSoldier->aiData.bNextAction = AI_ACTION_NONE; + pSoldier->aiData.usNextActionData = 0; + pSoldier->aiData.bNextTargetLevel = 0; + pSoldier->iNextActionSpecialData = 0; + if (!(gTacticalStatus.uiFlags & ENGAGED_IN_CONV)) { if(!pSoldier->ai_masterplan_) // if the Soldier has no plan, create one diff --git a/TacticalAI/Attacks.cpp b/TacticalAI/Attacks.cpp index 6cb99ea6..90749f72 100644 --- a/TacticalAI/Attacks.cpp +++ b/TacticalAI/Attacks.cpp @@ -1336,6 +1336,12 @@ void CalcBestThrow(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestThrow) fSpare = FALSE; } + // militia always try to spare grenades unless under attack or using flares + if (pSoldier->bTeam == MILITIA_TEAM && !pSoldier->aiData.bUnderFire && !Item[usGrenade].flare) + { + fSpare = TRUE; + } + // need 3 opponents for 0 difficulty, 1 opponent for max difficulty if (fSpare && ubOpponentCnt < 3 - ubDiff / 2) { diff --git a/TacticalAI/DecideAction.cpp b/TacticalAI/DecideAction.cpp index e9265d1d..0cda6a2b 100644 --- a/TacticalAI/DecideAction.cpp +++ b/TacticalAI/DecideAction.cpp @@ -2517,6 +2517,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier) // sevenfm: before deciding anything, stop cowering if (SoldierAI(pSoldier) && + !fCivilian && ubCanMove && pSoldier->stats.bLife >= OKLIFE && !pSoldier->bCollapsed && @@ -4909,6 +4910,7 @@ INT16 ubMinAPCost; // sevenfm: before deciding anything, stop cowering if (SoldierAI(pSoldier) && + !fCivilian && ubCanMove && pSoldier->stats.bLife >= OKLIFE && !pSoldier->bCollapsed && diff --git a/TacticalAI/Realtime.cpp b/TacticalAI/Realtime.cpp index 3bbeb1fa..4898bb2c 100644 --- a/TacticalAI/Realtime.cpp +++ b/TacticalAI/Realtime.cpp @@ -185,6 +185,12 @@ void RTHandleAI( SOLDIERTYPE * pSoldier ) } else { + // sevenfm: clear next action data before making decision + pSoldier->aiData.bNextAction = AI_ACTION_NONE; + pSoldier->aiData.usNextActionData = 0; + pSoldier->aiData.bNextTargetLevel = 0; + pSoldier->iNextActionSpecialData = 0; + if (!(gTacticalStatus.uiFlags & ENGAGED_IN_CONV)) { if(!pSoldier->ai_masterplan_) // if the Soldier has no plan, create one