BattleAction.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. if(questInfo.obj->ID == Obj::BORDER_GATE || questInfo.obj->ID == Obj::BORDERGUARD)
  30. {
  31. return dynamic_cast<const IQuestObject *>(questInfo.obj)->checkQuest(node->actor->hero);
  32. }
  33. return questInfo.quest->progress == CQuest::NOT_ACTIVE
  34. || questInfo.quest->checkQuest(node->actor->hero);
  35. }
  36. Goals::TSubgoal QuestAction::decompose(const CGHeroInstance * hero) const
  37. {
  38. return Goals::sptr(Goals::CompleteQuest(questInfo));
  39. }
  40. void QuestAction::execute(const CGHeroInstance * hero) const
  41. {
  42. ai->moveHeroToTile(questInfo.obj->visitablePos(), hero);
  43. }
  44. std::string QuestAction::toString() const
  45. {
  46. return "Complete Quest";
  47. }
  48. }