Procházet zdrojové kódy

Fixes battle stack queue for high morale bonus and not-skipping-turn monster spellcast

Opuszek před 1 měsícem
rodič
revize
ca7896a1ba

+ 1 - 0
lib/battle/CUnitState.cpp

@@ -931,6 +931,7 @@ void CUnitState::afterGetsTurn(BattleUnitTurnReason reason)
 	{
 		hadMorale = true;
 		castSpellThisTurn = false;
+		movedThisRound = false;
 	}
 }
 

+ 15 - 1
lib/gameState/GameStatePackVisitor.cpp

@@ -31,6 +31,8 @@
 #include "../mapping/CMap.h"
 #include "../networkPacks/StackLocation.h"
 
+#include "../../lib/spells/CSpellHandler.h"
+
 VCMI_LIB_NAMESPACE_BEGIN
 
 void GameStatePackVisitor::visitSetResources(SetResources & pack)
@@ -1328,13 +1330,25 @@ void GameStatePackVisitor::visitStartAction(StartAction & pack)
 				st->waiting = true;
 				st->waitedThisTurn = true;
 				break;
+			case EActionType::MONSTER_SPELL:
+			{
+				auto * spell = pack.ba.spell.toSpell();
+				if (spell && spell->canCastWithoutSkip()) {}	//state does not change
+				else
+				{
+					st->waiting = false;
+					st->defendingAnim = false;
+					st->movedThisRound = true;
+				}
+				st->castSpellThisTurn = true;
+				break;
+			}
 			case EActionType::HERO_SPELL: //no change in current stack state
 				break;
 			default: //any active stack action - attack, catapult, heal, spell...
 				st->waiting = false;
 				st->defendingAnim = false;
 				st->movedThisRound = true;
-				st->castSpellThisTurn = pack.ba.actionType == EActionType::MONSTER_SPELL;
 				break;
 		}
 	}