mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Bring hero strength for campaigns in line with h3
This commit is contained in:
@@ -270,6 +270,10 @@
|
|||||||
"description" : "List of configuration files for creatures",
|
"description" : "List of configuration files for creatures",
|
||||||
"$ref" : "#/definitions/fileListOrObject"
|
"$ref" : "#/definitions/fileListOrObject"
|
||||||
},
|
},
|
||||||
|
"campaignRegions" : {
|
||||||
|
"description" : "List of configuration files for campaign regions",
|
||||||
|
"$ref" : "#/definitions/fileListOrObject"
|
||||||
|
},
|
||||||
"artifacts" : {
|
"artifacts" : {
|
||||||
"description" : "List of configuration files for artifacts",
|
"description" : "List of configuration files for artifacts",
|
||||||
"$ref" : "#/definitions/fileListOrObject"
|
"$ref" : "#/definitions/fileListOrObject"
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ void CampaignState::setCurrentMapAsConquered(std::vector<CGHeroInstance *> heroe
|
|||||||
{
|
{
|
||||||
boost::range::sort(heroes, [](const CGHeroInstance * a, const CGHeroInstance * b)
|
boost::range::sort(heroes, [](const CGHeroInstance * a, const CGHeroInstance * b)
|
||||||
{
|
{
|
||||||
return a->getValueForCampaign() > b->getValueForCampaign();
|
return CGHeroInstance::compareCampaignValue(a, b);
|
||||||
});
|
});
|
||||||
|
|
||||||
logGlobal->info("Scenario %d of campaign %s (%s) has been completed", currentMap->getNum(), getFilename(), getNameTranslated());
|
logGlobal->info("Scenario %d of campaign %s (%s) has been completed", currentMap->getNum(), getFilename(), getNameTranslated());
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ void CGameStateCampaign::initHeroes()
|
|||||||
int maxB = -1;
|
int maxB = -1;
|
||||||
for (int b=0; b<heroes.size(); ++b)
|
for (int b=0; b<heroes.size(); ++b)
|
||||||
{
|
{
|
||||||
if (maxB == -1 || heroes[b]->getValueForCampaign() > heroes[maxB]->getValueForCampaign())
|
if(maxB == -1 || CGHeroInstance::compareCampaignValue(heroes[b], heroes[maxB]))
|
||||||
{
|
{
|
||||||
maxB = b;
|
maxB = b;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -748,17 +748,30 @@ uint64_t CGHeroInstance::getValueForDiplomacy() const
|
|||||||
return heroStrength * armyStrength;
|
return heroStrength * armyStrength;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CGHeroInstance::getValueForCampaign() const
|
bool CGHeroInstance::compareCampaignValue(const CGHeroInstance * left, const CGHeroInstance * right)
|
||||||
{
|
{
|
||||||
// Determined by testing H3: hero is preferred for transfer in campaigns if total sum of his primary skills and his secondary skill levels is greatest
|
// https://heroes.thelazy.net/index.php/Power_rating
|
||||||
// Additional info from wiki: https://heroes.thelazy.net/index.php/Power_rating
|
|
||||||
uint32_t score = level;
|
|
||||||
score += getPrimSkillLevel(PrimarySkill::ATTACK);
|
|
||||||
score += getPrimSkillLevel(PrimarySkill::DEFENSE);
|
|
||||||
score += getPrimSkillLevel(PrimarySkill::SPELL_POWER);
|
|
||||||
score += getPrimSkillLevel(PrimarySkill::DEFENSE);
|
|
||||||
|
|
||||||
return score;
|
uint32_t leftLevel = left->level;
|
||||||
|
uint64_t leftExperience = left->exp;
|
||||||
|
uint32_t leftPrimary = left->getPrimSkillLevel(PrimarySkill::ATTACK) + left->getPrimSkillLevel(PrimarySkill::DEFENSE) + left->getPrimSkillLevel(PrimarySkill::SPELL_POWER) + left->getPrimSkillLevel(PrimarySkill::DEFENSE);
|
||||||
|
uint32_t leftPrimaryAndLevel = leftPrimary + leftLevel;
|
||||||
|
|
||||||
|
uint32_t rightLevel = right->level;
|
||||||
|
uint64_t rightExperience = right->exp;
|
||||||
|
uint32_t rightPrimary = right->getPrimSkillLevel(PrimarySkill::ATTACK) + right->getPrimSkillLevel(PrimarySkill::DEFENSE) + right->getPrimSkillLevel(PrimarySkill::SPELL_POWER) + right->getPrimSkillLevel(PrimarySkill::DEFENSE);
|
||||||
|
uint32_t rightPrimaryAndLevel = rightPrimary + rightLevel;
|
||||||
|
|
||||||
|
if (leftPrimaryAndLevel != rightPrimaryAndLevel)
|
||||||
|
return leftPrimaryAndLevel > rightPrimaryAndLevel;
|
||||||
|
|
||||||
|
if (leftLevel != rightLevel)
|
||||||
|
return leftLevel > rightLevel;
|
||||||
|
|
||||||
|
if (leftExperience != rightExperience)
|
||||||
|
return leftExperience > rightExperience;
|
||||||
|
|
||||||
|
return left->getHeroTypeID() > right->getHeroTypeID();
|
||||||
}
|
}
|
||||||
|
|
||||||
ui64 CGHeroInstance::getTotalStrength() const
|
ui64 CGHeroInstance::getTotalStrength() const
|
||||||
|
|||||||
@@ -212,7 +212,8 @@ public:
|
|||||||
double getMagicStrength() const; // takes knowledge / spell power skill but also current mana, whether the hero owns a spell-book and whether that books contains anything into account
|
double getMagicStrength() const; // takes knowledge / spell power skill but also current mana, whether the hero owns a spell-book and whether that books contains anything into account
|
||||||
double getHeroStrength() const; // includes fighting and magic strength
|
double getHeroStrength() const; // includes fighting and magic strength
|
||||||
|
|
||||||
uint32_t getValueForCampaign() const;
|
/// Returns true if 'left' hero is stronger than 'right' when considering campaign transfer priority
|
||||||
|
static bool compareCampaignValue(const CGHeroInstance * left, const CGHeroInstance * right);
|
||||||
uint64_t getValueForDiplomacy() const;
|
uint64_t getValueForDiplomacy() const;
|
||||||
|
|
||||||
ui64 getTotalStrength() const; // includes fighting strength and army strength
|
ui64 getTotalStrength() const; // includes fighting strength and army strength
|
||||||
|
|||||||
Reference in New Issue
Block a user