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

Life Steal Spell Necromancer Class

ghunalma

New Member
Joined
Feb 5, 2016
Messages
19
Reaction score
2
Twitch
wordoffanic
Hi guys, is my first post on this forum in many years. I need a help with my necro skill life steal. i'm making one, it's causing dmg(dot) but dont return the healing. Anyone can help me?
In this case, it's causing dot dmg without calculate damage and a fix heal rate. I want to do this, causing damage with magic level and level base, and return healing with a percent of the damage.

Its my spell. i'm using TFS 1.3
client version 12.72



Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 18)

local condition = Condition(CONDITION_CURSED)
condition:addDamage(25, 1, -45)
combat:addCondition(condition)

local condition2 = Condition(CONDITION_REGENERATION)
condition2:setParameter(CONDITION_PARAM_TICKS, 1 * 60 * 1000)
condition2:setParameter(CONDITION_PARAM_HEALTHGAIN, 20)
condition2:setParameter(CONDITION_PARAM_HEALTHTICKS, 3 * 1000)
condition2:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
combat:addCondition(condition2)

local spell = Spell("instant")


function spell.onCastSpell(creature, var)
    return combat:execute(creature, var)
end

spell:group("attack")
spell:name("demon kiss")
spell:words("life leech")
spell:level(1)
spell:mana(0)
spell:isAggressive(true)
spell:range(3)
spell:needTarget(true)
spell:blockWalls(true)
spell:cooldown(500)
spell:groupCooldown(2 * 1000)
spell:needLearn(false)
spell:vocation("necromancer;true")
spell:register()
 
Solution
I might be wrong, but I believe when you apply it to the combat like you are doing combat:addCondition(condition) you have to set all the values during start-up.

But if you changed the code so that it applies directly to the target.. creature:addCondition(condition) then you'd be able to modify the conditions before applying it.

idk how cursed condition works.. but the main idea I'm showing should be correct lol

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 18)

local condition_cursed = Condition(CONDITION_CURSED)

local condition_regeneration = Condition(CONDITION_REGENERATION)
condition_regeneration:setParameter(CONDITION_PARAM_TICKS, 1...
I might be wrong, but I believe when you apply it to the combat like you are doing combat:addCondition(condition) you have to set all the values during start-up.

But if you changed the code so that it applies directly to the target.. creature:addCondition(condition) then you'd be able to modify the conditions before applying it.

idk how cursed condition works.. but the main idea I'm showing should be correct lol

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 18)

local condition_cursed = Condition(CONDITION_CURSED)

local condition_regeneration = Condition(CONDITION_REGENERATION)
condition_regeneration:setParameter(CONDITION_PARAM_TICKS, 1 * 60 * 1000)
condition_regeneration:setParameter(CONDITION_PARAM_HEALTHTICKS, 3 * 1000)
condition_regeneration:setParameter(CONDITION_PARAM_BUFF_SPELL, true)

local spell = Spell("instant")

function spell.onCastSpell(creature, var)
    local target = creature:getTarget()
    if not target then
        -- no target
        return false
    end
   
    local targetPos = target:getPosition()
    local casterPos = creature:getPosition()
    if casterPos:getDistance(targetPos) > 3 then
        -- target is too far away
        return false
    end
   
    if not casterPos:isSightClear(targetPos, true) then
        -- line of sight is blocked
        return false
    end
   
    -- now you can do all your math stuff.
   
    local base_damage = 45
    local magiclevel = creature:getMagicLevel()
    local experiencelevel = creature:getLevel()
   
    local dot_damage = base_damage + (magiclevel * 2) + (experiencelevel * 1.5) -- damage we deal
   
    local healing_percentage = 30
    local dot_healing = dot_damage * (healing_percentage / 100) -- damage we heal
   
    condition_cursed:addDamage(25, 1, -45) -- I have no idea what each of these numbers mean lol
    condition_regeneration:setParameter(CONDITION_PARAM_HEALTHGAIN, dot_healing) -- but hey this one I understand! xD
   
    target:addCondition(condition_cursed)
    creature:addCondition(condition_regeneration)   
    return combat:execute(creature, var)
end

spell:group("attack")
spell:name("demon kiss")
spell:words("life leech")
spell:level(1)
spell:mana(0)
spell:isAggressive(true)
spell:range(3)
spell:needTarget(true)
spell:blockWalls(true)
spell:cooldown(500)
spell:groupCooldown(2 * 1000)
spell:needLearn(false)
spell:vocation("necromancer;true")
spell:register()
 
Solution
I might be wrong, but I believe when you apply it to the combat like you are doing combat:addCondition(condition) you have to set all the values during start-up.

But if you changed the code so that it applies directly to the target.. creature:addCondition(condition) then you'd be able to modify the conditions before applying it.

idk how cursed condition works.. but the main idea I'm showing should be correct lol

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 18)

local condition_cursed = Condition(CONDITION_CURSED)

local condition_regeneration = Condition(CONDITION_REGENERATION)
condition_regeneration:setParameter(CONDITION_PARAM_TICKS, 1 * 60 * 1000)
condition_regeneration:setParameter(CONDITION_PARAM_HEALTHTICKS, 3 * 1000)
condition_regeneration:setParameter(CONDITION_PARAM_BUFF_SPELL, true)

local spell = Spell("instant")

function spell.onCastSpell(creature, var)
    local target = creature:getTarget()
    if not target then
        -- no target
        return false
    end
  
    local targetPos = target:getPosition()
    local casterPos = creature:getPosition()
    if casterPos:getDistance(targetPos) > 3 then
        -- target is too far away
        return false
    end
  
    if not casterPos:isSightClear(targetPos, true) then
        -- line of sight is blocked
        return false
    end
  
    -- now you can do all your math stuff.
  
    local base_damage = 45
    local magiclevel = creature:getMagicLevel()
    local experiencelevel = creature:getLevel()
  
    local dot_damage = base_damage + (magiclevel * 2) + (experiencelevel * 1.5) -- damage we deal
  
    local healing_percentage = 30
    local dot_healing = dot_damage * (healing_percentage / 100) -- damage we heal
  
    condition_cursed:addDamage(25, 1, -45) -- I have no idea what each of these numbers mean lol
    condition_regeneration:setParameter(CONDITION_PARAM_HEALTHGAIN, dot_healing) -- but hey this one I understand! xD
  
    target:addCondition(condition_cursed)
    creature:addCondition(condition_regeneration)  
    return combat:execute(creature, var)
end

spell:group("attack")
spell:name("demon kiss")
spell:words("life leech")
spell:level(1)
spell:mana(0)
spell:isAggressive(true)
spell:range(3)
spell:needTarget(true)
spell:blockWalls(true)
spell:cooldown(500)
spell:groupCooldown(2 * 1000)
spell:needLearn(false)
spell:vocation("necromancer;true")
spell:register()
hi bro. ty so much!!! where i put an area arr { 0 0 0 0}, when i want to do other spell?

i've change this line
Lua:
condition_cursed:addDamage(25, 1, -dot_damage)
now the damage're calculating. when -45 on this line the damage are fixed on 45.
 
hi bro. ty so much!!! where i put an area arr { 0 0 0 0}, when i want to do other spell?

i've change this line
Lua:
condition_cursed:addDamage(25, 1, -dot_damage)
now the damage're calculating. when -45 on this line the damage are fixed on 45.
You'd want to use onTargetTile, then loop through all the creatures on that tile, I guess.
And I think the healing would only work on a single instance (the most recent damage).. unless you start working with subId's.

This get's a bit muddy though.. as you can't really tell when someone's dot runs out, to stop the healing.

So the spell works but could be better.

Lua:
function onTargetTile(creature, position)
    local creatures = tile:getCreatures()
    if creatures and creatures > 0 then
        for i = 1, #creatures do
            local target = creatures[i]
            -- do all the math stuff, and apply damage/healing
        end
    end
end

combat:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile")
 
Back
Top