diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 630264052..36642508a 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -850,7 +850,7 @@ void CPlayerInterface::battleAttack(const BattleAttack *ba) if (ba->deathBlow()) { const CStack *stack = cb->battleGetStackByID(ba->stackAttacking); - std::string hlp = CGI->generaltexth->allTexts[(stack->count != 1) ? 336 : 335]; + std::string hlp = CGI->generaltexth->allTexts[(stack->count != 1) ? 366 : 365]; boost::algorithm::replace_first(hlp,"%s", (stack->count != 1) ? stack->getCreature()->namePl.c_str() : stack->getCreature()->nameSing.c_str()); battleInt->console->addText(hlp); for (std::vector::const_iterator i = ba->bsa.begin(); i != ba->bsa.end(); i++) diff --git a/client/Client.cpp b/client/Client.cpp index 64585b490..1bbfedd8c 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -20,7 +20,7 @@ #include "../lib/NetPacks.h" #include "../lib/VCMI_Lib.h" #include "../lib/map.h" -#include "../lib/JsonNode.cpp" +#include "../lib/JsonNode.h" #include "mapHandler.h" #include "CConfigHandler.h" #include "Client.h" diff --git a/lib/BattleState.cpp b/lib/BattleState.cpp index 87db418b3..c3cdaa835 100644 --- a/lib/BattleState.cpp +++ b/lib/BattleState.cpp @@ -2562,6 +2562,14 @@ bool CStack::isMeleeAttackPossible(const CStack * attacker, const CStack * defen } +bool CStack::ableToRetaliate() const +{ + return alive() + && (counterAttacks > 0 || hasBonusOfType(Bonus::UNLIMITED_RETALIATIONS)) + && !hasBonusOfType(Bonus::SIEGE_WEAPON) + && !hasBonusOfType(Bonus::HYPNOTIZED); +} + bool CMP_stack::operator()( const CStack* a, const CStack* b ) { switch(phase) diff --git a/lib/BattleState.h b/lib/BattleState.h index fde4a0015..fa7763c8d 100644 --- a/lib/BattleState.h +++ b/lib/BattleState.h @@ -161,6 +161,7 @@ public: const Bonus * getEffect(ui16 id, int turn = 0) const; //effect id (SP) ui8 howManyEffectsSet(ui16 id) const; //returns amount of effects with given id set for this stack bool willMove(int turn = 0) const; //if stack has remaining move this turn + bool ableToRetaliate() const; //if stack can retaliate after attacked bool moved(int turn = 0) const; //if stack was already moved this turn bool canMove(int turn = 0) const; //if stack can move ui32 Speed(int turn = 0) const; //get speed of creature with all modificators diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 3470716a4..b994a69ec 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -3055,19 +3055,19 @@ bool CGameHandler::makeBattleAction( BattleAction &ba ) } //attack - BattleAttack bat; - prepareAttack(bat, curStack, stackAtEnd, distance, ba.additionalInfo); - handleAttackBeforeCasting(bat); //only before first attack - sendAndApply(&bat); - handleAfterAttackCasting(bat); + { + BattleAttack bat; + prepareAttack(bat, curStack, stackAtEnd, distance, ba.additionalInfo); + handleAttackBeforeCasting(bat); //only before first attack + sendAndApply(&bat); + handleAfterAttackCasting(bat); + } //counterattack if(!curStack->hasBonusOfType(Bonus::BLOCKS_RETALIATION) - && stackAtEnd->alive() - && ( stackAtEnd->counterAttacks > 0 || stackAtEnd->hasBonusOfType(Bonus::UNLIMITED_RETALIATIONS) ) - && !stackAtEnd->hasBonusOfType(Bonus::SIEGE_WEAPON) - && !stackAtEnd->hasBonusOfType(Bonus::HYPNOTIZED)) + && stackAtEnd->ableToRetaliate()) { + BattleAttack bat; prepareAttack(bat, stackAtEnd, curStack, 0, curStack->position); bat.flags |= BattleAttack::COUNTER; sendAndApply(&bat); @@ -3080,7 +3080,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba ) && curStack->alive() && stackAtEnd->alive() ) { - bat.flags = 0; + BattleAttack bat; prepareAttack(bat, curStack, stackAtEnd, 0, ba.additionalInfo); sendAndApply(&bat); handleAfterAttackCasting(bat); @@ -3105,12 +3105,14 @@ bool CGameHandler::makeBattleAction( BattleAction &ba ) StartAction start_action(ba); sendAndApply(&start_action); //start shooting - BattleAttack bat; - bat.flags |= BattleAttack::SHOT; - prepareAttack(bat, curStack, destStack, 0, ba.destinationTile); - handleAttackBeforeCasting(bat); - sendAndApply(&bat); - handleAfterAttackCasting(bat); + { + BattleAttack bat; + bat.flags |= BattleAttack::SHOT; + prepareAttack(bat, curStack, destStack, 0, ba.destinationTile); + handleAttackBeforeCasting(bat); + sendAndApply(&bat); + handleAfterAttackCasting(bat); + } //ballista & artillery handling if(destStack->alive() && curStack->getCreature()->idNumber == 146) @@ -3127,6 +3129,8 @@ bool CGameHandler::makeBattleAction( BattleAction &ba ) && curStack->shots ) { + BattleAttack bat; + bat.flags |= BattleAttack::SHOT; prepareAttack(bat, curStack, destStack, 0, ba.destinationTile); sendAndApply(&bat); handleAfterAttackCasting(bat);