Skip to content

Commit

Permalink
feat: add EventCallbacks for item movement restrictions and boss inte…
Browse files Browse the repository at this point in the history
…ractions
  • Loading branch information
omarcopires committed Nov 13, 2024
1 parent f34cb83 commit 398b089
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
local callback = EventCallback("CultsOnItemMoved")

function callback.onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
local fromPos = Position(33023, 31904, 14)
local toPos = Position(33052, 31932, 15)
local removeItem = false

if player:getPosition():isInRange(fromPos, toPos) and item:getId() == 23729 then
local tile = Tile(toPosition)
if tile then
local tileBoss = tile:getTopCreature()
if tileBoss and tileBoss:isMonster() then
local bossName = tileBoss:getName():lower()
if bossName == "the remorseless corruptor" then
tileBoss:addHealth(-17000)
tileBoss:remove()

local monster = Game.createMonster("The Corruptor of Souls", toPosition)
if not monster then
return false
end

removeItem = true
monster:registerEvent("CheckTile")

local storedHealth = Game.getStorageValue("healthSoul")
if storedHealth > 0 then
monster:addHealth(-(monster:getHealth() - storedHealth))
end

Game.setStorageValue("CheckTile", os.time() + 30)
elseif bossName == "the corruptor of souls" then
Game.setStorageValue("CheckTile", os.time() + 30)
removeItem = true
end
end
end

if removeItem then
item:remove(1)
end
end
return true
end

callback:register()
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local callback = EventCallback("SecretOnItemMoved")

function callback.onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
if toPosition == Position(32460, 32928, 7) and item.itemid == 3578 then
toPosition:sendMagicEffect(CONST_ME_HEARTS)
player:say("You feed the turtle, now you may pass.", TALKTYPE_MONSTER_SAY)
Game.setStorageValue(Storage.Quest.U11_80.TheSecretLibrary.SmallIslands.Turtle, os.time() + 10 * 60)
item:remove(1)
end
return true
end

callback:register()
43 changes: 0 additions & 43 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -370,49 +370,6 @@ function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder,
end

function Player:onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
if IsRunningGlobalDatapack() then
-- The Secret Library Quest
if toPosition == Position(32460, 32928, 7) and item.itemid == 3578 then
toPosition:sendMagicEffect(CONST_ME_HEARTS)
self:say("You feed the turtle, now you may pass.", TALKTYPE_MONSTER_SAY)
Game.setStorageValue(Storage.Quest.U11_80.TheSecretLibrary.SmallIslands.Turtle, os.time() + 10 * 60)
item:remove(1)
end

-- Cults of Tibia begin
local frompos = Position(33023, 31904, 14)
local topos = Position(33052, 31932, 15)
local removeItem = false
if self:getPosition():isInRange(frompos, topos) and item:getId() == 23729 then
local tile = Tile(toPosition)
if tile then
local tileBoss = tile:getTopCreature()
if tileBoss and tileBoss:isMonster() then
if tileBoss:getName():lower() == "the remorseless corruptor" then
tileBoss:addHealth(-17000)
tileBoss:remove()
local monster = Game.createMonster("The Corruptor of Souls", toPosition)
if not monster then
return false
end
removeItem = true
monster:registerEvent("CheckTile")
if Game.getStorageValue("healthSoul") > 0 then
monster:addHealth(-(monster:getHealth() - Game.getStorageValue("healthSoul")))
end
Game.setStorageValue("CheckTile", os.time() + 30)
elseif tileBoss:getName():lower() == "the corruptor of souls" then
Game.setStorageValue("CheckTile", os.time() + 30)
removeItem = true
end
end
end
if removeItem then
item:remove(1)
end
end
-- Cults of Tibia end
end
return true
end

Expand Down

0 comments on commit 398b089

Please sign in to comment.