Ir para conteúdo

Featured Replies

Postado

.

Fala pessoal tudo bem com vcs?

queria pedir uma ajuda em uma alteraçao de um script que tenho aki se alguem poderia me ajudar

o script aficiona items ao monstro quando ele morre no corpse

eu queria pedir a ajuda de alguem para alterar o script que em vez do item for adcionado ao corpse da criatura adicionar direto para a backpack do player teria como ?

vou deixar o script abaixo

 

  Citar

 

 

local extra_loot = {
    {hasName = "dragon", items = {
        {id = 2152, count = 2, chance = 40000}, -- 40%
        {id = 2160, countMax = 4, chance = 99000}
    }},
    {items = {
        {id = 2365, chance = 10000},
        {id = 2392, chance = 1000}
    }},
}

function Container:addExtraLoot(c, t)
    if t.hasName then
        local cn = c:getName():lower()
        local cm = t.hasName:lower()
        if not cn:match(cm) then
            return true
        end
    end
    
    for i = 1, #t.items do
        local count = 1
        if t.items[i].count then
            if t.items[i].countMax then
                count = math.random(t.items[i].count, t.items[i].countMax)
            else
                count = t.items[i].count
            end
        else
            if t.items[i].countMax then
                count = math.random(1, t.items[i].countMax)
            end
        end
        
        if math.random(0, 100000) <= t.items[i].chance then
            self:addItem(t.items[i].id, count)
        end
    end
end

function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if not creature:isMonster() then return true end
    if corpse and corpse:isContainer() then
        for i = 1, #extra_loot do
            corpse:addExtraLoot(creature, extra_loot[i])
        end
    end
    return true
end 

 

Editado por Felippe Reine014 (veja o histórico de edições)

  • 1 month later...
Postado
local extra_loot = {
    {hasName = "dragon", items = {
        {id = 2152, count = 2, chance = 40000}, -- 40%
        {id = 2160, countMax = 4, chance = 99000}
    }},
    {items = {
        {id = 2365, chance = 10000},
        {id = 2392, chance = 1000}
    }},
}

function Player:addExtraLoot()
    local monsterName = self:getKilledCreatureName():lower()

    for i = 1, #extra_loot do
        local lootConfig = extra_loot[i]

        if lootConfig.hasName then
            local targetName = lootConfig.hasName:lower()
            if not monsterName:match(targetName) then
                return true
            end
        end

        for j = 1, #lootConfig.items do
            local itemConfig = lootConfig.items[j]
            local count = 1

            if itemConfig.count then
                if itemConfig.countMax then
                    count = math.random(itemConfig.count, itemConfig.countMax)
                else
                    count = itemConfig.count
                end
            else
                if itemConfig.countMax then
                    count = math.random(1, itemConfig.countMax)
                end
            end

            if math.random(0, 100000) <= itemConfig.chance then
                self:addItem(itemConfig.id, count)
            end
        end
    end
end

function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if not creature:isMonster() or not killer:isPlayer() then
        return true
    end

    killer:addExtraLoot()

    return true
end

Tenta Isso aqui!!!

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