• 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!

Lua Function to get current weapon's skill

  • Thread starter Deleted member 210450
  • Start date
D

Deleted member 210450

Guest
Hi!

I was trying to find it in documentation or in Otland in general, but could not find it.

Ive got spell that deals dmg & heals:
Code:
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(cid, var)
    local skill,lvl = getPlayerSkill(cid,SKILL_SWORD),getPlayerLevel(cid)
    local min = skill * 2.75 + lvl + 5 --change this formula to change the min amount of healing
    local max = skill * 3.5 + lvl + 8 --change this formula to change the max amount of healing
    doCreatureAddHealth(cid, math.random(min,max))
    return doCombat(cid, combat, var)
end

There's constant, pre-typed skill (sword in this case). I'd like to change to "current equipped weapon's skill", so If player has axe equipped it will be SKILL_AXE and so on.
And, just in case, how to write entire formula (because if you tell me "SKILL_WEAPONTYPE" i probably won't know how to put that into script).

Thanks in advance.
 
Solution
Now this only heals.

TFS 1.3. Why you ask?
Lua:
local combat = createCombatObject()
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, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)

function onGetFormulaValues(cid, weaponSkill, weaponAttack, factor)
    local lvl = getPlayerLevel(cid)
    local min = weaponSkill* 2.75 + lvl + 5 --change this formula to change the min amount of healing
    local max = weaponSkill* 3.5 + lvl + 8 --change this formula to change the max amount of healing
    doCreatureAddHealth(cid, math.random(min,max))...
Lua:
function onGetFormulaValues(cid, weaponSkill, weaponAttack)
    local lvl = getPlayerLevel(cid)
    local min = weaponSkill* 2.75 + lvl + 5 --change this formula to change the min amount of healing
    local max = weaponSkill* 3.5 + lvl + 8 --change this formula to change the max amount of healing
    doCreatureAddHealth(cid, math.random(min,max))
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
 
Either i'm dumb or something is wrong (its not working). Maybe because i sent just a piece of code, because your code seems to be mix of both (attack, heal) formulas in my code, so lets see entire spell.lua:

Code:
local combat = createCombatObject()
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, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 2) + (attack * 0.02) + 1
    local max = (player:getLevel() / 2) + (attack * 0.04) + 3
    return -min, -max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(cid, var)
    local skill,lvl = getPlayerSkill(cid,SKILL_SWORD),getPlayerLevel(cid)
    local min = skill * 2.75 + lvl + 5 --change this formula to change the min amount of healing
    local max = skill * 3.5 + lvl + 8 --change this formula to change the max amount of healing
    doCreatureAddHealth(cid, math.random(min,max))
    return doCombat(cid, combat, var)
end

TFS 1.3 btw, forgot to mention that.
 
Lua:
local combat = createCombatObject()
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, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)

function onGetFormulaValues(cid, weaponSkill, weaponAttack, factor)
    local lvl = getPlayerLevel(cid)
    local min = weaponSkill* 2.75 + lvl + 5 --change this formula to change the min amount of healing
    local max = weaponSkill* 3.5 + lvl + 8 --change this formula to change the max amount of healing
    doCreatureAddHealth(cid, math.random(min,max))
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
you use 0.4 or 1.3?
 
Now this only heals.

TFS 1.3. Why you ask?
#Edit:
Generally i took this:
And now i see it is for 0.3.6. So, how should it look for 1.3?
 
Now this only heals.

TFS 1.3. Why you ask?
Lua:
local combat = createCombatObject()
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, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)

function onGetFormulaValues(cid, weaponSkill, weaponAttack, factor)
    local lvl = getPlayerLevel(cid)
    local min = weaponSkill* 2.75 + lvl + 5 --change this formula to change the min amount of healing
    local max = weaponSkill* 3.5 + lvl + 8 --change this formula to change the max amount of healing
    doCreatureAddHealth(cid, math.random(min,max))

    local hitmin = (lvl  / 2) + (weaponAttack* 0.02) + 1
    local hitmax = (lvl / 2) + (weaponAttack* 0.04) + 3
    return -hitmin , -hitmax 
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end

because this cod work for 0.4 and i think for 1.3 too
 
Solution
Back
Top