mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
support 0 spellpower and knowledge
This commit is contained in:
@ -296,7 +296,12 @@
|
|||||||
// number of artifacts that can fit in a backpack. -1 is unlimited.
|
// number of artifacts that can fit in a backpack. -1 is unlimited.
|
||||||
"backpackSize" : -1,
|
"backpackSize" : -1,
|
||||||
// if heroes are invitable in tavern
|
// if heroes are invitable in tavern
|
||||||
"tavernInvite" : false
|
"tavernInvite" : false,
|
||||||
|
// minimai primary skills for heroes
|
||||||
|
"minimalAttack": 0,
|
||||||
|
"minimalDefence": 0,
|
||||||
|
"minimalKnowledge": 1,
|
||||||
|
"minimalSpellPower": 1
|
||||||
},
|
},
|
||||||
|
|
||||||
"towns":
|
"towns":
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "VCMI_Lib.h"
|
#include "VCMI_Lib.h"
|
||||||
#include "GameConstants.h"
|
#include "GameConstants.h"
|
||||||
#include "GameSettings.h"
|
#include "GameSettings.h"
|
||||||
|
#include "MinimalPrimarySkill.h"
|
||||||
#include "bonuses/BonusList.h"
|
#include "bonuses/BonusList.h"
|
||||||
#include "bonuses/Bonus.h"
|
#include "bonuses/Bonus.h"
|
||||||
#include "bonuses/IBonusBearer.h"
|
#include "bonuses/IBonusBearer.h"
|
||||||
@ -86,7 +87,7 @@ int AFactionMember::getPrimSkillLevel(PrimarySkill id) const
|
|||||||
static const std::string keyAllSkills = "type_PRIMARY_SKILL";
|
static const std::string keyAllSkills = "type_PRIMARY_SKILL";
|
||||||
auto allSkills = getBonusBearer()->getBonuses(selectorAllSkills, keyAllSkills);
|
auto allSkills = getBonusBearer()->getBonuses(selectorAllSkills, keyAllSkills);
|
||||||
auto ret = allSkills->valOfBonuses(Selector::subtype()(BonusSubtypeID(id)));
|
auto ret = allSkills->valOfBonuses(Selector::subtype()(BonusSubtypeID(id)));
|
||||||
auto minSkillValue = (id == PrimarySkill::SPELL_POWER || id == PrimarySkill::KNOWLEDGE) ? 1 : 0;
|
auto minSkillValue = getPrimarySkillMinimum(id);
|
||||||
return std::max(ret, minSkillValue); //otherwise, some artifacts may cause negative skill value effect, sp=0 works in old saves
|
return std::max(ret, minSkillValue); //otherwise, some artifacts may cause negative skill value effect, sp=0 works in old saves
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "GameSettings.h"
|
#include "GameSettings.h"
|
||||||
#include "CSkillHandler.h"
|
#include "CSkillHandler.h"
|
||||||
#include "BattleFieldHandler.h"
|
#include "BattleFieldHandler.h"
|
||||||
|
#include "MinimalPrimarySkill.h"
|
||||||
#include "bonuses/Limiters.h"
|
#include "bonuses/Limiters.h"
|
||||||
#include "bonuses/Updaters.h"
|
#include "bonuses/Updaters.h"
|
||||||
#include "entities/faction/CFaction.h"
|
#include "entities/faction/CFaction.h"
|
||||||
@ -230,8 +231,7 @@ void CHeroClassHandler::fillPrimarySkillData(const JsonNode & node, CHeroClass *
|
|||||||
{
|
{
|
||||||
const auto & skillName = NPrimarySkill::names[pSkill.getNum()];
|
const auto & skillName = NPrimarySkill::names[pSkill.getNum()];
|
||||||
auto currentPrimarySkillValue = static_cast<int>(node["primarySkills"][skillName].Integer());
|
auto currentPrimarySkillValue = static_cast<int>(node["primarySkills"][skillName].Integer());
|
||||||
//minimal value is 0 for attack and defense and 1 for spell power and knowledge
|
int primarySkillLegalMinimum = getPrimarySkillMinimum(pSkill);
|
||||||
auto primarySkillLegalMinimum = (pSkill == PrimarySkill::ATTACK || pSkill == PrimarySkill::DEFENSE) ? 0 : 1;
|
|
||||||
|
|
||||||
if(currentPrimarySkillValue < primarySkillLegalMinimum)
|
if(currentPrimarySkillValue < primarySkillLegalMinimum)
|
||||||
{
|
{
|
||||||
|
@ -275,6 +275,7 @@ set(lib_MAIN_SRCS
|
|||||||
IHandlerBase.cpp
|
IHandlerBase.cpp
|
||||||
LoadProgress.cpp
|
LoadProgress.cpp
|
||||||
LogicalExpression.cpp
|
LogicalExpression.cpp
|
||||||
|
MimialPrimarySkill.cpp
|
||||||
ObstacleHandler.cpp
|
ObstacleHandler.cpp
|
||||||
StartInfo.cpp
|
StartInfo.cpp
|
||||||
ResourceSet.cpp
|
ResourceSet.cpp
|
||||||
@ -696,6 +697,7 @@ set(lib_MAIN_HEADERS
|
|||||||
int3.h
|
int3.h
|
||||||
LoadProgress.h
|
LoadProgress.h
|
||||||
LogicalExpression.h
|
LogicalExpression.h
|
||||||
|
MinimalPrimarySkill.h
|
||||||
ObstacleHandler.h
|
ObstacleHandler.h
|
||||||
Point.h
|
Point.h
|
||||||
Rect.h
|
Rect.h
|
||||||
|
@ -75,6 +75,10 @@ void GameSettings::load(const JsonNode & input)
|
|||||||
{EGameSettings::HEROES_STARTING_STACKS_CHANCES, "heroes", "startingStackChances" },
|
{EGameSettings::HEROES_STARTING_STACKS_CHANCES, "heroes", "startingStackChances" },
|
||||||
{EGameSettings::HEROES_BACKPACK_CAP, "heroes", "backpackSize" },
|
{EGameSettings::HEROES_BACKPACK_CAP, "heroes", "backpackSize" },
|
||||||
{EGameSettings::HEROES_TAVERN_INVITE, "heroes", "tavernInvite" },
|
{EGameSettings::HEROES_TAVERN_INVITE, "heroes", "tavernInvite" },
|
||||||
|
{EGameSettings::HEROES_MINIMAL_ATTACK, "heroes", "minimalAttack" },
|
||||||
|
{EGameSettings::HEROES_MINIMAL_DEFENCE, "heroes", "minimalDefence" },
|
||||||
|
{EGameSettings::HEROES_MINIMAL_KNOWLEDGE, "heroes", "minimalKnowledge" },
|
||||||
|
{EGameSettings::HEROES_MINIMAL_SPELL_POWER, "heroes", "minimalSpellPower" },
|
||||||
{EGameSettings::MAP_FORMAT_RESTORATION_OF_ERATHIA, "mapFormat", "restorationOfErathia" },
|
{EGameSettings::MAP_FORMAT_RESTORATION_OF_ERATHIA, "mapFormat", "restorationOfErathia" },
|
||||||
{EGameSettings::MAP_FORMAT_ARMAGEDDONS_BLADE, "mapFormat", "armageddonsBlade" },
|
{EGameSettings::MAP_FORMAT_ARMAGEDDONS_BLADE, "mapFormat", "armageddonsBlade" },
|
||||||
{EGameSettings::MAP_FORMAT_SHADOW_OF_DEATH, "mapFormat", "shadowOfDeath" },
|
{EGameSettings::MAP_FORMAT_SHADOW_OF_DEATH, "mapFormat", "shadowOfDeath" },
|
||||||
|
@ -39,6 +39,10 @@ enum class EGameSettings
|
|||||||
HEROES_STARTING_STACKS_CHANCES,
|
HEROES_STARTING_STACKS_CHANCES,
|
||||||
HEROES_BACKPACK_CAP,
|
HEROES_BACKPACK_CAP,
|
||||||
HEROES_TAVERN_INVITE,
|
HEROES_TAVERN_INVITE,
|
||||||
|
HEROES_MINIMAL_ATTACK,
|
||||||
|
HEROES_MINIMAL_DEFENCE,
|
||||||
|
HEROES_MINIMAL_KNOWLEDGE,
|
||||||
|
HEROES_MINIMAL_SPELL_POWER,
|
||||||
MARKETS_BLACK_MARKET_RESTOCK_PERIOD,
|
MARKETS_BLACK_MARKET_RESTOCK_PERIOD,
|
||||||
BANKS_SHOW_GUARDS_COMPOSITION,
|
BANKS_SHOW_GUARDS_COMPOSITION,
|
||||||
MODULE_COMMANDERS,
|
MODULE_COMMANDERS,
|
||||||
|
29
lib/MimialPrimarySkill.cpp
Normal file
29
lib/MimialPrimarySkill.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* MinimalPrimarySkill.cpp, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include "StdInc.h"
|
||||||
|
#include "MinimalPrimarySkill.h"
|
||||||
|
#include "VCMI_Lib.h"
|
||||||
|
#include "GameSettings.h"
|
||||||
|
|
||||||
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
int getPrimarySkillMinimum(PrimarySkill pSkill)
|
||||||
|
{
|
||||||
|
if (pSkill == PrimarySkill::ATTACK)
|
||||||
|
return VLC->settings()->getInteger(EGameSettings::HEROES_MINIMAL_ATTACK);
|
||||||
|
else if (pSkill == PrimarySkill::DEFENSE)
|
||||||
|
return VLC->settings()->getInteger(EGameSettings::HEROES_MINIMAL_DEFENCE);
|
||||||
|
else if (pSkill == PrimarySkill::SPELL_POWER)
|
||||||
|
return VLC->settings()->getInteger(EGameSettings::HEROES_MINIMAL_SPELL_POWER);
|
||||||
|
else
|
||||||
|
return VLC->settings()->getInteger(EGameSettings::HEROES_MINIMAL_KNOWLEDGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
VCMI_LIB_NAMESPACE_END
|
18
lib/MinimalPrimarySkill.h
Normal file
18
lib/MinimalPrimarySkill.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* MinimalPrimarySkill.h, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GameConstants.h"
|
||||||
|
|
||||||
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
int getPrimarySkillMinimum(PrimarySkill pSkill);
|
||||||
|
|
||||||
|
VCMI_LIB_NAMESPACE_END
|
@ -107,7 +107,7 @@ bool Rewardable::Limiter::heroAllowed(const CGHeroInstance * hero) const
|
|||||||
if (canLearnSkills && !hero->canLearnSkill())
|
if (canLearnSkills && !hero->canLearnSkill())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(manaPercentage > 100 * hero->mana / hero->manaLimit())
|
if (hero->manaLimit() != 0 && manaPercentage > 100 * hero->mana / hero->manaLimit())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for(size_t i=0; i<primary.size(); i++)
|
for(size_t i=0; i<primary.size(); i++)
|
||||||
|
Reference in New Issue
Block a user