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

TFS 0.X Poison arrow poisoning 0.5~2.0 * skill

fyalhed

Member
Joined
Nov 18, 2017
Messages
156
Reaction score
20
What do i doing wrong?

I'm trying to make poison from poison arrow, do the poison based on skills
poison = skills * 0.5~2.0

Code:
-- Poison
local combat2 = {}
local poison = {}
function DoPoison(cid)
    combat2 = createCombatObject()
    poison = createConditionObject(CONDITION_POISON)
    setConditionParam(poison, CONDITION_PARAM_DELAYED, 15)
    -- 10 ???
    -- after 2 seconds start the poison
    -- poison = skill / 2 ~ skill * 2
    local skill = getPlayerSkillLevel(cid, SKILL_DISTANCE)
    local from_half_to_double = (math.random(5, 20)) / 10
    print("[0.5-2.0]: " .. from_half_to_double)
    addDamageCondition(poison, 10, 2000, -(skill * from_half_to_double) )
    setCombatCondition(combat2, poison)
end

function onUseWeapon(cid, var)
    autoRechargeAmmo(cid)
    DoPoison(cid)
    doCombat(cid, combat2, var) -- applies the poison
    return doCombat(cid, combat, var) -- applies the damage
end


error on console
Code:
[10:43:30.184] [Error - Weapon Interface] 
[10:43:30.184] data/weapons/scripts/distance_weapons/arrows/poison_arrow.lua:onUseWeapon
[10:43:30.184] Description: 
[10:43:30.184] (luaCreateCombatObject) This function can only be used while loading the script.
[0.5-2.0]: 1.7

[10:43:30.184] [Error - Weapon Interface] 
[10:43:30.184] data/weapons/scripts/distance_weapons/arrows/poison_arrow.lua:onUseWeapon
[10:43:30.184] Description: 
[10:43:30.184] (luaSetCombatCondition) Combat not found

[10:43:30.184] [Error - Weapon Interface] 
[10:43:30.185] data/weapons/scripts/distance_weapons/arrows/poison_arrow.lua:onUseWeapon
[10:43:30.185] Description: 
[10:43:30.185] (luaDoCombat) Combat not found

how should i do this?
 
Solution
It works, but the poison dmg is not actually being dealt by the player (cid).
So, depending of what you're planning to do (statschange wise), it might not be the solution.

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISONARROW)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 1, 0, 1, 0)

function onUseWeapon(cid, var)
    local skill = getPlayerSkillLevel(cid, SKILL_DISTANCE)
    local from_half_to_double = (math.random(5, 20)) / 10
    local poisonDamage = (skill * from_half_to_double) * -1
    print("Skill: " .. skill .. " | from_half_to_double: " ...

leo139

New Member
Joined
Dec 23, 2012
Messages
2
Solutions
1
Reaction score
1
It works, but the poison dmg is not actually being dealt by the player (cid).
So, depending of what you're planning to do (statschange wise), it might not be the solution.

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISONARROW)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 1, 0, 1, 0)

function onUseWeapon(cid, var)
    local skill = getPlayerSkillLevel(cid, SKILL_DISTANCE)
    local from_half_to_double = (math.random(5, 20)) / 10
    local poisonDamage = (skill * from_half_to_double) * -1
    print("Skill: " .. skill .. " | from_half_to_double: " .. from_half_to_double .. " | poisonDamage: " .. poisonDamage)
   
    local condition = createConditionObject(CONDITION_POISON)
    setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
    addDamageCondition(condition, 5, 1000, poisonDamage)
   
    local target = variantToNumber(var)
    if(target ~= 0) then
        doAddCondition(target, condition)
    end

    return doCombat(cid, combat, var)
end
 
Solution
OP
fyalhed

fyalhed

Member
Joined
Nov 18, 2017
Messages
156
Reaction score
20
It works, but the poison dmg is not actually being dealt by the player (cid).
So, depending of what you're planning to do (statschange wise), it might not be the solution.

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISONARROW)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 1, 0, 1, 0)

function onUseWeapon(cid, var)
    local skill = getPlayerSkillLevel(cid, SKILL_DISTANCE)
    local from_half_to_double = (math.random(5, 20)) / 10
    local poisonDamage = (skill * from_half_to_double) * -1
    print("Skill: " .. skill .. " | from_half_to_double: " .. from_half_to_double .. " | poisonDamage: " .. poisonDamage)
  
    local condition = createConditionObject(CONDITION_POISON)
    setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
    addDamageCondition(condition, 5, 1000, poisonDamage)
  
    local target = variantToNumber(var)
    if(target ~= 0) then
        doAddCondition(target, condition)
    end

    return doCombat(cid, combat, var)
end

IT WORKS! TY
 
Top