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

Help to translate this code!

thalmonn

New Member
Joined
Aug 18, 2019
Messages
9
Reaction score
0
Hello folks! I'm not a expert on dev otserver, so in this moment i'm trying to "convert" this code to a new version. This script is write to work on tfs 0.4 (i think) on a otserver 7.92.

I need to convert him to a tfs 1.2 params, to do the same thing as the original version. I need to run it on a 10.90 otserver.

The code is:


Lua:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
function onGetFormulaValues(cid, level, maglevel)
skill = getPlayerSkill(cid,2)
level = getPlayerLevel(cid)
min = -((skill*1)+level*1)
max = -((skill*7)+level*1)
return min, max
end

setCombatCallback(combat1, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 31)
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
function onGetFormulaValues(cid, level, maglevel)
skill = getPlayerSkill(cid,2)
level = getPlayerLevel(cid)
min = -((skill*9)+level*2)
max = -((skill*12)+level*3)
return min, max
end

local condition = createConditionObject(CONDITION_EMO)
rande = math.random(67,112)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 100, 3100, -rande)
setCombatCondition(combat2, condition)

setCombatCallback(combat2, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
    fala = math.random(1,29)
    rand = math.random(1,645)
    if rand <= getPlayerSkill(cid,2) then
    if fala == 1 then
     doPlayerSay(cid,"For honor!",16)
    doPlayerAddHealth(cid,(getPlayerMaxHealth(cid)/5))
     doSendAnimatedText(getPlayerPosition(cid),"Critical!",129)
        doCombat(cid, combat2, var)
else
     --doPlayerSay(cid,"Fell my fury!",16)
    doPlayerAddHealth(cid,(getPlayerMaxHealth(cid)/5))
     doSendAnimatedText(getPlayerPosition(cid),"Critical!",129)
        doCombat(cid, combat2, var)
end
else
        doCombat(cid, combat1, var)
end
end

So, anyone can help me?
 
I have never used 0.4 and Im really not a good coder but Ive tried, more than likely it will not work. Maybe someone else can finish it
Lua:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
function onGetFormulaValues(cid, level, maglevel)
skill = player:getSkill(2)
level = player:getLevel()
min = -((skill*1)+level*1)
max = -((skill*7)+level*1)
return min, max
end

setCombatCallback(combat1, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 31)
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
function onGetFormulaValues(cid, level, maglevel)
skill = player:getSkill(2)
level = player:getLevel()
min = -((skill*9)+level*2)
max = -((skill*12)+level*3)
return min, max
end

local condition = createConditionObject(CONDITION_EMO)
rande = math.random(67,112)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
condition:addDamage(100, 3100, -rande)

setCombatCondition(combat2, condition)

setCombatCallback(combat2, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
    fala = math.random(1,29)
    rand = math.random(1,645)
    if rand <= player:getSkill(2) then
    if fala == 1 then
    player:say("For Honor,", TALKTYPE_SAY)
    player:addHealth(player:getMaxHealth()/5)
    player:say("Critical!", TALKTYPE_MONSTER_SAY)   
    doCombat(cid, combat2, var)
else
    --player:say("Fell my fury!", TALKTYPE_SAY)
    player:addHealth(player:getMaxHealth()/5)
    player:say("Critical!", TALKTYPE_MONSTER_SAY)   
    doCombat(cid, combat2, var)
end
else
        doCombat(cid, combat1, var)
end
end
 
Which weapon do you want this to work for?

Lua:
-- Create the normal attack combatObject 
local normalAttack = createCombatObject()
setCombatParam(normalAttack, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

-- Define the formula for a normal attack 
function normalAttackFormula(player, level, maglevel)
    skill = player:getSkill(2)
    level = player:getLevel()
    min = -((skill*1)+level*1)
    max = -((skill*7)+level*1)
    return min, max
end

-- Attach the normal attack formula to the normal attack combat object 
setCombatCallback(normalAttack, CALLBACK_PARAM_LEVELMAGICVALUE, "normalAttackFormula")

-- Create the critical strike combatObject 
local criticalStrike = createCombatObject()
setCombatParam(criticalStrike, COMBAT_PARAM_EFFECT, 31)
setCombatParam(criticalStrike, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

-- Define the formula for a critical strike 
function criticalStrikeFormula(player, level, maglevel)
    skill = player:getSkill(2)
    level = player:getLevel()
    min = -((skill*9)+level*2)
    max = -((skill*12)+level*3)
    return min, max
end

-- Attach a delayed condition to the critical strike combatObject 
local condition = createConditionObject(CONDITION_EMO)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 100, 3100, -math.random(67,112))
setCombatCondition(criticalStrike, condition)

-- Attach the critical strike formula to the critical strike combat object 
setCombatCallback(criticalStrike, CALLBACK_PARAM_LEVELMAGICVALUE, "criticalStrikeFormula")

-- When assigned weapon is used 
function onUseWeapon(player, variant)
    -- 50 skill / 645 = aprox 7.7% chance of a critical strike 
    if math.random(1,645) <= player:getSkill(2) then
        -- If you do a critical strike, there is an additional 
        -- 1 / 29 = 3.4% chance of saying "For honor!"
        if math.random(1,29) == 1 then
            player:say("For honor!",TALKTYPE_SAY)
        end
        -- Heal player 20% of his max health 
        player:addHealth(player:getMaxHealth()/5)
        -- AnimatedText might be deprecated in clients > 8.6
        --doSendAnimatedText(getPlayerPosition(cid),"Critical!",129)
        player:say("Critical!", TALKTYPE_MONSTER_SAY)  
        -- Do the critical strike
        doCombat(player, criticalStrike, variant)
    else
        -- Do a regular attack
        doCombat(player, normalAttack, variant)
    end
end
 
Edit: i work on this version of your code @Znote and now his work like i need. Thank you so much for the help! You are a literaly GOD!

This version is for a player using a sword.

Lua:
-- Create the normal attack combatObject
local normalAttack = createCombatObject()
setCombatParam(normalAttack, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

-- Define the formula for a normal attack
function normalAttackFormula(player, level, maglevel)
    skill = player:getSkillLevel(SKILL_SWORD)
    level = player:getLevel()
    min = -((skill*1)+level*1)
    max = -((skill*7)+level*1)
    return min, max
end

-- Attach the normal attack formula to the normal attack combat object
setCombatCallback(normalAttack, CALLBACK_PARAM_LEVELMAGICVALUE, "normalAttackFormula")

-- Create the critical strike combatObject
local criticalStrike = createCombatObject()
setCombatParam(criticalStrike, COMBAT_PARAM_EFFECT, 32)
setCombatParam(criticalStrike, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

-- Define the formula for a critical strike
function criticalStrikeFormula(player, level, maglevel)
    skill = player:getSkillLevel(SKILL_SWORD)
    level = player:getLevel()
    min = -((skill*9)+level*2)
    max = -((skill*12)+level*3)
    return min, max
end

-- Attach a delayed condition to the critical strike combatObject
local condition = createConditionObject(CONDITION_EMO)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 100, 3100, -math.random(67,112))
setCombatCondition(criticalStrike, condition)

-- Attach the critical strike formula to the critical strike combat object
setCombatCallback(criticalStrike, CALLBACK_PARAM_LEVELMAGICVALUE, "criticalStrikeFormula")

-- When assigned weapon is used
function onUseWeapon(player, variant)
    -- 50 skill / 645 = aprox 7.7% chance of a critical strike
    if math.random(1,645) <= player:getSkillLevel(SKILL_SWORD) then
        -- If you do a critical strike, there is an additional
        -- 1 / 29 = 3.4% chance of saying "For honor!"
        if math.random(1,29) == 1 then
            player:say("For honor!",TALKTYPE_SAY)
        end
        -- Heal player 20% of his max health
        player:addHealth(player:getMaxHealth()/5)
        -- AnimatedText might be deprecated in clients > 8.6
        --doSendAnimatedText(getPlayerPosition(cid),"Critical!",129)
        player:say("Critical!", TALKTYPE_MONSTER_SAY) 
        -- Do the critical strike
        doCombat(player, criticalStrike, variant)
    else
        -- Do a regular attack
        doCombat(player, normalAttack, variant)
    end
end

Thanks folks!
 
Last edited:
Back
Top