瀏覽代碼

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
Fior.in 7 年之前
父節點
當前提交
47ba3b2476
共有 5 個文件被更改,包括 33 次插入7 次删除
  1. 21 6
      client/battle/CBattleInterface.cpp
  2. 5 0
      config/schemas/hero.json
  3. 1 0
      lib/CHeroHandler.cpp
  4. 5 0
      lib/CHeroHandler.h
  5. 1 1
      lib/serializer/CSerializer.h

+ 21 - 6
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<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
 	{
 		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<CBattleHero>(battleImage, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : nullptr, this);
 

+ 5 - 0
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"
 				}
 			}
 		},

+ 1 - 0
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);

+ 5 - 0
lib/CHeroHandler.h

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

+ 1 - 1
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";