Selaa lähdekoodia

* fixed crash on after attack spell casting
* more aggressive stack direction normalization after action
* artillery support

mateuszb 14 vuotta sitten
vanhempi
sitoutus
6d6a1af9ed
2 muutettua tiedostoa jossa 20 lisäystä ja 3 poistoa
  1. 5 3
      client/CBattleInterface.cpp
  2. 15 0
      server/CGameHandler.cpp

+ 5 - 3
client/CBattleInterface.cpp

@@ -3321,9 +3321,11 @@ void CBattleInterface::endAction(const BattleAction* action)
 	}
 
 	//check if we should reverse stacks
-	std::set<const CStack *> stacks;
-	stacks.insert(LOCPLINT->cb->battleGetStackByID(action->stackNumber));
-	stacks.insert(LOCPLINT->cb->battleGetStackByPos(action->destinationTile));
+	//for some strange reason, it's not enough
+// 	std::set<const CStack *> stacks;
+// 	stacks.insert(LOCPLINT->cb->battleGetStackByID(action->stackNumber));
+// 	stacks.insert(LOCPLINT->cb->battleGetStackByPos(action->destinationTile));
+	TStacks stacks = curInt->cb->battleGetStacks(IBattleCallback::MINE_AND_ENEMY);
 
 	BOOST_FOREACH(const CStack *s, stacks)
 	{

+ 15 - 0
server/CGameHandler.cpp

@@ -3253,6 +3253,21 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
 			prepareAttack(bat, curStack, destStack, 0);
 			sendAndApply(&bat);
 
+			//ballista & artillery handling
+			if(destStack->alive() && curStack->getCreature()->idNumber == 146)
+			{
+				static const int artilleryLvlToChance[] = {0, 50, 75, 100};
+				const CGHeroInstance * owner = gs->curB->getHero(curStack->owner);
+				int chance = artilleryLvlToChance[owner->getSecSkillLevel(CGHeroInstance::ARTILLERY)];
+				if(chance > (rand() % 100))
+				{
+					BattleAttack bat2;
+					bat2.flags |= 1;
+					prepareAttack(bat2, curStack, destStack, 0);
+					sendAndApply(&bat2);
+				}
+			}
+
 			if(curStack->valOfBonuses(Bonus::ADDITIONAL_ATTACK) > 0 //if unit shots twice let's make another shot
 				&& curStack->alive()
 				&& destStack->alive()