• 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.X+ Spells caster for porcent of life. (Boss)

Fabi Marzan

Well-Known Member
Joined
Aug 31, 2020
Messages
135
Solutions
6
Reaction score
67
TFS 1.5

Greetings, I was looking for how to make a Spell that if I have 100% life I can cast the storage 2000 for example. When I have 50% health, I give another storage. When I go back up to 100%, I give the 2000 storage and the 50% storage is removed.

My idea is that when a boss has health at 100% health, he starts casting the spell "exevo gran mas mort" for example, and when he has health at 50% use "exevo gran mas ice".


What I came up with was to use it for storage and do the spell separately. Doing the spells and placing this code
Lua:
if getCreatureStorage(cid, 2000) == 1 then ---EXEVO GRAN MAS MORT
That code means that if the player has storage 2000 he can execute the spells.
 
Solution
My bad yeah, getMaxHealth() for 10% I would change it to: * .10

Lua:
(creature:getMaxHealth() * .10) -- 10%
(creature:getMaxHealth() * .20) -- 20%
(creature:getMaxHealth() * .50) -- 50%
Post automatically merged:

the "onCastSpell" function can be as simple as this...
Lua:
function onCastSpell(creature, variant)
  if creature:getHealth() <= math.floor(creature:getHealth() / 2) then
    return combat2:execute(creature, variant)
  else
    return combat:execute(creature, variant)
  end
end
As I understood it he wanted the second spell to be casted until the creature is back at 100%. So it should hold which spell it is casting. If its just under 50 then 1 spell over 50 then another then yeah that would be fine.

Code:
My idea is that when...
You would just make a custom spell for it....
Lua:
-- FIRST SPELL TO CAST --
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.06) + 13
    local max = (player:getLevel() / 5) + (skill * attack * 0.14) + 34
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

-- SECOND SPELL TO CAST --
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
combat2:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValuesTwo(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2.85) + 16
    return -min, -max
end

combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValuesTwo")

local currentSpell = 1

function onCastSpell(creature, variant)
    if creature:getHealth() <= math.floor(creature:getHealth() / 2) and currentSpell == 1 then
        currentSpell = 2
        return combat2:execute(creature, variant)
    elseif creature:getHealth() == creature:getMaxHealth() and currentSpell == 2 then
        currentSpell = 1
        return combat:execute(creature, variant)
    end
  
    if currentSpell == 1 then
        return combat:execute(creature, variant)
    end
  

    return combat2:execute(creature, variant)
end
 
Last edited:
You would just make a custom spell for it....
Lua:
-- FIRST SPELL TO CAST --
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.06) + 13
    local max = (player:getLevel() / 5) + (skill * attack * 0.14) + 34
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

-- SECOND SPELL TO CAST --
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
combat2:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValuesTwo(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2.85) + 16
    return -min, -max
end

combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValuesTwo")

local currentSpell = 1

function onCastSpell(creature, variant)
    if creature:getHealth() <= math.floor(creature:getHealth() / 2) and currentSpell == 1 then
        currentSpell = 2
        return combat2:execute(creature, variant)
    elseif creature:getHealth() == creature:getMaxHealth() and currentSpell == 2 then
        currentSpell = 1
        return combat:execute(creature, variant)
    end
 
    if currentSpell == 1 then
        return combat:execute(creature, variant)
    end
 

    return combat2:execute(creature, variant)
end
the "onCastSpell" function can be as simple as this...
Lua:
function onCastSpell(creature, variant)
  if creature:getHealth() <= math.floor(creature:getHealth() / 2) then
    return combat2:execute(creature, variant)
  else
    return combat:execute(creature, variant)
  end
end
 
@Itutorial @Paulix
I was testing it and the life thing doesn't work for me, the first spell casts me but combat2 doesn't come out, even though my life is in red.

What exactly does the number 2 mean? in this function.
Lua:
(creature:getHealth() / 2)
Because I was editing it and combat 2 still doesn't cast me, even though I'm at 1% health.
 
@Itutorial @Paulix
I was testing it and the life thing doesn't work for me, the first spell casts me but combat2 doesn't come out, even though my life is in red.

What exactly does the number 2 mean? in this function.
Lua:
(creature:getHealth() / 2)
Because I was editing it and combat 2 still doesn't cast me, even though I'm at 1% health.
the idea is to get half hp by diving it by 2, but it was getting the actual health, not max
try this one

Lua:
-- FIRST SPELL TO CAST --
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.06) + 13
    local max = (player:getLevel() / 5) + (skill * attack * 0.14) + 34
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

-- SECOND SPELL TO CAST --
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
combat2:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValuesTwo(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2.85) + 16
    return -min, -max
end

combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValuesTwo")

function onCastSpell(creature, variant)
  if creature:getHealth() <= math.floor(creature:getMaxHealth() / 2) then
    return combat2:execute(creature, variant)
  end

  return combat:execute(creature, variant)
end
 
@Paulix
Thank you very much now if it worked for me, but another question
If the function:
Lua:
(creature:getMaxHealth() / 2)
the number 2 means 50%, what number should I place for 10%?
 
My bad yeah, getMaxHealth() for 10% I would change it to: * .10

Lua:
(creature:getMaxHealth() * .10) -- 10%
(creature:getMaxHealth() * .20) -- 20%
(creature:getMaxHealth() * .50) -- 50%
Post automatically merged:

the "onCastSpell" function can be as simple as this...
Lua:
function onCastSpell(creature, variant)
  if creature:getHealth() <= math.floor(creature:getHealth() / 2) then
    return combat2:execute(creature, variant)
  else
    return combat:execute(creature, variant)
  end
end
As I understood it he wanted the second spell to be casted until the creature is back at 100%. So it should hold which spell it is casting. If its just under 50 then 1 spell over 50 then another then yeah that would be fine.

Code:
My idea is that when a boss has health at 100% health, he starts casting the spell "exevo gran mas mort" for example, and when he has health at 50% use "exevo gran mas ice".
 
Solution
Back
Top