Răsfoiți Sursa

Merge pull request #557 from dydzio0614/CrystalDragonAbility

Fix crystal dragon ability to match H3
Alexander Shishkin 6 ani în urmă
părinte
comite
549d8c97df
3 a modificat fișierele cu 34 adăugiri și 4 ștergeri
  1. 1 4
      config/creatures/neutral.json
  2. 1 0
      lib/HeroBonus.h
  3. 32 0
      server/CGameHandler.cpp

+ 1 - 4
config/creatures/neutral.json

@@ -122,10 +122,7 @@
 			},
 			"crystals" :
 			{
-				"type" : "GENERATE_RESOURCE",
-				"subtype" : "resource.crystal",
-				"val" : 1,
-				"propagator" : "HERO"
+				"type" : "SPECIAL_CRYSTAL_GENERATION"
 			},
 			"FLYING_ARMY" : null
 		},

+ 1 - 0
lib/HeroBonus.h

@@ -269,6 +269,7 @@ public:
 	BONUS_NAME(SHOOTS_ALL_ADJACENT) /* H4 Cyclops-like shoot (attacks all hexes neighboring with target) without spell-like mechanics */\
 	BONUS_NAME(BLOCK_MAGIC_BELOW) /*blocks casting spells of the level < value */ \
 	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*/ \
 
 	/* end of list */
 

+ 32 - 0
server/CGameHandler.cpp

@@ -1739,6 +1739,38 @@ void CGameHandler::newTurn()
 
 		n.res[elem.first] = elem.second.resources;
 
+		if(!firstTurn && newWeek) //weekly crystal generation if 1 or more crystal dragons in any hero army or town garrison
+		{
+			bool hasCrystalGenCreature = false;
+			for(CGHeroInstance * hero : elem.second.heroes)
+			{
+				for(auto stack : hero->stacks)
+				{
+					if(stack.second->hasBonusOfType(Bonus::SPECIAL_CRYSTAL_GENERATION))
+					{
+						hasCrystalGenCreature = true;
+						break;
+					}
+				}
+			}
+			if(!hasCrystalGenCreature) //not found in armies, check towns
+			{
+				for(CGTownInstance * town : elem.second.towns)
+				{
+					for(auto stack : town->stacks)
+					{
+						if(stack.second->hasBonusOfType(Bonus::SPECIAL_CRYSTAL_GENERATION))
+						{
+							hasCrystalGenCreature = true;
+							break;
+						}
+					}
+				}
+			}
+			if(hasCrystalGenCreature)
+				n.res[elem.first][Res::CRYSTAL] += 3;
+		}
+
 		for (CGHeroInstance *h : (elem).second.heroes)
 		{
 			if (h->visitedTown)