mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- Commanders will now be properly intialized
- Commanders show in the battle
This commit is contained in:
parent
b0371597cd
commit
82f3bc8135
@ -1,5 +1,6 @@
|
||||
{
|
||||
"battle_positions": [
|
||||
"battle_positions":
|
||||
[
|
||||
{
|
||||
"name" : "attackerLoose", // loose formation, attacker
|
||||
"levels": [
|
||||
@ -77,5 +78,10 @@
|
||||
[ 15, 185, 171, 1, 100, 86, 8 ]
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
"commanderPositions":
|
||||
{
|
||||
"field" : [88, 98], //attacker/defender
|
||||
"creBank" : [95, 8] //not expecting defendig hero at bank, but hell knows
|
||||
}
|
||||
}
|
||||
|
@ -1616,7 +1616,9 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const
|
||||
}
|
||||
|
||||
//reading battleStartpos
|
||||
//TODO: parse once to some structure
|
||||
std::vector< std::vector<int> > attackerLoose, defenderLoose, attackerTight, defenderTight, attackerCreBank, defenderCreBank;
|
||||
std::vector <int> commanderField, commanderBank;
|
||||
const JsonNode config(GameConstants::DATA_DIR + "/config/battleStartpos.json");
|
||||
const JsonVector &positions = config["battle_positions"].Vector();
|
||||
|
||||
@ -1626,6 +1628,15 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const
|
||||
CGH::readBattlePositions(positions[3]["levels"], defenderTight);
|
||||
CGH::readBattlePositions(positions[4]["levels"], attackerCreBank);
|
||||
CGH::readBattlePositions(positions[5]["levels"], defenderCreBank);
|
||||
|
||||
BOOST_FOREACH (auto position, config["commanderPositions"]["field"].Vector())
|
||||
{
|
||||
commanderField.push_back (position.Float());
|
||||
}
|
||||
BOOST_FOREACH (auto position, config["commanderPositions"]["creBank"].Vector())
|
||||
{
|
||||
commanderBank.push_back (position.Float());
|
||||
}
|
||||
|
||||
//battleStartpos read
|
||||
int k = 0; //stack serial
|
||||
@ -1721,6 +1732,18 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const
|
||||
}
|
||||
//war machines added
|
||||
|
||||
//adding commanders
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
if (heroes[i] && heroes[i]->commander)
|
||||
{
|
||||
CStack * stack = curB->generateNewStack (*heroes[i]->commander, !i, 255,
|
||||
creatureBank ? commanderBank[i] : commanderField[i]);
|
||||
stacks.push_back(stack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (curB->siege == 2 || curB->siege == 3)
|
||||
{
|
||||
// keep tower
|
||||
|
@ -36,7 +36,7 @@ namespace ArtBearer
|
||||
{
|
||||
enum
|
||||
{
|
||||
HERO, CREATURE//, COMMANDER
|
||||
HERO, CREATURE, COMMANDER
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -949,20 +949,21 @@ ui8 CStackInstance::bearerType() const
|
||||
CCommanderInstance::CCommanderInstance()
|
||||
{
|
||||
init();
|
||||
name = "Unnamed";
|
||||
}
|
||||
|
||||
CCommanderInstance::CCommanderInstance (TCreature id)
|
||||
{
|
||||
init();
|
||||
CStackInstance (id, 1); //init with single unit
|
||||
setType(id);
|
||||
name = "Commando"; //TODO - parse them
|
||||
}
|
||||
|
||||
void CCommanderInstance::init()
|
||||
void CCommanderInstance::init() //called only after CStackInstance::init was executed
|
||||
{
|
||||
alive = true;
|
||||
experience = 0;
|
||||
count = 0;
|
||||
count = 1;
|
||||
type = NULL;
|
||||
idRand = -1;
|
||||
_armyObj = NULL;
|
||||
|
@ -83,13 +83,14 @@ public:
|
||||
std::string name; // each Commander has different name
|
||||
std::vector <std::pair <ui8, ui8> > secondarySkills; //ID, level
|
||||
//std::vector <CArtifactInstance *> arts;
|
||||
void init();
|
||||
void init() OVERRIDE;
|
||||
CCommanderInstance();
|
||||
CCommanderInstance (TCreature id);
|
||||
~CCommanderInstance();
|
||||
|
||||
ui64 getPower() const {return 0;};
|
||||
int getExpRank() const {return 0;};
|
||||
ui8 bearerType() const OVERRIDE {return ArtBearer::COMMANDER;}; //from CArtifactSet
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
|
@ -777,6 +777,7 @@ void CGHeroInstance::initHero()
|
||||
if (GameConstants::COMMANDERS)
|
||||
{
|
||||
commander = new CCommanderInstance (VLC->creh->factionCommanders[type->heroType / 2]); //hopefully it returns town type
|
||||
commander->setArmyObj (castToArmyObj()); //TODO: separate function for setting commanders
|
||||
}
|
||||
|
||||
hoverName = VLC->generaltexth->allTexts[15];
|
||||
|
@ -92,7 +92,7 @@ namespace GameConstants
|
||||
//game modules
|
||||
const bool STACK_EXP = true;
|
||||
const bool STACK_ARTIFACT = true; //now toggle for testing
|
||||
const bool COMMANDERS = false;
|
||||
const bool COMMANDERS = true;
|
||||
const bool MITHRIL = false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user