mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Fix handling of tactics by AI
This commit is contained in:
parent
112a40a254
commit
639880a426
@ -251,7 +251,7 @@ BattleAction CBattleAI::selectStackAction(const CStack * stack)
|
||||
|
||||
void CBattleAI::yourTacticPhase(int distance)
|
||||
{
|
||||
cb->battleMakeUnitAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
|
||||
cb->battleMakeTacticAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
|
||||
}
|
||||
|
||||
void CBattleAI::activeStack( const CStack * stack )
|
||||
|
@ -41,7 +41,7 @@ void CEmptyAI::activeStack(const CStack * stack)
|
||||
|
||||
void CEmptyAI::yourTacticPhase(int distance)
|
||||
{
|
||||
cb->battleMakeUnitAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
|
||||
cb->battleMakeTacticAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
|
||||
}
|
||||
|
||||
void CEmptyAI::heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID)
|
||||
|
@ -90,7 +90,7 @@ static bool willSecondHexBlockMoreEnemyShooters(const BattleHex &h1, const Battl
|
||||
|
||||
void CStupidAI::yourTacticPhase(int distance)
|
||||
{
|
||||
cb->battleMakeUnitAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
|
||||
cb->battleMakeTacticAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
|
||||
}
|
||||
|
||||
void CStupidAI::activeStack( const CStack * stack )
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "../lib/gameState/CGameState.h"
|
||||
#include "../lib/CThreadHelper.h"
|
||||
#include "../lib/VCMIDirs.h"
|
||||
#include "../lib/UnlockGuard.h"
|
||||
#include "../lib/battle/BattleInfo.h"
|
||||
#include "../lib/serializer/BinaryDeserializer.h"
|
||||
#include "../lib/mapping/CMapService.h"
|
||||
@ -624,6 +625,14 @@ void CClient::battleStarted(const BattleInfo * info)
|
||||
CPlayerInterface::battleInt = std::make_shared<BattleInterface>(leftSide.armyObject, rightSide.armyObject, leftSide.hero, rightSide.hero, att, def, spectratorInt);
|
||||
}
|
||||
}
|
||||
|
||||
if(info->tacticDistance)
|
||||
{
|
||||
auto tacticianColor = info->sides[info->tacticsSide].color;
|
||||
|
||||
if (vstd::contains(battleints, tacticianColor))
|
||||
battleints[tacticianColor]->yourTacticPhase(info->tacticDistance);
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::battleFinished()
|
||||
@ -645,6 +654,9 @@ void CClient::startPlayerBattleAction(PlayerColor color)
|
||||
|
||||
if(vstd::contains(battleints, color))
|
||||
{
|
||||
// we want to avoid locking gamestate and causing UI to freeze while AI is making turn
|
||||
auto unlock = vstd::makeUnlockGuardIf(*CPlayerInterface::pim, !battleints[color]->human);
|
||||
|
||||
assert(vstd::contains(battleints, color));
|
||||
battleints[color]->activeStack(gs->curB->battleGetStackByID(gs->curB->activeStack, false));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user