1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Hero scheme: allow each hero to have a unique battle animation (#480)

* attribute for battle image added on hero class, allowing on hero schemes each hero have a unique battle .def in 'images' structures sided with portraits and specialties images
This commit is contained in:
Fior.in 2018-08-27 03:42:36 -03:00 committed by ArseniyShestakov
parent 26fe5607ac
commit 47ba3b2476
5 changed files with 33 additions and 7 deletions

View File

@ -256,10 +256,17 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
if(hero1) // attacking hero if(hero1) // attacking hero
{ {
std::string battleImage; std::string battleImage;
if(hero1->sex) if(!hero1->type->battleImage.empty())
battleImage = hero1->type->heroClass->imageBattleFemale; {
battleImage = hero1->type->battleImage;
}
else else
battleImage = hero1->type->heroClass->imageBattleMale; {
if(hero1->sex)
battleImage = hero1->type->heroClass->imageBattleFemale;
else
battleImage = hero1->type->heroClass->imageBattleMale;
}
attackingHero = std::make_shared<CBattleHero>(battleImage, false, hero1->tempOwner, hero1->tempOwner == curInt->playerID ? hero1 : nullptr, this); attackingHero = std::make_shared<CBattleHero>(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 if(hero2) // defending hero
{ {
std::string battleImage; std::string battleImage;
if(hero2->sex)
battleImage = hero2->type->heroClass->imageBattleFemale; if(!hero2->type->battleImage.empty())
{
battleImage = hero2->type->battleImage;
}
else else
battleImage = hero2->type->heroClass->imageBattleMale; {
if(hero2->sex)
battleImage = hero2->type->heroClass->imageBattleFemale;
else
battleImage = hero2->type->heroClass->imageBattleMale;
}
defendingHero = std::make_shared<CBattleHero>(battleImage, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : nullptr, this); defendingHero = std::make_shared<CBattleHero>(battleImage, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : nullptr, this);

View File

@ -84,6 +84,11 @@
"type":"string", "type":"string",
"description": "Small image of hero specialty for use in exchange screen", "description": "Small image of hero specialty for use in exchange screen",
"format" : "imageFile" "format" : "imageFile"
},
"battleImage": {
"type":"string",
"description": "Custom def used on battle",
"format" : "defFile"
} }
} }
}, },

View File

@ -322,6 +322,7 @@ CHero * CHeroHandler::loadFromJson(const JsonNode & node, const std::string & id
hero->iconSpecLarge = node["images"]["specialtyLarge"].String(); hero->iconSpecLarge = node["images"]["specialtyLarge"].String();
hero->portraitSmall = node["images"]["small"].String(); hero->portraitSmall = node["images"]["small"].String();
hero->portraitLarge = node["images"]["large"].String(); hero->portraitLarge = node["images"]["large"].String();
hero->battleImage = node["images"]["battleImage"].String();
loadHeroArmy(hero, node); loadHeroArmy(hero, node);
loadHeroSkills(hero, node); loadHeroSkills(hero, node);

View File

@ -91,6 +91,7 @@ public:
std::string iconSpecLarge; std::string iconSpecLarge;
std::string portraitSmall; std::string portraitSmall;
std::string portraitLarge; std::string portraitLarge;
std::string battleImage;
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
@ -125,6 +126,10 @@ public:
{ {
h & identifier; h & identifier;
} }
if(version >= 790)
{
h & battleImage;
}
} }
}; };

View File

@ -12,7 +12,7 @@
#include "../ConstTransitivePtr.h" #include "../ConstTransitivePtr.h"
#include "../GameConstants.h" #include "../GameConstants.h"
const ui32 SERIALIZATION_VERSION = 789; const ui32 SERIALIZATION_VERSION = 790;
const ui32 MINIMAL_SERIALIZATION_VERSION = 753; const ui32 MINIMAL_SERIALIZATION_VERSION = 753;
const std::string SAVEGAME_MAGIC = "VCMISVG"; const std::string SAVEGAME_MAGIC = "VCMISVG";