diff --git a/client/battle/CBattleInterface.cpp b/client/battle/CBattleInterface.cpp index b1f5121a6..1fa1bd084 100644 --- a/client/battle/CBattleInterface.cpp +++ b/client/battle/CBattleInterface.cpp @@ -256,10 +256,17 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet if(hero1) // attacking hero { std::string battleImage; - if(hero1->sex) - battleImage = hero1->type->heroClass->imageBattleFemale; + if(!hero1->type->battleImage.empty()) + { + battleImage = hero1->type->battleImage; + } else - battleImage = hero1->type->heroClass->imageBattleMale; + { + if(hero1->sex) + battleImage = hero1->type->heroClass->imageBattleFemale; + else + battleImage = hero1->type->heroClass->imageBattleMale; + } attackingHero = std::make_shared(battleImage, false, hero1->tempOwner, hero1->tempOwner == curInt->playerID ? hero1 : nullptr, this); @@ -272,10 +279,18 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet if(hero2) // defending hero { std::string battleImage; - if(hero2->sex) - battleImage = hero2->type->heroClass->imageBattleFemale; + + if(!hero2->type->battleImage.empty()) + { + battleImage = hero2->type->battleImage; + } else - battleImage = hero2->type->heroClass->imageBattleMale; + { + if(hero2->sex) + battleImage = hero2->type->heroClass->imageBattleFemale; + else + battleImage = hero2->type->heroClass->imageBattleMale; + } defendingHero = std::make_shared(battleImage, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : nullptr, this); diff --git a/config/schemas/hero.json b/config/schemas/hero.json index d88163dc6..68c3a474a 100644 --- a/config/schemas/hero.json +++ b/config/schemas/hero.json @@ -84,6 +84,11 @@ "type":"string", "description": "Small image of hero specialty for use in exchange screen", "format" : "imageFile" + }, + "battleImage": { + "type":"string", + "description": "Custom def used on battle", + "format" : "defFile" } } }, diff --git a/lib/CHeroHandler.cpp b/lib/CHeroHandler.cpp index 1f0c7cdcd..12231c508 100644 --- a/lib/CHeroHandler.cpp +++ b/lib/CHeroHandler.cpp @@ -322,6 +322,7 @@ CHero * CHeroHandler::loadFromJson(const JsonNode & node, const std::string & id hero->iconSpecLarge = node["images"]["specialtyLarge"].String(); hero->portraitSmall = node["images"]["small"].String(); hero->portraitLarge = node["images"]["large"].String(); + hero->battleImage = node["images"]["battleImage"].String(); loadHeroArmy(hero, node); loadHeroSkills(hero, node); diff --git a/lib/CHeroHandler.h b/lib/CHeroHandler.h index 1608efa5a..fd0407de2 100644 --- a/lib/CHeroHandler.h +++ b/lib/CHeroHandler.h @@ -91,6 +91,7 @@ public: std::string iconSpecLarge; std::string portraitSmall; std::string portraitLarge; + std::string battleImage; template void serialize(Handler &h, const int version) { @@ -125,6 +126,10 @@ public: { h & identifier; } + if(version >= 790) + { + h & battleImage; + } } }; diff --git a/lib/serializer/CSerializer.h b/lib/serializer/CSerializer.h index 794af38dd..49b24b5ea 100644 --- a/lib/serializer/CSerializer.h +++ b/lib/serializer/CSerializer.h @@ -12,7 +12,7 @@ #include "../ConstTransitivePtr.h" #include "../GameConstants.h" -const ui32 SERIALIZATION_VERSION = 789; +const ui32 SERIALIZATION_VERSION = 790; const ui32 MINIMAL_SERIALIZATION_VERSION = 753; const std::string SAVEGAME_MAGIC = "VCMISVG";