From ef8f2e695f446a675d2a96431278bf805d551dc8 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Sat, 22 Aug 2009 14:39:44 +0000 Subject: [PATCH] * support for HP regeneration * minor fixes --- CCallback.cpp | 3 ++- client/CBattleInterface.cpp | 14 ++++++++++++++ config/cr_abils.txt | 5 +++-- lib/NetPacksLib.cpp | 9 +++++++++ lib/StackFeature.h | 3 ++- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/CCallback.cpp b/CCallback.cpp index d1795e36f..9d3e7bae0 100644 --- a/CCallback.cpp +++ b/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; diff --git a/client/CBattleInterface.cpp b/client/CBattleInterface.cpp index 84eed2c2f..9682c9273 100644 --- a/client/CBattleInterface.cpp +++ b/client/CBattleInterface.cpp @@ -1574,6 +1574,20 @@ void CBattleInterface::newRound(int number) //unlock spellbook bSpell->block(!LOCPLINT->cb->battleCanCastSpell()); + + //handle regeneration + std::map stacks = LOCPLINT->cb->battleGetStacks(); + for(std::map::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) diff --git a/config/cr_abils.txt b/config/cr_abils.txt index 2b6b167de..4fdffa9d9 100644 --- a/config/cr_abils.txt +++ b/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 diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index ba8d72e7d..30dbf68b2 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -15,6 +15,9 @@ #include #include +#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( 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 tmpEffects = s->effects; s->effects.clear(); diff --git a/lib/StackFeature.h b/lib/StackFeature.h index 79745cf90..495deea0f 100644 --- a/lib/StackFeature.h +++ b/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*/ \