1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

Hero try to execute a quest to kill himself

This commit is contained in:
Andrii Danylchenko 2018-11-03 15:26:21 +02:00
parent ff75e5e6e8
commit 3871ed0085

View File

@ -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:
{