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

SOLVED [TFS 1.0] Spell Take SoulPoint Every 1 Sec to be Active

Eldin

Eldin Projects
Premium User
Joined
Jun 12, 2008
Messages
1,334
Reaction score
613
Location
Sweden
Greets!

Im working on some nice systems for my upcoming servers as well as systems being released to public when done.
One thing that I need help with is a spell that cost soul points to stay ACTIVE.

So The Spell:
We will use the recovery from real tibia, the spell sets a faster HP regeneration for X time.
What if I want a person to say the spell, but it will ALSO take 1 soul Point each second to be Active for 5 minutes? If you run out of soul points, the spell stops.

recovery
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

local condition = createConditionObject(CONDITION_REGENERATION)
setConditionParam(condition, CONDITION_PARAM_SUBID, 1)
setConditionParam(condition, CONDITION_PARAM_BUFF_SPELL, 1)
setConditionParam(condition, CONDITION_PARAM_TICKS, 1 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_HEALTHGAIN, 20)
setConditionParam(condition, CONDITION_PARAM_HEALTHTICKS, 3000)
setCombatCondition(combat, condition)

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

What do I add? Is it possible? :)

Kind Regards,
Eldin.
 
You could try something like this

function onCastSpell(cid, var)

local function effect(cid)
doSendMagicEffect(getThingPos(cid), 14)
if getPlayerSoul(cid) >= 4 then
doPlayerAddSoul(cid, -4) -- Taking away 1 soul every second
doCreatureAddHealth(cid, 20) -- Regenerating 20 HP every second
else
doPlayerSendCancel(cid, "You don't have enough soul to continue regenerating.")
return false
end
end

for i = 0, 300000, 1000 do -- setting the regeneration function to happen every 1 second for the next 5 mins.
addEvent(effect, i, cid)
end

return true
end
 
Oh, nice... almost :D

Once my soul Went out, this kept spamming the logg:

Code:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
LuaScriptInterface::luaGetThingPos(). Thing not found
stack traceback:
  [C]: in function 'getThingPos'
  data/spells/scripts/healing/hp focus.lua:4: in function <data/spells/scr
ipts/healing/hp focus.lua:3>

Kind Regards,
Eldin.
 
Sorry I didn't respond earlier, totally forgot D;
Anyway, as I can see, you're using 1.0 and I'm not familiar with its functions so I'll pass on attempting to do it and let someone else who knows what they're doing. :c
 
Oh, nice... almost :D

Once my soul Went out, this kept spamming the logg:

Code:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
LuaScriptInterface::luaGetThingPos(). Thing not found
stack traceback:
  [C]: in function 'getThingPos'
  data/spells/scripts/healing/hp focus.lua:4: in function <data/spells/scr
ipts/healing/hp focus.lua:3>

Kind Regards,
Eldin.

In this spell don't have check if soul go to 0.
 
switch those 2 lines
doSendMagicEffect(getThingPos(cid), 14)
if getPlayerSoul(cid) >= 4 then
should be
if getPlayerSoul(cid) >= 4 then
doSendMagicEffect(getThingPos(cid), 14)
 
First of all, the script is badly made, preformence purposes also.
Such as it will still send out the event even if you dont have soul, the loop will still send it out.
Also you forgot to make it execute when the spells is not under effect.

Enjoy:
Code:
local function doSendSpell(cid, time)
    local player = Player(cid)
    if player ~= nil then
        if time > 0 then
            if player:getSoul() >= 1 then
                player:addSoul(-1)
                player:addHealth(20)
                player:getPosition():sendMagicEffect(14)
            else
                player:sendCancelMessage("You don't have enough soul to continue regenerating.")
                player:setStorageValue(1000, 0)
                return false
            end
        else
            player:sendCancelMessage("The spell has ranned out.")
            player:setStorageValue(1000, 0)
            return false
        end
        addEvent(doSendSpell, 1000, cid, time - 1)
    end
    return true
end

function onCastSpell(cid, var)
    local player = Player(cid)
    if player:getStorageValue(1000) <= 0 then
        if player:getSoul() >= 1 then
            doSendSpell(cid, 5 * 60 * 1000)
            player:setStorageValue(1000, 1)
        else
            player:sendCancelMessage("You dont have enough of soul.")
        end
    else
        player:sendCancelMessage("You are already under the spells effect.")
    end
    return true
end

set this onLogin if it happens that player logout with the spell activated, then when they login back it sets storage to 0.
Code:
    if player:getStorageValue(1000) == 1 then
        player:setStorageValue(1000, 0)
    emd
 
Last edited:
Back
Top