소스 검색

* support for HP regeneration
* minor fixes

mateuszb 16 년 전
부모
커밋
ef8f2e695f
5개의 변경된 파일30개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 1
      CCallback.cpp
  2. 14 0
      client/CBattleInterface.cpp
  3. 3 2
      config/cr_abils.txt
  4. 9 0
      lib/NetPacksLib.cpp
  5. 2 1
      lib/StackFeature.h

+ 2 - 1
CCallback.cpp

@@ -563,7 +563,8 @@ bool CCallback::battleCanShoot(int ID, int dest)
 	if(our->hasFeatureOfType(StackFeature::SHOOTER)//it's shooter
 		&& our->owner != dst->owner
 		&& dst->alive()
-		&& (!gs->curB->isStackBlocked(ID) || gs->getHero(ourHero)->hasBonusOfType(HeroBonus::FREE_SHOOTING))
+		&& (!gs->curB->isStackBlocked(ID) || 
+			( gs->getHero(ourHero) && gs->getHero(ourHero)->hasBonusOfType(HeroBonus::FREE_SHOOTING) ) )
 		&& our->shots
 		)
 		return true;

+ 14 - 0
client/CBattleInterface.cpp

@@ -1574,6 +1574,20 @@ void CBattleInterface::newRound(int number)
 
 	//unlock spellbook
 	bSpell->block(!LOCPLINT->cb->battleCanCastSpell());
+
+	//handle regeneration
+	std::map<int, CStack> stacks = LOCPLINT->cb->battleGetStacks();
+	for(std::map<int, CStack>::const_iterator it = stacks.begin(); it != stacks.end(); ++it)
+	{
+		if( it->second.hasFeatureOfType(StackFeature::HP_REGENERATION) )
+			displayEffect(74, it->second.position);
+
+		if( it->second.hasFeatureOfType(StackFeature::FULL_HP_REGENERATION, 0) )
+			displayEffect(4, it->second.position);
+
+		if( it->second.hasFeatureOfType(StackFeature::FULL_HP_REGENERATION, 1) )
+			displayEffect(74, it->second.position);
+	}
 }
 
 void CBattleInterface::giveCommand(ui8 action, ui16 tile, ui32 stack, si32 additional)

+ 3 - 2
config/cr_abils.txt

@@ -74,9 +74,9 @@
 +  55 ENEMY_LUCK_DECREASING -1 0 0 	//archdevils
 +  55 HATE 0 12 0		   	 		//archdevils hate angels
 +  55 HATE 0 13 0					//archdevils hate archangles
-+  60 REGENERATION 0 0 0			//wight
++  60 FULL_HP_REGENERATION 0 1 0			//wight
 +  61 MANA_DRAIN 2 0 0 				//wraith
-+  61 REGENERATION 0 0 0 			//wraith
++  61 FULL_HP_REGENERATION 0 1 0 			//wraith
 +  62 BLOCKS_RETALIATION 0 0 0		//vampires
 +  63 BLOCKS_RETALIATION 0 0 0		//vampire lords
 +  63 LIFE_DRAIN 0 0 0	   	 		//vampire lords
@@ -160,6 +160,7 @@
 + 123 DOUBLE_WIDE 0 0 0 			//ice elemental should be treated as double-wide
 + 140 DOUBLE_WIDE 0 0 0 			//boar should be treated as double-wide
 + 142 DOUBLE_WIDE 0 0 0 			//nomads should be treated as double-wide
++ 144 FULL_HP_REGENERATION 0 0 0 			//troll
 + 147 NOT_ACTIVE 0 0 0	   	 		//First Aid Tent //TODO: remove when support is added
 + 148 NOT_ACTIVE 0 0 0				//Ammo Cart
 -  46 FLYING		  				//hell hound doesn't fly

+ 9 - 0
lib/NetPacksLib.cpp

@@ -15,6 +15,9 @@
 #include <boost/thread.hpp>
 #include <boost/thread/shared_mutex.hpp>
 
+#undef min
+#undef max
+
 /*
  * NetPacksLib.cpp, part of VCMI engine
  *
@@ -602,6 +605,12 @@ DLL_EXPORT void BattleNextRound::applyGs( CGameState *gs )
 		s->state -= HAD_MORALE;
 		s->counterAttacks = 1 + s->valOfFeatures(StackFeature::ADDITIONAL_RETALIATION);
 
+		//regeneration
+		if( s->hasFeatureOfType(StackFeature::HP_REGENERATION) )
+			s->firstHPleft = std::min<ui32>( s->MaxHealth(), s->valOfFeatures(StackFeature::HP_REGENERATION) );
+		if( s->hasFeatureOfType(StackFeature::FULL_HP_REGENERATION) )
+			s->firstHPleft = s->MaxHealth();
+
 		//remove effects and restore only those with remaining turns in duration
 		std::vector<CStack::StackEffect> tmpEffects = s->effects;
 		s->effects.clear();

+ 2 - 1
lib/StackFeature.h

@@ -40,7 +40,8 @@ struct StackFeature
 	VCMI_CREATURE_ABILITY_NAME(ENEMY_MORALE_DECREASING) /*value - how much it decreases*/ \
 	VCMI_CREATURE_ABILITY_NAME(ENEMY_LUCK_DECREASING)					\
 	VCMI_CREATURE_ABILITY_NAME(UNDEAD)									\
-	VCMI_CREATURE_ABILITY_NAME(REGENERATION)							\
+	VCMI_CREATURE_ABILITY_NAME(HP_REGENERATION) /*creature regenerates val HP every new round*/					\
+	VCMI_CREATURE_ABILITY_NAME(FULL_HP_REGENERATION) /*first creature regenerates all HP every new round; subtype 0 - animation 4 (trolllike), 1 - animation 47 (wightlike)*/		\
 	VCMI_CREATURE_ABILITY_NAME(MANA_DRAIN) /*value - spell points per turn*/ \
 	VCMI_CREATURE_ABILITY_NAME(LIFE_DRAIN)								\
 	VCMI_CREATURE_ABILITY_NAME(DOUBLE_DAMAGE_CHANCE) /*value in %, eg. dread knight*/ \