Ramirow
Veteran OT User
- Joined
- Aug 22, 2009
- Messages
- 584
- Solutions
- 15
- Reaction score
- 301
- Location
- Argentina
- YouTube
- ramirogrant
I'm facing a weird problem now and I don't know how to address it.
The script is supposed to do the following:
Check if player is knight/elite knight and terminates execution.
Check then if player is Sorcerer and can conjure the rune.
Check if it is Druid and can conjure the rune.
And check if it is Paladin and can conjure the rune.
No problems with Sorcerer or Druid's checks, they work flawlessly.
The issue arises with Paladin's, they can cast all spells marked with the var 'usable = 3' which is only used for Druid/Sorcerer spells they share.
But I don't see how it's possible, it may be a dumb error, but I can't seem to find it..
I know this script could be written better, I was just experimenting!
The script is supposed to do the following:
Check if player is knight/elite knight and terminates execution.
Check then if player is Sorcerer and can conjure the rune.
Check if it is Druid and can conjure the rune.
And check if it is Paladin and can conjure the rune.
No problems with Sorcerer or Druid's checks, they work flawlessly.
The issue arises with Paladin's, they can cast all spells marked with the var 'usable = 3' which is only used for Druid/Sorcerer spells they share.
But I don't see how it's possible, it may be a dumb error, but I can't seem to find it..
I know this script could be written better, I was just experimenting!
Code:
local exhaust = Condition(CONDITION_SPELLCOOLDOWN)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) + 500))
-- Runes Table.
-- 'Usable' var. stands for: 1 - sorcerer only, 2 - druid only, 3 - sor/druid, 4 - paladin only and 5 -- stands for sor/druid/pala
local runes = {
{name = "adura gran", runeID = 2265, runeAmount = 1, manaCost = 120, levelReq = 15, soul = 2, usable = 2},
{name = "adori min vis", runeID = 2287, runeAmount = 10, manaCost = 120, levelReq = 15, soul = 1, usable = 3},
{name = "adori mas flam", runeID = 2304, runeAmount = 4, manaCost = 530, levelReq = 30, soul = 3, usable = 1},
{name = "adito grav", runeID = 2261, runeAmount = 3, manaCost = 120, levelReq = 17, soul = 2, usable = 5},
{name = "adori san", runeID = 2295, runeAmount = 5, manaCost = 350, levelReq = 27, soul = 3, usable = 4}
}
local noSoul = "You do not have enough soul points."
local noBlank = "You need a blank rune to cast this spell."
local noMana = "You do not have enough mana."
local noVoc = "Your vocation cannot use this spell."
function onSay(player, words, param)
local voc = player:getVocation():getId()
if player:getCondition(CONDITION_SPELLCOOLDOWN) then
player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if isInArray({4, 8}, voc) then
player:sendTextMessage(MESSAGE_STATUS_SMALL, noVoc)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
for i=1,#runes,1 do
if runes[i].name == string.lower((words.." "..param)) then
local noLvl = "You need level " .. (runes[i].levelReq) .. " to conjure this rune."
if isInArray({1,5}, voc) and runes[i].usable == 1 or runes[i].usable == 3 or runes[i].usable == 5 then
if player:getLevel() >= runes[i].levelReq then
if player:getMana() >= runes[i].manaCost then
if player:getSoul() >= runes[i].soul then
if player:removeItem(2260, 1) then
player:addMana(-(runes[i].manaCost))
player:addManaSpent(runes[i].manaCost)
player:addSoul(-(runes[i].soul))
player:addItem(runes[i].runeID, runes[i].runeAmount)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
player:addCondition(exhaust)
player:say(runes[i].name, TALKTYPE_MONSTER_SAY)
return false
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, noBlank)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, noSoul)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, noMana)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, noLvl)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return
end
end
if isInArray({2,6}, voc) and runes[i].usable == 2 or runes[i].usable == 3 or runes[i].usable == 5 then
if player:getLevel() >= runes[i].levelReq then
if player:getMana() >= runes[i].manaCost then
if player:getSoul() >= runes[i].soul then
if player:removeItem(2260, 1) then
player:addMana(-(runes[i].manaCost))
player:addManaSpent(runes[i].manaCost)
player:addSoul(-(runes[i].soul))
player:addItem(runes[i].runeID, runes[i].runeAmount)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
player:addCondition(exhaust)
player:say(runes[i].name, TALKTYPE_MONSTER_SAY)
return false
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, noBlank)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, noSoul)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, noMana)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, noLvl)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return
end
end
if isInArray({3,7}, voc) and runes[i].usable == 4 or runes[i].usable == 5 then
if player:getLevel() >= runes[i].levelReq then
if player:getMana() >= runes[i].manaCost then
if player:getSoul() >= runes[i].soul then
if player:removeItem(2260, 1) then
player:addMana(-(runes[i].manaCost))
player:addManaSpent(runes[i].manaCost)
player:addSoul(-(runes[i].soul))
player:addItem(runes[i].runeID, runes[i].runeAmount)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
player:addCondition(exhaust)
player:say(runes[i].name, TALKTYPE_MONSTER_SAY)
return false
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, noBlank)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, noSoul)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, noMana)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, noLvl)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return
end
end
else
return true
end
end
return true
end