mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Merge pull request #514 from dydzio0614/HeroAiValueFix
Hero ai value fix
This commit is contained in:
@@ -382,7 +382,7 @@ float VisitObjEngine::evaluate(Goals::VisitObj & goal)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
MapObjectsEvaluator::getInstance().addObjectData(obj->ID, obj->subID, 0);
|
MapObjectsEvaluator::getInstance().addObjectData(obj->ID, obj->subID, 0);
|
||||||
logGlobal->warn("AI met object type it doesn't know - ID: " + std::to_string(obj->ID) + ", subID: " + std::to_string(obj->subID) + " - adding to database with value " + std::to_string(objValue));
|
logGlobal->error("AI met object type it doesn't know - ID: " + std::to_string(obj->ID) + ", subID: " + std::to_string(obj->subID) + " - adding to database with value " + std::to_string(objValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
setSharedFuzzyVariables(goal);
|
setSharedFuzzyVariables(goal);
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
#include "../../lib/GameConstants.h"
|
#include "../../lib/GameConstants.h"
|
||||||
#include "../../lib/VCMI_Lib.h"
|
#include "../../lib/VCMI_Lib.h"
|
||||||
#include "../../lib/CCreatureHandler.h"
|
#include "../../lib/CCreatureHandler.h"
|
||||||
|
#include "../../lib/CHeroHandler.h"
|
||||||
|
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||||
#include "../../lib/mapObjects/CGTownInstance.h"
|
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||||
#include "../../lib/mapObjects/MiscObjects.h"
|
#include "../../lib/mapObjects/MiscObjects.h"
|
||||||
#include "../../lib/CRandomGenerator.h"
|
#include "../../lib/CRandomGenerator.h"
|
||||||
@@ -56,6 +58,12 @@ boost::optional<int> MapObjectsEvaluator::getObjectValue(int primaryID, int seco
|
|||||||
|
|
||||||
boost::optional<int> MapObjectsEvaluator::getObjectValue(const CGObjectInstance * obj) const
|
boost::optional<int> MapObjectsEvaluator::getObjectValue(const CGObjectInstance * obj) const
|
||||||
{
|
{
|
||||||
|
if(obj->ID == Obj::HERO)
|
||||||
|
{
|
||||||
|
//special case handling: in-game heroes have hero ID as object subID, but when reading configs available hero object subID's are hero classes
|
||||||
|
auto hero = dynamic_cast<const CGHeroInstance*>(obj);
|
||||||
|
return getObjectValue(obj->ID, hero->type->heroClass->id);
|
||||||
|
}
|
||||||
if(obj->ID == Obj::CREATURE_GENERATOR1 || obj->ID == Obj::CREATURE_GENERATOR4)
|
if(obj->ID == Obj::CREATURE_GENERATOR1 || obj->ID == Obj::CREATURE_GENERATOR4)
|
||||||
{
|
{
|
||||||
auto dwelling = dynamic_cast<const CGDwelling *>(obj);
|
auto dwelling = dynamic_cast<const CGDwelling *>(obj);
|
||||||
|
Reference in New Issue
Block a user