mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-23 21:29:13 +02:00
basic 8th creature support
This commit is contained in:
parent
c1c04b3eb4
commit
1a06a2cc44
@ -143,9 +143,9 @@ static const std::vector<BuildingID> basicGoldSource = { BuildingID::TOWN_HALL,
|
||||
static const std::vector<BuildingID> defence = { BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE };
|
||||
static const std::vector<BuildingID> capitolAndRequirements = { BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE, BuildingID::CAPITOL };
|
||||
static const std::vector<BuildingID> unitsSource = { BuildingID::DWELL_LVL_1, BuildingID::DWELL_LVL_2, BuildingID::DWELL_LVL_3,
|
||||
BuildingID::DWELL_LVL_4, BuildingID::DWELL_LVL_5, BuildingID::DWELL_LVL_6, BuildingID::DWELL_LVL_7 };
|
||||
BuildingID::DWELL_LVL_4, BuildingID::DWELL_LVL_5, BuildingID::DWELL_LVL_6, BuildingID::DWELL_LVL_7, BuildingID::DWELL_LVL_8 };
|
||||
static const std::vector<BuildingID> unitsUpgrade = { BuildingID::DWELL_LVL_1_UP, BuildingID::DWELL_LVL_2_UP, BuildingID::DWELL_LVL_3_UP,
|
||||
BuildingID::DWELL_LVL_4_UP, BuildingID::DWELL_LVL_5_UP, BuildingID::DWELL_LVL_6_UP, BuildingID::DWELL_LVL_7_UP };
|
||||
BuildingID::DWELL_LVL_4_UP, BuildingID::DWELL_LVL_5_UP, BuildingID::DWELL_LVL_6_UP, BuildingID::DWELL_LVL_7_UP, BuildingID::DWELL_LVL_8_UP };
|
||||
static const std::vector<BuildingID> unitGrowth = { BuildingID::HORDE_1, BuildingID::HORDE_1_UPGR, BuildingID::HORDE_2, BuildingID::HORDE_2_UPGR };
|
||||
static const std::vector<BuildingID> _spells = { BuildingID::MAGES_GUILD_1, BuildingID::MAGES_GUILD_2, BuildingID::MAGES_GUILD_3,
|
||||
BuildingID::MAGES_GUILD_4, BuildingID::MAGES_GUILD_5 };
|
||||
|
@ -163,7 +163,7 @@ void CBuildingRect::showPopupWindow(const Point & cursorPosition)
|
||||
}
|
||||
else
|
||||
{
|
||||
int level = ( bid - BuildingID::DWELL_FIRST ) % GameConstants::CREATURES_PER_TOWN;
|
||||
int level = ( bid - BuildingID::DWELL_FIRST ) % bld->town->creatures.size();
|
||||
GH.windows().createAndPushWindow<CDwellingInfoBox>(parent->pos.x+parent->pos.w / 2, parent->pos.y+parent->pos.h /2, town, level);
|
||||
}
|
||||
}
|
||||
@ -1740,7 +1740,7 @@ CFortScreen::CFortScreen(const CGTownInstance * town):
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
ui32 fortSize = static_cast<ui32>(town->creatures.size());
|
||||
if(fortSize > GameConstants::CREATURES_PER_TOWN && town->creatures.back().second.empty())
|
||||
if(fortSize > town->town->creatures.size() && town->creatures.back().second.empty())
|
||||
fortSize--;
|
||||
|
||||
const CBuilding * fortBuilding = town->town->buildings.at(BuildingID(town->fortLevel()+6));
|
||||
@ -1758,18 +1758,18 @@ CFortScreen::CFortScreen(const CGTownInstance * town):
|
||||
|
||||
if(fortSize == GameConstants::CREATURES_PER_TOWN)
|
||||
{
|
||||
positions.push_back(Point(206,421));
|
||||
positions.push_back(Point(10, 421));
|
||||
positions.push_back(Point(404,421));
|
||||
}
|
||||
else
|
||||
{
|
||||
positions.push_back(Point(10, 421));
|
||||
positions.push_back(Point(404,421));
|
||||
positions.push_back(Point(206,421));
|
||||
}
|
||||
|
||||
for(ui32 i=0; i<fortSize; i++)
|
||||
{
|
||||
BuildingID buildingID;
|
||||
if(fortSize == GameConstants::CREATURES_PER_TOWN)
|
||||
if(fortSize == town->town->creatures.size())
|
||||
{
|
||||
BuildingID dwelling = BuildingID::DWELL_UP_FIRST+i;
|
||||
|
||||
@ -1798,13 +1798,13 @@ CFortScreen::CFortScreen(const CGTownInstance * town):
|
||||
ImagePath CFortScreen::getBgName(const CGTownInstance * town)
|
||||
{
|
||||
ui32 fortSize = static_cast<ui32>(town->creatures.size());
|
||||
if(fortSize > GameConstants::CREATURES_PER_TOWN && town->creatures.back().second.empty())
|
||||
if(fortSize > town->town->creatures.size() && town->creatures.back().second.empty())
|
||||
fortSize--;
|
||||
|
||||
if(fortSize == GameConstants::CREATURES_PER_TOWN)
|
||||
return ImagePath::builtin("TPCASTL7");
|
||||
else
|
||||
return ImagePath::builtin("TPCASTL8");
|
||||
else
|
||||
return ImagePath::builtin("TPCASTL7");
|
||||
}
|
||||
|
||||
void CFortScreen::creaturesChangedEventHandler()
|
||||
|
@ -280,6 +280,7 @@ public:
|
||||
enum Type
|
||||
{
|
||||
DEFAULT = -50,
|
||||
HORDE_PLACEHOLDER8 = -37,
|
||||
HORDE_PLACEHOLDER7 = -36,
|
||||
HORDE_PLACEHOLDER6 = -35,
|
||||
HORDE_PLACEHOLDER5 = -34,
|
||||
@ -295,16 +296,16 @@ public:
|
||||
RESOURCE_SILO, BLACKSMITH, SPECIAL_1, HORDE_1, HORDE_1_UPGR,
|
||||
SHIP, SPECIAL_2, SPECIAL_3, SPECIAL_4, HORDE_2,
|
||||
HORDE_2_UPGR, GRAIL, EXTRA_TOWN_HALL, EXTRA_CITY_HALL, EXTRA_CAPITOL,
|
||||
DWELL_FIRST=30, DWELL_LVL_2, DWELL_LVL_3, DWELL_LVL_4, DWELL_LVL_5, DWELL_LVL_6, DWELL_LAST=36,
|
||||
DWELL_UP_FIRST=37, DWELL_LVL_2_UP, DWELL_LVL_3_UP, DWELL_LVL_4_UP, DWELL_LVL_5_UP,
|
||||
DWELL_LVL_6_UP, DWELL_UP_LAST=43,
|
||||
DWELL_FIRST=30, DWELL_LVL_2, DWELL_LVL_3, DWELL_LVL_4, DWELL_LVL_5, DWELL_LVL_6, DWELL_LVL_7, DWELL_LAST=37,
|
||||
DWELL_UP_FIRST=38, DWELL_LVL_2_UP, DWELL_LVL_3_UP, DWELL_LVL_4_UP, DWELL_LVL_5_UP,
|
||||
DWELL_LVL_6_UP, DWELL_LVL_7_UP, DWELL_UP_LAST=45,
|
||||
|
||||
DWELL_LVL_1 = DWELL_FIRST,
|
||||
DWELL_LVL_7 = DWELL_LAST,
|
||||
DWELL_LVL_8 = DWELL_LAST,
|
||||
DWELL_LVL_1_UP = DWELL_UP_FIRST,
|
||||
DWELL_LVL_7_UP = DWELL_UP_LAST,
|
||||
DWELL_LVL_8_UP = DWELL_UP_LAST,
|
||||
|
||||
DWELL_UP2_FIRST = DWELL_LVL_7_UP + 1,
|
||||
DWELL_UP2_FIRST = DWELL_LVL_8_UP + 1,
|
||||
|
||||
// //Special buildings for towns.
|
||||
CASTLE_GATE = SPECIAL_3, //Inferno
|
||||
|
@ -22,7 +22,7 @@ namespace GameConstants
|
||||
|
||||
constexpr int ALL_PLAYERS = 255; //bitfield
|
||||
|
||||
constexpr int CREATURES_PER_TOWN = 7; //without upgrades
|
||||
constexpr int CREATURES_PER_TOWN = 8; //without upgrades
|
||||
constexpr int SPELL_LEVELS = 5;
|
||||
constexpr int SPELL_SCHOOL_LEVELS = 4;
|
||||
constexpr int DEFAULT_SCHOOLS = 4;
|
||||
|
@ -56,7 +56,7 @@ namespace NSecondarySkill
|
||||
|
||||
namespace EBuildingType
|
||||
{
|
||||
const std::string names [44] =
|
||||
const std::string names [46] =
|
||||
{
|
||||
"mageGuild1", "mageGuild2", "mageGuild3", "mageGuild4", "mageGuild5", // 5
|
||||
"tavern", "shipyard", "fort", "citadel", "castle", // 10
|
||||
@ -66,7 +66,8 @@ namespace EBuildingType
|
||||
"horde2Upgr", "grail", "extraTownHall", "extraCityHall", "extraCapitol", // 30
|
||||
"dwellingLvl1", "dwellingLvl2", "dwellingLvl3", "dwellingLvl4", "dwellingLvl5", // 35
|
||||
"dwellingLvl6", "dwellingLvl7", "dwellingUpLvl1", "dwellingUpLvl2", "dwellingUpLvl3", // 40
|
||||
"dwellingUpLvl4", "dwellingUpLvl5", "dwellingUpLvl6", "dwellingUpLvl7"
|
||||
"dwellingUpLvl4", "dwellingUpLvl5", "dwellingUpLvl6", "dwellingUpLvl7", "dwellingLvl8",
|
||||
"dwellingUpLvl8"
|
||||
};
|
||||
}
|
||||
|
||||
@ -163,6 +164,7 @@ namespace MappedKeys
|
||||
{ "dwellingLvl5", BuildingID::DWELL_LVL_5 },
|
||||
{ "dwellingLvl6", BuildingID::DWELL_LVL_6 },
|
||||
{ "dwellingLvl7", BuildingID::DWELL_LVL_7 },
|
||||
{ "dwellingLvl8", BuildingID::DWELL_LVL_8 },
|
||||
{ "dwellingUpLvl1", BuildingID::DWELL_LVL_1_UP },
|
||||
{ "dwellingUpLvl2", BuildingID::DWELL_LVL_2_UP },
|
||||
{ "dwellingUpLvl3", BuildingID::DWELL_LVL_3_UP },
|
||||
@ -170,6 +172,7 @@ namespace MappedKeys
|
||||
{ "dwellingUpLvl5", BuildingID::DWELL_LVL_5_UP },
|
||||
{ "dwellingUpLvl6", BuildingID::DWELL_LVL_6_UP },
|
||||
{ "dwellingUpLvl7", BuildingID::DWELL_LVL_7_UP },
|
||||
{ "dwellingUpLvl8", BuildingID::DWELL_LVL_8_UP },
|
||||
};
|
||||
|
||||
static const std::map<std::string, BuildingSubID::EBuildingSubID> SPECIAL_BUILDINGS =
|
||||
|
@ -795,10 +795,11 @@ void CGameState::initTowns()
|
||||
for (auto & vti : map->towns)
|
||||
{
|
||||
assert(vti->town);
|
||||
assert(vti->town->creatures.size() <= GameConstants::CREATURES_PER_TOWN);
|
||||
|
||||
constexpr std::array basicDwellings = { BuildingID::DWELL_FIRST, BuildingID::DWELL_LVL_2, BuildingID::DWELL_LVL_3, BuildingID::DWELL_LVL_4, BuildingID::DWELL_LVL_5, BuildingID::DWELL_LVL_6, BuildingID::DWELL_LVL_7 };
|
||||
constexpr std::array upgradedDwellings = { BuildingID::DWELL_UP_FIRST, BuildingID::DWELL_LVL_2_UP, BuildingID::DWELL_LVL_3_UP, BuildingID::DWELL_LVL_4_UP, BuildingID::DWELL_LVL_5_UP, BuildingID::DWELL_LVL_6_UP, BuildingID::DWELL_LVL_7_UP };
|
||||
constexpr std::array hordes = { BuildingID::HORDE_PLACEHOLDER1, BuildingID::HORDE_PLACEHOLDER2, BuildingID::HORDE_PLACEHOLDER3, BuildingID::HORDE_PLACEHOLDER4, BuildingID::HORDE_PLACEHOLDER5, BuildingID::HORDE_PLACEHOLDER6, BuildingID::HORDE_PLACEHOLDER7 };
|
||||
constexpr std::array basicDwellings = { BuildingID::DWELL_FIRST, BuildingID::DWELL_LVL_2, BuildingID::DWELL_LVL_3, BuildingID::DWELL_LVL_4, BuildingID::DWELL_LVL_5, BuildingID::DWELL_LVL_6, BuildingID::DWELL_LVL_7, BuildingID::DWELL_LVL_8 };
|
||||
constexpr std::array upgradedDwellings = { BuildingID::DWELL_UP_FIRST, BuildingID::DWELL_LVL_2_UP, BuildingID::DWELL_LVL_3_UP, BuildingID::DWELL_LVL_4_UP, BuildingID::DWELL_LVL_5_UP, BuildingID::DWELL_LVL_6_UP, BuildingID::DWELL_LVL_7_UP, BuildingID::DWELL_LVL_8_UP };
|
||||
constexpr std::array hordes = { BuildingID::HORDE_PLACEHOLDER1, BuildingID::HORDE_PLACEHOLDER2, BuildingID::HORDE_PLACEHOLDER3, BuildingID::HORDE_PLACEHOLDER4, BuildingID::HORDE_PLACEHOLDER5, BuildingID::HORDE_PLACEHOLDER6, BuildingID::HORDE_PLACEHOLDER7, BuildingID::HORDE_PLACEHOLDER8 };
|
||||
|
||||
//init buildings
|
||||
if(vstd::contains(vti->builtBuildings, BuildingID::DEFAULT)) //give standard set of buildings
|
||||
@ -823,7 +824,7 @@ void CGameState::initTowns()
|
||||
vti->builtBuildings.insert(BuildingID::VILLAGE_HALL);
|
||||
|
||||
//init hordes
|
||||
for (int i = 0; i < GameConstants::CREATURES_PER_TOWN; i++)
|
||||
for (int i = 0; i < vti->town->creatures.size(); i++)
|
||||
{
|
||||
if (vstd::contains(vti->builtBuildings, hordes[i])) //if we have horde for this level
|
||||
{
|
||||
|
@ -514,16 +514,16 @@ void CGTownInstance::initObj(vstd::RNG & rand) ///initialize town structures
|
||||
blockVisit = true;
|
||||
|
||||
if(townEnvisagesBuilding(BuildingSubID::PORTAL_OF_SUMMONING)) //Dungeon for example
|
||||
creatures.resize(GameConstants::CREATURES_PER_TOWN + 1);
|
||||
creatures.resize(town->creatures.size() + 1);
|
||||
else
|
||||
creatures.resize(GameConstants::CREATURES_PER_TOWN);
|
||||
creatures.resize(town->creatures.size());
|
||||
|
||||
for (int level = 0; level < GameConstants::CREATURES_PER_TOWN; level++)
|
||||
for (int level = 0; level < town->creatures.size(); level++)
|
||||
{
|
||||
BuildingID buildID = BuildingID(BuildingID::DWELL_FIRST + level);
|
||||
int upgradeNum = 0;
|
||||
|
||||
for (; town->buildings.count(buildID); upgradeNum++, buildID.advance(GameConstants::CREATURES_PER_TOWN))
|
||||
for (; town->buildings.count(buildID); upgradeNum++, buildID.advance(town->creatures.size()))
|
||||
{
|
||||
if (hasBuilt(buildID) && town->creatures.at(level).size() > upgradeNum)
|
||||
creatures[level].second.push_back(town->creatures[level][upgradeNum]);
|
||||
|
@ -56,6 +56,7 @@ std::string defaultBuildingIdConversion(BuildingID bId)
|
||||
case BuildingID::DWELL_LVL_5: return "DWELL_LVL_5";
|
||||
case BuildingID::DWELL_LVL_6: return "DWELL_LVL_6";
|
||||
case BuildingID::DWELL_LVL_7: return "DWELL_LVL_7";
|
||||
case BuildingID::DWELL_LVL_8: return "DWELL_LVL_8";
|
||||
case BuildingID::DWELL_LVL_1_UP: return "DWELL_LVL_1_UP";
|
||||
case BuildingID::DWELL_LVL_2_UP: return "DWELL_LVL_2_UP";
|
||||
case BuildingID::DWELL_LVL_3_UP: return "DWELL_LVL_3_UP";
|
||||
@ -63,6 +64,7 @@ std::string defaultBuildingIdConversion(BuildingID bId)
|
||||
case BuildingID::DWELL_LVL_5_UP: return "DWELL_LVL_5_UP";
|
||||
case BuildingID::DWELL_LVL_6_UP: return "DWELL_LVL_6_UP";
|
||||
case BuildingID::DWELL_LVL_7_UP: return "DWELL_LVL_7_UP";
|
||||
case BuildingID::DWELL_LVL_8_UP: return "DWELL_LVL_8_UP";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
@ -599,12 +599,12 @@ void CGameHandler::setPortalDwelling(const CGTownInstance * town, bool forced=fa
|
||||
return;
|
||||
}
|
||||
|
||||
if (forced || town->creatures.at(GameConstants::CREATURES_PER_TOWN).second.empty())//we need to change creature
|
||||
if (forced || town->creatures.at(town->town->creatures.size()).second.empty())//we need to change creature
|
||||
{
|
||||
SetAvailableCreatures ssi;
|
||||
ssi.tid = town->id;
|
||||
ssi.creatures = town->creatures;
|
||||
ssi.creatures[GameConstants::CREATURES_PER_TOWN].second.clear();//remove old one
|
||||
ssi.creatures[town->town->creatures.size()].second.clear();//remove old one
|
||||
|
||||
const std::vector<ConstTransitivePtr<CGDwelling> > &dwellings = p->dwellings;
|
||||
if (dwellings.empty())//no dwellings - just remove
|
||||
@ -620,13 +620,13 @@ void CGameHandler::setPortalDwelling(const CGTownInstance * town, bool forced=fa
|
||||
|
||||
if (clear)
|
||||
{
|
||||
ssi.creatures[GameConstants::CREATURES_PER_TOWN].first = std::max(1, (VLC->creh->objects.at(creatureId)->getGrowth())/2);
|
||||
ssi.creatures[town->town->creatures.size()].first = std::max(1, (VLC->creh->objects.at(creatureId)->getGrowth())/2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ssi.creatures[GameConstants::CREATURES_PER_TOWN].first = VLC->creh->objects.at(creatureId)->getGrowth();
|
||||
ssi.creatures[town->town->creatures.size()].first = VLC->creh->objects.at(creatureId)->getGrowth();
|
||||
}
|
||||
ssi.creatures[GameConstants::CREATURES_PER_TOWN].second.push_back(creatureId);
|
||||
ssi.creatures[town->town->creatures.size()].second.push_back(creatureId);
|
||||
sendAndApply(&ssi);
|
||||
}
|
||||
}
|
||||
@ -864,7 +864,7 @@ void CGameHandler::onNewTurn()
|
||||
}
|
||||
auto & sac = n.cres.at(t->id);
|
||||
|
||||
for (int k=0; k < GameConstants::CREATURES_PER_TOWN; k++) //creature growths
|
||||
for (int k=0; k < t->town->creatures.size(); k++) //creature growths
|
||||
{
|
||||
if (!t->creatures.at(k).second.empty()) // there are creatures at this level
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user