mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Implemented #479
This commit is contained in:
parent
423fd2ffb7
commit
af8d8cbfc7
@ -206,7 +206,7 @@ void CStupidAI::battleStart(const CCreatureSet *army1, const CCreatureSet *army2
|
||||
side = Side;
|
||||
}
|
||||
|
||||
void CStupidAI::battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom)
|
||||
void CStupidAI::battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom)
|
||||
{
|
||||
print("battleStacksHealedRes called");
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
void battleSpellCast(const BattleSpellCast *sc) OVERRIDE;
|
||||
void battleStacksEffectsSet(const SetStackEffect & sse) OVERRIDE;//called when a specific effect is set to stacks
|
||||
void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) OVERRIDE; //called by engine when battle starts; side=0 - left, side=1 - right
|
||||
void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom) OVERRIDE; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp
|
||||
void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) OVERRIDE; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp
|
||||
void battleNewStackAppeared(const CStack * stack) OVERRIDE; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
|
||||
void battleObstaclesRemoved(const std::set<si32> & removedObstacles) OVERRIDE; //called when a certain set of obstacles is removed from batlefield; IDs of them are given
|
||||
void battleCatapultAttacked(const CatapultAttack & ca) OVERRIDE; //called when catapult makes an attack
|
||||
|
@ -556,7 +556,7 @@ void CPlayerInterface::battleStart(const CCreatureSet *army1, const CCreatureSet
|
||||
}
|
||||
|
||||
|
||||
void CPlayerInterface::battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom)
|
||||
void CPlayerInterface::battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom)
|
||||
{
|
||||
if(LOCPLINT != this)
|
||||
{ //another local interface should do this
|
||||
@ -594,6 +594,14 @@ void CPlayerInterface::battleStacksHealedRes(const std::vector<std::pair<ui32, u
|
||||
healedStacks[0].second, defender->getCreature()->namePl.c_str());
|
||||
battleInt->console->addText(textBuf);
|
||||
}
|
||||
if (tentHeal)
|
||||
{
|
||||
std::string text = CGI->generaltexth->allTexts[414];
|
||||
boost::algorithm::replace_first(text, "%s", cb->battleGetStackByID(lifeDrainFrom, false)->getCreature()->nameSing);
|
||||
boost::algorithm::replace_first(text, "%s", cb->battleGetStackByID(healedStacks[0].first, false)->getCreature()->nameSing);
|
||||
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(healedStacks[0].second));
|
||||
battleInt->console->addText(text);
|
||||
}
|
||||
}
|
||||
|
||||
void CPlayerInterface::battleNewStackAppeared(const CStack * stack)
|
||||
|
@ -224,7 +224,7 @@ public:
|
||||
void battleStacksEffectsSet(const SetStackEffect & sse) OVERRIDE; //called when a specific effect is set to stacks
|
||||
void battleStacksAttacked(const std::vector<BattleStackAttacked> & bsa) OVERRIDE;
|
||||
void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) OVERRIDE; //called by engine when battle starts; side=0 - left, side=1 - right
|
||||
void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom) OVERRIDE; //called when stacks are healed / resurrected
|
||||
void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) OVERRIDE; //called when stacks are healed / resurrected
|
||||
void battleNewStackAppeared(const CStack * stack) OVERRIDE; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
|
||||
void battleObstaclesRemoved(const std::set<si32> & removedObstacles) OVERRIDE; //called when a certain set of obstacles is removed from batlefield; IDs of them are given
|
||||
void battleCatapultAttacked(const CatapultAttack & ca) OVERRIDE; //called when catapult makes an attack
|
||||
|
@ -669,7 +669,7 @@ void StacksHealedOrResurrected::applyCl( CClient *cl )
|
||||
{
|
||||
shiftedHealed.push_back(std::make_pair(healedStacks[v].stackID, healedStacks[v].healedHP));
|
||||
}
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksHealedRes, shiftedHealed, lifeDrain, drainedFrom);
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksHealedRes, shiftedHealed, lifeDrain, tentHealing, drainedFrom);
|
||||
}
|
||||
|
||||
void ObstaclesRemoved::applyCl( CClient *cl )
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
virtual void battleSpellCast(const BattleSpellCast *sc){};
|
||||
virtual void battleStacksEffectsSet(const SetStackEffect & sse){};//called when a specific effect is set to stacks
|
||||
virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side){}; //called by engine when battle starts; side=0 - left, side=1 - right
|
||||
virtual void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom){}; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp
|
||||
virtual void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom){}; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp
|
||||
virtual void battleNewStackAppeared(const CStack * stack){}; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
|
||||
virtual void battleObstaclesRemoved(const std::set<si32> & removedObstacles){}; //called when a certain set of obstacles is removed from batlefield; IDs of them are given
|
||||
virtual void battleCatapultAttacked(const CatapultAttack & ca){}; //called when catapult makes an attack
|
||||
|
@ -1245,11 +1245,12 @@ struct StacksHealedOrResurrected : public CPackForClient //3013
|
||||
|
||||
std::vector<HealInfo> healedStacks;
|
||||
ui8 lifeDrain; //if true, this heal is an effect of life drain
|
||||
si32 drainedFrom; //if life drain - then stack life was drain from
|
||||
ui8 tentHealing; //if true, than it's healing via First Aid Tent
|
||||
si32 drainedFrom; //if life drain - then stack life was drain from, if tentHealing - stack that is a healer
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & healedStacks & lifeDrain & drainedFrom;
|
||||
h & healedStacks & lifeDrain & tentHealing & drainedFrom;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -548,7 +548,8 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
|
||||
if (att->hasBonusOfType(Bonus::LIFE_DRAIN))
|
||||
{
|
||||
StacksHealedOrResurrected shi;
|
||||
shi.lifeDrain = true;
|
||||
shi.lifeDrain = (ui8)true;
|
||||
shi.tentHealing = (ui8)false;
|
||||
shi.drainedFrom = def->ID;
|
||||
|
||||
StacksHealedOrResurrected::HealInfo hi;
|
||||
@ -3217,7 +3218,9 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
else
|
||||
{
|
||||
StacksHealedOrResurrected shr;
|
||||
shr.lifeDrain = false;
|
||||
shr.lifeDrain = (ui8)false;
|
||||
shr.tentHealing = (ui8)true;
|
||||
shr.drainedFrom = ba.stackNumber;
|
||||
StacksHealedOrResurrected::HealInfo hi;
|
||||
|
||||
hi.healedHP = healed;
|
||||
@ -3565,7 +3568,8 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, int destinatio
|
||||
case 39: //animate dead
|
||||
{
|
||||
StacksHealedOrResurrected shr;
|
||||
shr.lifeDrain = false;
|
||||
shr.lifeDrain = (ui8)false;
|
||||
shr.tentHealing = (ui8)false;
|
||||
for(std::set<CStack*>::iterator it = attackedCres.begin(); it != attackedCres.end(); ++it)
|
||||
{
|
||||
if(vstd::contains(sc.resisted, (*it)->ID) //this creature resisted the spell
|
||||
|
Loading…
Reference in New Issue
Block a user