• 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 1.0] Bleeding damage.

spyk3z

Theós:Undying
Joined
Jul 23, 2007
Messages
385
Reaction score
90
Location
Home.
Is it possible to make bleeding skill based? I tried using this code
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLACKSMOKE)

local area = createCombatArea(AREA_CIRCLE3X3)
combat:setArea(area)

function onGetFormulaValues(cid, level, maglevel)
    min = -((level / 5) + (maglevel * 6) + 50)
    max = -((level / 5) + (maglevel * 12) + 75)
    return min, max
end

local condition = Condition(CONDITION_BLEEDING)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLOODYSTEPS)
condition:addDamage(math.random(5,11), 500, math.random(min,max))
combat:setCondition(condition)


combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end
But it's static.
 
Is it possible to make bleeding skill based? I tried using this code
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLACKSMOKE)

local area = createCombatArea(AREA_CIRCLE3X3)
combat:setArea(area)

function onGetFormulaValues(cid, level, maglevel)
    min = -((level / 5) + (maglevel * 6) + 50)
    max = -((level / 5) + (maglevel * 12) + 75)
    return min, max
end

local condition = Condition(CONDITION_BLEEDING)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLOODYSTEPS)
condition:addDamage(math.random(5,11), 500, math.random(min,max))
combat:setCondition(condition)


combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end
But it's static.
I think maybe the problem is that min and max are only defined within the function "onGetFormulaValues", so if you want the the same min and max, maybe you could try it this way and let me know if it works for you..

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLACKSMOKE)

local area = createCombatArea(AREA_CIRCLE3X3)
combat:setArea(area)

local condition = Condition(CONDITION_BLEEDING)
condition:setTicks(9000)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 3000)

function onGetFormulaValues(cid, level, maglevel)
    min = -((level / 5) + (maglevel * 6) + 50)
    max = -((level / 5) + (maglevel * 12) + 75)
    return min, max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function CastSpell(cid, var)
    local player = Player(cid)
    local level = player:getLevel()
    local maglevel = player:getMagicLevel()
    min = -((level / 5) + (maglevel * 6) + 50)
    max = -((level / 5) + (maglevel * 12) + 75)
    condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, math.random(min,max))
    combat:setCondition(condition)
    end
   
function onCastSpell(creature, var)
    CastSpell(creature:getId(), var)
    return combat:execute(creature, var)
end
 
Last edited:
I have no idea if you can even use the effect you were trying to use for the condition, anyways you also forgot to set ticks and tick interval, which I set in the above spell... Anyways all that you should be able to handle from here, just let me know if it is working correctly for you....

Also I changed it to periodicdamage simply because I have had problems with add damage, seems that it literally does that, and the damage keeps going up for bleeding, obviously that's not what you wanted so I changed it...
 
It's possible. You have to do a table with combat.

Example for 0.3+
Code:
local combat = {}
local condition = {}
for i = 0, 150 do
    combat[i] = createCombatObject()
    condition[i] = createConditionObject(CONDITION_CURSED)
    setConditionParam(condition[i], CONDITION_PARAM_DELAYED, 1)
    setConditionParam(condition[i], CONDITION_PARAM_FORCEUPDATE, TRUE)
    addDamageCondition(condition[i], 6, 1000, -(i * 0.5))  -- damage formula, 'i' is equal to 4th skill
    setCombatCondition(combat[i], condition[i])
end

function onCastSpell(cid, var)
    local level = getPlayerSkillLevel(cid, 4)
    doCombat(cid, combat[level], var)
    return true
end

If you have skill 10, this DoT will do 5 every second. If your skill is 120, then DoT will do 60 dmg per sec etc. Skill will not work if used by character with skill over 150.
 
It's possible. You have to do a table with combat.

Example for 0.3+
Code:
local combat = {}
local condition = {}
for i = 0, 150 do
    combat[i] = createCombatObject()
    condition[i] = createConditionObject(CONDITION_CURSED)
    setConditionParam(condition[i], CONDITION_PARAM_DELAYED, 1)
    setConditionParam(condition[i], CONDITION_PARAM_FORCEUPDATE, TRUE)
    addDamageCondition(condition[i], 6, 1000, -(i * 0.5))  -- damage formula, 'i' is equal to 4th skill
    setCombatCondition(combat[i], condition[i])
end

function onCastSpell(cid, var)
    local level = getPlayerSkillLevel(cid, 4)
    doCombat(cid, combat[level], var)
    return true
end

If you have skill 10, this DoT will do 5 every second. If your skill is 120, then DoT will do 60 dmg per sec etc. Skill will not work if used by character with skill over 150.
@andu
do a bigger loop or
Code:
math.min(getPlayerLevel(cid), 150)

What's wrong with the code I posted guys? I mean, yeah yours is fancier with the tables and loops, however mine does exactly what he did ask for... He wanted it to be based off the same formula he already wrote for the combat, which is based off of level and magic level not just one skill.... Anyways I went ahead and tested it, no errors are showing up in my console, and the monsters DO receive bleeding condition that is based off of my level and magic level....
 
What's wrong with the code I posted guys? I mean, yeah yours is fancier with the tables and loops, however mine does exactly what he did ask for... He wanted it to be based off the same formula he already wrote for the combat, which is based off of level and magic level not just one skill.... Anyways I went ahead and tested it, no errors are showing up in my console, and the monsters DO receive bleeding condition that is based off of my level and magic level....
Works perfectly, A lot cleaner then what I ended up doing.

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLACKSMOKE)

local area = createCombatArea(AREA_CIRCLE3X3)
combat:setArea(area)

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
combat2:setParameter(COMBAT_PARAM_EFFECT, 158)

local area2 = createCombatArea(AREA_CIRCLE3X3)
combat2:setArea(area2)


combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onGetFormulaValues(cid, skill, attack, factor)
    local skillTotal, levelTotal = skill * attack, Player(cid):getLevel() / 5
    return -(((skillTotal * 0.32) + 4) + (levelTotal)), -(((skillTotal * 0.83) + 6) + (levelTotal))
end
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onGetFormulaValues(cid, skill, attack, factor)
    local skillTotal, levelTotal = skill * attack, Player(cid):getLevel() / 5
    return -(((skillTotal * 0.22) + 4) + (levelTotal)), -(((skillTotal * 0.93) + 6) + (levelTotal))
end

local function bleeds(creature,var)

return combat2:execute(creature, var)
end
local function start2(creature,var)
return combat:execute(creature, var)
end

function onCastSpell(creature, var)
    addEvent(start2, 100, creature, var)
    addEvent(bleeds, 1000, creature, var)
    addEvent(bleeds, 1500, creature, var)
    addEvent(bleeds, 2000, creature, var)
    addEvent(bleeds, 2500, creature, var)
    addEvent(bleeds, 3000, creature, var)
        addEvent(bleeds, 3500, creature, var)
    addEvent(bleeds, 4000, creature, var)
    addEvent(bleeds, 4500, creature, var)
    addEvent(bleeds, 5000, creature, var)
    addEvent(bleeds, 5500, creature, var)
    return true
end
 
@andu
do a bigger loop or
Code:
math.min(getPlayerLevel(cid), 150)
Combat values are out of function. Isn't possible to use getPlayerLevel there.

What's wrong with the code I posted guys? I mean, yeah yours is fancier with the tables and loops, however mine does exactly what he did ask for... He wanted it to be based off the same formula he already wrote for the combat, which is based off of level and magic level not just one skill.... Anyways I went ahead and tested it, no errors are showing up in my console, and the monsters DO receive bleeding condition that is based off of my level and magic level....
In TFS 0.3+ and 0.4+ onGetFormulaValues ins't working with conditions. Didn't know that works in 1.0.
 
Combat values are out of function. Isn't possible to use getPlayerLevel there.


In TFS 0.3+ and 0.4+ onGetFormulaValues ins't working with conditions. Didn't know that works in 1.0.

Because of the metamethods used, and how it sets the parameters. Using this new method the parameters for the condition can be placed almost anywhere in the script instead of only loaded at the beginning... Same with the combat.

You can still do it the old way like your code:

combat = createCombatObject()
condition = createConditionObject(CONDITION_CURSED)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
setConditionParam(condition, CONDITION_PARAM_FORCEUPDATE, TRUE)

However using setConditionParam and setCombatParam will then again be restricted to only being placed within the right part of the script...

There are many of great advantages to 1.0, soon everyone will see....
 
Works perfectly, A lot cleaner then what I ended up doing.

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLACKSMOKE)

local area = createCombatArea(AREA_CIRCLE3X3)
combat:setArea(area)

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
combat2:setParameter(COMBAT_PARAM_EFFECT, 158)

local area2 = createCombatArea(AREA_CIRCLE3X3)
combat2:setArea(area2)


combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onGetFormulaValues(cid, skill, attack, factor)
    local skillTotal, levelTotal = skill * attack, Player(cid):getLevel() / 5
    return -(((skillTotal * 0.32) + 4) + (levelTotal)), -(((skillTotal * 0.83) + 6) + (levelTotal))
end
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onGetFormulaValues(cid, skill, attack, factor)
    local skillTotal, levelTotal = skill * attack, Player(cid):getLevel() / 5
    return -(((skillTotal * 0.22) + 4) + (levelTotal)), -(((skillTotal * 0.93) + 6) + (levelTotal))
end

local function bleeds(creature,var)

return combat2:execute(creature, var)
end
local function start2(creature,var)
return combat:execute(creature, var)
end

function onCastSpell(creature, var)
    addEvent(start2, 100, creature, var)
    addEvent(bleeds, 1000, creature, var)
    addEvent(bleeds, 1500, creature, var)
    addEvent(bleeds, 2000, creature, var)
    addEvent(bleeds, 2500, creature, var)
    addEvent(bleeds, 3000, creature, var)
        addEvent(bleeds, 3500, creature, var)
    addEvent(bleeds, 4000, creature, var)
    addEvent(bleeds, 4500, creature, var)
    addEvent(bleeds, 5000, creature, var)
    addEvent(bleeds, 5500, creature, var)
    return true
end
So you liked my code? Glad I could help :D

Anyways if you are using mine that is better simply because of what I recently learned about user data being passed instead of cid. If you aren't working from the very latest source then it can crash the server, may still be able to crash the server, idk I think they fixed it for spells, also there is the unsafe scripts configuration options. Anyways here is correct way to pass parameters

function blahblah(cid, combat, var)

function onCastSpell(creature, combat, var)
return function blahblah(creature:getId(), combat, var) --- Note you are using the creatures id instead of just straight up passing the userdata like so (creature, combat, var)
 
So you liked my code? Glad I could help :D

Anyways if you are using mine that is better simply because of what I recently learned about user data being passed instead of cid. If you aren't working from the very latest source then it can crash the server, may still be able to crash the server, idk I think they fixed it for spells, also there is the unsafe scripts configuration options. Anyways here is correct way to pass parameters

function blahblah(cid, combat, var)

function onCastSpell(creature, combat, var)
return function blahblah(creature:getId(), combat, var) --- Note you are using the creatures id instead of just straight up passing the userdata like so (creature, combat, var)
Thanks man, Awesome.
 
Back
Top