From 4fd9bcfedc61eaa2ef730393a5ad3f6317c35864 Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Mon, 22 Jul 2013 10:39:11 +0000 Subject: [PATCH] Fixed #1345 --- client/CCreatureWindow.cpp | 2 +- config/spell_info.json | 9 ++++++--- lib/BattleState.cpp | 27 --------------------------- lib/BattleState.h | 1 - lib/HeroBonus.cpp | 27 +++++++++++++++++++++++++++ lib/HeroBonus.h | 3 +++ 6 files changed, 37 insertions(+), 32 deletions(-) diff --git a/client/CCreatureWindow.cpp b/client/CCreatureWindow.cpp index 9fcb3bc95..ac967b5a9 100644 --- a/client/CCreatureWindow.cpp +++ b/client/CCreatureWindow.cpp @@ -540,7 +540,7 @@ void CCreatureWindow::showAll(SDL_Surface * to) printLine(3, CGI->generaltexth->allTexts[199], stackNode->getMinDamage() * dmgMultiply, stackNode->getMaxDamage() * dmgMultiply, true); printLine(4, CGI->generaltexth->allTexts[388], c->valOfBonuses(Bonus::STACK_HEALTH), stackNode->valOfBonuses(Bonus::STACK_HEALTH)); - printLine(6, CGI->generaltexth->zelp[441].first, c->valOfBonuses(Bonus::STACKS_SPEED), stackNode->valOfBonuses(Bonus::STACKS_SPEED)); + printLine(6, CGI->generaltexth->zelp[441].first, c->Speed(), stackNode->Speed()); for(CBonusItem* b : bonusItems) b->showAll (to); diff --git a/config/spell_info.json b/config/spell_info.json index 8ad602b82..349197c29 100644 --- a/config/spell_info.json +++ b/config/spell_info.json @@ -588,7 +588,8 @@ { "type": "STACKS_SPEED", "duration": "N_TURNS", - "values":[2, 2, 4, 4] + "values":[2, 2, 4, 4], + "ainfos":[0,0,0,0] } ] }, @@ -669,7 +670,8 @@ { "type": "STACKS_SPEED", "duration": "N_TURNS", - "values":[3, 3, 5, 5] + "values":[3, 3, 5, 5], + "ainfos":[0,0,0,0] } ], "immunity":["SIEGE_WEAPON"] @@ -690,7 +692,8 @@ "type": "STACKS_SPEED", "valueType": "PERCENT_TO_ALL", "duration": "N_TURNS", - "values":[-25,-25,-50,-50] + "values":[-25,-25,-50,-50], + "ainfos":[0,0,0,0] } ], "immunity":["SIEGE_WEAPON"] diff --git a/lib/BattleState.cpp b/lib/BattleState.cpp index 00ba471c2..355d3d21d 100644 --- a/lib/BattleState.cpp +++ b/lib/BattleState.cpp @@ -895,33 +895,6 @@ void CStack::postInit() casts = valOfBonuses(Bonus::CASTS); } -ui32 CStack::Speed( int turn /*= 0*/ , bool useBind /* = false*/) const -{ - if(hasBonus(Selector::type(Bonus::SIEGE_WEAPON).And(Selector::turns(turn)))) //war machines cannot move - return 0; - - int speed = valOfBonuses(Selector::type(Bonus::STACKS_SPEED).And(Selector::turns(turn))); - - int percentBonus = 0; - for(const Bonus *b : getBonusList()) - { - if(b->type == Bonus::STACKS_SPEED) - { - percentBonus += b->additionalInfo; - } - } - - speed = ((100 + percentBonus) * speed)/100; - - //bind effect check - doesn't influence stack initiative - if (useBind && getEffect (SpellID::BIND)) - { - return 0; - } - - return speed; -} - ui32 CStack::level() const { if (base) diff --git a/lib/BattleState.h b/lib/BattleState.h index 3afa286fb..cc36f7659 100644 --- a/lib/BattleState.h +++ b/lib/BattleState.h @@ -185,7 +185,6 @@ public: bool waited(int turn = 0) const; bool canMove(int turn = 0) const; //if stack can move bool canBeHealed() const; //for first aid tent - only harmed stacks that are not war machines - ui32 Speed(int turn = 0, bool useBind = false) const; //get speed of creature with all modificators ui32 level() const; si32 magicResistance() const override; //include aura of resistance static void stackEffectToFeature(std::vector & sf, const Bonus & sse); diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index 955559e02..91deeea30 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -486,6 +486,33 @@ si32 IBonusBearer::magicResistance() const return valOfBonuses(Bonus::MAGIC_RESISTANCE); } +ui32 CBonusSystemNode::Speed( int turn /*= 0*/ , bool useBind /* = false*/) const +{ + if(hasBonus(Selector::type(Bonus::SIEGE_WEAPON).And(Selector::turns(turn)))) //war machines cannot move + return 0; + + int speed = valOfBonuses(Selector::type(Bonus::STACKS_SPEED).And(Selector::turns(turn))); + + int percentBonus = 0; + for(const Bonus *b : getBonusList()) + { + if(b->type == Bonus::STACKS_SPEED) + { + percentBonus += b->additionalInfo; + } + } + + speed = ((100 + percentBonus) * speed)/100; + + //bind effect check - doesn't influence stack initiative + if (useBind && getEffect (SpellID::BIND)) + { + return 0; + } + + return speed; +} + bool IBonusBearer::isLiving() const //TODO: theoreticaly there exists "LIVING" bonus in stack experience documentation { std::stringstream cachingStr; diff --git a/lib/HeroBonus.h b/lib/HeroBonus.h index 4750ab709..6ef960b9f 100644 --- a/lib/HeroBonus.h +++ b/lib/HeroBonus.h @@ -675,6 +675,9 @@ public: virtual std::string bonusToString(const Bonus *bonus, bool description) const {return "";}; //description or bonus name virtual std::string nodeName() const; + ui32 Speed(int turn = 0, bool useBind = false) const; //get speed of creature with all modificators + //FIXME: this interface should be moved to IBonusBearer, but bonus list is required for original implementation to compile + void deserializationFix(); void exportBonus(Bonus * b); void exportBonuses();