mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
- Commanders are now a part of faction config
- Support for external dwellings for new towns
This commit is contained in:
parent
c0ce8712c1
commit
0e06ac15ad
@ -4,6 +4,7 @@
|
||||
"index" : 0,
|
||||
"nativeTerrain": "grass",
|
||||
"alignment" : "good",
|
||||
"commander" : "Paladin1",
|
||||
"creatureBackground" :
|
||||
{
|
||||
"120px" : "TPCASCAS",
|
||||
|
@ -4,6 +4,7 @@
|
||||
"index" : 8,
|
||||
"nativeTerrain": "grass",
|
||||
"alignment" : "neutral",
|
||||
"commander" : "AstralSpirit1",
|
||||
"creatureBackground" :
|
||||
{
|
||||
"120px" : "TPCASELE",
|
||||
|
@ -4,6 +4,7 @@
|
||||
"index" : 5,
|
||||
"nativeTerrain": "subterra",
|
||||
"alignment" : "evil",
|
||||
"commander" : "Brute1",
|
||||
"creatureBackground" :
|
||||
{
|
||||
"120px" : "TPCASDUN",
|
||||
|
@ -4,6 +4,7 @@
|
||||
"index" : 7,
|
||||
"nativeTerrain": "swamp",
|
||||
"alignment" : "neutral",
|
||||
"commander" : "Shaman1",
|
||||
"creatureBackground" :
|
||||
{
|
||||
"120px" : "TPCASFOR",
|
||||
|
@ -4,6 +4,7 @@
|
||||
"index" : 3,
|
||||
"nativeTerrain": "lava",
|
||||
"alignment" : "evil",
|
||||
"commander" : "Succubus1",
|
||||
"creatureBackground" :
|
||||
{
|
||||
"120px" : "TPCASINF",
|
||||
|
@ -4,6 +4,7 @@
|
||||
"index" : 4,
|
||||
"nativeTerrain": "dirt",
|
||||
"alignment" : "evil",
|
||||
"commander" : "SoulEater1",
|
||||
"creatureBackground" :
|
||||
{
|
||||
"120px" : "TPCASNEC",
|
||||
|
@ -7,6 +7,7 @@
|
||||
{
|
||||
"120px" : "TPCASNEU",
|
||||
"130px" : "CRBKGNEU"
|
||||
}
|
||||
},
|
||||
"commander" : "Enchanter" //just in case
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
"index" : 1,
|
||||
"nativeTerrain": "grass",
|
||||
"alignment" : "good",
|
||||
"commander" : "Hierophant1",
|
||||
"creatureBackground" :
|
||||
{
|
||||
"120px" : "TPCASRAM",
|
||||
|
@ -4,6 +4,7 @@
|
||||
"index" : 6,
|
||||
"nativeTerrain": "rough",
|
||||
"alignment" : "neutral",
|
||||
"commander" : "OgreLeader1",
|
||||
"creatureBackground" :
|
||||
{
|
||||
"120px" : "TPCASSTR",
|
||||
|
@ -4,6 +4,7 @@
|
||||
"index" : 2,
|
||||
"nativeTerrain" : "snow",
|
||||
"alignment" : "good",
|
||||
"commander" : "TempleGuardian1",
|
||||
"creatureBackground" :
|
||||
{
|
||||
"120px" : "TPCASTOW",
|
||||
|
@ -502,10 +502,6 @@ void CCreatureHandler::loadCreatures()
|
||||
tlog5 << "\t\tReading config/commanders.json" << std::endl;
|
||||
const JsonNode config3(ResourceID("config/commanders.json"));
|
||||
|
||||
BOOST_FOREACH (auto creature, config3["factionCreatures"].Vector())
|
||||
{
|
||||
factionCommanders[creature["faction"].Float()] = creature["id"].Float();
|
||||
}
|
||||
BOOST_FOREACH (auto bonus, config3["bonusPerLevel"].Vector())
|
||||
{
|
||||
commanderLevelPremy.push_back(JsonUtils::parseBonus (bonus.Vector()));
|
||||
|
@ -139,7 +139,6 @@ public:
|
||||
si8 expAfterUpgrade;//multiplier in %
|
||||
|
||||
//Commanders
|
||||
std::map <TFaction, TCreature> factionCommanders;
|
||||
BonusList commanderLevelPremy; //bonus values added with each level-up
|
||||
std::vector< std::vector <ui8> > skillLevels; //how much of a bonus will be given to commander with every level. SPELL_POWER also gives CASTS and RESISTANCE
|
||||
std::vector <std::pair <Bonus, std::pair <ui8, ui8> > > skillRequirements; // first - Bonus, second - which two skills are needed to use it
|
||||
@ -179,7 +178,7 @@ public:
|
||||
//TODO: should be optimized, not all these informations needs to be serialized (same for ccreature)
|
||||
h & notUsedMonsters & creatures;
|
||||
h & stackBonuses & expRanks & maxExpPerBattle & expAfterUpgrade;
|
||||
h & factionCommanders & skillLevels & skillRequirements & commanderLevelPremy;
|
||||
h & skillLevels & skillRequirements & commanderLevelPremy;
|
||||
h & allCreatures;
|
||||
h & creaturesOfLevel;
|
||||
BONUS_TREE_DESERIALIZATION_FIX
|
||||
|
@ -582,7 +582,7 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
|
||||
//if castle alignment available
|
||||
if (auto info = dynamic_cast<CCreGenAsCastleInfo*>(dwl->info))
|
||||
{
|
||||
faction = ran()%GameConstants::F_NUMBER;
|
||||
faction = ran() % VLC->townh->factions.size();
|
||||
if (info->asCastle)
|
||||
{
|
||||
for(ui32 i=0;i<map->objects.size();i++)
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "CArtHandler.h"
|
||||
#include "CTownHandler.h"
|
||||
#include "CHeroHandler.h"
|
||||
#include "CObjectHandler.h"
|
||||
|
||||
/*
|
||||
* CModHandler.h, part of VCMI engine
|
||||
@ -224,6 +225,21 @@ void CModHandler::reload()
|
||||
|
||||
VLC->dobjinfo->capitols[town.first] = new CGDefInfo(*townInfos[town.first]);
|
||||
VLC->dobjinfo->capitols[town.first]->name = cientInfo.advMapCapitol;
|
||||
|
||||
for (int i = 0; i < town.second.dwellings.size(); ++i)
|
||||
{
|
||||
const CGDefInfo * baseInfo = VLC->dobjinfo->gobjs[Obj::CREATURE_GENERATOR1][i]; //get same blockmap as first dwelling of tier i
|
||||
|
||||
BOOST_FOREACH (auto cre, town.second.creatures[i]) //both unupgraded and upgraded get same dwelling
|
||||
{
|
||||
CGDefInfo * info = new CGDefInfo(*baseInfo);
|
||||
info->subid = cre;
|
||||
info->name = town.second.dwellings[i];
|
||||
VLC->dobjinfo->gobjs[Obj::CREATURE_GENERATOR1][cre] = info;
|
||||
|
||||
VLC->objh->cregens[cre] = cre; //map of dwelling -> creature id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -762,7 +762,7 @@ void CGHeroInstance::initHero()
|
||||
|
||||
if (VLC->modh->modules.COMMANDERS)
|
||||
{
|
||||
commander = new CCommanderInstance (VLC->creh->factionCommanders[type->heroClass->faction]);
|
||||
commander = new CCommanderInstance (VLC->townh->factions[type->heroClass->faction].commander);
|
||||
commander->setArmyObj (castToArmyObj()); //TODO: separate function for setting commanders
|
||||
}
|
||||
|
||||
@ -1531,7 +1531,14 @@ void CGDwelling::initObj()
|
||||
|
||||
creatures.resize(1);
|
||||
creatures[0].second.push_back(crid);
|
||||
hoverName = VLC->generaltexth->creGens[subID];
|
||||
if (subID >= VLC->generaltexth->creGens.size()) //very messy workaround
|
||||
{
|
||||
int faction = VLC->creh->creatures[subID]->faction;
|
||||
assert (VLC->townh->towns[faction].dwellingNames.size());
|
||||
hoverName = VLC->townh->towns[faction].dwellingNames[VLC->creh->creatures[subID]->level - 1];
|
||||
}
|
||||
else
|
||||
hoverName = VLC->generaltexth->creGens[subID];
|
||||
if(crs->level > 4)
|
||||
putStack(0, new CStackInstance(crs, (crs->growth) * 3));
|
||||
if (getOwner() != GameConstants::NEUTRAL_PLAYER)
|
||||
|
@ -392,6 +392,16 @@ void CTownHandler::loadClientData(CTown &town, const JsonNode & source)
|
||||
town.clientInfo.advMapCastle = source["adventureMap"]["castle"].String();
|
||||
town.clientInfo.advMapCapitol = source["adventureMap"]["capitol"].String();
|
||||
|
||||
const JsonNode *value = &source["adventureMap"]["dwellings"];
|
||||
if (!value->isNull())
|
||||
{
|
||||
BOOST_FOREACH (const JsonNode &d, value->Vector())
|
||||
{
|
||||
town.dwellings.push_back (d["graphics"].String());
|
||||
town.dwellingNames.push_back (d["name"].String());
|
||||
}
|
||||
}
|
||||
|
||||
loadTownHall(town, source["hallSlots"]);
|
||||
loadStructures(town, source["structures"]);
|
||||
loadSiegeScreen(town, source["siege"]);
|
||||
@ -506,6 +516,12 @@ void CTownHandler::load(const JsonNode &source)
|
||||
faction.factionID = id;
|
||||
faction.name = node.second["name"].String();
|
||||
|
||||
VLC->modh->identifiers.requestIdentifier ("creature." + node.second["commander"].String(),
|
||||
[=](si32 commanderID)
|
||||
{
|
||||
factions[id].commander = commanderID;
|
||||
}); //TODO: resolve string id
|
||||
|
||||
faction.creatureBg120 = node.second["creatureBackground"]["120px"].String();
|
||||
faction.creatureBg130 = node.second["creatureBackground"]["130px"].String();
|
||||
|
||||
|
@ -94,6 +94,9 @@ public:
|
||||
|
||||
bmap<int, ConstTransitivePtr<CBuilding> > buildings;
|
||||
|
||||
std::vector<std::string> dwellings; //defs for adventure map dwellings for new towns, [0] means tier 1 creatures etc.
|
||||
std::vector<std::string> dwellingNames;
|
||||
|
||||
// should be removed at least from configs in favour of auto-detection
|
||||
std::map<int,int> hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present)
|
||||
ui32 mageLevel; //max available mage guild level
|
||||
@ -145,7 +148,7 @@ public:
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & names & typeID & creatures & buildings & hordeLvl & mageLevel
|
||||
h & names & typeID & creatures & dwellings & dwellingNames & buildings & hordeLvl & mageLevel
|
||||
& primaryRes & warMachine & clientInfo;
|
||||
}
|
||||
};
|
||||
@ -173,6 +176,9 @@ public:
|
||||
ui8 nativeTerrain;
|
||||
ui8 alignment; // uses EAlignment enum
|
||||
|
||||
//std::string commanderClass;
|
||||
TCreature commander;
|
||||
|
||||
std::string creatureBg120;
|
||||
std::string creatureBg130;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user