1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

AI pathfinding shared storage

This commit is contained in:
Andrii Danylchenko
2021-05-15 19:22:49 +03:00
committed by Andrii Danylchenko
parent be4f803d4a
commit 0bff5f9eb6
14 changed files with 262 additions and 191 deletions

View File

@@ -73,14 +73,16 @@ namespace AIPathfinding
}
}
auto hero = nodeStorage->getHero();
auto summonBoatSpell = SpellID(SpellID::SUMMON_BOAT).toSpell();
if(hero->canCastThisSpell(summonBoatSpell)
&& hero->getSpellSchoolLevel(summonBoatSpell) >= SecSkillLevel::ADVANCED)
for(const CGHeroInstance * hero : nodeStorage->getAllHeroes())
{
// TODO: For lower school level we might need to check the existance of some boat
summonableVirtualBoat.reset(new SummonBoatAction());
auto summonBoatSpell = SpellID(SpellID::SUMMON_BOAT).toSpell();
if(hero->canCastThisSpell(summonBoatSpell)
&& hero->getSpellSchoolLevel(summonBoatSpell) >= SecSkillLevel::ADVANCED)
{
// TODO: For lower school level we might need to check the existance of some boat
summonableVirtualBoats[hero] = std::make_shared<SummonBoatAction>();
}
}
}
@@ -94,11 +96,15 @@ namespace AIPathfinding
{
virtualBoat = virtualBoats.at(destination.coord);
}
else if(
summonableVirtualBoat
&& summonableVirtualBoat->isAffordableBy(nodeStorage->getHero(), nodeStorage->getAINode(source.node)))
else
{
virtualBoat = summonableVirtualBoat;
const CGHeroInstance * hero = nodeStorage->getHero(source.node);
if(vstd::contains(summonableVirtualBoats, hero)
&& summonableVirtualBoats.at(hero)->isAffordableBy(hero, nodeStorage->getAINode(source.node)))
{
virtualBoat = summonableVirtualBoats.at(hero);
}
}
return virtualBoat;
@@ -116,7 +122,7 @@ namespace AIPathfinding
auto boatNodeOptional = nodeStorage->getOrCreateNode(
node->coord,
node->layer,
node->chainMask | virtualBoat->getSpecialChain());
virtualBoat->getActor(node->actor));
if(boatNodeOptional)
{