1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Support for configurable town fortifications

Removed most of hardcoded checks for fort level or for presence of fort/
citadel/castle buildings.

It is now possible to define which parts of town fortifications are
provided by town buildings

Configuration for H3-like fortifications is provided in
buildingsLibrary.json and will be used automatically by mods as long as
mods have buidings named "fort", "citadel" and "castle".

Alternatively, mods can separately define:
- hitpoints of walls (shared value for all sections)
- hitpoints of central, upper and lower towers (separate values)
- presence of moat
- shooters for each tower (separate values)
This commit is contained in:
Ivan Savenko
2024-08-28 19:33:56 +00:00
parent 247be94015
commit 36c1ed670f
33 changed files with 284 additions and 98 deletions

View File

@@ -245,6 +245,19 @@ bool CGTownInstance::hasCapitol() const
return hasBuilt(BuildingID::CAPITOL);
}
TownFortifications CGTownInstance::fortificationsLevel() const
{
auto result = town->fortifications;
for (auto const & buildingID : builtBuildings)
result += town->buildings.at(buildingID)->fortifications;
if (result.wallsHealth == 0)
return TownFortifications();
return result;
}
CGTownInstance::CGTownInstance(IGameCallback *cb):
CGDwelling(cb),
town(nullptr),
@@ -384,8 +397,6 @@ void CGTownInstance::initializeConfigurableBuildings(vstd::RNG & rand)
DamageRange CGTownInstance::getTowerDamageRange() const
{
assert(hasBuilt(BuildingID::CASTLE));
// http://heroes.thelazy.net/wiki/Arrow_tower
// base damage, irregardless of town level
static constexpr int baseDamage = 6;
@@ -402,8 +413,6 @@ DamageRange CGTownInstance::getTowerDamageRange() const
DamageRange CGTownInstance::getKeepDamageRange() const
{
assert(hasBuilt(BuildingID::CITADEL));
// http://heroes.thelazy.net/wiki/Arrow_tower
// base damage, irregardless of town level
static constexpr int baseDamage = 10;