Skip to content

Commit

Permalink
* Fixed water bug in houses opentibiabr/canary#3039
Browse files Browse the repository at this point in the history
NOTE: You need to remove house water tiles in your map for it to load water properly.
  • Loading branch information
jprzimba committed Dec 15, 2024
1 parent 6e4454f commit cb87ea6
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 2 deletions.
30 changes: 30 additions & 0 deletions data-global/scripts/creaturescripts/customs/water_houses.lua
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 2 additions & 2 deletions data-global/world/world-house.xml
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@
<house name="Quay 1" houseid="3636" entryx="33885" entryy="31552" entryz="7" rent="200000" townid="22" size="81" clientid="0" beds="4" />
<house name="Quay 2" houseid="3637" entryx="33896" entryy="31544" entryz="7" rent="200000" townid="22" size="130" clientid="0" beds="3" />
<house name="Halls of Sun and Sea" houseid="3638" entryx="33909" entryy="31535" entryz="7" rent="1000000" guildhall="true" townid="22" size="423" clientid="0" beds="15" />
<house name="Palace Vicinity" houseid="3639" entryx="33866" entryy="31516" entryz="7" rent="200000" townid="22" size="132" clientid="0" beds="4" />
<house name="Palace Vicinity" houseid="3639" entryx="33866" entryy="31516" entryz="7" rent="200000" townid="22" size="129" clientid="0" beds="4" />
<house name="Wave Tower" houseid="3640" entryx="33879" entryy="31525" entryz="7" rent="400000" townid="22" size="212" clientid="0" beds="6" />
<house name="Old Sanctuary of God King Qjell" houseid="3641" entryx="33473" entryy="31310" entryz="9" rent="300000" townid="18" size="699" clientid="0" beds="6" />
<house name="Old Heritage Estate" houseid="3642" entryx="33598" entryy="31909" entryz="6" rent="600000" townid="20" size="335" clientid="0" beds="7" />
Expand All @@ -952,7 +952,7 @@
<house name="Wallside Lane 2" houseid="3651" entryx="33637" entryy="31928" entryz="6" rent="600000" townid="20" size="227" clientid="0" beds="4" />
<house name="Vanward Flats B" houseid="3652" entryx="33614" entryy="31935" entryz="6" rent="400000" townid="20" size="179" clientid="0" beds="4" />
<house name="Vanward Flats A" houseid="3653" entryx="33621" entryy="31935" entryz="6" rent="400000" townid="20" size="189" clientid="0" beds="4" />
<house name="Bronze Brothers Bastion" houseid="3654" entryx="33599" entryy="31933" entryz="6" rent="5000000" guildhall="true" townid="20" size="976" clientid="0" beds="16" />
<house name="Bronze Brothers Bastion" houseid="3654" entryx="33599" entryy="31933" entryz="6" rent="5000000" guildhall="true" townid="20" size="945" clientid="0" beds="16" />
<house name="Cistern Ave" houseid="3655" entryx="33588" entryy="31926" entryz="6" rent="300000" townid="20" size="111" clientid="0" beds="2" />
<house name="Antimony Lane 4" houseid="3656" entryx="33614" entryy="31922" entryz="6" rent="400000" townid="20" size="159" clientid="0" beds="3" />
<house name="Antimony Lane 3" houseid="3657" entryx="33630" entryy="31921" entryz="6" rent="400000" townid="20" size="101" clientid="0" beds="3" />
Expand Down
4 changes: 4 additions & 0 deletions src/items/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,10 @@ void Tile::addThing(int32_t, const std::shared_ptr<Thing> &thing) {
}
}

if (item->getID() == ITEM_WATERBALL_SPLASH && !hasFlag(TILESTATE_TRASHHOLDER)) {
item->setID(ITEM_WATERBALL);
}

items = makeItemList();
items->insert(items->getBeginDownItem(), item);
items->increaseDownItemCount();
Expand Down
10 changes: 10 additions & 0 deletions src/items/trashholder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ void TrashHolder::addThing(int32_t, const std::shared_ptr<Thing> &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) {
Expand Down
3 changes: 3 additions & 0 deletions src/lua/functions/core/game/lua_enums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 3 additions & 0 deletions src/utils/utils_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down

0 comments on commit cb87ea6

Please sign in to comment.