diff --git a/data-global/scripts/creaturescripts/customs/water_houses.lua b/data-global/scripts/creaturescripts/customs/water_houses.lua new file mode 100644 index 0000000..2485332 --- /dev/null +++ b/data-global/scripts/creaturescripts/customs/water_houses.lua @@ -0,0 +1,30 @@ +local positions = { + { fromPos = Position(33600, 31927, 3), toPos = Position(33606, 31931, 3) } +} + +local function isInRestrictedArea(position) + for _, restrictedArea in ipairs(positions) do + if position.x >= restrictedArea.fromPos.x and position.x <= restrictedArea.toPos.x and + position.y >= restrictedArea.fromPos.y and position.y <= restrictedArea.toPos.y and + position.z == restrictedArea.fromPos.z then + return true + end + end + return false +end + +local disableMovingItems = EventCallback("DisableMovingItems") + +disableMovingItems.playerOnMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder) + if isInRestrictedArea(toPosition) then + if item:getId() == ITEM_WATERBALL or item:getId() == ITEM_WATERBALL_SPLASH then + return true + end + + self:sendTextMessage(MESSAGE_FAILURE, "You cannot throw items into the water.") + return false + end + return true +end + +disableMovingItems:register() \ No newline at end of file diff --git a/data-global/world/world-house.xml b/data-global/world/world-house.xml index 7eff23b..9fd96d0 100644 --- a/data-global/world/world-house.xml +++ b/data-global/world/world-house.xml @@ -937,7 +937,7 @@ - + @@ -952,7 +952,7 @@ - + diff --git a/src/items/tile.cpp b/src/items/tile.cpp index 5fd14cf..6c98034 100644 --- a/src/items/tile.cpp +++ b/src/items/tile.cpp @@ -1131,6 +1131,10 @@ void Tile::addThing(int32_t, const std::shared_ptr &thing) { } } + if (item->getID() == ITEM_WATERBALL_SPLASH && !hasFlag(TILESTATE_TRASHHOLDER)) { + item->setID(ITEM_WATERBALL); + } + items = makeItemList(); items->insert(items->getBeginDownItem(), item); items->increaseDownItemCount(); diff --git a/src/items/trashholder.cpp b/src/items/trashholder.cpp index df42888..8305524 100644 --- a/src/items/trashholder.cpp +++ b/src/items/trashholder.cpp @@ -76,6 +76,16 @@ void TrashHolder::addThing(int32_t, const std::shared_ptr &thing) { if (item->isCarpet() || item->getID() == ITEM_DECORATION_KIT) { return; } + + if(item->getID() == ITEM_WATERBALL_SPLASH) { + return; + } + + if (item->getID() == ITEM_WATERBALL) { + g_game().transformItem(item, ITEM_WATERBALL_SPLASH); + return; + } + g_game().internalRemoveItem(item); if (it.magicEffect != CONST_ME_NONE) { diff --git a/src/lua/functions/core/game/lua_enums.cpp b/src/lua/functions/core/game/lua_enums.cpp index 82bfd89..8aa8a4b 100644 --- a/src/lua/functions/core/game/lua_enums.cpp +++ b/src/lua/functions/core/game/lua_enums.cpp @@ -914,6 +914,9 @@ void LuaEnums::initItemIdEnums(lua_State* L) { registerEnum(L, ITEM_PRIMAL_POD); registerEnum(L, ITEM_DECORATION_KIT); + registerEnum(L, ITEM_WATERBALL); + registerEnum(L, ITEM_WATERBALL_SPLASH); + registerEnum(L, ItemID_t::HIRELING_LAMP); } diff --git a/src/utils/utils_definitions.hpp b/src/utils/utils_definitions.hpp index affb98c..f472a7b 100644 --- a/src/utils/utils_definitions.hpp +++ b/src/utils/utils_definitions.hpp @@ -642,6 +642,9 @@ enum ItemID_t : uint16_t { ITEM_LESSER_FRAGMENT = 46625, ITEM_GREATER_FRAGMENT = 46626, + ITEM_WATERBALL_SPLASH = 619, + ITEM_WATERBALL = 893, + ITEM_NONE = 0 };