Ir para conteúdo

Featured Replies

Postado

Oi

 

Eu nao sei falar portuges

Presiso do ajuda em script

Por favor eliminar mechanical fishing rod/nails de script

Agregar dirty water y shimmer swimmer 0.001% chance of fishing

quitar getmonsterloot function y cambiar por math.random para water elemental sin monsterowner

 

obrigado

local FISH_WATER = {4620, 4621, 4622, 4623, 4624, 4625}
local NOFISH_WATER = {493, 4820, 4821, 4822, 4823, 4824, 4825, 13843, 13844, 13845, 13846, 13847, 13848}
local ICE_HOLE_FISH = 7236

local ITEM_NAIL = 8309
local ITEM_WORM = 3976
local ITEM_FISH = 2667
local ITEM_MECHANICAL_FISH = 10224

local ITEM_FISHING_ROD = 2580
local ITEM_MECHANICAL_FISHING_ROD = 10223
local ITEM_GREEN_PERCH = 7159
local ITEM_RAINBOW_TROUT = 7158
local ITEM_NORTHERN_PIKE = 2669
local ITEM_WATER_ELEMENTAL_CORPSE = 10499

local WATER_ELEMENTAL_LOOT = {
    {2149, 1, 80/4845},--small emerald
    {2146, 1, 60/4845},--small sapphire
    {2143, 1, 40/4845},--white pearl
    {7632, 1, 80/4845},--giant shimmering pearl
    {10220, 1, 10/4845}--Leviathan's amulet
}

local function calculateWidth(lootList, index)
    if lootList[index][2] > 0 and lootList[index][3] > 0 then
        local ret = lootList[index][3] * 100000
        if lootList[index][1] == 0 then
            ret = ret / getConfigValue("rate_loot")
        else
            ret = ret * (2/(lootList[index][2]+1))
        end
        return math.max(math.ceil(ret),1)
    else
        return false
    end
end

local function calculateTotalWidth(lootList)
    local ret = 0
    local listSize = table.getn(lootList)
    for aux = 1, listSize do
        ret = ret + calculateWidth(lootList,aux)
    end
    return ret
end

local totalArray = {}
local function getTotal(lootList)
    if totalArray[lootList] == nil then
        totalArray[lootList] = calculateTotalWidth(lootList)
    end
    return totalArray[lootList]
end

local function getMonsterLoot(lootList)
    local pos = 0
    local total = getTotal(lootList)
    if total == 0 then
        return nil --no loot
    end
    local rand = math.random(1, total)
    local listSize = table.getn(lootList)
    local index = 1
    while index <= listSize do
        local w = calculateWidth(lootList, index)
        pos = pos + w
        if rand <= pos and w ~= 0 then
            if lootList[index][1] == 0 then
                return nil
            end
            local count = math.max(math.random(1, lootList[index][2] * getConfigValue("rate_loot")),1)
            count = math.min(lootList[index][2], count)
            return {lootList[index][1], count}
        end
        index = index + 1
    end
    return nil
end


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

    if(topos.x == CONTAINER_POSITION) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        return true
    end
    
    if (isInArray(NOFISH_WATER, item2.itemid) ) then
        doSendMagicEffect(topos, CONST_ME_LOSEENERGY)
        return true
    end

    if (item2.itemid == ITEM_WATER_ELEMENTAL_CORPSE) then
        local monsterLoot = getMonsterLoot(WATER_ELEMENTAL_LOOT)
        if monsterLoot ~= nil then
            doPlayerAddItem(cid, monsterLoot[1], monsterLoot[2])
        end
        doSendMagicEffect(topos, CONST_ME_WATERSPLASH)
        doTransformItem(item2.uid, item2.itemid + 1)
        if item2.actionid ~= 0 then
            doSetItemActionId(item2.uid, item2.actionid)
        end
        return true
    end

    local formula = (getPlayerSkill(cid, SKILL_FISHING) / 200) + (0.85 * math.random())
    local useNail = (item.itemid == ITEM_MECHANICAL_FISHING_ROD)
    local hasFished = false;

    local canGainSkill = not(getTilePzInfo(getThingPos(cid)) or
        (getPlayerItemCount(cid, ITEM_WORM) < 1 and item.itemid == ITEM_FISHING_ROD) or
        (getPlayerItemCount(cid, ITEM_NAIL) < 1 and item.itemid == ITEM_MECHANICAL_FISHING_ROD))

    
    if (isInArray(FISH_WATER, item2.itemid) ) then
        
        if(canGainSkill) then
            if(formula > 0.7) then
                if useNail then
                    doPlayerAddItem(cid, ITEM_MECHANICAL_FISH)
                else
                    doPlayerAddItem(cid, ITEM_FISH)
                end
                doPlayerAddSkillTry(cid, SKILL_FISHING, 1)
                doTransformItem(item2.uid, item2.itemid + 200)
                hasFished = true;
            end
            doPlayerAddSkillTry(cid, SKILL_FISHING, 1)
        end
        doSendMagicEffect(topos, CONST_ME_LOSEENERGY)
    elseif (item2.itemid == ICE_HOLE_FISH) then
        if(canGainSkill) then
            if useNail then
                if formula < 0.5 then
                    doPlayerAddItem(cid, ITEM_MECHANICAL_FISH)
                end
            else
                if(formula > 0.83) then
                    doPlayerAddItem(cid, ITEM_RAINBOW_TROUT)
                elseif(formula > 0.75) then
                    doPlayerAddItem(cid, ITEM_NORTHERN_PIKE)
                elseif(formula > 0.5) then
                    doPlayerAddItem(cid, ITEM_GREEN_PERCH)
                elseif(formula > 0.47) then
                    doPlayerAddItem(cid, ITEM_FISH)
                end
                if formula > 0.47 then
                    hasFished = true
                end
            end
            doTransformItem(item2.uid, item2.itemid + 1)
            doPlayerAddSkillTry(cid, SKILL_FISHING, 2)
        end
    else
        return false
    end

    if useNail and hasFished then
        doPlayerRemoveItem(cid, ITEM_NAIL, 1)
    elseif hasFished then
        doPlayerRemoveItem(cid, ITEM_WORM, 1)
    end
    doDecayItem(item2.uid)

    return true
end

script debe quedar asi:

normal fishing

ice fishing

dirty waterfishing (extremely rare shimmer swimmer fish)

loot from elementals con item2.itemid (como machete) y math.random

 

muito obrigado

 

yo estar desactualizado en LUA, en ningun otro sitio me ayudan, por favor ayuda

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo