mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- corrected "isToReverse" check, partially fixes 1397
- ballistics fix - minor
This commit is contained in:
parent
c81a31c74a
commit
8beee29482
@ -61,6 +61,9 @@ bool CBattleAnimation::isEarliest(bool perStackConcurrency)
|
||||
|
||||
for(auto & elem : owner->pendingAnims)
|
||||
{
|
||||
if (elem.first == this)
|
||||
continue;
|
||||
|
||||
CBattleStackAnimation * stAnim = dynamic_cast<CBattleStackAnimation *>(elem.first);
|
||||
CSpellEffectAnimation * sen = dynamic_cast<CSpellEffectAnimation *>(elem.first);
|
||||
if(perStackConcurrency && stAnim && thAnim && stAnim->stack->ID != thAnim->stack->ID)
|
||||
@ -155,6 +158,9 @@ bool CDefenceAnimation::init()
|
||||
ui32 lowestMoveID = owner->animIDhelper + 5;
|
||||
for(auto & elem : owner->pendingAnims)
|
||||
{
|
||||
if (elem.first == this)
|
||||
continue;
|
||||
|
||||
CDefenceAnimation * defAnim = dynamic_cast<CDefenceAnimation *>(elem.first);
|
||||
if(defAnim && defAnim->stack->ID != stack->ID)
|
||||
continue;
|
||||
@ -165,7 +171,7 @@ bool CDefenceAnimation::init()
|
||||
|
||||
CReverseAnimation * animAsRev = dynamic_cast<CReverseAnimation *>(elem.first);
|
||||
|
||||
if(animAsRev /*&& animAsRev->priority*/)
|
||||
if(animAsRev)
|
||||
return false;
|
||||
|
||||
if(elem.first)
|
||||
@ -175,6 +181,7 @@ bool CDefenceAnimation::init()
|
||||
if(ID > lowestMoveID)
|
||||
return false;
|
||||
|
||||
|
||||
//reverse unit if necessary
|
||||
if (attacker && owner->curInt->cb->isToReverse(stack->position, attacker->position, owner->creDir[stack->ID], attacker->doubleWide(), owner->creDir[attacker->ID]))
|
||||
{
|
||||
|
@ -1160,7 +1160,8 @@ bool CBattleInterface::isCatapultAttackable(BattleHex hex) const
|
||||
if(wallUnder < 0) //invalid or indestructible
|
||||
return false;
|
||||
|
||||
return curInt->cb->battleGetWallState(wallUnder) < EWallState::DESTROYED;
|
||||
auto state = curInt->cb->battleGetWallState(wallUnder);
|
||||
return state != EWallState::DESTROYED && state != EWallState::NONE;
|
||||
}
|
||||
|
||||
const CGHeroInstance * CBattleInterface::getActiveHero()
|
||||
|
@ -416,7 +416,7 @@ bool CBattleInfoEssentials::battleHasHero(ui8 side) const
|
||||
return getBattle()->sides[side].hero;
|
||||
}
|
||||
|
||||
ui8 CBattleInfoEssentials::battleGetWallState(int partOfWall) const
|
||||
si8 CBattleInfoEssentials::battleGetWallState(int partOfWall) const
|
||||
{
|
||||
RETURN_IF_NOT_BATTLE(0);
|
||||
if(getBattle()->siege == CGTownInstance::NONE)
|
||||
@ -1410,33 +1410,41 @@ std::set<const CStack*> CBattleInfoCallback::getAttackedCreatures(const CStack*
|
||||
return attackedCres;
|
||||
}
|
||||
|
||||
bool CBattleInfoCallback::isToReverseHlp (BattleHex hexFrom, BattleHex hexTo, bool curDir) const //TODO: this should apply also to mechanics and cursor interface
|
||||
//TODO: this should apply also to mechanics and cursor interface
|
||||
bool CBattleInfoCallback::isToReverseHlp (BattleHex hexFrom, BattleHex hexTo, bool curDir) const
|
||||
{
|
||||
int fromMod = hexFrom % GameConstants::BFIELD_WIDTH;
|
||||
int fromDiv = hexFrom / GameConstants::BFIELD_WIDTH;
|
||||
int toMod = hexTo % GameConstants::BFIELD_WIDTH;
|
||||
int fromX = hexFrom.getX();
|
||||
int fromY = hexFrom.getY();
|
||||
int toX = hexTo.getX();
|
||||
int toY = hexTo.getY();
|
||||
|
||||
if(curDir && fromMod < toMod)
|
||||
return false;
|
||||
else if(curDir && fromMod > toMod)
|
||||
return true;
|
||||
else if(curDir && fromMod == toMod)
|
||||
if (curDir) // attacker, facing right
|
||||
{
|
||||
return fromDiv % 2 == 0;
|
||||
}
|
||||
else if(!curDir && fromMod < toMod)
|
||||
return true;
|
||||
else if(!curDir && fromMod > toMod)
|
||||
if (fromX < toX)
|
||||
return false;
|
||||
if (fromX > toX)
|
||||
return true;
|
||||
|
||||
if (fromY % 2 == 0 && toY % 2 == 1)
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
else // defender, facing left
|
||||
{
|
||||
if(fromX < toX)
|
||||
return true;
|
||||
if(fromX > toX)
|
||||
return false;
|
||||
|
||||
if (fromY % 2 == 1 && toY % 2 == 0)
|
||||
return true;
|
||||
return false;
|
||||
else if(!curDir && fromMod == toMod)
|
||||
{
|
||||
return fromDiv % 2 == 1;
|
||||
}
|
||||
logGlobal->errorStream() << "Catastrope in CBattleInfoCallback::isToReverse!";
|
||||
return false; //should never happen
|
||||
}
|
||||
|
||||
bool CBattleInfoCallback::isToReverse (BattleHex hexFrom, BattleHex hexTo, bool curDir, bool toDoubleWide, bool toDir) const //TODO: this should apply also to mechanics and cursor interface
|
||||
//TODO: this should apply also to mechanics and cursor interface
|
||||
bool CBattleInfoCallback::isToReverse (BattleHex hexFrom, BattleHex hexTo, bool curDir, bool toDoubleWide, bool toDir) const
|
||||
{
|
||||
if (hexTo < 0 || hexFrom < 0) //turret
|
||||
return false;
|
||||
|
@ -170,7 +170,7 @@ public:
|
||||
std::vector<shared_ptr<const CObstacleInstance> > battleGetAllObstacles(boost::optional<BattlePerspective::BattlePerspective> perspective = boost::none) const; //returns all obstacles on the battlefield
|
||||
TStacks battleGetAllStacks() const; //returns all stacks, alive or dead or undead or mechanical :)
|
||||
bool battleHasNativeStack(ui8 side) const;
|
||||
ui8 battleGetWallState(int partOfWall) const; //for determining state of a part of the wall; format: parameter [0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate; returned value: 1 - intact, 2 - damaged, 3 - destroyed; 0 - no battle
|
||||
si8 battleGetWallState(int partOfWall) const; //for determining state of a part of the wall; format: parameter [0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate; returned value: 1 - intact, 2 - damaged, 3 - destroyed; 0 - no battle
|
||||
int battleGetMoatDmg() const; //what dmg unit will suffer if ending turn in the moat
|
||||
const CGTownInstance * battleGetDefendedTown() const; //returns defended town if current battle is a siege, nullptr instead
|
||||
const CStack *battleActiveStack() const;
|
||||
|
@ -1539,7 +1539,6 @@ struct BattleAttack : public CPackForClient//3006
|
||||
}
|
||||
bool unlucky() const
|
||||
{
|
||||
//TODO: support?
|
||||
return flags & UNLUCKY;
|
||||
}
|
||||
bool ballistaDoubleDmg() const //if it's ballista attack and does double dmg
|
||||
|
Loading…
Reference in New Issue
Block a user