Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions data-otservbr-global/lib/others/soulpit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,25 @@ SoulPit = {
return name:match("^(.-) soul core")
end,
onFuseSoulCores = function(player, item, target)
local itemName = item:getName()
local targetItemName = target:getName()
local itemCount = item:getCount(item:getId())
if item:getId() == target:getId() and itemCount <= 1 then
return false
end

if SoulPit.getSoulCoreMonster(itemName) and SoulPit.getSoulCoreMonster(targetItemName) then
local randomSoulCore = SoulPit.soulCores[math.random(#SoulPit.soulCores)]
player:addItem(randomSoulCore:getId(), 1)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have received a %s soul core.", randomSoulCore:getName()))
item:remove(1)
target:remove(1)
return true
local itemSoulCore = SoulPit.getSoulCoreMonster(item:getName())
local targetSoulCore = SoulPit.getSoulCoreMonster(target:getName())
if not itemSoulCore or not targetSoulCore then
return false
end

return false
local randomSoulCore = SoulPit.soulCores[math.random(#SoulPit.soulCores)]
player:addItem(randomSoulCore:getId(), 1)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have received a %s soul core.", randomSoulCore:getName()))

item:remove(1)
target:remove(1)
return true
end,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@ function callback.monsterOnDropLoot(monster, corpse)
if not monster or not corpse then
return
end

local player = Player(corpse:getCorpseOwner())
if not player or not player:canReceiveLoot() then
return
end

if monster:getMonsterForgeClassification() ~= FORGE_FIENDISH_MONSTER then
return
end

local soulCoreId = nil
local trySameMonsterSoulCore = math.random(100) <= SoulPit.SoulCoresConfiguration.chanceToGetSameMonsterSoulCore
local mType = monster:getType()
local lootTable = {}

if math.random(100) < SoulPit.SoulCoresConfiguration.chanceToDropSoulCore then
local soulCoreId
if trySameMonsterSoulCore then
local itemName = monster:getName():lower() .. " soul core"
soulCoreId = getItemIdByName(itemName)
soulCoreId = getItemIdByName(string.format("%s soul core", monster:getName():lower()))
end

if not soulCoreId and not trySameMonsterSoulCore then
Expand All @@ -29,16 +30,13 @@ function callback.monsterOnDropLoot(monster, corpse)

if monstersInCategory and #monstersInCategory > 0 then
local randomMonster = monstersInCategory[math.random(#monstersInCategory)]
local itemName = randomMonster:name():lower() .. " soul core"
soulCoreId = getItemIdByName(itemName)
logger.info("soulcoreId: " .. soulCoreId)
soulCoreId = getItemIdByName(string.format("%s soul core", randomMonster:name():lower()))
end
end

if soulCoreId then
lootTable[soulCoreId] = {
count = 1,
}
lootTable[soulCoreId] = { count = 1 }
logger.debug("[monsterOnDropLoot.MonsterOnDropLootSoulCore] {} dropped {} for {}.", monster:getName(), ItemType(soulCoreId):getName(), player:getName())
else
return {}
end
Expand All @@ -47,11 +45,11 @@ function callback.monsterOnDropLoot(monster, corpse)
if math.random(100) < SoulPit.SoulCoresConfiguration.chanceToDropSoulPrism then
local soulPrismId = getItemIdByName("soul prism")
if soulPrismId then
lootTable[soulPrismId] = {
count = 1,
}
lootTable[soulPrismId] = { count = 1 }
logger.debug("[monsterOnDropLoot.MonsterOnDropLootSoulCore] {} dropped {} for {}.", monster:getName(), ItemType(soulPrismId):getName(), player:getName())
end
end

corpse:addLoot(mType:generateLootRoll({}, lootTable, player))
end

Expand Down