mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-07 00:58:39 +02:00
NKAI: various AI fixes after tests in headless
This commit is contained in:
@ -586,13 +586,18 @@ void AIGateway::heroGotLevel(const CGHeroInstance * hero, PrimarySkill pskill, s
|
|||||||
|
|
||||||
requestActionASAP([=]()
|
requestActionASAP([=]()
|
||||||
{
|
{
|
||||||
|
int sel = 0;
|
||||||
|
|
||||||
if(hPtr.validAndSet())
|
if(hPtr.validAndSet())
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lockGuard(nullkiller->aiStateMutex);
|
std::unique_lock<std::mutex> lockGuard(nullkiller->aiStateMutex);
|
||||||
|
|
||||||
nullkiller->heroManager->update();
|
nullkiller->heroManager->update();
|
||||||
answerQuery(queryID, nullkiller->heroManager->selectBestSkill(hPtr, skills));
|
|
||||||
|
sel = nullkiller->heroManager->selectBestSkill(hPtr, skills);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
answerQuery(queryID, sel);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ TResources getCreatureBankResources(const CGObjectInstance * target, const CGHer
|
|||||||
return sum > 1 ? result / sum : result;
|
return sum > 1 ? result / sum : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t getResourcesGoldReward(TResources & res)
|
uint64_t getResourcesGoldReward(const TResources & res)
|
||||||
{
|
{
|
||||||
int nonGoldResources = res[EGameResID::GEMS]
|
int nonGoldResources = res[EGameResID::GEMS]
|
||||||
+ res[EGameResID::SULFUR]
|
+ res[EGameResID::SULFUR]
|
||||||
@ -541,6 +541,9 @@ float RewardEvaluator::getStrategicalValue(const CGObjectInstance * target) cons
|
|||||||
? getEnemyHeroStrategicalValue(dynamic_cast<const CGHeroInstance *>(target))
|
? getEnemyHeroStrategicalValue(dynamic_cast<const CGHeroInstance *>(target))
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
|
case Obj::KEYMASTER:
|
||||||
|
return 0.6f;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -524,25 +524,24 @@ void handleQuit(bool ask)
|
|||||||
// FIXME: avoids crash if player attempts to close game while opening is still playing
|
// FIXME: avoids crash if player attempts to close game while opening is still playing
|
||||||
// use cursor handler as indicator that loading is not done yet
|
// use cursor handler as indicator that loading is not done yet
|
||||||
// proper solution would be to abort init thread (or wait for it to finish)
|
// proper solution would be to abort init thread (or wait for it to finish)
|
||||||
|
if(!ask)
|
||||||
|
{
|
||||||
|
quitApplication();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!CCS->curh)
|
if (!CCS->curh)
|
||||||
{
|
{
|
||||||
quitRequestedDuringOpeningPlayback = true;
|
quitRequestedDuringOpeningPlayback = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ask)
|
CCS->curh->set(Cursor::Map::POINTER);
|
||||||
{
|
|
||||||
CCS->curh->set(Cursor::Map::POINTER);
|
|
||||||
|
|
||||||
if (LOCPLINT)
|
if (LOCPLINT)
|
||||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[69], quitApplication, nullptr);
|
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[69], quitApplication, nullptr);
|
||||||
else
|
|
||||||
CInfoWindow::showYesNoDialog(CGI->generaltexth->allTexts[69], {}, quitApplication, {}, PlayerColor(1));
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
CInfoWindow::showYesNoDialog(CGI->generaltexth->allTexts[69], {}, quitApplication, {}, PlayerColor(1));
|
||||||
quitApplication();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleFatalError(const std::string & message, bool terminate)
|
void handleFatalError(const std::string & message, bool terminate)
|
||||||
|
@ -249,9 +249,7 @@ PathfinderBlockingRule::BlockingReason MovementAfterDestinationRule::getBlocking
|
|||||||
}
|
}
|
||||||
|
|
||||||
case EPathNodeAction::BLOCKING_VISIT:
|
case EPathNodeAction::BLOCKING_VISIT:
|
||||||
return destination.guarded
|
return BlockingReason::DESTINATION_BLOCKVIS;
|
||||||
? BlockingReason::DESTINATION_GUARDED
|
|
||||||
: BlockingReason::DESTINATION_BLOCKVIS;
|
|
||||||
|
|
||||||
case EPathNodeAction::NORMAL:
|
case EPathNodeAction::NORMAL:
|
||||||
return BlockingReason::NONE;
|
return BlockingReason::NONE;
|
||||||
|
Reference in New Issue
Block a user