瀏覽代碼

Fixed total spell immunity granted by 2212.

Improvements for Life Drain.
DjWarmonger 14 年之前
父節點
當前提交
9ca5d9048a
共有 7 個文件被更改,包括 16 次插入8 次删除
  1. 1 0
      AI/GeniusAI/ExpertSystem.h
  2. 1 0
      client/CPlayerInterface.cpp
  3. 6 6
      lib/BattleState.cpp
  4. 1 1
      lib/CObjectHandler.cpp
  5. 5 0
      lib/HeroBonus.cpp
  6. 1 0
      lib/HeroBonus.h
  7. 1 1
      server/CGameHandler.cpp

+ 1 - 0
AI/GeniusAI/ExpertSystem.h

@@ -3,6 +3,7 @@
 #include "../vcmi/lib/HeroBonus.h"
 #include <boost/bind.hpp>
 #include <vector>
+#include <list>
 
 /*
  * ExpertSystem.h, part of VCMI engine

+ 1 - 0
client/CPlayerInterface.cpp

@@ -587,6 +587,7 @@ void CPlayerInterface::battleStacksHealedRes(const std::vector<std::pair<ui32, u
 			{
 				textOff += 1;
 			}
+			CCS->soundh->playSound(soundBase::DRAINLIF);
 		}
 
 		//print info about life drain

+ 6 - 6
lib/BattleState.cpp

@@ -1782,7 +1782,7 @@ bool BattleInfo::battleTestElementalImmunity(const CStack * subject, const CSpel
 {
 	if (spell->positiveness < 1) //negative or indifferent
 	{
-		if (damageSpell && subject->hasBonusOfType(element, 2) || subject->hasBonusOfType(element, 1))
+		if ((damageSpell && subject->hasBonusOfType(element, 2)) || subject->hasBonusOfType(element, 1))
 			return true;
 	}
 	else if (spell->positiveness == 1) //positive
@@ -1806,27 +1806,27 @@ SpellCasting::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance
 		
 		bool damageSpell = (VLC->spellh->damageSpells.find(spell->id) != VLC->spellh->damageSpells.end());
 
-		if (damageSpell && subject->hasBonusOfType(Bonus::DIRECT_DAMAGE_IMMUNITY));
+		if (damageSpell && subject->hasBonusOfType(Bonus::DIRECT_DAMAGE_IMMUNITY))
 			return SpellCasting::STACK_IMMUNE_TO_SPELL;
 
 		if (spell->fire)
 		{
-			if (battleTestElementalImmunity(subject, spell, Bonus::FIRE_IMMUNITY, damageSpell));
+			if (battleTestElementalImmunity(subject, spell, Bonus::FIRE_IMMUNITY, damageSpell))
 				return SpellCasting::STACK_IMMUNE_TO_SPELL;
 		}
 		if (spell->water)
 		{
-			if (battleTestElementalImmunity(subject, spell, Bonus::WATER_IMMUNITY, damageSpell));
+			if (battleTestElementalImmunity(subject, spell, Bonus::WATER_IMMUNITY, damageSpell))
 				return SpellCasting::STACK_IMMUNE_TO_SPELL;
 		}
 		if (spell->earth)
 		{
-			if (battleTestElementalImmunity(subject, spell, Bonus::EARTH_IMMUNITY, damageSpell));
+			if (battleTestElementalImmunity(subject, spell, Bonus::EARTH_IMMUNITY, damageSpell))
 				return SpellCasting::STACK_IMMUNE_TO_SPELL;
 		}
 		if (spell->air)
 		{
-			if (battleTestElementalImmunity(subject, spell, Bonus::AIR_IMMUNITY, damageSpell));
+			if (battleTestElementalImmunity(subject, spell, Bonus::AIR_IMMUNITY, damageSpell))
 				return SpellCasting::STACK_IMMUNE_TO_SPELL;
 		}
 

+ 1 - 1
lib/CObjectHandler.cpp

@@ -1346,7 +1346,7 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b
 		{
 			// Get lost enemy hit points convertible to units.
 			CCreature * c = VLC->creh->creatures[it->first];
-			if (!(c->hasBonusOfType(Bonus::UNDEAD) || c->hasBonusOfType(Bonus::NON_LIVING)))
+			if (c->isLiving())
 			{
 				const ui32 raisedHP = c->valOfBonuses(Bonus::STACK_HEALTH) * it->second * necromancySkill;
 				raisedUnits += std::min<ui32>(raisedHP / raisedUnitHP, it->second * necromancySkill); //limit to % of HP and % of original stack count

+ 5 - 0
lib/HeroBonus.cpp

@@ -319,6 +319,11 @@ si32 IBonusBearer::magicResistance() const
 	return valOfBonuses(Selector::type(Bonus::MAGIC_RESISTANCE));
 }
 
+bool IBonusBearer::isLiving() const //TODO: theoreticaly there exists "LIVING" bonus in stack experience documentation
+{
+	return(!hasBonus(Selector::type(Bonus::UNDEAD) || Selector::type(Bonus::NON_LIVING)));
+}
+
 void IBonusBearer::setCachingStr(const std::string &request) const
 {
 }

+ 1 - 0
lib/HeroBonus.h

@@ -426,6 +426,7 @@ public:
 	si32 Attack() const; //get attack of stack with all modificators
 	si32 Defense(bool withFrenzy = true) const; //get defense of stack with all modificators
 	ui16 MaxHealth() const; //get max HP of stack with all modifiers
+	bool isLiving() const; //non-undead, non-non living or alive
 	virtual si32 magicResistance() const;
 
 	si32 manaLimit() const; //maximum mana value for this hero (basically 10*knowledge)

+ 1 - 1
server/CGameHandler.cpp

@@ -545,7 +545,7 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
 	def->prepareAttacked(*bsa);
 
 	//life drain handling
-	if (att->hasBonusOfType(Bonus::LIFE_DRAIN))
+	if (att->hasBonusOfType(Bonus::LIFE_DRAIN) && def->isLiving())
 	{
 		StacksHealedOrResurrected shi;
 		shi.lifeDrain = (ui8)true;