Jump to content
  • 0

[Problem]Functions in Quests doesnt work


Human

Question

Hello Guys, 
As title states the functions in quest is not working in most cases 
for eg.. 
 

Spoiler

quest guild_building_melt begin
    state start begin
        function GetOreRefineCost(cost)
            if pc.empire != npc.empire then
                return 3 * cost
            end
            if pc.get_guild() == npc.get_guild() then
                return cost * 0.9
            end
            return cost
        end

        function GetOreRefineGoodPct()
            return 60
        end

        function GetOreRefineBadPct()
            return 30
        end

        function GetMyRefineNum(race)
            return({
                [20060] = 50601,
                [20061] = 50602,
                [20062] = 50603,
                [20063] = 50604,
                [20064] = 50605,
                [20065] = 50606,
                [20066] = 50607,
                [20067] = 50608,
                [20068] = 50609,
                [20069] = 50610,
                [20070] = 50611,
                [20071] = 50612,
                [20072] = 50613,
                [33009] = 50614,
                [33010] = 50615,
                [33011] = 50616,
                [33012] = 50617,
                [33013] = 50618
            })[race]
            --return race - 20060 + 50601 or race - 33009 + 50614


        end


        function IsRefinableRawOre(vnum)
            return vnum >= 50601 and vnum <= 50618
        end

        function DoRefineDiamond(pct)
            local from_postfix
            local from_name = item_name(item.vnum)
            local to_vnum = item.vnum + 20
            local to_name = item_name(to_vnum)
            local to_postfix

            if under_han(from_name) then
                from_postfix = "something"
            else
                from_postfix = "something"
            end

            if under_han(to_name) then
                to_postfix = "after"
            else
                to_postfix = "with"
            end
            say_title("Alchemist:")
            say("")
            say("You must collect 100 " .. from_name .." so I can")
            say("produce "..to_name .. ".")
            say("")
            if item.count >= 100 then
                say("The success rate is "..pct.."% and you need "..guild_building_melt.GetOreRefineCost(10000).." Yang.")
                say("")
                say("Do you want to try it?")
                say("")
                local s = select("Yes", "No")
                if s == 1 then
                    if pc.get_gold() < guild_building_melt.GetOreRefineCost(10000) then
                        say_title("Alchemist:")
                        say("")
                        say("Sorry but you need more Yang. It's not free.")
                        say("")
                        return
                    end

                    if pc.diamond_refine(10000, pct) then
                        say_title("Alchemist:")
                        say("")
                        say("Congratulations - the refining was successful!")
                        say("")
                        say("You now have:")
                        say("")
                        say_item(to_name, to_vnum, "")
                        say("")
                    else
                        say_title("Alchemist:")
                        say("")
                        say("The refining was not successful. Sorry.")
                        say("")
                    end
                end
            else
                say("First collect 100 ores.")
            end
        end
        function DoRefine(pct)
            local from_postfix
            local from_name = item_name(item.vnum)
            local to_vnum = item.vnum + 20
            local to_name = item_name(to_vnum)
            local to_postfix

            if under_han(from_name) then
                from_postfix = "Object"
            else
                from_postfix = "Object"
            end

            if under_han(to_name) then
                to_postfix = "After"
            else
                to_postfix = "With"
            end
            say_title("Alchemist:")
            say("")
            say("You must collect 100 " .. from_name .." and a")
            say("Spirit Stone +0, +1 or +2 to produce "..to_name..".")
            say("")
            if item.count >= 100 then
                say("There is a "..pct.."% chance to succeed and you")
                say("need "..guild_building_melt.GetOreRefineCost(3000).." Yang.")
                say("")
                say("Do you want to try it?")
                say("")
                local s = select("Yes", "No")
                if s == 1 then
                    if pc.get_gold() < guild_building_melt.GetOreRefineCost(3000) then
                        say_title("Alchemist:")
                        say("")
                        say("Sorry, you need more Yang for this.")
                        say("")
                        return
                    end

                    local selected_item_cell = select_item()
                    if selected_item_cell == 0 then
                        say_title("Alchemist:")
                        say("")
                        say("Find the required materials and then talk to me.")
                        say("")
                        return
                    end
                    local old_item = item.get_id()

                    if not item.select_cell(selected_item_cell) then
                        say_title("Alchemist:")
                        say("")
                        say("That is not the item that is needed.")
                        say("")
                        return
                    end

                    -- check whether the material is
                    if item.vnum < 28000 or item.vnum >= 28300 then
                        say_title("Alchemist:")
                        say("")
                        say("You have chosen the wrong item.")
                        say("")
                        return
                    end

                    item.select(old_item)

                    if pc.ore_refine(3000, pct, selected_item_cell) then
                        ----"123456789012345678901234567890123456789012345678901234567890"|
                        say_title("Alchemist:")
                        say("")
                        say("Congratulations - the refining was successful!")
                        say("")
                        say("You now have:")
                        say("")
                        say_item(to_name, to_vnum, "")
                        say("")
                        return
                    else
                        say_title("Alchemist:")
                        say("")
                        say("The refining was not successful. Sorry!")
                        say("")
                        return
                    end
                end
            else
                wait()
                say_title("Alchemist:")
                say("")
                say_reward("Collect the required materials first.")
                say("")
                return
            end
        end

        when 20060.take or 20061.take or 20062.take or 20063.take or 20064.take or 20065.take or 20066.take or
             20067.take or 20068.take or 20069.take or 20070.take or 20071.take or 20072.take or 
             33009.take or 33010.take or 33011.take or 33012.take or 33013.take
            with guild_building_melt.IsRefinableRawOre(item.vnum) begin
            --Good

            if guild_building_melt.GetMyRefineNum(npc.race) == item.vnum then

                if item.vnum == 50601 then
                    guild_building_melt.DoRefineDiamond(guild_building_melt.GetOreRefineGoodPct())
                else
                    guild_building_melt.DoRefine(guild_building_melt.GetOreRefineGoodPct())
                end
            else--Bad


                if item.vnum == 50601 then
                    guild_building_melt.DoRefineDiamond(guild_building_melt.GetOreRefineBadPct())
                else
                    guild_building_melt.DoRefine(guild_building_melt.GetOreRefineBadPct())
                end
            end
        end

        when 20060.click or 20061.click or 20062.click or 20063.click or 20064.click or 20065.click or 20066.click or
             20067.click or 20068.click or 20069.click or 20070.click or 20071.click or 20072.click or 
             33009.click or  33010.click or 33011.click or  33012.click or 33013.click begin

            if npc.get_guild() == pc.get_guild() and pc.isguildmaster() then
                say_title("Alchemist:")
                say("")
                say("If you own 3.000.000 Yang, you can replace your ")
                say("current alchemist with a different one.")
                say("")
                wait()
                if pc.get_gold() < 3000000 then
                    say_title("Alchemist:")
                    say("")
                    say_reward("Bring me 3.000.000 Yang.")
                    say("")
                    return
                end
                local sel = 0
                local timetable1 = {"Diamonds", "Fossils", "Copper", "Silver", "Gold", "Jade", "Next", "Close"}
                local valuetable1 = {14043, 14045, 14046, 14047, 14048, 14049, 1, 3}
                local timetable2 = {"Ebony", "Pearls", "White Gold", "Crystal", "Amethyst", "Next", "Back", "Close"}
                local valuetable2 = {14050, 10451, 14052, 14053, 14054, 2, 0, 3}
                local timetable3 = {"Heaven's Tear", "Soul Crystal", "Ruby", "Garnet", "Emerald", "Sapphire", "Back", "Close"}
                local valuetable3 = {14055, 26992, 26993, 26994, 26995, 26996, 1, 3}                repeat
                    say_size(300, 350)
                    say_title("System:")
                    say("Which Alchemist do you want to create?")
                    if sel == 0 then
                        local s = select_table(timetable1)
  

In this quest the guild alchemist not taking any ore say " Diamond alchemist is not taking any diamond ore " rather when i click it says the last sentence " come back anytime" and not refining.. same for many other quest.. Could anyone tell me whats the problem? 
Hope i get solution by someone 
thanks in advance 

Human

Link to comment
Share on other sites

  • Answers 0
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

Popular Days

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.