BattleAction.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * BattleAction.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "BattleAction.h"
  12. #include "../../VCAI.h"
  13. #include "../../Behaviors/CompleteQuestBehavior.h"
  14. #include "../../../../lib/mapping/CMap.h" //for victory conditions
  15. extern boost::thread_specific_ptr<CCallback> cb;
  16. extern boost::thread_specific_ptr<VCAI> ai;
  17. namespace AIPathfinding
  18. {
  19. void BattleAction::execute(const CGHeroInstance * hero) const
  20. {
  21. ai->moveHeroToTile(targetTile, hero);
  22. }
  23. std::string BattleAction::toString() const
  24. {
  25. return "Battle at " + targetTile.toString();
  26. }
  27. bool QuestAction::canAct(const AIPathNode * node) const
  28. {
  29. QuestInfo q = questInfo;
  30. return q.quest->checkQuest(node->actor->hero);
  31. }
  32. Goals::TSubgoal QuestAction::decompose(const CGHeroInstance * hero) const
  33. {
  34. return Goals::sptr(Goals::Invalid());
  35. }
  36. void QuestAction::execute(const CGHeroInstance * hero) const
  37. {
  38. ai->moveHeroToTile(questInfo.obj->visitablePos(), hero);
  39. }
  40. std::string QuestAction::toString() const
  41. {
  42. return "Complete Quest";
  43. }
  44. }