mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +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
|
"name" : "attackerLoose", // loose formation, attacker
|
||||||
"levels": [
|
"levels": [
|
||||||
@ -77,5 +78,10 @@
|
|||||||
[ 15, 185, 171, 1, 100, 86, 8 ]
|
[ 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
|
//reading battleStartpos
|
||||||
|
//TODO: parse once to some structure
|
||||||
std::vector< std::vector<int> > attackerLoose, defenderLoose, attackerTight, defenderTight, attackerCreBank, defenderCreBank;
|
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 JsonNode config(GameConstants::DATA_DIR + "/config/battleStartpos.json");
|
||||||
const JsonVector &positions = config["battle_positions"].Vector();
|
const JsonVector &positions = config["battle_positions"].Vector();
|
||||||
|
|
||||||
@ -1627,6 +1629,15 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const
|
|||||||
CGH::readBattlePositions(positions[4]["levels"], attackerCreBank);
|
CGH::readBattlePositions(positions[4]["levels"], attackerCreBank);
|
||||||
CGH::readBattlePositions(positions[5]["levels"], defenderCreBank);
|
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
|
//battleStartpos read
|
||||||
int k = 0; //stack serial
|
int k = 0; //stack serial
|
||||||
for(TSlots::const_iterator i = armies[0]->Slots().begin(); i!=armies[0]->Slots().end(); i++, k++)
|
for(TSlots::const_iterator i = armies[0]->Slots().begin(); i!=armies[0]->Slots().end(); i++, k++)
|
||||||
@ -1721,6 +1732,18 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const
|
|||||||
}
|
}
|
||||||
//war machines added
|
//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)
|
if (curB->siege == 2 || curB->siege == 3)
|
||||||
{
|
{
|
||||||
// keep tower
|
// keep tower
|
||||||
|
@ -36,7 +36,7 @@ namespace ArtBearer
|
|||||||
{
|
{
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
HERO, CREATURE//, COMMANDER
|
HERO, CREATURE, COMMANDER
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,20 +949,21 @@ ui8 CStackInstance::bearerType() const
|
|||||||
CCommanderInstance::CCommanderInstance()
|
CCommanderInstance::CCommanderInstance()
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
name = "Unnamed";
|
||||||
}
|
}
|
||||||
|
|
||||||
CCommanderInstance::CCommanderInstance (TCreature id)
|
CCommanderInstance::CCommanderInstance (TCreature id)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
CStackInstance (id, 1); //init with single unit
|
setType(id);
|
||||||
name = "Commando"; //TODO - parse them
|
name = "Commando"; //TODO - parse them
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCommanderInstance::init()
|
void CCommanderInstance::init() //called only after CStackInstance::init was executed
|
||||||
{
|
{
|
||||||
alive = true;
|
alive = true;
|
||||||
experience = 0;
|
experience = 0;
|
||||||
count = 0;
|
count = 1;
|
||||||
type = NULL;
|
type = NULL;
|
||||||
idRand = -1;
|
idRand = -1;
|
||||||
_armyObj = NULL;
|
_armyObj = NULL;
|
||||||
|
@ -83,13 +83,14 @@ public:
|
|||||||
std::string name; // each Commander has different name
|
std::string name; // each Commander has different name
|
||||||
std::vector <std::pair <ui8, ui8> > secondarySkills; //ID, level
|
std::vector <std::pair <ui8, ui8> > secondarySkills; //ID, level
|
||||||
//std::vector <CArtifactInstance *> arts;
|
//std::vector <CArtifactInstance *> arts;
|
||||||
void init();
|
void init() OVERRIDE;
|
||||||
CCommanderInstance();
|
CCommanderInstance();
|
||||||
CCommanderInstance (TCreature id);
|
CCommanderInstance (TCreature id);
|
||||||
~CCommanderInstance();
|
~CCommanderInstance();
|
||||||
|
|
||||||
ui64 getPower() const {return 0;};
|
ui64 getPower() const {return 0;};
|
||||||
int getExpRank() 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)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
|
@ -777,6 +777,7 @@ void CGHeroInstance::initHero()
|
|||||||
if (GameConstants::COMMANDERS)
|
if (GameConstants::COMMANDERS)
|
||||||
{
|
{
|
||||||
commander = new CCommanderInstance (VLC->creh->factionCommanders[type->heroType / 2]); //hopefully it returns town type
|
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];
|
hoverName = VLC->generaltexth->allTexts[15];
|
||||||
|
@ -92,7 +92,7 @@ namespace GameConstants
|
|||||||
//game modules
|
//game modules
|
||||||
const bool STACK_EXP = true;
|
const bool STACK_EXP = true;
|
||||||
const bool STACK_ARTIFACT = true; //now toggle for testing
|
const bool STACK_ARTIFACT = true; //now toggle for testing
|
||||||
const bool COMMANDERS = false;
|
const bool COMMANDERS = true;
|
||||||
const bool MITHRIL = false;
|
const bool MITHRIL = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user