Quest Teleporter Quest

Stato
Discussione chiusa ad ulteriori risposte.

OzMoMoH

Utente Emerald
14 Ottobre 2012
1,508
30
454
493
Buongiorno ragazzi, non so se sul sito esiste già una quest per il teleporter base , ma vedo che molti la cercano quindi ho scritto una piccola quest del teleporter da modificare a vostro piacimento!
Fatene buon uso ecco a voi!

Codice:
-- File: teleport.quest
-- Autore: KamiKaZe


quest teleport begin
    state __FUNC__ begin
        function translations()
            return
            {
                ["TITLE"] = string.format("%s",item_name(item.vnum)),
                ["LEVEL_IS_TO_LOW"] = "Il tuo livello è troppo basso per %s",
                ["LEVEL_IS_TO_HIGH"] = "Il tuo livello è troppo alto per %s",
                ["NOT_ENOUGH_YANG"] = "Hai bisogno %s Yang per %s",
                ["NO_ITEM"] = "Hai bisogno di questo oggetto per %s",
                ["COOLDOWN_NOT_FINISHED"] = "Devi aspettare %ss per essere trasportato di nuovo %s",
            }
            --
        end

        function settings()
            return
            {
                {
                    "Orc valley", -- map name
                    2560, -- globalX (get this from locale/xx/map/map_n_threeway/settings.txt without 00 at the end)
                    6656, -- globalY (get this from locale/xx/map/map_n_threeway/settings.txt without 00 at the end)
                    {1461,83}, -- {localX,localY}, -- Shinsoo
                    {144,743}, -- {localX,localY}, -- Chunjo
                    {653,1424}, -- {localX,localY}, -- Jinno
                    {1,0}, -- {min entry level,max entry level},
                    0, -- min yang req
                    {0,0}, -- {item vnum,item count}, -- item req for entry
                    10, -- entry cooldown for map (seconds)
                },
            }
            -- ####### QUI PUOI AGGIUNGERE ALTRE MAPPE #######
        end

        function get_local_pos(l1,l2,l3)
            local tempE = {}
            table.insert(tempE,l1)
            table.insert(tempE,l2)
            table.insert(tempE,l3)
            local e = pc.get_empire()
            return tempE[e]
        end

        function hasLevel(lvl)
            local ret = 0
            local level = pc.get_level()
            local minLvl = lvl[1]
            local maxLvl = lvl[2]

            if level > maxLvl and maxLvl != 0 then
                ret = 2
            end

            if level < minLvl then
                ret = 1
            end

            return ret
        end

        function hasYang(req)
            local yang = pc.get_money()
            if yang < req then
                return false
            end
            return true
        end

        function hasItem(itm)
            local i = itm[1]
            local c = itm[2]

            if i == 0 then return true end

            if pc.count_item(i) >= c then
                return true
            end
            return false
        end

        function display_go_back()
            local b = select("Go back","Nope")

            if b == 2 then return end
            if b == 1 then
                local translations = teleport.translations()
                local settings = teleport.settings()
                teleport.display_list(settings,translations)
            end
        end

        function display_list(tab,translations)
            -- indexes
            local mpN = 1 -- name of the map
            local glX = 2 -- global x pos
            local glY = 3 -- global y pos
            local lc1 = 4 -- local shinsoo pos
            local lc2 = 5 -- local chunjo pos
            local lc3 = 6 -- local jinno pos
            local lvl = 7 -- level req
            local yng = 8 -- yang req
            local itm = 9 -- item req
            local cd = 10 -- cooldown time seconds
            --

            local settings = tab
            local mapNames = {}

            for i in settings do table.insert(mapNames,settings[i][mpN]) end -- put the map names in table
            table.insert(mapNames,"close") -- insert the close button

            local s = select_table(mapNames)
            if s == table.getn(mapNames) then
                return
            else
                glX = settings[s][glX]
                glY = settings[s][glY]
                lc1 = settings[s][lc1]
                lc2 = settings[s][lc2]
                lc3 = settings[s][lc3]
                lvl = settings[s][lvl]
                yng = settings[s][yng]
                itm = settings[s][itm]
                cd = settings[s][cd]
                local hasLvl = teleport.hasLevel(lvl)
                local hasYang = teleport.hasYang(yng)
                local hasItem = teleport.hasItem(itm)
                local lPos = teleport.get_local_pos(lc1,lc2,lc3)

                if hasLvl == 1 then
                    say_title(translations["TITLE"])
                    say_reward(string.format(translations["LEVEL_IS_TO_LOW"],settings[s][mpN]))
                    teleport.display_go_back()
                    return
                elseif hasLvl == 2 then
                    say_title(translations["TITLE"])
                    say_reward(string.format(translations["LEVEL_IS_TO_HIGH"],settings[s][mpN]))
                    teleport.display_go_back()
                    return
                end

                if hasYang == false then
                    say_title(translations["TITLE"])
                    say_reward(string.format(translations["NOT_ENOUGH_YANG"],yng,settings[s][mpN]))
                    teleport.display_go_back()
                    return
                end

                if hasItem == false then
                    say_title(translations["TITLE"])
                    say_reward(string.format(translations["NO_ITEM"],settings[s][mpN]))
                    say_item_vnum(itm[1])
                    teleport.display_go_back()
                    return
                end

                local cooldown = pc.getqf(string.format("teleport_cooldown_%s",s))
                if get_time() < cooldown then
                    say_title(translations["TITLE"])
                    say_reward(string.format(translations["COOLDOWN_NOT_FINISHED"],cooldown-get_time(),settings[s][mpN])) -- function for time format(nicer time) is not included in this quest, it displays just seconds
                    teleport.display_go_back()
                    return
                end

                pc.warp((glX + lPos[1] )* 100, (glY + lPos[2]) * 100)
                if cd != 0 then
                    pc.setqf(string.format("teleport_cooldown_%s",s),get_time()+cd)
                end
            end
        end
    end

    state start begin
        when 70030.use begin
            local translations = teleport.translations()
            local settings = teleport.settings()

            teleport.display_list(settings,translations)
        end
    end
end
 
Are you sure that you are the creator for this quest?

fkcredits.png
 
  • Mi piace
Reazioni: NewRazer
Stato
Discussione chiusa ad ulteriori risposte.