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

TFS 1.X+ Problem "The Elemental Spheres Quest"

Kownikuzyt

Member
Joined
Feb 11, 2020
Messages
170
Solutions
1
Reaction score
8
Hello, I have a problem with "The Elemental Spheres Quest".

I am using TFS 1.1.

According to the guide, talk to Arkulius.

The Elemental Spheres Quest.png

Player: hi
Arkulius: ...then I could transform a spell to bend... How can anyone expect me to work under these conditions?? What do you want?
Player: Alverus
Arkulius: It happened while he carried out an experiment concerning the creation of the elemental shrines. I still get goose bumps just by thinking of it. ...
Arkulius: You need to know about the process of creating an elemental shrine to understand it completely, but I don't want to go into detail now. ...
Arkulius: Anyway, his spell had a different outcome than he had planned. He accidentally created an Ice Overlord, pure living elemental ice, who froze him in a blink of an eye.
Player: shrines
Arkulius: The creation of the elemental shrines is a really complex matter. They are actually nodes, locations where the matching elemental sphere is very close. ...
Arkulius: The shrine itself is like a portal between our world and the elemental sphere and enables us to use the elemental energy emerging from it.
Player: sphere
Arkulius: There are four spheres we know of: ice, fire, earth and energy. ....<mumbles> Hmmm, should I ask or not?....The heck with it! Now that you know about the spheres ...
Arkulius: I found a way to visit them. It's VERY dangerous and there is a decent chance that you won't come back BUT if you succeed you'll write history!!! Ask me about that mission if you're interested.
Player: mission
Arkulius: Okay, listen closely: First of all, you need to gather 20 enchanted amethysts in order to go to the energy sphere. Deep under the academy, one floor below the elemental shrines, there is a machine. Put the gems in there and activate it. ...
Arkulius: Once you got there, find a way to gather elemental energy in any form. You will face energy elementals, that's for sure, but I don't know how the energy is stored. ...
Arkulius: Anyway, there should be a way to use that energy and strengthen one of the elementals. If my calculations are right, you will create an Energy Overlord who hopefully will consist of some sort of 'concentrated' energy. ...
Arkulius: THAT'S what we need!! Are you in on it?
Player: yes
Arkulius: Good, don't waste time! Come back here when you have the elemental object!



The interview went well.

We go to the very bottom of the middle tower, there is a machine in the north. If it is on, you have to turn it off, use 20 enchanted pebbles on it and turn it on.

And here's the problem, because I can't get the machine running to get to the quest.

The code that is responsible for transferring us to after use:
  • Small Enchanted Ruby,
  • Small Enchanted Amethyst,
  • Small Enchanted Emerald,
  • Small Enchanted Sapphire.



data/actions/actions.xml



<action fromid="7911" toid="7912" script="quests/elemental spheres/machine.lua" />



data/actions/scripts/quests/elemental spheres/machine.lua



Lua:
local config = {
    [1] = Position(33183, 32197, 13),
    [2] = Position(33331, 32076, 13),
    [3] = Position(33265, 32202, 13),
    [4] = Position(33087, 32096, 13)
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if isInArray({7911, 7912}, item.itemid) then
        local gemCount = player:getStorageValue(Storage.ElementalSphere.MachineGemCount)
        if isInArray({33268, 33269}, toPosition.x) and toPosition.y == 31830 and toPosition.z == 10 and gemCount >= 20 then
            player:setStorageValue(Storage.ElementalSphere.MachineGemCount, gemCount - 20)
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(config[player:getVocation():getBase():getId()], false)
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        end
        toPosition.x = toPosition.x + (item.itemid == 7911 and 1 or -1)
        local tile = toPosition:getTile()
        if tile then
            local thing = tile:getItemById(item.itemid == 7911 and 7912 or 7911)
            if thing then
                thing:transform(thing.itemid + 4)
            end
        end
        item:transform(item.itemid + 4)
    else
        toPosition.x = toPosition.x + (item.itemid == 7915 and 1 or -1)
        local tile = toPosition:getTile()
        if tile then
            local thing = tile:getItemById(item.itemid == 7915 and 7916 or 7915)
            if thing then
                thing:transform(thing.itemid - 4)
            end
        end
        item:transform(item.itemid - 4)
    end
    return true
end



Anyone know a solution? How to fix it?
 
Hello, I have a problem with "The Elemental Spheres Quest".

I am using TFS 1.1.

According to the guide, talk to Arkulius.

View attachment 53570





The interview went well.



And here's the problem, because I can't get the machine running to get to the quest.

The code that is responsible for transferring us to after use:
  • Small Enchanted Ruby,
  • Small Enchanted Amethyst,
  • Small Enchanted Emerald,
  • Small Enchanted Sapphire.



data/actions/actions.xml







data/actions/scripts/quests/elemental spheres/machine.lua



Lua:
local config = {
    [1] = Position(33183, 32197, 13),
    [2] = Position(33331, 32076, 13),
    [3] = Position(33265, 32202, 13),
    [4] = Position(33087, 32096, 13)
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if isInArray({7911, 7912}, item.itemid) then
        local gemCount = player:getStorageValue(Storage.ElementalSphere.MachineGemCount)
        if isInArray({33268, 33269}, toPosition.x) and toPosition.y == 31830 and toPosition.z == 10 and gemCount >= 20 then
            player:setStorageValue(Storage.ElementalSphere.MachineGemCount, gemCount - 20)
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(config[player:getVocation():getBase():getId()], false)
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        end
        toPosition.x = toPosition.x + (item.itemid == 7911 and 1 or -1)
        local tile = toPosition:getTile()
        if tile then
            local thing = tile:getItemById(item.itemid == 7911 and 7912 or 7911)
            if thing then
                thing:transform(thing.itemid + 4)
            end
        end
        item:transform(item.itemid + 4)
    else
        toPosition.x = toPosition.x + (item.itemid == 7915 and 1 or -1)
        local tile = toPosition:getTile()
        if tile then
            local thing = tile:getItemById(item.itemid == 7915 and 7916 or 7915)
            if thing then
                thing:transform(thing.itemid - 4)
            end
        end
        item:transform(item.itemid - 4)
    end
    return true
end



Anyone know a solution? How to fix it?
DOn't know the quest, but everything appears to be related to this storage "Storage.ElementalSphere.MachineGemCount"

Is there a second script that affects this storage?
 
Have you done a text search through all your Lua scripts for "Storage.ElementalSphere.MachineGemCount"?

I agree 100% with Xikini - there's almost certainly something else that interacts with that storage.
 
DOn't know the quest, but everything appears to be related to this storage "Storage.ElementalSphere.MachineGemCount"

Is there a second script that affects this storage?

@Akela, @Xikini

Works, code was missing...



Kod: data/actions/scripts/other/enchanting.lua



Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if isInArray({33268, 33269}, toPosition.x) and toPosition.y == 31830 and toPosition.z == 10 and player:getStorageValue(Storage.ElementalSphere.QuestLine) > 0 then
        if not isInArray(spheres[item.itemid], player:getVocation():getId()) then
            return false
        elseif isInArray({7915, 7916}, target.itemid) then
            player:say('Turn off the machine first.', TALKTYPE_MONSTER_SAY)
            return true
        else
            player:setStorageValue(Storage.ElementalSphere.MachineGemCount, math.max(1, player:getStorageValue(Storage.ElementalSphere.MachineGemCount) + 1))
            toPosition:sendMagicEffect(CONST_ME_PURPLEENERGY)
            item:transform(item.itemid, item.type - 1)
            return true
        end
    end


    if item.itemid == 2147 and target.itemid == 2342 then
        target:transform(2343)
        target:decay()
        item:remove(1)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        return true
    end


    if item.itemid == 7760 and isInArray({9934, 10022}, target.itemid) then
        target:transform(9933)
        item:remove(1)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        return true
    end


    if isInArray(enchantableGems, item.itemid) then
        local subtype = item.type
        if subtype == 0 then
            subtype = 1
        end


        local mana = config.manaCost * subtype
        if player:getMana() < mana then
            player:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
            return false
        end


        local soul = config.soulCost * subtype
        if player:getSoul() < soul then
            player:sendCancelMessage(RETURNVALUE_NOTENOUGHSOUL)
            return false
        end


        local targetId = table.find(enchantableGems, item.itemid)
        if not targetId or not isInArray(enchantingAltars[targetId], target.itemid) then
            return false
        end


        player:addMana(-mana)
        player:addSoul(-soul)
        item:transform(enchantedGems[targetId])
        player:addManaSpent(mana * configManager.getNumber(configKeys.RATE_MAGIC))
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
        return true
    end


    if item.itemid == 7761 and isInArray({9949, 9954}, target.itemid) then
        target:transform(target.itemid - 1)
        target:decay()
        item:remove(1)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        return true
    end


    if isInArray(enchantedGems, item.itemid) then
        if not isInArray(enchantableItems, target.itemid) then
            fromPosition:sendMagicEffect(CONST_ME_POFF)
            return false
        end


        local targetId = table.find(enchantedGems, item.itemid)
        if not targetId then
            return false
        end


        local subtype = target.type
        if not isInArray({2544, 8905}, target.itemid) then
            subtype = 1000
        end


        target:transform(enchantedItems[target.itemid][targetId], subtype)
        target:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        item:remove(1)
        return true
    end
    return false
end



but I have a problem because "enchanting" doesn't work :( Any idea to solve this?



Kod: data/actions/scripts/other/enchanting.lua (all content)



Lua:
function onUse(cid, item, frompos, item2, topos)


local gems = {2146, 2147, 2149, 2150}
local egems = {7759, 7760, 7761, 7762}
local altars = {{7508, 7509, 7510, 7511}, {7504, 7505, 7506, 7507}, {7516, 7517, 7518, 7519}, {7512, 7513, 7514, 7515}}
local weapons = {2383, 7384, 7389, 7406, 7402, 2429, 2430, 7383, 7380, 2454, 2423, 2445, 7415, 7392, 2391, 2544, 8905}
local eweapons = {{7763, 7744, 7854, 7869}, {7765, 7746, 7856, 7871}, {7770, 7751, 7861, 7876}, {7766, 7747, 7857, 7872}, {7767, 7748, 7858, 7873}, {7768, 7749, 7859, 7874}, {7769, 7750, 7860, 7875}, {7764, 7745, 7855, 7870}, {7771, 7752, 7862, 7877}, {7772, 7753, 7863, 7878}, {7773, 7754, 7864, 7879}, {7774, 7755, 7865, 7880}, {7775, 7756, 7866, 7881}, {7776, 7757, 7867, 7882}, {7777, 7758, 7868, 7883}, {7839, 7840, 7850, 7838}, {8907, 8906, 8909, 8908}}


--2435--


local type = item.type
if type == 0 then
type = 1
end


local mana = 300 * type
local soul = 2 * type


if isInArray(gems, item.itemid)== TRUE then
for aa=1, #gems do
if item.itemid == gems[aa] then
a=aa
end
end
if isInArray(altars[a], item2.itemid)== TRUE then
if getPlayerMana(cid) >= mana and getPlayerSoul(cid) >= soul then
doTransformItem(item.uid,egems[a])
doPlayerAddMana(cid,-mana)
doPlayerAddSoul(cid,-soul)
doSendMagicEffect(frompos,39)
else
doPlayerSendCancel(cid,"You dont have mana or soul points.")
end
else
return 2
end


elseif isInArray(egems, item.itemid)== TRUE then
for bb=1, #egems do
if item.itemid == egems[bb] then
b=bb
end
end
if isInArray(weapons, item2.itemid)== TRUE then
for cc=1, #weapons do
if item2.itemid == weapons[cc] then
c=cc
end
end
doTransformItem(item2.uid,eweapons[c][b],1000)
doSendMagicEffect(frompos,39)
doRemoveItem(item.uid,1)
else
doPlayerSendCancel(cid,"You can't enchanted this.")
end
else
return 0
end
return 1
end




-=-= Add Code =-=-

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if isInArray({33268, 33269}, toPosition.x) and toPosition.y == 31830 and toPosition.z == 10 and player:getStorageValue(Storage.ElementalSphere.QuestLine) > 0 then
        if not isInArray(spheres[item.itemid], player:getVocation():getId()) then
            return false
        elseif isInArray({7915, 7916}, target.itemid) then
            player:say('Turn off the machine first.', TALKTYPE_MONSTER_SAY)
            return true
        else
            player:setStorageValue(Storage.ElementalSphere.MachineGemCount, math.max(1, player:getStorageValue(Storage.ElementalSphere.MachineGemCount) + 1))
            toPosition:sendMagicEffect(CONST_ME_PURPLEENERGY)
            item:transform(item.itemid, item.type - 1)
            return true
        end
    end


    if item.itemid == 2147 and target.itemid == 2342 then
        target:transform(2343)
        target:decay()
        item:remove(1)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        return true
    end


    if item.itemid == 7760 and isInArray({9934, 10022}, target.itemid) then
        target:transform(9933)
        item:remove(1)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        return true
    end


    if isInArray(enchantableGems, item.itemid) then
        local subtype = item.type
        if subtype == 0 then
            subtype = 1
        end


        local mana = config.manaCost * subtype
        if player:getMana() < mana then
            player:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
            return false
        end


        local soul = config.soulCost * subtype
        if player:getSoul() < soul then
            player:sendCancelMessage(RETURNVALUE_NOTENOUGHSOUL)
            return false
        end


        local targetId = table.find(enchantableGems, item.itemid)
        if not targetId or not isInArray(enchantingAltars[targetId], target.itemid) then
            return false
        end


        player:addMana(-mana)
        player:addSoul(-soul)
        item:transform(enchantedGems[targetId])
        player:addManaSpent(mana * configManager.getNumber(configKeys.RATE_MAGIC))
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
        return true
    end


    if item.itemid == 7761 and isInArray({9949, 9954}, target.itemid) then
        target:transform(target.itemid - 1)
        target:decay()
        item:remove(1)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        return true
    end


    if isInArray(enchantedGems, item.itemid) then
        if not isInArray(enchantableItems, target.itemid) then
            fromPosition:sendMagicEffect(CONST_ME_POFF)
            return false
        end


        local targetId = table.find(enchantedGems, item.itemid)
        if not targetId then
            return false
        end


        local subtype = target.type
        if not isInArray({2544, 8905}, target.itemid) then
            subtype = 1000
        end


        target:transform(enchantedItems[target.itemid][targetId], subtype)
        target:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        item:remove(1)
        return true
    end
    return false
end
 
@Kownikuzyt

The original developer of that quest used a coding style which makes it resistant to a quick analysis:
  • There's a fair bit of code, and it's spread around, but there are no comments in the code, and you haven't shared any external documentation that would tie it together for us
  • It uses techniques to make the code compact and "developer-friendly" which are unfortunately "maintenance-hostile"
BTW every coder does this with their "Version 1", so we can't be too critical of the original developer, but it presents us with a real problem now: "reverse engineering", especially with no test frame and the real possibility of more missing code, is going to take hours, and still may not succeed due to missing code.

You can help, but it will cost you a few hours too, so you'll need to decide how much this is worth to you.

(BTW: - I'm not trying to criticize your original question. You might have been lucky, and found someone with a functioning version of the Quest, or even the original developer. But so far all the the answers are coming from people who just know how to read and write logic (Xikini is much better at OT and Lua than me, but I've probably written more code then he has overall).

So we either need to engage with what we have, which entails the risks of failure, or project failure due to people getting bored, or you can wait for a "magic wand" - given time, perhaps someone who can solve this in ten minutes may yet turn up :)

If you want to keep going now, you'll need to do a few things for us, or it's probably not with the effort from our side:
  • Provide a structured description of the errors you're getting, and answer any additional questions I/we ask (and we will ask, because it's not easy to describe an IT problem accurately unless you're expert with the tech, and if you were already expert you wouldn't need us :)
  • If you're seeing no errors, add some "print" statements to the code (or trace it if you have a debugger) so we can figure out where it breaks, and why
  • Run some tests (with small code modifications and/or changes in parameters and/or try different behavior during the quest) and report then results
  • Keep searching your modified OT for the other fragments of the code. You've done well so far (finding the customized "enchanting.lua"), but I suspect there will be many more searches if we move forward
  • Probably more annoying tasks will turn up too, but this list is long enough for now :)
So: think about how much time this is worth for you, and don't forget it may be unsolvable
(BTW the quest could probably be recreated, but I'm not that interested - for example I'm really only in this to figure out how the "machine" in the first script works).

Also some of the activities I/we will ask will not be fun (e.g. nobody likes testing for errors that don't normally provide any useful symptoms :) This will be at least 50% grind for you. And your helpers may get bored and give up. Bottom line - make sure your expected effort matches the expected value, so nobody will be too unhappy if it isn't successful.

If you're still interested, reply here.
 
@Kownikuzyt

The original developer of that quest used a coding style which makes it resistant to a quick analysis:
  • There's a fair bit of code, and it's spread around, but there are no comments in the code, and you haven't shared any external documentation that would tie it together for us
  • It uses techniques to make the code compact and "developer-friendly" which are unfortunately "maintenance-hostile"
BTW every coder does this with their "Version 1", so we can't be too critical of the original developer, but it presents us with a real problem now: "reverse engineering", especially with no test frame and the real possibility of more missing code, is going to take hours, and still may not succeed due to missing code.

You can help, but it will cost you a few hours too, so you'll need to decide how much this is worth to you.

(BTW: - I'm not trying to criticize your original question. You might have been lucky, and found someone with a functioning version of the Quest, or even the original developer. But so far all the the answers are coming from people who just know how to read and write logic (Xikini is much better at OT and Lua than me, but I've probably written more code then he has overall).

So we either need to engage with what we have, which entails the risks of failure, or project failure due to people getting bored, or you can wait for a "magic wand" - given time, perhaps someone who can solve this in ten minutes may yet turn up :)

If you want to keep going now, you'll need to do a few things for us, or it's probably not with the effort from our side:
  • Provide a structured description of the errors you're getting, and answer any additional questions I/we ask (and we will ask, because it's not easy to describe an IT problem accurately unless you're expert with the tech, and if you were already expert you wouldn't need us :)
  • If you're seeing no errors, add some "print" statements to the code (or trace it if you have a debugger) so we can figure out where it breaks, and why
  • Run some tests (with small code modifications and/or changes in parameters and/or try different behavior during the quest) and report then results
  • Keep searching your modified OT for the other fragments of the code. You've done well so far (finding the customized "enchanting.lua"), but I suspect there will be many more searches if we move forward
  • Probably more annoying tasks will turn up too, but this list is long enough for now :)
So: think about how much time this is worth for you, and don't forget it may be unsolvable
(BTW the quest could probably be recreated, but I'm not that interested - for example I'm really only in this to figure out how the "machine" in the first script works).

Also some of the activities I/we will ask will not be fun (e.g. nobody likes testing for errors that don't normally provide any useful symptoms :) This will be at least 50% grind for you. And your helpers may get bored and give up. Bottom line - make sure your expected effort matches the expected value, so nobody will be too unhappy if it isn't successful.

If you're still interested, reply here.
@Akela

Thank you for the answer, I did not have a TFS 1.1 engine, which is totally bugged, I put too much work on the server to give up now. I understand that there are plenty of motods. Please direct me what to do and I will do it, because I want to solve it once and for all. I looked through the guides on how to solve it and nothing helped.



The code I am using: data/actions/scripts/other/enchanting.lua



Lua:
local config = {
    manaCost = 300,
    soulCost = 2,
}


local spheres = {
    [7759] = {3, 7},
    [7760] = {1, 5},
    [7761] = {2, 6},
    [7762] = {4, 8}
}


local enchantableGems = {2147, 2146, 2149, 2150}
local enchantableItems = {2383, 7383, 7384, 7406, 7402, 2429, 2430, 7389, 7380, 2454, 2423, 2445, 7415, 7392, 2391, 2544, 8905}


local enchantingAltars = {
    {7504, 7505, 7506, 7507},
    {7508, 7509, 7510, 7511},
    {7516, 7517, 7518, 7519},
    {7512, 7513, 7514, 7515}
}


local enchantedGems = {7760, 7759, 7761, 7762}
local enchantedItems = {
    [2383] = {7744, 7763, 7854, 7869},
    [7383] = {7745, 7764, 7855, 7870},
    [7384] = {7746, 7765, 7856, 7871},
    [7406] = {7747, 7766, 7857, 7872},
    [7402] = {7748, 7767, 7858, 7873},
    [2429] = {7749, 7768, 7859, 7874},
    [2430] = {7750, 7769, 7860, 7875},
    [7389] = {7751, 7770, 7861, 7876},
    [7380] = {7752, 7771, 7862, 7877},
    [2454] = {7753, 7772, 7863, 7878},
    [2423] = {7754, 7773, 7864, 7879},
    [2445] = {7755, 7774, 7865, 7880},
    [7415] = {7756, 7775, 7866, 7881},
    [7392] = {7757, 7776, 7867, 7882},
    [2391] = {7758, 7777, 7868, 7883},
    [2544] = {7840, 7839, 7850, 7838},
    [8905] = {8906, 8907, 8909, 8908}
}


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if isInArray({33268, 33269}, toPosition.x) and toPosition.y == 31830 and toPosition.z == 10 and player:getStorageValue(Storage.ElementalSphere.QuestLine) > 0 then
        if not isInArray(spheres[item.itemid], player:getVocation():getId()) then
            return false
        elseif isInArray({7915, 7916}, target.itemid) then
            player:say('Turn off the machine first.', TALKTYPE_MONSTER_SAY)
            return true
        else
            player:setStorageValue(Storage.ElementalSphere.MachineGemCount, math.max(1, player:getStorageValue(Storage.ElementalSphere.MachineGemCount) + 1))
            toPosition:sendMagicEffect(CONST_ME_PURPLEENERGY)
            item:transform(item.itemid, item.type - 1)
            return true
        end
    end


    if item.itemid == 2147 and target.itemid == 2342 then
        target:transform(2343)
        target:decay()
        item:remove(1)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        return true
    end


    if item.itemid == 7760 and isInArray({9934, 10022}, target.itemid) then
        target:transform(9933)
        item:remove(1)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        return true
    end


    if isInArray(enchantableGems, item.itemid) then
        local subtype = item.type
        if subtype == 0 then
            subtype = 1
        end


        local mana = config.manaCost * subtype
        if player:getMana() < mana then
            player:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
            return false
        end


        local soul = config.soulCost * subtype
        if player:getSoul() < soul then
            player:sendCancelMessage(RETURNVALUE_NOTENOUGHSOUL)
            return false
        end


        local targetId = table.find(enchantableGems, item.itemid)
        if not targetId or not isInArray(enchantingAltars[targetId], target.itemid) then
            return false
        end


        player:addMana(-mana)
        player:addSoul(-soul)
        item:transform(enchantedGems[targetId])
        player:addManaSpent(mana * configManager.getNumber(configKeys.RATE_MAGIC))
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
        return true
    end


    if item.itemid == 7761 and isInArray({9949, 9954}, target.itemid) then
        target:transform(target.itemid - 1)
        target:decay()
        item:remove(1)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        return true
    end


    if isInArray(enchantedGems, item.itemid) then
        if not isInArray(enchantableItems, target.itemid) then
            fromPosition:sendMagicEffect(CONST_ME_POFF)
            return false
        end


        local targetId = table.find(enchantedGems, item.itemid)
        if not targetId then
            return false
        end


        local subtype = target.type
        if not isInArray({2544, 8905}, target.itemid) then
            subtype = 1000
        end


        target:transform(enchantedItems[target.itemid][targetId], subtype)
        target:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        item:remove(1)
        return true
    end
    return false
end




Kod: data/actions/actions.xml




XML:
<action fromid="2146" toid="2147" script="other/enchanting.lua" />
<action fromid="2149" toid="2150" script="other/enchanting.lua" />
<action fromid="7759" toid="7762" script="other/enchanting.lua" />



"The Elemental Spheres Quest" works with this code.



I used this code once: data/actions/scripts/other/enchanting.lua
(and enchanting works fine but "The Elemental Spheres Quest" does not work)


Lua:
function onUse(cid, item, frompos, item2, topos)


local gems = {2146, 2147, 2149, 2150}
local egems = {7759, 7760, 7761, 7762}
local altars = {{7508, 7509, 7510, 7511}, {7504, 7505, 7506, 7507}, {7516, 7517, 7518, 7519}, {7512, 7513, 7514, 7515}}
local weapons = {2383, 7384, 7389, 7406, 7402, 2429, 2430, 7383, 7380, 2454, 2423, 2445, 7415, 7392, 2391, 2544, 8905}
local eweapons = {{7763, 7744, 7854, 7869}, {7765, 7746, 7856, 7871}, {7770, 7751, 7861, 7876}, {7766, 7747, 7857, 7872}, {7767, 7748, 7858, 7873}, {7768, 7749, 7859, 7874}, {7769, 7750, 7860, 7875}, {7764, 7745, 7855, 7870}, {7771, 7752, 7862, 7877}, {7772, 7753, 7863, 7878}, {7773, 7754, 7864, 7879}, {7774, 7755, 7865, 7880}, {7775, 7756, 7866, 7881}, {7776, 7757, 7867, 7882}, {7777, 7758, 7868, 7883}, {7839, 7840, 7850, 7838}, {8907, 8906, 8909, 8908}}


--2435--


local type = item.type
if type == 0 then
type = 1
end


local mana = 300 * type
local soul = 2 * type


if isInArray(gems, item.itemid)== TRUE then
for aa=1, #gems do
if item.itemid == gems[aa] then
a=aa
end
end
if isInArray(altars[a], item2.itemid)== TRUE then
if getPlayerMana(cid) >= mana and getPlayerSoul(cid) >= soul then
doTransformItem(item.uid,egems[a])
doPlayerAddMana(cid,-mana)
doPlayerAddSoul(cid,-soul)
doSendMagicEffect(frompos,39)
else
doPlayerSendCancel(cid,"You dont have mana or soul points.")
end
else
return 2
end


elseif isInArray(egems, item.itemid)== TRUE then
for bb=1, #egems do
if item.itemid == egems[bb] then
b=bb
end
end
if isInArray(weapons, item2.itemid)== TRUE then
for cc=1, #weapons do
if item2.itemid == weapons[cc] then
c=cc
end
end
doTransformItem(item2.uid,eweapons[c][b],1000)
doSendMagicEffect(frompos,39)
doRemoveItem(item.uid,1)
else
doPlayerSendCancel(cid,"You can't enchanted this.")
end
else
return 0
end
return 1
end




Code responsible for "The Elemental Spheres Quest"




Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if isInArray({33268, 33269}, toPosition.x) and toPosition.y == 31830 and toPosition.z == 10 and player:getStorageValue(Storage.ElementalSphere.QuestLine) > 0 then
        if not isInArray(spheres[item.itemid], player:getVocation():getId()) then
            return false
        elseif isInArray({7915, 7916}, target.itemid) then
            player:say('Turn off the machine first.', TALKTYPE_MONSTER_SAY)
            return true
        else
            player:setStorageValue(Storage.ElementalSphere.MachineGemCount, math.max(1, player:getStorageValue(Storage.ElementalSphere.MachineGemCount) + 1))
            toPosition:sendMagicEffect(CONST_ME_PURPLEENERGY)
            item:transform(item.itemid, item.type - 1)
            return true
        end
    end


    if item.itemid == 2147 and target.itemid == 2342 then
        target:transform(2343)
        target:decay()
        item:remove(1)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        return true
    end


    if item.itemid == 7760 and isInArray({9934, 10022}, target.itemid) then
        target:transform(9933)
        item:remove(1)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        return true
    end


    if isInArray(enchantableGems, item.itemid) then
        local subtype = item.type
        if subtype == 0 then
            subtype = 1
        end


        local mana = config.manaCost * subtype
        if player:getMana() < mana then
            player:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
            return false
        end


        local soul = config.soulCost * subtype
        if player:getSoul() < soul then
            player:sendCancelMessage(RETURNVALUE_NOTENOUGHSOUL)
            return false
        end


        local targetId = table.find(enchantableGems, item.itemid)
        if not targetId or not isInArray(enchantingAltars[targetId], target.itemid) then
            return false
        end


        player:addMana(-mana)
        player:addSoul(-soul)
        item:transform(enchantedGems[targetId])
        player:addManaSpent(mana * configManager.getNumber(configKeys.RATE_MAGIC))
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
        return true
    end


    if item.itemid == 7761 and isInArray({9949, 9954}, target.itemid) then
        target:transform(target.itemid - 1)
        target:decay()
        item:remove(1)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        return true
    end


    if isInArray(enchantedGems, item.itemid) then
        if not isInArray(enchantableItems, target.itemid) then
            fromPosition:sendMagicEffect(CONST_ME_POFF)
            return false
        end


        local targetId = table.find(enchantedGems, item.itemid)
        if not targetId then
            return false
        end


        local subtype = target.type
        if not isInArray({2544, 8905}, target.itemid) then
            subtype = 1000
        end


        target:transform(enchantedItems[target.itemid][targetId], subtype)
        target:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        item:remove(1)
        return true
    end
    return false
end
 
Last edited:
Back
Top