QuestAction.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * QuestAction.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 "QuestAction.h"
  12. #include "../../AIGateway.h"
  13. #include "../../Goals/CompleteQuest.h"
  14. namespace NKAI
  15. {
  16. extern boost::thread_specific_ptr<CCallback> cb;
  17. extern boost::thread_specific_ptr<AIGateway> ai;
  18. namespace AIPathfinding
  19. {
  20. bool QuestAction::canAct(const AIPathNode * node) const
  21. {
  22. if(questInfo.obj->ID == Obj::BORDER_GATE || questInfo.obj->ID == Obj::BORDERGUARD)
  23. {
  24. return dynamic_cast<const IQuestObject *>(questInfo.obj)->checkQuest(node->actor->hero);
  25. }
  26. return questInfo.quest->progress == CQuest::NOT_ACTIVE
  27. || questInfo.quest->checkQuest(node->actor->hero);
  28. }
  29. Goals::TSubgoal QuestAction::decompose(const CGHeroInstance * hero) const
  30. {
  31. return Goals::sptr(Goals::CompleteQuest(questInfo));
  32. }
  33. void QuestAction::execute(const CGHeroInstance * hero) const
  34. {
  35. ai->moveHeroToTile(questInfo.obj->visitablePos(), hero);
  36. }
  37. std::string QuestAction::toString() const
  38. {
  39. return "Complete Quest";
  40. }
  41. }
  42. }