local exhaustTime = 1000
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, exhaustTime)
local function conjuration(cid, t, word)
doPlayerAddMana(cid, -(t[word].manaCost))
doPlayerAddItem(cid, t[word].runeID, t[word].runeAmount)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You conjured "..(t[word].runeAmount).." "..(getItemNameById(t[word].runeID)).." runes.")
doAddCondition(cid, exhaust)
end
function onSay(cid, words, param, channel)
if(hasCondition(cid, CONDITION_EXHAUST)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
local vocations = {"Sorcerer", "Druid", "Paladin", "Knight", "Master sorcerer", "Elder druid", "Royal paladin", "Elite knight"}
local cast = string.lower(words.." "..param)
local voc = getPlayerVocation(cid)
local lvl = getPlayerLevel(cid)
local mana = getPlayerMana(cid)
local errorMessage = ""
local invalidSpell = "--- Valid conjuration spells for you are ---"
local runes = {
["adori blank"] = {runeID = 2260, runeAmount = 1, manaCost = 20, levelReq = 8, vocations = {1,2,3,4,5,6,7,8}},
["adori vita vis"] = {runeID = 2268, runeAmount = 3, manaCost = 200, levelReq = 200, vocations = {1,2,3,4,5,6,7,8}},
["adori vis"] = {runeID = 2311, runeAmount = 15, manaCost = 200, levelReq = 200, vocations = {1,2,3,4,5,6,7,8}}
}
if runes[cast] then
if isInArray(runes[cast].vocations, voc) then
if lvl >= runes[cast].levelReq then
if mana >= runes[cast].manaCost then
if cast ~= "adori blank" and doPlayerRemoveItem(cid, 2260, runes[cast].runeAmount) then
conjuration(cid, runes, cast)
return true
elseif cast == "adori blank" then
conjuration(cid, runes, cast)
return true
else
errorMessage = "You do not have enough blank runes. You need "..(runes[cast].runeAmount).."."
end
else
errorMessage = "You do not have enough mana. You have "..mana.." and you need "..runes[cast].manaCost.."."
end
else
errorMessage = "You do not have the required level for this. You need level "..runes[cast].levelReq.."."
end
else
errorMessage = "That spell can only be used by:\n"
for i=1,#(runes[cast].vocations),1 do
if i == #(runes[cast].vocations) then
errorMessage = errorMessage..vocations[i].."."
else
errorMessage = errorMessage..vocations[i]..", "
end
end
end
else
errorMessage = "That conjuration spell does not exist."
end
for pos,val in pairs(runes) do
if isInArray(runes[pos].vocations, voc) then
invalidSpell = invalidSpell.."\n"..pos.." --- which costs "..(runes[pos].manaCost).." mana and gives you "..(runes[pos].runeAmount).." "..(getItemNameById(runes[pos].runeID))..""
if runes[pos].runeAmount > 1 then
invalidSpell = invalidSpell.."s."
else
invalidSpell = invalidSpell.."."
end
end
end
invalidSpell = errorMessage.."\n"..invalidSpell
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, invalidSpell)
doAddCondition(cid, exhaust)
return true
end