mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Fixed #1367. Removed confusing code for speed calculation.
This commit is contained in:
@@ -486,32 +486,21 @@ si32 IBonusBearer::magicResistance() const
|
||||
return valOfBonuses(Bonus::MAGIC_RESISTANCE);
|
||||
}
|
||||
|
||||
ui32 CBonusSystemNode::Speed( int turn /*= 0*/ , bool useBind /* = false*/) const
|
||||
ui32 IBonusBearer::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())
|
||||
//war machines cannot move
|
||||
if(hasBonus(Selector::type(Bonus::SIEGE_WEAPON).And(Selector::turns(turn))))
|
||||
{
|
||||
if(b->type == Bonus::STACKS_SPEED)
|
||||
{
|
||||
percentBonus += b->additionalInfo;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
speed = ((100 + percentBonus) * speed)/100;
|
||||
|
||||
//bind effect check - doesn't influence stack initiative
|
||||
if (useBind && getEffect (SpellID::BIND))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return speed;
|
||||
}
|
||||
return valOfBonuses(Selector::type(Bonus::STACKS_SPEED).And(Selector::turns(turn)));
|
||||
}
|
||||
|
||||
bool IBonusBearer::isLiving() const //TODO: theoreticaly there exists "LIVING" bonus in stack experience documentation
|
||||
{
|
||||
|
@@ -592,6 +592,7 @@ public:
|
||||
ui32 MaxHealth() const; //get max HP of stack with all modifiers
|
||||
bool isLiving() const; //non-undead, non-non living or alive
|
||||
virtual si32 magicResistance() const;
|
||||
ui32 Speed(int turn = 0, bool useBind = false) const; //get speed of creature with all modificators
|
||||
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
|
||||
|
||||
@@ -675,9 +676,6 @@ 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();
|
||||
|
Reference in New Issue
Block a user