Skip to content

Commit 0699362

Browse files
authored
fix: Chain System does not show effects for paladins (zimbadev#543)
This PR fixes an issue where paladins enabling the chain system do not see the weapon effect. Also removed chainSystemModifyMagic config
1 parent 3e2843b commit 0699362

5 files changed

Lines changed: 30 additions & 48 deletions

File tree

config.lua.dist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,8 @@ logPlayersStatements = false
527527

528528
-- Chain system
529529
-- NOTE: combatChainDelay: set to minimum 50 miliseconds
530-
-- NOTE: chainSystemModifyMagic will increase power of wands and rods based on player magic level
531530
toggleChainSystem = false
532531
chainSystemVipOnly = true
533-
chainSystemModifyMagic = false
534532
combatChainDelay = 50
535533
combatChainTargets = 5
536534
combatChainSkillFormulaFist = 1.0

src/config/config_enums.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ enum ConfigKey_t : uint16_t {
289289
TIBIADROME_CONCOCTION_TICK_TYPE,
290290
TOGGLE_ATTACK_SPEED_ONFIST,
291291
TOGGLE_CHAIN_SYSTEM,
292-
CHAIN_SYSTEM_MODIFY_MAGIC,
293292
TOGGLE_FREE_QUEST,
294293
TOGGLE_GOLD_POUCH_ALLOW_ANYTHING,
295294
TOGGLE_GOLD_POUCH_QUICKLOOT_ONLY,

src/config/configmanager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ bool ConfigManager::load() {
141141
loadBoolConfig(L, TELEPORT_SUMMONS, "teleportSummons", false);
142142
loadBoolConfig(L, TOGGLE_ATTACK_SPEED_ONFIST, "toggleAttackSpeedOnFist", false);
143143
loadBoolConfig(L, TOGGLE_CHAIN_SYSTEM, "toggleChainSystem", true);
144-
loadBoolConfig(L, CHAIN_SYSTEM_MODIFY_MAGIC, "chainSystemModifyMagic", false);
145144
loadBoolConfig(L, TOGGLE_FREE_QUEST, "toggleFreeQuest", true);
146145
loadBoolConfig(L, TOGGLE_GOLD_POUCH_ALLOW_ANYTHING, "toggleGoldPouchAllowAnything", false);
147146
loadBoolConfig(L, TOGGLE_GOLD_POUCH_QUICKLOOT_ONLY, "toggleGoldPouchQuickLootOnly", false);

src/creatures/combat/combat.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,22 @@ void Combat::addDistanceEffect(const std::shared_ptr<Creature> &caster, const Po
11891189
case WEAPON_CLUB:
11901190
effect = CONST_ANI_WHIRLWINDCLUB;
11911191
break;
1192+
case WEAPON_DISTANCE:
1193+
case WEAPON_AMMO: {
1194+
auto ammoOrWeapon = player->getWeapon();
1195+
if (ammoOrWeapon) {
1196+
const auto &iType = Item::items[ammoOrWeapon->getID()];
1197+
effect = iType.shootType;
1198+
if (effect == CONST_ANI_NONE) {
1199+
auto mainWeapon = player->getWeapon(true);
1200+
if (mainWeapon) {
1201+
const auto &mainType = Item::items[mainWeapon->getID()];
1202+
effect = mainType.shootType;
1203+
}
1204+
}
1205+
}
1206+
break;
1207+
}
11921208
case WEAPON_MISSILE: {
11931209
auto weapon = player->getWeapon();
11941210
if (weapon) {
@@ -1288,12 +1304,15 @@ void Combat::setupChain(const std::shared_ptr<Weapon> &weapon) {
12881304
break;
12891305
case WEAPON_DISTANCE:
12901306
setCommonValues(g_configManager().getFloat(COMBAT_CHAIN_SKILL_FORMULA_DISTANCE), DIST_ATK_BOW, CONST_ANI_HOLY);
1307+
setParam(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE);
12911308
break;
12921309
case WEAPON_AMMO:
12931310
setCommonValues(g_configManager().getFloat(COMBAT_CHAIN_SKILL_FORMULA_DISTANCE), DIST_ATK_BOW, CONST_ANI_HOLY);
1311+
setParam(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE);
12941312
break;
12951313
case WEAPON_MISSILE:
12961314
setCommonValues(g_configManager().getFloat(COMBAT_CHAIN_SKILL_FORMULA_MISSILE), DIST_ATK_BOW, CONST_ANI_HOLY);
1315+
setParam(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE);
12971316
break;
12981317
}
12991318

src/items/weapons/weapons.cpp

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,16 @@ void Weapon::internalUseWeapon(const std::shared_ptr<Player> &player, const std:
303303
}
304304

305305
// Handle chain system
306-
if (player->checkChainSystem() && params.chainCallback) {
307-
m_combat->doCombatChain(player, target, params.aggressive);
308-
g_logger().debug("Weapon::internalUseWeapon - Chain callback executed.");
306+
if (player->checkChainSystem()) {
307+
const auto &selfWeapon = g_weapons().getWeapon(item);
308+
if (selfWeapon) {
309+
m_combat->setupChain(selfWeapon);
310+
}
311+
if (!m_combat->doCombatChain(player, target, params.aggressive)) {
312+
Combat::doCombatHealth(player, target, damage, params);
313+
} else {
314+
g_logger().debug("Weapon::internalUseWeapon - Chain executed with distance effects.");
315+
}
309316
} else {
310317
Combat::doCombatHealth(player, target, damage, params);
311318
}
@@ -975,47 +982,7 @@ void WeaponWand::configureWeapon(const ItemType &it) {
975982
}
976983

977984
int32_t WeaponWand::getWeaponDamage(const std::shared_ptr<Player> &player, const std::shared_ptr<Creature> &, const std::shared_ptr<Item> &, bool maxDamage /* = false*/) const {
978-
if (!player->checkChainSystem()) {
979-
float multiplier = 1.0f;
980-
auto vocation = player->getVocation();
981-
if (vocation) {
982-
multiplier = vocation->wandRodDamageMultiplier;
983-
}
984-
985-
auto maxValue = static_cast<int32_t>(maxChange * multiplier);
986-
987-
// Returns maximum damage or a random value between minChange and maxChange
988-
return maxDamage ? -maxValue : -normal_random(minChange, maxValue);
989-
}
990-
991-
if (!g_configManager().getBoolean(CHAIN_SYSTEM_MODIFY_MAGIC)) {
992-
return maxDamage ? -maxChange : -normal_random(minChange, maxChange);
993-
}
994-
995-
// If chain system is enabled, calculates magic-based damage
996-
int32_t attackSkill = 0;
997-
int32_t attackValue = 0;
998-
float attackFactor = 0.0;
999-
[[maybe_unused]] int16_t elementAttack = 0;
1000-
[[maybe_unused]] CombatDamage combatDamage;
1001-
calculateSkillFormula(player, attackSkill, attackValue, attackFactor, elementAttack, combatDamage);
1002-
1003-
const auto magLevel = player->getMagicLevel();
1004-
const auto level = player->getLevel();
1005-
1006-
// Check if level is greater than zero before performing division
1007-
const auto levelDivision = level > 0 ? level / 5.0 : 0.0;
1008-
1009-
const auto totalAttackValue = magLevel + attackValue;
1010-
1011-
// Check if magLevel is greater than zero before performing division
1012-
const auto magicLevelDivision = totalAttackValue > 0 ? totalAttackValue / 3.0 : 0.0;
1013-
1014-
const double min = levelDivision + magicLevelDivision;
1015-
const double max = levelDivision + totalAttackValue;
1016-
1017-
// Returns the calculated maximum damage or a random value between the calculated minimum and maximum
1018-
return maxDamage ? -max : -normal_random(min, max);
985+
return maxDamage ? -maxChange : -normal_random(minChange, maxChange);
1019986
}
1020987

1021988
int16_t WeaponWand::getElementDamageValue() const {

0 commit comments

Comments
 (0)