Преглед изворни кода

vcmi: configurable charge

There is no reason not to make charge configurable.
Just do it.
Konstantin пре 2 година
родитељ
комит
1e73c2e1e6

+ 1 - 1
Mods/vcmi/config/vcmi/english.json

@@ -213,7 +213,7 @@
 	"core.bonus.HP_REGENERATION.name": "Regeneration",
 	"core.bonus.HP_REGENERATION.description": "Heals ${val} hit points every round",
 	"core.bonus.JOUSTING.name": "Champion Charge",
-	"core.bonus.JOUSTING.description": "+5% damage per hex travelled",
+	"core.bonus.JOUSTING.description": "+${val}% damage per hex travelled",
 	"core.bonus.KING1.name": "King 1",
 	"core.bonus.KING1.description": "Vulnerable to basic SLAYER",
 	"core.bonus.KING2.name": "King 2",

+ 1 - 1
Mods/vcmi/config/vcmi/german.json

@@ -211,7 +211,7 @@
 	"core.bonus.HP_REGENERATION.name": "Regeneration",
 	"core.bonus.HP_REGENERATION.description": "Heilt ${val} Trefferpunkte jede Runde",
 	"core.bonus.JOUSTING.name": "Champion Charge",
-	"core.bonus.JOUSTING.description": "+5% Schaden pro zurückgelegtem Feld",
+	"core.bonus.JOUSTING.description": "+${val}% Schaden pro zurückgelegtem Feld",
 	"core.bonus.KING1.name": "König 1",
 	"core.bonus.KING1.description": "Anfällig für grundlegende SLAYER",
 	"core.bonus.KING2.name": "König 2",

+ 1 - 1
Mods/vcmi/config/vcmi/polish.json

@@ -141,7 +141,7 @@
 	"core.bonus.HP_REGENERATION.name": "Regeneracja",
 	"core.bonus.HP_REGENERATION.description": "Leczy ${val} punktów zdrowia każdej rundy",
 	"core.bonus.JOUSTING.name": "Szarża Czempiona",
-	"core.bonus.JOUSTING.description": "+5% obrażeń na przebytego heksa",
+	"core.bonus.JOUSTING.description": "+${val}% obrażeń na przebytego heksa",
 	"core.bonus.KING1.name": "Król 1",
 	"core.bonus.KING1.description": "Wrażliwy na podstawowy czar POGROMCA",
 	"core.bonus.KING2.name": "Król 2",

+ 1 - 1
Mods/vcmi/config/vcmi/russian.json

@@ -226,7 +226,7 @@
 	"core.bonus.HP_REGENERATION.name": "Регенерация",
 	"core.bonus.HP_REGENERATION.description": "Исцеляет ${val} очков здоровья каждый ход",
 	"core.bonus.JOUSTING.name": "Разгон",
-	"core.bonus.JOUSTING.description": "+5% урона за каждую пройденную клетку",
+	"core.bonus.JOUSTING.description": "+${val}% урона за каждую пройденную клетку",
 	"core.bonus.KING1.name": "Король 1",
 	"core.bonus.KING1.description": "Уязвимость к заклинанию Палач 1 ступени",
 	"core.bonus.KING2.name": "Король 2",

+ 1 - 1
Mods/vcmi/config/vcmi/ukrainian.json

@@ -201,7 +201,7 @@
 	"core.bonus.HP_REGENERATION.name" : "Регенерація",
 	"core.bonus.HP_REGENERATION.description" : "Відновлює ${val} очок здоров'я кожного раунду",
 	"core.bonus.JOUSTING.name" : "Турнірна перевага",
-	"core.bonus.JOUSTING.description" : "+5% шкоди за кожен пройдений гекс",
+	"core.bonus.JOUSTING.description" : "+${val}% шкоди за кожен пройдений гекс",
 	"core.bonus.KING1.name" : "Король 1",
 	"core.bonus.KING1.description" : "Вразливий до 1-го рівня закляття Вбивця",
 	"core.bonus.KING2.name" : "Король 2",

+ 6 - 3
lib/CCreatureHandler.cpp

@@ -469,10 +469,11 @@ void CCreatureHandler::loadCommanders()
 
 void CCreatureHandler::loadBonuses(JsonNode & creature, std::string bonuses)
 {
-	auto makeBonusNode = [&](std::string type) -> JsonNode
+	auto makeBonusNode = [&](std::string type, double val = 0) -> JsonNode
 	{
 		JsonNode ret;
 		ret["type"].String() = type;
+		ret["val"].Float() = val;
 		return ret;
 	};
 
@@ -484,7 +485,7 @@ void CCreatureHandler::loadBonuses(JsonNode & creature, std::string bonuses)
 		{"const_free_attack",      makeBonusNode("BLOCKS_RETALIATION")},
 		{"IS_UNDEAD",              makeBonusNode("UNDEAD")},
 		{"const_no_melee_penalty", makeBonusNode("NO_MELEE_PENALTY")},
-		{"const_jousting",         makeBonusNode("JOUSTING")},
+		{"const_jousting",         makeBonusNode("JOUSTING", 5)},
 		{"KING_1",                 makeBonusNode("KING1")},
 		{"KING_2",                 makeBonusNode("KING2")},
 		{"KING_3",                 makeBonusNode("KING3")},
@@ -1070,7 +1071,9 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
 			case 'B':
 				b.type = Bonus::TWO_HEX_ATTACK_BREATH; break;
 			case 'c':
-				b.type = Bonus::JOUSTING; break;
+				b.type = Bonus::JOUSTING; 
+				b.val = 5;
+				break;
 			case 'D':
 				b.type = Bonus::ADDITIONAL_ATTACK; break;
 			case 'f':

+ 1 - 1
lib/battle/DamageCalculator.cpp

@@ -258,7 +258,7 @@ double DamageCalculator::getAttackJoustingFactor() const
 
 	//applying jousting bonus
 	if(info.chargeDistance > 0 && info.attacker->hasBonus(selectorJousting, cachingStrJousting) && !info.defender->hasBonus(selectorChargeImmunity, cachingStrChargeImmunity))
-		return info.chargeDistance * 0.05;
+		return info.chargeDistance * (info.attacker->valOfBonuses(selectorJousting))/100.0;
 	return 0.0;
 }