1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fixed Berserk spell effect aka Bonus::ATTACKS_NEAREST_CREATURE

* issue http://bugs.vcmi.eu/view.php?id=2513
* fix is not retroactive
This commit is contained in:
AlexVinS 2016-09-29 14:11:15 +03:00
parent 8f18dec5e3
commit 34b8b2c91b
3 changed files with 7 additions and 30 deletions

View File

@ -1113,40 +1113,15 @@
"effects" : {
"attacksNearestCreature" : {
"type" : "ATTACKS_NEAREST_CREATURE",
"duration" : "N_TURNS",
"turns" : 1
}
}
},
"none":{
"effects" : {
"attacksNearestCreature" : {
"val" : 0
}
}
},
"basic":{
"effects" : {
"attacksNearestCreature" : {
"val" : 1
"duration" : "STACK_GETS_TURN"
}
}
},
"advanced":{
"range" : "0-1",
"effects" : {
"attacksNearestCreature" : {
"val" : 2
}
}
"range" : "0-1"
},
"expert":{
"range" : "0-2",
"effects" : {
"attacksNearestCreature" : {
"val" : 3
}
}
"range" : "0-2"
}
},
"absoluteImmunity" : {

View File

@ -139,7 +139,6 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
CStack * generateNewStack(const CStackInstance &base, bool attackerOwned, SlotID slot, BattleHex position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield
CStack * generateNewStack(const CStackBasicDescriptor &base, bool attackerOwned, SlotID slot, BattleHex position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield
int getIdForNewStack() const; //suggest a currently unused ID that'd suitable for generating a new stack
//std::pair<const CStack *, BattleHex> getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const; //if attackerOwned is indetermnate, returened stack is of any owner; hex is the number of hex we should be looking from; returns (nerarest creature, predecessorHex)
const CGHeroInstance * getHero(PlayerColor player) const; //returns fighting hero that belongs to given player

View File

@ -5704,7 +5704,8 @@ void CGameHandler::runBattle()
}
if(next->hasBonusOfType(Bonus::ATTACKS_NEAREST_CREATURE)) //while in berserk
{ //fixme: stack should not attack itself
{
logGlobal->debug("Handle Berserk effect");
std::pair<const CStack *, int> attackInfo = curB.getNearestStack(next, boost::logic::indeterminate);
if(attackInfo.first != nullptr)
{
@ -5716,10 +5717,12 @@ void CGameHandler::runBattle()
attack.destinationTile = attackInfo.second;
makeAutomaticAction(next, attack);
logGlobal->debug("Attacked nearest target %s", attackInfo.first->nodeName());
}
else
{
makeStackDoNothing(next);
logGlobal->debug("No target found");
}
continue;
}