• 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 spell that use health to cure mana

zabuzo

Well-Known Member
Joined
Jun 10, 2016
Messages
238
Reaction score
54
I want to create a spell that uses health to regen some mana

I tried it:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
function onGetFormulaValues(cid, level, maglevel)
    min = 200
    max = 300
    return min, max
end

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end


But didn't work as i want...
I want to cure 200-300 mana
But removes 150-300 health...

What i'm doing wrong?
 
I want to create a spell that uses health to regen some mana

I tried it:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
function onGetFormulaValues(cid, level, maglevel)
    min = 200
    max = 300
    return min, max
end

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end


But didn't work as i want...
I want to cure 200-300 mana
But removes 150-300 health...

What i'm doing wrong?
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
    doCreatureAddHealth(cid, math.random(-150,-300))
    doCreatureAddMana(cid, math.random(200,300))
end
 
Last edited:
I think this one won't work and he'll have to change it
Lua:
doCreatureAddHealth(cid, math.random(-150,-300))
to
Lua:
doCreatureAddHealth(cid, -math.random(150,300))
 
0.4-3777: https://github.com/Fir3element/3777/blob/master/src/luascript.cpp#L3943

i've tried:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
    doCreatureAddHealth(cid, -math.random(200,201))
    doCreatureAddMana(cid, math.random(200,201))
end

but it not removes 200-201
it is removing 60-120


no matter what i do
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onCastSpell(cid, var)
    doCreatureAddHealth(cid, -math.ceil(math.random(200, 250)*2))
    doCreatureAddMana(cid, math.random(math.random(200, 250)*2))
    return doCombat(cid, combat, var)
end

it stills removing the same numbers
 
What if you just do

doCreatureAddHealth(cid, -200)

test:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onCastSpell(cid, var)
    doCreatureAddHealth(cid, -200)
    doCreatureAddMana(cid, 200)
    return doCombat(cid, combat, var)
end

do the same thing :(
its ignoring the fucking 200;...

why?
 
if you're going to not use the combat, just do

function onCastSpell(cid, var)
doCreatureAddMana(cid, 200)
doCreatureAddHealth(cid, -200)
return true
end
 
as pink panther said use
function onCastSpell(cid, var)
doCreatureAddMana(cid, 200)
doCreatureAddHealth(cid, -200)
return true
end

and on spells.xml make the mana consumption for the spell = o
mana="530"
 
swap the +/- lol
not work too, already tested this...


as pink panther said use
function onCastSpell(cid, var)
doCreatureAddMana(cid, 200)
doCreatureAddHealth(cid, -200)
return true
end

and on spells.xml make the mana consumption for the spell = o
mana="530"

what are u mean?
this spell is to use health to regen mana
 
Example:

spells.xml
XML:
<instant name="Light Mana" words="exura mana" lvl="9" mana="0" aggressive="0" selftarget="1" exhaustion="2000" groups="2,2000" icon="1" needlearn="0" event="script" value="healing/light mana.lua">
        <vocation id="1;5"/>
        <vocation id="2;6"/>
        <vocation id="3;7"/>
    </instant>

data/spells/scripts/healing/light mana.lua
Lua:
local config = {
    needHealth = 200,
    addMana = {100, 200}
}

function onCastSpell(cid, var)
    if getCreatureHealth(cid) < config.needHealth then
        doPlayerSendCancel(cid, "No have health!")
        return false
    end

    doCreatureAddHealth(cid, -config.needHealth)
    doPlayerAddMana(cid, math.random(config.addMana[1], config.addMana[2]))
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    return true
end
 
i mean that it consume mana bec that line on spells.xml
you can disable it " mana = 0 " so it dosnt take any mana

Set mana to 0 and still same thing:
Code:
    <instant name="Mana Healing" words="exura mana" maglvl="1" selftarget="1" prem="0" exhaustion="5000" needlearn="0" soul="0" mana="0" script="support/exura mana.lua">
    </instant>


Example:

spells.xml
XML:
<instant name="Light Mana" words="exura mana" lvl="9" mana="0" aggressive="0" selftarget="1" exhaustion="2000" groups="2,2000" icon="1" needlearn="0" event="script" value="healing/light mana.lua">
        <vocation id="1;5"/>
        <vocation id="2;6"/>
        <vocation id="3;7"/>
    </instant>

data/spells/scripts/healing/light mana.lua
Lua:
local config = {
    needHealth = 200,
    addMana = {100, 200}
}

function onCastSpell(cid, var)
    if getCreatureHealth(cid) < config.needHealth then
        doPlayerSendCancel(cid, "No have health!")
        return false
    end

    doCreatureAddHealth(cid, -config.needHealth)
    doPlayerAddMana(cid, math.random(config.addMana[1], config.addMana[2]))
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    return true
end

also same thing, same values...
 
Example:

spells.xml
XML:
<instant name="Light Mana" words="exura mana" lvl="9" mana="0" aggressive="0" selftarget="1" exhaustion="2000" groups="2,2000" icon="1" needlearn="0" event="script" value="healing/light mana.lua">
        <vocation id="1;5"/>
        <vocation id="2;6"/>
        <vocation id="3;7"/>
    </instant>

data/spells/scripts/healing/light mana.lua
Lua:
local config = {
    needHealth = 200,
    addMana = {100, 200}
}

function onCastSpell(cid, var)
    if getCreatureHealth(cid) < config.needHealth then
        doPlayerSendCancel(cid, "No have health!")
        return false
    end

    doCreatureAddHealth(cid, -config.needHealth)
    doPlayerAddMana(cid, math.random(config.addMana[1], config.addMana[2]))
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    return true
end
there's a way to do it with percent value? remove up to 30% of life and add up to 30% of mana
 
there's a way to do it with percent value? remove up to 30% of life and add up to 30% of mana
I haven't tested it, but try this:
Lua:
local config = {
    removeHealth = 30, --%
    addMana = 30 --%
}
function onCastSpell(cid, var)
    local currentMaxHp = getCreatureMaxHealth(cid)
    local currentHppc = getCreatureHealth(cid) * 100 / currentMaxHp
    if currentHppc < config.removeHealth then
        doPlayerSendCancel(cid, "No have health!")
        return false
    end
    doCreatureAddHealth(cid, -(currentMaxHp * (config.removeHealth / 100)))
    doPlayerAddMana(cid, (getPlayerMaxMana(cid) * (config.addMana / 100)))
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    return true
end
 
I haven't tested it, but try this:
Lua:
local config = {
    removeHealth = 30, --%
    addMana = 30 --%
}
function onCastSpell(cid, var)
    local currentMaxHp = getCreatureMaxHealth(cid)
    local currentHppc = getCreatureHealth(cid) * 100 / currentMaxHp
    if currentHppc < config.removeHealth then
        doPlayerSendCancel(cid, "No have health!")
        return false
    end
    doCreatureAddHealth(cid, -(currentMaxHp * (config.removeHealth / 100)))
    doPlayerAddMana(cid, (getPlayerMaxMana(cid) * (config.addMana / 100)))
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    return true
end

sorry this long...
this message "No have health!" should appears when u don't have 50% of hp, right?
there is something wrong...

i've test your script with a mage lvl 59, so...
max mana 1565
max hp 440

then i run your script 5 times, until msg "you do not have Health enough."

hp/mana
440/5
376/50
263/100
166/134
56/185
you do not have Health enough.


i couldn't find a pattern

any idea what is going on?
 
Change the function:
Lua:
doCreatureAddHealth(cid, -(currentMaxHp * (config.removeHealth / 100)))
For:
Lua:
doCreatureAddHealth(cid, -(currentMaxHp * (config.removeHealth / 100)), 255, 0, true)
 
Back
Top