From dde420334c512f262ad1cddf1dd9ac4182984263 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Fri, 24 Nov 2023 03:11:42 -0300 Subject: [PATCH] fix: wheel divine empowerment multiplier --- .../spells/support/divine_empowerment.lua | 18 +++++++++++++++++- src/creatures/combat/combat.cpp | 5 ++++- src/creatures/players/wheel/player_wheel.cpp | 1 - .../creatures/player/player_functions.cpp | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/data-otservbr-global/scripts/spells/support/divine_empowerment.lua b/data-otservbr-global/scripts/spells/support/divine_empowerment.lua index 35375d04d7d..05fcb2b8a42 100644 --- a/data-otservbr-global/scripts/spells/support/divine_empowerment.lua +++ b/data-otservbr-global/scripts/spells/support/divine_empowerment.lua @@ -1,3 +1,17 @@ +local function removeEmpowermentItem(position) + for x = -1, 1 do + for y = -1, 1 do + local tile = Tile(Position(position.x + x, position.y + y, position.z)) + if tile then + local item = tile:getItemById(ITEM_DIVINE_EMPOWERMENT) + if item then + item:remove() + end + end + end + end +end + local spell = Spell("instant") function spell.onCastSpell(creature, var) @@ -29,10 +43,12 @@ function spell.onCastSpell(creature, var) for y = -1, 1 do local item = Game.createItem(ITEM_DIVINE_EMPOWERMENT, 1, Position(position.x + x, position.y + y, position.z)) if item then - item:setDuration(5, 5, 0, false) + item:setAttribute(ITEM_ATTRIBUTE_OWNER, creature:getId()) end end end + + addEvent(removeEmpowermentItem, 5000, position) creature:onThinkWheelOfDestiny(true) return true end diff --git a/src/creatures/combat/combat.cpp b/src/creatures/combat/combat.cpp index 2a646be071c..7625dbb038b 100644 --- a/src/creatures/combat/combat.cpp +++ b/src/creatures/combat/combat.cpp @@ -569,7 +569,7 @@ void Combat::CombatHealthFunc(std::shared_ptr caster, std::shared_ptr< targetPlayer = target->getPlayer(); } - if (caster && attackerPlayer) { + if (attackerPlayer) { std::shared_ptr item = attackerPlayer->getWeapon(); damage = applyImbuementElementalDamage(attackerPlayer, item, damage); g_events().eventPlayerOnCombat(attackerPlayer, target, item, damage); @@ -582,6 +582,9 @@ void Combat::CombatHealthFunc(std::shared_ptr caster, std::shared_ptr< damage.secondary.value /= 2; } } + + damage.damageMultiplier += attackerPlayer->wheel()->getMajorStatConditional("Divine Empowerment", WheelMajor_t::DAMAGE); + g_logger().debug("Wheel Divine Empowerment damage multiplier {}", damage.damageMultiplier); } if (g_game().combatBlockHit(damage, caster, target, params.blockedByShield, params.blockedByArmor, params.itemId != 0)) { diff --git a/src/creatures/players/wheel/player_wheel.cpp b/src/creatures/players/wheel/player_wheel.cpp index ad65a95ec95..1e3dea8d6f9 100644 --- a/src/creatures/players/wheel/player_wheel.cpp +++ b/src/creatures/players/wheel/player_wheel.cpp @@ -2173,7 +2173,6 @@ void PlayerWheel::downgradeSpell(const std::string &name) { std::shared_ptr PlayerWheel::getCombatDataSpell(CombatDamage &damage) { std::shared_ptr spell = nullptr; - damage.damageMultiplier += getMajorStatConditional("Divine Empowerment", WheelMajor_t::DAMAGE); WheelSpellGrade_t spellGrade = WheelSpellGrade_t::NONE; if (!(damage.instantSpellName).empty()) { spellGrade = getSpellUpgrade(damage.instantSpellName); diff --git a/src/lua/functions/creatures/player/player_functions.cpp b/src/lua/functions/creatures/player/player_functions.cpp index 7c8934b4574..f328f3369ef 100644 --- a/src/lua/functions/creatures/player/player_functions.cpp +++ b/src/lua/functions/creatures/player/player_functions.cpp @@ -3877,7 +3877,7 @@ int PlayerFunctions::luaPlayerUpgradeSpellWOD(lua_State* L) { } int PlayerFunctions::luaPlayerRevelationStageWOD(lua_State* L) { - // player:revelationStagesWOD([name[, set]]) + // player:revelationStageWOD([name[, set]]) std::shared_ptr player = getUserdataShared(L, 1); if (!player) { lua_pushnil(L);