Skip to content

Commit

Permalink
feat: add fusion possibility through soul cores
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipePaluco committed Dec 6, 2024
1 parent b284851 commit 24e8cd6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
19 changes: 19 additions & 0 deletions data-otservbr-global/lib/others/soulpit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
12 changes: 8 additions & 4 deletions data-otservbr-global/scripts/actions/soulpit/soulpit_fight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down Expand Up @@ -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()
6 changes: 6 additions & 0 deletions data/items/items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79734,5 +79734,11 @@ Granted by TibiaGoals.com"/>
<attribute key="description" value="Focalises the soul within a core. Can be used to turn a soul core into a greater version"/>
<attribute key="weight" value="100"/>
</item>
<item id="49174" article="a" name="large obelisk">
<attribute key="primarytype" value="pillars"/>
</item>
<item id="49175" article="a" name="large obelisk">
<attribute key="primarytype" value="pillars"/>
</item>
</items>

2 changes: 1 addition & 1 deletion data/scripts/actions/items/exalted_core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/actions/items/soul_prism.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down

0 comments on commit 24e8cd6

Please sign in to comment.