Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Rekomendowane odpowiedzi

Opublikowano

Witam, orientuje sie może ktoś co jest nie tak w tym queście?

.quest

Spoiler

quest pet_system begin
    state start begin
        when login begin
            cmdchat("ManagerPetSystem Quest|"..q.getcurrentquestindex())
            for i = 53001, 53025 do if pc.count_item(i) >0 then Pet_S.GetPetFolder() end end
            Pet_S.SetItemsDescBonus()
        end
        
        when button or info begin
            cmdchat("ManagerPetSystem Input|1")
            local sema = input(cmdchat("ManagerPetSystem Reload|")) -- Obtiene la accion a realizar de la pet
            local sema2 = string.split(sema, "|") -- Hace split y obtiene el texto claro
            cmdchat("ManagerPetSystem Input|0")
            if is_test_server then syschat(tostring(sema2[1])) end
            
            if tostring(sema2[1]) == "Remove_Slot" then
                Pet_S.Recoger_Items(sema2[2],sema2[3])
                Pet_S.ReloadGui()
            elseif tostring(sema2[1]) == "Remove_Bonus" then
                Pet_S.Remove_Bonus(sema2[2],sema2[3],sema2[4],sema2[5],sema2[6])
            elseif tostring(sema2[1]) == "ReloadBonusAndItems" then
                Pet_S.ReloadBonus(sema2[2],sema2[3],sema2[4],sema2[5],sema2[6])
            elseif tostring(sema2[1]) == "No hacer nada" then
                pet.set_attack(0)
            elseif tostring(sema2[1]) == "Recoger Items & Yang (lv 30)" then
                pet.set_attack(0)
            elseif tostring(sema2[1]) == "Atacar Mobs & Players (lv 100)" then
                pet.set_attack(1)
            elseif tostring(sema2[1]) == "Skill_PointUp" then
                Pet_S.SetSkillPoint(tonumber(sema2[2])+1)
            elseif tostring(sema2[1]) == "Button_Options" then
                Pet_S.SetButton(tonumber(sema2[2])+1,sema2[3])
            end
        end
        --[[
            Exp
        --]]
        when kill with pc.getqf("pet_spawn") != 0 and pet.count_summoned() > 0 begin
            -- if Pet_S.Get_Level(pc.getqf("pet_spawn")) -10 <= npc.get_level() and Pet_S.Get_Level(pc.getqf("pet_spawn")) +10 >= npc.get_level() or is_test_server or pc.is_gm() then -- ahora solo gana exp si el mob es del mismo lv que la pet y no el player
            if pc.get_level() -10 <= npc.get_level() and pc.get_level() +10 >= npc.get_level() or is_test_server or pc.is_gm() then
                pet.show_exp(1)
                Pet_S.Set_Exp(pet.get_exp())
            else
                pet.show_exp(0)
            end
        end
        --[[
            Items
        --]]
        when 31950.use or 31951.use or 31952.use or 31953.use or 31954.use 
        or 31955.use or 31956.use or 31957.use or 31958.use or 31959.use
        or 31960.use or 31961.use or 31962.use or 31963.use or 31964.use or 31965.use
        or 31966.use or 31967.use or 31968.use or 31969.use or 31970.use or 31971.use
        or 31972.use or 31973.use or 31974.use or 31975.use or 31976.use or 31977.use
        or 31978.use or 31979.use with pc.getqf("pet_spawn") != 0 begin
            local pet, vnum = pc.getqf("pet_spawn"), item.vnum
            local pet_level
            for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..pet.."/lv") do pet_level = line end
            if tonumber(pet_level) >= tonumber(Pet_S.GetSlotsPosition(vnum, 5)) then
                if pc.getqf("pet_system_slot_ocuped_"..tostring(pet).."_"..tostring(Pet_S.GetSlotsPosition(tonumber(vnum),1))) != 0 then syschat("Este slot ya esta ocupado, deberas quitar el item para poner otro.") return end
                Pet_S.SetItem(item.get_vnum())
                item.remove()
            else
                syschat("Su mascota no tiene nivel suficiente como para usar este item.")
                return
            end
        end
        
        when pet_system_dead.timer begin
            if pc.is_dead() or pet.count_summoned() == 0 then
                for i = 1, 5 do Pet_S.Desactive_Bonus(i) end
                cmdchat("ManagerPetSystem GetItemsVnumsAndSlots|")
                cmdchat("ManagerPetSystem ClearSlots|")
                cmdchat("ManagerPetSystem Pet_Level|0")
                cmdchat("ManagerPetSystem Hide|")
                pc.delqf("pet_spawn")
                pc.delqf("pet_hp")
                cleartimer("pet_system_dead")
                pet.set_attack(0)
            else
                if pc.count_item(pc.getqf("pet_spawn")) == 0 then
                    for i = 1, 5 do Pet_S.Desactive_Bonus(i) end
                    cmdchat("ManagerPetSystem GetItemsVnumsAndSlots|")
                    cmdchat("ManagerPetSystem ClearSlots|")
                    cmdchat("ManagerPetSystem Pet_Level|0")
                    cmdchat("ManagerPetSystem Hide|")
                    pc.delqf("pet_spawn")
                    pc.delqf("pet_hp")
                    cleartimer("pet_system_dead")
                    pet.set_attack(0)
                end
                if pc.getqf("pet_hp") >0 and pet.count_summoned() >0 then
                    cmdchat("ManagerPetSystem Pet_Hp|"..npc.get_hp_by_vid(pc.getqf("pet_hp")))
                end
            end
        end
        --[[
            Pets
        --]]
        when logout with pc.getqf("pet_spawn") != 0 and pet.count_summoned() > 0 begin
            for i = 1, 5 do Pet_S.Desactive_Bonus(i) end
            cmdchat("ManagerPetSystem GetItemsVnumsAndSlots|")
            cmdchat("ManagerPetSystem ClearSlots|")
            cmdchat("ManagerPetSystem Pet_Level|0")
            cmdchat("ManagerPetSystem Hide|")
            pc.delqf("pet_spawn")
            pc.delqf("pet_hp")
            pet.set_attack(0)
        end
        
        when 38200.use or 38201.use or 53007.use or 53013.use or 53012.use or 53011.use or 53010.use or 53006.use  or 53005.use or 53002.use or 53001.use or 53003.use or 53008.use or 53009.use or
            53014.use or 53015.use  or 53016.use or 53017.use or 53022.use or 53023.use or 53024.use or 53025.use begin
            local pet_info = Pet_S.Get_Pet_Info(item.vnum)
            if null != pet_info then

                local mobVnum = pet_info[1]
                local petName = pet_info[2]
                local spawn_effect_file_name = Pet_S.Get_Spawn_Effect_File(pet_info[3])
                if pet.is_summon(mobVnum) then
                    cleartimer("pet_system_dead")
                    pet.unsummon(mobVnum)
                    cmdchat("ManagerPetSystem Hide|")
                    for i = 1, 5 do Pet_S.Desactive_Bonus(i) end
                    cmdchat("ManagerPetSystem GetItemsVnumsAndSlots|")
                    cmdchat("ManagerPetSystem ClearSlots|")
                    cmdchat("ManagerPetSystem Pet_Level|0")
                    cmdchat("ManagerPetSystem Hide|")
                    pc.delqf("pet_spawn")
                    pc.delqf("pet_hp")
                    pet.set_attack(0)
                else
                    if pet.count_summoned() < 1 then
                        Pet_S.Registro(item.vnum)
                        if pc.getqf("pet_system_name_"..item.vnum) == 1 then
                            pet.summon(mobVnum, " Lv "..Pet_S.Get_Level(item.vnum).." "..Pet_S.GetPetName(item.vnum), false)
                        else
                            pet.summon(mobVnum, " Lv "..Pet_S.Get_Level(item.vnum).." "..petName, false)
                        end
                        pc.setqf("pet_spawn", item.vnum)
                        pet.spawn_effect(mobVnum, spawn_effect_file_name)
                        loop_timer("pet_system_dead", 0.5)
                        Pet_S.ReloadGui()
                        Pet_S.ReloadItems()
                        Pet_S.SetLevelConstant()
                        for i = 1, 5 do Pet_S.GetSkillInfo(i) end
                        for i = 1, 5 do Pet_S.Active_Bonus(i) end
                    else
                        syschat("Usted ya tiene una mascota fuera.")
                    end
                end
            end
        end
        --[[
            Pet Is Mine
        --]]
        when 34001.click or 34002.click or 34003.click or 34004.click or 34005.click or 34006.click
            or 34007.click or 34008.click or 34009.click or 34010.click or 34011.click or 34012.click
            or 34013.click or 34014.click or 34015.click or 34016.click or 34021.click or 34022.click
            or 34023.click or 34024.click begin
            if pet.is_mine() then    
                local pet = pc.getqf("pet_spawn")
                local pet_info = Pet_S.Get_Pet_Info(pet)
                local petImg = pet_info[4]
                local petImg2 = pet_info[5]
                pc.setqf("pet_hp", npc.get_vid())
                cmdchat("ManagerPetSystem SetImg|"..petImg)
                cmdchat("ManagerPetSystem SetImg2|"..petImg2)
                cmdchat("ManagerPetSystem Pet_Hp|"..npc.get_hp_by_vid(pc.getqf("pet_hp")))
                cmdchat("ManagerPetSystem Pet_Max_Hp|"..npc.get_max_hp_by_vid(pc.getqf("pet_hp")))
                cmdchat("ManagerPetSystem SetSkillPoints|"..pc.getqf("pet_system_status_points_"..pc.getqf("pet_spawn")))
                cmdchat("ManagerPetSystem Show|")
            end
        end
    end
end

.lua

Spoiler

Pet_S = Pet_S or {}

function Pet_S.GetPath() -- ruta hacia la carpeta io/Pet_System
    return "cd /usr/home/mt2/share/locale/poland/quest/io/Pet_System" -- sin la / al final
end

function Pet_S.GetPath2() -- ruta hacia la carpeta io/Pet_System
    return "/usr/home/mt2/share/locale/poland/quest/io/Pet_System" -- sin la / al final
end

function Pet_S.Registro(item)
    local folder = io.open(Pet_S.GetPath2().."/"..pc.get_name(), "r")
    if folder == nil then
        os.execute("mkdir "..get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name())
    end
    local mascota = pc.getqf("pet_spawn")
    local check
    local sema = io.open(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/pet_system.sh", "w")
    sema:write("#!/bin/bash \n")
    sema:write("FILE=./"..tostring(item).."/lv \n")
    sema:write("if [ -f $FILE ]; then \n")
    sema:write("echo 1 >>pet_system_ \n")
    sema:write("else \n")
    sema:write("echo 0 >>pet_system_ \n")
    sema:write("fi \n")
    sema:close()

    os.execute(Pet_S.GetPath().."/"..pc.get_name().."/ && chmod 777 pet_system.sh")
    os.execute(Pet_S.GetPath().."/"..pc.get_name().."/ && sh pet_system.sh")
    for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/pet_system_") do check = line end

    if tonumber(check) == 0 then
        syschat("Archivos para la mascota creados con éxito.")
        os.execute("mkdir "..get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name())
        os.execute("mkdir "..get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..tostring(item))
        local file = io.open(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..tostring(item).."/lv","w") file:write("1") file:close()
        local file2 = io.open(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..tostring(item).."/exp","w") file2:write("0") file2:close()
        pc.setqf("pet_system_status_points_"..mascota, 0)
        for i = 1, 5 do
            local file = io.open(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..tostring(item).."/skill"..tostring(i),"w")
            file:write(Pet_S.GetFirstSkill(tonumber(item),i))
            file:close()
        end
    end
    os.execute(Pet_S.GetPath().."/"..pc.get_name().."/ && rm -rf pet_system.sh && rm -rf pet_system_")
end

function Pet_S.SetItem(item) -- working
    local tiempo = 3600*2
    local pet = pc.getqf("pet_spawn")
    cmdchat("ManagerPetSystem Item|"..Pet_S.GetSlotsPosition(item,1).."|"..tostring(item))
    affect.add_collect(Pet_S.GetSlotsPosition(item,2), Pet_S.GetSlotsPosition(item,3), tiempo)
    pc.setqf("pet_system_bonus_"..tostring(pet).."_"..tostring(Pet_S.GetSlotsPosition(item,1)).."_"..tostring(item), 1)
    pc.setqf("pet_system_slot_ocuped_"..tostring(pet).."_"..tostring(Pet_S.GetSlotsPosition(item,1)), 1)
end

function Pet_S.Get_Level(pet)
    local pet_level
    for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..pet.."/lv") do pet_level = line end
    return pet_level
end

function Pet_S.SetPetName() -- working
    say("Hola "..pc.get_name())
    say("Desea renombrar a su mascota?")
    local a = select("Si", "No")
    if a == 1 then
        local pet_item = pc.getqf("pet_spawn")
        say("Escriba el nombre que le quiere dar a su mascota.")
        local s = input()
        if s == "" then say("Debes escribir algo") return end
        say("Su mascota se va a llamar "..s)
        local file = io.open(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..pet_item.."/name", "w") file:write(tostring(s)) file:close()
        pc.setqf("pet_system_name_"..pet_item, 1)
        item.remove()
    else
        say("Bueno, en otro momento quizas...")
    end
end

function Pet_S.GetPetName(item) -- working
    local name
    for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..item.."/name", "r") do name = line end
    -- syschat(tostring(name))
    return tostring(name)
end

function Pet_S.Remove_Bonus(slot0,slot1,slot2,slot3,slot4) -- working
    local pet = pc.getqf("pet_spawn")
    local tiempo = 3600*2
    -- syschat(slot0.."_"..slot1.."_"..slot2.."_"..slot3.."_"..slot4)
    for vnum = 31950, 31979 do -- vnums de los items, aumentar cuando se pongan mas
        if tonumber(slot0) == vnum or tonumber(slot1) == vnum or tonumber(slot2) == vnum or tonumber(slot3) == vnum or tonumber(slot4) == vnum then
            affect.remove_collect(Pet_S.GetSlotsPosition(tonumber(vnum),2), Pet_S.GetSlotsPosition(tonumber(vnum),3), tiempo) -- borramos el bonus
            -- syschat(tostring(Pet_S.GetSlotsPosition(tonumber(vnum),2)).."_"..tostring(Pet_S.GetSlotsPosition(tonumber(vnum),3)))
        end
    end
end

function Pet_S.Recoger_Items(slot, vnum) -- working
    local pet = pc.getqf("pet_spawn")
    local tiempo = 3600*2
    pc.give_item2(vnum)
    affect.remove_collect(Pet_S.GetSlotsPosition(tonumber(vnum),2), Pet_S.GetSlotsPosition(tonumber(vnum),3), tiempo) -- borramos el bonus
    pc.setqf("pet_system_bonus_"..tostring(pet).."_"..tostring(Pet_S.GetSlotsPosition(tonumber(vnum),1)).."_"..tostring(vnum), 0)
    pc.setqf("pet_system_slot_ocuped_"..tostring(pet).."_"..tostring(Pet_S.GetSlotsPosition(tonumber(vnum),1)), 0)
end

function Pet_S.ReloadBonus(slot0,slot1,slot2,slot3,slot4) -- working
    local tiempo = 3600*2
    local pet = pc.getqf("pet_spawn")
    -- syschat(slot0.."_"..slot1.."_"..slot2.."_"..slot3.."_"..slot4)
    for vnum = 31950, 31979 do -- vnums de los items, aumentar cuando se pongan mas
        if tonumber(slot0) == vnum or tonumber(slot1) == vnum or tonumber(slot2) == vnum or tonumber(slot3) == vnum or tonumber(slot4) == vnum then
            -- syschat(tostring(vnum))
            affect.add_collect(Pet_S.GetSlotsPosition(vnum,2), Pet_S.GetSlotsPosition(vnum,3), tiempo)
            -- syschat(tostring(Pet_S.GetSlotsPosition(tonumber(vnum),2)).."_"..tostring(Pet_S.GetSlotsPosition(tonumber(vnum),3)))
        end
    end
end

function Pet_S.ReloadItems() -- working
    local tiempo = 3600*2
    local pet = pc.getqf("pet_spawn")
    for vnum = 31950, 31979 do -- vnums de los items, aumentar cuando se pongan mas
        if pc.getqf("pet_system_bonus_"..tostring(pet).."_"..tostring(Pet_S.GetSlotsPosition(tonumber(vnum),1)).."_"..tostring(vnum)) == 1 then
            -- syschat("pet_system_bonus_"..tostring(pet).."_"..tostring(Pet_S.GetSlotsPosition(tonumber(vnum),1)).."_"..tostring(vnum))
            cmdchat("ManagerPetSystem Item|"..Pet_S.GetSlotsPosition(vnum,1).."|"..tostring(vnum))
        end
    end
    cmdchat("ManagerPetSystem ReloadBonusAndItems|")
end

function Pet_S.Set_Exp(experiencia) -- subir la dificultad de la exp
    local mascota = pc.getqf("pet_spawn")
    local pet_level, exp
    
    for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..mascota.."/lv") do pet_level = line end
    for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..mascota.."/exp") do exp = line end
    
    -- Si la mascota es mayor de nivel 100 ( el maximo, return )
    if tonumber(pet_level) >= 100 then
        return
    end
    
    local pet_info = Pet_S.Get_Pet_Info(tonumber(mascota))
    local mob_vnum = pet_info[1]
    
    local exp_necesaria = tonumber(Pet_S.Get_Exp_Table(pet_level))
    local give_exp = exp_necesaria / number(20,60) -- para test, normal ampliar mas
    local exp2 = math.floor(exp)
    -- local give_exp2 = math.floor(give_exp)
    local give_exp2 = experiencia
    local exp_actual = tonumber(exp2+give_exp2)
    local file = io.open(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..tostring(mascota).."/exp","w") file:write(tostring(tonumber(exp2+give_exp2))) file:close()
    
    if is_test_server then
        syschat("---------Debug-----------")
        syschat("MobVnum: "..tostring(mob_vnum))
        syschat("Pet_Level: " ..tostring(pet_level))
        syschat("Pet_Exp: "..tostring(exp2))
        syschat("Experiencia Ganada: "..tostring(give_exp2))
        syschat("Pet_Exp_Necesaria: "..tostring(tonumber(Pet_S.Get_Exp_Table(pet_level))))
        syschat("Experienca actual de la pet: "..tostring(exp_actual))
        syschat("-------------------------")
    end

    -- Comprobamos el 25, 50, 75% y hacemos el efecto de subir bola
    local mobVnum = pet_info[1]
    local spawn_effect_file_name = Pet_S.Get_Spawn_Effect_File(1)
    
    if exp_actual >= tonumber(Pet_S.Get_Exp_Table(pet_level))*(25/100) and pc.getqf("pet_system_25_"..mascota) != 1 then
        pet.spawn_effect(mobVnum, spawn_effect_file_name)
        pc.setqf("pet_system_25_"..mascota,1)
    elseif exp_actual >= tonumber(Pet_S.Get_Exp_Table(pet_level))*(50/100) and pc.getqf("pet_system_50_"..mascota) != 1 then
        pet.spawn_effect(mobVnum, spawn_effect_file_name)
        pc.setqf("pet_system_50_"..mascota,1)
    elseif exp_actual >= tonumber(Pet_S.Get_Exp_Table(pet_level))*(75/100) and pc.getqf("pet_system_75_"..mascota) != 1 then
        pet.spawn_effect(mobVnum, spawn_effect_file_name)
        pc.setqf("pet_system_75_"..mascota,1)
    end

    -- Subimos de nivel a la mascota si su experiencia actual es mayor o igual que la experiencia necesaria para subir de nivel
    if exp_actual >= tonumber(Pet_S.Get_Exp_Table(pet_level)) then
        local file2 = io.open(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..tostring(mascota).."/exp","w") file2:write("0") file2:close()
        local mobVnum = pet_info[1]
        local mobName = pet_info[2]
        syschat("Su mascota "..tostring(mobName).." ha subido al nivel "..tostring(tonumber(pet_level+1)))
        syschat("Ha ganado un punto de estado.")
        pc.setqf("pet_system_status_points_"..pc.getqf("pet_spawn"), pc.getqf("pet_system_status_points_"..pc.getqf("pet_spawn"))+1)
        cmdchat("ManagerPetSystem SetSkillPoints|"..pc.getqf("pet_system_status_points_"..pc.getqf("pet_spawn")))
        local file = io.open(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..tostring(mascota).."/lv","w") file:write(tostring(tonumber(pet_level+1))) file:close()
        local spawn_effect_file_name = Pet_S.Get_Spawn_Effect_File(2)
        pet.spawn_effect(mobVnum, spawn_effect_file_name)
        pc.setqf("pet_system_25_"..mascota,0)
        pc.setqf("pet_system_50_"..mascota,0)
        pc.setqf("pet_system_75_"..mascota,0)
    end
    Pet_S.SetLevelConstant()
    Pet_S.ReloadGui()
end

function Pet_S.Is_Mine() -- working
    cmdchat("ManagerPetSystem Input|1")
    local ret = tostring(input(cmdchat("PetIsMine "..tostring(npc.get_vid()))))
    cmdchat("ManagerPetSystem Input|0")
    if ret == "true" then return true
    elseif ret == "false" then return false
    else syschat("ERROR") end
end

function Pet_S.GetPetFolder() -- working
    local pet_level
    local sema = io.open(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/pet_system.sh", "w") sema:write("#!/bin/bash \n") sema:write("ls >>pet_system_") sema:close()
    
    os.execute(Pet_S.GetPath().."/"..pc.get_name().."/ && chmod 777 pet_system.sh")
    os.execute(Pet_S.GetPath().."/"..pc.get_name().."/ && sh pet_system.sh")
    
    for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/pet_system_") do
        for i = 53001, 53025 do -- aqui vnums de los items de las pets
            if tonumber(line) == i then
                for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..i.."/lv") do pet_level = line end
                cmdchat("ManagerPetSystem SetLevelItem|"..line.."|"..pet_level)
            end
        end
    end
    os.execute(Pet_S.GetPath().."/"..pc.get_name().."/ && rm -rf pet_system.sh && rm -rf pet_system_")
end

function Pet_S.SetLevelConstant() -- working
    local pet = pc.getqf("pet_spawn")
    local pet_level
    for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..pet.."/lv") do pet_level = line end
    cmdchat("ManagerPetSystem Pet_Level|"..pet_level)
end

function Pet_S.SetItemsDescBonus() -- working
    for i = 31950, 31979 do
        cmdchat("ManagerPetSystem DescBonus|"..i.."|"..tostring(Pet_S.GetSlotsPosition(i, 4)))
        cmdchat("ManagerPetSystem LvItemsPet|"..i.."|"..tostring(Pet_S.GetSlotsPosition(i, 5)))
    end
end

function Pet_S.ReloadGui() -- working
    local mascota = pc.getqf("pet_spawn") -- vnum del sello & vnum de la carpeta del sistema.
    local pet_level, exp
    for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..mascota.."/lv") do pet_level = line end
    for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..mascota.."/exp") do exp = line end
    local exp2 = math.floor(exp)
    cmdchat("ManagerPetSystem Nivel|"..pet_level)
    cmdchat("ManagerPetSystem Exp|"..exp2)
    cmdchat("ManagerPetSystem T.Exp|"..Pet_S.Get_Exp_Table(pet_level)-exp2)
    cmdchat("ManagerPetSystem SetLevelItem|"..mascota.."|"..pet_level)
end

function Pet_S.Get_Exp_Table(lvl) -- working
    local pet_exp_table = 
        {
            [1] = 300, [2] = 800, [3] = 1500, 
            [4] = 2500, [5] = 4300, [6] = 7200, 
            [7] = 11000, [8] = 17000, [9] = 24000, 
            [10] = 33000, [11] = 43000, [12] = 58000, 
            [13] = 76000, [14] = 100000, [15] = 130000, 
            [16] = 169000, [17] = 219000, [18] = 283000, 
            [19] = 365000, [20] = 472000, [21] = 610000, 
            [22] = 705000, [23] = 813000, [24] = 937000, 
            [25] = 1077000, [26] = 1237000, [27] = 1418000, 
            [28] = 1624000, [29] = 1857000, [30] = 2122000,
            [31] = 2421000, [32] = 2761000, [33] = 3145000, 
            [34] = 3580000, [35] = 4073000, [36] = 4632000, 
            [37] = 5194000, [38] = 5717000, [39] = 6264000, 
            [40] = 6837000, [41] = 7600000, [42] = 8274000, 
            [43] = 8990000, [44] = 9753000, [45] = 10560000, 
            [46] = 11410000, [47] = 12320000, [48] = 13270000, 
            [49] = 14280000, [50] = 15340000, [51] = 16870000, 
            [52] = 18960000, [53] = 19980000, [54] = 21420000, 
            [55] = 22930000, [56] = 24580000, [57] = 26200000, 
            [58] = 27960000, [59] = 29800000, [60] = 32780000,
            [61] = 36060000, [62] = 39670000, [63] = 43640000, 
            [64] = 48000000, [65] = 52800000, [66] = 58080000, 
            [67] = 63890000, [68] = 70280000, [69] = 77310000, 
            [70] = 85040000, [71] = 93540000, [72] = 102900000, 
            [73] = 113500000, [74] = 121000000, [75] = 137000000, 
            [76] = 150700000, [77] = 165700000, [78] = 236990000, 
            [79] = 260650000, [80] = 286780000,    [81] = 315000000, 
            [82] = 346970000, [83] = 381680000, [84] = 419770000, 
            [85] = 461760000, [86] = 508040000, [87] = 558740000, 
            [88] = 614640000, [89] = 676130000, [90] = 743130000,
            [91] = 1041222000, [92] = 1145344200, [93] = 1259878620, 
            [94] = 1385866482, [95] = 1524453130, [96] = 1676898443, 
            [97] = 1844588288, [98] = 2029047116, [99] = 2029047116, 
            [100] = 2029047116, [101] = 2029047116, [102] = 2029047116, 
            [103] = 2029047116, [104] = 2029047116, [105] = 2029047116, 
            [106] = 2029047116, [107] = 2029047116, [108] = 2029047116, 
            [109] = 2029047116, [110] = 2029047116, [111] = 2029047116, 
            [112] = 2029047116, [113] = 2029047116, [114] = 2029047116, 
            [115] = 2029047116, [116] = 2029047116, [117] = 2029047116, 
            [118] = 2029047116, [119] = 2029047116, [120] = 2029047116,
            [121] = 2029047116, [122] = 2029047116, [123] = 2029047116, 
            [124] = 2029047116, [125] = 2029047116, [126] = 2029047116, 
            [127] = 2029047116, [128] = 2029047116, [129] = 2029047116, 
            [130] = 2029047116, [131] = 2029047116, [132] = 2029047116, 
            [133] = 2029047116, [134] = 2029047116, [135] = 2029047116, 
            [136] = 2029047116, [137] = 2029047116, [138] = 2029047116, 
            [139] = 2029047116, [140] = 2029047116, [141] = 2029047116, 
            [142] = 2029047116, [143] = 2029047116, [144] = 2029047116, 
            [145] = 2029047116, [146] = 2029047116, [147] = 2029047116, 
            [148] = 2029047116, [149] = 2029047116, [150] = 2029047116,
        }
    return pet_exp_table[tonumber(lvl)]
end

function Pet_S.Get_Spawn_Effect_File(idx) -- efectos
    local effect_table = {
        [0] = nil,
        [1] = "d:\\\ymir work\\\effect\\\etc\\\skillup\\\skillup_1.mse",
        [2] = "d:\\\ymir work\\\effect\\\etc\\\levelup_1\\\level_up.mse",
        [3] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_fenixfogo.mse",
        [4] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_fenixgelo.mse",
        [5] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_rena.mse",
        [6] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_azrael.mse",
        [7] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_khan.mse",
        [8] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_porky.mse",
        [9] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_rufus.mse",
        [10] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_leonidas.mse",
        [11] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_baobao.mse",
        [12] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_knuud.mse",
        [13] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_boney.mse",
        [14] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_miniexecutor.mse",
        [15] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_fenixverde.mse",
        [16] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_sheldon.mse",
        [17] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_cooper.mse",
        [18] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_pantera.mse",
        [19] = "d:\\\ymir work\\\effect\\\etc\\\pets\\\pet_leopardo.mse"

    }
    return effect_table [idx]
end

function Pet_S.SetSkillPoint(skill)
    local status = Pet_S.GetSkillInfoLua(skill,3)
    local max = Pet_S.GetSkillInfoLua(skill,4)
    local up = tostring(tonumber(status) +1)
    local string = Pet_S.GetSkillInfoLua(skill,1).."/"..Pet_S.GetSkillInfoLua(skill,2).."/"..up.."/"..Pet_S.GetSkillInfoLua(skill,4)
    if tonumber(status) >= tonumber(max) then syschat("Esta habilidad está al maximo.") cmdchat("ManagerPetSystem SetSkillPoints|"..pc.getqf("pet_system_status_points_"..pc.getqf("pet_spawn"))) return end
    if pc.getqf("pet_system_status_points_"..pc.getqf("pet_spawn")) >= 1 then
        Pet_S.Desactive_Bonus(skill)
        pc.setqf("pet_system_status_points_"..pc.getqf("pet_spawn"), pc.getqf("pet_system_status_points_"..pc.getqf("pet_spawn"))-1)
        cmdchat("ManagerPetSystem SetSkillPoints|"..pc.getqf("pet_system_status_points_"..pc.getqf("pet_spawn")))
        Pet_S.GetSkillInfo(skill)
        local file = io.open(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..tostring(pc.getqf("pet_spawn")).."/skill"..skill, "w")
        file:write(tostring(string))
        file:close()
        Pet_S.Active_Bonus(skill)
    else
        syschat("Usted no tiene puntos suficientes para subir esta habilidad.")
    end
end

function Pet_S.Active_Bonus(skill)
    local cantidad = Pet_S.GetSkillInfoLua(skill,3)
    local bonus = Pet_S.GetSkillInfoLua(skill,2)
    local tiempo = 3600*2

    if tonumber(bonus) == 1 or tonumber(bonus) == 2 then
        cantidad = cantidad * 100
    elseif tonumber(bonus) == 53 or tonumber(bonus) == 54 or tonumber(bonus) == 55 or tonumber(bonus) == 56 or tonumber(bonus) == 64 or tonumber(bonus) == 65 then
        cantidad = cantidad * 10
    end
    
    local string = bonus.."_"..cantidad.."_"..tiempo
    if is_test_server then syschat("Active bonus: "..string) end
    affect.add_collect(bonus, cantidad, tiempo)
    Pet_S.GetSkillInfo(skill)
end

function Pet_S.Desactive_Bonus(skill)
    local cantidad = Pet_S.GetSkillInfoLua(skill,3)
    local bonus = Pet_S.GetSkillInfoLua(skill,2)
    local tiempo = 3600*2
    if tonumber(cantidad) == 0 then return end
    if tonumber(bonus) == 1 or tonumber(bonus) == 2 then
        cantidad = cantidad * 100
    elseif tonumber(bonus) == 53 or tonumber(bonus) == 54 or tonumber(bonus) == 55 or tonumber(bonus) == 56 or tonumber(bonus) == 64 or tonumber(bonus) == 65 then
        cantidad = cantidad * 10
    end

    local string = bonus.."_"..cantidad.."_"..tiempo
    if is_test_server then syschat("Desactive bonus: "..string) end
    affect.remove_collect(bonus, cantidad, tiempo)
end

function Pet_S.GetFirstSkill(itemVnum,x)
    -- 5 skills por pet
    local skills = {
        [53001] = {"Przywołano Zwierzaka :) "},
        [53002] = {"Przywołano Zwierzaka :) "},
        [53003] = {"Przywołano Zwierzaka :) "},
        [53005] = {"Przywołano Zwierzaka :) "},
        [53006] = {"Przywołano Zwierzaka :) "},
        [53007] = {"Przywołano Zwierzaka :) "},
        [53008] = {"Przywołano Zwierzaka :) "},
        [53009] = {"Przywołano Zwierzaka :) "},
        [53010] = {"Przywołano Zwierzaka :) "},
        [53011] = {"Przywołano Zwierzaka :) "},
        [53012] = {"Przywołano Zwierzaka :) "},
        [53013] = {"Przywołano Zwierzaka :) "},
        [53014] = {"Przywołano Zwierzaka :) "},
        [53015] = {"Przywołano Zwierzaka :) "},
        [53016] = {"Przywołano Zwierzaka :) "},
        [53017] = {"Przywołano Zwierzaka :) "},
        [53022] = {"Przywołano Zwierzaka :) "},
        [53023] = {"Przywołano Zwierzaka :) "},
        [53024] = {"Przywołano Zwierzaka :) "},
        [53025] = {"Przywołano Zwierzaka :) "},
    }
    itemVnum = tonumber(itemVnum)
    return skills[itemVnum][x]
end

function Pet_S.GetSkillInfoLua(skill, dato)
    local test
    for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..tostring(pc.getqf("pet_spawn")).."/skill"..skill) do test = line end
    local sema = string.split(test, "/")
    return tostring(sema[dato])
end

function Pet_S.GetSkillInfo(skill)
    local test
    for line in io.lines(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..tostring(pc.getqf("pet_spawn")).."/skill"..skill) do test = line end
    if test == "" or test == nil then return end
    if is_test_server then syschat(tostring(test)) end
    cmdchat("ManagerPetSystem SetSkill|"..skill.."|"..tostring(test))
end

function Pet_S.GetSlotsPosition(vnum, pos) -- working
    -- [vnum] = {slot(0 min - 4 max), bonus, cantidad, "descripcion", nivel}
    local info_items = {
        [31950] = {0,43, 1, "1_%_Bonus_de_Experiencia", 0},
        [31951] = {0,43, 3, "3_%_Bonus_de_Experiencia", 10},
        [31952] = {0,43, 5, "5_%_Bonus_de_Experiencia", 20},
        [31953] = {0,43, 7, "7_%_Bonus_de_Experiencia", 30},
        [31954] = {0,43, 9, "9_%_Bonus_de_Experiencia", 40},
        [31955] = {0,43, 11, "10_%_Bonus_de_Experiencia", 50},
        [31956] = {0,43, 13, "13_%_Bonus_de_Experiencia", 60},
        [31957] = {0,43, 15, "15_%_Bonus_de_Experiencia", 70},
        [31958] = {0,43, 18, "18_%_Bonus_de_Experiencia", 80},
        [31959] = {0,43, 20, "20_%_Bonus_de_Experiencia", 100},
        [31960] = {1,44, 1, "1_%_Bonus_de_Doble_Drop", 0},
        [31961] = {1,44, 3, "3_%_Bonus_de_Doble_Drop", 10},
        [31962] = {1,44, 5, "5_%_Bonus_de_Doble_Drop", 20},
        [31963] = {1,44, 7, "7_%_Bonus_de_Doble_Drop", 30},
        [31964] = {1,44, 9, "9_%_Bonus_de_Doble_Drop", 40},
        [31965] = {1,44, 11, "11_%_Bonus_de_Doble_Drop", 50},
        [31966] = {1,44, 13, "13_%_Bonus_de_Doble_Drop", 60},
        [31967] = {1,44, 15, "15_%_Bonus_de_Doble_Drop", 70},
        [31968] = {1,44, 18, "18_%_Bonus_de_Doble_Drop", 80},
        [31969] = {1,44, 20, "20_%_Bonus_de_Doble_Drop", 100},
        [31970] = {2,45, 1, "1_%_Bonus_de_Doble_Yang", 0},
        [31971] = {2,45, 3, "3_%_Bonus_de_Doble_Yang", 10},
        [31972] = {2,45, 5, "5_%_Bonus_de_Doble_Yang", 20},
        [31973] = {2,45, 7, "7_%_Bonus_de_Doble_Yang", 30},
        [31974] = {2,45, 9, "9_%_Bonus_de_Doble_Yang", 40},
        [31975] = {2,45, 11, "15_%_Bonus_de_Doble_Yang", 50},
        [31976] = {2,45, 13, "13_%_Bonus_de_Doble_Yang", 60},
        [31977] = {2,45, 15, "15_%_Bonus_de_Doble_Yang", 70},
        [31978] = {2,45, 18, "18_%_Bonus_de_Doble_Yang", 80},
        [31979] = {2,45, 20, "20_%_Bonus_de_Doble_Yang", 100}
        }
    return info_items[vnum][pos]
end

function Pet_S.Get_Pet_Info(itemVnum) -- working
    local pet_info_map = {
    --  [ITEM VNUM] MOB_VNUM, DEFAULT NAME, effect, pet_img(0=default), special_img
    [53001]     = { 34001, " Fenix de Fuego" ,3,1,1},
    [53002]     = { 34002, " Bambi" ,5,15,0},
    [53003]     = { 34003, " Fenix de Hielo" ,4,1,2},
    [53005]     = { 34004, " Azrael", 6,5,1},
    [53006]     = { 34009, " Azrael Dorado", 6,5,2},
    [53010]     = { 34008, " Leonidas", 10,3,0},
    [53011]     = { 34007, " Khan", 7,6,0},
    [53012]     = { 34005, " Porkie", 8,4,0},
    [53013]     = { 34006, " Rufus", 9,2,0},
    [53007]     = { 34010, " Bambi", 5,15,0},
    [53008]     = { 34011, " Knuud", 12,8,0},
    [53009]     = { 34012, " Bao Bao", 11,9,0},
    [53014]     = { 34013, " Executor", 14,10,1},
    [53015]     = { 34014, " Executor Dorado", 14,10,2},
    [53016]     = { 34015, " Boney", 13,7,0},
    [53017]     = { 34016, " Fenix Verde", 15,1,3},
    -- Sellos escarcha
    [53018]     = { 34017, " Leonidas", 10,3,0},
    [53019]     = { 34018, " Khan", 7,6,0},
    [53020]     = { 34019, " Porkie", 8,4,0},
    [53021]     = { 34020, " Rufus", 9,2,0},
    -- Sellos News
    [53022]        = { 34021, " Sheldon",16,12,0},
    [53023]        = { 34022, " Cooper", 17,11,0},
    [53024]        = { 34023, " Pantera", 18,14,0},
    [53025]        = { 34024, " Leopardo", 19,13,0}
    }
    itemVnum = tonumber(itemVnum)
    return pet_info_map[itemVnum]
end

function Pet_S.SetButton(btn, nombre)
    if btn == 1 then -- alimientar pet
        if pc.count_item(38100) > 0 then
            item.select(tonumber(pc.getqf("pet_spawn")))
            local s = item.get_socket(0)
            item.set_socket(0,s+60*60*24*7) -- 7 dias
            pc.remove_item(38100)
        elseif pc.count_item(38101) > 0 then
            item.select(tonumber(pc.getqf("pet_spawn")))
            local s = item.get_socket(0)
            item.set_socket(0,s+60*60*24*15) -- 15 dias
            pc.remove_item(38101)
        elseif pc.count_item(38102) > 0 then
            item.select(tonumber(pc.getqf("pet_spawn")))
            local s = item.get_socket(0)
            item.set_socket(0,s+60*60*24*30) -- 30 dias
            pc.remove_item(38102)
        end

    elseif btn == 2 then -- renombrar mascota
        local minutos = (pc.getqf("tiempo_restante")-get_time())/60
        if get_time() > pc.getqf("tiempo_restante") then
            if nombre == "" then syschat("No puedes poner este nombre") return end
            local pet_item = pc.getqf("pet_spawn")
            local file = io.open(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..pet_item.."/name", "w") file:write(tostring(nombre)) file:close()
            pc.setqf("pet_system_name_"..pet_item, 1)
            pc.setqf("tiempo_restante", get_time() +600)
            syschat("Usted ha cambiado el nombre de su mascota a: "..nombre)
        else
            syschat("Debe esperar "..math.floor(minutos).." minutos para poder renombrarla.")
        end
        
    elseif btn == 3 then -- resetear puntos
        for e = 1, 5 do
            Pet_S.Desactive_Bonus(e)
        end
        for i = 1, 5 do
            local file = io.open(get_locale_base_path().."/quest/io/Pet_System/"..pc.get_name().."/"..pc.getqf("pet_spawn").."/skill"..tostring(i),"w")
            file:write(Pet_S.GetFirstSkill(tonumber(pc.getqf("pet_spawn")),i))
            file:close()
        end
        pc.setqf("pet_system_status_points_"..pc.getqf("pet_spawn"), Pet_S.Get_Level(pc.getqf("pet_spawn")))
        cmdchat("ManagerPetSystem SetSkillPoints|"..pc.getqf("pet_system_status_points_"..pc.getqf("pet_spawn")))
        for a = 1,5 do Pet_S.GetSkillInfo(a) end
        
    elseif btn == 4 then -- guardar mascota
        local pet_info = Pet_S.Get_Pet_Info(pc.getqf("pet_spawn"))
        local mobVnum = pet_info[1]
        if pet.is_summon(mobVnum) then
            cmdchat("ManagerPetSystem Hide|")
            cleartimer("pet_system_dead")
            pet.unsummon(mobVnum)
            for i = 1, 5 do Pet_S.Desactive_Bonus(i) end
            cmdchat("ManagerPetSystem GetItemsVnumsAndSlots|")
            cmdchat("ManagerPetSystem ClearSlots|")
            cmdchat("ManagerPetSystem Pet_Level|0")
            cmdchat("ManagerPetSystem Hide|")
            pc.delqf("pet_spawn")
            pc.delqf("pet_hp")
            pet.set_attack(0)
        end
    end
end

 

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...