mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
* fixed crash on after attack spell casting
* more aggressive stack direction normalization after action * artillery support
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
@@ -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()
|
||||
|
Reference in New Issue
Block a user