2021-05-15 18:22:44 +02:00
|
|
|
/*
|
|
|
|
* TownPortalAction.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdInc.h"
|
|
|
|
#include "../../Goals/AdventureSpellCast.h"
|
|
|
|
#include "../../../../lib/mapObjects/MapObjects.h"
|
|
|
|
#include "TownPortalAction.h"
|
|
|
|
|
2022-09-26 20:01:07 +02:00
|
|
|
namespace NKAI
|
|
|
|
{
|
|
|
|
|
2021-05-15 18:22:44 +02:00
|
|
|
using namespace AIPathfinding;
|
|
|
|
|
2021-05-16 13:38:53 +02:00
|
|
|
void TownPortalAction::execute(const CGHeroInstance * hero) const
|
|
|
|
{
|
|
|
|
auto goal = Goals::AdventureSpellCast(hero, SpellID::TOWN_PORTAL);
|
|
|
|
|
|
|
|
goal.town = target;
|
|
|
|
goal.tile = target->visitablePos();
|
|
|
|
|
2023-07-31 16:00:37 +02:00
|
|
|
goal.accept(ai);
|
2021-05-16 13:38:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TownPortalAction::toString() const
|
|
|
|
{
|
2023-01-04 15:17:50 +02:00
|
|
|
return "Town Portal to " + target->getNameTranslated();
|
2021-05-16 13:38:53 +02:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
bool TownPortalAction::canAct(const CGHeroInstance * hero, const AIPathNode * source) const
|
|
|
|
{
|
|
|
|
#ifdef VCMI_TRACE_PATHFINDER
|
|
|
|
logAi->trace(
|
|
|
|
"Hero %s has %d mana and needed %d and already spent %d",
|
|
|
|
hero->name,
|
|
|
|
hero->mana,
|
|
|
|
getManaCost(hero),
|
|
|
|
source->manaCost);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return hero->mana >= source->manaCost + getManaCost(hero);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t TownPortalAction::getManaCost(const CGHeroInstance * hero) const
|
2021-05-15 18:22:44 +02:00
|
|
|
{
|
2021-05-16 13:38:53 +02:00
|
|
|
SpellID summonBoat = SpellID::TOWN_PORTAL;
|
2021-05-15 18:22:44 +02:00
|
|
|
|
2021-05-16 13:38:53 +02:00
|
|
|
return hero->getSpellCost(summonBoat.toSpell());
|
2022-09-26 20:01:07 +02:00
|
|
|
}*/
|
|
|
|
|
|
|
|
}
|