• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

weapons with elemental damage hit little with spell [TFS 1.3]

robertorb12

New Member
Joined
Jan 15, 2020
Messages
65
Reaction score
3
Hi everyone, I have a little problem with knight spells or weapons. if I do a knight spell (anyone) and I have an ax cobra, cobra ax (Atk: 8 physical + 44 ice, Def: 29 +2, ax fighting +2), falcon battleaxe, etc. anyone who has little physical attack and a lot of elementary the damage done by spells is very little, even weapons that have 30 physical do twice the damage with spells


I'll put a script on one of those weapons and a spell to see what might be happening
exori gran script:
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)
combat:setParameter(COMBAT_PARAM_USECHARGES, 1)

function onGetFormulaValues(player, skill, attack, factor)
    local skillTotal = skill * attack
    local levelTotal = player:getLevel() / 5
    return -(((skillTotal * 0.02) + 4) + (levelTotal)), -(((skillTotal * 0.04) + 9) + (levelTotal))
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end

cobra axe:
Code:
    <item id="35231" article="a" name="cobra axe">
        <attribute key="weight" value="4000" />
        <attribute key="weaponType" value="axe" />
        <attribute key="attack" value="8" />
        <attribute key="elementIce" value="44" />
        <attribute key="defense" value="29" />
        <attribute key="extradef" value="2" />
        <attribute key="skillAxe" value="2" />
        <attribute key="imbuingSlots" value="2" />
    </item>
weapons.xml of cobra axe:
Code:
        </melee>
    <melee id="35231" level="220" unproperly="1">
        <vocation name="Knight" />



What could be happening?
 
Last edited:
That's because the extra elemental damage is not included in attack, it'll take the 8 attack from your weapon and calculates the spell dmg with it (leaving the 44 icedamage out)
 
Change
Lua:
    local skillTotal = skill * attack
to
Lua:
    local weapon = player:getSlotItem(CONST_SLOT_LEFT).itemid
    local eledmg = ItemType(weapon):getElementDamage() ~= nil and ItemType(weapon):getElementDamage() or 0
    local skillTotal = skill * (attack + eledmg)
 
Change
Lua:
    local skillTotal = skill * attack
to
Lua:
    local weapon = player:getSlotItem(CONST_SLOT_LEFT).itemid
    local eledmg = ItemType(weapon):getElementDamage() ~= nil and ItemType(weapon):getElementDamage() or 0
    local skillTotal = skill * (attack + eledmg)

i change it and the attack remains the same bro :s
 
add bellow skillTotal
Lua:
print(eledmg + attack)
reload and try the spell, then upload a screenshot of your console

also, I edited the code a few times, check if you are using the last one
 
add bellow skillTotal
Lua:
print(eledmg + attack)
reload and try the spell, then upload a screenshot of your console

also, I edited the code a few times, check if you are using the last one

I put it that way but it's still the same, don't throw me bug on the console
Code:
function onGetFormulaValues(player, skill, attack, factor)
    local weapon = player:getSlotItem(CONST_SLOT_LEFT).itemid
    local eledmg = ItemType(weapon):getElementDamage() ~= nil and ItemType(weapon):getElementDamage() or 0
    local skillTotal = skill * (attack + eledmg)
    print(eledmg + attack)
    local levelTotal = player:getLevel() / 5
    return -(((skillTotal * 0.02) + 4) + (levelTotal)), -(((skillTotal * 0.04) + 9) + (levelTotal))
end

consola.png
 
Check your inbox, I will try to help you in detail and post here the results
I tested myself the script and it's working
 
Last edited:
Check your inbox, I will try to help you in detail and post here the results
I tested myself the script and it's working
I already checked it well, if it worked only now that it hits more than it should, I tested it with "cobra axe" a total charge atk:52 between physical and elementary its hit was 1500 with exori gran and with umbral master axe atk:54 its hit was 1000
 
Im trying to guess what's going on with a mixed damage weapon
If you use -100, -100 on the function onGetFormulaValues for normal weapons like umbral master slayer it will hit 100 always but with gnome sword it will be 100 physical and the energy damage is calculated anyways ¿?
Post automatically merged:

I tried coding the spells, there's one problem btw, area spells (exori, exori gran, exori min, exori mas) will not be able to count the armor, but at least it's an improvement

data/spells/libs/spells.lua
add
Lua:
------ WEAPON DAMAGE BUG FIX START
function Player:getTotalArmor()
    local total = 0
    local slots = { CONST_SLOT_HEAD, CONST_SLOT_NECKLACE, CONST_SLOT_ARMOR, CONST_SLOT_LEGS, CONST_SLOT_FEET, CONST_SLOT_RING }
    local item
    for i = 1, #slots do
        item = self:getSlotItem(slots[i])
        if item then
            total = total + item:getType():getArmor()
        end
    end
    return total
end


function elementalDamage(item)
    local damage = ItemType(item):getElementDamage()
    return (damage ~= nil and damage > 0) and damage or 0
end
function Player:getSkillFromId(item)
local weapontype = ItemType(item):getWeaponType()
local skills = {
[1] = SKILL_SWORD,
[2] = SKILL_CLUB,
[3] = SKILL_AXE,
}
return self:getSkillLevel(skills[weapontype])
end
function getWeaponDistanceEffect(weapon)
local types = {
[1] = CONST_ANI_WHIRLWINDSWORD,
[2] = CONST_ANI_WHIRLWINDCLUB,
[3] = CONST_ANI_WHIRLWINDAXE,
}
return types[ItemType(weapon):getWeaponType()]
end
------ WEAPON DAMAGE BUG FIX END

Fierce Berserk as an Example
Lua:
local function Formula(skill, level, attack)
local skillTotal = skill*attack
local levelTotal = level / 5
return {-(((skillTotal * 0.12) + 12) + (levelTotal)), -(((skillTotal * 0.15) + 27) + (levelTotal))}
end

local area = createCombatArea(AREA_SQUARE1X1)

function onCastSpell(creature, var)
  local weapon = creature:getSlotItem(CONST_SLOT_LEFT)
    local dmg = ItemType(weapon.itemid):getAttack()
    local edmg = elementalDamage(weapon.itemid)
    local skill = creature:getSkillFromId(weapon.itemid)
    local level = creature:getLevel()
    local result = Formula(skill, level, dmg + edmg)
    local position = creature:getPosition()
    if getConfigInfo("removeWeaponCharges") == true and weapon:hasAttribute("charges") then
    local charges = weapon:getAttribute("charges")
    if charges == 1 then
    weapon:remove(1)
    else
    weapon:setAttribute("charges", charges-1)
    end
    end

    if dmg > 0 then
    doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, position, area, math.min(0, result[1] * dmg / (edmg + dmg)), math.min(0, result[2] * dmg / (edmg+dmg)), CONST_ME_HITAREA)
    end
    if edmg > 0 then
    doAreaCombatHealth(creature, ItemType(weapon.itemid):getElementType(), position, area, math.min(0, result[1] * edmg / (edmg + dmg)), math.min(0, result[2] * edmg / (edmg+dmg)), CONST_ME_HITAREA)
    end
    return true
end

a bit messy, but it works

Brutal Strike as target spell example (you can take armor in count, because we can scan the target)

Lua:
local function Formula(skill, level, attack)
local skillTotal = skill*attack
local levelTotal = level / 5
return {-(((skillTotal * 0.02) + 4) + (levelTotal)), -(((skillTotal * 0.04) + 9) + (levelTotal))}
end

function onCastSpell(creature, var)
    local weapon = creature:getSlotItem(CONST_SLOT_LEFT)

    local target = Creature(var.number)
    local dmg = ItemType(weapon.itemid):getAttack()
    local edmg = elementalDamage(weapon.itemid)
    local skill = creature:getSkillFromId(weapon.itemid)
    local level = creature:getLevel()
    local result = Formula(skill, level, dmg + edmg)
    local armor = target:isPlayer() and target:getTotalArmor() or MonsterType(target:getName()):armor()
    local armorreduction = armor > 1 and math.random(armor/2, armor) or 0
    creature:getPosition():sendDistanceEffect(target:getPosition(), getWeaponDistanceEffect(weapon.itemid))
        if getConfigInfo("removeWeaponCharges") == true and weapon:hasAttribute("charges") then
    local charges = weapon:getAttribute("charges")
    if charges == 1 then
    weapon:remove(1)
    else
    weapon:setAttribute("charges", charges-1)
    end
    end

    if dmg > 0 then
    doTargetCombatHealth(creature, target, COMBAT_PHYSICALDAMAGE, math.min(0, (result[1] * dmg / (edmg + dmg)) + armorreduction), math.min(0, (result[2] * dmg / (edmg+dmg)) + armorreduction), CONST_ME_HITAREA)
    end
    if edmg > 0 then
    doTargetCombatHealth(creature, target, ItemType(weapon.itemid):getElementType(), math.min(0, result[1] * edmg / (edmg + dmg)), math.min(0, result[2] * edmg / (edmg+dmg)), CONST_ME_HITAREA)
    end

    return true
end

For frontsweep add under local position
Lua:
position:getNextPosition(creature:getDirection())
Hope it works

Also credit to Ninja for his function
TFS 1.0 player:getTotalArm() (https://otland.net/threads/tfs-1-0-player-gettotalarm.222681/)
 
Last edited:
Im trying to guess what's going on with a mixed damage weapon
If you use -100, -100 on the function onGetFormulaValues for normal weapons like umbral master slayer it will hit 100 always but with gnome sword it will be 100 physical and the energy damage is calculated anyways ¿?
Post automatically merged:

I tried coding the spells, there's one problem btw, area spells (exori, exori gran, exori min, exori mas) will not be able to count the armor, but at least it's an improvement

data/spells/libs/spells.lua
add
Lua:
------ WEAPON DAMAGE BUG FIX START
function Player:getTotalArmor()
    local total = 0
    local slots = { CONST_SLOT_HEAD, CONST_SLOT_NECKLACE, CONST_SLOT_ARMOR, CONST_SLOT_LEGS, CONST_SLOT_FEET, CONST_SLOT_RING }
    local item
    for i = 1, #slots do
        item = self:getSlotItem(slots[i])
        if item then
            total = total + item:getType():getArmor()
        end
    end
    return total
end


function elementalDamage(item)
    local damage = ItemType(item):getElementDamage()
    return (damage ~= nil and damage > 0) and damage or 0
end
function Player:getSkillFromId(item)
local weapontype = ItemType(item):getWeaponType()
local skills = {
[1] = SKILL_SWORD,
[2] = SKILL_CLUB,
[3] = SKILL_AXE,
}
return self:getSkillLevel(skills[weapontype])
end
function getWeaponDistanceEffect(weapon)
local types = {
[1] = CONST_ANI_WHIRLWINDSWORD,
[2] = CONST_ANI_WHIRLWINDCLUB,
[3] = CONST_ANI_WHIRLWINDAXE,
}
return types[ItemType(weapon):getWeaponType()]
end
------ WEAPON DAMAGE BUG FIX END

Fierce Berserk as an Example
Lua:
local function Formula(skill, level, attack)
local skillTotal = skill*attack
local levelTotal = level / 5
return {-(((skillTotal * 0.12) + 12) + (levelTotal)), -(((skillTotal * 0.15) + 27) + (levelTotal))}
end

local area = createCombatArea(AREA_SQUARE1X1)

function onCastSpell(creature, var)
  local weapon = creature:getSlotItem(CONST_SLOT_LEFT)
    local dmg = ItemType(weapon.itemid):getAttack()
    local edmg = elementalDamage(weapon.itemid)
    local skill = creature:getSkillFromId(weapon.itemid)
    local level = creature:getLevel()
    local result = Formula(skill, level, dmg + edmg)
    local position = creature:getPosition()
    if getConfigInfo("removeWeaponCharges") == true and weapon:hasAttribute("charges") then
    local charges = weapon:getAttribute("charges")
    if charges == 1 then
    weapon:remove(1)
    else
    weapon:setAttribute("charges", charges-1)
    end
    end

    if dmg > 0 then
    doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, position, area, math.min(0, result[1] * dmg / (edmg + dmg)), math.min(0, result[2] * dmg / (edmg+dmg)), CONST_ME_HITAREA)
    end
    if edmg > 0 then
    doAreaCombatHealth(creature, ItemType(weapon.itemid):getElementType(), position, area, math.min(0, result[1] * edmg / (edmg + dmg)), math.min(0, result[2] * edmg / (edmg+dmg)), CONST_ME_HITAREA)
    end
    return true
end

a bit messy, but it works

Brutal Strike as target spell example (you can take armor in count, because we can scan the target)

Lua:
local function Formula(skill, level, attack)
local skillTotal = skill*attack
local levelTotal = level / 5
return {-(((skillTotal * 0.02) + 4) + (levelTotal)), -(((skillTotal * 0.04) + 9) + (levelTotal))}
end

function onCastSpell(creature, var)
    local weapon = creature:getSlotItem(CONST_SLOT_LEFT)

    local target = Creature(var.number)
    local dmg = ItemType(weapon.itemid):getAttack()
    local edmg = elementalDamage(weapon.itemid)
    local skill = creature:getSkillFromId(weapon.itemid)
    local level = creature:getLevel()
    local result = Formula(skill, level, dmg + edmg)
    local armor = target:isPlayer() and target:getTotalArmor() or MonsterType(target:getName()):armor()
    local armorreduction = armor > 1 and math.random(armor/2, armor) or 0
    creature:getPosition():sendDistanceEffect(target:getPosition(), getWeaponDistanceEffect(weapon.itemid))
        if getConfigInfo("removeWeaponCharges") == true and weapon:hasAttribute("charges") then
    local charges = weapon:getAttribute("charges")
    if charges == 1 then
    weapon:remove(1)
    else
    weapon:setAttribute("charges", charges-1)
    end
    end

    if dmg > 0 then
    doTargetCombatHealth(creature, target, COMBAT_PHYSICALDAMAGE, math.min(0, (result[1] * dmg / (edmg + dmg)) + armorreduction), math.min(0, (result[2] * dmg / (edmg+dmg)) + armorreduction), CONST_ME_HITAREA)
    end
    if edmg > 0 then
    doTargetCombatHealth(creature, target, ItemType(weapon.itemid):getElementType(), math.min(0, result[1] * edmg / (edmg + dmg)), math.min(0, result[2] * edmg / (edmg+dmg)), CONST_ME_HITAREA)
    end

    return true
end

For frontsweep add under local position
Lua:
position:getNextPosition(creature:getDirection())
Hope it works

Also credit to Ninja for his function
TFS 1.0 player:getTotalArm() (https://otland.net/threads/tfs-1-0-player-gettotalarm.222681/)

Yes, it is as you say. elemental damage does extra damage .

That configuration you sent for what it is?
 
Based in this problem I ended creating a thread, look here
 
Back
Top