RevScript Loot System Tiers: Normal / Enchanted / Epic / Legendary

Alex

Administrator
Webdesigner
LV
58
 
Awards
38
Hola a todos,

Hoy les compartimos el sistema de loot,
El loot de cada monstruo queda siendo el mismo, lo que diferencia, es que anade mas loot dependiendo la chance en mathrandom de ser un monstruo Sin nada, Normal, Enchanted, Epic o Legendary.

Mas sea alto y mas dara un item raro, en el ejemplo probamos con Gold Coin, Platinum Coin y Crystal Coin.

Ps: En el video no salio Legendary, no tubimos suerte, obviamente.

Nota: Hacerlo con el servidor apagado y no online, sino al matar el monstruo se caera la consola, debeis reiniciar el servidor antes de usarlo.

Video Password: lepiigortv

Video:


Iremos en el monstruo que deseamos anadirle el sistema ( tengan en cuenta que el sistema lo anade a todos los monstruos del juego )
despues de monsters.flags , anadiremos esto:

Code:
monster.events = {
    "onDeath_randomItemDrops"
}

Luego iremos en data/scripts/ en donde quiera, crean si quieren una nueva carpeta loot por ejemplo y lo ponen dentro, llaman el fichero como quieran loot.lua por ejemplo

Code:
local config = {
    chance = 2500, -- chance out of 10000. 2500 = 25% of an additional item dropping in monsters.
    tiers = {
        -- A random number is rolled between 1 to 10000.
        -- If the number is between or equal to these numbers, that tier is selected.
   
        -- [chance_lower, chance_higher] = {tier = {"text", enabled?}, effect = {effect, enabled?}}
        [{  1,  5000}] = { tier = {"normal", true}, effect = {CONST_ME_SOUND_WHITE, true}, itemList = {
                {2148, 1, 1, 10000},
                {2148, 2, 2, 5000}, -- {itemid, amount_min, amount_max, chance} -- chance out of 10000.
                {2148, 3, 3, 5000}
            }
        },
        [{5001,  8500}] = { tier = {"enchanted", true}, effect = {CONST_ME_SOUND_PURPLE, true}, itemList = {
                {2152, 1, 1, 10000},
                {2152, 2, 2, 5000}, -- note; DO NOT SET amount_min, amount_max higher then 1, if that item is not stackable.
                {2152, 3, 3, 5000}
            }
        },
        [{8501,  9500}] = { tier = {"epic", true}, effect = {CONST_ME_SOUND_BLUE, true}, itemList = {
                {2160, 1, 1, 10000},
                {2160, 2, 2, 5000}, -- note; Even though a reward tier has been selected, if all item chances fail to reward an item, it's possible that a player will not receive any item.
                {2160, 3, 3, 5000}  -- for that reason, I suggest that at least 1 item's chance is set to 10000, so that a player is garenteed to receive an item.
            }
        },
        [{9501, 10000}] = { tier = {"legendary", true}, effect = {CONST_ME_SOUND_YELLOW, true}, itemList = {
                {6500, 1, 1, 10000},
                {6500, 2, 2, 5000},
                {6500, 3, 3, 5000}
            }
        }
    }
}

local creatureevent = CreatureEvent("onDeath_randomItemDrops")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- check if corpse item has available space to receive an additional item.
    if corpse:getEmptySlots() > 0 then
        -- check if an additional item will drop.
        if math.random(10000) > config.chance then
            return true
        end
        -- choose a tier.
        local rand = math.random(10000)
        for chance, index in pairs(config.tiers) do
            if chance[1] <= rand and chance[2] >= rand then
                -- create loot list.
                local rewardItems = {}
                for i = 1, #index.itemList do
                    if math.random(10000) <= index.itemList[i][4] then
                        rewardItems[#rewardItems + 1] = i
                    end
                end
                -- give a random item, if there are any to give.
                if rewardItems[1] then
                    rand = math.random(#rewardItems)
                    corpse:addItem(index.itemList[rand][1], math.random(index.itemList[rand][2], index.itemList[rand][3]))
                    if index.tier[2] == true then
                        creature:say(index.tier[1], TALKTYPE_MONSTER_SAY, false, nil, creature:getPosition())
                    end
                    if index.effect[2] == true then
                        local position = creature:getPosition()
                        for i = 1, 4 do
                            addEvent(function() position:sendMagicEffect(index.effect[1]) end, (i - 1) * 500)
                        end
                    end
                end
                return true
            end
        end
    end
    return true
end

creatureevent:register()
Podran retocar el loot por X categoria, 2148 sabemos que es el gold, 2152 el platinum y el 2160 el crystal coin
Tendremos el minimo y maximo en cantidad que dara, lo teneis escrito en el script en color verde.

Luego iremos en data/events/scripts/monsters.lua , abriremos el fichero ctrl+f y buscaremos 'onSpawn'

Aparecera:
Code:
function Monster:onSpawn(position)
    if self:getType():isRewardBoss() then
        self:setReward(true)
    end

    if self:getName():lower() == "cobra scout" or
        self:getName():lower() == "cobra vizier" or
        self:getName():lower() == "cobra assassin" then
        if getGlobalStorageValue(GlobalStorage.CobraBastionFlask) >= os.time() then
            self:setHealth(self:getMaxHealth() * 0.75)
        end
    end

Lo reemplazais por este: que anade la linea : self:registerEvent("onDeath_randomItemDrops")

Code:
function Monster:onSpawn(position)
    if self:getType():isRewardBoss() then
        self:setReward(true)
    end
    self:registerEvent("onDeath_randomItemDrops")

    if self:getName():lower() == "cobra scout" or
        self:getName():lower() == "cobra vizier" or
        self:getName():lower() == "cobra assassin" then
        if getGlobalStorageValue(GlobalStorage.CobraBastionFlask) >= os.time() then
            self:setHealth(self:getMaxHealth() * 0.75)
        end
    end
Resetear el servidor y listo.


Opcional:

Si desean usar varios sets por cada monsters distinto pueden usar este script de ejemplo:

Code:
local config = {
    ["rat"] = {
        chance = 2500, -- chance out of 10000. 2500 = 25% of an additional item dropping in monsters.
        tiers = {
            -- A random number is rolled between 1 to 10000.
            -- If the number is between or equal to these numbers, that tier is selected.
           
            -- [chance_lower, chance_higher] = {tier = {"text", enabled?}, effect = {effect, enabled?}}
            [{  1,  5000}] = { tier = {"normal", true}, effect = {CONST_ME_SOUND_WHITE, true}, itemList = {
                    {2160, 1, 1, 10000},
                    {2160, 2, 2, 5000}, -- {itemid, amount_min, amount_max, chance} -- chance out of 10000.
                    {2160, 3, 3, 5000}
                }
            },
            [{5001,  8500}] = { tier = {"enchanted", true}, effect = {CONST_ME_SOUND_PURPLE, true}, itemList = {
                    {2160, 1, 1, 10000},
                    {2160, 2, 2, 5000}, -- note; DO NOT SET amount_min, amount_max higher then 1, if that item is not stackable.
                    {2160, 3, 3, 5000}
                }
            },
            [{8501,  9500}] = { tier = {"epic", true}, effect = {CONST_ME_SOUND_BLUE, true}, itemList = {
                    {2160, 1, 1, 10000},
                    {2160, 2, 2, 5000}, -- note; Even though a reward tier has been selected, if all item chances fail to reward an item, it's possible that a player will not receive any item.
                    {2160, 3, 3, 5000}  -- for that reason, I suggest that at least 1 item's chance is set to 10000, so that a player is garenteed to receive an item.
                }
            },
            [{9501, 10000}] = { tier = {"legendary", true}, effect = {CONST_ME_SOUND_YELLOW, true}, itemList = {
                    {2160, 1, 1, 10000},
                    {2160, 2, 2, 5000},
                    {2160, 3, 3, 5000}
                }
            }
        }
    },
    ["cave rat"] = {
        chance = 2500, tiers = {
            [{   1,  5000}] = {tier = {"normal", true},    effect = {CONST_ME_SOUND_WHITE, true},  itemList = {{6500, 1, 1, 10000}, {6500, 2, 2, 5000}, {6500, 3, 3, 5000} }},
            [{5001,  8500}] = {tier = {"enchanted", true}, effect = {CONST_ME_SOUND_PURPLE, true}, itemList = {{6500, 1, 1, 10000}, {6500, 2, 2, 5000}, {6500, 3, 3, 5000} }},
            [{8501,  9500}] = {tier = {"epic", true},      effect = {CONST_ME_SOUND_BLUE, true},   itemList = {{6500, 1, 1, 10000}, {6500, 2, 2, 5000}, {6500, 3, 3, 5000} }},
            [{9501, 10000}] = {tier = {"legendary", true}, effect = {CONST_ME_SOUND_YELLOW, true}, itemList = {{6500, 1, 1, 10000}, {6500, 2, 2, 5000}, {6500, 3, 3, 5000} }}
        }
    },
}

local creatureevent = CreatureEvent("onDeath_randomItemDrops")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    local monster = config[creature:getName():lower()]
    -- check if monster is in table
    if monster then
        -- check if corpse item has available space to receive an additional item.
        if corpse:getEmptySlots() > 0 then
            -- check if an additional item will drop.
            if math.random(10000) > monster.chance then
                return true
            end
            -- choose a tier.
            local rand = math.random(10000)
            for chance, index in pairs(monster.tiers) do
                if chance[1] <= rand and chance[2] >= rand then
                    -- create loot list.
                    local rewardItems = {}
                    for i = 1, #index.itemList do
                        if math.random(10000) <= index.itemList[i][4] then
                            rewardItems[#rewardItems + 1] = i
                        end
                    end
                    -- give a random item, if there are any to give.
                    if rewardItems[1] then
                        rand = math.random(#rewardItems)
                        corpse:addItem(index.itemList[rand][1], math.random(index.itemList[rand][2], index.itemList[rand][3]))
                        if index.tier[2] == true then
                            creature:say(index.tier[1], TALKTYPE_MONSTER_SAY, false, nil, creature:getPosition())
                        end
                        if index.effect[2] == true then
                            local position = creature:getPosition()
                            for i = 1, 4 do
                                addEvent(function() position:sendMagicEffect(index.effect[1]) end, (i - 1) * 500)
                            end
                        end
                    end
                    return true
                end
            end
        end
    end
    return true
end

creatureevent:register()
 

Ethaanks123

Miembro
LV
7
 
Awards
6
felicidades eres realmente un maestro para explicar los detalle y su funci贸n me gustaria saber si existe algun scripts para hacer funcionar la forge ?
y si tiene algun costo por favor h谩zmelo saber
 

Alex

Administrator
Webdesigner
LV
58
 
Awards
38
felicidades eres realmente un maestro para explicar los detalle y su funci贸n me gustaria saber si existe algun scripts para hacer funcionar la forge ?
y si tiene algun costo por favor h谩zmelo saber
Hola,

La forge en s铆, no tengo idea si hay un script, nosotros haremos funcionar la forge con un script de Craft Y modalwindows.

Ese tipo de script sera subido en el foro despu茅s de la salida de la gran actualizaci贸n de Hellgarve v6.0.
Estamos a煤n en pruebas de test.
 
Top