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

Weapon problem

jareczekjsp

Member
Joined
Jan 30, 2023
Messages
188
Reaction score
9
GitHub
Jarek123
Hello guys I Work on tfs 0.4 but I was have a crash server and I move my server to tfs 1.5 and little bit I have problem
I have custom script on arrow and have a problem like that
Lua:
 data/weapons/scripts/arroww.lua] Function setCombatCondition was renamed to addCombatCondition and will be removed in the future


my script is

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 34)
 
local condition = createConditionObject(CONDITION_ENERGY)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 5, 1000, -100)
setCombatCondition(combat, condition)
 
function onGetFormulaValues(cid, level, skill, attack, factor)
if getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7 then
return -(level * 1) - 100, -(level * 3) - 200
end
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
 
function onUseWeapon(cid, var)
return doCombat(cid, combat, var)
end


How I can Fix it ?
 
As perun said it tells you what to do and please try to tab your script like this:

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 34)
 
local condition = createConditionObject(CONDITION_ENERGY)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 5, 1000, -100)
addCombatCondition(combat, condition)
 
function onGetFormulaValues(cid, level, skill, attack, factor)
    if getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7 then
        return -(level * 1) - 100, -(level * 3) - 200
    end
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
 
function onUseWeapon(cid, var)
    return doCombat(cid, combat, var)
end

For the supporter: please give Perun the solution here
 
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 34)

local condition = Condition(CONDITION_ENERGY)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(5, 1000, -100)
combat:addCondition(condition)

function onGetFormulaValues(cid, level, skill, attack, factor)
local player = Player(cid)
  if player:getVocation():getId() == 3 or player:getVocation():getId() == 7 then
    return -(level * 1) - 100, -(level * 3) - 200
  end
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
  return combat:execute(cid, var)
end

The main changes are:
createCombatObject() is replaced with Combat().
addCombatCondition() is replaced with Combat.addCondition().
setCombatArea() is replaced with Combat.setArea().
setCombatCallback() is replaced with Combat.setCallback().
setCombatFormula() is replaced with Combat.setFormula().
setCombatParam() is replaced with Combat.setParameter().
createConditionObject() is replaced with Condition().
setConditionParam() is replaced with Condition.setParameter().
setConditionFormula() is replaced with Condition.setFormula().
addDamageCondition() is replaced with Condition.addDamage().
addOutfitCondition() is replaced with Condition.setOutfit().
doCombat() is replaced with combat:execute().
 
Mateus also inspired me a bit, so I modified the script a bit.

Lua:
local function createDamageCondition(min, max, interval, effect)
    local condition = createConditionObject(effect)
    condition:setParameter(CONDITION_PARAM_DELAYED, interval)
    addDamageCondition(condition, min, max, -100)
    return condition
end

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 34)

local energyCondition = createDamageCondition(5, 300, 1, CONDITION_ENERGY)
combat:addCondition(energyCondition)

local poisonCondition = createDamageCondition(5, 600, 1, CONDITION_POISON)
combat:addCondition(poisonCondition)

local fireCondition = createDamageCondition(5, 800, 1, CONDITION_FIRE)
combat:addCondition(fireCondition)

function onGetFormulaValues(cid, level, skill, attack, factor)
    local baseMinDamage = -100
    local baseMaxDamage = -200
    local vocation = getPlayerVocation(cid)

    if vocation == 3 or vocation == 7 then
        local damageModifier = 1.5
        local minDamage = baseMinDamage - level * damageModifier
        local maxDamage = baseMaxDamage - level * damageModifier * 2

        return -minDamage, -maxDamage
    end
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
    return combat:execute(cid, var)
end
 
Last edited:
Back
Top