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

OTX2 - npcs is not teaching spells to cast runes.

tdp157

Member
Joined
Oct 14, 2014
Messages
29
Reaction score
12
Hello, I have an otx2 0.7 server codename Lord Zedd


My NPCs cannot teach rune casting magic, only instantaneous spells.

Below is the npc script that teaches spells to sorcerers:

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then   
        return false
    end

    local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

    local t = {
            ["destroy field rune"] = {price = 1050, vocations = {1, 5}, ml = 6},
            ["energy field rune"] = {price = 1050, vocations = {1, 5}, ml = 5},
            ["energy wall rune"] = {price = 3750, vocations = {1, 5}, ml = 18},
            ["explosion rune"] = {price = 2700, vocations = {1, 5}, ml = 12},
            ["fire field rune"] = {price = 750, vocations = {1, 5}, ml = 3},
            ["fire wall rune"] = {price = 3000, vocations = {1, 5}, ml = 13},
            ["fireball rune"] = {price = 1200, vocations = {1, 5}, ml = 5},
            ["fire bomb rune"] = {price = 2250, vocations = {1, 5}, ml = 9},
            ["heavy magic missile rune"] = {price = 2250, vocations = {1, 5}, ml = 3},
            ["great fireball rune"] = {price = 1800, vocations = {1, 5}, ml = 9},
            ["light magic missile rune"] = {price = 750, vocations = {1, 5}, ml = 1},
            ["poison field rune"] = {price = 450, vocations = {1, 5}, ml = 2},
            ["poison wall rune"] = {price = 2400, vocations = {1, 5}, ml = 11},
            ["sudden death rune"] = {price = 4500, vocations = {1, 5}, ml = 25},
            ["cure poison"] = {price = 225, vocations = {1, 5}, ml = 2},
            ["creature illusion"] = {price = 1500, vocations = {1, 5}, ml = 10},
            ["energy beam"] = {price = 1500, vocations = {1, 5}, ml = 10},
            ["energy wave"] = {price = 3750, vocations = {1, 5}, ml = 20},
            ["find person"] = {price = 120, vocations = {1, 5}, ml = 0},
            ["fire wave"] = {price = 1275, vocations = {1, 5}, ml = 7},
            ["great energy beam"] = {price = 2700, vocations = {1, 5}, ml = 14},
            ["great light"] = {price = 750, vocations = {1, 5}, ml = 3},
            ["intense healing"] = {price = 525, vocations = {1, 5}, ml = 2},
            ["invisibility"] = {price = 3000, vocations = {1, 5}, ml = 15},
            ["light"] = {price = 150, vocations = {1, 5}, ml = 0},
            ["light healing"] = {price = 255, vocations = {1, 5}, ml = 1},
            ["magic shield"] = {price = 675, vocations = {1, 5}, ml = 1},
            ["summon creature"] = {price = 3000, vocations = {1, 5}, ml = 16},
            ["ultimate healing"] = {price = 1500, vocations = {1, 5}, ml = 8}
             }
    local msg = msg:lower()

    if t[msg] then
        if isInArray(t[msg:lower()].vocations, getPlayerVocation(cid)) then
            if not getPlayerLearnedInstantSpell(cid, msg) then
                npcHandler:say("Do you wish to learn the spell ".. msg .." for the price of "..t[msg].price.." gold?", cid)
                compra = 1
                magia = msg           
            else
                npcHandler:say("You have already learned this spell.", cid)
            end
        else
            npcHandler:say(" teach spells only to Sorcerer.", cid)
        end

    elseif msgcontains(msg, "yes") and compra ~= nil then
        if not getPlayerLearnedInstantSpell(cid, msg) then
            if getPlayerMoney(cid) >= t[magia].price then
                if doPlayerRemoveMoney(cid, t[magia].price) then
                    doPlayerLearnInstantSpell(cid, magia)
                    doSendMagicEffect(getPlayerPosition(cid), 12)
                    npcHandler:say("You have learned the spell called ".. magia .."!", cid)
                    compra = nil
                end
            else
                npcHandler:say("You do not have "..t[magia].price.." gold to buy this spell!", cid)
            end
        else
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
            npcHandler:say("You have already learned this spell.", cid)
        end
        
    elseif msgcontains(msg, "no") and compra ~= nil then
        npcHandler:say("No problem, come back whenever you want to learn!", cid)
        compra = nil
    end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I am also sending the npc.cpp and spells.cpp file for analysis.

Can someone help me?
 

Attachments

  • spells_and_npc_cpp.zip
    24.7 KB · Views: 1 · VirusTotal
@tdp157 I'm not 100% sure about... but, if the script works for instant spells, the problem is the "rune" in the end of the spellname, just remove rune from spell runes, only ultimate healing, intense healing and antidote runes(others?) have rune in the end
 
@tdp157 I'm not 100% sure about... but, if the script works for instant spells, the problem is the "rune" in the end of the spellname, just remove rune from spell runes, only ultimate healing, intense healing and antidote runes(others?) have rune in the end
true. Usually there is an instant spell that conjures the rune, and another spell that activates the rune.
 
Back
Top