mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Add configurable damage and defense parameters
This commit is contained in:
parent
e8845244f7
commit
a83c7eb00f
@ -26,7 +26,11 @@
|
|||||||
"MAX_HEROES_ON_MAP_PER_PLAYER" : 8,
|
"MAX_HEROES_ON_MAP_PER_PLAYER" : 8,
|
||||||
"WINNING_HERO_WITH_NO_TROOPS_RETREATS": true,
|
"WINNING_HERO_WITH_NO_TROOPS_RETREATS": true,
|
||||||
"BLACK_MARKET_MONTHLY_ARTIFACTS_CHANGE": true,
|
"BLACK_MARKET_MONTHLY_ARTIFACTS_CHANGE": true,
|
||||||
"NO_RANDOM_SPECIAL_WEEKS_AND_MONTHS": false
|
"NO_RANDOM_SPECIAL_WEEKS_AND_MONTHS": false,
|
||||||
|
"ATTACK_POINT_DMG_MULTIPLIER": 0.05,
|
||||||
|
"ATTACK_POINTS_DMG_MULTIPLIER_CAP": 4.0,
|
||||||
|
"DEFENSE_POINT_DMG_MULTIPLIER": 0.025,
|
||||||
|
"DEFENSE_POINTS_DMG_MULTIPLIER_CAP": 0.7
|
||||||
},
|
},
|
||||||
"modules":
|
"modules":
|
||||||
{
|
{
|
||||||
|
@ -751,6 +751,14 @@ void CModHandler::loadConfigFromFile (std::string name)
|
|||||||
logMod->debug("\tBLACK_MARKET_MONTHLY_ARTIFACTS_CHANGE\t%d", static_cast<int>(settings.BLACK_MARKET_MONTHLY_ARTIFACTS_CHANGE));
|
logMod->debug("\tBLACK_MARKET_MONTHLY_ARTIFACTS_CHANGE\t%d", static_cast<int>(settings.BLACK_MARKET_MONTHLY_ARTIFACTS_CHANGE));
|
||||||
settings.NO_RANDOM_SPECIAL_WEEKS_AND_MONTHS = hardcodedFeatures["NO_RANDOM_SPECIAL_WEEKS_AND_MONTHS"].Bool();
|
settings.NO_RANDOM_SPECIAL_WEEKS_AND_MONTHS = hardcodedFeatures["NO_RANDOM_SPECIAL_WEEKS_AND_MONTHS"].Bool();
|
||||||
logMod->debug("\tNO_RANDOM_SPECIAL_WEEKS_AND_MONTHS\t%d", static_cast<int>(settings.NO_RANDOM_SPECIAL_WEEKS_AND_MONTHS));
|
logMod->debug("\tNO_RANDOM_SPECIAL_WEEKS_AND_MONTHS\t%d", static_cast<int>(settings.NO_RANDOM_SPECIAL_WEEKS_AND_MONTHS));
|
||||||
|
settings.ATTACK_POINT_DMG_MULTIPLIER = hardcodedFeatures["ATTACK_POINT_DMG_MULTIPLIER"].Float();
|
||||||
|
logMod->debug("\tATTACK_POINT_DMG_MULTIPLIER\t%f", settings.ATTACK_POINT_DMG_MULTIPLIER);
|
||||||
|
settings.ATTACK_POINTS_DMG_MULTIPLIER_CAP = hardcodedFeatures["ATTACK_POINTS_DMG_MULTIPLIER_CAP"].Float();
|
||||||
|
logMod->debug("\tATTACK_POINTS_DMG_MULTIPLIER_CAP\t%f", settings.ATTACK_POINTS_DMG_MULTIPLIER_CAP);
|
||||||
|
settings.DEFENSE_POINT_DMG_MULTIPLIER = hardcodedFeatures["DEFENSE_POINT_DMG_MULTIPLIER"].Float();
|
||||||
|
logMod->debug("\tDEFENSE_POINT_DMG_MULTIPLIER\t%f", settings.DEFENSE_POINT_DMG_MULTIPLIER);
|
||||||
|
settings.DEFENSE_POINTS_DMG_MULTIPLIER_CAP = hardcodedFeatures["DEFENSE_POINTS_DMG_MULTIPLIER_CAP"].Float();
|
||||||
|
logMod->debug("\tDEFENSE_POINTS_DMG_MULTIPLIER_CAP\t%f", settings.DEFENSE_POINTS_DMG_MULTIPLIER_CAP);
|
||||||
|
|
||||||
const JsonNode & gameModules = settings.data["modules"];
|
const JsonNode & gameModules = settings.data["modules"];
|
||||||
modules.STACK_EXP = gameModules["STACK_EXPERIENCE"].Bool();
|
modules.STACK_EXP = gameModules["STACK_EXPERIENCE"].Bool();
|
||||||
|
@ -358,6 +358,10 @@ public:
|
|||||||
bool WINNING_HERO_WITH_NO_TROOPS_RETREATS;
|
bool WINNING_HERO_WITH_NO_TROOPS_RETREATS;
|
||||||
bool BLACK_MARKET_MONTHLY_ARTIFACTS_CHANGE;
|
bool BLACK_MARKET_MONTHLY_ARTIFACTS_CHANGE;
|
||||||
bool NO_RANDOM_SPECIAL_WEEKS_AND_MONTHS;
|
bool NO_RANDOM_SPECIAL_WEEKS_AND_MONTHS;
|
||||||
|
double ATTACK_POINT_DMG_MULTIPLIER;
|
||||||
|
double ATTACK_POINTS_DMG_MULTIPLIER_CAP;
|
||||||
|
double DEFENSE_POINT_DMG_MULTIPLIER;
|
||||||
|
double DEFENSE_POINTS_DMG_MULTIPLIER_CAP;
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
@ -373,6 +377,10 @@ public:
|
|||||||
h & WINNING_HERO_WITH_NO_TROOPS_RETREATS;
|
h & WINNING_HERO_WITH_NO_TROOPS_RETREATS;
|
||||||
h & BLACK_MARKET_MONTHLY_ARTIFACTS_CHANGE;
|
h & BLACK_MARKET_MONTHLY_ARTIFACTS_CHANGE;
|
||||||
h & NO_RANDOM_SPECIAL_WEEKS_AND_MONTHS;
|
h & NO_RANDOM_SPECIAL_WEEKS_AND_MONTHS;
|
||||||
|
h & ATTACK_POINT_DMG_MULTIPLIER;
|
||||||
|
h & ATTACK_POINTS_DMG_MULTIPLIER_CAP;
|
||||||
|
h & DEFENSE_POINT_DMG_MULTIPLIER;
|
||||||
|
h & DEFENSE_POINTS_DMG_MULTIPLIER_CAP;
|
||||||
}
|
}
|
||||||
} settings;
|
} settings;
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "../spells/CSpellHandler.h"
|
#include "../spells/CSpellHandler.h"
|
||||||
#include "../mapObjects/CGTownInstance.h"
|
#include "../mapObjects/CGTownInstance.h"
|
||||||
#include "../BattleFieldHandler.h"
|
#include "../BattleFieldHandler.h"
|
||||||
|
#include "../CModHandler.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@ -802,12 +803,18 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo & info)
|
|||||||
//bonus from attack/defense skills
|
//bonus from attack/defense skills
|
||||||
if(attackDefenceDifference < 0) //decreasing dmg
|
if(attackDefenceDifference < 0) //decreasing dmg
|
||||||
{
|
{
|
||||||
const double dec = std::min(0.025 * (-attackDefenceDifference), 0.7);
|
double defenseMultiplier = VLC->modh->settings.DEFENSE_POINT_DMG_MULTIPLIER;
|
||||||
|
double defenseMultiplierCap = VLC->modh->settings.DEFENSE_POINTS_DMG_MULTIPLIER_CAP;
|
||||||
|
|
||||||
|
const double dec = std::min(defenseMultiplier * (-attackDefenceDifference), defenseMultiplierCap);
|
||||||
multBonus *= 1.0 - dec;
|
multBonus *= 1.0 - dec;
|
||||||
}
|
}
|
||||||
else //increasing dmg
|
else //increasing dmg
|
||||||
{
|
{
|
||||||
const double inc = std::min(0.05 * attackDefenceDifference, 4.0);
|
double attackMultiplier = VLC->modh->settings.ATTACK_POINT_DMG_MULTIPLIER;
|
||||||
|
double attackMultiplierCap = VLC->modh->settings.ATTACK_POINTS_DMG_MULTIPLIER_CAP;
|
||||||
|
|
||||||
|
const double inc = std::min(attackMultiplier * attackDefenceDifference, attackMultiplierCap);
|
||||||
additiveBonus += inc;
|
additiveBonus += inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user