Kaynağa Gözat

Merge pull request #330 from dydzio0614/AmountBoxTweaks

Tweak battle creatures amount box hiding
ArseniyShestakov 8 yıl önce
ebeveyn
işleme
3634af10ba
1 değiştirilmiş dosya ile 19 ekleme ve 7 silme
  1. 19 7
      client/battle/CBattleInterface.cpp

+ 19 - 7
client/battle/CBattleInterface.cpp

@@ -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;
+
+				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->destinationTile == stack->position) // stack is moving
+			if(curInt->curAction->actionType == Battle::SHOOT && curInt->curAction->destinationTile == stack->position) //hide if we are ranged attack target
 				return false;
 		}