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

Merge pull request #330 from dydzio0614/AmountBoxTweaks

Tweak battle creatures amount box hiding
This commit is contained in:
ArseniyShestakov 2017-07-08 15:54:18 +03:00 committed by GitHub
commit 3634af10ba

View File

@ -3275,19 +3275,31 @@ void CBattleInterface::showAliveStacks(SDL_Surface *to, std::vector<const CStack
{
auto isAmountBoxVisible = [&](const CStack *stack) -> bool
{
if (stack->hasBonusOfType(Bonus::SIEGE_WEAPON)) // siege weapons are always singular
if(stack->hasBonusOfType(Bonus::SIEGE_WEAPON) && stack->count == 1) //do not show box for singular war machines, stacked war machines with box shown are supported as extension feature
return false;
if (curInt->curAction)
if(stack->count == 0) //hide box when target is going to die anyway - do not display "0 creatures"
return false;
for(auto anim : pendingAnims) //no matter what other conditions below are, hide box when creature is playing hit animation
{
if (curInt->curAction->stackNumber == stack->ID) // stack is currently taking an action
auto hitAnimation = dynamic_cast<CDefenceAnimation*>(anim.first);
if(hitAnimation && (hitAnimation->stack->ID == stack->ID)) //we process only "current creature" as other creatures will be processed reliably on their own iteration
return false;
}
if (curInt->curAction->actionType == Battle::WALK_AND_ATTACK && // stack is being targeted
stack->position == curInt->curAction->additionalInfo)
return false;
if(curInt->curAction)
{
if(curInt->curAction->stackNumber == stack->ID) //stack is currently taking action (is not a target of another creature's action etc)
{
if(curInt->curAction->actionType == Battle::WALK || curInt->curAction->actionType == Battle::SHOOT) //hide when stack walks or shoots
return false;
if (curInt->curAction->destinationTile == stack->position) // stack is moving
else if(curInt->curAction->actionType == Battle::WALK_AND_ATTACK && curInt->curAction->destinationTile != stack->position) //when attacking, hide until walk phase finished
return false;
}
if(curInt->curAction->actionType == Battle::SHOOT && curInt->curAction->destinationTile == stack->position) //hide if we are ranged attack target
return false;
}