As ots didn't have tibia exhausted working propetly for attacking\healing spells I tryed to make healing spells in talkactions. I just maked first spell(Divine healing), i post it here, I ask someone look, maybe I forgot something, or maked wrong ;] (I know, my scripts are complicated, but I just started )
also I added to functions.lua(trunk), global.lua(tags)
talkaction.lua
PHP:
function onSay(cid, words, param)
local mana = 210
local level = getPlayerLevel(cid)
local maglevel = getPlayerMagLevel(cid)
local mini = (level * 3 + maglevel * 3) * 2.08
local maxi = (level * 3 + maglevel * 3) * 2.7
local pos = getCreaturePosition(cid)
local voc = getPlayerVocation(cid)
local storevalue = 9995
local exhausttime = 1
local mananow = getPlayerMana(cid)
if mananow >= mana then
if level > 34 and getPlayerPremiumDays(cid) > 0 then
if voc == 3 or voc == 7 then
if (exhaust(cid, storevalue, exhausttime) == 1) then
doCreatureAddHealth(cid, math.random(mini,maxi))
doCreatureAddMana(cid, -mana)
doPlayerAddManaSpent(cid, mana)
doSendAnimatedText(pos, 'HEAL', TEXTCOLOR_LIGHTGREEN)
else doPlayerSendCancel(cid, "EXHAUSTED.")
end
else doPlayerSendCancel(cid, "Your vocation cannot cast this spell.")
end
else doPlayerSendCancel(cid, "Your level is too low or you don't have premium account.")
end
else doPlayerSendCancel(cid, "You don't have mana for this spell")
end
end
also I added to functions.lua(trunk), global.lua(tags)
PHP:
function exhaust(cid, storevalue, exhausttime)
-- Exhaustion function by Alreth, v1.1 2006-06-24 01:31
-- Returns 1 if not exhausted and 0 if exhausted
newExhaust = os.time()
oldExhaust = getPlayerStorageValue(cid, storevalue)
if (oldExhaust == nil or oldExhaust < 0) then
oldExhaust = 0
end
if (exhausttime == nil or exhausttime < 0) then
exhausttime = 1
end
diffTime = os.difftime(newExhaust, oldExhaust)
if (diffTime >= exhausttime or diffTime < 0) then
setPlayerStorageValue(cid, storevalue, newExhaust)
return 1
else
return 0
end
end
talkaction.lua
HTML:
<talkaction words="exura san" script="spells/divine healing.lua" />