Помогите новичку разобраться с дропом итэмов по рарити.

romanson

Пользователь
5 Фев 2020
41
3
Проект
Diablo_rpg
Подскажите плиз что не так. Коммон итэм выпадает, а как сделать чтоб при выборе большего уровня сложности предметы выподали по рарити. Common? uncommon, acient и.т.д.
 
Последнее редактирование:
Если в таком виде то common item перестает падать и начинает падать uncommon.
 
1661036740077.png
Код надо вставлять через "дополнительно" - "код"
А еще лучше завернуть это все в спойлер
 
Код:
function Enemies:BuildDropTable(enemy, difficulty)

    local dropTable = {}

    local IsBoss = Enemies:IsBoss(enemy)

    local IsElite = Enemies:IsElite(enemy)

    local dropChance = 10

    if (IsElite) then

        dropChance = Enemies:GetEliteEnemyDropChance(enemy, difficulty)

    end

    if (IsBoss) then

        dropChance = 100

    end

    if (not RollPercentage(dropChance)) then

        return dropTable

    end

    local itemsPerDrop = 1

    local dropChanceFactor = Enemies.dropChanceFactor

    local itemsTable = {}

    local commonItems = Inventory:GetItemsByRarity(Inventory.rarity.common)

    if(GetTableSize(commonItems) > 0) then

        table.insert(itemsTable, Inventory.rarity.common, { items = Inventory:GetItemsByRarity(Inventory.rarity.common), chance = 100, itemsDifficulty = 1 })

    end

 

    for _ = 1, itemsPerDrop do

        for rarity = #itemsTable, Inventory.rarity.common do

            if (GetTableSize(dropTable) >= itemsPerDrop) then

                break

            end

            if (itemsTable[rarity] and RollPercentage(itemsTable[rarity].chance)) then

                table.insert(dropTable, { item = itemsTable[rarity].items[math.random(1, #itemsTable[rarity].items)], difficulty = itemsTable[rarity].itemsDifficulty})

            end

        end

    end

    return dropTable

end
Посмотреть вложение 1633
Код надо вставлять через "дополнительно" - "код"
А еще лучше завернуть это все в спойлер
Прошу прощения, поправил
 
Ты это сам писал ?
Или откуда то скопировал
Скопировал. Есть идеи по этому коду? Пробовал решить проблемму, но получается выдавать только один вид итэма. Не
пойму как сделать чтоб выпадали шмотки разного грэйда с разным шансом.
 
function Enemies:BuildDropTable(enemy, difficulty)
local dropTable = {}
local IsBoss = Enemies:IsBoss(enemy)
local IsElite = Enemies:IsElite(enemy)
local dropChance = 10
if (IsElite) then
dropChance = Enemies:GetEliteEnemyDropChance(enemy, difficulty)
end
if (IsBoss) then
dropChance = 100
end
if (not RollPercentage(dropChance)) then
return dropTable
end
local itemsPerDrop = 1
local dropChanceFactor = Enemies.dropChanceFactor
local itemsTable = {}
local commonItems = Inventory:GetItemsByRarity(Inventory.rarity.common)
local uncommonItems = Inventory:GetItemsByRarity(Inventory.rarity.uncommon)
if(GetTableSize(commonItems) > 0) then
table.insert(itemsTable, Inventory.rarity.common, { items = Inventory:GetItemsByRarity(Inventory.rarity.common), chance = 100, itemsDifficulty = 1 })
end
if (difficulty > Difficulty.DIFFICULTY1) then
table.insert(itemsTable, Inventory.rarity.uncommon, { items = Inventory:GetItemsByRarity(Inventory.rarity.uncommon), chance = 60 })
end

for _ = 1, itemsPerDrop do
for rarity = #itemsTable, Inventory.rarity.common do
if (GetTableSize(dropTable) >= itemsPerDrop) then
break
end
if (itemsTable[rarity] and RollPercentage(itemsTable[rarity].chance)) then
table.insert(dropTable, { item = itemsTable[rarity].items[math.random(1, #itemsTable[rarity].items)], difficulty = itemsTable[rarity].itemsDifficulty})
end
end
for rarity = #itemsTable, Inventory.rarity.uncommon do
if (GetTableSize(dropTable) >= itemsPerDrop) then
break
end
if (itemsTable[rarity] and RollPercentage(itemsTable[rarity].chance)) then
table.insert(dropTable, { item = itemsTable[rarity].items[math.random(1, #itemsTable[rarity].items)], difficulty = itemsTable[rarity].itemsDifficulty})
end
end
end
return dropTable
end
 
Последнее редактирование:
Пробовал вот так, начинает падать ункомон, при этом коммон падать перестает(
 
Я не знаю как работает твой, код а разбирайться если честно лень...
Вот возьми мой шаблон, там есть система дропа предметов.
Изучи её пойми что и как работает, и можешь модифицировать под себя как оно нужно.
Не удивлюсь, если ты базовые гайды даже не читал...
 
Реклама: