Переглянути джерело

Improvements to skeleton transformer logic

Ivan Savenko 4 місяців тому
батько
коміт
0e2463f9c4

+ 10 - 0
config/creatures/dungeon.json

@@ -429,6 +429,11 @@
 			{
 				"type" : "DRAGON_NATURE"
 			},
+			"dragonSkeleton" : 
+			{
+				"type" : "SKELETON_TRANSFORMER_TARGET",
+				"subtype" : "boneDragon"
+			},
 			"canFly" :
 			{
 				"type" : "FLYING"
@@ -474,6 +479,11 @@
 			{
 				"type" : "DRAGON_NATURE"
 			},
+			"dragonSkeleton" : 
+			{
+				"type" : "SKELETON_TRANSFORMER_TARGET",
+				"subtype" : "boneDragon"
+			},
 			"canFly" :
 			{
 				"type" : "FLYING"

+ 6 - 4
config/creatures/fortress.json

@@ -349,9 +349,10 @@
 			{
 				"type" : "ATTACKS_ALL_ADJACENT"
 			},
-			"draconicSkeleton" :
+			"dragonSkeleton" : 
 			{
-				"type" : "DRACONIC_SKELETON"
+				"type" : "SKELETON_TRANSFORMER_TARGET",
+				"subtype" : "boneDragon"
 			},
 			"noRetaliation" :
 			{
@@ -389,9 +390,10 @@
 			{
 				"type" : "ATTACKS_ALL_ADJACENT"
 			},
-			"draconicSkeleton" :
+			"dragonSkeleton" : 
 			{
-				"type" : "DRACONIC_SKELETON"
+				"type" : "SKELETON_TRANSFORMER_TARGET",
+				"subtype" : "boneDragon"
 			},
 			"noRetaliation" :
 			{

+ 20 - 0
config/creatures/neutral.json

@@ -75,6 +75,11 @@
 			{
 				"type" : "DRAGON_NATURE"
 			},
+			"dragonSkeleton" : 
+			{
+				"type" : "SKELETON_TRANSFORMER_TARGET",
+				"subtype" : "boneDragon"
+			},
 			"canFly" :
 			{
 				"type" : "FLYING"
@@ -135,6 +140,11 @@
 			{
 				"type" : "DRAGON_NATURE"
 			},
+			"dragonSkeleton" : 
+			{
+				"type" : "SKELETON_TRANSFORMER_TARGET",
+				"subtype" : "boneDragon"
+			},
 			"crystals" :
 			{
 				"type" : "SPECIAL_CRYSTAL_GENERATION"
@@ -176,6 +186,11 @@
 			{
 				"type" : "DRAGON_NATURE"
 			},
+			"dragonSkeleton" : 
+			{
+				"type" : "SKELETON_TRANSFORMER_TARGET",
+				"subtype" : "boneDragon"
+			},
 			"canFly" :
 			{
 				"type" : "FLYING"
@@ -284,6 +299,11 @@
 			{
 				"type" : "DRAGON_NATURE"
 			},
+			"dragonSkeleton" : 
+			{
+				"type" : "SKELETON_TRANSFORMER_TARGET",
+				"subtype" : "boneDragon"
+			},
 			"canFly" :
 			{
 				"type" : "FLYING"

+ 10 - 0
config/creatures/rampart.json

@@ -366,6 +366,11 @@
 			{
 				"type" : "DRAGON_NATURE"
 			},
+			"dragonSkeleton" : 
+			{
+				"type" : "SKELETON_TRANSFORMER_TARGET",
+				"subtype" : "boneDragon"
+			},
 			"canFly" :
 			{
 				"type" : "FLYING"
@@ -411,6 +416,11 @@
 			{
 				"type" : "DRAGON_NATURE"
 			},
+			"dragonSkeleton" : 
+			{
+				"type" : "SKELETON_TRANSFORMER_TARGET",
+				"subtype" : "boneDragon"
+			},
 			"canFly" :
 			{
 				"type" : "FLYING"

+ 1 - 1
lib/bonuses/BonusEnum.h

@@ -148,7 +148,7 @@ class JsonNode;
 	BONUS_NAME(DESTRUCTION) /*kills extra units after hit, subtype = 0 - kill percentage of units, 1 - kill amount, val = chance in percent to trigger, additional info - amount/percentage to kill*/ \
 	BONUS_NAME(SPECIAL_CRYSTAL_GENERATION) /*crystal dragon crystal generation*/ \
 	BONUS_NAME(NO_SPELLCAST_BY_DEFAULT) /*spellcast will not be default attack option for this creature*/ \
-	BONUS_NAME(DRACONIC_SKELETON) /* for skeleton transformer */ \
+	BONUS_NAME(SKELETON_TRANSFORMER_TARGET) /* for skeleton transformer */ \
 	BONUS_NAME(SPECIAL_ADD_VALUE_ENCHANT) /*specialty spell like Aenin has, increased effect of spell, additionalInfo = value to add*/\
 	BONUS_NAME(SPECIAL_FIXED_VALUE_ENCHANT) /*specialty spell like Melody has, constant spell effect (i.e. 3 luck), additionalInfo = value to fix.*/\
 	BONUS_NAME(THIEVES_GUILD_ACCESS) \

+ 1 - 4
lib/mapObjects/CArmedInstance.cpp

@@ -70,9 +70,6 @@ void CArmedInstance::updateMoraleBonusFromArmy()
 	std::set<FactionID> factions;
 	bool hasUndead = false;
 
-	const std::string undeadCacheKey = "type_UNDEAD";
-	static const CSelector undeadSelector = Selector::type()(BonusType::UNDEAD);
-
 	for(const auto & slot : Slots())
 	{
 		const auto * creature  = slot.second->getCreatureID().toEntity(LIBRARY);
@@ -82,7 +79,7 @@ void CArmedInstance::updateMoraleBonusFromArmy()
 		if (!hasUndead)
 		{
 			//this is costly check, let's skip it at first undead
-			hasUndead |= slot.second->hasBonus(undeadSelector, undeadCacheKey);
+			hasUndead |= slot.second->hasBonusOfType(BonusType::UNDEAD);
 		}
 	}
 

+ 4 - 5
server/CGameHandler.cpp

@@ -3254,11 +3254,10 @@ bool CGameHandler::transformInUndead(const IMarket *market, const CGHeroInstance
 	//resulting creature - bone dragons or skeletons
 	CreatureID resCreature = CreatureID::SKELETON;
 
-	if (!s.hasBonusOfType(BonusType::UNDEAD))
-	{
-		if (s.hasBonusOfType(BonusType::DRAGON_NATURE) || s.hasBonusOfType(BonusType::DRACONIC_SKELETON))
-			resCreature = CreatureID::BONE_DRAGON;
-	}
+	auto customTargerBonus = s.getBonusesOfType(BonusType::SKELETON_TRANSFORMER_TARGET);
+	if (!customTargerBonus->empty())
+		resCreature = customTargerBonus->front()->subtype.as<CreatureID>();
+
 	changeStackType(StackLocation(army->id, slot), resCreature.toCreature());
 	return true;
 }