Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Fix getMinMaxValues attackSkill with distance weapons (#1060)
Browse files Browse the repository at this point in the history
* Fix getMinMaxValues attackSkill with distance weapons

* Updated onGetFormulaValues for Ethereal Spear spells
  • Loading branch information
Oen44 authored Jun 6, 2020
1 parent 1bebd91 commit 4661158
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions data/spells/scripts/attack/ethereal spear.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)

function onGetFormulaValues(player, attack, factor)
local skillTotal = 2 * player:getEffectiveSkillLevel(SKILL_DISTANCE)
function onGetFormulaValues(player, skill, attack, factor)
local levelTotal = player:getLevel() / 5
return -(((skillTotal + attack / 3500) * 0.35) + (levelTotal) + 0), -(((skillTotal + attack / 3125) * 0.5) + (levelTotal) + 5)
return -(((2 * skill + attack / 3500) * 0.35) + (levelTotal) + 0), -(((2 * skill + attack / 3125) * 0.5) + (levelTotal) + 5)
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
Expand Down
5 changes: 2 additions & 3 deletions data/spells/scripts/attack/strong ethereal spear.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)

function onGetFormulaValues(player, attack, factor)
local skillTotal = 2 * player:getEffectiveSkillLevel(SKILL_DISTANCE)
function onGetFormulaValues(player, skill, attack, factor)
local levelTotal = player:getLevel() / 5
return -(((skillTotal + attack / 2500) * 2.30) + (levelTotal) + 7), -(((skillTotal + attack / 1875) * 3.30) + (levelTotal) + 13)
return -(((2 * skill + attack / 2500) * 2.30) + (levelTotal) + 7), -(((2 * skill + attack / 1875) * 3.30) + (levelTotal) + 13)
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
Expand Down
5 changes: 3 additions & 2 deletions src/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,11 +1012,12 @@ void ValueCallback::getMinMaxValues(Player* player, CombatDamage& damage, bool u
//onGetPlayerMinMaxValues(player, attackSkill, attackValue, attackFactor)
Item* tool = player->getWeapon();
const Weapon* weapon = g_weapons->getWeapon(tool);
Item* item = nullptr;

if (weapon) {
attackValue = tool->getAttack();
if (tool->getWeaponType() == WEAPON_AMMO) {
Item* item = player->getWeapon(true);
item = player->getWeapon(true);
if (item) {
attackValue += item->getAttack();
}
Expand Down Expand Up @@ -1044,7 +1045,7 @@ void ValueCallback::getMinMaxValues(Player* player, CombatDamage& damage, bool u
}
}

lua_pushnumber(L, player->getWeaponSkill(tool));
lua_pushnumber(L, player->getWeaponSkill(item ? item : tool));
lua_pushnumber(L, attackValue);
lua_pushnumber(L, player->getAttackFactor());
parameters += 3;
Expand Down

0 comments on commit 4661158

Please sign in to comment.