(It's part of my talents system)
in ../data/creaturescripts/creaturescripts.xml add:
in ../data/creaturescripts/scripts/talents/login.lua add:
in ../data/creaturescripts/scripts/talents/statschange.lua add:
and new spell:
in ../data/creaturescripts/creaturescripts.xml add:
XML:
<event type="login" name="TalentsLogin" event="script" value="talents/login.lua"/>
<event type="statschange" name="TalentsStatsChange" event="script" value="talents/statschange.lua"/>
Lua:
function onLogin(cid)
registerCreatureEvent(cid, "TalentsStatsChange")
return true
end
Lua:
local drainStorage = 34527
local drainPercent = 30
function onStatsChange(cid, attacker, type, combat, value)
if(isPlayer(attacker) and getCreatureStorage(attacker, drainStorage) >= os.time() and (type == STATSCHANGE_MANALOSS or type == STATSCHANGE_HEALTHLOSS)) then
doCreatureAddHealth(attacker, value * drainPercent / 100)
end
return true
end
and new spell:
Lua:
local drainStorage = 34527
local drainTime = 30
local drainExhaust = 60
function onCastSpell(cid, var)
if(getCreatureStorage(cid, drainStorage) - drainTime + drainExhaust <= os.time()) then
doCreatureSetStorage(cid, drainStorage, os.time() + drainTime)
return true
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can not cast life drain. Wait " .. getCreatureStorage(cid, drainStorage) - drainTime + drainExhaust - os.time() .. " seconds.")
return false
end
end
Last edited: