mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
CONSIDERED_NEUTRAL: removed dying check as it may cause problems with AI. Improved code to avoid moving into gas/deep water/light/artillery danger zone. ClosestReachableDisturbance: - skip dying opponent if found not dying - when in deep water, skip opponents in deep water ClosestKnownOpponent: skip dying opponent if found not dying. RedSmokeDanger: consider deep water as safe from artillery strike. Allow deep water flanking for soldiers of ENEMY_TEAM with SEEKENEMY orders and CUNNINGSOLO attitude or athletics trait. CalcBestShot: - dying, cowering or unconscious soldiers have very low priority - added safety checks - if best opponent is dying and new opponent is ok, use new opponent DecideAction: improved deep water checks. Red, Black AI: when SEEKENEMY soldier is in deep water, move to closest opponent on the ground. FindNearestUngassedLand: - increased max search distance to 35 - added speed optimization - removed max AP budget FindNearbyDarkerSpot: - increased max search range to 25 - added speed optimization - removed max AP budget FindFlankingSpot: added condition to allow deep water flanking git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8758 3b4a5df2-a311-0410-b5c6-a8a6f20db521
110 lines
4.6 KiB
C++
110 lines
4.6 KiB
C++
/**
|
|
* @file
|
|
* @author feynman (bears-pit.com)
|
|
*/
|
|
|
|
#include "../include/LegacyAIPlan.h"
|
|
|
|
#include "../../TacticalAI/ai.h"
|
|
#include "../../TacticalAI/AIInternals.h" // ACTING_ON_SCHEDULE
|
|
#include "../../TacticalAI/NPC.h" // NPCReachedDestination
|
|
#include "../../Tactical/Animation Control.h" // defines ANIM_...
|
|
#include "../../Tactical/Soldier Macros.h" // CREATURE_OR_BLOODCAT
|
|
#include "../../Tactical/opplist.h" // EndMuzzleFlash
|
|
#include "../../Tactical/Dialogue Control.h" // DialogueQueueIsEmpty
|
|
#include "../../TileEngine/Isometric Utils.h" // defines NOWHERE
|
|
#include "../../Utils/Debug Control.h" // LiveMessage
|
|
#include "../../Utils/Font Control.h" // ScreenMsg about deadlock
|
|
#include "../../Utils/Text.h" // Sniper warning
|
|
#include "../../Utils/message.h" // ditto
|
|
|
|
|
|
namespace AI
|
|
{
|
|
namespace tactical
|
|
{
|
|
LegacyAIPlan::LegacyAIPlan(SOLDIERTYPE* npc)
|
|
: Plan(npc)
|
|
{
|
|
}
|
|
|
|
|
|
void LegacyAIPlan::execute(PlanInputData& environment)
|
|
{
|
|
if(!environment.turn_based())
|
|
{
|
|
if ( (get_npc()->ubProfile != NO_PROFILE) && (gMercProfiles[ get_npc()->ubProfile ].ubMiscFlags3 & PROFILE_MISC_FLAG3_HANDLE_DONE_TRAVERSAL ) )
|
|
{
|
|
TriggerNPCWithGivenApproach( get_npc()->ubProfile, APPROACH_DONE_TRAVERSAL, FALSE );
|
|
gMercProfiles[ get_npc()->ubProfile ].ubMiscFlags3 &= (~PROFILE_MISC_FLAG3_HANDLE_DONE_TRAVERSAL);
|
|
get_npc()->ubQuoteActionID = 0;
|
|
// wait a tiny bit
|
|
get_npc()->aiData.usActionData = 100;
|
|
get_npc()->aiData.bAction = AI_ACTION_WAIT;
|
|
return;
|
|
}
|
|
if (get_npc()->bTeam == gbPlayerNum)
|
|
{
|
|
if (environment.get_tactical_status().fAutoBandageMode)
|
|
{
|
|
get_npc()->aiData.bAction = DecideAutoBandage( get_npc() );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( get_npc()->bTeam != MILITIA_TEAM )
|
|
{
|
|
if ( !sniperwarning && get_npc()->aiData.bOrders == SNIPER )
|
|
{
|
|
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, New113Message[MSG113_WATHCHOUTFORSNIPERS] );
|
|
sniperwarning = TRUE;
|
|
|
|
// Flugente: additional dialogue
|
|
AdditionalTacticalCharacterDialogue_AllInCurrentSector( NO_PROFILE, ADE_SNIPERWARNING );
|
|
}
|
|
|
|
if (!biggunwarning && FindRocketLauncherOrCannon(get_npc()) != NO_SLOT )
|
|
{
|
|
biggunwarning = TRUE;
|
|
//TODO: don't say this again after reloading a savegame
|
|
SayQuoteFromAnyBodyInSector( QUOTE_WEARY_SLASH_SUSPUCIOUS );
|
|
}
|
|
}
|
|
get_npc()->aiData.fAIFlags &= (~AI_CAUTIOUS); // turn off cautious flag
|
|
// if status override is set, bypass RED/YELLOW and go directly to GREEN!
|
|
if ((get_npc()->aiData.bBypassToGreen) && (get_npc()->aiData.bAlertStatus < STATUS_BLACK))
|
|
{
|
|
get_npc()->aiData.bAction = DecideActionGreen(get_npc());
|
|
if ( !gfTurnBasedAI )
|
|
{
|
|
// reset bypass now
|
|
get_npc()->aiData.bBypassToGreen = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch (get_npc()->aiData.bAlertStatus)
|
|
{
|
|
case STATUS_GREEN:
|
|
get_npc()->aiData.bAction = DecideActionGreen(get_npc());
|
|
break;
|
|
case STATUS_YELLOW:
|
|
get_npc()->aiData.bAction = DecideActionYellow(get_npc());
|
|
break;
|
|
case STATUS_RED:
|
|
get_npc()->aiData.bAction = DecideActionRed(get_npc());
|
|
break;
|
|
case STATUS_BLACK:
|
|
get_npc()->aiData.bAction = DecideActionBlack(get_npc());
|
|
break;
|
|
}
|
|
}
|
|
DEBUGAIMSG("Deciding for guynum "<<(int)get_npc()->ubID<<" at gridno "<<get_npc()->sGridNo<<", APs "<<get_npc()->bActionPoints<<
|
|
", decided action: "<<(int)get_npc()->aiData.bAction<<", data "<<(int)get_npc()->aiData.usActionData);
|
|
}
|
|
|
|
} // namespace tactical
|
|
} // namespace AI
|
|
|