From 24e8cd621849eec099270d1f9da67887afe46576 Mon Sep 17 00:00:00 2001 From: Felipe Paluco Date: Fri, 6 Dec 2024 14:33:58 -0300 Subject: [PATCH] feat: add fusion possibility through soul cores --- data-otservbr-global/lib/others/soulpit.lua | 19 +++++++++++++++++++ .../scripts/actions/soulpit/soulpit_fight.lua | 12 ++++++++---- data/items/items.xml | 6 ++++++ data/scripts/actions/items/exalted_core.lua | 2 +- data/scripts/actions/items/soul_prism.lua | 2 +- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/data-otservbr-global/lib/others/soulpit.lua b/data-otservbr-global/lib/others/soulpit.lua index 4eb4dac4d53..bbaf0bf48c9 100644 --- a/data-otservbr-global/lib/others/soulpit.lua +++ b/data-otservbr-global/lib/others/soulpit.lua @@ -133,6 +133,25 @@ SoulPit = { return nil end, + getSoulCoreMonster = function(name) + return name:match("^(.-) soul core") + end, + onFuseSoulCores = function(player, item, target) + local itemName = item:getName() + local targetItemName = target:getName() + + 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 + end + + return false + end } SoulPit.zone:addArea(Position(32365, 31134, 8), Position(32382, 31152, 8)) diff --git a/data-otservbr-global/scripts/actions/soulpit/soulpit_fight.lua b/data-otservbr-global/scripts/actions/soulpit/soulpit_fight.lua index 1d3ddd21f66..fff8a92267d 100644 --- a/data-otservbr-global/scripts/actions/soulpit/soulpit_fight.lua +++ b/data-otservbr-global/scripts/actions/soulpit/soulpit_fight.lua @@ -27,7 +27,11 @@ end zoneEvent:register() local soulPitAction = Action() -function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isHotkey) +function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if SoulPit.onFuseSoulCores(player, item, target) then + return true + end + logger.warn(item:getName()) if target and target:getId() == SoulPit.obeliskActive then creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting in the soulpit!") @@ -148,8 +152,8 @@ function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isH end for _, itemType in pairs(SoulPit.soulCores) do - if itemType:getId() ~= 49164 then -- TO-DO: currently Game.getSoulCoreItems() it's returning soul prism item in the results, we don't want this. - soulPitAction:id(itemType:getId()) - end + -- if itemType:getId() ~= 49164 then -- TO-DO: currently Game.getSoulCoreItems() it's returning soul prism item in the results, we don't want this. + soulPitAction:id(itemType:getId()) + -- end end soulPitAction:register() diff --git a/data/items/items.xml b/data/items/items.xml index 46f1c95a9d3..d2e43e35605 100644 --- a/data/items/items.xml +++ b/data/items/items.xml @@ -79734,5 +79734,11 @@ Granted by TibiaGoals.com"/> + + + + + + diff --git a/data/scripts/actions/items/exalted_core.lua b/data/scripts/actions/items/exalted_core.lua index a45633a3af7..7a4c778589a 100644 --- a/data/scripts/actions/items/exalted_core.lua +++ b/data/scripts/actions/items/exalted_core.lua @@ -31,7 +31,7 @@ end function exaltedCore.onUse(player, item, fromPosition, target, toPosition, isHotkey) local itemName = target:getName() - local monsterName = itemName:match("^(.-) soul core") + local monsterName = SoulPit.getSoulCoreMonster(itemName) if not monsterName then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only use Exalted Core with a Soul Core.") diff --git a/data/scripts/actions/items/soul_prism.lua b/data/scripts/actions/items/soul_prism.lua index 4241f8277e5..190ad086098 100644 --- a/data/scripts/actions/items/soul_prism.lua +++ b/data/scripts/actions/items/soul_prism.lua @@ -40,7 +40,7 @@ end function soulPrism.onUse(player, item, fromPosition, target, toPosition, isHotkey) local itemName = target:getName() - local monsterName = itemName:match("^(.-) soul core") + local monsterName = SoulPit.getSoulCoreMonster(itemName) if not monsterName then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only use Soul Prism with a Soul Core.")