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

Give extra health to a character

tnecniiv

scripter to be
Joined
Jan 6, 2012
Messages
294
Solutions
3
Reaction score
23
Hello guys i am working on a 9.60 server using tfs 0.2.14. i was wondering if it is possible to have a druid use a spell to give 10% hp of the characters health and or mana. if it isnt possible in my server ill understand. thank you for your time.
 
Rune option:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onCastSpell(cid, var)
   local config = {
       percent_hp = 10,
       percent_mp = 10
   }
   local pos = variantToPosition(var)
   pos.stackpos = 255
   local creature = getThingFromPos(pos)
   if isPlayer(creature.uid) then
       doCreatureAddHealth(creature.uid, getCreatureMaxHealth(creature.uid) * config.percent_hp / 100)
       doCreatureAddMana(creature.uid, getCreatureMaxMana(creature.uid) * config.percent_mp / 100)
   else
       doPlayerSendCancel(cid, "You can heal only players.")
       return true
   end
end
 
Rune option:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onCastSpell(cid, var)
   local config = {
       percent_hp = 10,
       percent_mp = 10
   }
   local pos = variantToPosition(var)
   pos.stackpos = 255
   local creature = getThingFromPos(pos)
   if isPlayer(creature.uid) then
       doCreatureAddHealth(creature.uid, getCreatureMaxHealth(creature.uid) * config.percent_hp / 100)
       doCreatureAddMana(creature.uid, getCreatureMaxMana(creature.uid) * config.percent_mp / 100)
   else
       doPlayerSendCancel(cid, "You can heal only players.")
       return true
   end
end

Why did you put the table inside the function?
If you do it will re-load it every time the function is called and there is no reason for it since the variables are static.
 
unfortunately it doesn't work with the rune i put the code in a rune and tried using it on myself for testing purposes says there is a problem in line 14
20/07/2017 12:31:34] Lua Script Error: [Spell Interface]
[20/07/2017 12:31:34] data/spells/scripts/healing/percent.lua:eek:nCastSpell
[20/07/2017 12:31:34] data/spells/scripts/healing/percent.lua:14: attempt to call global 'getThingFromPos' (a nil value)
[20/07/2017 12:31:34] stack traceback:
[20/07/2017 12:31:34] [C]: in function 'getThingFromPos'
[20/07/2017 12:31:34] data/spells/scripts/healing/percent.lua:14: in function <data/spells/scripts/healing/percent.lua:7>

i love the idea of bringing runes back into the game i miss tibia when it was rune based

i would also like to apologize for the late response i got busy in my real life.
@GarQet
 
unfortunately it doesn't work with the rune i put the code in a rune and tried using it on myself for testing purposes says there is a problem in line 14
20/07/2017 12:31:34] Lua Script Error: [Spell Interface]
[20/07/2017 12:31:34] data/spells/scripts/healing/percent.lua:eek:nCastSpell
[20/07/2017 12:31:34] data/spells/scripts/healing/percent.lua:14: attempt to call global 'getThingFromPos' (a nil value)
[20/07/2017 12:31:34] stack traceback:
[20/07/2017 12:31:34] [C]: in function 'getThingFromPos'
[20/07/2017 12:31:34] data/spells/scripts/healing/percent.lua:14: in function <data/spells/scripts/healing/percent.lua:7>

i love the idea of bringing runes back into the game i miss tibia when it was rune based

i would also like to apologize for the late response i got busy in my real life.
@GarQet

Can you check your source code (luascript.cpp) and check if you can find this word "getThingFromPos"
 
getThingfromPos(pos)
i have this in my lua functions

update _ i figured out how to set up the healing but now i cant get the player to get % based mana or even add mana i get this error
17 19:11:31] Lua Script Error: [Spell Interface]
[21/07/2017 19:11:31] data/spells/scripts/healing/percent.lua:eek:nCastSpell
[21/07/2017 19:11:31] data/spells/scripts/healing/percent.lua:17: attempt to call global 'doplayerAddMana' (a nil value)
[21/07/2017 19:11:31] stack traceback:
[21/07/2017 19:11:31] [C]: in function 'doplayerAddMana'
[21/07/2017 19:11:31] data/spells/scripts/healing/percent.lua:17: in function <data/spells/scripts/healing/percent.lua:7>
and my script looks like this


Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
function onCastSpell(cid, var)
   local config = {
       percent_hp = 50,
       percent_mp = 25
   }
   local pos = variantToPosition(var)
   pos.stackpos = 255
   local creature = getThingfromPos(pos)
   if isPlayer(creature.uid) then
       doCreatureAddHealth(creature.uid, getCreatureMaxHealth(creature.uid) * config.percent_hp / 100)
       doplayerAddMana(creature.uid, getPlayerMana(cid) * config.percent_mp / 100)
   else
       doPlayerSendCancel(cid, "You can heal only players.")
       return true
   end
end
thank you guys for you time.
 
Last edited by a moderator:
update _ i figured out how to set up the healing but now i cant get the player to get % based mana or even add mana i get this error
17 19:11:31] Lua Script Error: [Spell Interface]
[21/07/2017 19:11:31] data/spells/scripts/healing/percent.lua:eek:nCastSpell
[21/07/2017 19:11:31] data/spells/scripts/healing/percent.lua:17: attempt to call global 'doplayerAddMana' (a nil value)
[21/07/2017 19:11:31] stack traceback:
[21/07/2017 19:11:31] [C]: in function 'doplayerAddMana'
[21/07/2017 19:11:31] data/spells/scripts/healing/percent.lua:17: in function <data/spells/scripts/healing/percent.lua:7>
and my script looks like this


Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
function onCastSpell(cid, var)
   local config = {
       percent_hp = 50,
       percent_mp = 25
   }
   local pos = variantToPosition(var)
   pos.stackpos = 255
   local creature = getThingfromPos(pos)
   if isPlayer(creature.uid) then
       doCreatureAddHealth(creature.uid, getCreatureMaxHealth(creature.uid) * config.percent_hp / 100)
       doplayerAddMana(creature.uid, getPlayerMana(cid) * config.percent_mp / 100)
   else
       doPlayerSendCancel(cid, "You can heal only players.")
       return true
   end
end
thank you guys for you time.
doCreatureAddMana
 
Back
Top