From 3871ed0085798fe269340cd449aad4a442c87d4a Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Sat, 3 Nov 2018 15:26:21 +0200 Subject: [PATCH] Hero try to execute a quest to kill himself --- AI/VCAI/VCAI.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 8ebd1dc35..713df10a9 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -2469,7 +2469,6 @@ Goals::TSubgoal VCAI::questToGoal(const QuestInfo & q) } return sptr(Goals::FindObj(Obj::PRISON)); //rule of a thumb - quest heroes usually are locked in prisons //BNLOG ("Don't know how to recruit hero with id %d\n", q.quest->m13489val); - break; } case CQuest::MISSION_ARMY: { @@ -2513,11 +2512,27 @@ Goals::TSubgoal VCAI::questToGoal(const QuestInfo & q) case CQuest::MISSION_KILL_CREATURE: { auto obj = cb->getObjByQuestIdentifier(q.quest->m13489val); - if (obj) - return sptr(Goals::VisitObj(obj->id.getNum())); - else + + if(!obj) return sptr(Goals::VisitObj(q.obj->id.getNum())); //visit seer hut - break; + + if(obj->ID == Obj::HERO) + { + auto relations = myCb->getPlayerRelations(playerID, obj->tempOwner); + + if(relations == PlayerRelations::SAME_PLAYER) + { + auto heroToProtect = cb->getHero(obj->id); + + return sptr(Goals::GatherArmy().sethero(heroToProtect)); + } + else if(relations == PlayerRelations::ALLIES) + { + break; + } + } + + return sptr(Goals::VisitObj(obj->id.getNum())); } case CQuest::MISSION_PRIMARY_STAT: {