TFS 0.X spell that use health to cure mana

zabuzo

Well-Known Member
Joined
Jun 10, 2016
Messages
237
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?
 

Ascuas Funkeln

Rakkedo Game
Joined
Apr 14, 2013
Messages
513
Solutions
30
Reaction score
265
Location
Poland
GitHub
AscuasFunkeln
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:

M0ustafa

1337
Senator
Joined
Mar 4, 2017
Messages
2,508
Solutions
310
Reaction score
1,082
Location
Egypt
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))
 
OP
zabuzo

zabuzo

Well-Known Member
Joined
Jun 10, 2016
Messages
237
Reaction score
54
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
 
OP
zabuzo

zabuzo

Well-Known Member
Joined
Jun 10, 2016
Messages
237
Reaction score
54
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?
 

pink_panther

Premium User
Premium User
Joined
Sep 10, 2016
Messages
637
Solutions
8
Reaction score
276
Location
Kazordoon
if you're going to not use the combat, just do

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

5lave Ots

Active Member
Joined
Oct 2, 2017
Messages
243
Solutions
1
Reaction score
38
Location
Ankrahmun
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"
 
OP
zabuzo

zabuzo

Well-Known Member
Joined
Jun 10, 2016
Messages
237
Reaction score
54
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
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
921
Solutions
90
Reaction score
906
Location
London
GitHub
MillhioreBT
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
 
OP
zabuzo

zabuzo

Well-Known Member
Joined
Jun 10, 2016
Messages
237
Reaction score
54
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...
 
Top