2022-11-17 13:21:03 +02:00
|
|
|
/*
|
2022-12-11 23:16:23 +02:00
|
|
|
* BattleSiegeController.cpp, part of VCMI engine
|
2022-11-17 13:21:03 +02:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "StdInc.h"
|
2022-12-09 13:38:46 +02:00
|
|
|
#include "BattleSiegeController.h"
|
2022-11-17 13:21:03 +02:00
|
|
|
|
2022-12-09 13:38:46 +02:00
|
|
|
#include "BattleAnimationClasses.h"
|
|
|
|
#include "BattleInterface.h"
|
|
|
|
#include "BattleInterfaceClasses.h"
|
|
|
|
#include "BattleStacksController.h"
|
|
|
|
#include "BattleFieldController.h"
|
|
|
|
#include "BattleRenderer.h"
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-11-25 00:26:14 +02:00
|
|
|
#include "../CMusicHandler.h"
|
|
|
|
#include "../CGameInfo.h"
|
|
|
|
#include "../CPlayerInterface.h"
|
|
|
|
#include "../gui/CAnimation.h"
|
2022-12-11 22:09:57 +02:00
|
|
|
#include "../gui/Canvas.h"
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-11-25 00:26:14 +02:00
|
|
|
#include "../../CCallback.h"
|
|
|
|
#include "../../lib/NetPacks.h"
|
|
|
|
#include "../../lib/CStack.h"
|
|
|
|
#include "../../lib/mapObjects/CGTownInstance.h"
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
std::string BattleSiegeController::getWallPieceImageName(EWallVisual::EWallVisual what, EWallState::EWallState state) const
|
2022-11-17 18:50:12 +02:00
|
|
|
{
|
|
|
|
auto getImageIndex = [&]() -> int
|
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
2022-11-25 00:26:14 +02:00
|
|
|
case EWallState::INTACT :
|
|
|
|
return 1;
|
2022-11-17 18:50:12 +02:00
|
|
|
case EWallState::DAMAGED :
|
2022-11-25 00:26:14 +02:00
|
|
|
// towers don't have separate image here - INTACT and DAMAGED is 1, DESTROYED is 2
|
|
|
|
if(what == EWallVisual::KEEP || what == EWallVisual::BOTTOM_TOWER || what == EWallVisual::UPPER_TOWER)
|
2022-11-17 18:50:12 +02:00
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 2;
|
|
|
|
case EWallState::DESTROYED :
|
2022-11-25 00:26:14 +02:00
|
|
|
if (what == EWallVisual::KEEP || what == EWallVisual::BOTTOM_TOWER || what == EWallVisual::UPPER_TOWER)
|
2022-11-17 18:50:12 +02:00
|
|
|
return 2;
|
|
|
|
else
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
const std::string & prefix = town->town->clientInfo.siegePrefix;
|
|
|
|
std::string addit = boost::lexical_cast<std::string>(getImageIndex());
|
|
|
|
|
|
|
|
switch(what)
|
|
|
|
{
|
|
|
|
case EWallVisual::BACKGROUND_WALL:
|
|
|
|
{
|
|
|
|
switch(town->town->faction->index)
|
|
|
|
{
|
|
|
|
case ETownType::RAMPART:
|
|
|
|
case ETownType::NECROPOLIS:
|
|
|
|
case ETownType::DUNGEON:
|
|
|
|
case ETownType::STRONGHOLD:
|
|
|
|
return prefix + "TPW1.BMP";
|
|
|
|
default:
|
|
|
|
return prefix + "TPWL.BMP";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case EWallVisual::KEEP:
|
|
|
|
return prefix + "MAN" + addit + ".BMP";
|
|
|
|
case EWallVisual::BOTTOM_TOWER:
|
|
|
|
return prefix + "TW1" + addit + ".BMP";
|
|
|
|
case EWallVisual::BOTTOM_WALL:
|
|
|
|
return prefix + "WA1" + addit + ".BMP";
|
|
|
|
case EWallVisual::WALL_BELLOW_GATE:
|
|
|
|
return prefix + "WA3" + addit + ".BMP";
|
|
|
|
case EWallVisual::WALL_OVER_GATE:
|
|
|
|
return prefix + "WA4" + addit + ".BMP";
|
|
|
|
case EWallVisual::UPPER_WALL:
|
|
|
|
return prefix + "WA6" + addit + ".BMP";
|
|
|
|
case EWallVisual::UPPER_TOWER:
|
|
|
|
return prefix + "TW2" + addit + ".BMP";
|
|
|
|
case EWallVisual::GATE:
|
|
|
|
return prefix + "DRW" + addit + ".BMP";
|
|
|
|
case EWallVisual::GATE_ARCH:
|
|
|
|
return prefix + "ARCH.BMP";
|
|
|
|
case EWallVisual::BOTTOM_STATIC_WALL:
|
|
|
|
return prefix + "WA2.BMP";
|
|
|
|
case EWallVisual::UPPER_STATIC_WALL:
|
|
|
|
return prefix + "WA5.BMP";
|
|
|
|
case EWallVisual::MOAT:
|
|
|
|
return prefix + "MOAT.BMP";
|
2022-11-27 22:50:18 +02:00
|
|
|
case EWallVisual::MOAT_BANK:
|
2022-11-17 18:50:12 +02:00
|
|
|
return prefix + "MLIP.BMP";
|
|
|
|
case EWallVisual::KEEP_BATTLEMENT:
|
|
|
|
return prefix + "MANC.BMP";
|
|
|
|
case EWallVisual::BOTTOM_BATTLEMENT:
|
|
|
|
return prefix + "TW1C.BMP";
|
|
|
|
case EWallVisual::UPPER_BATTLEMENT:
|
|
|
|
return prefix + "TW2C.BMP";
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-05 14:16:01 +02:00
|
|
|
void BattleSiegeController::showWallPiece(Canvas & canvas, EWallVisual::EWallVisual what)
|
2022-11-17 18:50:12 +02:00
|
|
|
{
|
|
|
|
auto & ci = town->town->clientInfo;
|
2022-11-25 00:26:14 +02:00
|
|
|
auto const & pos = ci.siegePositions[what];
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-11-27 20:01:52 +02:00
|
|
|
if ( wallPieceImages[what])
|
2023-01-05 14:16:01 +02:00
|
|
|
canvas.draw(wallPieceImages[what], Point(pos.x, pos.y));
|
2022-11-25 00:26:14 +02:00
|
|
|
}
|
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
std::string BattleSiegeController::getBattleBackgroundName() const
|
2022-11-25 00:26:14 +02:00
|
|
|
{
|
|
|
|
const std::string & prefix = town->town->clientInfo.siegePrefix;
|
|
|
|
return prefix + "BACK.BMP";
|
|
|
|
}
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
bool BattleSiegeController::getWallPieceExistance(EWallVisual::EWallVisual what) const
|
2022-11-25 00:26:14 +02:00
|
|
|
{
|
|
|
|
//FIXME: use this instead of buildings test?
|
2022-12-13 13:58:16 +02:00
|
|
|
//ui8 siegeLevel = owner.curInt->cb->battleGetSiegeLevel();
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-11-27 22:50:18 +02:00
|
|
|
switch (what)
|
|
|
|
{
|
|
|
|
case EWallVisual::MOAT: return town->hasBuilt(BuildingID::CITADEL) && town->town->faction->index != ETownType::TOWER;
|
|
|
|
case EWallVisual::MOAT_BANK: return town->hasBuilt(BuildingID::CITADEL) && town->town->faction->index != ETownType::TOWER && town->town->faction->index != ETownType::NECROPOLIS;
|
2022-12-13 13:58:16 +02:00
|
|
|
case EWallVisual::KEEP_BATTLEMENT: return town->hasBuilt(BuildingID::CITADEL) && EWallState::EWallState(owner.curInt->cb->battleGetWallState(EWallPart::KEEP)) != EWallState::DESTROYED;
|
|
|
|
case EWallVisual::UPPER_BATTLEMENT: return town->hasBuilt(BuildingID::CASTLE) && EWallState::EWallState(owner.curInt->cb->battleGetWallState(EWallPart::UPPER_TOWER)) != EWallState::DESTROYED;
|
|
|
|
case EWallVisual::BOTTOM_BATTLEMENT: return town->hasBuilt(BuildingID::CASTLE) && EWallState::EWallState(owner.curInt->cb->battleGetWallState(EWallPart::BOTTOM_TOWER)) != EWallState::DESTROYED;
|
2022-11-27 22:50:18 +02:00
|
|
|
default: return true;
|
|
|
|
}
|
2022-11-17 18:50:12 +02:00
|
|
|
}
|
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
BattleHex BattleSiegeController::getWallPiecePosition(EWallVisual::EWallVisual what) const
|
2022-11-17 23:57:51 +02:00
|
|
|
{
|
2022-11-25 00:26:14 +02:00
|
|
|
static const std::array<BattleHex, 18> wallsPositions = {
|
2022-11-30 22:05:25 +02:00
|
|
|
BattleHex::INVALID, // BACKGROUND, // handled separately
|
|
|
|
BattleHex::HEX_BEFORE_ALL, // BACKGROUND_WALL,
|
|
|
|
135, // KEEP,
|
|
|
|
BattleHex::HEX_AFTER_ALL, // BOTTOM_TOWER,
|
|
|
|
182, // BOTTOM_WALL,
|
|
|
|
130, // WALL_BELLOW_GATE,
|
2022-12-11 12:29:11 +02:00
|
|
|
62, // WALL_OVER_GATE,
|
2022-11-30 22:05:25 +02:00
|
|
|
12, // UPPER_WALL,
|
|
|
|
BattleHex::HEX_BEFORE_ALL, // UPPER_TOWER,
|
|
|
|
BattleHex::HEX_BEFORE_ALL, // GATE, // 94
|
|
|
|
112, // GATE_ARCH,
|
|
|
|
165, // BOTTOM_STATIC_WALL,
|
|
|
|
45, // UPPER_STATIC_WALL,
|
|
|
|
BattleHex::INVALID, // MOAT, // printed as absolute obstacle
|
|
|
|
BattleHex::INVALID, // MOAT_BANK, // printed as absolute obstacle
|
|
|
|
135, // KEEP_BATTLEMENT,
|
|
|
|
BattleHex::HEX_AFTER_ALL, // BOTTOM_BATTLEMENT,
|
|
|
|
BattleHex::HEX_BEFORE_ALL, // UPPER_BATTLEMENT,
|
2022-11-25 00:26:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
return wallsPositions[what];
|
2022-11-17 23:57:51 +02:00
|
|
|
}
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-12-13 13:58:16 +02:00
|
|
|
BattleSiegeController::BattleSiegeController(BattleInterface & owner, const CGTownInstance *siegeTown):
|
2022-11-17 19:36:25 +02:00
|
|
|
owner(owner),
|
|
|
|
town(siegeTown)
|
2022-11-17 18:50:12 +02:00
|
|
|
{
|
2022-12-13 13:58:16 +02:00
|
|
|
assert(owner.fieldController.get() == nullptr); // must be created after this
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-11-25 00:26:14 +02:00
|
|
|
for (int g = 0; g < wallPieceImages.size(); ++g)
|
2022-11-17 18:50:12 +02:00
|
|
|
{
|
2022-11-25 00:26:14 +02:00
|
|
|
if ( g == EWallVisual::GATE ) // gate is initially closed and has no image to display in this state
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ( !getWallPieceExistance(EWallVisual::EWallVisual(g)) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wallPieceImages[g] = IImage::createFromFile(getWallPieceImageName(EWallVisual::EWallVisual(g), EWallState::INTACT));
|
2022-11-17 18:50:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
const CCreature *BattleSiegeController::getTurretCreature() const
|
2022-11-17 18:50:12 +02:00
|
|
|
{
|
|
|
|
return CGI->creh->objects[town->town->clientInfo.siegeShooter];
|
|
|
|
}
|
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
Point BattleSiegeController::getTurretCreaturePosition( BattleHex position ) const
|
2022-11-17 18:50:12 +02:00
|
|
|
{
|
|
|
|
// Turret positions are read out of the config/wall_pos.txt
|
|
|
|
int posID = 0;
|
|
|
|
switch (position)
|
|
|
|
{
|
|
|
|
case BattleHex::CASTLE_CENTRAL_TOWER: // keep creature
|
2022-11-25 00:26:14 +02:00
|
|
|
posID = EWallVisual::CREATURE_KEEP;
|
2022-11-17 18:50:12 +02:00
|
|
|
break;
|
|
|
|
case BattleHex::CASTLE_BOTTOM_TOWER: // bottom creature
|
2022-11-25 00:26:14 +02:00
|
|
|
posID = EWallVisual::CREATURE_BOTTOM_TOWER;
|
2022-11-17 18:50:12 +02:00
|
|
|
break;
|
|
|
|
case BattleHex::CASTLE_UPPER_TOWER: // upper creature
|
2022-11-25 00:26:14 +02:00
|
|
|
posID = EWallVisual::CREATURE_UPPER_TOWER;
|
2022-11-17 18:50:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (posID != 0)
|
|
|
|
{
|
2023-01-05 14:16:01 +02:00
|
|
|
return {
|
|
|
|
town->town->clientInfo.siegePositions[posID].x,
|
|
|
|
town->town->clientInfo.siegePositions[posID].y
|
|
|
|
};
|
2022-11-17 18:50:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
assert(0);
|
|
|
|
return Point(0,0);
|
|
|
|
}
|
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
void BattleSiegeController::gateStateChanged(const EGateState state)
|
2022-11-17 18:50:12 +02:00
|
|
|
{
|
2022-12-13 13:58:16 +02:00
|
|
|
auto oldState = owner.curInt->cb->battleGetGateState();
|
2022-11-17 18:50:12 +02:00
|
|
|
bool playSound = false;
|
2022-11-25 00:26:14 +02:00
|
|
|
auto stateId = EWallState::NONE;
|
2022-11-17 18:50:12 +02:00
|
|
|
switch(state)
|
|
|
|
{
|
|
|
|
case EGateState::CLOSED:
|
|
|
|
if (oldState != EGateState::BLOCKED)
|
|
|
|
playSound = true;
|
|
|
|
break;
|
|
|
|
case EGateState::BLOCKED:
|
|
|
|
if (oldState != EGateState::CLOSED)
|
|
|
|
playSound = true;
|
|
|
|
break;
|
|
|
|
case EGateState::OPENED:
|
|
|
|
playSound = true;
|
|
|
|
stateId = EWallState::DAMAGED;
|
|
|
|
break;
|
|
|
|
case EGateState::DESTROYED:
|
|
|
|
stateId = EWallState::DESTROYED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oldState != EGateState::NONE && oldState != EGateState::CLOSED && oldState != EGateState::BLOCKED)
|
2022-11-25 00:26:14 +02:00
|
|
|
wallPieceImages[EWallVisual::GATE] = nullptr;
|
2022-11-17 18:50:12 +02:00
|
|
|
|
|
|
|
if (stateId != EWallState::NONE)
|
2022-11-25 00:26:14 +02:00
|
|
|
wallPieceImages[EWallVisual::GATE] = IImage::createFromFile(getWallPieceImageName(EWallVisual::GATE, stateId));
|
|
|
|
|
2022-11-17 18:50:12 +02:00
|
|
|
if (playSound)
|
|
|
|
CCS->soundh->playSound(soundBase::DRAWBRG);
|
|
|
|
}
|
|
|
|
|
2023-01-05 14:16:01 +02:00
|
|
|
void BattleSiegeController::showAbsoluteObstacles(Canvas & canvas)
|
2022-11-17 18:50:12 +02:00
|
|
|
{
|
2022-11-25 00:26:14 +02:00
|
|
|
if (getWallPieceExistance(EWallVisual::MOAT))
|
2023-01-05 14:16:01 +02:00
|
|
|
showWallPiece(canvas, EWallVisual::MOAT);
|
2022-11-25 00:26:14 +02:00
|
|
|
|
2022-11-27 22:50:18 +02:00
|
|
|
if (getWallPieceExistance(EWallVisual::MOAT_BANK))
|
2023-01-05 14:16:01 +02:00
|
|
|
showWallPiece(canvas, EWallVisual::MOAT_BANK);
|
2022-11-17 18:50:12 +02:00
|
|
|
}
|
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
BattleHex BattleSiegeController::getTurretBattleHex(EWallVisual::EWallVisual wallPiece) const
|
2022-11-30 22:05:25 +02:00
|
|
|
{
|
|
|
|
switch(wallPiece)
|
|
|
|
{
|
|
|
|
case EWallVisual::KEEP_BATTLEMENT: return BattleHex::CASTLE_CENTRAL_TOWER;
|
|
|
|
case EWallVisual::BOTTOM_BATTLEMENT: return BattleHex::CASTLE_BOTTOM_TOWER;
|
|
|
|
case EWallVisual::UPPER_BATTLEMENT: return BattleHex::CASTLE_UPPER_TOWER;
|
|
|
|
}
|
|
|
|
assert(0);
|
|
|
|
return BattleHex::INVALID;
|
|
|
|
}
|
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
const CStack * BattleSiegeController::getTurretStack(EWallVisual::EWallVisual wallPiece) const
|
2022-11-30 22:05:25 +02:00
|
|
|
{
|
2022-12-13 13:58:16 +02:00
|
|
|
for (auto & stack : owner.curInt->cb->battleGetAllStacks(true))
|
2022-11-30 22:05:25 +02:00
|
|
|
{
|
|
|
|
if ( stack->initialPosition == getTurretBattleHex(wallPiece))
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
assert(0);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
void BattleSiegeController::collectRenderableObjects(BattleRenderer & renderer)
|
2022-11-17 18:50:12 +02:00
|
|
|
{
|
2022-11-25 00:26:14 +02:00
|
|
|
for (int i = EWallVisual::WALL_FIRST; i <= EWallVisual::WALL_LAST; ++i)
|
2022-11-17 18:50:12 +02:00
|
|
|
{
|
2022-11-25 00:26:14 +02:00
|
|
|
auto wallPiece = EWallVisual::EWallVisual(i);
|
|
|
|
|
|
|
|
if ( !getWallPieceExistance(wallPiece))
|
|
|
|
continue;
|
|
|
|
|
2022-12-02 17:49:38 +02:00
|
|
|
if ( getWallPiecePosition(wallPiece) == BattleHex::INVALID)
|
2022-11-25 00:26:14 +02:00
|
|
|
continue;
|
|
|
|
|
2022-11-30 22:05:25 +02:00
|
|
|
if (wallPiece == EWallVisual::KEEP_BATTLEMENT ||
|
|
|
|
wallPiece == EWallVisual::BOTTOM_BATTLEMENT ||
|
|
|
|
wallPiece == EWallVisual::UPPER_BATTLEMENT)
|
2022-11-25 00:26:14 +02:00
|
|
|
{
|
2022-12-13 15:10:31 +02:00
|
|
|
renderer.insert( EBattleFieldLayer::STACKS, getWallPiecePosition(wallPiece), [this, wallPiece](BattleRenderer::RendererRef canvas){
|
2022-12-13 13:58:16 +02:00
|
|
|
owner.stacksController->showStack(canvas, getTurretStack(wallPiece));
|
2022-12-02 17:49:38 +02:00
|
|
|
});
|
2022-12-13 15:10:31 +02:00
|
|
|
renderer.insert( EBattleFieldLayer::BATTLEMENTS, getWallPiecePosition(wallPiece), [this, wallPiece](BattleRenderer::RendererRef canvas){
|
2023-01-05 14:16:01 +02:00
|
|
|
showWallPiece(canvas, wallPiece);
|
2022-12-02 17:49:38 +02:00
|
|
|
});
|
2022-11-17 18:50:12 +02:00
|
|
|
}
|
2022-12-13 15:10:31 +02:00
|
|
|
renderer.insert( EBattleFieldLayer::WALLS, getWallPiecePosition(wallPiece), [this, wallPiece](BattleRenderer::RendererRef canvas){
|
2023-01-05 14:16:01 +02:00
|
|
|
showWallPiece(canvas, wallPiece);
|
2022-12-02 17:49:38 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2022-11-17 18:50:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
bool BattleSiegeController::isAttackableByCatapult(BattleHex hex) const
|
2022-11-17 18:50:12 +02:00
|
|
|
{
|
2022-12-13 13:58:16 +02:00
|
|
|
if (owner.tacticsMode)
|
2022-11-17 18:50:12 +02:00
|
|
|
return false;
|
|
|
|
|
2022-12-13 13:58:16 +02:00
|
|
|
auto wallPart = owner.curInt->cb->battleHexToWallPart(hex);
|
|
|
|
if (!owner.curInt->cb->isWallPartPotentiallyAttackable(wallPart))
|
2022-11-17 18:50:12 +02:00
|
|
|
return false;
|
|
|
|
|
2022-12-13 13:58:16 +02:00
|
|
|
auto state = owner.curInt->cb->battleGetWallState(static_cast<int>(wallPart));
|
2022-11-17 18:50:12 +02:00
|
|
|
return state != EWallState::DESTROYED && state != EWallState::NONE;
|
|
|
|
}
|
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
void BattleSiegeController::stackIsCatapulting(const CatapultAttack & ca)
|
2022-11-17 18:50:12 +02:00
|
|
|
{
|
2022-12-11 12:29:11 +02:00
|
|
|
assert(owner.getAnimationCondition(EAnimationEvents::ACTION) == false);
|
|
|
|
|
2022-11-17 18:50:12 +02:00
|
|
|
if (ca.attacker != -1)
|
|
|
|
{
|
2022-12-13 13:58:16 +02:00
|
|
|
const CStack *stack = owner.curInt->cb->battleGetStackByID(ca.attacker);
|
2022-11-17 18:50:12 +02:00
|
|
|
for (auto attackInfo : ca.attackedParts)
|
|
|
|
{
|
2022-12-12 22:04:25 +02:00
|
|
|
owner.stacksController->addNewAnim(new CatapultAnimation(owner, stack, attackInfo.destinationTile, nullptr, attackInfo.damageDealt));
|
2022-11-17 18:50:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-01 22:06:42 +02:00
|
|
|
std::vector<Point> positions;
|
|
|
|
|
2022-11-17 18:50:12 +02:00
|
|
|
//no attacker stack, assume spell-related (earthquake) - only hit animation
|
|
|
|
for (auto attackInfo : ca.attackedParts)
|
2022-12-13 13:58:16 +02:00
|
|
|
positions.push_back(owner.stacksController->getStackPositionAtHex(attackInfo.destinationTile, nullptr) + Point(99, 120));
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-12-25 21:35:13 +02:00
|
|
|
CCS->soundh->playSound( "WALLHIT" );
|
2022-12-25 21:39:55 +02:00
|
|
|
owner.stacksController->addNewAnim(new EffectAnimation(owner, "SGEXPL.DEF", positions));
|
2022-11-17 18:50:12 +02:00
|
|
|
}
|
|
|
|
|
2022-12-10 00:25:11 +02:00
|
|
|
owner.waitForAnimationCondition(EAnimationEvents::ACTION, false);
|
|
|
|
owner.setAnimationCondition(EAnimationEvents::HIT, false);
|
2022-11-17 18:50:12 +02:00
|
|
|
|
|
|
|
for (auto attackInfo : ca.attackedParts)
|
|
|
|
{
|
2022-11-25 00:26:14 +02:00
|
|
|
int wallId = attackInfo.attackedPart + EWallVisual::DESTRUCTIBLE_FIRST;
|
2022-11-17 18:50:12 +02:00
|
|
|
//gate state changing handled separately
|
|
|
|
if (wallId == EWallVisual::GATE)
|
|
|
|
continue;
|
|
|
|
|
2022-12-13 13:58:16 +02:00
|
|
|
auto wallState = EWallState::EWallState(owner.curInt->cb->battleGetWallState(attackInfo.attackedPart));
|
2022-11-25 00:26:14 +02:00
|
|
|
|
|
|
|
wallPieceImages[wallId] = IImage::createFromFile(getWallPieceImageName(EWallVisual::EWallVisual(wallId), wallState));
|
2022-11-17 18:50:12 +02:00
|
|
|
}
|
|
|
|
}
|
2022-12-02 00:06:57 +02:00
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
const CGTownInstance *BattleSiegeController::getSiegedTown() const
|
2022-12-02 00:06:57 +02:00
|
|
|
{
|
|
|
|
return town;
|
|
|
|
}
|