mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Fix battle AI using Fire elementals (had score 0)
This commit is contained in:
@@ -596,9 +596,18 @@ void CBattleAI::attemptCastingSpell()
|
|||||||
|
|
||||||
size_t ourUnits = 0;
|
size_t ourUnits = 0;
|
||||||
|
|
||||||
for(auto unit : all)
|
std::set<uint32_t> unitIds;
|
||||||
|
|
||||||
|
state.battleGetUnitsIf([&](const battle::Unit * u)->bool
|
||||||
|
{
|
||||||
|
if(!u->isGhost() && !u->isTurret())
|
||||||
|
unitIds.insert(u->unitId());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
for(auto unitId : unitIds)
|
||||||
{
|
{
|
||||||
auto unitId = unit->unitId();
|
|
||||||
auto localUnit = state.battleGetUnitByID(unitId);
|
auto localUnit = state.battleGetUnitByID(unitId);
|
||||||
|
|
||||||
newHealthOfStack[unitId] = localUnit->getAvailableHealth();
|
newHealthOfStack[unitId] = localUnit->getAvailableHealth();
|
||||||
@@ -620,9 +629,8 @@ void CBattleAI::attemptCastingSpell()
|
|||||||
{
|
{
|
||||||
int64_t totalGain = 0;
|
int64_t totalGain = 0;
|
||||||
|
|
||||||
for(auto unit : all)
|
for(auto unitId : unitIds)
|
||||||
{
|
{
|
||||||
auto unitId = unit->unitId();
|
|
||||||
auto localUnit = state.battleGetUnitByID(unitId);
|
auto localUnit = state.battleGetUnitByID(unitId);
|
||||||
|
|
||||||
auto newValue = getValOr(newValueOfStack, unitId, 0);
|
auto newValue = getValOr(newValueOfStack, unitId, 0);
|
||||||
|
Reference in New Issue
Block a user