• 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 Add paralyze condition to weapon TFS 1.3

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
295
Solutions
1
Reaction score
37
Hello guys, I have a script here that I found a few years ago and I made some changes to do what I needed. I use the script to apply a formula of attack, area of attack, conditions and several other things about weapons, but one thing I'm not able to do it's to apply paralyze condition. Could somebody help me?

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SOUND_WHITE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HUNTINGSPEAR)

function onGetFormulaValues(xxx, yyy, zzz)

my own formular

    return -min, -max
    end   
end                               

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
            
 
local area = createCombatArea( { {0, 0, 0}, {0, 3, 0}, {0, 0, 0} } )
setCombatArea(combat, area)
 
function onUseWeapon(cid, var)
        return doCombat(cid, combat, var)
 

end

I would like for the paralyze condition work with this requests:

% of slow it applies. (if target has 300 speed and the weapon applies 10% slow, than the target will have 270 speed for the next 3 seconds)
% of chance to apply slow (if the weapon has 10% of applying slow, it means out of 10 attacks, one will apply the paralyze)
 
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
295
Solutions
1
Reaction score
37
To add conditions to the script I usually do this:

Lua:
function onUseWeapon(cid, var)
        cid:addDamageCondition(Creature(var:getNumber()), CONDITION_CURSED, DAMAGELIST_LOGARITHMIC_DAMAGE, 25, CONDITION_PARAM_TICKS, 100)
        return doCombat(cid, combat, var)
 
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
295
Solutions
1
Reaction score
37
Have you looked at the following example ?
Yes, I've tried before, but I just tried again and I got this results: (have in mind that I don't know much about script, so I do stuff by experiment)

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SOUND_WHITE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HUNTINGSPEAR)

function onGetFormulaValues(player, skill, attack)

    local playlvl = player:getLevel()

    if (playlvl<300) then
    local min = (own formula)
    local max = (own formula)
    return -min, -max
    
    else
    local min = (own formula)
    local max = (own formula)
    return -min, -max
    end   
end                               

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
            
 
local area = createCombatArea( { {0, 0, 0}, {0, 3, 0}, {0, 0, 0} } )
setCombatArea(combat, area)
 
function onUseWeapon(cid, var)

local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, 20000)
condition:setFormula(-1, 80, -1, 80)
Combat:addCondition(condition)

        return doCombat(cid, combat, var)
 

end

and I got no erros on TFS, the attack, damage and effect works perfectly in game, but it doesn't apply paralyze.

Tried this way:

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SOUND_WHITE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HUNTINGSPEAR)

function onGetFormulaValues(player, skill, attack)

    local playlvl = player:getLevel()

    if (playlvl<300) then
    local min = (own formula)
    local max = (own formula)
    return -min, -max
    
    else
    local min = (own formula)
    local max = (own formula)
    return -min, -max
    end   
end                               

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
            
 
local area = createCombatArea( { {0, 0, 0}, {0, 3, 0}, {0, 0, 0} } )
setCombatArea(combat, area)

local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, 20000)
condition:setFormula(-1, 80, -1, 80)
Combat:addCondition(condition)
 
function onUseWeapon(cid, var)
        return doCombat(cid, combat, var)
 

end

and also got no erros on TFS, the attack, damage and effect works perfectly in game, but it doesn't apply paralyze.

Then I try to edit the script I use for other conditions:

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SOUND_WHITE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HUNTINGSPEAR)

function onGetFormulaValues(player, skill, attack)

    local playlvl = player:getLevel()

    if (playlvl<300) then
    local min = (own formula)
    local max = (own formula)
    return -min, -max
    
    else
    local min = (own formula)
    local max = (own formula)
    return -min, -max
    end   
end                               

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
            
 
local area = createCombatArea( { {0, 0, 0}, {0, 3, 0}, {0, 0, 0} } )
setCombatArea(combat, area)

 
function onUseWeapon(cid, var)
        cid:addCondition(Creature(var:getNumber()), CONDITION_PARALYZE, condition:setFormula(-1, 80, -1, 80), CONDITION_PARAM_TICKS, 20000)
        return doCombat(cid, combat, var)
 

end

and I got error on TFS, no attack, no effect on game. The TFS error was:

Lua Script Error: [Weapon Interface]
data/weapons/scripts/heroicbow.lua:eek:nUseWeapon
data/weapons/scripts/heroicbow.lua:31: attempt to index global 'condition' (a nil value)
stack traceback:
[C]: in function '__index'
data/weapons/scripts/heroicbow.lua:31: in function <data/weapons/scripts/heroicbow.lua:30>

Then I try to add local condition = Condition(CONDITION_PARALYZE) at the function and it crashes the server.

So I've tried to solve this in many different ways and still can't find the solution
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,672
Solutions
406
Reaction score
3,786
This is my best guess, but I suck at spells.
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SOUND_WHITE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HUNTINGSPEAR)

function onGetFormulaValues(player, skill, attack)
    local playlvl = player:getLevel()
    if (playlvl<300) then
        local min = (own formula)
        local max = (own formula)
        return -min, -max
    else
        local min = (own formula)
        local max = (own formula)
        return -min, -max
    end   
end                               

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

local area = createCombatArea( { {0, 0, 0}, {0, 3, 0}, {0, 0, 0} } )
setCombatArea(combat, area)

local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, 20000)
condition:setFormula(-1, 80, -1, 80)
combat:addCondition(condition)

function onUseWeapon(player, variant)
    return combat:execute(player, variant)
end
 
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
295
Solutions
1
Reaction score
37
This is my best guess, but I suck at spells.
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SOUND_WHITE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HUNTINGSPEAR)

function onGetFormulaValues(player, skill, attack)
    local playlvl = player:getLevel()
    if (playlvl<300) then
        local min = (own formula)
        local max = (own formula)
        return -min, -max
    else
        local min = (own formula)
        local max = (own formula)
        return -min, -max
    end  
end                              

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

local area = createCombatArea( { {0, 0, 0}, {0, 3, 0}, {0, 0, 0} } )
setCombatArea(combat, area)

local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, 20000)
condition:setFormula(-1, 80, -1, 80)
combat:addCondition(condition)

function onUseWeapon(player, variant)
    return combat:execute(player, variant)
end
No errors appear, but it doesn't apply paralyze to target
 

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
8,041
Solutions
215
Reaction score
3,880
why not use viper star as example?

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_GREENSTAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)

function onUseWeapon(player, variant)
    if not combat:execute(player, variant) then
        return false
    end

    if math.random(1, 100) <= 90 then
        return false
    end

    player:addDamageCondition(Creature(variant:getNumber()), CONDITION_POISON, DAMAGELIST_LOGARITHMIC_DAMAGE, 2)
    return true
end
 
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
295
Solutions
1
Reaction score
37
why not use viper star as example?

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_GREENSTAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)

function onUseWeapon(player, variant)
    if not combat:execute(player, variant) then
        return false
    end

    if math.random(1, 100) <= 90 then
        return false
    end

    player:addDamageCondition(Creature(variant:getNumber()), CONDITION_POISON, DAMAGELIST_LOGARITHMIC_DAMAGE, 2)
    return true
end
I've tried to add like this, but paralyze is not a damage condition, it does not recognize. But i'm also not good with script, so I might just have done this wrong.
Post automatically merged:

Target > add condition
I tried to put this after the formula:

Lua:
local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, 20000)
condition:setFormula(-1, 80, -1, 80)
combat:addCondition(condition)

function onUseWeapon(player, variant, target)
target:addCondition(condition)
    return combat:execute (player, variant, target)
end

But when I tried to hit the target, no damage was dealt and appear this erro on TFS:
Lua Script Error: [Weapon Interface]
data/weapons/scripts/heroicbow.lua:eek:nUseWeapon
data/weapons/scripts/heroicbow.lua:34: attempt to index local 'target' (a nil value)
stack traceback:
[C]: in function '__index'
data/weapons/scripts/heroicbow.lua:34: in function <data/weapons/scripts/heroicbow.lua:33>
 
Top